sorry, last commit was from an older version

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5669 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2004-01-22 07:17:05 +00:00
commit d02ce4b533

View file

@ -1466,12 +1466,18 @@ int Language::unrollVirtualMethods(Node *n,
Node *method_id = NewStringf("%s|%s", name, local_decl); Node *method_id = NewStringf("%s|%s", name, local_decl);
/* Make sure that the new method overwrites the existing: */ /* Make sure that the new method overwrites the existing: */
Hash *exists_item = Getattr(vm, method_id); Hash *exists_item = Getattr(vm, method_id);
if (exists_item) Delattr(vm, method_id); if (exists_item) {
/* filling a new method item */ /* maybe we should check for precedence here, ie, only
String *fqname = NewStringf("%s::%s", classname, name); delete the previous method if 'n' is derived from the
previous method parent node. This is almost always true,
so by now, we just delete the entry. */
Delattr(vm, method_id);
}
/* filling a new method item */
String *fqname = NewStringf("%s::%s", classname, name);
Hash *item = NewHash(); Hash *item = NewHash();
Setattr(item, "fqName", fqname); Setattr(item, "fqName", fqname);
Setattr(item, "methodNode", ni); Setattr(item, "methodNode", Copy(ni));
Setattr(vm, method_id, item); Setattr(vm, method_id, item);
Delete(fqname); Delete(fqname);
Delete(item); Delete(item);
@ -1484,33 +1490,61 @@ int Language::unrollVirtualMethods(Node *n,
} }
/* /*
We delete all the nodirector methods. This prevents the We delete all the nodirector methods. This prevents the
generation of 'empty' director classes. generation of 'empty' director classes.
But this has to be done outside the previous loop!. But this has to be done outside the previous 'for'
*/ an the recursive loop!.
Iterator k; */
for (k = First(vm); k.key; k = Next(k)) { if (n == parent) {
Node *m = Getattr(k.item, "methodNode"); Iterator k;
int mdir = !Cmp(Getattr(m, "feature:director"), "1"); for (k = First(vm); k.key; k = Next(k)) {
int mnodir = !Cmp(Getattr(m, "feature:nodirector"), "1"); Node *m = Getattr(k.item, "methodNode");
/* defines if we need director method */ /* retrieve the director features */
int dir = (mdir || !mnodir); int mdir = checkAttribute(m, "feature:director", "1");
Node *pm = Getattr(m, "parentNode"); int mndir = checkAttribute(m, "feature:nodirector", "1");
if (pm != parent) { /* 'nodirector' has precedence over 'director' */
/* check the method found in vtable against my method features */ int dir = (mdir || mndir) ? (mdir && !mndir) : 1;
Node *c = Copy(m); /* check if the method was found only in a base class */
Setattr(c,"parentNode", parent); Node *p = Getattr(m, "parentNode");
Setattr(c,"sym:symtab", Getattr(parent,"symtab")); if (p != n) {
int cdir = !Cmp(Getattr(c, "feature:director"), "1"); /* check for my own features to take precedence, ie, if I only
int cnodir = !Cmp(Getattr(c, "feature:nodirector"), "1"); found Base::method(), look for MySelf::method() features.
dir = (cdir || cnodir) ? (cdir || !cnodir) : dir;
Delete(c); The problem is that MySelf::method() is not declared in the
} MySelf class, and appears here through derivation:
if (dir) {
if (mnodir) Delattr(m, "feature:nodirector"); %feature("nodirector") Base::method();
} else { %feature("director") MySelf::method();
Delattr(vm, k.key);
struct Base {
virtual ~Base();
virtual int method();
};
struct MySelf : Base {
};
*** Ask David, this is not working now!!! *****
This is now just giving back the Base::method() features,
maybe we need to look directly in the feature hash
table?...
*/
Node *c = Copy(m);
Setattr(c, "parentNode", n);
int cdir = checkAttribute(c, "feature:director", "1");
int cndir = checkAttribute(c, "feature:nodirector", "1");
dir = (cdir || cndir) ? (cdir && !cndir) : dir;
Delete(c);
}
if (dir) {
/* be sure the 'nodirector' feature is disabled */
if (mndir) Delattr(m, "feature:nodirector");
} else {
/* or just delete from the vm, since is not a director method */
Delattr(vm, k.key);
}
} }
} }