finishing the first stage of the typemap unification scheme, fixing issues with gcc and valgrind
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7692 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
733322c539
commit
ba3efb0917
44 changed files with 565 additions and 426 deletions
|
|
@ -305,6 +305,15 @@ static void SWIG_dump_runtime() {
|
|||
Printf(runtime, "%s", s);
|
||||
Delete(s);
|
||||
|
||||
s = Swig_include_sys("swigerrors.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swigerrors.swg'\n");
|
||||
Close(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
Delete(s);
|
||||
|
||||
s = Swig_include_sys("swigrun.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swigrun.swg'\n");
|
||||
|
|
|
|||
|
|
@ -1177,7 +1177,7 @@ public:
|
|||
outarg = NewString("");
|
||||
kwargs = NewString("");
|
||||
|
||||
Wrapper_add_local(f,"resultobj", "PyObject *resultobj = NULL");
|
||||
Wrapper_add_local(f,"resultobj", "PyObject *resultobj = 0");
|
||||
|
||||
/* Write code to extract function parameters. */
|
||||
emit_args(d, l, f);
|
||||
|
|
@ -1491,7 +1491,6 @@ public:
|
|||
/* Output cleanup code */
|
||||
int need_cleanup = Len(cleanup) != 0;
|
||||
if (need_cleanup) {
|
||||
Printf(f->code,"cleanup:\n");
|
||||
Printv(f->code,cleanup,NIL);
|
||||
}
|
||||
|
||||
|
|
@ -1515,12 +1514,10 @@ public:
|
|||
|
||||
Printf(f->code,"fail:\n");
|
||||
if (need_cleanup) {
|
||||
Printf(f->code,"if (resultobj) Py_DECREF(resultobj);\n");
|
||||
Printf(f->code,"resultobj = NULL;\n");
|
||||
Printf(f->code,"goto cleanup;\n");
|
||||
} else {
|
||||
Printf(f->code,"return NULL;\n");
|
||||
Printv(f->code,cleanup,NIL);
|
||||
}
|
||||
Printv(f->code,tab4,"return NULL;\n",NIL);
|
||||
|
||||
|
||||
|
||||
Printf(f->code,"}\n");
|
||||
|
|
@ -1606,7 +1603,7 @@ public:
|
|||
Python dictionary. */
|
||||
|
||||
if (!have_globals) {
|
||||
Printf(f_init,"\t PyDict_SetItemString(d,(char*)\"%s\", SWIG_globals);\n",global_name);
|
||||
Printf(f_init,"\t PyDict_SetItemString(d,(char*)\"%s\", SWIG_globals());\n",global_name);
|
||||
have_globals=1;
|
||||
if ((shadow) && (!(shadow & PYSHADOW_MEMBER))) {
|
||||
Printf(f_shadow_stubs,"%s = %s.%s\n", global_name, module, global_name);
|
||||
|
|
@ -1636,7 +1633,9 @@ public:
|
|||
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number,
|
||||
"Unable to set variable of type %s.\n", SwigType_str(t,0));
|
||||
}
|
||||
Printf(setf->code," return 0;\n");
|
||||
Printv(setf->code,tab4,"return 0;\n",NULL);
|
||||
Printf(setf->code,"fail:\n");
|
||||
Printv(setf->code,tab4,"return 1;\n",NULL);
|
||||
} else {
|
||||
/* Is a readonly variable. Issue an error */
|
||||
if (CPlusPlus) {
|
||||
|
|
@ -1645,8 +1644,7 @@ public:
|
|||
Printf(setf->def,"static int %s_set(PyObject *_val) {", wname);
|
||||
}
|
||||
Printv(setf->code,
|
||||
tab4, "PyErr_SetString(PyExc_TypeError,\"Variable ", iname,
|
||||
" is read-only.\");\n",
|
||||
tab4, "SWIG_Error(SWIG_AttributeError,\"Variable ", iname," is read-only.\");\n",
|
||||
tab4, "return 1;\n",
|
||||
NIL);
|
||||
}
|
||||
|
|
@ -1656,7 +1654,7 @@ public:
|
|||
|
||||
/* Create a function for getting the value of a variable */
|
||||
Printf(getf->def,"static PyObject *%s_get(void) {", wname);
|
||||
Wrapper_add_local(getf,"pyobj", "PyObject *pyobj = NULL");
|
||||
Wrapper_add_local(getf,"pyobj", "PyObject *pyobj = 0");
|
||||
if ((tm = Swig_typemap_lookup_new("varout",n,name,0))) {
|
||||
Replaceall(tm,"$source",name);
|
||||
Replaceall(tm,"$target","pyobj");
|
||||
|
|
@ -1671,7 +1669,7 @@ public:
|
|||
Wrapper_print(getf,f_wrappers);
|
||||
|
||||
/* Now add this to the variable linking mechanism */
|
||||
Printf(f_init,"\t SWIG_addvarlink(SWIG_globals,(char*)\"%s\",%s_get, %s_set);\n", iname, wname, wname);
|
||||
Printf(f_init,"\t SWIG_addvarlink(SWIG_globals(),(char*)\"%s\",%s_get, %s_set);\n", iname, wname, wname);
|
||||
|
||||
DelWrapper(setf);
|
||||
DelWrapper(getf);
|
||||
|
|
|
|||
|
|
@ -1314,7 +1314,6 @@ public:
|
|||
/* Dump the argument cleanup code */
|
||||
int need_cleanup = (current != CONSTRUCTOR_ALLOCATE) && (Len(cleanup) != 0);
|
||||
if (need_cleanup) {
|
||||
Printv(f->code,"cleanup:\n",NIL);
|
||||
Printv(f->code,cleanup,NIL);
|
||||
}
|
||||
|
||||
|
|
@ -1343,38 +1342,27 @@ public:
|
|||
Printv(f->code, tab4, "return self;\n", NIL);
|
||||
Printv(f->code,"fail:\n",NIL);
|
||||
if (need_cleanup) {
|
||||
Printv(f->code, tab4, "self = Qnil;\n", NIL);
|
||||
Printv(f->code, tab4, "goto cleanup;\n", NIL);
|
||||
} else {
|
||||
Printv(f->code, tab4, "return Qnil;\n", NIL);
|
||||
}
|
||||
Printv(f->code,cleanup,NIL);
|
||||
}
|
||||
Printv(f->code, tab4, "return Qnil;\n", NIL);
|
||||
} else {
|
||||
Wrapper_add_local(f,"vresult","VALUE vresult = Qnil");
|
||||
Printv(f->code, tab4, "return vresult;\n", NIL);
|
||||
Printv(f->code,"fail:\n",NIL);
|
||||
if (need_cleanup) {
|
||||
Printv(f->code, tab4, "vresult = Qnil;\n", NIL);
|
||||
Printv(f->code, tab4, "goto cleanup;\n", NIL);
|
||||
} else {
|
||||
Printv(f->code, tab4, "return Qnil;\n", NIL);
|
||||
}
|
||||
Printv(f->code,cleanup,NIL);
|
||||
}
|
||||
Printv(f->code, tab4, "return Qnil;\n", NIL);
|
||||
}
|
||||
} else {
|
||||
Printv(f->code, tab4, "return Qnil;\n", NIL);
|
||||
Printv(f->code,"fail:\n",NIL);
|
||||
if (need_cleanup) {
|
||||
Printv(f->code, tab4, "goto cleanup;\n", NIL);
|
||||
} else {
|
||||
Printv(f->code, tab4, "return Qnil;\n", NIL);
|
||||
Printv(f->code,cleanup,NIL);
|
||||
}
|
||||
Printv(f->code, tab4, "return Qnil;\n", NIL);
|
||||
}
|
||||
|
||||
/* Error handling code */
|
||||
/*
|
||||
Printf(f->code,"fail:\n");
|
||||
Printv(f->code,cleanup,NIL);
|
||||
Printv(f->code,"return Qnil;\n",NIL);
|
||||
*/
|
||||
Printf(f->code,"}\n");
|
||||
|
||||
/* Substitute the cleanup code */
|
||||
|
|
@ -1500,7 +1488,7 @@ public:
|
|||
Printv(getf->code, tab4, "return _val;\n}\n", NIL);
|
||||
Wrapper_print(getf,f_wrappers);
|
||||
|
||||
if (GetFlag(n,"feature:immutable")) {
|
||||
if (!is_assignable(n)) {
|
||||
setfname = NewString("NULL");
|
||||
} else {
|
||||
/* create setter */
|
||||
|
|
@ -1518,7 +1506,9 @@ public:
|
|||
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number,
|
||||
"Unable to set variable of type %s\n", SwigType_str(t,0));
|
||||
}
|
||||
Printv(setf->code, tab4, "return _val;\n",NIL);
|
||||
Printv(setf->code, tab4, "return _val;\n", NIL);
|
||||
Printf(setf->code, "fail:\n");
|
||||
Printv(setf->code, tab4, "return Qnil;\n", NIL);
|
||||
Printf(setf->code,"}\n");
|
||||
Wrapper_print(setf,f_wrappers);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -583,7 +583,7 @@ public:
|
|||
DelWrapper(getf);
|
||||
|
||||
/* Try to create a function setting a variable */
|
||||
if (!GetFlag(n,"feature:immutable")) {
|
||||
if (is_assignable(n)) {
|
||||
setf = NewWrapper();
|
||||
setname = Swig_name_wrapper(Swig_name_set(iname));
|
||||
Printv(setf->def,"SWIGINTERN char *",setname, "(ClientData clientData, Tcl_Interp *interp, char *name1, char *name2, int flags) {",NIL);
|
||||
|
|
@ -600,6 +600,8 @@ public:
|
|||
Printf(setf->code,"if (!value) return NULL;\n");
|
||||
Printf(setf->code,"%s\n", tm);
|
||||
Printf(setf->code,"return NULL;\n");
|
||||
Printf(setf->code,"fail:\n");
|
||||
Printf(setf->code,"return \"%s\";\n", iname);
|
||||
Printf(setf->code,"}\n");
|
||||
if (setf) Wrapper_print(setf,f_wrappers);
|
||||
} else {
|
||||
|
|
@ -608,10 +610,13 @@ public:
|
|||
readonly = 1;
|
||||
}
|
||||
DelWrapper(setf);
|
||||
}
|
||||
} else {
|
||||
readonly = 1;
|
||||
}
|
||||
|
||||
|
||||
Printv(var_tab, tab4,"{ SWIG_prefix \"", iname, "\", 0, (swig_variable_func) ", getname, ",", NIL);
|
||||
if (readonly || GetFlag(n,"feature:immutable")) {
|
||||
if (readonly) {
|
||||
static int readonlywrap = 0;
|
||||
if (!readonlywrap) {
|
||||
Wrapper *ro = NewWrapper();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue