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:
Matthias Köppe 2000-08-31 12:12:40 +00:00
commit dbd9b844a8
3 changed files with 45 additions and 5 deletions

View file

@ -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
}
#endif

View file

@ -93,6 +93,12 @@ SWIG_Guile_GetPtr (SCM s, void **result, _swig_type_info *type);
SWIGSTATIC SCM
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
}
#endif

View file

@ -639,11 +639,23 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l)
Wrapper_print (f, f_wrappers);
if (numargs > 10) {
// Guile would complain: too many args
Printf(stderr,
"%s : Line %d. Warning. Too many arguments in Guile wrapper "
"for function %s (max. 10).\n",
input_file, line_number, name);
int i;
/* gh_new_procedure would complain: too many args */
/* Build a wrapper wrapper */
Printv(f_wrappers, "static SCM\n", wname,"_rest (SCM rest)\n", 0);
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 {
// Now register the function