1 /* -----------------------------------------------------------------------------
2 * See the LICENSE file for information on copyright, usage and redistribution
3 * of SWIG, and the README file for authors - http://www.swig.org/release.html.
7 * Mzscheme language module for SWIG.
8 * ----------------------------------------------------------------------------- */
10 char cvsroot_mzscheme_cxx[] = "$Id: mzscheme.cxx 11133 2009-02-20 07:52:24Z wsfulton $";
16 static const char *usage = (char *) "\
17 Mzscheme Options (available with -mzscheme)\n\
18 -prefix <name> - Set a prefix <name> to be prepended to all names\n\
19 -declaremodule - Create extension that declares a module\n\
20 -noinit - Do not emit scheme_initialize, scheme_reload,\n\
21 scheme_module_name functions\n\
22 -dynamic-load <library>,[library,...] - Do not link with these libraries, dynamic load\n\
26 static String *fieldnames_tab = 0;
27 static String *convert_tab = 0;
28 static String *convert_proto_tab = 0;
29 static String *struct_name = 0;
30 static String *mangled_struct_name = 0;
32 static char *prefix = 0;
33 static bool declaremodule = false;
34 static bool noinit = false;
36 static char *load_libraries = NULL;
38 static String *module = 0;
39 static char *mzscheme_path = (char *) "mzscheme";
40 static String *init_func_def = 0;
42 static File *f_begin = 0;
43 static File *f_runtime = 0;
44 static File *f_header = 0;
45 static File *f_wrappers = 0;
46 static File *f_init = 0;
48 // Used for garbage collection
49 static int exporting_destructor = 0;
50 static String *swigtype_ptr = 0;
51 static String *cls_swigtype = 0;
53 class MZSCHEME:public Language {
56 /* ------------------------------------------------------------
58 * ------------------------------------------------------------ */
60 virtual void main(int argc, char *argv[]) {
64 SWIG_library_directory(mzscheme_path);
66 // Look for certain command line options
67 for (i = 1; i < argc; i++) {
69 if (strcmp(argv[i], "-help") == 0) {
72 } else if (strcmp(argv[i], "-prefix") == 0) {
74 prefix = new char[strlen(argv[i + 1]) + 2];
75 strcpy(prefix, argv[i + 1]);
82 } else if (strcmp(argv[i], "-declaremodule") == 0) {
85 } else if (strcmp(argv[i], "-noinit") == 0) {
90 else if (strcmp(argv[i], "-dynamic-load") == 0) {
91 load_libraries = new char[strlen(argv[i + 1]) + 2];
92 strcpy(load_libraries, argv[i + 1]);
100 // If a prefix has been specified make sure it ends in a '_'
103 if (prefix[strlen(prefix)] != '_') {
104 prefix[strlen(prefix) + 1] = 0;
105 prefix[strlen(prefix)] = '_';
108 prefix = (char *) "swig_";
110 // Add a symbol for this module
112 Preprocessor_define("SWIGMZSCHEME 1", 0);
114 // Set name of typemaps
116 SWIG_typemap_lang("mzscheme");
118 // Read in default typemaps */
119 SWIG_config_file("mzscheme.swg");
124 /* ------------------------------------------------------------
126 * ------------------------------------------------------------ */
128 virtual int top(Node *n) {
130 /* Initialize all of the output files */
131 String *outfile = Getattr(n, "outfile");
133 f_begin = NewFile(outfile, "w", SWIG_output_files());
135 FileErrorDisplay(outfile);
136 SWIG_exit(EXIT_FAILURE);
138 f_runtime = NewString("");
139 f_init = NewString("");
140 f_header = NewString("");
141 f_wrappers = NewString("");
143 /* Register file targets with the SWIG file handler */
144 Swig_register_filebyname("header", f_header);
145 Swig_register_filebyname("wrapper", f_wrappers);
146 Swig_register_filebyname("begin", f_begin);
147 Swig_register_filebyname("runtime", f_runtime);
149 init_func_def = NewString("");
150 Swig_register_filebyname("init", init_func_def);
152 Swig_banner(f_begin);
154 Printf(f_runtime, "\n");
155 Printf(f_runtime, "#define SWIGMZSCHEME\n");
156 Printf(f_runtime, "\n");
158 module = Getattr(n, "name");
162 SwigType_emit_type_table(f_runtime, f_wrappers);
165 Printf(f_init, "#define SWIG_MZSCHEME_CREATE_MENV(env) scheme_primitive_module(scheme_intern_symbol(\"%s\"), env)\n", module);
167 Printf(f_init, "#define SWIG_MZSCHEME_CREATE_MENV(env) (env)\n");
169 Printf(f_init, "%s\n", Char(init_func_def));
171 Printf(f_init, "\tscheme_finish_primitive_module(menv);\n");
173 Printf(f_init, "\treturn scheme_void;\n}\n");
174 Printf(f_init, "Scheme_Object *scheme_initialize(Scheme_Env *env) {\n");
177 if (load_libraries) {
178 Printf(f_init, "mz_set_dlopen_libraries(\"%s\");\n", load_libraries);
182 Printf(f_init, "\treturn scheme_reload(env);\n");
183 Printf(f_init, "}\n");
185 Printf(f_init, "Scheme_Object *scheme_module_name(void) {\n");
187 Printf(f_init, " return scheme_intern_symbol((char*)\"%s\");\n", module);
189 Printf(f_init, " return scheme_make_symbol((char*)\"%s\");\n", module);
191 Printf(f_init, "}\n");
194 /* Close all of the files */
195 Dump(f_runtime, f_begin);
196 Dump(f_header, f_begin);
197 Dump(f_wrappers, f_begin);
198 Wrapper_pretty_print(f_init, f_begin);
208 /* ------------------------------------------------------------
210 * Create a function declaration and register it with the interpreter.
211 * ------------------------------------------------------------ */
213 void throw_unhandled_mzscheme_type_error(SwigType *d) {
214 Swig_warning(WARN_TYPEMAP_UNDEF, input_file, line_number, "Unable to handle type %s.\n", SwigType_str(d, 0));
217 /* Return true iff T is a pointer type */
220 is_a_pointer(SwigType *t) {
221 return SwigType_ispointer(SwigType_typedef_resolve_all(t));
224 virtual int functionWrapper(Node *n) {
225 char *iname = GetChar(n, "sym:name");
226 SwigType *d = Getattr(n, "type");
227 ParmList *l = Getattr(n, "parms");
230 Wrapper *f = NewWrapper();
231 String *proc_name = NewString("");
232 String *source = NewString("");
233 String *target = NewString("");
234 String *arg = NewString("");
235 String *cleanup = NewString("");
236 String *outarg = NewString("");
237 String *build = NewString("");
243 String *overname = 0;
246 if (load_libraries) {
247 ParmList *parms = Getattr(n, "parms");
248 SwigType *type = Getattr(n, "type");
249 String *name = NewString("caller");
250 Setattr(n, "wrap:action", Swig_cresult(type, "result", Swig_cfunction_call(name, parms)));
254 // Make a wrapper name for this
255 String *wname = Swig_name_wrapper(iname);
256 if (Getattr(n, "sym:overloaded")) {
257 overname = Getattr(n, "sym:overname");
259 if (!addSymbol(iname, n)) {
265 Append(wname, overname);
267 Setattr(n, "wrap:name", wname);
269 // Build the name for Scheme.
270 Printv(proc_name, iname, NIL);
271 Replaceall(proc_name, "_", "-");
273 // writing the function wrapper function
274 Printv(f->def, "static Scheme_Object *", wname, " (", NIL);
275 Printv(f->def, "int argc, Scheme_Object **argv", NIL);
276 Printv(f->def, ")\n{", NIL);
278 /* Define the scheme name in C. This define is used by several
280 Printv(f->def, "#define FUNC_NAME \"", proc_name, "\"", NIL);
282 // Emit all of the local variables for holding arguments.
283 emit_parameter_variables(l, f);
285 /* Attach the standard typemaps */
286 emit_attach_parmmaps(l, f);
287 Setattr(n, "wrap:parms", l);
289 numargs = emit_num_arguments(l);
290 numreq = emit_num_required(l);
293 /* Add the holder for the pointer to the function to be opened */
294 if (load_libraries) {
295 Wrapper_add_local(f, "_function_loaded", "static int _function_loaded=(1==0)");
296 Wrapper_add_local(f, "_the_function", "static void *_the_function=NULL");
298 String *parms = ParmList_protostr(l);
299 String *func = NewStringf("(*caller)(%s)", parms);
300 Wrapper_add_local(f, "caller", SwigType_lstr(d, func)); /*"(*caller)()")); */
305 // adds local variables
306 Wrapper_add_local(f, "lenv", "int lenv = 1");
307 Wrapper_add_local(f, "values", "Scheme_Object *values[MAXVALUES]");
310 if (load_libraries) {
311 Printf(f->code, "if (!_function_loaded) { _the_function=mz_load_function(\"%s\");_function_loaded=(1==1); }\n", iname);
312 Printf(f->code, "if (!_the_function) { scheme_signal_error(\"Cannot load C function '%s'\"); }\n", iname);
313 Printf(f->code, "caller=_the_function;\n");
317 // Now write code to extract the parameters (this is super ugly)
319 for (i = 0, p = l; i < numargs; i++) {
320 /* Skip ignored arguments */
322 while (checkAttribute(p, "tmap:in:numinputs", "0")) {
323 p = Getattr(p, "tmap:in:next");
326 SwigType *pt = Getattr(p, "type");
327 String *ln = Getattr(p, "lname");
329 // Produce names of source and target
333 Printf(source, "argv[%d]", i);
334 Printf(target, "%s", ln);
335 Printv(arg, Getattr(p, "name"), NIL);
338 Printf(f->code, "if (argc > %d) {\n", i);
340 // Handle parameter types.
341 if ((tm = Getattr(p, "tmap:in"))) {
342 Replaceall(tm, "$source", source);
343 Replaceall(tm, "$target", target);
344 Replaceall(tm, "$input", source);
345 Setattr(p, "emit:input", source);
346 Printv(f->code, tm, "\n", NIL);
347 p = Getattr(p, "tmap:in:next");
350 // check if typedef and resolve
351 throw_unhandled_mzscheme_type_error(pt);
355 Printf(f->code, "}\n");
359 /* Insert constraint checking code */
361 if ((tm = Getattr(p, "tmap:check"))) {
362 Replaceall(tm, "$target", Getattr(p, "lname"));
363 Printv(f->code, tm, "\n", NIL);
364 p = Getattr(p, "tmap:check:next");
370 // Pass output arguments back to the caller.
373 if ((tm = Getattr(p, "tmap:argout"))) {
374 Replaceall(tm, "$source", Getattr(p, "emit:input")); /* Deprecated */
375 Replaceall(tm, "$target", Getattr(p, "lname")); /* Deprecated */
376 Replaceall(tm, "$arg", Getattr(p, "emit:input"));
377 Replaceall(tm, "$input", Getattr(p, "emit:input"));
378 Printv(outarg, tm, "\n", NIL);
379 p = Getattr(p, "tmap:argout:next");
386 // Free up any memory allocated for the arguments.
388 /* Insert cleanup code */
390 if ((tm = Getattr(p, "tmap:freearg"))) {
391 Replaceall(tm, "$target", Getattr(p, "lname"));
392 Printv(cleanup, tm, "\n", NIL);
393 p = Getattr(p, "tmap:freearg:next");
399 // Now write code to make the function call
401 String *actioncode = emit_action(n);
403 // Now have return value, figure out what to do with it.
404 if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
405 Replaceall(tm, "$source", "result");
406 Replaceall(tm, "$target", "values[0]");
407 Replaceall(tm, "$result", "values[0]");
408 if (GetFlag(n, "feature:new"))
409 Replaceall(tm, "$owner", "1");
411 Replaceall(tm, "$owner", "0");
412 Printv(f->code, tm, "\n", NIL);
414 throw_unhandled_mzscheme_type_error(d);
416 emit_return_variable(n, d, f);
418 // Dump the argument output code
419 Printv(f->code, Char(outarg), NIL);
421 // Dump the argument cleanup code
422 Printv(f->code, Char(cleanup), NIL);
424 // Look for any remaining cleanup
426 if (GetFlag(n, "feature:new")) {
427 if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
428 Replaceall(tm, "$source", "result");
429 Printv(f->code, tm, "\n", NIL);
432 // Free any memory allocated by the function being wrapped..
434 if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
435 Replaceall(tm, "$source", "result");
436 Printv(f->code, tm, "\n", NIL);
438 // Wrap things up (in a manner of speaking)
440 Printv(f->code, tab4, "return SWIG_MzScheme_PackageValues(lenv, values);\n", NIL);
441 Printf(f->code, "#undef FUNC_NAME\n");
442 Printv(f->code, "}\n", NIL);
444 /* Substitute the function name */
445 Replaceall(f->code, "$symname", iname);
447 Wrapper_print(f, f_wrappers);
449 if (!Getattr(n, "sym:overloaded")) {
451 // Now register the function
453 sprintf(temp, "%d", numargs);
454 if (exporting_destructor) {
455 Printf(init_func_def, "SWIG_TypeClientData(SWIGTYPE%s, (void *) %s);\n", swigtype_ptr, wname);
457 Printf(init_func_def, "scheme_add_global(\"%s\", scheme_make_prim_w_arity(%s,\"%s\",%d,%d),menv);\n", proc_name, wname, proc_name, numreq, numargs);
460 if (!Getattr(n, "sym:nextSibling")) {
461 /* Emit overloading dispatch function */
464 String *dispatch = Swig_overload_dispatch(n, "return %s(argc,argv);", &maxargs);
466 /* Generate a dispatch wrapper for all overloaded functions */
468 Wrapper *df = NewWrapper();
469 String *dname = Swig_name_wrapper(iname);
471 Printv(df->def, "static Scheme_Object *\n", dname, "(int argc, Scheme_Object **argv) {", NIL);
472 Printv(df->code, dispatch, "\n", NIL);
473 Printf(df->code, "scheme_signal_error(\"No matching function for overloaded '%s'\");\n", iname);
474 Printv(df->code, "}\n", NIL);
475 Wrapper_print(df, f_wrappers);
476 Printf(init_func_def, "scheme_add_global(\"%s\", scheme_make_prim_w_arity(%s,\"%s\",%d,%d),menv);\n", proc_name, dname, proc_name, 0, maxargs);
494 /* ------------------------------------------------------------
497 * Create a link to a C variable.
498 * This creates a single function _wrap_swig_var_varname().
499 * This function takes a single optional argument. If supplied, it means
500 * we are setting this variable to some value. If omitted, it means we are
501 * simply evaluating this variable. Either way, we return the variables
503 * ------------------------------------------------------------ */
505 virtual int variableWrapper(Node *n) {
507 char *name = GetChar(n, "name");
508 char *iname = GetChar(n, "sym:name");
509 SwigType *t = Getattr(n, "type");
511 String *proc_name = NewString("");
513 String *tm2 = NewString("");;
514 String *argnum = NewString("0");
515 String *arg = NewString("argv[0]");
518 if (!addSymbol(iname, n))
523 // evaluation function names
524 String *var_name = Swig_name_wrapper(iname);
526 // Build the name for scheme.
527 Printv(proc_name, iname, NIL);
528 Replaceall(proc_name, "_", "-");
529 Setattr(n, "wrap:name", proc_name);
531 if ((SwigType_type(t) != T_USER) || (is_a_pointer(t))) {
533 Printf(f->def, "static Scheme_Object *%s(int argc, Scheme_Object** argv) {\n", var_name);
534 Printv(f->def, "#define FUNC_NAME \"", proc_name, "\"", NIL);
536 Wrapper_add_local(f, "swig_result", "Scheme_Object *swig_result");
538 if (!GetFlag(n, "feature:immutable")) {
539 /* Check for a setting of the variable value */
540 Printf(f->code, "if (argc) {\n");
541 if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
542 Replaceall(tm, "$source", "argv[0]");
543 Replaceall(tm, "$target", name);
544 Replaceall(tm, "$input", "argv[0]");
545 /* Printv(f->code, tm, "\n",NIL); */
546 emit_action_code(n, f->code, tm);
548 throw_unhandled_mzscheme_type_error(t);
550 Printf(f->code, "}\n");
552 // Now return the value of the variable (regardless
553 // of evaluating or setting)
555 if ((tm = Swig_typemap_lookup("varout", n, name, 0))) {
556 Replaceall(tm, "$source", name);
557 Replaceall(tm, "$target", "swig_result");
558 Replaceall(tm, "$result", "swig_result");
559 /* Printf (f->code, "%s\n", tm); */
560 emit_action_code(n, f->code, tm);
562 throw_unhandled_mzscheme_type_error(t);
564 Printf(f->code, "\nreturn swig_result;\n");
565 Printf(f->code, "#undef FUNC_NAME\n");
566 Printf(f->code, "}\n");
568 Wrapper_print(f, f_wrappers);
570 // Now add symbol to the MzScheme interpreter
572 Printv(init_func_def,
573 "scheme_add_global(\"", proc_name, "\", scheme_make_prim_w_arity(", var_name, ", \"", proc_name, "\", ", "0", ", ", "1", "), menv);\n", NIL);
576 Swig_warning(WARN_TYPEMAP_VAR_UNDEF, input_file, line_number, "Unsupported variable type %s (ignored).\n", SwigType_str(t, 0));
587 /* ------------------------------------------------------------
589 * ------------------------------------------------------------ */
591 virtual int constantWrapper(Node *n) {
592 char *name = GetChar(n, "name");
593 char *iname = GetChar(n, "sym:name");
594 SwigType *type = Getattr(n, "type");
595 String *value = Getattr(n, "value");
597 String *var_name = NewString("");
598 String *proc_name = NewString("");
599 String *rvalue = NewString("");
600 String *temp = NewString("");
603 // Make a static variable;
605 Printf(var_name, "_wrap_const_%s", Swig_name_mangle(Getattr(n, "sym:name")));
607 // Build the name for scheme.
608 Printv(proc_name, iname, NIL);
609 Replaceall(proc_name, "_", "-");
611 if ((SwigType_type(type) == T_USER) && (!is_a_pointer(type))) {
612 Swig_warning(WARN_TYPEMAP_CONST_UNDEF, input_file, line_number, "Unsupported constant value.\n");
615 // See if there's a typemap
617 Printv(rvalue, value, NIL);
618 if ((SwigType_type(type) == T_CHAR) && (is_a_pointer(type) == 1)) {
621 Printv(rvalue, "\"", temp, "\"", NIL);
623 if ((SwigType_type(type) == T_CHAR) && (is_a_pointer(type) == 0)) {
627 Printv(rvalue, "'", temp, "'", NIL);
629 if ((tm = Swig_typemap_lookup("constant", n, name, 0))) {
630 Replaceall(tm, "$source", rvalue);
631 Replaceall(tm, "$value", rvalue);
632 Replaceall(tm, "$target", name);
633 Printf(f_init, "%s\n", tm);
635 // Create variable and assign it a value
637 Printf(f_header, "static %s = ", SwigType_lstr(type, var_name));
638 if ((SwigType_type(type) == T_STRING)) {
639 Printf(f_header, "\"%s\";\n", value);
640 } else if (SwigType_type(type) == T_CHAR) {
641 Printf(f_header, "\'%s\';\n", value);
643 Printf(f_header, "%s;\n", value);
646 // Now create a variable declaration
649 /* Hack alert: will cleanup later -- Dave */
651 Setattr(n, "name", var_name);
652 Setattr(n, "sym:name", iname);
653 Setattr(n, "type", type);
654 SetFlag(n, "feature:immutable");
665 virtual int destructorHandler(Node *n) {
666 exporting_destructor = true;
667 Language::destructorHandler(n);
668 exporting_destructor = false;
672 /* ------------------------------------------------------------
674 * ------------------------------------------------------------ */
675 virtual int classHandler(Node *n) {
676 String *mangled_classname = 0;
677 String *real_classname = 0;
678 String *scm_structname = NewString("");
679 SwigType *ctype_ptr = NewStringf("p.%s", Getattr(n, "classtype"));
681 SwigType *t = NewStringf("p.%s", Getattr(n, "name"));
682 swigtype_ptr = SwigType_manglestr(t);
685 cls_swigtype = SwigType_manglestr(Getattr(n, "name"));
688 fieldnames_tab = NewString("");
689 convert_tab = NewString("");
690 convert_proto_tab = NewString("");
692 struct_name = Getattr(n, "sym:name");
693 mangled_struct_name = Swig_name_mangle(Getattr(n, "sym:name"));
695 Printv(scm_structname, struct_name, NIL);
696 Replaceall(scm_structname, "_", "-");
698 real_classname = Getattr(n, "name");
699 mangled_classname = Swig_name_mangle(real_classname);
701 Printv(fieldnames_tab, "static const char *_swig_struct_", cls_swigtype, "_field_names[] = { \n", NIL);
703 Printv(convert_proto_tab, "static Scheme_Object *_swig_convert_struct_", cls_swigtype, "(", SwigType_str(ctype_ptr, "ptr"), ");\n", NIL);
705 Printv(convert_tab, "static Scheme_Object *_swig_convert_struct_", cls_swigtype, "(", SwigType_str(ctype_ptr, "ptr"), ")\n {\n", NIL);
708 tab4, "Scheme_Object *obj;\n", tab4, "Scheme_Object *fields[_swig_struct_", cls_swigtype, "_field_names_cnt];\n", tab4, "int i = 0;\n\n", NIL);
710 /* Generate normal wrappers */
711 Language::classHandler(n);
713 Printv(convert_tab, tab4, "obj = scheme_make_struct_instance(", "_swig_struct_type_", cls_swigtype, ", i, fields);\n", NIL);
714 Printv(convert_tab, tab4, "return obj;\n}\n\n", NIL);
716 Printv(fieldnames_tab, "};\n", NIL);
718 Printv(f_header, "static Scheme_Object *_swig_struct_type_", cls_swigtype, ";\n", NIL);
720 Printv(f_header, fieldnames_tab, NIL);
721 Printv(f_header, "#define _swig_struct_", cls_swigtype, "_field_names_cnt (sizeof(_swig_struct_", cls_swigtype, "_field_names)/sizeof(char*))\n", NIL);
723 Printv(f_header, convert_proto_tab, NIL);
724 Printv(f_wrappers, convert_tab, NIL);
726 Printv(init_func_def, "_swig_struct_type_", cls_swigtype,
727 " = SWIG_MzScheme_new_scheme_struct(menv, \"", scm_structname, "\", ",
728 "_swig_struct_", cls_swigtype, "_field_names_cnt,", "(char**) _swig_struct_", cls_swigtype, "_field_names);\n", NIL);
730 Delete(mangled_classname);
731 Delete(swigtype_ptr);
733 Delete(fieldnames_tab);
736 Delete(convert_proto_tab);
738 mangled_struct_name = 0;
739 Delete(cls_swigtype);
745 /* ------------------------------------------------------------
746 * membervariableHandler()
747 * ------------------------------------------------------------ */
749 virtual int membervariableHandler(Node *n) {
750 Language::membervariableHandler(n);
752 if (!is_smart_pointer()) {
753 String *symname = Getattr(n, "sym:name");
754 String *name = Getattr(n, "name");
755 SwigType *type = Getattr(n, "type");
756 String *swigtype = SwigType_manglestr(Getattr(n, "type"));
758 String *access_mem = NewString("");
759 SwigType *ctype_ptr = NewStringf("p.%s", Getattr(n, "type"));
761 Printv(fieldnames_tab, tab4, "\"", symname, "\",\n", NIL);
762 Printv(access_mem, "(ptr)->", name, NIL);
763 if ((SwigType_type(type) == T_USER) && (!is_a_pointer(type))) {
764 Printv(convert_tab, tab4, "fields[i++] = ", NIL);
765 Printv(convert_tab, "_swig_convert_struct_", swigtype, "((", SwigType_str(ctype_ptr, ""), ")&((ptr)->", name, "));\n", NIL);
766 } else if ((tm = Swig_typemap_lookup("varout", n, access_mem, 0))) {
767 Replaceall(tm, "$result", "fields[i++]");
768 Printv(convert_tab, tm, "\n", NIL);
770 Swig_warning(WARN_TYPEMAP_VAR_UNDEF, input_file, line_number, "Unsupported member variable type %s (ignored).\n", SwigType_str(type, 0));
778 /* ------------------------------------------------------------
780 * ------------------------------------------------------------ */
782 virtual int validIdentifier(String *s) {
784 /* Check whether we have an R5RS identifier. */
785 /* <identifier> --> <initial> <subsequent>* | <peculiar identifier> */
786 /* <initial> --> <letter> | <special initial> */
787 if (!(isalpha(*c) || (*c == '!') || (*c == '$') || (*c == '%')
788 || (*c == '&') || (*c == '*') || (*c == '/') || (*c == ':')
789 || (*c == '<') || (*c == '=') || (*c == '>') || (*c == '?')
790 || (*c == '^') || (*c == '_') || (*c == '~'))) {
791 /* <peculiar identifier> --> + | - | ... */
792 if ((strcmp(c, "+") == 0)
793 || strcmp(c, "-") == 0 || strcmp(c, "...") == 0)
798 /* <subsequent> --> <initial> | <digit> | <special subsequent> */
800 if (!(isalnum(*c) || (*c == '!') || (*c == '$') || (*c == '%')
801 || (*c == '&') || (*c == '*') || (*c == '/') || (*c == ':')
802 || (*c == '<') || (*c == '=') || (*c == '>') || (*c == '?')
803 || (*c == '^') || (*c == '_') || (*c == '~') || (*c == '+')
804 || (*c == '-') || (*c == '.') || (*c == '@')))
811 String *runtimeCode() {
812 String *s = Swig_include_sys("mzrun.swg");
814 Printf(stderr, "*** Unable to open 'mzrun.swg'\n");
820 String *defaultExternalRuntimeFilename() {
821 return NewString("swigmzrun.h");
825 /* -----------------------------------------------------------------------------
826 * swig_mzscheme() - Instantiate module
827 * ----------------------------------------------------------------------------- */
829 static Language *new_swig_mzscheme() {
830 return new MZSCHEME();
832 extern "C" Language *swig_mzscheme(void) {
833 return new_swig_mzscheme();