[PHP] Fix handling of methods of classes with a virtual base class (SF#3124665).
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12711 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
f38530b490
commit
1d7f309a8a
2 changed files with 16 additions and 22 deletions
|
|
@ -4,3 +4,7 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
|
|
||||||
Version 2.0.5 (in progress)
|
Version 2.0.5 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2011-05-24: olly
|
||||||
|
[PHP] Fix handling of methods of classes with a virtual base class (SF#3124665).
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1682,36 +1682,26 @@ public:
|
||||||
if (Cmp(invoke, "$r") != 0)
|
if (Cmp(invoke, "$r") != 0)
|
||||||
Printf(output, "\t\t$r=%s;\n", invoke);
|
Printf(output, "\t\t$r=%s;\n", invoke);
|
||||||
if (Len(ret_types) == 1) {
|
if (Len(ret_types) == 1) {
|
||||||
/* If it has an abstract base, then we can't create a new
|
/* If d is abstract we can't create a new wrapper type d. */
|
||||||
* base object. */
|
Node * d_class = classLookup(d);
|
||||||
int hasabstractbase = 0;
|
int is_abstract = 0;
|
||||||
Node *bases = Getattr(Swig_methodclass(n), "bases");
|
if (Getattr(d_class, "abstract")) {
|
||||||
if (bases) {
|
is_abstract = 1;
|
||||||
Iterator i = First(bases);
|
|
||||||
while(i.item) {
|
|
||||||
if (Getattr(i.item, "abstract")) {
|
|
||||||
hasabstractbase = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i = Next(i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (newobject || !hasabstractbase) {
|
if (newobject || !is_abstract) {
|
||||||
/*
|
|
||||||
* _p_Foo -> Foo, _p_ns__Bar -> Bar
|
|
||||||
* TODO: do this in a more elegant way
|
|
||||||
*/
|
|
||||||
Printf(output, "\t\tif (is_resource($r)) {\n");
|
Printf(output, "\t\tif (is_resource($r)) {\n");
|
||||||
if (Getattr(classLookup(Getattr(n, "type")), "module")) {
|
if (Getattr(classLookup(Getattr(n, "type")), "module")) {
|
||||||
|
/*
|
||||||
|
* _p_Foo -> Foo, _p_ns__Bar -> Bar
|
||||||
|
* TODO: do this in a more elegant way
|
||||||
|
*/
|
||||||
if (Len(prefix) == 0) {
|
if (Len(prefix) == 0) {
|
||||||
Printf(output, "\t\t\t$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n");
|
Printf(output, "\t\t\t$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n");
|
||||||
} else {
|
} else {
|
||||||
Printf(output, "\t\t\t$c='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix);
|
Printf(output, "\t\t\t$c='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix);
|
||||||
}
|
}
|
||||||
Printf(output, "\t\t\tif (!class_exists($c)) {\n");
|
Printf(output, "\t\t\tif (class_exists($c)) return new $c($r);\n");
|
||||||
Printf(output, "\t\t\t\treturn new %s%s($r);\n", prefix, Getattr(classLookup(d), "sym:name"));
|
Printf(output, "\t\t\treturn new %s%s($r);\n", prefix, Getattr(classLookup(d), "sym:name"));
|
||||||
Printf(output, "\t\t\t}\n");
|
|
||||||
Printf(output, "\t\t\treturn new $c($r);\n");
|
|
||||||
} else {
|
} else {
|
||||||
Printf(output, "\t\t\t$c = new stdClass();\n");
|
Printf(output, "\t\t\t$c = new stdClass();\n");
|
||||||
Printf(output, "\t\t\t$c->"SWIG_PTR" = $r;\n");
|
Printf(output, "\t\t\t$c->"SWIG_PTR" = $r;\n");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue