Fix for virtual_poly.i test case.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5585 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
bbeeed588b
commit
944e1a77d2
1 changed files with 70 additions and 41 deletions
|
|
@ -669,11 +669,50 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------
|
/* ---------------------------------------------------------------------
|
||||||
* marshalInputArgs(int numarg, int numreq, int start, Wrapper *f)
|
* applyInputTypemap()
|
||||||
*
|
*
|
||||||
* Checks each of the parameters in the parameter list for a "check"
|
* Look up the appropriate "in" typemap for this parameter (p),
|
||||||
* typemap and (if it finds one) inserts the typemapping code into
|
* substitute the correct strings for the $target and $input typemap
|
||||||
* the function wrapper.
|
* parameters, and dump the resulting code to the wrapper file.
|
||||||
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
Parm *applyInputTypemap(Parm *p, String *ln, String *source, Wrapper *f) {
|
||||||
|
String *tm;
|
||||||
|
SwigType *pt = Getattr(p,"type");
|
||||||
|
if ((tm = Getattr(p,"tmap:in"))) {
|
||||||
|
Replaceall(tm,"$target",ln);
|
||||||
|
Replaceall(tm,"$source",source);
|
||||||
|
Replaceall(tm,"$input",source);
|
||||||
|
Setattr(p,"emit:input",Copy(source));
|
||||||
|
Printf(f->code,"%s\n", tm);
|
||||||
|
p = Getattr(p,"tmap:in:next");
|
||||||
|
} else {
|
||||||
|
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number,
|
||||||
|
"Unable to use type %s as a function argument.\n", SwigType_str(pt,0));
|
||||||
|
p = nextSibling(p);
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
Parm *skipIgnoredArgs(Parm *p) {
|
||||||
|
while (checkAttribute(p,"tmap:in:numinputs","0")) {
|
||||||
|
p = Getattr(p,"tmap:in:next");
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------
|
||||||
|
* marshalInputArgs()
|
||||||
|
*
|
||||||
|
* Process all of the arguments passed into the scripting language
|
||||||
|
* method and convert them into C/C++ function arguments using the
|
||||||
|
* supplied typemaps.
|
||||||
|
*
|
||||||
|
* The 'start' argument indicates which of the C/C++ function arguments
|
||||||
|
* produced here corresponds to the first value in Ruby's argv[] array.
|
||||||
|
* The value of start is either zero or one. If start is zero, then
|
||||||
|
* the first argument (with name arg1) is based on the value of argv[0].
|
||||||
|
* If start is one, then arg1 is based on the value of argv[1].
|
||||||
* --------------------------------------------------------------------- */
|
* --------------------------------------------------------------------- */
|
||||||
|
|
||||||
void marshalInputArgs(Node *n, ParmList *l, int numarg, int numreq, int start, String *kwargs, bool allow_kwargs, Wrapper *f) {
|
void marshalInputArgs(Node *n, ParmList *l, int numarg, int numreq, int start, String *kwargs, bool allow_kwargs, Wrapper *f) {
|
||||||
|
|
@ -683,6 +722,8 @@ public:
|
||||||
String *source;
|
String *source;
|
||||||
String *target;
|
String *target;
|
||||||
|
|
||||||
|
assert((start == 0) || (start == 1));
|
||||||
|
|
||||||
source = NewString("");
|
source = NewString("");
|
||||||
target = NewString("");
|
target = NewString("");
|
||||||
|
|
||||||
|
|
@ -692,23 +733,28 @@ public:
|
||||||
Printf(kwargs,"{ ");
|
Printf(kwargs,"{ ");
|
||||||
for (i = 0, p = l; i < numarg; i++) {
|
for (i = 0, p = l; i < numarg; i++) {
|
||||||
|
|
||||||
/* Skip ignored arguments */
|
p = skipIgnoredArgs(p);
|
||||||
while (checkAttribute(p,"tmap:in:numinputs","0")) {
|
|
||||||
p = Getattr(p,"tmap:in:next");
|
String *pn = Getattr(p,"name");
|
||||||
|
String *ln = Getattr(p,"lname");
|
||||||
|
|
||||||
|
/* Produce string representation of source argument */
|
||||||
|
Clear(source);
|
||||||
|
|
||||||
|
/* First argument is a special case */
|
||||||
|
if (i == 0) {
|
||||||
|
if (use_self)
|
||||||
|
Printv(source,"self",NIL);
|
||||||
|
else {
|
||||||
|
assert(start == 0);
|
||||||
|
Printv(source,"argv[0]",NIL);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert(i >= start);
|
||||||
|
Printf(source,"argv[%d]",i-start);
|
||||||
}
|
}
|
||||||
|
|
||||||
SwigType *pt = Getattr(p,"type");
|
/* Produce string representation of target argument */
|
||||||
String *pn = Getattr(p,"name");
|
|
||||||
String *ln = Getattr(p,"lname");
|
|
||||||
|
|
||||||
/* Produce string representation of source and target arguments */
|
|
||||||
Clear(source);
|
|
||||||
int selfp = (use_self && i == 0);
|
|
||||||
if (selfp)
|
|
||||||
Printv(source,"self",NIL);
|
|
||||||
else
|
|
||||||
Printf(source,"argv[%d]",i-start);
|
|
||||||
|
|
||||||
Clear(target);
|
Clear(target);
|
||||||
Printf(target,"%s",Char(ln));
|
Printf(target,"%s",Char(ln));
|
||||||
|
|
||||||
|
|
@ -724,18 +770,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Look for an input typemap */
|
/* Look for an input typemap */
|
||||||
if ((tm = Getattr(p,"tmap:in"))) {
|
p = applyInputTypemap(p, ln, source, f);
|
||||||
Replaceall(tm,"$target",ln);
|
|
||||||
Replaceall(tm,"$source",source);
|
|
||||||
Replaceall(tm,"$input",source);
|
|
||||||
Setattr(p,"emit:input",Copy(source));
|
|
||||||
Printf(f->code,"%s\n", tm);
|
|
||||||
p = Getattr(p,"tmap:in:next");
|
|
||||||
} else {
|
|
||||||
Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number,
|
|
||||||
"Unable to use type %s as a function argument.\n", SwigType_str(pt,0));
|
|
||||||
p = nextSibling(p);
|
|
||||||
}
|
|
||||||
if (i >= numreq) {
|
if (i >= numreq) {
|
||||||
Printf(f->code,"}\n");
|
Printf(f->code,"}\n");
|
||||||
}
|
}
|
||||||
|
|
@ -941,8 +976,8 @@ public:
|
||||||
int varargs = emit_isvarargs(l);
|
int varargs = emit_isvarargs(l);
|
||||||
bool allow_kwargs = use_kw || Getattr(n,"feature:kwargs");
|
bool allow_kwargs = use_kw || Getattr(n,"feature:kwargs");
|
||||||
|
|
||||||
int start = (current == MEMBER_FUNC || current == MEMBER_VAR) ? 1 : 0;
|
|
||||||
bool use_director = (current == CONSTRUCTOR_INITIALIZE && Swig_directorclass(n));
|
bool use_director = (current == CONSTRUCTOR_INITIALIZE && Swig_directorclass(n));
|
||||||
|
int start = (current == MEMBER_FUNC || current == MEMBER_VAR || use_director) ? 1 : 0;
|
||||||
|
|
||||||
/* Now write the wrapper function itself */
|
/* Now write the wrapper function itself */
|
||||||
if (current == CONSTRUCTOR_ALLOCATE) {
|
if (current == CONSTRUCTOR_ALLOCATE) {
|
||||||
|
|
@ -952,19 +987,13 @@ public:
|
||||||
Printv(f->def, "static VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL);
|
Printv(f->def, "static VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL);
|
||||||
Printf(f->def, "#endif\n");
|
Printf(f->def, "#endif\n");
|
||||||
} else if (current == CONSTRUCTOR_INITIALIZE) {
|
} else if (current == CONSTRUCTOR_INITIALIZE) {
|
||||||
int na = numarg;
|
|
||||||
int nr = numreq;
|
|
||||||
if (use_director) {
|
|
||||||
na--;
|
|
||||||
nr--;
|
|
||||||
}
|
|
||||||
Printv(f->def, "static VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL);
|
Printv(f->def, "static VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL);
|
||||||
if (!varargs) {
|
if (!varargs) {
|
||||||
Printf(f->code,"if ((argc < %d) || (argc > %d))\n", nr-start, na-start);
|
Printf(f->code,"if ((argc < %d) || (argc > %d))\n", numreq-start, numarg-start);
|
||||||
} else {
|
} else {
|
||||||
Printf(f->code,"if (argc < %d)\n", nr-start);
|
Printf(f->code,"if (argc < %d)\n", numreq-start);
|
||||||
}
|
}
|
||||||
Printf(f->code,"rb_raise(rb_eArgError, \"wrong # of arguments(%%d for %d)\",argc);\n",nr-start);
|
Printf(f->code,"rb_raise(rb_eArgError, \"wrong # of arguments(%%d for %d)\",argc);\n",numreq-start);
|
||||||
} else {
|
} else {
|
||||||
Printv(f->def, "static VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL);
|
Printv(f->def, "static VALUE\n", wname, "(int argc, VALUE *argv, VALUE self) {", NIL);
|
||||||
if (!varargs) {
|
if (!varargs) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue