vararg support for Java and C#

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4575 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2003-03-19 20:44:33 +00:00
commit c201cb7376
4 changed files with 52 additions and 4 deletions

View file

@ -1320,11 +1320,19 @@ class CSHARP : public Language {
if (!static_flag)
Printv(nativecall, "swigCPtr", NIL);
emit_mark_varargs(l);
int gencomma = !static_flag;
/* Output each parameter */
for (i = 0, p=l; p; i++) {
/* Ignored varargs */
if (checkAttribute(p,"varargs:ignore","1")) {
p = nextSibling(p);
continue;
}
/* Ignored parameters */
if (checkAttribute(p,"tmap:in:numinputs","0")) {
p = Getattr(p,"tmap:in:next");
@ -1457,11 +1465,19 @@ class CSHARP : public Language {
Swig_typemap_attach_parms("jstype", l, NULL);
Swig_typemap_attach_parms("javain", l, NULL);
emit_mark_varargs(l);
int gencomma = 0;
/* Output each parameter */
for (i = 0, p=l; p; i++) {
/* Ignored varargs */
if (checkAttribute(p,"varargs:ignore","1")) {
p = nextSibling(p);
continue;
}
/* Ignored parameters */
if (checkAttribute(p,"tmap:in:numinputs","0")) {
p = Getattr(p,"tmap:in:next");
@ -2045,7 +2061,7 @@ swig_csharp(void) {
* ----------------------------------------------------------------------------- */
const char *CSHARP::usage = (char*)"\
CSharp Options (available with -csharp)\n\
C# Options (available with -csharp)\n\
-package <name> - set name of the assembly\n\
-noproxy - Generate the low-level functional interface instead of proxy classes\n\
\n";

View file

@ -328,6 +328,24 @@ emit_isvarargs(ParmList *p) {
return 0;
}
/* -----------------------------------------------------------------------------
* void emit_mark_vararg_parms()
*
* Marks the vararg parameters which are to be ignored.
* Vararg parameters are marked as ignored if there is no 'in' varargs (...)
* typemap.
* ----------------------------------------------------------------------------- */
void emit_mark_varargs(ParmList *l) {
Parm *p = l;
while (p) {
if (SwigType_isvarargs(Getattr(p,"type")))
if (!Getattr(p,"tmap:in"))
Setattr(p,"varargs:ignore","1");
p = nextSibling(p);
}
}
/* -----------------------------------------------------------------------------
* replace_args()
* ----------------------------------------------------------------------------- */
@ -454,5 +472,3 @@ void emit_action(Node *n, Wrapper *f) {
}

View file

@ -554,7 +554,6 @@ class JAVA : public Language {
/* Get number of required and total arguments */
num_arguments = emit_num_arguments(l);
num_required = emit_num_required(l);
int gencomma = 0;
// Now walk the function parameter list and generate code to get arguments
@ -1314,11 +1313,19 @@ class JAVA : public Language {
if (!static_flag)
Printv(nativecall, "swigCPtr", NIL);
emit_mark_varargs(l);
int gencomma = !static_flag;
/* Output each parameter */
for (i = 0, p=l; p; i++) {
/* Ignored varargs */
if (checkAttribute(p,"varargs:ignore","1")) {
p = nextSibling(p);
continue;
}
/* Ignored parameters */
if (checkAttribute(p,"tmap:in:numinputs","0")) {
p = Getattr(p,"tmap:in:next");
@ -1417,11 +1424,19 @@ class JAVA : public Language {
Swig_typemap_attach_parms("jstype", l, NULL);
Swig_typemap_attach_parms("javain", l, NULL);
emit_mark_varargs(l);
int gencomma = 0;
/* Output each parameter */
for (i = 0, p=l; p; i++) {
/* Ignored varargs */
if (checkAttribute(p,"varargs:ignore","1")) {
p = nextSibling(p);
continue;
}
/* Ignored parameters */
if (checkAttribute(p,"tmap:in:numinputs","0")) {
p = Getattr(p,"tmap:in:next");

View file

@ -260,6 +260,7 @@ extern int emit_num_arguments(ParmList *);
extern int emit_num_required(ParmList *);
extern int emit_isvarargs(ParmList *);
extern void emit_attach_parmmaps(ParmList *, Wrapper *f);
extern void emit_mark_varargs(ParmList *l);
extern void emit_action(Node *n, Wrapper *f);
extern List *Swig_overload_rank(Node *n);
extern String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *);