From 46a0db50fe0fcd9f546b3903f814f92d31a02832 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 1 May 2008 21:47:23 +0000 Subject: [PATCH] enforce consistency in wrap:action wrt line spacing git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10411 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/csharp.cxx | 2 +- Source/Modules/emit.cxx | 5 +++-- Source/Modules/java.cxx | 2 +- Source/Modules/lua.cxx | 2 +- Source/Modules/modula3.cxx | 2 +- Source/Modules/ruby.cxx | 8 ++++---- Source/Modules/tcl8.cxx | 2 +- Source/Swig/cwrap.c | 18 +++++++++--------- 8 files changed, 21 insertions(+), 20 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index fdb9c6979..8597d731e 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -907,7 +907,7 @@ public: // below based on Swig_VargetToFunction() SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n)); - Setattr(n, "wrap:action", NewStringf("result = (%s) %s;\n", SwigType_lstr(ty, 0), Getattr(n, "value"))); + Setattr(n, "wrap:action", NewStringf("result = (%s) %s;", SwigType_lstr(ty, 0), Getattr(n, "value"))); } // Now write code to make the function call if (!native_function_flag) diff --git a/Source/Modules/emit.cxx b/Source/Modules/emit.cxx index 5cf8a241b..bbf563b4b 100644 --- a/Source/Modules/emit.cxx +++ b/Source/Modules/emit.cxx @@ -334,12 +334,12 @@ static void replace_contract_args(Parm *cp, Parm *rp, String *s) { /* ----------------------------------------------------------------------------- * int emit_action() * - * Emits action code for a wrapper and checks for exception handling + * Emits action code for a wrapper. Adds in exception handling code (%exception). * ----------------------------------------------------------------------------- */ int emit_action_code(Node *n, Wrapper *f, String *eaction) { assert(Getattr(n, "wrap:name")); - /* Look for except feature */ + /* Look for except feature (%exception) */ String *tm = GetFlagAttr(n, "feature:except"); if (tm) tm = Copy(tm); @@ -410,6 +410,7 @@ void emit_action(Node *n, Wrapper *f) { } Setattr(n, "wrap:code:done", f_code); } + action = Getattr(n, "feature:action"); if (!action) action = Getattr(n, "wrap:action"); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index e2f00dc48..40c57a739 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -986,7 +986,7 @@ public: // below based on Swig_VargetToFunction() SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n)); - Setattr(n, "wrap:action", NewStringf("result = (%s) %s;\n", SwigType_lstr(ty, 0), Getattr(n, "value"))); + Setattr(n, "wrap:action", NewStringf("result = (%s) %s;", SwigType_lstr(ty, 0), Getattr(n, "value"))); } // Now write code to make the function call if (!native_function_flag) { diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index f807a7f87..f5561bb81 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -919,7 +919,7 @@ public: Printv(f_wrappers, "static void swig_delete_", class_name, "(void *obj) {\n", NIL); if (destructor_action) { Printv(f_wrappers, SwigType_str(rt, "arg1"), " = (", SwigType_str(rt, 0), ") obj;\n", NIL); - Printv(f_wrappers, destructor_action, NIL); + Printv(f_wrappers, destructor_action, "\n", NIL); } else { if (CPlusPlus) { Printv(f_wrappers, " delete (", SwigType_str(rt, 0), ") obj;\n", NIL); diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index ebc0d8666..5791cca0d 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -1413,7 +1413,7 @@ MODULA3(): // below based on Swig_VargetToFunction() SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n)); - Setattr(n, "wrap:action", NewStringf("result = (%s) %s;\n", SwigType_lstr(ty, 0), Getattr(n, "value"))); + Setattr(n, "wrap:action", NewStringf("result = (%s) %s;", SwigType_lstr(ty, 0), Getattr(n, "value"))); } Setattr(n, "wrap:name", wname); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 7ac4e70b8..96165ae9b 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1759,9 +1759,9 @@ public: Wrapper_add_local(f, "classname", classname); } if (action) { - Append(action, "DATA_PTR(self) = result;\n"); + Append(action, "\nDATA_PTR(self) = result;"); if (GetFlag(pn, "feature:trackobjects")) { - Append(action, "SWIG_RubyAddTracking(result, self);\n"); + Append(action, "\nSWIG_RubyAddTracking(result, self);"); } } } @@ -2654,11 +2654,11 @@ public: Printv(f_wrappers, wrap, NIL); } /* Printv(freebody, Swig_name_destroy(name), "(", pname0, ")", NIL); */ - Printv(freebody, Getattr(n, "wrap:action"), NIL); + Printv(freebody, Getattr(n, "wrap:action"), "\n", NIL); } else { String *action = Getattr(n, "wrap:action"); if (action) { - Printv(freebody, action, NIL); + Printv(freebody, action, "\n", NIL); } else { /* In the case swig emits no destroy function. */ if (CPlusPlus) diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 4e76074a4..c2ce79b49 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -782,7 +782,7 @@ public: Printv(f_wrappers, "SWIGINTERN void swig_delete_", class_name, "(void *obj) {\n", NIL); if (destructor_action) { Printv(f_wrappers, SwigType_str(rt, "arg1"), " = (", SwigType_str(rt, 0), ") obj;\n", NIL); - Printv(f_wrappers, destructor_action, NIL); + Printv(f_wrappers, destructor_action, "\n", NIL); } else { if (CPlusPlus) { Printv(f_wrappers, " delete (", SwigType_str(rt, 0), ") obj;\n", NIL); diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 5906b3768..2fc444290 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -658,7 +658,7 @@ String *Swig_cdestructor_call(Node *n) { * * Creates a string that calls a C destructor function. * - * delete arg0; + * delete arg1; * ----------------------------------------------------------------------------- */ String *Swig_cppdestructor_call(Node *n) { @@ -1175,7 +1175,7 @@ int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags) Swig_add_extension_code(n, mangled, p, type, code, cparse_cplusplus, "self"); } call = Swig_cfunction_call(mangled, p); - cres = NewStringf("%s;\n", call); + cres = NewStringf("%s;", call); Setattr(n, "wrap:action", cres); Delete(membername); Delete(mangled); @@ -1184,13 +1184,13 @@ int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags) } else { if (cplus) { String *call = Swig_cppdestructor_call(n); - String *cres = NewStringf("%s\n", call); + String *cres = NewStringf("%s", call); Setattr(n, "wrap:action", cres); Delete(call); Delete(cres); } else { String *call = Swig_cdestructor_call(n); - String *cres = NewStringf("%s\n", call); + String *cres = NewStringf("%s", call); Setattr(n, "wrap:action", cres); Delete(call); Delete(cres); @@ -1265,13 +1265,13 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) { Swig_add_extension_code(n, mangled, parms, void_type, code, cparse_cplusplus, "self"); } call = Swig_cfunction_call(mangled, parms); - cres = NewStringf("%s;\n", call); + cres = NewStringf("%s;", call); Setattr(n, "wrap:action", cres); Delete(call); Delete(cres); } else { String *call = Swig_cmemberset_call(name, type, self, varcref); - String *cres = NewStringf("%s;\n", call); + String *cres = NewStringf("%s;", call); Setattr(n, "wrap:action", cres); Delete(call); Delete(cres); @@ -1391,7 +1391,7 @@ int Swig_VarsetToFunction(Node *n, int flags) { String *sname = Swig_name_set(name); String *mangled = Swig_name_mangle(sname); String *call = Swig_cfunction_call(mangled, parms); - String *cres = NewStringf("%s;\n", call); + String *cres = NewStringf("%s;", call); Setattr(n, "wrap:action", cres); Delete(cres); Delete(call); @@ -1401,14 +1401,14 @@ int Swig_VarsetToFunction(Node *n, int flags) { if (!Strstr(type, "enum $unnamed")) { String *pname = Swig_cparm_name(0, 0); String *dref = Swig_wrapped_var_deref(type, pname, varcref); - String *call = NewStringf("%s = %s;\n", nname, dref); + String *call = NewStringf("%s = %s;", nname, dref); Setattr(n, "wrap:action", call); Delete(call); Delete(dref); Delete(pname); } else { String *pname = Swig_cparm_name(0, 0); - String *call = NewStringf("if (sizeof(int) == sizeof(%s)) *(int*)(void*)&(%s) = %s;\n", nname, nname, pname); + String *call = NewStringf("if (sizeof(int) == sizeof(%s)) *(int*)(void*)&(%s) = %s;", nname, nname, pname); Setattr(n, "wrap:action", call); Delete(pname); Delete(call);