director method tagging simplification
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4572 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6ec42cda59
commit
ebbc33f90b
4 changed files with 26 additions and 70 deletions
|
|
@ -1,5 +1,15 @@
|
||||||
Version 1.3.18 (In progress)
|
Version 1.3.18 (In progress)
|
||||||
============================
|
============================
|
||||||
|
03/18/2003: mrose (Mark Rose)
|
||||||
|
Removed code related to tagging individual methods for directors.
|
||||||
|
The concept of having directors for some but not all virtual methods
|
||||||
|
of a class is deeply flawed. The %feature("nodirector") tag is also
|
||||||
|
gone.
|
||||||
|
|
||||||
|
Directors are off by default. To enable them for a class, issue
|
||||||
|
%feature("director") classname; which will create director methods
|
||||||
|
for every virtual method in the hierarchy of the class.
|
||||||
|
|
||||||
03/17/2003: beazley
|
03/17/2003: beazley
|
||||||
Fixed a subtle problem with passing arguments of type function. For
|
Fixed a subtle problem with passing arguments of type function. For
|
||||||
example:
|
example:
|
||||||
|
|
|
||||||
|
|
@ -1343,24 +1343,7 @@ int Language::classDirectorDefaultConstructor(Node *n) {
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
|
||||||
* Language::tagDirectorBases()
|
|
||||||
* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
int Language::tagDirectorBases(Node *n) {
|
|
||||||
List* bl;
|
|
||||||
if (Getattr(n, "directorBase")) return SWIG_OK;
|
|
||||||
if (Getattr(n, "hasVirtual") == 0) return SWIG_OK;
|
|
||||||
Setattr(n, "directorBase", "1");
|
|
||||||
bl = Getattr(n, "bases");
|
|
||||||
if (bl) {
|
|
||||||
Node* bi;
|
|
||||||
for (bi = Firstitem(bl); bi; bi = Nextitem(bl)) {
|
|
||||||
tagDirectorBases(bi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return SWIG_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
* Language::unrollVirtualMethods()
|
* Language::unrollVirtualMethods()
|
||||||
|
|
@ -1370,31 +1353,19 @@ int Language::unrollVirtualMethods(Node *n,
|
||||||
Node *parent,
|
Node *parent,
|
||||||
Hash *vm,
|
Hash *vm,
|
||||||
int default_director,
|
int default_director,
|
||||||
int &virtual_destructor,
|
int &virtual_destructor) {
|
||||||
int &has_virtual) {
|
|
||||||
int only_virtual = (Getattr(parent, "director:nonvirtual") == 0);
|
|
||||||
int top = (n == parent);
|
int top = (n == parent);
|
||||||
has_virtual = 0;
|
|
||||||
Node *ni;
|
Node *ni;
|
||||||
String *nodeType;
|
String *nodeType;
|
||||||
String *storage;
|
String *storage;
|
||||||
String *classname;
|
String *classname;
|
||||||
String *decl;
|
String *decl;
|
||||||
// default_director < 0 turns off director generation for this class and all its superclasses
|
|
||||||
if (default_director >= 0) {
|
|
||||||
if (Getattr(n, "feature:director")) default_director = 1;
|
|
||||||
if (Getattr(n, "feature:nodirector")) default_director = -1;
|
|
||||||
}
|
|
||||||
// recurse through all base classes to build the vtable
|
// recurse through all base classes to build the vtable
|
||||||
List* bl = Getattr(n, "bases");
|
List* bl = Getattr(n, "bases");
|
||||||
if (bl) {
|
if (bl) {
|
||||||
Node* bi;
|
Node* bi;
|
||||||
for (bi = Firstitem(bl); bi; bi = Nextitem(bl)) {
|
for (bi = Firstitem(bl); bi; bi = Nextitem(bl)) {
|
||||||
int virtual_base = 0;
|
unrollVirtualMethods(bi, parent, vm, default_director, virtual_destructor);
|
||||||
unrollVirtualMethods(bi, parent, vm, default_director, virtual_destructor, virtual_base);
|
|
||||||
if (virtual_base) {
|
|
||||||
has_virtual = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// find the methods that need directors
|
// find the methods that need directors
|
||||||
|
|
@ -1405,28 +1376,12 @@ int Language::unrollVirtualMethods(Node *n,
|
||||||
decl = Getattr(ni, "decl");
|
decl = Getattr(ni, "decl");
|
||||||
if (!Cmp(nodeType, "cdecl") && SwigType_isfunction(decl)) {
|
if (!Cmp(nodeType, "cdecl") && SwigType_isfunction(decl)) {
|
||||||
int is_virtual = storage && !Cmp(storage, "virtual");
|
int is_virtual = storage && !Cmp(storage, "virtual");
|
||||||
if (is_virtual) has_virtual = 1;
|
|
||||||
String* access = Getattr(ni, "access");
|
String* access = Getattr(ni, "access");
|
||||||
if (!access || !Cmp(access, "public")) {
|
if (!access || !Cmp(access, "public")) {
|
||||||
if (!only_virtual || is_virtual) {
|
if (is_virtual) {
|
||||||
String *method_id;
|
String *method_id;
|
||||||
String *name = Getattr(ni, "name");
|
String *name = Getattr(ni, "name");
|
||||||
method_id = NewStringf("%s|%s", name, decl);
|
method_id = NewStringf("%s|%s", name, decl);
|
||||||
int director = default_director;
|
|
||||||
if (director >= 0) {
|
|
||||||
if (Getattr(ni, "feature:director")) director = 1;
|
|
||||||
if (Getattr(ni, "feature:nodirector")) director = 0;
|
|
||||||
}
|
|
||||||
// if this method has a director in a base class, we must
|
|
||||||
// either override it or remove it (otherwise the director
|
|
||||||
// method will use the wrong class for superclass calls)
|
|
||||||
if (Getattr(vm, method_id)) {
|
|
||||||
if (director == 0) director = 1;
|
|
||||||
else if (director < 0) {
|
|
||||||
Delattr(vm, method_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (director == 1) {
|
|
||||||
String *fqname = NewString("");
|
String *fqname = NewString("");
|
||||||
Printf(fqname, "%s::%s", classname, name);
|
Printf(fqname, "%s::%s", classname, name);
|
||||||
Hash *item = NewHash();
|
Hash *item = NewHash();
|
||||||
|
|
@ -1435,7 +1390,6 @@ int Language::unrollVirtualMethods(Node *n,
|
||||||
Setattr(vm, method_id, item);
|
Setattr(vm, method_id, item);
|
||||||
Delete(fqname);
|
Delete(fqname);
|
||||||
Delete(item);
|
Delete(item);
|
||||||
}
|
|
||||||
Delete(method_id);
|
Delete(method_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1448,9 +1402,6 @@ int Language::unrollVirtualMethods(Node *n,
|
||||||
else {
|
else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (has_virtual) {
|
|
||||||
Setattr(n, "hasVirtual", "1");
|
|
||||||
}
|
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1565,8 +1516,7 @@ int Language::classDirector(Node *n) {
|
||||||
}
|
}
|
||||||
Hash* vtable = NewHash();
|
Hash* vtable = NewHash();
|
||||||
int virtual_destructor = 0;
|
int virtual_destructor = 0;
|
||||||
int has_virtual = 0;
|
unrollVirtualMethods(n, n, vtable, 0, virtual_destructor);
|
||||||
unrollVirtualMethods(n, n, vtable, 0, virtual_destructor, has_virtual);
|
|
||||||
if (Len(vtable) > 0) {
|
if (Len(vtable) > 0) {
|
||||||
if (!virtual_destructor) {
|
if (!virtual_destructor) {
|
||||||
String *classtype = Getattr(n, "classtype");
|
String *classtype = Getattr(n, "classtype");
|
||||||
|
|
@ -1575,7 +1525,6 @@ int Language::classDirector(Node *n) {
|
||||||
classtype);
|
classtype);
|
||||||
}
|
}
|
||||||
Setattr(n, "vtable", vtable);
|
Setattr(n, "vtable", vtable);
|
||||||
tagDirectorBases(n);
|
|
||||||
classDirectorInit(n);
|
classDirectorInit(n);
|
||||||
classDirectorConstructors(n);
|
classDirectorConstructors(n);
|
||||||
classDirectorMethods(n);
|
classDirectorMethods(n);
|
||||||
|
|
@ -1646,7 +1595,7 @@ int Language::classDeclaration(Node *n) {
|
||||||
|
|
||||||
/* Call classHandler() here */
|
/* Call classHandler() here */
|
||||||
if (!ImportMode) {
|
if (!ImportMode) {
|
||||||
if (directorsEnabled()) {
|
if (directorsEnabled() && Getattr(n, "feature:director")) {
|
||||||
classDirector(n);
|
classDirector(n);
|
||||||
}
|
}
|
||||||
classHandler(n);
|
classHandler(n);
|
||||||
|
|
|
||||||
|
|
@ -657,7 +657,6 @@ public:
|
||||||
int director = Swig_directormethod(n);
|
int director = Swig_directormethod(n);
|
||||||
int directorbase = Swig_directorbase(n);
|
int directorbase = Swig_directorbase(n);
|
||||||
Node *classNode = Swig_methodclass(n);
|
Node *classNode = Swig_methodclass(n);
|
||||||
int hasVirtual = (classNode && (Getattr(classNode, "hasVirtual") != 0));
|
|
||||||
String *nodeType = Getattr(n, "nodeType");
|
String *nodeType = Getattr(n, "nodeType");
|
||||||
int constructor = (!Cmp(nodeType, "constructor"));
|
int constructor = (!Cmp(nodeType, "constructor"));
|
||||||
String *storage = Getattr(n,"storage");
|
String *storage = Getattr(n,"storage");
|
||||||
|
|
@ -873,7 +872,7 @@ public:
|
||||||
|
|
||||||
if (directorsEnabled()) {
|
if (directorsEnabled()) {
|
||||||
if (!is_smart_pointer()) {
|
if (!is_smart_pointer()) {
|
||||||
if (/*directorbase &&*/ hasVirtual && !constructor && isVirtual) {
|
if (/*directorbase &&*/ !constructor && isVirtual) {
|
||||||
Wrapper_add_local(f, "director", "__DIRECTOR__ *director = 0");
|
Wrapper_add_local(f, "director", "__DIRECTOR__ *director = 0");
|
||||||
Printf(f->code, "director = dynamic_cast<__DIRECTOR__*>(arg1);\n");
|
Printf(f->code, "director = dynamic_cast<__DIRECTOR__*>(arg1);\n");
|
||||||
Printf(f->code, "if (director && (director->__get_self()==obj0)) director->__set_up();\n");
|
Printf(f->code, "if (director && (director->__get_self()==obj0)) director->__set_up();\n");
|
||||||
|
|
@ -1459,7 +1458,7 @@ public:
|
||||||
} else {
|
} else {
|
||||||
if (is_void) {
|
if (is_void) {
|
||||||
Printf(w->code, "%s;\n", Swig_method_call(super,l));
|
Printf(w->code, "%s;\n", Swig_method_call(super,l));
|
||||||
Printf(w->code, "return;\n", Swig_method_call(super,l));
|
Printf(w->code, "return;\n");
|
||||||
} else {
|
} else {
|
||||||
Printf(w->code, "return %s;\n", Swig_method_call(super,l));
|
Printf(w->code, "return %s;\n", Swig_method_call(super,l));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -182,13 +182,11 @@ public:
|
||||||
virtual int classDirector(Node *n);
|
virtual int classDirector(Node *n);
|
||||||
virtual int classDirectorInit(Node *n);
|
virtual int classDirectorInit(Node *n);
|
||||||
virtual int classDirectorEnd(Node *n);
|
virtual int classDirectorEnd(Node *n);
|
||||||
virtual int tagDirectorBases(Node *n);
|
|
||||||
virtual int unrollVirtualMethods(Node *n,
|
virtual int unrollVirtualMethods(Node *n,
|
||||||
Node *parent,
|
Node *parent,
|
||||||
Hash *vm,
|
Hash *vm,
|
||||||
int default_director,
|
int default_director,
|
||||||
int &virtual_destructor,
|
int &virtual_destructor);
|
||||||
int &has_virtual);
|
|
||||||
virtual int classDirectorConstructor(Node *n);
|
virtual int classDirectorConstructor(Node *n);
|
||||||
virtual int classDirectorDefaultConstructor(Node *n);
|
virtual int classDirectorDefaultConstructor(Node *n);
|
||||||
virtual int classDirectorMethod(Node *n, Node *parent, String *super);
|
virtual int classDirectorMethod(Node *n, Node *parent, String *super);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue