If there's no prefix, special case to avoid prepending an empty string.

Don't calculate $class in the stdClass case when we don't need it.
Eliminate an unnecessary else.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11563 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2009-08-14 07:53:38 +00:00
commit e068305125

View file

@ -1651,15 +1651,19 @@ public:
* TODO: do this in a more elegant way
*/
Printf(output, "\t\tif (is_resource($r)) {\n");
Printf(output, "\t\t\t$class='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix);
if (Getattr(classLookup(Getattr(n, "type")), "module")) {
if (Len(prefix) == 0) {
Printf(output, "\t\t\t$class=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n");
} else {
Printf(output, "\t\t\t$class='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix);
}
Printf(output, "\t\t\treturn new $class($r);\n");
} else {
Printf(output, "\t\t\t$c = new stdClass();\n");
Printf(output, "\t\t\t$c->_cPtr = $r;\n");
Printf(output, "\t\t\treturn $c;\n");
}
Printf(output, "\t\t}\n\t\telse return $r;\n");
Printf(output, "\t\t}\n\t\treturn $r;\n");
} else {
Printf(output, "\t\t$this->%s = $r;\n", SWIG_PTR);
Printf(output, "\t\treturn $this;\n");