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:
parent
6f80e2f7a6
commit
e068305125
1 changed files with 6 additions and 2 deletions
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue