View Single Post
  #23  
Old 06-22-2007, 08:58 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
I've updated your script so it calls things as you'd expect. Before onCreated was only getting called in the parent class, not both the parent then the child class.

Here:

PHP Code:
public function maketype(typenamesuperclasses) {
  
temp.0;
  
  if ((@
"T"@typename) != null) {
    (@
"T"@typename).destroy();
  }
  
  
this.(@ "type_" typename) = (super.type() == 2) ? new super("T"@typename) : new TStaticVar("T"@typename);
  
  
  for (
iclasses) {
    
this.(@ "type_" typename).join(i);
    
  }

  
  if (
this.types.index("T"@typename) < 0) {
    
this.types.add("T"@typename);
  }
  

I actually did this in an attempt to get function inheritance working, but I don't think that it's possible using this method because theres no way to know from what class in the original object to inherit from. You use parentobject.joinedclasses[0] but this wont work:

parent::function

where parent is a string variable because it expects a class name before ::.


edit:


Although that does the onCreateds in the right order, when you go to call a function on the object it will look for it in the parent class first. This is a problem, I don't think it's possible to have onCreated's in the correct order *and* have function calling work upwards.

So either: onCreated gets called in the child then the parent and functions get called in the parent when the same function name exists in both the parent and the child
or: onCreated gets called in the parent then the child (as you'd hope) and functions are looked for in the parent before the child.
__________________

Coming soon (Hopefully:P)

Last edited by JkWhoSaysNi; 06-22-2007 at 09:51 PM..
Reply With Quote