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<Interface_<BinaryPolarization> >;

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.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11593 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Miklos Vajna 2009-08-16 21:44:05 +00:00
commit b5c49c20fd

View file

@ -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");