From 41beef4abaf62a9258575aeb139c8baa1670a85f Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Thu, 2 Feb 2006 22:56:15 +0000 Subject: [PATCH] add fail: label for the get methods always, just in case someone write a 'varout' typemap that need it git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8682 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/perl5.cxx | 9 +++------ Source/Modules/python.cxx | 9 +++------ Source/Modules/ruby.cxx | 9 +++------ Source/Modules/tcl8.cxx | 9 +++------ 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 7f2a2f08c..7ce24a90b 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -850,7 +850,6 @@ public: tab4, "MAGIC_PPERL\n", NIL); - int addfail = 0; if ((tm = Swig_typemap_lookup_new("varout",n,name,0))) { Replaceall(tm,"$target","sv"); Replaceall(tm,"$result","sv"); @@ -861,17 +860,15 @@ public: Replaceall(tm, "$shadow", "0"); } /* Printf(getf->code,"%s\n", tm);*/ - addfail = emit_action_code(n, getf, tm); + emit_action_code(n, getf, tm); } else { Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number, "Unable to read variable of type %s\n", SwigType_str(t,0)); return SWIG_NOWRAP; } Printf(getf->code," return 1;\n"); - if (addfail) { - Append(getf->code,"fail:\n"); - Append(getf->code," return 0;\n"); - } + Append(getf->code,"fail:\n"); + Append(getf->code," return 0;\n"); Append(getf->code,"}\n"); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 90e62765d..080ecf791 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2164,12 +2164,11 @@ public: /* Create a function for getting the value of a variable */ Printf(getf->def,"SWIGINTERN PyObject *%s(void) {", getnamef); Wrapper_add_local(getf,"pyobj", "PyObject *pyobj = 0"); - int addfail = 0; if ((tm = Swig_typemap_lookup_new("varout",n,name,0))) { Replaceall(tm,"$source",name); Replaceall(tm,"$target","pyobj"); Replaceall(tm,"$result","pyobj"); - addfail = emit_action_code(n, getf, tm); + emit_action_code(n, getf, tm); Delete(tm); } else { Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number, @@ -2177,10 +2176,8 @@ public: } Append(getf->code," return pyobj;\n"); - if (addfail) { - Append(getf->code,"fail:\n"); - Append(getf->code," return NULL;\n"); - } + Append(getf->code,"fail:\n"); + Append(getf->code," return NULL;\n"); Append(getf->code,"}\n"); Wrapper_print(getf,f_wrappers); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index c1fcd59cc..bc89eea37 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1433,22 +1433,19 @@ public: Wrapper_add_local(getf,"_val","VALUE _val"); tm = Swig_typemap_lookup_new("varout",n, name, 0); - int addfail = 0; if (tm) { Replaceall(tm,"$result","_val"); Replaceall(tm,"$target","_val"); Replaceall(tm,"$source",name); /* Printv(getf->code,tm, NIL); */ - addfail = emit_action_code(n, getf, tm); + emit_action_code(n, getf, tm); } else { Swig_warning(WARN_TYPEMAP_VAROUT_UNDEF, input_file, line_number, "Unable to read variable of type %s\n", SwigType_str(t,0)); } Printv(getf->code, tab4, "return _val;\n", NIL); - if (addfail) { - Append(getf->code,"fail:\n"); - Append(getf->code," return Qnil;\n"); - } + Append(getf->code,"fail:\n"); + Append(getf->code," return Qnil;\n"); Append(getf->code,"}\n"); Wrapper_print(getf,f_wrappers); diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 5bdf5248b..86cb52708 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -578,22 +578,19 @@ public: getname = Swig_name_get(iname); Printv(getf->def,"SWIGINTERN char *",getname,"(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, char *name1, char *name2, int flags) {",NIL); Wrapper_add_local(getf,"value", "Tcl_Obj *value = 0"); - int addfail = 0; if ((tm = Swig_typemap_lookup_new("varout",n,name,0))) { Replaceall(tm,"$source", name); Replaceall(tm,"$target","value"); Replaceall(tm,"$result", "value"); /* Printf(getf->code, "%s\n",tm); */ - addfail = emit_action_code(n, getf, tm); + emit_action_code(n, getf, tm); Printf(getf->code, "if (value) {\n"); Printf(getf->code, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n"); Printf(getf->code, "Tcl_DecrRefCount(value);\n"); Printf(getf->code, "}\n"); Printf(getf->code, "return NULL;\n"); - if (addfail) { - Append(getf->code,"fail:\n"); - Printf(getf->code,"return \"%s\";\n", iname); - } + Append(getf->code,"fail:\n"); + Printf(getf->code,"return \"%s\";\n", iname); Printf(getf->code,"}\n"); Wrapper_print(getf,f_wrappers); } else {