fix %varargs
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7093 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
697b6a4c4d
commit
175e89dc8f
2 changed files with 23 additions and 45 deletions
|
|
@ -1137,9 +1137,30 @@ static int is_cfunction(Node *n) {
|
||||||
static void default_arguments(Node *n) {
|
static void default_arguments(Node *n) {
|
||||||
Node *function = n;
|
Node *function = n;
|
||||||
|
|
||||||
/* Do not add in functions if kwargs is being used or if user wants old default argument wrapping
|
|
||||||
(one wrapped method per function irrespective of number of default arguments) */
|
|
||||||
if (function) {
|
if (function) {
|
||||||
|
ParmList *varargs = Getattr(function,"feature:varargs");
|
||||||
|
if (varargs) {
|
||||||
|
/* Handles the %varargs directive by looking for "feature:varargs" and
|
||||||
|
* substituting ... with an alternative set of arguments. */
|
||||||
|
Parm *p = Getattr(function,"parms");
|
||||||
|
Parm *pp = 0;
|
||||||
|
while (p) {
|
||||||
|
SwigType *t = Getattr(p,"type");
|
||||||
|
if (Strcmp(t,"v(...)") == 0) {
|
||||||
|
if (pp) {
|
||||||
|
set_nextSibling(pp,Copy(varargs));
|
||||||
|
} else {
|
||||||
|
Setattr(function,"parms", Copy(varargs));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pp = p;
|
||||||
|
p = nextSibling(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do not add in functions if kwargs is being used or if user wants old default argument wrapping
|
||||||
|
(one wrapped method per function irrespective of number of default arguments) */
|
||||||
if (compact_default_args
|
if (compact_default_args
|
||||||
|| is_cfunction(function)
|
|| is_cfunction(function)
|
||||||
|| Getattr(function,"feature:compactdefaultargs")
|
|| Getattr(function,"feature:compactdefaultargs")
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,6 @@
|
||||||
* type-expansion. All types are fully qualified with namespace prefixes
|
* type-expansion. All types are fully qualified with namespace prefixes
|
||||||
* and other information needed for compilation.
|
* and other information needed for compilation.
|
||||||
*
|
*
|
||||||
* This module also handles the %varargs directive by looking for
|
|
||||||
* "feature:varargs" and substituting ... with an alternative set of
|
|
||||||
* arguments.
|
|
||||||
*
|
|
||||||
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
* Author(s) : David Beazley (beazley@cs.uchicago.edu)
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998-2002. The University of Chicago
|
* Copyright (C) 1998-2002. The University of Chicago
|
||||||
|
|
@ -558,26 +554,6 @@ class TypePass : private Dispatcher {
|
||||||
Delattr(n,"throws");
|
Delattr(n,"throws");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search for var args */
|
|
||||||
if (Getattr(n,"feature:varargs")) {
|
|
||||||
ParmList *v = Getattr(n,"feature:varargs");
|
|
||||||
Parm *p = Getattr(n,"parms");
|
|
||||||
Parm *pp = 0;
|
|
||||||
while (p) {
|
|
||||||
SwigType *t = Getattr(p,"type");
|
|
||||||
if (Strcmp(t,"v(...)") == 0) {
|
|
||||||
if (pp) {
|
|
||||||
set_nextSibling(pp,Copy(v));
|
|
||||||
} else {
|
|
||||||
Setattr(n,"parms", Copy(v));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pp = p;
|
|
||||||
p = nextSibling(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Normalize types. */
|
/* Normalize types. */
|
||||||
SwigType *ty = Getattr(n,"type");
|
SwigType *ty = Getattr(n,"type");
|
||||||
normalize_type(ty);
|
normalize_type(ty);
|
||||||
|
|
@ -638,25 +614,6 @@ class TypePass : private Dispatcher {
|
||||||
Delattr(n,"throws");
|
Delattr(n,"throws");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search for var args */
|
|
||||||
if (Getattr(n,"feature:varargs")) {
|
|
||||||
ParmList *v = Getattr(n,"feature:varargs");
|
|
||||||
Parm *p = Getattr(n,"parms");
|
|
||||||
Parm *pp = 0;
|
|
||||||
while (p) {
|
|
||||||
SwigType *t = Getattr(p,"type");
|
|
||||||
if (Strcmp(t,"v(...)") == 0) {
|
|
||||||
if (pp) {
|
|
||||||
set_nextSibling(pp,Copy(v));
|
|
||||||
} else {
|
|
||||||
Setattr(n,"parms", Copy(v));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
pp = p;
|
|
||||||
p = nextSibling(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
normalize_parms(Getattr(n,"parms"));
|
normalize_parms(Getattr(n,"parms"));
|
||||||
normalize_parms(Getattr(n,"throws"));
|
normalize_parms(Getattr(n,"throws"));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue