summaryrefslogtreecommitdiff
path: root/Source/Modules/php.cxx
diff options
context:
space:
mode:
authorOlly Betts <olly@survex.com>2011-05-24 14:51:59 +0000
committerOlly Betts <olly@survex.com>2011-05-24 14:51:59 +0000
commit1d7f309a8a3b46582334ac0846b8981425d313b5 (patch)
tree355057088722521bf9ff118a4f149911fe3b1c96 /Source/Modules/php.cxx
parentf38530b4900f39213d277f880deee2ff7df1974b (diff)
downloadswig-1d7f309a8a3b46582334ac0846b8981425d313b5.tar.gz
[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
Diffstat (limited to 'Source/Modules/php.cxx')
-rw-r--r--Source/Modules/php.cxx34
1 files changed, 12 insertions, 22 deletions
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index a304946e7..09d6c5730 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -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");