fixes for the examples and tcl to use the old Tcl_SetResult()... methods
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7962 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
fdf4d72b4b
commit
2173101af6
8 changed files with 47 additions and 17 deletions
|
|
@ -31,7 +31,7 @@ extern int gcd(int x, int y);
|
|||
tempav = (AV*)SvRV($input);
|
||||
len = av_len(tempav);
|
||||
$1 = (int) len+1;
|
||||
$2 = (char **) malloc($1*sizeof(char *));
|
||||
$2 = (char **) malloc(($1+1)*sizeof(char *));
|
||||
for (i = 0; i < $1; i++) {
|
||||
tv = av_fetch(tempav, i, 0);
|
||||
$2[i] = (char *) SvPV(*tv,PL_na);
|
||||
|
|
|
|||
|
|
@ -47,10 +47,10 @@
|
|||
try {
|
||||
$action
|
||||
} catch(FullError& e) {
|
||||
FullError *ecopy = new FullError(e);
|
||||
PyObject *err = SWIG_NewPointerObj(ecopy, SWIGTYPE_p_FullError, 1);
|
||||
PyErr_SetObject((PyObject *) SWIGTYPE_p_FullError->clientdata, err);
|
||||
return NULL;
|
||||
FullError *ecopy = new FullError(e);
|
||||
PyObject *err = SWIG_NewPointerObj(ecopy, SWIGTYPE_p_FullError, 1);
|
||||
PyErr_SetObject(SWIG_Python_ExceptionType(SWIGTYPE_p_FullError), err);
|
||||
SWIG_fail;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -87,6 +87,7 @@
|
|||
|
||||
*/
|
||||
%exceptionclass EmptyError;
|
||||
%exceptionclass FullError;
|
||||
|
||||
%exception *::dequeue {
|
||||
try {
|
||||
|
|
@ -94,8 +95,8 @@
|
|||
} catch(EmptyError& e) {
|
||||
EmptyError *ecopy = new EmptyError(e);
|
||||
PyObject *err = SWIG_NewPointerObj(ecopy, SWIGTYPE_p_EmptyError, 1);
|
||||
PyErr_SetObject((PyObject *) SWIGTYPE_p_EmptyError->clientdata, err);
|
||||
return NULL;
|
||||
PyErr_SetObject(SWIG_Python_ExceptionType(SWIGTYPE_p_EmptyError), err);
|
||||
SWIG_fail;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,11 @@
|
|||
%typemap(in) int Space::nspace "/*int nspace in */ $1=0;"
|
||||
%typemap(out) int Space::nspace "/*int nspace out*/ $result=0;"
|
||||
%typemap(in) int member "/*int member in */ $1=0;"
|
||||
#ifdef SWIGTCL
|
||||
%typemap(out) int member "/*int member out*/"
|
||||
#else
|
||||
%typemap(out) int member "/*int member out*/ $result=0;"
|
||||
#endif
|
||||
%typemap(in) int Space::Struct::smember "/*int smember in */ $1=0;"
|
||||
%typemap(out) int Space::Struct::smember "/*int smember out*/ $result=0;"
|
||||
|
||||
|
|
|
|||
|
|
@ -532,7 +532,7 @@ namespace swig
|
|||
typedef Reference reference;
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef int difference_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
|
||||
PySequence_InputIterator()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,10 +30,18 @@
|
|||
SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {}
|
||||
~SWIG_Python_Thread_Allow() { end(); }
|
||||
};
|
||||
# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block
|
||||
# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end()
|
||||
# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow
|
||||
# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end()
|
||||
# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK)
|
||||
# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block
|
||||
# endif
|
||||
# if !defined(SWIG_PYTHON_THREAD_END_BLOCK)
|
||||
# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end()
|
||||
# endif
|
||||
# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW)
|
||||
# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow
|
||||
# endif
|
||||
# if !defined(SWIG_PYTHON_THREAD_END_ALLOW)
|
||||
# define SWIG_PYTHON_THREAD_END_ALLOW
|
||||
# endif
|
||||
# else /* C code */
|
||||
# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure()
|
||||
# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,9 @@
|
|||
#define SWIG_Object Tcl_Obj *
|
||||
|
||||
/* Simple overload of the output/constant/exception handling */
|
||||
#define SWIG_AppendOutput(result,obj) (Tcl_ListObjAppendElement(NULL,result,obj) == TCL_OK) ? result : NULL
|
||||
/* output */
|
||||
#define %set_output(obj) Tcl_SetObjResult(interp,obj)
|
||||
#define %append_output(obj) Tcl_ListObjAppendElement(interp,Tcl_GetObjResult(interp),obj)
|
||||
#define SWIG_SetConstant(name, obj) SWIG_Tcl_SetConstantObj(interp, name, obj)
|
||||
#define SWIG_Raise(obj,type,desc) SWIG_Tcl_SetErrorObj(interp,type,obj)
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@
|
|||
|
||||
|
||||
%typemap(out,noblock=1) SWIG_Object {
|
||||
$result = $1;
|
||||
%set_output($1);
|
||||
}
|
||||
|
||||
%typemap(out,noblock=1) SWIG_Object const & {
|
||||
$result = *$1;
|
||||
%set_output(*$1);
|
||||
}
|
||||
|
||||
%typecheck(SWIG_TYPECHECK_POINTER) SWIG_Object "$1 = ($input != 0);";
|
||||
|
|
|
|||
|
|
@ -299,7 +299,10 @@ public:
|
|||
|
||||
f = NewWrapper();
|
||||
|
||||
#ifdef SWIG_USE_RESULTOBJ
|
||||
Wrapper_add_local(f,"resultobj", "Tcl_Obj *resultobj = NULL");
|
||||
#endif
|
||||
|
||||
|
||||
String *wname = Swig_name_wrapper(iname);
|
||||
if (overname) {
|
||||
|
|
@ -436,8 +439,13 @@ public:
|
|||
for (i=0,p = parms; p;i++) {
|
||||
if ((tm = Getattr(p,"tmap:argout"))) {
|
||||
Replaceall(tm,"$source",Getattr(p,"lname"));
|
||||
#ifdef SWIG_USE_RESULTOBJ
|
||||
Replaceall(tm,"$target","resultobj");
|
||||
Replaceall(tm,"$result","resultobj");
|
||||
#else
|
||||
Replaceall(tm,"$target","(Tcl_GetObjResult(interp))");
|
||||
Replaceall(tm,"$result","(Tcl_GetObjResult(interp))");
|
||||
#endif
|
||||
Replaceall(tm,"$arg",Getattr(p,"emit:input"));
|
||||
Replaceall(tm,"$input",Getattr(p,"emit:input"));
|
||||
Printv(outarg,tm,"\n",NIL);
|
||||
|
|
@ -455,8 +463,13 @@ public:
|
|||
/* Return value if necessary */
|
||||
if ((tm = Swig_typemap_lookup_new("out",n,"result",0))) {
|
||||
Replaceall(tm,"$source", "result");
|
||||
Replaceall(tm,"$target", "resultobj");
|
||||
Replaceall(tm,"$result", "resultobj");
|
||||
#ifdef SWIG_USE_RESULTOBJ
|
||||
Replaceall(tm,"$target","resultobj");
|
||||
Replaceall(tm,"$result","resultobj");
|
||||
#else
|
||||
Replaceall(tm,"$target","(Tcl_GetObjResult(interp))");
|
||||
Replaceall(tm,"$result","(Tcl_GetObjResult(interp))");
|
||||
#endif
|
||||
if(GetFlag(n,"feature:new")) {
|
||||
Replaceall(tm,"$owner","SWIG_POINTER_OWN");
|
||||
} else {
|
||||
|
|
@ -486,7 +499,9 @@ public:
|
|||
Replaceall(tm,"$source","result");
|
||||
Printf(f->code,"%s\n", tm);
|
||||
}
|
||||
#ifdef SWIG_USE_RESULTOBJ
|
||||
Printv(f->code, "if (resultobj) Tcl_SetObjResult(interp, resultobj);\n", NIL);
|
||||
#endif
|
||||
Printv(f->code, "return TCL_OK;\n", NIL);
|
||||
Printv(f->code, "fail:\n", cleanup, "return TCL_ERROR;\n", NIL);
|
||||
Printv(f->code,"}\n", NIL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue