[PHP] Fix incorrect wrapper code generation
Fix code generated when there's a combination of overloading, parameters with a default value and %newobject. Fixes https://sourceforge.net/p/swig/bugs/1350/
This commit is contained in:
parent
8be1d0e03a
commit
0c56d0cb72
2 changed files with 18 additions and 10 deletions
|
|
@ -1574,13 +1574,15 @@ public:
|
|||
Printf(prepare, "case %d: ", ++last_handled_i);
|
||||
}
|
||||
if (non_void_return) {
|
||||
if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
|
||||
if ((!directorsEnabled() || !Swig_directorclass(n)) && !constructor) {
|
||||
Append(prepare, "$r=");
|
||||
} else if (wrapperType == staticmemberfn || wrapperType == staticmembervar) {
|
||||
Append(prepare, "$r=");
|
||||
} else {
|
||||
Printf(prepare, "$this->%s=", SWIG_PTR);
|
||||
}
|
||||
}
|
||||
if (!directorsEnabled() || !Swig_directorclass(n) || !newobject) {
|
||||
if (!directorsEnabled() || !Swig_directorclass(n) || !constructor) {
|
||||
Printf(prepare, "%s(%s); break;\n", iname, invoke_args);
|
||||
} else if (!i) {
|
||||
Printf(prepare, "%s($_this%s); break;\n", iname, invoke_args);
|
||||
|
|
@ -1596,14 +1598,16 @@ public:
|
|||
if (had_a_case)
|
||||
Printf(prepare, "default: ");
|
||||
if (non_void_return) {
|
||||
if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
|
||||
if ((!directorsEnabled() || !Swig_directorclass(n)) && !constructor) {
|
||||
Append(prepare, "$r=");
|
||||
} else if (wrapperType == staticmemberfn || wrapperType == staticmembervar) {
|
||||
Append(prepare, "$r=");
|
||||
} else {
|
||||
Printf(prepare, "$this->%s=", SWIG_PTR);
|
||||
}
|
||||
}
|
||||
|
||||
if (!directorsEnabled() || !Swig_directorclass(n) || !newobject) {
|
||||
if (!directorsEnabled() || !Swig_directorclass(n) || !constructor) {
|
||||
Printf(prepare, "%s(%s);\n", iname, invoke_args);
|
||||
} else {
|
||||
Printf(prepare, "%s($_this, %s);\n", iname, invoke_args);
|
||||
|
|
@ -1713,7 +1717,7 @@ public:
|
|||
Printf(output, "\tstatic function %s(%s) {\n", methodname, args);
|
||||
}
|
||||
|
||||
if (!newobject)
|
||||
if (!constructor)
|
||||
Printf(output, "%s", prepare);
|
||||
if (constructor) {
|
||||
if (!directorsEnabled() || !Swig_directorclass(n)) {
|
||||
|
|
|
|||
|
|
@ -1560,13 +1560,15 @@ public:
|
|||
Printf(prepare, "case %d: ", ++last_handled_i);
|
||||
}
|
||||
if (non_void_return) {
|
||||
if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
|
||||
if ((!directorsEnabled() || !Swig_directorclass(n)) && !constructor) {
|
||||
Append(prepare, "$r=");
|
||||
} else if (wrapperType == staticmemberfn || wrapperType == staticmembervar) {
|
||||
Append(prepare, "$r=");
|
||||
} else {
|
||||
Printf(prepare, "$this->%s=", SWIG_PTR);
|
||||
}
|
||||
}
|
||||
if (!directorsEnabled() || !Swig_directorclass(n) || !newobject) {
|
||||
if (!directorsEnabled() || !Swig_directorclass(n) || !constructor) {
|
||||
Printf(prepare, "%s(%s); break;\n", iname, invoke_args);
|
||||
} else if (!i) {
|
||||
Printf(prepare, "%s($_this%s); break;\n", iname, invoke_args);
|
||||
|
|
@ -1582,14 +1584,16 @@ public:
|
|||
if (had_a_case)
|
||||
Printf(prepare, "default: ");
|
||||
if (non_void_return) {
|
||||
if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
|
||||
if ((!directorsEnabled() || !Swig_directorclass(n)) && !constructor) {
|
||||
Append(prepare, "$r=");
|
||||
} else if (wrapperType == staticmemberfn || wrapperType == staticmembervar) {
|
||||
Append(prepare, "$r=");
|
||||
} else {
|
||||
Printf(prepare, "$this->%s=", SWIG_PTR);
|
||||
}
|
||||
}
|
||||
|
||||
if (!directorsEnabled() || !Swig_directorclass(n) || !newobject) {
|
||||
if (!directorsEnabled() || !Swig_directorclass(n) || !constructor) {
|
||||
Printf(prepare, "%s(%s);\n", iname, invoke_args);
|
||||
} else {
|
||||
Printf(prepare, "%s($_this, %s);\n", iname, invoke_args);
|
||||
|
|
@ -1699,7 +1703,7 @@ public:
|
|||
Printf(output, "\tstatic function %s(%s) {\n", methodname, args);
|
||||
}
|
||||
|
||||
if (!newobject)
|
||||
if (!constructor)
|
||||
Printf(output, "%s", prepare);
|
||||
if (constructor) {
|
||||
if (!directorsEnabled() || !Swig_directorclass(n)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue