Changed %module xx_yy_zz to generate xx-yy-zz.scm and

xx-yy-zz_wrap.c[xx] (and xx-yy-zz-clos.scm and xx-yy-zz-generic.scm if
using TinyCLOS).  Consistent with the "namifying" of other C
identifiers.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4535 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Jonah Beckford 2003-03-15 15:19:00 +00:00
commit 8bbb5d2f77
13 changed files with 95 additions and 83 deletions

View file

@ -55,8 +55,8 @@
difficult to wrap by hand in CHICKEN -- and its <strong>typed difficult to wrap by hand in CHICKEN -- and its <strong>typed
pointer representation</strong>, essential for C and C++ pointer representation</strong>, essential for C and C++
libraries involving structures or classes. libraries involving structures or classes.
</p> </p>
<a name="n2"></a><H2>22.1 Preliminaries</H2> <a name="n2"></a><H2>22.1 Preliminaries</H2>
@ -73,7 +73,7 @@
You may want to look at any of the examples in Examples/chicken/ You may want to look at any of the examples in Examples/chicken/
or Examples/GIFPlot/Chicken for the basic steps to run SWIG or Examples/GIFPlot/Chicken for the basic steps to run SWIG
CHICKEN. CHICKEN.
We will generically refer to the <em>wrapper</em> as the We will generically refer to the <em>wrapper</em> as the
generated files. generated files.
@ -112,8 +112,8 @@
<pre>% swig -chicken -c++ example.i</pre> <pre>% swig -chicken -c++ example.i</pre>
</blockquote> </blockquote>
This will generate <tt>example_wrap.cxx</tt>, This will generate <tt>example_wrap.cxx</tt>,
<tt>example.scm</tt>, <tt>example_generic.scm</tt> and <tt>example.scm</tt>, <tt>example-generic.scm</tt> and
<tt>example_clos.scm</tt>. The basic Scheme code must be <tt>example-clos.scm</tt>. The basic Scheme code must be
compiled to C using your system's CHICKEN compiler. compiled to C using your system's CHICKEN compiler.
<blockquote> <blockquote>
<pre>% chicken example.scm -output-file oexample.c</pre> <pre>% chicken example.scm -output-file oexample.c</pre>
@ -248,16 +248,16 @@
generic procedures to implement an object-oriented Scheme generic procedures to implement an object-oriented Scheme
system. Please consult a Scheme book if you are unfamiliar system. Please consult a Scheme book if you are unfamiliar
with the concept. with the concept.
<br></br> <br></br>
CHICKEN has a modified version of TinyCLOS, which SWIG CHICKEN CHICKEN has a modified version of TinyCLOS, which SWIG CHICKEN
uses in C++ mode. SWIG CHICKEN generates a uses in C++ mode. SWIG CHICKEN generates a
<tt>xxx_generic.scm</tt> and a <tt>xxx_clos.scm</tt> file, which <tt>xxx-generic.scm</tt> and a <tt>xxx-clos.scm</tt> file, which
contain TinyCLOS macros. When using these macros, you will need contain TinyCLOS macros. When using these macros, you will need
to <tt>(include "xxx_generic")</tt> all the generic macros your to <tt>(include "xxx-generic")</tt> all the generic macros your
program needs, and <strong>then</strong> <tt>(include program needs, and <strong>then</strong> <tt>(include
"xxx_clos")</tt> all the metaobject (class) macros your program "xxx-clos")</tt> all the metaobject (class) macros your program
needs. needs.
<br></br> <br></br>
@ -391,9 +391,9 @@ CHICKEN_HOME=/usr/local/share/chicken</pre>
to SWIG</em> will have correct TinyCLOS representations based on to SWIG</em> will have correct TinyCLOS representations based on
<code>SIMPLE_CLOS_OBJECT</code>. SWIG "knows" the classes that <code>SIMPLE_CLOS_OBJECT</code>. SWIG "knows" the classes that
are exposed in the SWIG interface file; it "fully knows" only are exposed in the SWIG interface file; it "fully knows" only
those classes that are not forward declarations. those classes that are not forward declarations.
<br></br> <br></br>
A real-world example of the "fully knows" problem is found in A real-world example of the "fully knows" problem is found in
the VTK visualization library. All VTK classes are derived from the VTK visualization library. All VTK classes are derived from
@ -488,13 +488,13 @@ CHICKEN_HOME=/usr/local/share/chicken</pre>
<code>vtkRenderer</code>. <code>vtkRenderer</code>.
</p> </p>
<a name="n15"></a><H2>22.7 Pointers</H2> <a name="n15"></a><H2>22.7 Pointers</H2>
<p> <p>
For pointer types, SWIG uses CHICKEN tagged pointers. For pointer types, SWIG uses CHICKEN tagged pointers.
A tagged pointer is an ordinary CHICKEN pointer with an A tagged pointer is an ordinary CHICKEN pointer with an
extra slot for an arbitrary Scheme object. With SWIG extra slot for an arbitrary Scheme object. With SWIG
CHICKEN, this Scheme object is a reference to a type-info CHICKEN, this Scheme object is a reference to a type-info

View file

@ -9,7 +9,7 @@ INCLUDE =
SWIGOPT = SWIGOPT =
CFLAGS = CFLAGS =
all:: $(TARGET) example_generic.scm example_clos.scm all:: $(TARGET) example-generic.scm example-clos.scm
csi.c: csi.c:
$(MAKE) -f $(TOP)/Makefile TARGET='csi.c' \ $(MAKE) -f $(TOP)/Makefile TARGET='csi.c' \
@ -19,7 +19,7 @@ precsi.c: precsi.scm
$(MAKE) -f $(TOP)/Makefile TARGET='precsi.c' \ $(MAKE) -f $(TOP)/Makefile TARGET='precsi.c' \
INTERFACE='$<' chicken INTERFACE='$<' chicken
example_wrap.cxx example.scm example_generic.scm example_clos.scm: example.i example_wrap.cxx example.scm example-generic.scm example-clos.scm: example.i
$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
INCLUDE='$(INCLUDE)' INTERFACE='example.i' chicken_cpp INCLUDE='$(INCLUDE)' INTERFACE='example.i' chicken_cpp
@ -42,7 +42,7 @@ module:: $(CHICKSRCS) $(SRCS) $(CXXSRCS)
clean:: clean::
$(MAKE) -f $(TOP)/Makefile chicken_clean $(MAKE) -f $(TOP)/Makefile chicken_clean
rm -f $(CHICKGEN) rm -f $(CHICKGEN)
rm -f example.scm example_generic.scm example_clos.scm rm -f example.scm example-generic.scm example-clos.scm
rm -f $(TARGET) rm -f $(TARGET)
check:: all check:: all

View file

@ -85,9 +85,9 @@ public:
(display "----------------\n") (display "----------------\n")
(display " (display "
;; ALL generic methods must be included first ;; ALL generic methods must be included first
(include \"example_generic\") (include \"example-generic\")
;; After generic methods are defined, can include TinyCLOS code ;; After generic methods are defined, can include TinyCLOS code
(include \"example_clos\") (include \"example-clos\")
(define A-CIRCLE-SHAPE (make <example:Circle> %radius)) (define A-CIRCLE-SHAPE (make <example:Circle> %radius))
(-get-x- %shapeObject) (-get-x- %shapeObject)

View file

@ -2,10 +2,10 @@
;; by SWIG. ;; by SWIG.
;; All generic methods must be included first ;; All generic methods must be included first
(include "example_generic") (include "example-generic")
;; After generic are defined, can include TinyCLOS code ;; After generic are defined, can include TinyCLOS code
(include "example_clos") (include "example-clos")
;; ----- Object creation ----- ;; ----- Object creation -----

View file

@ -42,7 +42,7 @@ module:: $(CHICKSRCS) $(SRCS) $(CXXSRCS)
clean:: clean::
$(MAKE) -f $(TOP)/Makefile chicken_clean $(MAKE) -f $(TOP)/Makefile chicken_clean
rm -f $(CHICKGEN) rm -f $(CHICKGEN)
rm -f example.scm example_generic.scm example_clos.scm rm -f example.scm example-generic.scm example-clos.scm
rm -f $(TARGET) rm -f $(TARGET)
check:: all check:: all

View file

@ -42,7 +42,7 @@ module:: $(CHICKSRCS) $(SRCS) $(CXXSRCS)
clean:: clean::
$(MAKE) -f $(TOP)/Makefile chicken_clean $(MAKE) -f $(TOP)/Makefile chicken_clean
rm -f $(CHICKGEN) rm -f $(CHICKGEN)
rm -f example.scm example_generic.scm example_clos.scm rm -f example.scm example-generic.scm example-clos.scm
rm -f $(TARGET) rm -f $(TARGET)
check:: all check:: all

View file

@ -9,7 +9,7 @@ INCLUDE =
SWIGOPT = SWIGOPT =
CFLAGS = CFLAGS =
all:: $(TARGET) example_generic.scm example_clos.scm all:: $(TARGET) example-generic.scm example-clos.scm
csi.c: csi.c:
$(MAKE) -f $(TOP)/Makefile TARGET='csi.c' \ $(MAKE) -f $(TOP)/Makefile TARGET='csi.c' \
@ -19,7 +19,7 @@ precsi.c: precsi.scm
$(MAKE) -f $(TOP)/Makefile TARGET='precsi.c' \ $(MAKE) -f $(TOP)/Makefile TARGET='precsi.c' \
INTERFACE='$<' chicken INTERFACE='$<' chicken
example_wrap.cxx example.scm example_generic.scm example_clos.scm: example.i example_wrap.cxx example.scm example-generic.scm example-clos.scm: example.i
$(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ $(MAKE) -f $(TOP)/Makefile SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
INCLUDE='$(INCLUDE)' INTERFACE='example.i' chicken_cpp INCLUDE='$(INCLUDE)' INTERFACE='example.i' chicken_cpp
@ -42,7 +42,7 @@ module:: $(CHICKSRCS) $(SRCS) $(CXXSRCS)
clean:: clean::
$(MAKE) -f $(TOP)/Makefile chicken_clean $(MAKE) -f $(TOP)/Makefile chicken_clean
rm -f $(CHICKGEN) rm -f $(CHICKGEN)
rm -f example.scm example_generic.scm example_clos.scm rm -f example.scm example-generic.scm example-clos.scm
rm -f $(TARGET) rm -f $(TARGET)
check:: all check:: all

View file

@ -43,9 +43,9 @@ class Foo {
(display "----------------\n") (display "----------------\n")
(display " (display "
;; ALL generic methods must be included first ;; ALL generic methods must be included first
(include \"example_generic\") (include \"example-generic\")
;; After generic methods are defined, can include TinyCLOS code ;; After generic methods are defined, can include TinyCLOS code
(include \"example_clos\") (include \"example-clos\")
(+example:foo+ %x-int) (+example:foo+ %x-int)
(+example:foo+ %x-string) (+example:foo+ %x-string)

View file

@ -34,9 +34,9 @@ Trying TinyCLOS code ...
") ")
;; ALL generic methods must be included first ;; ALL generic methods must be included first
(include "example_generic") (include "example-generic")
;; After generic methods are defined, can include TinyCLOS code ;; After generic methods are defined, can include TinyCLOS code
(include "example_clos") (include "example-clos")
(+example:foo+ 1) (+example:foo+ 1)
(+example:foo+ "some string") (+example:foo+ "some string")

View file

@ -42,7 +42,7 @@ module:: $(CHICKSRCS) $(SRCS) $(CXXSRCS)
clean:: clean::
$(MAKE) -f $(TOP)/Makefile chicken_clean $(MAKE) -f $(TOP)/Makefile chicken_clean
rm -f $(CHICKGEN) rm -f $(CHICKGEN)
rm -f example.scm example_generic.scm example_clos.scm rm -f example.scm example-generic.scm example-clos.scm
rm -f $(TARGET) rm -f $(TARGET)
check:: all check:: all

View file

@ -42,7 +42,7 @@ module:: $(CHICKSRCS) $(SRCS) $(CXXSRCS)
clean:: clean::
$(MAKE) -f $(TOP)/Makefile chicken_clean $(MAKE) -f $(TOP)/Makefile chicken_clean
rm -f $(CHICKGEN) rm -f $(CHICKGEN)
rm -f example.scm example_generic.scm example_clos.scm rm -f example.scm example-generic.scm example-clos.scm
rm -f $(TARGET) rm -f $(TARGET)
check:: all check:: all

View file

@ -652,13 +652,13 @@ CHICKW(quasiquote);
extern "C" { extern "C" {
#endif #endif
/* Chicken initialization function */ /* Chicken initialization function */
SWIGEXPORT(void) $module_swig_init(int, C_word, C_word) C_noret; SWIGEXPORT(void) $realmodule_swig_init(int, C_word, C_word) C_noret;
/* Tag functions */ /* Tag functions */
SWIGEXPORT(int) $module_swig_num_types (void); SWIGEXPORT(int) $realmodule_swig_num_types (void);
SWIGEXPORT(const char*) $module_swig_type_name (int); SWIGEXPORT(const char*) $realmodule_swig_type_name (int);
SWIGEXPORT(void*) $module_swig_type_ptr (int); SWIGEXPORT(void*) $realmodule_swig_type_ptr (int);
SWIGEXPORT(const char*) $module_swig_type_str (int); SWIGEXPORT(const char*) $realmodule_swig_type_str (int);
SWIGEXPORT(void) $module_swig_type_tag (int, C_word); SWIGEXPORT(void) $realmodule_swig_type_tag (int, C_word);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
@ -667,7 +667,7 @@ SWIGEXPORT(void) $module_swig_type_tag (int, C_word);
%insert(init) %{ %insert(init) %{
/* CHICKEN initialization function */ /* CHICKEN initialization function */
SWIGEXPORT(void) SWIGEXPORT(void)
$module_swig_init(int argc, C_word closure, C_word continuation) { $realmodule_swig_init(int argc, C_word closure, C_word continuation) {
static int typeinit = 0; static int typeinit = 0;
int i; int i;
@ -686,29 +686,29 @@ $module_swig_init(int argc, C_word closure, C_word continuation) {
/* Tag functions */ /* Tag functions */
SWIGEXPORT(int) SWIGEXPORT(int)
$module_swig_num_types (void) $realmodule_swig_num_types (void)
{ {
int i; int i;
for (i=0; swig_types_initial[i]; i++); for (i=0; swig_types_initial[i]; i++);
return i; return i;
} }
SWIGEXPORT(const char*) SWIGEXPORT(const char*)
$module_swig_type_name (int index) $realmodule_swig_type_name (int index)
{ {
return swig_types[index]->name; return swig_types[index]->name;
} }
SWIGEXPORT(void*) SWIGEXPORT(void*)
$module_swig_type_ptr (int index) $realmodule_swig_type_ptr (int index)
{ {
return (void*) (swig_types[index]); return (void*) (swig_types[index]);
} }
SWIGEXPORT(const char*) SWIGEXPORT(const char*)
$module_swig_type_str (int index) $realmodule_swig_type_str (int index)
{ {
return swig_types[index]->str; return swig_types[index]->str;
} }
SWIGEXPORT(void) SWIGEXPORT(void)
$module_swig_type_tag (int index, C_word tag) $realmodule_swig_type_tag (int index, C_word tag)
{ {
swig_chicken_clientdata *data = swig_chicken_clientdata *data =
(swig_chicken_clientdata*) malloc (sizeof (swig_chicken_clientdata)); (swig_chicken_clientdata*) malloc (sizeof (swig_chicken_clientdata));
@ -720,17 +720,17 @@ $module_swig_type_tag (int index, C_word tag)
%insert(chicken) %{ %insert(chicken) %{
(declare (declare
(foreign-declare "C_extern int $module_swig_num_types (void);") (foreign-declare "C_extern int $realmodule_swig_num_types (void);")
(foreign-declare "C_extern char* $module_swig_type_name (int);") (foreign-declare "C_extern char* $realmodule_swig_type_name (int);")
(foreign-declare "C_extern void* $module_swig_type_ptr (int);") (foreign-declare "C_extern void* $realmodule_swig_type_ptr (int);")
(foreign-declare "C_extern char* $module_swig_type_str (int);") (foreign-declare "C_extern char* $realmodule_swig_type_str (int);")
(foreign-declare "C_extern void $module_swig_type_tag (int, C_word);")) (foreign-declare "C_extern void $realmodule_swig_type_tag (int, C_word);"))
(define-record swig-$module-tag class name ptr str) (define-record swig-$module-tag class name ptr str)
(define-record-printer (swig-$module-tag tag out) (define-record-printer (swig-$module-tag tag out)
(fprintf out "#<c++ ~S>(~A)" (swig-$module-tag-str tag) (fprintf out "#<c++ ~S>(~A)" (swig-$module-tag-str tag)
(swig-$module-tag-ptr tag))) (swig-$module-tag-ptr tag)))
(define swig-$module-tag-num (define swig-$module-tag-num
((foreign-lambda int "$module_swig_num_types"))) ((foreign-lambda int "$realmodule_swig_num_types")))
(define swig-$module-tags (make-vector swig-$module-tag-num #f)) (define swig-$module-tags (make-vector swig-$module-tag-num #f))
(letrec (letrec
((gen ((gen
@ -745,13 +745,13 @@ $module_swig_type_tag (int index, C_word tag)
(make-swig-$module-tag (make-swig-$module-tag
1000 1000
((foreign-lambda ((foreign-lambda
c-string "$module_swig_type_name" int) index) c-string "$realmodule_swig_type_name" int) index)
((foreign-lambda ((foreign-lambda
c-pointer "$module_swig_type_ptr" int) index) c-pointer "$realmodule_swig_type_ptr" int) index)
((foreign-lambda ((foreign-lambda
c-string "$module_swig_type_str" int) index)))) c-string "$realmodule_swig_type_str" int) index))))
(vector-set! swig-$module-tags index tag) (vector-set! swig-$module-tags index tag)
((foreign-lambda void "$module_swig_type_tag" ((foreign-lambda void "$realmodule_swig_type_tag"
int scheme-object) index tag))) int scheme-object) index tag)))
indices))) indices)))
%} %}

View file

@ -50,6 +50,7 @@ CHICKEN Options (available with -chicken)\n\
static String *prefix=0; static String *prefix=0;
static int noprefix=0; static int noprefix=0;
static String *module=0; static String *module=0;
static String *realmodule=0;
static char *chicken_path=(char*)"chicken"; static char *chicken_path=(char*)"chicken";
static int clos = 1; static int clos = 1;
static int generic = 1; static int generic = 1;
@ -203,6 +204,10 @@ CHICKEN::main(int argc, char *argv[])
int int
CHICKEN::top(Node *n) CHICKEN::top(Node *n)
{ {
String *chicken_filename;
String *clos_filename;
String *generic_filename;
if (!CPlusPlus) { if (!CPlusPlus) {
clos = 0; clos = 0;
generic = 0; generic = 0;
@ -223,6 +228,9 @@ CHICKEN::top(Node *n)
f_init = NewString(""); f_init = NewString("");
f_header = NewString(""); f_header = NewString("");
f_wrappers = NewString(""); f_wrappers = NewString("");
chicken_filename = NewString("");
clos_filename = NewString("");
generic_filename = NewString("");
/* Register file targets with the SWIG file handler */ /* Register file targets with the SWIG file handler */
Swig_register_filebyname("header",f_header); Swig_register_filebyname("header",f_header);
@ -239,7 +247,9 @@ CHICKEN::top(Node *n)
} }
/* Set module name */ /* Set module name */
module = Copy(Getattr(n,"name")); realmodule = Copy(Getattr(n,"name"));
module = Copy(realmodule);
namify(module);
/* Set prefix. If a prefix has been specified make sure it ends /* Set prefix. If a prefix has been specified make sure it ends
in a '-' */ in a '-' */
@ -255,11 +265,9 @@ CHICKEN::top(Node *n)
} }
} }
char filen[256]; Printf(chicken_filename,"%s%s.scm", Swig_file_dirname(outfile), module);
if ((f_scm = NewFile(chicken_filename,"w")) == 0) {
sprintf(filen,"%s%s.scm", Swig_file_dirname(outfile), Char(module)); Printf(stderr,"Unable to open %s\n", chicken_filename);
if ((f_scm = NewFile(filen,"w")) == 0) {
Printf(stderr,"Unable to open %s\n", filen);
SWIG_exit(EXIT_FAILURE); SWIG_exit(EXIT_FAILURE);
} }
f_scm_stubs = NewString(""); f_scm_stubs = NewString("");
@ -274,15 +282,15 @@ CHICKEN::top(Node *n)
Printv(f_scm,"(cond-expand ((or chicken-compile-shared shared)) (else (declare (unit ", module, "))))\n\n", NIL); Printv(f_scm,"(cond-expand ((or chicken-compile-shared shared)) (else (declare (unit ", module, "))))\n\n", NIL);
#ifdef JONAH_IS_CRAZY #ifdef JONAH_IS_CRAZY
Printv(f_scm,"(declare \n", Printv(f_scm,"(declare \n",
tab4, "(foreign-declare \"void* ", module, tab4, "(foreign-declare \"void* ", realmodule,
"_swig_get_type(char*);\"))\n", NIL); "_swig_get_type(char*);\"))\n", NIL);
#endif #endif
#ifndef INIT_BINDING #ifndef INIT_BINDING
Printv(f_scm,"(declare \n", Printv(f_scm,"(declare \n",
tab4, "(hide swig-init)\n", tab4, "(hide swig-init)\n",
tab4, "(foreign-declare \"C_extern void ", module, tab4, "(foreign-declare \"C_extern void ", realmodule,
"_swig_init(int,C_word,C_word) C_noret;\"))\n", NIL); "_swig_init(int,C_word,C_word) C_noret;\"))\n", NIL);
Printv(f_scm,"(define swig-init (##core#primitive \"", module, Printv(f_scm,"(define swig-init (##core#primitive \"", realmodule,
"_swig_init\"))\n", NIL); "_swig_init\"))\n", NIL);
Printv(f_scm,"(swig-init)\n\n", NIL); Printv(f_scm,"(swig-init)\n\n", NIL);
#endif #endif
@ -300,10 +308,10 @@ CHICKEN::top(Node *n)
if (generic) { if (generic) {
sprintf(filen,"%s%s_generic.scm", Swig_file_dirname(outfile), Printf(generic_filename,"%s%s-generic.scm",
Char(module)); Swig_file_dirname(outfile), module);
if ((f_generic = NewFile(filen,"w")) == 0) { if ((f_generic = NewFile(generic_filename,"w")) == 0) {
Printf(stderr,"Unable to open %s\n", filen); Printf(stderr,"Unable to open %s\n", generic_filename);
SWIG_exit (EXIT_FAILURE); SWIG_exit (EXIT_FAILURE);
} }
@ -317,10 +325,9 @@ CHICKEN::top(Node *n)
} }
if (clos) { if (clos) {
sprintf(filen,"%s%s_clos.scm", Swig_file_dirname(outfile), Printf(clos_filename,"%s%s-clos.scm", Swig_file_dirname(outfile), module);
Char(module)); if ((f_clos = NewFile(clos_filename,"w")) == 0) {
if ((f_clos = NewFile(filen,"w")) == 0) { Printf(stderr,"Unable to open %s\n", clos_filename);
Printf(stderr,"Unable to open %s\n", filen);
SWIG_exit (EXIT_FAILURE); SWIG_exit (EXIT_FAILURE);
} }
@ -334,7 +341,7 @@ CHICKEN::top(Node *n)
Printf (f_clos, "(declare (uses extras))\n"); Printf (f_clos, "(declare (uses extras))\n");
} }
Printf(f_header,"#define SWIG_name \"%s\"\n", module); Printf(f_header,"#define SWIG_name \"%s\"\n", realmodule);
Printf(f_wrappers,"#ifdef __cplusplus\n"); Printf(f_wrappers,"#ifdef __cplusplus\n");
Printf(f_wrappers,"extern \"C\" {\n"); Printf(f_wrappers,"extern \"C\" {\n");
@ -345,7 +352,7 @@ CHICKEN::top(Node *n)
"#ifdef __cplusplus\n", "#ifdef __cplusplus\n",
"extern \"C\"\n", "extern \"C\"\n",
"#endif\n", "#endif\n",
"SWIGEXPORT(void *) ", module, "_swig_get_type (char *type) {\n", "SWIGEXPORT(void *) ", realmodule, "_swig_get_type (char *type) {\n",
"int i;\n", "int i;\n",
"for (i = 0; swig_types_initial[i]; i++) {\n", "for (i = 0; swig_types_initial[i]; i++) {\n",
"if (strcmp (type, swig_types[i]->name) == 0) ", "if (strcmp (type, swig_types[i]->name) == 0) ",
@ -367,7 +374,7 @@ CHICKEN::top(Node *n)
{ {
String *tmp = NewString(""); String *tmp = NewString("");
String *tmp2 = NewString("swig-init"); String *tmp2 = NewString("swig-init");
Printv(tmp, module, "_swig_init", NIL); Printv(tmp, realmodule, "_swig_init", NIL);
addMethod(tmp, tmp2, tmp); addMethod(tmp, tmp2, tmp);
Delete(tmp); Delete(tmp);
Delete(tmp2); Delete(tmp2);
@ -392,6 +399,10 @@ CHICKEN::top(Node *n)
Replaceall(f_init_helper, "$nummethods", buftmp); Replaceall(f_init_helper, "$nummethods", buftmp);
Replaceall(f_init_helper, "$symsize", f_sym_size); Replaceall(f_init_helper, "$symsize", f_sym_size);
Delete(chicken_filename);
Delete(clos_filename);
Delete(generic_filename);
Printv(f_scm, f_scm_stubs, "\n",NIL); Printv(f_scm, f_scm_stubs, "\n",NIL);
Close(f_scm); Close(f_scm);
Delete(f_scm); Delete(f_scm);
@ -439,6 +450,7 @@ CHICKEN::insertDirective(Node *n)
{ {
String *code = Getattr(n,"code"); String *code = Getattr(n,"code");
Replaceall(code, "$module", module); Replaceall(code, "$module", module);
Replaceall(code, "$realmodule", realmodule);
return Language::insertDirective(n); return Language::insertDirective(n);
} }
@ -509,7 +521,7 @@ CHICKEN::functionWrapper(Node *n)
num_arguments = emit_num_arguments(l); num_arguments = emit_num_arguments(l);
num_required = emit_num_required(l); num_required = emit_num_required(l);
Append(wname, module); Append(wname, realmodule);
Append(wname, Swig_name_wrapper(iname)); Append(wname, Swig_name_wrapper(iname));
if (overname) { if (overname) {
Append(wname, overname); Append(wname, overname);
@ -813,7 +825,7 @@ CHICKEN::functionWrapper(Node *n)
Printv(f_scm, "(declare (foreign-declare \"C_extern ", Printv(f_scm, "(declare (foreign-declare \"C_extern ",
declfunc, " C_noret;\"))\n", NIL); declfunc, " C_noret;\"))\n", NIL);
Printv(f_scm, "(define ", prefix, scmname, Printv(f_scm, "(define ", prefix, scmname,
" (##core#primitive \"", module, "_wrap_", iname, " (##core#primitive \"", realmodule, "_wrap_", iname,
"\"))\n\n", NIL); "\"))\n\n", NIL);
#endif #endif
} }
@ -927,7 +939,7 @@ CHICKEN::variableWrapper(Node *n) {
num_required = emit_num_required(l); num_required = emit_num_required(l);
// evaluation function names // evaluation function names
Append(wname, module); Append(wname, realmodule);
Append(wname, Swig_name_wrapper(iname)); Append(wname, Swig_name_wrapper(iname));
if (overname) { if (overname) {
Append(wname, overname); Append(wname, overname);
@ -1093,7 +1105,7 @@ CHICKEN::variableWrapper(Node *n) {
wname, "(int,C_word,C_word,C_word)" wname, "(int,C_word,C_word,C_word)"
" C_noret;\"))\n", NIL); " C_noret;\"))\n", NIL);
Printv(f_scm, "(define ", prefix, scmname, Printv(f_scm, "(define ", prefix, scmname,
" (##core#primitive \"", module, "_wrap_", iname, " (##core#primitive \"", realmodule, "_wrap_", iname,
"\"))\n\n", NIL); "\"))\n\n", NIL);
#endif #endif
@ -1169,7 +1181,7 @@ CHICKEN::constantWrapper(Node *n)
if (!addSymbol(iname,n)) return SWIG_ERROR; if (!addSymbol(iname,n)) return SWIG_ERROR;
} }
Append(wname, module); Append(wname, realmodule);
Append(wname, Swig_name_wrapper(iname)); Append(wname, Swig_name_wrapper(iname));
if (overname) { if (overname) {
Append(wname, overname); Append(wname, overname);
@ -1281,7 +1293,7 @@ CHICKEN::constantWrapper(Node *n)
"C_word value)" "C_word value)"
" C_noret;\"))\n", NIL); " C_noret;\"))\n", NIL);
Printv(f_scm, "(define ", prefix, scmname, Printv(f_scm, "(define ", prefix, scmname,
" (##core#primitive \"", module, "_wrap_", iname, " (##core#primitive \"", realmodule, "_wrap_", iname,
"\"))\n\n", NIL); "\"))\n\n", NIL);
#endif #endif
@ -1350,7 +1362,7 @@ CHICKEN::classHandler(Node *n)
tab4,"(make-swig-",prefix,"tag ", tab4,"(make-swig-",prefix,"tag ",
"1000 \"_p_",Getattr(n,"sym:name"),"\"\n", "1000 \"_p_",Getattr(n,"sym:name"),"\"\n",
tab8,"((foreign-lambda* c-pointer ()\n", tab8,"((foreign-lambda* c-pointer ()\n",
tab8, tab4, "\"return (",module, tab8, tab4, "\"return (",realmodule,
"_swig_get_type (\\\"_p_",Getattr(n,"sym:name"),"\\\"));\"))\n", "_swig_get_type (\\\"_p_",Getattr(n,"sym:name"),"\\\"));\"))\n",
tab8, "\"",Getattr(n,"sym:name")," *\"))\n", NIL); tab8, "\"",Getattr(n,"sym:name")," *\"))\n", NIL);
#endif #endif
@ -1707,7 +1719,7 @@ CHICKEN::dispatchFunction(Node *n)
String *scmname = NewString(iname); String *scmname = NewString(iname);
namify(scmname); namify(scmname);
Append(wname, module); Append(wname, realmodule);
Append(wname, Swig_name_wrapper(iname)); Append(wname, Swig_name_wrapper(iname));
#ifndef BINDING #ifndef BINDING
@ -1749,9 +1761,9 @@ CHICKEN::dispatchFunction(Node *n)
/* Create a binding for this function */ /* Create a binding for this function */
#ifdef BINDING #ifdef BINDING
Printv(f_scm, "(declare (foreign-declare \"C_extern ", Printv(f_scm, "(declare (foreign-declare \"C_extern ",
module, wname, "(int, C_word, C_word, C_word) C_noret;\"))\n", NIL); realmodule, wname, "(int, C_word, C_word, C_word) C_noret;\"))\n", NIL);
Printv(f_scm, "(define swig-", prefix, scmname, Printv(f_scm, "(define swig-", prefix, scmname,
"-prim (##core#primitive \"", module, "_wrap_", iname, "-prim (##core#primitive \"", realmodule, "_wrap_", iname,
"\"))\n", NIL); "\"))\n", NIL);
Printv(f_scm, "(define (", prefix, scmname, Printv(f_scm, "(define (", prefix, scmname,
" . args) (swig-", prefix, scmname, "-prim args))\n\n", NIL); " . args) (swig-", prefix, scmname, "-prim args))\n\n", NIL);