Allow number of arguments replacement when overloading.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4316 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
d03f4a7db7
commit
28acc3cfbc
1 changed files with 22 additions and 4 deletions
|
|
@ -267,6 +267,22 @@ static bool print_typecheck(String *f, int j, Parm *pj)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String *
|
||||||
|
ReplaceFormat (const String_or_char *fmt, int j)
|
||||||
|
{
|
||||||
|
String *lfmt = NewString (fmt);
|
||||||
|
char buf[50];
|
||||||
|
sprintf (buf, "%d", j);
|
||||||
|
Replaceall (lfmt, "$numargs", buf);
|
||||||
|
int i;
|
||||||
|
String *commaargs = NewString ("");
|
||||||
|
for (i=0; i < j; i++) {
|
||||||
|
Printf (commaargs, ", argv[%d]", i);
|
||||||
|
}
|
||||||
|
Replaceall (lfmt, "$commaargs", commaargs);
|
||||||
|
return lfmt;
|
||||||
|
};
|
||||||
|
|
||||||
String *
|
String *
|
||||||
Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs) {
|
Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs) {
|
||||||
int i,j;
|
int i,j;
|
||||||
|
|
@ -312,9 +328,11 @@ Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (j >= num_required) {
|
if (j >= num_required) {
|
||||||
|
String *lfmt = ReplaceFormat (fmt, num_arguments);
|
||||||
Printf(f, "if (argc <= %d) {\n", j);
|
Printf(f, "if (argc <= %d) {\n", j);
|
||||||
Printf(f, Char(fmt),Getattr(ni,"wrap:name"));
|
Printf(f, Char(lfmt),Getattr(ni,"wrap:name"));
|
||||||
Printf(f, "}\n");
|
Printf(f, "}\n");
|
||||||
|
Delete (lfmt);
|
||||||
}
|
}
|
||||||
if (print_typecheck(f, j, pj)) {
|
if (print_typecheck(f, j, pj)) {
|
||||||
Printf(f, "if (_v) {\n");
|
Printf(f, "if (_v) {\n");
|
||||||
|
|
@ -325,7 +343,9 @@ Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs) {
|
||||||
else pj = nextSibling(pj);
|
else pj = nextSibling(pj);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
Printf(f, Char(fmt),Getattr(ni,"wrap:name"));
|
String *lfmt = ReplaceFormat (fmt, num_arguments);
|
||||||
|
Printf(f, Char(lfmt),Getattr(ni,"wrap:name"));
|
||||||
|
Delete (lfmt);
|
||||||
/* close braces */
|
/* close braces */
|
||||||
for (/* empty */; num_braces > 0; num_braces--)
|
for (/* empty */; num_braces > 0; num_braces--)
|
||||||
Printf(f, "}\n");
|
Printf(f, "}\n");
|
||||||
|
|
@ -334,5 +354,3 @@ Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs) {
|
||||||
Delete(dispatch);
|
Delete(dispatch);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue