Handle more than 10 args.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@748 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
942219835f
commit
dbd9b844a8
3 changed files with 45 additions and 5 deletions
|
|
@ -259,6 +259,28 @@ void SWIG_Guile_RegisterTypes(_swig_type_info **table)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWIGSTATIC void
|
||||||
|
SWIG_Guile_GetArgs (SCM *dest, SCM rest,
|
||||||
|
int reqargs, int optargs,
|
||||||
|
const char *procname)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i<reqargs; i++) {
|
||||||
|
if (!SCM_CONSP(rest))
|
||||||
|
scm_wrong_num_args(gh_str02scm(procname));
|
||||||
|
*dest++ = SCM_CAR(rest);
|
||||||
|
rest = SCM_CDR(rest);
|
||||||
|
}
|
||||||
|
for (i = 0; i<optargs && SCM_CONSP(rest); i++) {
|
||||||
|
*dest++ = SCM_CAR(rest);
|
||||||
|
rest = SCM_CDR(rest);
|
||||||
|
}
|
||||||
|
for (; i<optargs; i++)
|
||||||
|
*dest++ = GH_NOT_PASSED;
|
||||||
|
if (!SCM_NULLP(rest))
|
||||||
|
scm_wrong_num_args(gh_str02scm(procname));
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,12 @@ SWIG_Guile_GetPtr (SCM s, void **result, _swig_type_info *type);
|
||||||
SWIGSTATIC SCM
|
SWIGSTATIC SCM
|
||||||
SWIG_Guile_MakePtr (void *ptr, _swig_type_info *type);
|
SWIG_Guile_MakePtr (void *ptr, _swig_type_info *type);
|
||||||
|
|
||||||
|
/* Get arguments from an argument list */
|
||||||
|
SWIGSTATIC void
|
||||||
|
SWIG_Guile_GetArgs (SCM *dest, SCM rest,
|
||||||
|
int reqargs, int optargs,
|
||||||
|
const char *procname);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -639,11 +639,23 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
|
||||||
Wrapper_print (f, f_wrappers);
|
Wrapper_print (f, f_wrappers);
|
||||||
|
|
||||||
if (numargs > 10) {
|
if (numargs > 10) {
|
||||||
// Guile would complain: too many args
|
int i;
|
||||||
Printf(stderr,
|
/* gh_new_procedure would complain: too many args */
|
||||||
"%s : Line %d. Warning. Too many arguments in Guile wrapper "
|
/* Build a wrapper wrapper */
|
||||||
"for function %s (max. 10).\n",
|
Printv(f_wrappers, "static SCM\n", wname,"_rest (SCM rest)\n", 0);
|
||||||
input_file, line_number, name);
|
Printv(f_wrappers, "{\n", 0);
|
||||||
|
Printf(f_wrappers, "SCM arg[%d];\n", numargs);
|
||||||
|
Printf(f_wrappers, "SWIG_Guile_GetArgs (arg, rest, %d, %d, \"%s\");\n",
|
||||||
|
numargs-numopt, numopt, proc_name);
|
||||||
|
Printv(f_wrappers, "return ", wname, "(", 0);
|
||||||
|
Printv(f_wrappers, "arg[0]", 0);
|
||||||
|
for (i = 1; i<numargs; i++)
|
||||||
|
Printf(f_wrappers, ", arg[%d]", i);
|
||||||
|
Printv(f_wrappers, ");\n", 0);
|
||||||
|
Printv(f_wrappers, "}\n", 0);
|
||||||
|
/* Register it */
|
||||||
|
Printf (f_init, "\t gh_new_procedure(\"%s\", %s_rest, 0, 0, 1);\n",
|
||||||
|
proc_name, wname, numargs-numopt, numopt);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Now register the function
|
// Now register the function
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue