[PHP] Fix code generated for feature("director:except")
Previously the return value of call_user_function() was ignored and we checked an uninitialised value instead. Fixes #627. Based on patch from Sergey Seroshtan.
This commit is contained in:
parent
0769e9b727
commit
1adfe2f537
3 changed files with 26 additions and 0 deletions
|
|
@ -5,6 +5,12 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 3.0.11 (in progress)
|
Version 3.0.11 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
2016-09-24: olly
|
||||||
|
[PHP] Fix code generated for feature("director:except") -
|
||||||
|
previously the return value of call_user_function() was ignored and
|
||||||
|
we checked an uninitialised value instead. Fixes #627. Based on
|
||||||
|
patch from Sergey Seroshtan.
|
||||||
|
|
||||||
2016-09-17: wsfulton
|
2016-09-17: wsfulton
|
||||||
[Python] Fix iterators for containers of NULL pointers (or Python None) when using
|
[Python] Fix iterators for containers of NULL pointers (or Python None) when using
|
||||||
-builtin. Previously iteration would stop at the first element that was NULL.
|
-builtin. Previously iteration would stop at the first element that was NULL.
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,21 @@ class DirectorMethodException: public Swig::DirectorException {};
|
||||||
|
|
||||||
%include "std_string.i"
|
%include "std_string.i"
|
||||||
|
|
||||||
|
#ifdef SWIGPHP
|
||||||
|
|
||||||
|
%feature("director:except") {
|
||||||
|
if ($error == FAILURE) {
|
||||||
|
throw Swig::DirectorMethodException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%exception {
|
||||||
|
try { $action }
|
||||||
|
catch (Swig::DirectorException &) { SWIG_fail; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SWIGPYTHON
|
#ifdef SWIGPYTHON
|
||||||
|
|
||||||
%feature("director:except") {
|
%feature("director:except") {
|
||||||
|
|
|
||||||
|
|
@ -2625,6 +2625,7 @@ done:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* exception handling */
|
/* exception handling */
|
||||||
|
bool error_used_in_typemap = false;
|
||||||
tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0);
|
tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0);
|
||||||
if (!tm) {
|
if (!tm) {
|
||||||
tm = Getattr(n, "feature:director:except");
|
tm = Getattr(n, "feature:director:except");
|
||||||
|
|
@ -2634,6 +2635,7 @@ done:
|
||||||
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
|
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
|
||||||
if (Replaceall(tm, "$error", "error")) {
|
if (Replaceall(tm, "$error", "error")) {
|
||||||
/* Only declare error if it is used by the typemap. */
|
/* Only declare error if it is used by the typemap. */
|
||||||
|
error_used_in_typemap = true;
|
||||||
Append(w->code, "int error;\n");
|
Append(w->code, "int error;\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2657,6 +2659,9 @@ done:
|
||||||
/* wrap complex arguments to zvals */
|
/* wrap complex arguments to zvals */
|
||||||
Printv(w->code, wrap_args, NIL);
|
Printv(w->code, wrap_args, NIL);
|
||||||
|
|
||||||
|
if (error_used_in_typemap) {
|
||||||
|
Append(w->code, "error = ");
|
||||||
|
}
|
||||||
Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,");
|
Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,");
|
||||||
Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx);
|
Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue