diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index f2208aa08..c2849f941 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -16,6 +16,8 @@ char cvsroot_perl5_cxx[] = "$Header$"; #include "swigmod.h" +#include "cparse.h" +static int treduce = SWIG_cparse_template_reduce(1); #include @@ -128,6 +130,7 @@ public: int cppcast = 1; SWIG_library_directory("perl5"); + for (i = 1; i < argc; i++) { if (argv[i]) { if(strcmp(argv[i],"-package") == 0) { diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 1e8615a36..336d963b6 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -13,6 +13,7 @@ char cvsroot_python_cxx[] = "$Header$"; #include "swigmod.h" #include "cparse.h" +static int treduce = SWIG_cparse_template_reduce(1); #include @@ -1461,7 +1462,8 @@ public: /* Insert cleanup code */ for (p = l; p;) { - if (!checkAttribute(p,"tmap:in:numinputs","0") && (tm = Getattr(p,"tmap:freearg"))) { + if (!checkAttribute(p,"tmap:in:numinputs","0") && + !Getattr(p,"tmap:in:parse") && (tm = Getattr(p,"tmap:freearg"))) { if (Len(tm) != 0) { Replaceall(tm,"$source",Getattr(p,"lname")); Printv(cleanup,tm,"\n",NIL); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 23fbe9ed3..d94f4bac0 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -13,6 +13,9 @@ char cvsroot_ruby_cxx[] = "$Header$"; #include "swigmod.h" +#include "cparse.h" +static int treduce = SWIG_cparse_template_reduce(1); + #define SWIG_PROTECTED_TARGET_METHODS 1 #include diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 2b78b7b4c..6a9701b80 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -23,6 +23,8 @@ char cvsroot_tcl8_cxx[] = "$Header$"; #include "swigmod.h" +#include "cparse.h" +static int treduce = SWIG_cparse_template_reduce(1); static const char *usage = (char*)"\ Tcl 8 Options (available with -tcl)\n\ @@ -418,7 +420,8 @@ public: /* Insert cleanup code */ for (i = 0, p = parms; p; i++) { - if (!checkAttribute(p,"tmap:in:numinputs","0") && (tm = Getattr(p,"tmap:freearg"))) { + if (!checkAttribute(p,"tmap:in:numinputs","0") + && !Getattr(p,"tmap:in:parse") && (tm = Getattr(p,"tmap:freearg"))) { if (Len(tm) != 0) { Replaceall(tm,"$source",Getattr(p,"lname")); Printv(cleanup,tm,"\n",NIL); diff --git a/Source/Swig/fragment.c b/Source/Swig/fragment.c index 3f4cbf7ea..fa467da0f 100644 --- a/Source/Swig/fragment.c +++ b/Source/Swig/fragment.c @@ -39,7 +39,7 @@ Swig_fragment_register(Node* fragment) { String *type = Getattr(fragment,"type"); if (type) { SwigType *rtype = SwigType_typedef_resolve_all(type); - String *mangle = Swig_string_mangle(rtype); + String *mangle = Swig_string_mangle(type); Append(name,mangle); Delete(mangle); Delete(rtype); @@ -95,9 +95,7 @@ Swig_fragment_emit(Node *n) { } type = Getattr(n,"type"); if (type) { - SwigType *rtype = SwigType_typedef_resolve_all(type); - mangle = Swig_string_mangle(rtype); - Delete(rtype); + mangle = Swig_string_mangle(type); } if (debug) Printf(stdout,"looking fragment %s %s\n",name, type); @@ -133,7 +131,19 @@ Swig_fragment_emit(Node *n) { Setattr(fragments,name,"ignore"); } } + } else { + if (code && type) { + SwigType *rtype = SwigType_typedef_resolve_all(type); + if (!Equal(type,rtype)) { + String *name = Copy(Getattr(n,"value")); + Append(name,rtype); + Swig_fragment_emit(name); + Delete(name); + } + Delete(rtype); + } } + tok = pc ? pc + 1 : 0; if (tok) { pc = char_index(tok,','); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 4889b0900..136f421c1 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -1230,6 +1230,7 @@ String *Swig_typemap_lookup_new(const String_or_char *op, Node *node, const Stri String *symname; String *cname = 0; String *clname = 0; + char *cop = Char(op); #if 0 String *qsn; Symtab *st; @@ -1330,13 +1331,13 @@ Printf(stdout, "Swig_typemap_lookup %s [%s %s]\n", op, type, pname ? pname : "NO Setattr(node,tmop_name(op),s); if (locals) { - sprintf(temp,"%s:locals", Char(op)); + sprintf(temp,"%s:locals", cop); Setattr(node,tmop_name(temp), locals); Delete(locals); } if (HashCheckAttr(tm,k_type,k_SWIGTYPE)) { - sprintf(temp,"%s:SWIGTYPE", Char(op)); + sprintf(temp,"%s:SWIGTYPE", cop); Setattr(node,tmop_name(temp),k_one); } @@ -1345,14 +1346,13 @@ Printf(stdout, "Swig_typemap_lookup %s [%s %s]\n", op, type, pname ? pname : "NO while (kw) { String *value = Copy(Getattr(kw,k_value)); String *type = Getattr(kw,k_type); - if (type) { - SwigType *rtype = SwigType_typedef_resolve_all(type); - String *mangle = Swig_string_mangle(rtype); + char *ckwname = Char(Getattr(kw,k_name)); + if (type) { + String *mangle = Swig_string_mangle(type); StringAppend(value,mangle); Delete(mangle); - Delete(rtype); } - sprintf(temp,"%s:%s",Char(op),Char(Getattr(kw,k_name))); + sprintf(temp,"%s:%s",cop, ckwname); Setattr(node,tmop_name(temp), value); Delete(value); kw = nextSibling(kw); @@ -1361,7 +1361,7 @@ Printf(stdout, "Swig_typemap_lookup %s [%s %s]\n", op, type, pname ? pname : "NO /* Look for warnings */ { String *w; - sprintf(temp,"%s:warning", Char(op)); + sprintf(temp,"%s:warning", cop); w = Getattr(node,tmop_name(temp)); if (w) { Swig_warning(0,Getfile(node),Getline(node),"%s\n", w); @@ -1371,7 +1371,7 @@ Printf(stdout, "Swig_typemap_lookup %s [%s %s]\n", op, type, pname ? pname : "NO /* Look for code fragments */ { String *f; - sprintf(temp,"%s:fragment", Char(op)); + sprintf(temp,"%s:fragment", cop); f = Getattr(node,tmop_name(temp)); if (f) { Swig_fragment_emit(f); @@ -1468,6 +1468,7 @@ Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f) ParmList *locals; int argnum = 0; char temp[256]; + char *cop = Char(op); p = parms; while (p) { @@ -1513,7 +1514,7 @@ Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f) } if (HashCheckAttr(tm,k_type,k_SWIGTYPE)) { - sprintf(temp,"%s:SWIGTYPE", Char(op)); + sprintf(temp,"%s:SWIGTYPE", cop); Setattr(p,tmop_name(temp),k_one); } p = nextSibling(p); @@ -1533,13 +1534,13 @@ Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f) Setattr(firstp,tmop_name(op),s); /* Code object */ if (locals) { - sprintf(temp,"%s:locals", Char(op)); + sprintf(temp,"%s:locals", cop); Setattr(firstp,tmop_name(temp), locals); Delete(locals); } /* Attach a link to the next parameter. Needed for multimaps */ - sprintf(temp,"%s:next",Char(op)); + sprintf(temp,"%s:next",cop); Setattr(firstp,tmop_name(temp),p); /* Attach kwargs */