Merged trunk up to revision 12426

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12427 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Stefan Zager 2011-02-03 19:30:45 +00:00
commit 52a807ce95
16 changed files with 216 additions and 27 deletions

View file

@ -2292,17 +2292,24 @@ public:
String *ex_imcall = Copy(imcall);
Replaceall(ex_imcall, "$imfuncname", ex_intermediary_function_name);
Replaceall(imcall, "$imfuncname", intermediary_function_name);
String *excode = NewString("");
if (!Cmp(return_type, "void"))
Printf(excode, "if (this.GetType() == typeof(%s)) %s; else %s", proxy_class_name, imcall, ex_imcall);
else
Printf(excode, "((this.GetType() == typeof(%s)) ? %s : %s)", proxy_class_name, imcall, ex_imcall);
Node *directorNode = Getattr(n, "directorNode");
if (directorNode) {
UpcallData *udata = Getattr(directorNode, "upcalldata");
String *methid = Getattr(udata, "class_methodidx");
Clear(imcall);
Printv(imcall, excode, NIL);
Delete(ex_overloaded_name);
if (!Cmp(return_type, "void"))
Printf(excode, "if (SwigDerivedClassHasMethod(\"%s\", swigMethodTypes%s)) %s; else %s", proxy_function_name, methid, ex_imcall, imcall);
else
Printf(excode, "(SwigDerivedClassHasMethod(\"%s\", swigMethodTypes%s) ? %s : %s)", proxy_function_name, methid, ex_imcall, imcall);
Clear(imcall);
Printv(imcall, excode, NIL);
} else {
// probably an ignored method or nodirector
}
Delete(excode);
Delete(ex_overloaded_name);
} else {
Replaceall(imcall, "$imfuncname", intermediary_function_name);
}
@ -3869,6 +3876,10 @@ public:
/* Emit the actual upcall through */
UpcallData *udata = addUpcallMethod(imclass_dmethod, symname, decl, overloaded_name);
String *methid = Getattr(udata, "class_methodidx");
Setattr(n, "upcalldata", udata);
/*
Printf(stdout, "setting upcalldata, nodeType: %s %s::%s %p\n", nodeType(n), classname, Getattr(n, "name"), n);
*/
Printf(director_callback_typedefs, " typedef %s (SWIGSTDCALL* SWIG_Callback%s_t)(", c_ret_type, methid);
Printf(director_callback_typedefs, "%s);\n", callback_typedef_parms);

View file

@ -1806,17 +1806,25 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
classname = Getattr(n, "name");
for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) {
/* we only need to check the virtual members */
if (!checkAttribute(ni, "storage", "virtual"))
continue;
nodeType = Getattr(ni, "nodeType");
int is_using = (Cmp(nodeType, "using") == 0);
Node *nn = is_using ? firstChild(ni) : ni; /* assume there is only one child node for "using" nodes */
if (is_using) {
if (nn)
nodeType = Getattr(nn, "nodeType");
else
continue; // A private "using" node
}
if (!checkAttribute(nn, "storage", "virtual"))
continue;
/* we need to add methods(cdecl) and destructor (to check for throw decl) */
int is_destructor = (Cmp(nodeType, "destructor") == 0);
if ((Cmp(nodeType, "cdecl") == 0) || is_destructor) {
decl = Getattr(ni, "decl");
decl = Getattr(nn, "decl");
/* extra check for function type and proper access */
if (SwigType_isfunction(decl) && (((!protectedbase || dirprot_mode()) && is_public(ni)) || need_nonpublic_member(ni))) {
String *name = Getattr(ni, "name");
Node *method_id = is_destructor ? NewStringf("~destructor") : vtable_method_id(ni);
if (SwigType_isfunction(decl) && (((!protectedbase || dirprot_mode()) && is_public(nn)) || need_nonpublic_member(nn))) {
String *name = Getattr(nn, "name");
Node *method_id = is_destructor ? NewStringf("~destructor") : vtable_method_id(nn);
/* Make sure that the new method overwrites the existing: */
int len = Len(vm);
const int DO_NOT_REPLACE = -1;
@ -1834,7 +1842,7 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
String *fqdname = NewStringf("%s::%s", classname, name);
Hash *item = NewHash();
Setattr(item, "fqdname", fqdname);
Node *m = Copy(ni);
Node *m = Copy(nn);
/* Store the complete return type - needed for non-simple return types (pointers, references etc.) */
SwigType *ty = NewString(Getattr(m, "type"));
@ -1854,6 +1862,7 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
Append(vm, item);
else
Setitem(vm, replace, item);
Setattr(nn, "directorNode", m);
Delete(mname);
}
@ -2806,7 +2815,7 @@ int Language::validIdentifier(String *s) {
* ----------------------------------------------------------------------------- */
int Language::usingDeclaration(Node *n) {
if ((cplus_mode == PUBLIC)) {
if ((cplus_mode == PUBLIC) || (!is_public(n) && dirprot_mode())) {
Node *np = Copy(n);
Node *c;
for (c = firstChild(np); c; c = nextSibling(c)) {

View file

@ -999,6 +999,7 @@ class TypePass:private Dispatcher {
}
Node *nn = copyNode(c);
Delattr(nn, "access"); // access might be different from the method in the base class
Setattr(nn, "access", Getattr(n, "access"));
if (!Getattr(nn, "sym:name"))
Setattr(nn, "sym:name", symname);

View file

@ -1000,7 +1000,7 @@ int Swig_need_redefined_warn(Node *a, Node *b, int InClass) {
* This is basically any protected members when the allprotected mode is set.
* Otherwise we take just the protected virtual methods and non-static methods
* (potentially virtual methods) as well as constructors/destructors.
*
* Also any "using" statements in a class may potentially be virtual.
* ----------------------------------------------------------------------------- */
int Swig_need_protected(Node *n) {
@ -1017,6 +1017,8 @@ int Swig_need_protected(Node *n) {
}
} else if (Equal(nodetype, "constructor") || Equal(nodetype, "destructor")) {
return 1;
} else if (Equal(nodetype, "using") && !Getattr(n, "namespace")) {
return 1;
}
}
return 0;