Fix wrapping of methods and functions which return a pointer to a
class (bug#1700788) and those which have overloaded forms returning
both classes and non-classes (bug#1712717, thanks to Simon
Berthiaume for the patch).


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9838 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2007-05-26 11:38:18 +00:00
commit dc61936359
2 changed files with 19 additions and 1 deletions

View file

@ -1833,6 +1833,14 @@ public:
String *mangled = NewString("_p");
Printf(mangled, "%s", SwigType_manglestr(ret_type));
Node *class_node = Getattr(zend_types, mangled);
if (!class_node) {
/* This is needed when we're returning a pointer to a type
* rather than returning the type by value or reference. */
class_node = current_class;
Delete(mangled);
mangled = NewString(SwigType_manglestr(ret_type));
class_node = Getattr(zend_types, mangled);
}
if (i.item) {
Printf(output, "case \"%s\": ", mangled);
} else {
@ -1841,7 +1849,10 @@ public:
const char *classname = GetChar(class_node, "sym:name");
if (!classname)
classname = GetChar(class_node, "name");
Printf(output, "return new %s%s($r);\n", prefix, classname);
if (classname)
Printf(output, "return new %s%s($r);\n", prefix, classname);
else
Printf(output, "return $r;\n");
Delete(mangled);
}
Printf(output, "\t\t}\n");