[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)
|
||||
===========================
|
||||
|
||||
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)
|
||||
Printf(output, "\t\t$r=%s;\n", invoke);
|
||||
if (Len(ret_types) == 1) {
|
||||
/* If it has an abstract base, then we can't create a new
|
||||
* base object. */
|
||||
int hasabstractbase = 0;
|
||||
Node *bases = Getattr(Swig_methodclass(n), "bases");
|
||||
if (bases) {
|
||||
Iterator i = First(bases);
|
||||
while(i.item) {
|
||||
if (Getattr(i.item, "abstract")) {
|
||||
hasabstractbase = 1;
|
||||
break;
|
||||
}
|
||||
i = Next(i);
|
||||
}
|
||||
/* If d is abstract we can't create a new wrapper type d. */
|
||||
Node * d_class = classLookup(d);
|
||||
int is_abstract = 0;
|
||||
if (Getattr(d_class, "abstract")) {
|
||||
is_abstract = 1;
|
||||
}
|
||||
if (newobject || !hasabstractbase) {
|
||||
/*
|
||||
* _p_Foo -> Foo, _p_ns__Bar -> Bar
|
||||
* TODO: do this in a more elegant way
|
||||
*/
|
||||
if (newobject || !is_abstract) {
|
||||
Printf(output, "\t\tif (is_resource($r)) {\n");
|
||||
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) {
|
||||
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 {
|
||||
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\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");
|
||||
Printf(output, "\t\t\tif (class_exists($c)) return new $c($r);\n");
|
||||
Printf(output, "\t\t\treturn new %s%s($r);\n", prefix, Getattr(classLookup(d), "sym:name"));
|
||||
} else {
|
||||
Printf(output, "\t\t\t$c = new stdClass();\n");
|
||||
Printf(output, "\t\t\t$c->"SWIG_PTR" = $r;\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue