diff --git a/Lib/guile/guiledec.swg b/Lib/guile/guiledec.swg index e6ae7032b..2a285e7d9 100644 --- a/Lib/guile/guiledec.swg +++ b/Lib/guile/guiledec.swg @@ -45,6 +45,13 @@ GSWIG_scm2str (SCM s) return gh_scm2newstr (s, &len); } +static char +GSWIG_scm2char (SCM s) +{ + if (SCM_CHARP(s)) return SCM_CHAR(s); + scm_wrong_type_arg(NULL, 0, s); +} + typedef struct SwigPtrType SwigPtrType; typedef struct _swig_type_info { diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i index 4f5aa8a0e..27f14bb56 100644 --- a/Lib/guile/typemaps.i +++ b/Lib/guile/typemaps.i @@ -29,8 +29,8 @@ %enddef SIMPLE_MAP(bool, gh_scm2bool, gh_bool2scm, boolean); - SIMPLE_MAP(char, gh_scm2char, gh_char2scm, char); - SIMPLE_MAP(unsigned char, gh_scm2char, gh_char2scm, char); + SIMPLE_MAP(char, GSWIG_scm2char, gh_char2scm, char); + SIMPLE_MAP(unsigned char, GSWIG_scm2char, gh_char2scm, char); SIMPLE_MAP(int, gh_scm2int, gh_int2scm, integer); SIMPLE_MAP(short, gh_scm2int, gh_int2scm, integer); SIMPLE_MAP(long, gh_scm2long, gh_long2scm, integer); diff --git a/Source/Modules1.1/guile.cxx b/Source/Modules1.1/guile.cxx index f3c0f937f..26e4f5e33 100644 --- a/Source/Modules1.1/guile.cxx +++ b/Source/Modules1.1/guile.cxx @@ -474,6 +474,7 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l) int i; int numargs = 0; int numopt = 0; + int pcount = 0; // Make a wrapper name for this char * wname = new char [strlen (prefix) + strlen (iname) + 2]; @@ -484,7 +485,8 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l) Replace(proc_name,"_", "-", DOH_REPLACE_ANY); /* Emit locals etc. into f->code; figure out which args to ignore */ - emit_args (d, l, f); + pcount = emit_args (d, l, f); + numopt = check_numopt(l); /* Declare return variable */ @@ -516,6 +518,8 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l) else { if (numargs!=0) Printf(f->def,", "); Printf(f->def,"SCM s_%d", i); + if (i>=(pcount-numopt)) + Printf(f->code," if (s_%d != GH_NOT_PASSED) {\n", i); ++numargs; if (guile_do_typemap(f->code, "in", pt, pn, source, target, numargs, proc_name, f, 0)) { @@ -533,6 +537,8 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l) guile_do_doc_typemap(signature, "indoc", pt, pn, numargs, proc_name, f); } + if (i>=(pcount-numopt)) + Printf(f->code," }\n"); } /* Check if there are any constraints. */