From 5bac49bafc3a1a22cdea7bab421ea480bf03ac81 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Aug 2009 14:53:33 +0200 Subject: [PATCH] PHP: fix for the valuewrapper_base testcase The problem is the following: before director support, the return class type of a function was hardwired. That was bad, as factory functions wanted to instantiate abstract classes, so we switched to detecting the class type based on the PHP resource type. That was good, but broke the case when for example %template(make_Interface_BP) make >; was used, as the cheap parser had no idea how to turn 'Interface_T_oss__BinaryPolarization_t' to 'make_Interface_BP'. This patch still uses the resource type detection, but in case that would result in a non-existing class, we just use the hardwired name. NOTE: This still does not fix the case when abstract classes are used with templates. --- Source/Modules/php.cxx | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index dc7f863..72ba4d4 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1683,6 +1683,9 @@ public: } 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\t$c = '%s';\n", Getattr(classLookup(d), "sym:name")); + Printf(output, "\t\t\t}\n"); Printf(output, "\t\t\treturn new $c($r);\n"); } else { Printf(output, "\t\t\t$c = new stdClass();\n"); -- 1.6.3.3