(GUILE::headers): Fix conformance bug: Use the `SWIG_NOINCLUDE'
preprocessor symbol to indicate that SWIG runtime functions are imported from a different module, as it is done in other language modules. (GUILE::initialize): Rework `SWIG_init' declaration, so that it is globally visible only in simple linkage (the user should rename the function by a #define in this case). (GUILE::emit_linkage): In call to `scm_register_module_xxx', cast 2nd arg to `void *'. (GUILE::create_function): In conjunction w/ exception handling, generate setting of preprocessor macro `SCHEME_NAME' at the beginning of the function wrapper, and a corresponding undef at the end. (GUILE::link_variable): Fix bug: Printf the C string, not the String class. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@415 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
dac03b655d
commit
4dd74fc283
1 changed files with 24 additions and 6 deletions
|
|
@ -240,8 +240,7 @@ GUILE::headers (void)
|
|||
// Write out directives and declarations
|
||||
|
||||
if (NoInclude) {
|
||||
/* This module imports the helper functions, so declare them `extern' */
|
||||
fprintf(f_header, "#define SWIG_GLOBAL\n");
|
||||
fprintf(f_header, "#define SWIG_NOINCLUDE\n");
|
||||
}
|
||||
if (Swig_insert_file ("guiledec.swg", f_header) == -1) {
|
||||
fprintf (stderr, "SWIG : Fatal error. ");
|
||||
|
|
@ -268,7 +267,17 @@ GUILE::headers (void)
|
|||
void
|
||||
GUILE::initialize (void)
|
||||
{
|
||||
fprintf (f_init, "SWIGSTATIC void\nSWIG_init (void)\n{\n");
|
||||
switch (linkage) {
|
||||
case GUILE_LSTYLE_SIMPLE:
|
||||
/* Simple linkage; we have to export the SWIG_init function. The user can
|
||||
rename the function by a #define. */
|
||||
fprintf (f_init, "extern void\nSWIG_init (void)\n{\n");
|
||||
break;
|
||||
default:
|
||||
/* Other linkage; we make the SWIG_init function static */
|
||||
fprintf (f_init, "static void\nSWIG_init (void)\n{\n");
|
||||
break;
|
||||
}
|
||||
fprintf (f_init, "\tSWIG_Guile_Init();\n");
|
||||
}
|
||||
|
||||
|
|
@ -307,7 +316,7 @@ GUILE::emit_linkage (String &module_name)
|
|||
String mod = "";
|
||||
mod << module_name;
|
||||
mod.replace ("/", " ");
|
||||
fprintf (f_init, " scm_register_module_xxx (\"%s\", SWIG_init);\n",
|
||||
fprintf (f_init, " scm_register_module_xxx (\"%s\", (void *) SWIG_init);\n",
|
||||
mod.get());
|
||||
fprintf (f_init, " return SCM_UNSPECIFIED;\n");
|
||||
}
|
||||
|
|
@ -457,7 +466,11 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
}
|
||||
}
|
||||
|
||||
f.def << ")\n{";
|
||||
f.def << ")\n{\n";
|
||||
|
||||
// Define the scheme name in C
|
||||
|
||||
f.def << "#define SCHEME_NAME \"" << proc_name << "\"\n";
|
||||
|
||||
// Declare return variable and arguments
|
||||
|
||||
|
|
@ -598,6 +611,11 @@ GUILE::create_function (char *name, char *iname, DataType *d, ParmList *l)
|
|||
// Wrap things up (in a manner of speaking)
|
||||
|
||||
f.code << tab4 << "return gswig_result;\n";
|
||||
|
||||
// Undefine the scheme name
|
||||
|
||||
f.code << "#undef SCHEME_NAME\n";
|
||||
|
||||
f.code << "}\n";
|
||||
|
||||
f.print (f_wrappers);
|
||||
|
|
@ -688,7 +706,7 @@ GUILE::link_variable (char *name, char *iname, DataType *t)
|
|||
fprintf (f_wrappers, "\"%s\")) {\n", t->print_mangle());
|
||||
/* Raise exception */
|
||||
fprintf(f_wrappers, "\tscm_wrong_type_arg(\"%s\", "
|
||||
"%d, s_0);\n", proc_name, 1);
|
||||
"%d, s_0);\n", proc_name.get(), 1);
|
||||
fprintf (f_wrappers, "\t}\n");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue