From 16a603861cb24f28ab52a48535e21014912dce92 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 28 Sep 2006 02:07:19 +0000 Subject: [PATCH] Just generate the wrapper with items and ST(%d) rather than trying to search and replace argc and argv[%d] afterwards. Fixes bugs #1529249, #1566718 (and really fixes #1228480). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9371 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Source/Modules/perl5.cxx | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/SWIG/Source/Modules/perl5.cxx b/SWIG/Source/Modules/perl5.cxx index 7a6e86391..a404c91b0 100644 --- a/SWIG/Source/Modules/perl5.cxx +++ b/SWIG/Source/Modules/perl5.cxx @@ -101,6 +101,13 @@ static int have_operators = 0; class PERL5 : public Language { public: + PERL5() : Language() { + Clear(argc_template_string); + Printv(argc_template_string, "items", NIL); + Clear(argv_template_string); + Printv(argv_template_string, "ST(%d)", NIL); + } + /* Test to see if a type corresponds to something wrapped with a shadow class */ Node *is_shadow(SwigType *t) { Node *n; @@ -741,26 +748,17 @@ public: Printf(command_tab,"{\"%s::%s\", %s},\n", cmodule, iname, wname); } else if (!Getattr(n,"sym:nextSibling")) { /* Generate overloaded dispatch function */ - int maxargs, ii; + int maxargs; String *dispatch = Swig_overload_dispatch_cast(n,"++PL_markstack_ptr; SWIG_CALLXS(%s); return;",&maxargs); - + /* Generate a dispatch wrapper for all overloaded functions */ Wrapper *df = NewWrapper(); String *dname = Swig_name_wrapper(iname); - Printv(df->def, - "XS(", dname, ") {\n", NIL); - + Printv(df->def, "XS(", dname, ") {\n", NIL); + Wrapper_add_local(df,"dXSARGS", "dXSARGS"); - Replaceid(dispatch,"argc","items"); - for (ii = 0; ii < maxargs; ii++) { - char pat[128]; - char rep[128]; - sprintf(pat,"argv[%d]",ii); - sprintf(rep,"ST(%d)",ii); - Replaceall(dispatch,pat,rep); - } Printv(df->code,dispatch,"\n",NIL); Printf(df->code,"croak(\"No matching function for overloaded '%s'\");\n", iname); Printf(df->code,"XSRETURN(0);\n");