From bbb97f8e6df9f3ff64a2aa5045932fdd78bb1608 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 6 Oct 2004 21:10:24 +0000 Subject: [PATCH] fixes for the new default argument wrapping in director constructors and virtual methods git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6354 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/java.cxx | 51 +++++++++++++++++++++------------------ Source/Modules/ocaml.cxx | 50 ++++++++++++++++++++------------------ Source/Modules/python.cxx | 46 +++++++++++++++++++---------------- Source/Modules/ruby.cxx | 48 +++++++++++++++++++----------------- 4 files changed, 105 insertions(+), 90 deletions(-) diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 01c23cbe2..757bad1ae 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -3308,11 +3308,14 @@ class JAVA : public Language { if (status == SWIG_OK && output_director) { if(!is_void) { Replaceall(w->code,"$null", qualified_return); - } else + } else { Replaceall(w->code,"$null",""); - Wrapper_print(w, f_directors); + } Wrapper_print(imw, imclass_directors); - Printv(f_directors_h, declaration, NIL); + if (!Getattr(n,"defaultargs")) { + Wrapper_print(w, f_directors); + Printv(f_directors_h, declaration, NIL); + } } Delete(qualified_return); @@ -3382,28 +3385,30 @@ class JAVA : public Language { directorPrefixArgs(n); - /* constructor */ - { - String *basetype = Getattr(parent, "classtype"); - String *target = Swig_method_decl(decl, classname, parms, 0, 0); - String *call = Swig_csuperclass_call(0, basetype, superparms); - String *classtype = SwigType_namestr(Getattr(n, "name")); - String *dirclass_type = SwigType_namestr(Getattr(n, "sym:name")); + if (!Getattr(n,"defaultargs")) { + /* constructor */ + { + String *basetype = Getattr(parent, "classtype"); + String *target = Swig_method_decl(decl, classname, parms, 0, 0); + String *call = Swig_csuperclass_call(0, basetype, superparms); + String *classtype = SwigType_namestr(Getattr(n, "name")); + String *dirclass_type = SwigType_namestr(Getattr(n, "sym:name")); - Printf(f_directors, "%s::%s: %s, %s {\n", classname, target, call, Getattr(parent, "director:ctor")); - Printf(f_directors, "}\n\n"); + Printf(f_directors, "%s::%s: %s, %s {\n", classname, target, call, Getattr(parent, "director:ctor")); + Printf(f_directors, "}\n\n"); - Delete(dirclass_type); - Delete(classtype); - Delete(target); - Delete(call); - } - - /* constructor header */ - { - String *target = Swig_method_decl(decl, classname, parms, 0, 1); - Printf(f_directors_h, " %s;\n", target); - Delete(target); + Delete(dirclass_type); + Delete(classtype); + Delete(target); + Delete(call); + } + + /* constructor header */ + { + String *target = Swig_method_decl(decl, classname, parms, 0, 1); + Printf(f_directors_h, " %s;\n", target); + Delete(target); + } } Delete(sub); diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index be1daddd2..a80198f3d 100755 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1750,8 +1750,10 @@ public: /* emit the director method */ if (status == SWIG_OK) { + if (!Getattr(n,"defaultargs")) { Wrapper_print(w, f_directors); Printv(f_directors_h, declaration, NIL); + } } /* clean up */ @@ -1795,30 +1797,30 @@ public: Setattr(p, "value", "0"); set_nextSibling(ip, p); - /* constructor */ - { - Wrapper *w = NewWrapper(); - String *call; - String *basetype = Getattr(parent, "classtype"); - String *target = Swig_method_decl(decl, classname, parms, - 0, 0); - call = Swig_csuperclass_call(0, basetype, superparms); - Printf( w->def, - "%s::%s: %s, Swig::Director(self, disown) { }", - classname, target, call ); - Delete(target); - Wrapper_print(w, f_directors); - Delete(call); - DelWrapper(w); - } - - /* constructor header */ - { - String *target = Swig_method_decl(decl, classname, - parms, 0, 1); - Printf(f_directors_h, " %s;\n", target); - Delete(target); - } + if (!Getattr(n,"defaultargs")) { + /* constructor */ + { + Wrapper *w = NewWrapper(); + String *call; + String *basetype = Getattr(parent, "classtype"); + String *target = Swig_method_decl(decl, classname, parms, 0, 0); + call = Swig_csuperclass_call(0, basetype, superparms); + Printf( w->def, + "%s::%s: %s, Swig::Director(self, disown) { }", + classname, target, call ); + Delete(target); + Wrapper_print(w, f_directors); + Delete(call); + DelWrapper(w); + } + + /* constructor header */ + { + String *target = Swig_method_decl(decl, classname, parms, 0, 1); + Printf(f_directors_h, " %s;\n", target); + Delete(target); + } + } Setattr(n,"parms",q); Language::classDirectorConstructor(n); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 3b3ce9484..ca8acd705 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1993,8 +1993,10 @@ public: /* emit the director method */ if (status == SWIG_OK) { - Wrapper_print(w, f_directors); - Printv(f_directors_h, declaration, NIL); + if (!Getattr(n,"defaultargs")) { + Wrapper_print(w, f_directors); + Printv(f_directors_h, declaration, NIL); + } } /* clean up */ @@ -2038,25 +2040,27 @@ public: Setattr(p, "value", "false"); set_nextSibling(ip, p); - /* constructor */ - { - Wrapper *w = NewWrapper(); - String *call; - String *basetype = Getattr(parent, "classtype"); - String *target = Swig_method_decl(decl, classname, parms, 0, 0); - call = Swig_csuperclass_call(0, basetype, superparms); - Printf(w->def, "%s::%s: %s, Swig::Director(self, disown) { }", classname, target, call); - Delete(target); - Wrapper_print(w, f_directors); - Delete(call); - DelWrapper(w); - } - - /* constructor header */ - { - String *target = Swig_method_decl(decl, classname, parms, 0, 1); - Printf(f_directors_h, " %s;\n", target); - Delete(target); + if (!Getattr(n,"defaultargs")) { + /* constructor */ + { + Wrapper *w = NewWrapper(); + String *call; + String *basetype = Getattr(parent, "classtype"); + String *target = Swig_method_decl(decl, classname, parms, 0, 0); + call = Swig_csuperclass_call(0, basetype, superparms); + Printf(w->def, "%s::%s: %s, Swig::Director(self, disown) { }", classname, target, call); + Delete(target); + Wrapper_print(w, f_directors); + Delete(call); + DelWrapper(w); + } + + /* constructor header */ + { + String *target = Swig_method_decl(decl, classname, parms, 0, 1); + Printf(f_directors_h, " %s;\n", target); + Delete(target); + } } Delete(sub); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 94b03cffa..75de3e03b 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1911,25 +1911,27 @@ public: Setattr(p, "value", "false"); set_nextSibling(ip, p); - /* constructor */ - { - Wrapper *w = NewWrapper(); - String *call; - String *basetype = Getattr(parent, "classtype"); - String *target = Swig_method_decl(decl, classname, parms, 0, 0); - call = Swig_csuperclass_call(0, basetype, superparms); - Printf(w->def, "%s::%s: %s, Swig::Director(self, disown) { }", classname, target, call); - Delete(target); - Wrapper_print(w, f_directors); - Delete(call); - DelWrapper(w); - } - - /* constructor header */ - { - String *target = Swig_method_decl(decl, classname, parms, 0, 1); - Printf(f_directors_h, " %s;\n", target); - Delete(target); + if (!Getattr(n,"defaultargs")) { + /* constructor */ + { + Wrapper *w = NewWrapper(); + String *call; + String *basetype = Getattr(parent, "classtype"); + String *target = Swig_method_decl(decl, classname, parms, 0, 0); + call = Swig_csuperclass_call(0, basetype, superparms); + Printf(w->def, "%s::%s: %s, Swig::Director(self, disown) { }", classname, target, call); + Delete(target); + Wrapper_print(w, f_directors); + Delete(call); + DelWrapper(w); + } + + /* constructor header */ + { + String *target = Swig_method_decl(decl, classname, parms, 0, 1); + Printf(f_directors_h, " %s;\n", target); + Delete(target); + } } Delete(sub); @@ -1953,7 +1955,7 @@ public: } /* --------------------------------------------------------------- - * classDirectorMethod() + * exceptionSafeMethodCall() * * Emit a virtual director method to pass a method call on to the * underlying Ruby instance. @@ -2377,8 +2379,10 @@ public: /* emit the director method */ if (status == SWIG_OK) { - Wrapper_print(w, f_directors); - Printv(f_directors_h, declaration, NIL); + if (!Getattr(n,"defaultargs")) { + Wrapper_print(w, f_directors); + Printv(f_directors_h, declaration, NIL); + } } /* clean up */