Drop guilegh interface
All of guile's interface files now use the scm interface. This should not affect any users. Swig generated code using the scm interface can be mixed with gh interface using user code. It does simplify maintenance of the guile swig code though.
This commit is contained in:
parent
3c47730803
commit
b819d2a91e
25 changed files with 1283 additions and 1829 deletions
|
|
@ -23,7 +23,6 @@ Guile Options (available with -guile)\n\
|
|||
-emitslotaccessors - Emit accessor methods for all GOOPS slots\n" "\
|
||||
-exportprimitive - Add the (export ...) code from scmstub into the\n\
|
||||
GOOPS file.\n\
|
||||
-gh - Use the gh_ Guile API. (Guile <= 1.8) \n\
|
||||
-goopsprefix <prefix> - Prepend <prefix> to all goops identifiers\n\
|
||||
-linkage <lstyle> - Use linkage protocol <lstyle> (default `simple')\n\
|
||||
Use `module' for native Guile module linking\n\
|
||||
|
|
@ -44,10 +43,14 @@ Guile Options (available with -guile)\n\
|
|||
-proxy - Export GOOPS class definitions\n\
|
||||
-primsuffix <suffix> - Name appended to primitive module when exporting\n\
|
||||
GOOPS classes. (default = \"primitive\")\n\
|
||||
-scm - Use the scm Guile API. (Guile >= 1.6, default) \n\
|
||||
-scmstub - Output Scheme file with module declaration and\n\
|
||||
exports; only with `passive' and `simple' linkage\n\
|
||||
-useclassprefix - Prepend the class name to all goops identifiers\n\
|
||||
\n\
|
||||
Obsolete parameters:\n\
|
||||
These parameters do nothing, but are kept for compatibility with old scripts only.\n\
|
||||
-gh - Was used to select the gh_ Guile API. \n\
|
||||
-scm - scm Guile API is always used now. \n\
|
||||
\n";
|
||||
|
||||
static File *f_begin = 0;
|
||||
|
|
@ -94,7 +97,6 @@ static String *return_multi_doc = 0;
|
|||
|
||||
static String *exported_symbols = 0;
|
||||
|
||||
static int use_scm_interface = 1;
|
||||
static int exporting_destructor = 0;
|
||||
static String *swigtype_ptr = 0;
|
||||
|
||||
|
|
@ -216,10 +218,8 @@ public:
|
|||
goops = true;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-gh") == 0) {
|
||||
use_scm_interface = 0;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-scm") == 0) {
|
||||
use_scm_interface = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-primsuffix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
|
|
@ -285,10 +285,7 @@ public:
|
|||
/* Add a symbol for this module */
|
||||
Preprocessor_define("SWIGGUILE 1", 0);
|
||||
/* Read in default typemaps */
|
||||
if (use_scm_interface)
|
||||
SWIG_config_file("guile_scm.swg");
|
||||
else
|
||||
SWIG_config_file("guile_gh.swg");
|
||||
SWIG_config_file("guile_scm.swg");
|
||||
allow_overloading();
|
||||
|
||||
}
|
||||
|
|
@ -331,13 +328,6 @@ public:
|
|||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGGUILE\n");
|
||||
|
||||
if (!use_scm_interface) {
|
||||
if (SwigRuntime == 1)
|
||||
Printf(f_runtime, "#define SWIG_GLOBAL\n");
|
||||
if (SwigRuntime == 2)
|
||||
Printf(f_runtime, "#define SWIG_NOINCLUDE\n");
|
||||
}
|
||||
|
||||
/* Write out directives and declarations */
|
||||
|
||||
module = Swig_copy_string(Char(Getattr(n, "name")));
|
||||
|
|
@ -851,7 +841,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
if (use_scm_interface && exporting_destructor) {
|
||||
if (exporting_destructor) {
|
||||
/* Mark the destructor's argument as destroyed. */
|
||||
String *tm = NewString("SWIG_Guile_MarkPointerDestroyed($input);");
|
||||
Replaceall(tm, "$input", Getattr(l, "emit:input"));
|
||||
|
|
@ -868,14 +858,8 @@ public:
|
|||
Printv(f->def, "#define FUNC_NAME \"", proc_name, "\"", NIL);
|
||||
|
||||
// Now write code to make the function call
|
||||
if (!use_scm_interface)
|
||||
Printv(f->code, tab4, "gh_defer_ints();\n", NIL);
|
||||
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if (!use_scm_interface)
|
||||
Printv(actioncode, tab4, "gh_allow_ints();\n", NIL);
|
||||
|
||||
// Now have return value, figure out what to do with it.
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$result", "gswig_result");
|
||||
|
|
@ -958,11 +942,7 @@ public:
|
|||
Printv(f_wrappers, ");\n", NIL);
|
||||
Printv(f_wrappers, "}\n", NIL);
|
||||
/* Register it */
|
||||
if (use_scm_interface) {
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s_rest);\n", proc_name, wname);
|
||||
} else {
|
||||
Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s_rest, 0, 0, 1);\n", proc_name, wname);
|
||||
}
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s_rest);\n", proc_name, wname);
|
||||
} else if (emit_setters && struct_member && strlen(Char(proc_name)) > 3) {
|
||||
int len = Len(proc_name);
|
||||
const char *pc = Char(proc_name);
|
||||
|
|
@ -973,19 +953,13 @@ public:
|
|||
struct_member = 2; /* have a setter */
|
||||
} else
|
||||
Printf(f_init, "SCM getter = ");
|
||||
if (use_scm_interface) {
|
||||
/* GOOPS support uses the MEMBER-set and MEMBER-get functions,
|
||||
so ignore only_setters in this case. */
|
||||
if (only_setters && !goops)
|
||||
Printf(f_init, "scm_c_make_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname);
|
||||
else
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname);
|
||||
} else {
|
||||
if (only_setters && !goops)
|
||||
Printf(f_init, "scm_make_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname);
|
||||
else
|
||||
Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s, %d, %d, 0);\n", proc_name, wname, numreq, numargs - numreq);
|
||||
}
|
||||
/* GOOPS support uses the MEMBER-set and MEMBER-get functions,
|
||||
so ignore only_setters in this case. */
|
||||
if (only_setters && !goops)
|
||||
Printf(f_init, "scm_c_make_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname);
|
||||
else
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname);
|
||||
|
||||
if (!is_setter) {
|
||||
/* Strip off "-get" */
|
||||
char *pws_name = (char *) malloc(sizeof(char) * (len - 3));
|
||||
|
|
@ -993,19 +967,11 @@ public:
|
|||
pws_name[len - 4] = 0;
|
||||
if (struct_member == 2) {
|
||||
/* There was a setter, so create a procedure with setter */
|
||||
if (use_scm_interface) {
|
||||
Printf(f_init, "scm_c_define");
|
||||
} else {
|
||||
Printf(f_init, "gh_define");
|
||||
}
|
||||
Printf(f_init, "scm_c_define");
|
||||
Printf(f_init, "(\"%s\", " "scm_make_procedure_with_setter(getter, setter));\n", pws_name);
|
||||
} else {
|
||||
/* There was no setter, so make an alias to the getter */
|
||||
if (use_scm_interface) {
|
||||
Printf(f_init, "scm_c_define");
|
||||
} else {
|
||||
Printf(f_init, "gh_define");
|
||||
}
|
||||
Printf(f_init, "scm_c_define");
|
||||
Printf(f_init, "(\"%s\", getter);\n", pws_name);
|
||||
}
|
||||
Printf(exported_symbols, "\"%s\", ", pws_name);
|
||||
|
|
@ -1013,15 +979,11 @@ public:
|
|||
}
|
||||
} else {
|
||||
/* Register the function */
|
||||
if (use_scm_interface) {
|
||||
if (exporting_destructor) {
|
||||
Printf(f_init, "((swig_guile_clientdata *)(SWIGTYPE%s->clientdata))->destroy = (guile_destructor) %s;\n", swigtype_ptr, wname);
|
||||
//Printf(f_init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname);
|
||||
}
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname);
|
||||
} else {
|
||||
Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s, %d, %d, 0);\n", proc_name, wname, numreq, numargs - numreq);
|
||||
if (exporting_destructor) {
|
||||
Printf(f_init, "((swig_guile_clientdata *)(SWIGTYPE%s->clientdata))->destroy = (guile_destructor) %s;\n", swigtype_ptr, wname);
|
||||
//Printf(f_init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname);
|
||||
}
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", %d, %d, 0, (swig_guile_proc) %s);\n", proc_name, numreq, numargs - numreq, wname);
|
||||
}
|
||||
} else { /* overloaded function; don't export the single methods */
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
|
|
@ -1044,11 +1006,7 @@ public:
|
|||
Printf(df->code, "#undef FUNC_NAME\n");
|
||||
Printv(df->code, "}\n", NIL);
|
||||
Wrapper_print(df, f_wrappers);
|
||||
if (use_scm_interface) {
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s);\n", proc_name, dname);
|
||||
} else {
|
||||
Printf(f_init, "gh_new_procedure(\"%s\", (swig_guile_proc) %s, 0, 0, 1);\n", proc_name, dname);
|
||||
}
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, 0, 1, (swig_guile_proc) %s);\n", proc_name, dname);
|
||||
DelWrapper(df);
|
||||
Delete(dispatch);
|
||||
Delete(dname);
|
||||
|
|
@ -1221,36 +1179,27 @@ public:
|
|||
/* Read-only variables become a simple procedure returning the
|
||||
value; read-write variables become a simple procedure with
|
||||
an optional argument. */
|
||||
if (use_scm_interface) {
|
||||
|
||||
if (!goops && GetFlag(n, "feature:constasvar")) {
|
||||
/* need to export this function as a variable instead of a procedure */
|
||||
if (scmstub) {
|
||||
/* export the function in the wrapper, and (set!) it in scmstub */
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, %d, 0, (swig_guile_proc) %s);\n", proc_name, !GetFlag(n, "feature:immutable"), var_name);
|
||||
Printf(scmtext, "(set! %s (%s))\n", proc_name, proc_name);
|
||||
} else {
|
||||
/* export the variable directly */
|
||||
Printf(f_init, "scm_c_define(\"%s\", %s(SCM_UNDEFINED));\n", proc_name, var_name);
|
||||
}
|
||||
|
||||
} else {
|
||||
/* Export the function as normal */
|
||||
if (!goops && GetFlag(n, "feature:constasvar")) {
|
||||
/* need to export this function as a variable instead of a procedure */
|
||||
if (scmstub) {
|
||||
/* export the function in the wrapper, and (set!) it in scmstub */
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, %d, 0, (swig_guile_proc) %s);\n", proc_name, !GetFlag(n, "feature:immutable"), var_name);
|
||||
Printf(scmtext, "(set! %s (%s))\n", proc_name, proc_name);
|
||||
} else {
|
||||
/* export the variable directly */
|
||||
Printf(f_init, "scm_c_define(\"%s\", %s(SCM_UNDEFINED));\n", proc_name, var_name);
|
||||
}
|
||||
|
||||
} else {
|
||||
Printf(f_init, "\t gh_new_procedure(\"%s\", (swig_guile_proc) %s, 0, %d, 0);\n", proc_name, var_name, !GetFlag(n, "feature:immutable"));
|
||||
/* Export the function as normal */
|
||||
Printf(f_init, "scm_c_define_gsubr(\"%s\", 0, %d, 0, (swig_guile_proc) %s);\n", proc_name, !GetFlag(n, "feature:immutable"), var_name);
|
||||
}
|
||||
|
||||
} else {
|
||||
/* Read/write variables become a procedure with setter. */
|
||||
if (use_scm_interface) {
|
||||
Printf(f_init, "{ SCM p = scm_c_define_gsubr(\"%s\", 0, 1, 0, (swig_guile_proc) %s);\n", proc_name, var_name);
|
||||
Printf(f_init, "scm_c_define");
|
||||
} else {
|
||||
Printf(f_init, "\t{ SCM p = gh_new_procedure(\"%s\", (swig_guile_proc) %s, 0, 1, 0);\n", proc_name, var_name);
|
||||
Printf(f_init, "gh_define");
|
||||
}
|
||||
Printf(f_init, "{ SCM p = scm_c_define_gsubr(\"%s\", 0, 1, 0, (swig_guile_proc) %s);\n", proc_name, var_name);
|
||||
Printf(f_init, "scm_c_define");
|
||||
Printf(f_init, "(\"%s\", " "scm_make_procedure_with_setter(p, p)); }\n", proc_name);
|
||||
}
|
||||
Printf(exported_symbols, "\"%s\", ", proc_name);
|
||||
|
|
@ -1484,12 +1433,10 @@ public:
|
|||
|
||||
String *mangled_classname = Swig_name_mangle(Getattr(n, "sym:name"));
|
||||
/* Export clientdata structure */
|
||||
if (use_scm_interface) {
|
||||
Printf(f_runtime, "static swig_guile_clientdata _swig_guile_clientdata%s = { NULL, SCM_EOL };\n", mangled_classname);
|
||||
Printf(f_runtime, "static swig_guile_clientdata _swig_guile_clientdata%s = { NULL, SCM_EOL };\n", mangled_classname);
|
||||
|
||||
Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", swigtype_ptr, ", (void *) &_swig_guile_clientdata", mangled_classname, ");\n", NIL);
|
||||
SwigType_remember(ct);
|
||||
}
|
||||
Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", swigtype_ptr, ", (void *) &_swig_guile_clientdata", mangled_classname, ");\n", NIL);
|
||||
SwigType_remember(ct);
|
||||
Delete(ct);
|
||||
|
||||
/* Emit all of the members */
|
||||
|
|
@ -1725,28 +1672,16 @@ public:
|
|||
|
||||
String *runtimeCode() {
|
||||
String *s;
|
||||
if (use_scm_interface) {
|
||||
s = Swig_include_sys("guile_scm_run.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'guile_scm_run.swg");
|
||||
s = NewString("");
|
||||
}
|
||||
} else {
|
||||
s = Swig_include_sys("guile_gh_run.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'guile_gh_run.swg");
|
||||
s = NewString("");
|
||||
}
|
||||
s = Swig_include_sys("guile_scm_run.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'guile_scm_run.swg");
|
||||
s = NewString("");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
String *defaultExternalRuntimeFilename() {
|
||||
if (use_scm_interface) {
|
||||
return NewString("swigguilerun.h");
|
||||
} else {
|
||||
return NewString("swigguileghrun.h");
|
||||
}
|
||||
return NewString("swigguilerun.h");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue