add Scott's patches for directors: void return, directormap register, better error messages
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7324 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
06adaed870
commit
83ef5241ee
3 changed files with 32 additions and 21 deletions
|
|
@ -28,15 +28,23 @@ namespace Swig {
|
||||||
try {
|
try {
|
||||||
throw;
|
throw;
|
||||||
} catch (DirectorException& e) {
|
} catch (DirectorException& e) {
|
||||||
std::cerr << "Swig Director exception caught: "<< e.getMessage() << std::endl;
|
std::cerr << "Swig Director exception caught:" << std::endl
|
||||||
|
<< e.getMessage() << std::endl;
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
std::cerr << "std::exception caught: "<< e.what() << std::endl;
|
std::cerr << "std::exception caught: "<< e.what() << std::endl;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
std::cerr << "Unknown exception caught." << std::endl;
|
std::cerr << "Unknown exception caught." << std::endl;
|
||||||
}
|
}
|
||||||
std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl;
|
|
||||||
std::cerr << "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl;
|
std::cerr << std::endl
|
||||||
std::cerr << "Now your program will probably be terminated, bye." << std::endl;
|
<< "Python interpreter traceback:" << std::endl;
|
||||||
|
PyErr_Print();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
std::cerr << "This exception was caught by the SWIG unexpected exception handler." << std::endl
|
||||||
|
<< "Try using %feature(\"director:except\") to avoid reaching this point." << std::endl
|
||||||
|
<< std::endl
|
||||||
|
<< "Exception is being re-thrown, program will like abort/terminate." << std::endl;
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1884,19 +1884,15 @@ int Language::classDirector(Node *n) {
|
||||||
"Director base class %s has no virtual destructor.\n",
|
"Director base class %s has no virtual destructor.\n",
|
||||||
classtype);
|
classtype);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
since now %feature("nodirector") is working, we check
|
|
||||||
that the director is really not abstract.
|
|
||||||
*/
|
|
||||||
|
|
||||||
Setattr(n, "vtable", vtable);
|
Setattr(n, "vtable", vtable);
|
||||||
|
if (directormap != 0) {
|
||||||
|
Setattr(directormap, classtype, n);
|
||||||
|
}
|
||||||
classDirectorInit(n);
|
classDirectorInit(n);
|
||||||
classDirectorConstructors(n);
|
classDirectorConstructors(n);
|
||||||
classDirectorMethods(n);
|
classDirectorMethods(n);
|
||||||
classDirectorEnd(n);
|
classDirectorEnd(n);
|
||||||
if (directormap != 0) {
|
|
||||||
Setattr(directormap, classtype, n);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Delete(vtable);
|
Delete(vtable);
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
|
|
|
||||||
|
|
@ -2621,8 +2621,6 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
||||||
Swig_typemap_attach_parms("directorargout", l, w);
|
Swig_typemap_attach_parms("directorargout", l, w);
|
||||||
|
|
||||||
Parm* p;
|
Parm* p;
|
||||||
int num_arguments = emit_num_arguments(l);
|
|
||||||
int i;
|
|
||||||
char source[256];
|
char source[256];
|
||||||
|
|
||||||
wrap_args = NewString("");
|
wrap_args = NewString("");
|
||||||
|
|
@ -2630,8 +2628,9 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
||||||
if (!is_void) outputs++;
|
if (!is_void) outputs++;
|
||||||
|
|
||||||
/* build argument list and type conversion string */
|
/* build argument list and type conversion string */
|
||||||
for (i=0, idx=0, p = l; i < num_arguments && p != 0; i++) {
|
idx = 0;
|
||||||
|
p = l;
|
||||||
|
while (p != NULL) {
|
||||||
if (checkAttribute(p,"tmap:in:numinputs","0")) {
|
if (checkAttribute(p,"tmap:in:numinputs","0")) {
|
||||||
p = Getattr(p,"tmap:in:next");
|
p = Getattr(p,"tmap:in:next");
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -2752,7 +2751,9 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
||||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(return_type, "c_result"), NIL);
|
Wrapper_add_localv(w, "c_result", SwigType_lstr(return_type, "c_result"), NIL);
|
||||||
}
|
}
|
||||||
/* declare Python return value */
|
/* declare Python return value */
|
||||||
Wrapper_add_local(w, "result", "PyObject *result");
|
if (!is_void) {
|
||||||
|
Wrapper_add_local(w, "result", "PyObject *result");
|
||||||
|
}
|
||||||
|
|
||||||
/* direct call to superclass if _up is set */
|
/* direct call to superclass if _up is set */
|
||||||
Printf(w->code, "if (swig_get_up()) {\n");
|
Printf(w->code, "if (swig_get_up()) {\n");
|
||||||
|
|
@ -2782,11 +2783,13 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
||||||
Printf(w->code, " Swig::DirectorException::raise(\"'self' unitialized, maybe you forgot to call %s.__init__.\");\n", classname);
|
Printf(w->code, " Swig::DirectorException::raise(\"'self' unitialized, maybe you forgot to call %s.__init__.\");\n", classname);
|
||||||
Printf(w->code, "}\n");
|
Printf(w->code, "}\n");
|
||||||
if (Len(parse_args) > 0) {
|
if (Len(parse_args) > 0) {
|
||||||
Printf(w->code, "result = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n", pyname, parse_args, arglist);
|
Printf(w->code, "%s PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n", (!is_void ? "result =" : "(void)"), pyname, parse_args, arglist);
|
||||||
} else {
|
} else {
|
||||||
Printf(w->code, "result = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", NULL);\n", pyname);
|
Printf(w->code, "%s PyObject_CallMethod(swig_get_self(), (char *)\"%s\", NULL);\n", (!is_void ? "result =" : "(void)"), pyname);
|
||||||
|
}
|
||||||
|
if (!is_void) {
|
||||||
|
Printv(xdecref, "Py_XDECREF(result);\n", NULL);
|
||||||
}
|
}
|
||||||
Printv(xdecref, "Py_XDECREF(result);\n", NULL);
|
|
||||||
if (dirprot_mode() && !is_public(n))
|
if (dirprot_mode() && !is_public(n))
|
||||||
Printf(w->code, "swig_set_inner(\"%s\", false);\n", name);
|
Printf(w->code, "swig_set_inner(\"%s\", false);\n", name);
|
||||||
|
|
||||||
|
|
@ -2795,7 +2798,9 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
||||||
if (!tm) {
|
if (!tm) {
|
||||||
tm = Getattr(n, "feature:director:except");
|
tm = Getattr(n, "feature:director:except");
|
||||||
}
|
}
|
||||||
Printf(w->code, "if (result == NULL) {\n");
|
if (!is_void) {
|
||||||
|
Printf(w->code, "if (result == NULL) {\n");
|
||||||
|
}
|
||||||
Printf(w->code, " PyObject *error = PyErr_Occurred();\n");
|
Printf(w->code, " PyObject *error = PyErr_Occurred();\n");
|
||||||
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
|
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
|
||||||
Replaceall(tm, "$error", "error");
|
Replaceall(tm, "$error", "error");
|
||||||
|
|
@ -2807,7 +2812,9 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
|
||||||
Printf(w->code, " }\n");
|
Printf(w->code, " }\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf(w->code, "}\n");
|
if (!is_void) {
|
||||||
|
Printf(w->code, "}\n");
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Python method may return a simple object, or a tuple.
|
* Python method may return a simple object, or a tuple.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue