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/SWIG@9371 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2006-09-28 02:07:19 +00:00
commit 675e83dc22

View file

@ -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");