From ae044c1c2f91ee17669f7b8bb78748affc8f2883 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 23 Oct 2017 18:10:49 +0100 Subject: [PATCH] Generation of director method declarations fixes - Fixes generation of director method declarations containing C++11 ref-qualifiers. - Fixes generation of director method declarations returning more complex types such as const ref pointers. - Rewrite Swig_method_call to use more up to date code in the core. --- Examples/test-suite/cpp11_directors.i | 12 +- Source/Modules/csharp.cxx | 8 +- Source/Modules/d.cxx | 8 +- Source/Modules/directors.cxx | 215 +++++++++----------------- Source/Modules/go.cxx | 11 +- Source/Modules/java.cxx | 8 +- Source/Modules/ocaml.cxx | 8 +- Source/Modules/octave.cxx | 8 +- Source/Modules/perl5.cxx | 8 +- Source/Modules/php.cxx | 8 +- Source/Modules/php5.cxx | 8 +- Source/Modules/python.cxx | 8 +- Source/Modules/ruby.cxx | 8 +- Source/Modules/swigmod.h | 2 +- 14 files changed, 119 insertions(+), 201 deletions(-) diff --git a/Examples/test-suite/cpp11_directors.i b/Examples/test-suite/cpp11_directors.i index 4462c1d52..3d1fbea25 100644 --- a/Examples/test-suite/cpp11_directors.i +++ b/Examples/test-suite/cpp11_directors.i @@ -1,20 +1,16 @@ %module(directors="1") cpp11_directors %feature("director"); -%{ +%inline %{ class Foo { public: virtual ~Foo() noexcept {} virtual int ping() noexcept = 0; virtual int pong() noexcept = 0; + virtual int pang() const& noexcept = 0; + virtual int peng() & noexcept = 0; + virtual int pung() & = 0; }; %} - -class Foo { - public: - virtual ~Foo() noexcept {} - virtual int ping() noexcept = 0; - virtual int pong() noexcept = 0; -}; \ No newline at end of file diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 48b8050d2..3ab4c1505 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -4062,11 +4062,11 @@ public: /* header declaration, start wrapper definition */ String *target; SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); - target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); + target = Swig_method_decl(rtype, decl, qualified_name, l, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); - target = Swig_method_decl(rtype, decl, name, l, 0, 1); + target = Swig_method_decl(rtype, decl, name, l, 1); Printf(declaration, " virtual %s", target); Delete(target); @@ -4283,7 +4283,7 @@ public: /* constructor */ { String *basetype = Getattr(parent, "classtype"); - String *target = Swig_method_decl(0, decl, dirclassname, parms, 0, 0); + String *target = Swig_method_decl(0, decl, dirclassname, parms, 0); String *call = Swig_csuperclass_call(0, basetype, superparms); Printf(f_directors, "%s::%s : %s, %s {\n", dirclassname, target, call, Getattr(parent, "director:ctor")); @@ -4296,7 +4296,7 @@ public: /* constructor header */ { - String *target = Swig_method_decl(0, decl, dirclassname, parms, 0, 1); + String *target = Swig_method_decl(0, decl, dirclassname, parms, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index de67e0e1c..28ea16d5d 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -2212,11 +2212,11 @@ public: /* header declaration, start wrapper definition */ String *target; SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); - target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); + target = Swig_method_decl(rtype, decl, qualified_name, l, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); - target = Swig_method_decl(rtype, decl, name, l, 0, 1); + target = Swig_method_decl(rtype, decl, name, l, 1); Printf(declaration, " virtual %s", target); Delete(target); @@ -2436,7 +2436,7 @@ public: /* constructor */ { String *basetype = Getattr(parent, "classtype"); - String *target = Swig_method_decl(0, decl, dirclassname, parms, 0, 0); + String *target = Swig_method_decl(0, decl, dirclassname, parms, 0); String *call = Swig_csuperclass_call(0, basetype, superparms); String *classtype = SwigType_namestr(Getattr(n, "name")); @@ -2451,7 +2451,7 @@ public: /* constructor header */ { - String *target = Swig_method_decl(0, decl, dirclassname, parms, 0, 1); + String *target = Swig_method_decl(0, decl, dirclassname, parms, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } diff --git a/Source/Modules/directors.cxx b/Source/Modules/directors.cxx index 2fdda5a12..a91d5fd9a 100644 --- a/Source/Modules/directors.cxx +++ b/Source/Modules/directors.cxx @@ -15,12 +15,12 @@ #include "swigmod.h" -/* Swig_csuperclass_call() +/* ----------------------------------------------------------------------------- + * Swig_csuperclass_call() * * Generates a fully qualified method call, including the full parameter list. * e.g. "base::method(i, j)" - * - */ + * ----------------------------------------------------------------------------- */ String *Swig_csuperclass_call(String *base, String *method, ParmList *l) { String *call = NewString(""); @@ -44,12 +44,12 @@ String *Swig_csuperclass_call(String *base, String *method, ParmList *l) { return call; } -/* Swig_class_declaration() +/* ----------------------------------------------------------------------------- + * Swig_class_declaration() * * Generate the start of a class/struct declaration. * e.g. "class myclass" - * - */ + * ----------------------------------------------------------------------------- */ String *Swig_class_declaration(Node *n, String *name) { if (!name) { @@ -61,18 +61,22 @@ String *Swig_class_declaration(Node *n, String *name) { return result; } +/* ----------------------------------------------------------------------------- + * Swig_class_name() + * ----------------------------------------------------------------------------- */ + String *Swig_class_name(Node *n) { String *name; name = Copy(Getattr(n, "sym:name")); return name; } -/* Swig_director_declaration() +/* ----------------------------------------------------------------------------- + * Swig_director_declaration() * * Generate the full director class declaration, complete with base classes. * e.g. "class SwigDirector_myclass : public myclass, public Swig::Director {" - * - */ + * ----------------------------------------------------------------------------- */ String *Swig_director_declaration(Node *n) { String *classname = Swig_class_name(n); @@ -87,6 +91,10 @@ String *Swig_director_declaration(Node *n) { } +/* ----------------------------------------------------------------------------- + * Swig_method_call() + * ----------------------------------------------------------------------------- */ + String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms) { String *func; int i = 0; @@ -115,153 +123,67 @@ String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms) { return func; } -/* Swig_method_decl +/* ----------------------------------------------------------------------------- + * Swig_method_decl() * - * Misnamed and misappropriated! Taken from SWIG's type string manipulation utilities - * and modified to generate full (or partial) type qualifiers for method declarations, - * local variable declarations, and return value casting. More importantly, it merges - * parameter type information with actual parameter names to produce a complete method - * declaration that fully mirrors the original method declaration. - * - * There is almost certainly a saner way to do this. - * - * This function needs to be cleaned up and possibly split into several smaller - * functions. For instance, attaching default names to parameters should be done in a - * separate function. - * - */ + * Return a stringified version of a C/C++ declaration. + * ----------------------------------------------------------------------------- */ -String *Swig_method_decl(SwigType *rettype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values) { - String *result; - List *elements; - String *element = 0, *nextelement; - int is_const = 0; - int nelements, i; - int is_func = 0; +String *Swig_method_decl(SwigType *return_base_type, SwigType *decl, const_String_or_char_ptr id, List *args, int default_args) { + String *result = NewString(""); + bool conversion_operator = Strstr(id, "operator ") != 0 && !return_base_type; + + Parm *parm = args; int arg_idx = 0; - - if (id) { - result = NewString(Char(id)); - } else { - result = NewString(""); - } - - elements = SwigType_split(decl); - nelements = Len(elements); - if (nelements > 0) { - element = Getitem(elements, 0); - } - for (i = 0; i < nelements; i++) { - if (i < (nelements - 1)) { - nextelement = Getitem(elements, i + 1); - } else { - nextelement = 0; + while (parm) { + String *type = Getattr(parm, "type"); + String *name = Getattr(parm, "name"); + if (!name && Cmp(type, "void")) { + name = NewString(""); + Printf(name, "arg%d", arg_idx++); + Setattr(parm, "name", name); } - if (SwigType_isqualifier(element)) { - int skip = 0; - DOH *q = 0; - if (!strip) { - q = SwigType_parm(element); - if (!Cmp(q, "const")) { - is_const = 1; - is_func = SwigType_isfunction(nextelement); - if (is_func) - skip = 1; - skip = 1; - } - if (!skip) { - Insert(result, 0, " "); - Insert(result, 0, q); - } - Delete(q); - } - } else if (SwigType_isfunction(element)) { - Parm *parm; - String *p; - Append(result, "("); - parm = args; - while (parm != 0) { - String *type = Getattr(parm, "type"); - String *name = Getattr(parm, "name"); - if (!name && Cmp(type, "void")) { - name = NewString(""); - Printf(name, "arg%d", arg_idx++); - Setattr(parm, "name", name); - } - if (!name) { - name = NewString(""); - } - p = SwigType_str(type, name); - Append(result, p); - String *value = Getattr(parm, "value"); - if (values && (value != 0)) { - Printf(result, " = %s", value); - } - parm = nextSibling(parm); - if (parm != 0) - Append(result, ", "); - } - Append(result, ")"); - } else if (rettype) { // This check is intended for conversion operators to a pointer/reference which needs the pointer/reference ignoring in the declaration - if (SwigType_ispointer(element)) { - Insert(result, 0, "*"); - if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) { - Insert(result, 0, "("); - Append(result, ")"); - } - } else if (SwigType_ismemberpointer(element)) { - String *q; - q = SwigType_parm(element); - Insert(result, 0, "::*"); - Insert(result, 0, q); - if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) { - Insert(result, 0, "("); - Append(result, ")"); - } - Delete(q); - } else if (SwigType_isreference(element)) { - Insert(result, 0, "&"); - } else if (SwigType_isarray(element)) { - DOH *size; - Append(result, "["); - size = SwigType_parm(element); - Append(result, size); - Append(result, "]"); - Delete(size); - } else { - if (Strcmp(element, "v(...)") == 0) { - Insert(result, 0, "..."); - } else { - String *bs = SwigType_namestr(element); - Insert(result, 0, " "); - Insert(result, 0, bs); - Delete(bs); - } - } - } - element = nextelement; + parm = nextSibling(parm); } - Delete(elements); + String *rettype = Copy(decl); + String *quals = SwigType_pop_function_qualifiers(rettype); + String *qualifiers = 0; + if (quals) + qualifiers = SwigType_str(quals, 0); - if (is_const) { - if (is_func) { - Append(result, " "); - Append(result, "const"); - } else { - Insert(result, 0, "const "); - } - } + String *popped_decl = SwigType_pop_function(rettype); + if (return_base_type) + Append(rettype, return_base_type); - Chop(result); - - if (rettype) { - Insert(result, 0, " "); + if (!conversion_operator) { + SwigType *rettype_stripped = SwigType_strip_qualifiers(rettype); String *rtype = SwigType_str(rettype, 0); - Insert(result, 0, rtype); + Append(result, rtype); + if (SwigType_issimple(rettype_stripped) && return_base_type) + Append(result, " "); Delete(rtype); + Delete(rettype_stripped); } + if (id) + Append(result, id); + + String *args_string = default_args ? ParmList_str_defaultargs(args) : ParmList_str(args); + Printv(result, "(", args_string, ")", NIL); + + if (qualifiers) + Printv(result, " ", qualifiers, NIL); + + // Reformat result to how it has been historically + Replaceall(result, ",", ", "); + Replaceall(result, "=", " = "); + + Delete(args_string); + Delete(popped_decl); + Delete(qualifiers); + Delete(quals); + Delete(rettype); return result; } @@ -272,6 +194,7 @@ String *Swig_method_decl(SwigType *rettype, SwigType *decl, const_String_or_char * to add an extra dynamic_cast to call the public C++ wrapper in the director class. * Also for non-static protected members when the allprotected option is on. * ----------------------------------------------------------------------------- */ + void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f) { // TODO: why is the storage element removed in staticmemberfunctionHandler ?? if ((!is_public(n) && (is_member_director(n) || GetFlag(n, "explicitcall"))) || @@ -290,13 +213,13 @@ void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f) { } } -/* ------------------------------------------------------------ +/* ----------------------------------------------------------------------------- * Swig_director_parms_fixup() * * For each parameter in the C++ member function, copy the parameter name * to its "lname"; this ensures that Swig_typemap_attach_parms() will do * the right thing when it sees strings like "$1" in "directorin" typemaps. - * ------------------------------------------------------------ */ + * ----------------------------------------------------------------------------- */ void Swig_director_parms_fixup(ParmList *parms) { Parm *p; diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index 916030437..896872d47 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -3857,12 +3857,11 @@ private: String *cxx_director_name = NewString("SwigDirector_"); Append(cxx_director_name, class_name); - String *decl = Swig_method_decl(NULL, Getattr(n, "decl"), - cxx_director_name, first_parm, 0, 0); + String *decl = Swig_method_decl(NULL, Getattr(n, "decl"), cxx_director_name, first_parm, 0); Printv(f_c_directors_h, " ", decl, ";\n", NULL); Delete(decl); - decl = Swig_method_decl(NULL, Getattr(n, "decl"), cxx_director_name, first_parm, 0, 0); + decl = Swig_method_decl(NULL, Getattr(n, "decl"), cxx_director_name, first_parm, 0); Printv(f_c_directors, cxx_director_name, "::", decl, "\n", NULL); Delete(decl); @@ -4587,7 +4586,7 @@ private: Append(upcall_method_name, overname); } SwigType *rtype = Getattr(n, "classDirectorMethods:type"); - String *upcall_decl = Swig_method_decl(rtype, Getattr(n, "decl"), upcall_method_name, parms, 0, 0); + String *upcall_decl = Swig_method_decl(rtype, Getattr(n, "decl"), upcall_method_name, parms, 0); Printv(f_c_directors_h, " ", upcall_decl, " {\n", NULL); Delete(upcall_decl); @@ -5035,13 +5034,13 @@ private: // Declare the method for the director class. SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); - String *decl = Swig_method_decl(rtype, Getattr(n, "decl"), Getattr(n, "name"), parms, 0, 0); + String *decl = Swig_method_decl(rtype, Getattr(n, "decl"), Getattr(n, "name"), parms, 0); Printv(f_c_directors_h, " virtual ", decl, NULL); Delete(decl); String *qname = NewString(""); Printv(qname, "SwigDirector_", class_name, "::", Getattr(n, "name"), NULL); - decl = Swig_method_decl(rtype, Getattr(n, "decl"), qname, parms, 0, 0); + decl = Swig_method_decl(rtype, Getattr(n, "decl"), qname, parms, 0); Printv(w->def, decl, NULL); Delete(decl); Delete(qname); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 55bfc8c05..608c1c529 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -4243,11 +4243,11 @@ public: /* header declaration, start wrapper definition */ String *target; SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); - target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); + target = Swig_method_decl(rtype, decl, qualified_name, l, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); - target = Swig_method_decl(rtype, decl, name, l, 0, 1); + target = Swig_method_decl(rtype, decl, name, l, 1); Printf(declaration, " virtual %s", target); Delete(target); @@ -4562,7 +4562,7 @@ public: /* constructor */ { String *basetype = Getattr(parent, "classtype"); - String *target = Swig_method_decl(0, decl, dirclassname, parms, 0, 0); + String *target = Swig_method_decl(0, decl, dirclassname, parms, 0); String *call = Swig_csuperclass_call(0, basetype, superparms); String *classtype = SwigType_namestr(Getattr(n, "name")); @@ -4576,7 +4576,7 @@ public: /* constructor header */ { - String *target = Swig_method_decl(0, decl, dirclassname, parms, 0, 1); + String *target = Swig_method_decl(0, decl, dirclassname, parms, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 7005b556c..d42bd4684 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1416,12 +1416,12 @@ public: String *pclassname = NewStringf("SwigDirector_%s", classname); String *qualified_name = NewStringf("%s::%s", pclassname, name); SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); - target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); + target = Swig_method_decl(rtype, decl, qualified_name, l, 0); Printf(w->def, "%s {", target); Delete(qualified_name); Delete(target); /* header declaration */ - target = Swig_method_decl(rtype, decl, name, l, 0, 1); + target = Swig_method_decl(rtype, decl, name, l, 1); Printf(declaration, " virtual %s;", target); Delete(target); @@ -1716,7 +1716,7 @@ public: Wrapper *w = NewWrapper(); String *call; String *basetype = Getattr(parent, "classtype"); - String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); + String *target = Swig_method_decl(0, decl, classname, parms, 0); call = Swig_csuperclass_call(0, basetype, superparms); Printf(w->def, "%s::%s: %s, Swig::Director(self) { }", classname, target, call); Delete(target); @@ -1727,7 +1727,7 @@ public: /* constructor header */ { - String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); + String *target = Swig_method_decl(0, decl, classname, parms, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 79ad69379..0d7168225 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -1234,7 +1234,7 @@ public: Wrapper *w = NewWrapper(); String *call; String *basetype = Getattr(parent, "classtype"); - String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); + String *target = Swig_method_decl(0, decl, classname, parms, 0); call = Swig_csuperclass_call(0, basetype, superparms); Printf(w->def, "%s::%s: %s," "\nSwig::Director(static_cast<%s*>(this)) { \n", classname, target, call, basetype); Append(w->def, "}\n"); @@ -1246,7 +1246,7 @@ public: // constructor header { - String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); + String *target = Swig_method_decl(0, decl, classname, parms, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } @@ -1310,13 +1310,13 @@ public: String *pclassname = NewStringf("SwigDirector_%s", classname); String *qualified_name = NewStringf("%s::%s", pclassname, name); SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); - target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); + target = Swig_method_decl(rtype, decl, qualified_name, l, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); // header declaration - target = Swig_method_decl(rtype, decl, name, l, 0, 1); + target = Swig_method_decl(rtype, decl, name, l, 1); Printf(declaration, " virtual %s", target); Delete(target); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index e263b067f..d49da695f 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -2018,7 +2018,7 @@ public: Wrapper *w = NewWrapper(); String *call; String *basetype = Getattr(parent, "classtype"); - String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); + String *target = Swig_method_decl(0, decl, classname, parms, 0); call = Swig_csuperclass_call(0, basetype, superparms); Printf(w->def, "%s::%s: %s, Swig::Director(self) { \n", classname, target, call); Printf(w->def, " SWIG_DIRECTOR_RGTR((%s *)this, this); \n", basetype); @@ -2031,7 +2031,7 @@ public: /* constructor header */ { - String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); + String *target = Swig_method_decl(0, decl, classname, parms, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } @@ -2080,12 +2080,12 @@ public: String *pclassname = NewStringf("SwigDirector_%s", classname); String *qualified_name = NewStringf("%s::%s", pclassname, name); SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); - target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); + target = Swig_method_decl(rtype, decl, qualified_name, l, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); /* header declaration */ - target = Swig_method_decl(rtype, decl, name, l, 0, 1); + target = Swig_method_decl(rtype, decl, name, l, 1); Printf(declaration, " virtual %s", target); Delete(target); diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index f3d621218..dcfe4e377 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2478,7 +2478,7 @@ done: String *call; String *basetype = Getattr(parent, "classtype"); - String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); + String *target = Swig_method_decl(0, decl, classname, parms, 0); call = Swig_csuperclass_call(0, basetype, superparms); Printf(w->def, "%s::%s: %s, Swig::Director(self) {", classname, target, call); Append(w->def, "}"); @@ -2490,7 +2490,7 @@ done: /* constructor header */ { - String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); + String *target = Swig_method_decl(0, decl, classname, parms, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } @@ -2534,12 +2534,12 @@ done: String *pclassname = NewStringf("SwigDirector_%s", classname); String *qualified_name = NewStringf("%s::%s", pclassname, name); SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); - target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); + target = Swig_method_decl(rtype, decl, qualified_name, l, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); /* header declaration */ - target = Swig_method_decl(rtype, decl, name, l, 0, 1); + target = Swig_method_decl(rtype, decl, name, l, 1); Printf(declaration, " virtual %s", target); Delete(target); diff --git a/Source/Modules/php5.cxx b/Source/Modules/php5.cxx index ec7ae78ce..4710aa01a 100644 --- a/Source/Modules/php5.cxx +++ b/Source/Modules/php5.cxx @@ -2466,7 +2466,7 @@ done: // We put TSRMLS_DC after the self parameter in order to cope with // any default parameters. - String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); + String *target = Swig_method_decl(0, decl, classname, parms, 0); const char * p = Char(target); const char * comma = strchr(p, ','); int ins = comma ? (int)(comma - p) : Len(target) - 1; @@ -2485,7 +2485,7 @@ done: { // We put TSRMLS_DC after the self parameter in order to cope with // any default parameters. - String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); + String *target = Swig_method_decl(0, decl, classname, parms, 1); const char * p = Char(target); const char * comma = strchr(p, ','); int ins = comma ? (int)(comma - p) : Len(target) - 1; @@ -2534,12 +2534,12 @@ done: String *pclassname = NewStringf("SwigDirector_%s", classname); String *qualified_name = NewStringf("%s::%s", pclassname, name); SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); - target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); + target = Swig_method_decl(rtype, decl, qualified_name, l, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); /* header declaration */ - target = Swig_method_decl(rtype, decl, name, l, 0, 1); + target = Swig_method_decl(rtype, decl, name, l, 1); Printf(declaration, " virtual %s", target); Delete(target); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 0c8913006..f5d94d762 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3733,7 +3733,7 @@ public: Wrapper *w = NewWrapper(); String *call; String *basetype = Getattr(parent, "classtype"); - String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); + String *target = Swig_method_decl(0, decl, classname, parms, 0); call = Swig_csuperclass_call(0, basetype, superparms); Printf(w->def, "%s::%s: %s, Swig::Director(self) { \n", classname, target, call); Printf(w->def, " SWIG_DIRECTOR_RGTR((%s *)this, this); \n", basetype); @@ -3746,7 +3746,7 @@ public: /* constructor header */ { - String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); + String *target = Swig_method_decl(0, decl, classname, parms, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } @@ -5362,12 +5362,12 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { String *pclassname = NewStringf("SwigDirector_%s", classname); String *qualified_name = NewStringf("%s::%s", pclassname, name); SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); - target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); + target = Swig_method_decl(rtype, decl, qualified_name, l, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); /* header declaration */ - target = Swig_method_decl(rtype, decl, name, l, 0, 1); + target = Swig_method_decl(rtype, decl, name, l, 1); Printf(declaration, " virtual %s", target); Delete(target); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 539a7b391..69a849d16 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2925,7 +2925,7 @@ public: Wrapper *w = NewWrapper(); String *call; String *basetype = Getattr(parent, "classtype"); - String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); + String *target = Swig_method_decl(0, decl, classname, parms, 0); call = Swig_csuperclass_call(0, basetype, superparms); Printf(w->def, "%s::%s: %s, Swig::Director(self) { }", classname, target, call); Delete(target); @@ -2936,7 +2936,7 @@ public: /* constructor header */ { - String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); + String *target = Swig_method_decl(0, decl, classname, parms, 1); Printf(f_directors_h, " %s;\n", target); Delete(target); } @@ -3102,12 +3102,12 @@ public: String *pclassname = NewStringf("SwigDirector_%s", classname); String *qualified_name = NewStringf("%s::%s", pclassname, name); SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type"); - target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); + target = Swig_method_decl(rtype, decl, qualified_name, l, 0); Printf(w->def, "%s", target); Delete(qualified_name); Delete(target); /* header declaration */ - target = Swig_method_decl(rtype, decl, name, l, 0, 1); + target = Swig_method_decl(rtype, decl, name, l, 1); Printf(declaration, " virtual %s", target); Delete(target); diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 34763cc09..31b506f77 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -385,7 +385,7 @@ String *Swig_csuperclass_call(String *base, String *method, ParmList *l); String *Swig_class_declaration(Node *n, String *name); String *Swig_class_name(Node *n); String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms); -String *Swig_method_decl(SwigType *rtype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values); +String *Swig_method_decl(SwigType *return_base_type, SwigType *decl, const_String_or_char_ptr id, List *args, int default_args); String *Swig_director_declaration(Node *n); void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f); void Swig_director_parms_fixup(ParmList *parms);