diff --git a/Source/Modules/Makefile.in b/Source/Modules/Makefile.in
index e898e8ac3..e4c13e10b 100644
--- a/Source/Modules/Makefile.in
+++ b/Source/Modules/Makefile.in
@@ -5,8 +5,8 @@
srcdir = @srcdir@
VPATH = @srcdir@
-SRCS = init.c test.c
-OBJS = init.o test.o
+SRCS = init.c inputmodule.c cppmodule.c cparsemodule.c
+OBJS = init.o inputmodule.o cppmodule.o cparsemodule.o
prefix = @prefix@
exec_prefix = @exec_prefix@
diff --git a/Source/Modules/cparsemodule.c b/Source/Modules/cparsemodule.c
new file mode 100644
index 000000000..b9af54f66
--- /dev/null
+++ b/Source/Modules/cparsemodule.c
@@ -0,0 +1,55 @@
+/* -----------------------------------------------------------------------------
+ * cparsemodule.c
+ *
+ * This module is responsible for running the SWIG C Parsing module.
+ *
+ * Author(s) : David Beazley (beazley@cs.uchicago.edu)
+ *
+ * Copyright (C) 1999-2000. The University of Chicago
+ * See the file LICENSE for information on usage and redistribution.
+ * ----------------------------------------------------------------------------- */
+
+#include "swig.h"
+#include "swigconfig.h"
+#include "lparse.h"
+
+static const char *usage = "C Parsing options:\n\
+";
+
+static
+int cparse_init(int argc, char **argv) {
+ int i;
+ /* Look for command line options */
+ for (i = 1; i < argc; i++) {
+ if (argv[i]) {
+ if (strcmp(argv[i],"-c++") == 0) {
+ LParse_cplusplus(1);
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-help") == 0) {
+ Printf(stderr,"%s",usage);
+ Swig_mark_arg(i);
+ }
+ }
+ }
+ return 0;
+}
+
+static
+DOH *cparse_run(DOH *node) {
+ String *data;
+ DOH *result;
+
+ data = Getattr(node,"data");
+ if (!data) {
+ Printf(stderr,"SWIG: cparse error. no data.\n");
+ Swig_exit(1);
+ }
+ Seek(data,0, SEEK_SET);
+ result = LParse_parse(data);
+ Setattr(result,"last",node);
+ return result;
+}
+
+void cparsemodule() {
+ Swig_register_module("cparse","swig:preprocess", cparse_init, cparse_run);
+}
diff --git a/Source/Modules/cppmodule.c b/Source/Modules/cppmodule.c
new file mode 100644
index 000000000..490cb7306
--- /dev/null
+++ b/Source/Modules/cppmodule.c
@@ -0,0 +1,92 @@
+/* -----------------------------------------------------------------------------
+ * cppmodule.c
+ *
+ * This module is responsible for running the SWIG preprocessor module.
+ *
+ * Author(s) : David Beazley (beazley@cs.uchicago.edu)
+ *
+ * Copyright (C) 1999-2000. The University of Chicago
+ * See the file LICENSE for information on usage and redistribution.
+ * ----------------------------------------------------------------------------- */
+
+#include "swig.h"
+#include "swigconfig.h"
+#include "preprocessor.h"
+
+static int cpp_only = 0;
+
+static const char *usage = "Preprocessor options:\n\
+ -E - Run the preprocessor only\n\
+ -Dmacro - Define a new macro\n\
+";
+
+static
+int preprocessor_init(int argc, char **argv) {
+ int i;
+ /* Look for command line options */
+ for (i = 1; i < argc; i++) {
+ if (argv[i]) {
+ if (strcmp(argv[i],"-E") == 0) {
+ cpp_only = 1;
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-c++") == 0) {
+ Preprocessor_define("__cplusplus 1", 0);
+ Swig_mark_arg(i);
+ } else if (strncmp(argv[i],"-D",2) == 0) {
+ DOH *d = NewString(argv[i]+2);
+ Replace(d,"="," ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
+ Preprocessor_define(d,0);
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-includeall") == 0) {
+ Preprocessor_include_all(1);
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-help") == 0) {
+ Printf(stderr,"%s",usage);
+ Swig_mark_arg(i);
+ }
+ }
+ }
+ return 0;
+}
+
+static
+DOH *preprocessor_run(DOH *node) {
+ String *cpps, *data;
+ DOH *result;
+
+ data = Getattr(node,"data");
+ if (!data) {
+ Printf(stderr,"SWIG: preprocessor error. no data.\n");
+ Swig_exit(1);
+ }
+
+ Preprocessor_define("SWIG 1", 0);
+ Preprocessor_define("__STDC__ 1", 0);
+#ifdef MACSWIG
+ Preprocessor_define("SWIGMAC 1", 0);
+#endif
+#ifdef SWIGWIN32
+ Preprocessor_define("SWIGWIN32 1", 0);
+#endif
+
+ Seek(data,0, SEEK_SET);
+ cpps = Preprocessor_parse(data);
+ if (cpp_only) {
+ Printf(stdout,"%s", cpps);
+ return 0;
+ }
+
+ result = NewHash();
+ Settag(result,"swig:preprocess");
+ Setfile(cpps,Getfile(data));
+ Setline(cpps,Getline(data));
+ Seek(cpps,0,SEEK_SET);
+ Setattr(result,"data",cpps);
+ Setattr(result,"last",node);
+ return result;
+}
+
+void preprocessormodule() {
+ Swig_register_module("preprocessor","swig:input", preprocessor_init, preprocessor_run);
+ Preprocessor_init();
+}
diff --git a/Source/Modules/init.c b/Source/Modules/init.c
index c236fcba9..32c7d2c3b 100644
--- a/Source/Modules/init.c
+++ b/Source/Modules/init.c
@@ -11,12 +11,16 @@
#include "swig.h"
-extern void testmodule();
-extern void pythonmodule();
+extern void inputmodule();
+extern void preprocessormodule();
+extern void cparsemodule();
+extern void swig11module();
static void (*modules[])(void) = {
- testmodule,
- pythonmodule,
+ inputmodule,
+ preprocessormodule,
+ cparsemodule,
+ swig11module,
0
};
@@ -33,7 +37,16 @@ void init_modules() {
}
}
+/* This array contains the names of modules that should be loaded by default */
+static char *default_modules[] = {
+ "input",
+ "preprocessor",
+ "cparse",
+ 0
+};
+
int main(int argc, char **argv) {
init_modules();
- return Swig_main(argc, argv);
+ return Swig_main(argc, argv, default_modules);
}
+
diff --git a/Source/Modules/inputmodule.c b/Source/Modules/inputmodule.c
new file mode 100644
index 000000000..d0edca680
--- /dev/null
+++ b/Source/Modules/inputmodule.c
@@ -0,0 +1,186 @@
+/* -----------------------------------------------------------------------------
+ * inputmodule.c
+ *
+ * This module is responsible for reading input files and setting up all
+ * of the proper search paths.
+ *
+ * Author(s) : David Beazley (beazley@cs.uchicago.edu)
+ *
+ * Copyright (C) 1999-2000. The University of Chicago
+ * See the file LICENSE for information on usage and redistribution.
+ * ----------------------------------------------------------------------------- */
+
+#include "swig.h"
+#include "swigconfig.h"
+
+#ifndef SWIG_LIB
+#define SWIG_LIB "./swiglib"
+#endif
+
+static int checkout = 0;
+static List *includedirs;
+static List *libfiles;
+static String *outfile = 0;
+static int debug_path = 0;
+static int debug_input = 0;
+
+static const char *usage = "File options:\n\
+ -I
- Look for SWIG files in \n\
+ -l - Include SWIG library file.\n\
+ -o outfile - Set name of the output file.\n\
+ -co - Check file out of SWIG library.\n\
+";
+
+static
+int input_init(int argc, char **argv) {
+ char *c;
+ int i;
+
+ /* Directories included with the -I option */
+ includedirs = NewList();
+
+ /* Files added with the -l option */
+ libfiles = NewList();
+
+ /* Look for command line options */
+ for (i = 1; i < argc; i++) {
+ if (argv[i]) {
+ if (strncmp(argv[i],"-I",2) == 0) {
+ Append(includedirs,argv[i]+2);
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-debug_path") == 0) {
+ debug_path = 1;
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-debug_input") == 0) {
+ debug_input = 1;
+ Swig_mark_arg(i);
+ } else if (strncmp(argv[i],"-l",2) == 0) {
+ Append(libfiles, argv[i]+2);
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-co") == 0) {
+ checkout = 1;
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-o") == 0) {
+ Swig_mark_arg(i);
+ if (argv[i+1]) {
+ outfile = NewString(argv[i+1]);
+ Swig_mark_arg(i+1);
+ i++;
+ } else {
+ Swig_arg_error();
+ }
+ } else if (strcmp(argv[i],"-help") == 0) {
+ Printf(stderr,"%s",usage);
+ Swig_mark_arg(i);
+ }
+ }
+ }
+ /* Set the location of the SWIG library */
+ if (!(c = getenv("SWIG_LIB"))) {
+ Append(includedirs,SWIG_LIB);
+ } else {
+ Append(includedirs,c);
+ }
+ return 0;
+}
+
+static
+DOH *input_run(DOH *node) {
+ int i;
+ String *infile;
+ FILE *f;
+ String *input;
+ DOH *result;
+ String *swiglib;
+ String *lang_config;
+
+ infile = Getname(node);
+
+ /* Register all of the include directories */
+ swiglib = Swig_swiglib_get();
+ for (i = Len(includedirs); i > 0; i--) {
+ if (swiglib) {
+ String *l = NewStringf("%s%s%s", Getitem(includedirs,i-1),SWIG_FILE_DELIMETER,swiglib);
+ Swig_add_directory(l);
+ }
+ Swig_add_directory(Getitem(includedirs,i-1));
+ }
+
+ if (debug_path) {
+ List *l;
+ Printf(stdout,"SWIG search path:\n");
+ l = Swig_search_path();
+ if (l) {
+ String *s;
+ for (s = Firstitem(l); s; s = Nextitem(l)) {
+ Printf(stdout," %s\n", s);
+ }
+ }
+ }
+
+ /* user has requested to simply check out a file */
+ if (checkout) {
+ String *outfilename;
+ String *s;
+ outfilename = outfile ? outfile : infile;
+
+ /* Grab the file */
+ s = Swig_include(infile);
+ if (!s) {
+ Printf(stderr,"Unable to locate '%s' in the SWIG library.\n", infile);
+ Swig_exit(EXIT_FAILURE);
+ } else {
+ File *f = NewFile(outfilename,"r");
+ if (f) {
+ Delete(f);
+ Printf(stderr,"File '%s' already exists. Checkout aborted.\n", outfilename);
+ } else {
+ f = NewFile(outfilename,"w");
+ if (!f) {
+ Printf(stderr,"Unable to create file '%s'\n", outfilename);
+ } else {
+ Printf(stderr,"'%s' checked out from the SWIG library.\n", infile);
+ Dump(s,f);
+ Delete(f);
+ }
+ }
+ }
+ return 0;
+ }
+
+ /* Try to find input files */
+ f = Swig_open(infile);
+ if (!f) {
+ Printf(stderr,"Unable to find '%s'\n", infile);
+ Swig_exit (EXIT_FAILURE);
+ }
+ fclose(f);
+ input = NewString("%include \"swig.swg\"\n");
+ lang_config = Swig_get_config_file();
+ if (lang_config) {
+ Printf(input,"\n%%include \"%s\"\n", lang_config);
+ }
+ Printf(input,"\n%%include \"%s\"\n", infile);
+ for (i = 0; i < Len(libfiles); i++) {
+ Printf(input,"\n%%include \"%s\"\n", Getitem(libfiles,i));
+ }
+ result = NewHash();
+ Settag(result,"swig:input");
+ Setattr(result,"name", infile);
+ Setattr(result,"path", Getfile(input));
+ Setattr(result,"outfile", outfile);
+ Setattr(result,"data",input);
+ Setattr(result,"last",node);
+
+ if (debug_input) {
+ Printf(stdout,"::: inputmodule :::\n");
+ Printf(stdout,"%s\n", input);
+ }
+ return result;
+}
+
+void inputmodule() {
+ Swig_register_module("input","swig:initial", input_init, input_run);
+}
+
+
diff --git a/Source/Modules1.1/Makefile.in b/Source/Modules1.1/Makefile.in
index 1cbcc3bda..119ad4a4d 100644
--- a/Source/Modules1.1/Makefile.in
+++ b/Source/Modules1.1/Makefile.in
@@ -16,8 +16,8 @@ TARGET = libmodules11.a
COREOBJS = main.o emit.o lang.o generate.o
CORESRCS = main.cxx emit.cxx lang.cxx generate.cxx
-OBJS = $(COREOBJS) swigmain.o tcl8.o python.o perl5.o guile.o ruby.o mzscheme.o #java.o
-SRCS = $(CORESRCS) swigmain.cxx tcl8.cxx python.cxx perl5.cxx guile.cxx ruby.cxx mzscheme.cxx #java.cxx
+OBJS = $(COREOBJS) tcl8.o python.o perl5.o guile.o ruby.o mzscheme.o #java.o
+SRCS = $(CORESRCS) tcl8.cxx python.cxx perl5.cxx guile.cxx ruby.cxx mzscheme.cxx #java.cxx
INCLUDE = -I$(srcdir)/../Include \
-I$(srcdir)/../Preprocessor \
diff --git a/Source/Modules1.1/generate.cxx b/Source/Modules1.1/generate.cxx
index 3dee2d9bb..532bae40f 100644
--- a/Source/Modules1.1/generate.cxx
+++ b/Source/Modules1.1/generate.cxx
@@ -747,7 +747,7 @@ void generate(DOH *node) {
}
if (!swig_module) {
Printf(stderr,"SWIG: No module name specified! Please use %%module or -module.\n");
- SWIG_exit(EXIT_FAILURE);
+ Swig_exit(EXIT_FAILURE);
}
lang->initialize(swig_module);
diff --git a/Source/Modules1.1/guile.cxx b/Source/Modules1.1/guile.cxx
index 934f141e5..18d59f5b8 100644
--- a/Source/Modules1.1/guile.cxx
+++ b/Source/Modules1.1/guile.cxx
@@ -71,14 +71,14 @@ GUILE::parse_args (int argc, char *argv[])
{
int i, orig_len;
- sprintf (LibDir, "%s", "guile");
+ Swig_swiglib_set("guile");
// Look for certain command line options
for (i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp (argv[i], "-help") == 0) {
fputs (guile_usage, stderr);
- SWIG_exit (EXIT_SUCCESS);
+ Swig_exit (EXIT_SUCCESS);
}
else if (strcmp (argv[i], "-prefix") == 0) {
if (argv[i + 1]) {
@@ -149,7 +149,7 @@ GUILE::parse_args (int argc, char *argv[])
Preprocessor_define ((void *) "SWIGGUILE",0);
/* Read in default typemaps */
- SWIG_config_file("guile.i");
+ Swig_set_config_file("guile.i");
}
// --------------------------------------------------------------------
diff --git a/Source/Modules1.1/main.cxx b/Source/Modules1.1/main.cxx
index d487e42d1..72fd80bd9 100644
--- a/Source/Modules1.1/main.cxx
+++ b/Source/Modules1.1/main.cxx
@@ -25,54 +25,40 @@ static char cvsroot[] = "$Header$";
#include
extern "C" {
#include "preprocessor.h"
-#include "lparse.h"
}
-#ifndef SWIG_LIB
-#define SWIG_LIB "/usr/local/lib/swig1.3"
+#ifndef SWIG_LANG
+#define SWIG_LANG PYTHON
#endif
-#ifndef SWIG_CC
-#define SWIG_CC "CC"
+#include "tcl8.h"
+#include "python.h"
+#include "perl5.h"
+#include "guile.h"
+#ifdef OLD
+#include "java.h"
#endif
+#include "mzscheme.h"
+#include "ruby.h"
// Global variables
- FILE *f_runtime;
- DOH *f_header; // Some commonly used
- DOH *f_wrappers; // FILE pointers
- DOH *f_init;
- FILE *f_input;
- char LibDir[512]; // Library directory
+ FILE *f_runtime = 0;
+ DOH *f_header = 0; // Some commonly used
+ DOH *f_wrappers = 0; // FILE pointers
+ DOH *f_init = 0;
Language *lang; // Language method
int CPlusPlus = 0;
int NewObject = 0; // NewObject flag
int ForceExtern = 0; // Force extern mode
int GenerateDefault = 0; // Generate default constructors
- char *Config = 0;
int NoInclude = 0;
int Verbose = 0;
String *swig_module = 0;
-class SwigException {};
-
static char *usage = (char*)"\
-\nGeneral Options\n\
- -c - Produce raw wrapper code (omit support code)\n\
- -c++ - Enable C++ processing\n\
- -co - Check a file out of the SWIG library\n\
- -Dsymbol - Define a symbol (for conditional compilation)\n\
- -I - Look for SWIG files in \n\
- -includeall - Follow all #include statements\n\
- -l - Include SWIG library file.\n\
- -make_default - Create default constructors/destructors\n\
- -o outfile - Set name of the output file.\n\
- -swiglib - Report location of SWIG library and exit\n\
- -v - Run in verbose mode\n\
- -version - Print SWIG version number\n\
- -help - This output.\n\n";
-
-
+\nSWIG1.1 Options\n\
+";
// -----------------------------------------------------------------------------
// check_suffix(char *name)
@@ -80,6 +66,7 @@ static char *usage = (char*)"\
// Checks the suffix of a file to see if we should emit extern declarations.
// -----------------------------------------------------------------------------
+static
int
check_suffix(char *name) {
char *c;
@@ -112,413 +99,197 @@ char infilename[256];
char filename[256];
char output_dir[512];
char fn_runtime[256];
-
-#ifdef MACSWIG
-FILE *swig_log;
-#endif
+static char *outfile_name = 0;
char *SwigLib;
-static int freeze = 0;
-static String *lang_config = 0;
-
-/* This function sets the name of the configuration file */
-
-void SWIG_config_file(const String_or_char *filename) {
- lang_config = NewString(filename);
-}
-
-int SWIG_main(int argc, char *argv[], Language *l) {
+extern "C"
+int swig11_init(int argc, char *argv[]) {
int i;
char *c;
- char temp[512];
char infile[512];
- char *outfile_name = 0;
int help = 0;
- int checkout = 0;
- int cpp_only = 0;
- int tm_debug = 0;
- int tree_debug = 0;
- char *includefiles[256];
- int includecount = 0;
- extern int check_suffix(char *);
- extern void generate(DOH *top);
- DOH *libfiles = 0;
- DOH *cpps = 0;
- char *input_file = 0;
-
- /* Initialize the SWIG core */
- Swig_init();
-
-#ifdef MACSWIG
- try {
-#endif
-
- // Initialize the preprocessor
- Preprocessor_init();
+ lang = new SWIG_LANG;
f_wrappers = 0;
f_init = 0;
f_header = 0;
- lang = l;
-
- // Set up some default symbols (available in both SWIG interface files
- // and C files)
-
- Preprocessor_define((DOH *) "SWIG 1", 0);
- Preprocessor_define((DOH *) "__STDC__", 0);
-#ifdef MACSWIG
- Preprocessor_define((DOH *) "SWIGMAC 1", 0);
-#endif
-#ifdef SWIGWIN32
- Preprocessor_define((DOH *) "SWIGWIN32 1", 0);
-#endif
-
- // Check for SWIG_LIB environment variable
-
- if ((c = getenv("SWIG_LIB")) == (char *) 0) {
- sprintf(LibDir,"%s",SWIG_LIB); // Build up search paths
- } else {
- strcpy(LibDir,c);
- }
-
- SwigLib = Swig_copy_string(LibDir); // Make a copy of the real library location
-
-#ifdef MACSWIG
- sprintf(temp,"%s:config", LibDir);
- Swig_add_directory((DOH *) ":swig_lib:config");
- Swig_add_directory((DOH *) ":swig_lib");
-#else
- sprintf(temp,"%s/config", LibDir);
- Swig_add_directory((DOH *) "./swig_lib/config");
- Swig_add_directory((DOH *) "./swig_lib");
-#endif
- Swig_add_directory((DOH *) temp);
- Swig_add_directory((DOH *) LibDir);
-
- libfiles = NewList();
-
// Get options
for (i = 1; i < argc; i++) {
- if (argv[i]) {
- if (strncmp(argv[i],"-I",2) == 0) {
- // Add a new directory search path
- includefiles[includecount++] = Swig_copy_string(argv[i]+2);
- Swig_mark_arg(i);
- } else if (strncmp(argv[i],"-D",2) == 0) {
- DOH *d = NewString(argv[i]+2);
- Replace(d,(char*)"=",(char*)" ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
- Preprocessor_define((DOH *) d,0);
- // Create a symbol
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-E") == 0) {
- cpp_only = 1;
- Swig_mark_arg(i);
- } else if ((strcmp(argv[i],"-verbose") == 0) ||
- (strcmp(argv[i],"-v") == 0)) {
- Verbose = 1;
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-c++") == 0) {
- CPlusPlus=1;
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-c") == 0) {
- NoInclude=1;
- Preprocessor_define((DOH *) "SWIG_NOINCLUDE 1", 0);
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-make_default") == 0) {
- GenerateDefault = 1;
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-swiglib") == 0) {
- printf("%s\n", LibDir);
- SWIG_exit (EXIT_SUCCESS);
- } else if (strcmp(argv[i],"-o") == 0) {
- Swig_mark_arg(i);
- if (argv[i+1]) {
- outfile_name = Swig_copy_string(argv[i+1]);
- Swig_mark_arg(i+1);
- i++;
- } else {
- Swig_arg_error();
- }
- } else if (strcmp(argv[i],"-version") == 0) {
- fprintf(stderr,"\nSWIG Version %s %s\n",
- SWIG_VERSION, SWIG_SPIN);
- fprintf(stderr,"Copyright (c) 1995-98\n");
- fprintf(stderr,"University of Utah and the Regents of the University of California\n");
- fprintf(stderr,"\nCompiled with %s\n", SWIG_CC);
- SWIG_exit (EXIT_SUCCESS);
- } else if (strncmp(argv[i],"-l",2) == 0) {
- // Add a new directory search path
- Append(libfiles,argv[i]+2);
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-co") == 0) {
- checkout = 1;
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-freeze") == 0) {
- freeze = 1;
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-includeall") == 0) {
- Preprocessor_include_all(1);
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-tm_debug") == 0) {
- tm_debug = 1;
- Swig_mark_arg(i);
- } else if(strcmp(argv[i],"-module") == 0) {
- if (argv[i+1]) {
- swig_module = NewString(argv[i+1]);
- Swig_mark_arg(i);
- Swig_mark_arg(i+1);
- i++;
- } else {
- Swig_arg_error();
- }
- } else if (strcmp(argv[i],"-tree") == 0) {
- Swig_mark_arg(i);
- tree_debug = 1;
- } else if (strcmp(argv[i],"-help") == 0) {
- fputs(usage,stderr);
- Swig_mark_arg(i);
- help = 1;
- }
+ if (argv[i]) {
+ if(strcmp(argv[i],"-tcl") == 0) {
+ fprintf(stderr,"swig: -tcl option now implies -tcl8\n");
+ lang = new TCL8;
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-tcl8") == 0) {
+ lang = new TCL8;
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-python") == 0) {
+ lang = new PYTHON;
+ Swig_mark_arg(i);
+
+ } else if (strcmp(argv[i],"-perl5") == 0) {
+ lang = new PERL5;
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-guile") == 0) {
+ lang = new GUILE;
+ Swig_mark_arg(i);
+#ifdef OLD
+ } else if (strcmp(argv[i],"-java") == 0) {
+ lang = new JAVA;
+ Swig_mark_arg(i);
+#endif
+ } else if (strcmp(argv[i],"-mzscheme") == 0) {
+ lang = new MZSCHEME;
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-ruby") == 0) {
+ lang = new RUBY;
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-help") == 0) {
+ fputs(usage,stderr);
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-c++") == 0) {
+ CPlusPlus=1;
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-c") == 0) {
+ NoInclude=1;
+ Preprocessor_define("SWIG_NOINCLUDE 1", 0);
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i],"-make_default") == 0) {
+ GenerateDefault = 1;
+ Swig_mark_arg(i);
+ } else if(strcmp(argv[i],"-module") == 0) {
+ if (argv[i+1]) {
+ swig_module = NewString(argv[i+1]);
+ Swig_mark_arg(i);
+ Swig_mark_arg(i+1);
+ i++;
+ } else {
+ Swig_arg_error();
+ }
+ } else if (strcmp(argv[i],"-o") == 0) {
+ if (argv[i+1]) {
+ outfile_name = argv[i+1];
+ Swig_mark_arg(i);
+ Swig_mark_arg(i+1);
+ i++;
+ }
+ } else if (strcmp(argv[i],"-help") == 0) {
+ fputs(usage,stderr);
+ Swig_mark_arg(i);
+ help = 1;
}
+ }
}
- if (Verbose)
- printf ("LibDir: %s\n", LibDir);
-
- while (includecount > 0) {
- Swig_add_directory((DOH *) includefiles[--includecount]);
- }
-
// Parse language dependent options
lang->parse_args(argc,argv);
- if (help) SWIG_exit (EXIT_SUCCESS); // Exit if we're in help mode
-
- // Check all of the options to make sure we're cool.
- Swig_check_options();
-
- // Add language dependent directory to the search path
- {
- DOH *rl = NewString("");
-#ifdef MACSWIG
- Printf(r1,"%s:%s", SwigLib,LibDir);
-#else
- Printf(rl,"%s/%s", SwigLib,LibDir);
-#endif
- Swig_add_directory(rl);
- }
+ if (help) return 0;
// Create names of temporary files that are created
-
sprintf(infilename,"%s", argv[argc-1]);
- input_file = new char[strlen(infilename)+1];
- strcpy(input_file, infilename);
- // If the user has requested to check out a file, handle that
- if (checkout) {
- DOH *s;
- char *outfile = input_file;
- if (outfile_name)
- outfile = outfile_name;
-
- if (Verbose)
- printf ("Handling checkout...\n");
-
- s = Swig_include(input_file);
- if (!s) {
- fprintf(stderr,"Unable to locate '%s' in the SWIG library.\n", input_file);
+ // Check the suffix for a .c file. If so, we're going to
+ // declare everything we see as "extern"
+
+ ForceExtern = check_suffix(infilename);
+ // Strip off suffix
+
+ c = infilename + strlen(infilename);
+ while (c != infilename) {
+ if (*c == '.') {
+ *c = 0;
+ break;
} else {
- FILE *f = fopen(outfile,"r");
- if (f) {
- fclose(f);
- fprintf(stderr,"File '%s' already exists. Checkout aborted.\n", outfile);
- } else {
- f = fopen(outfile,"w");
- if (!f) {
- fprintf(stderr,"Unable to create file '%s'\n", outfile);
- } else {
- fprintf(stderr,"'%s' checked out from the SWIG library.\n", input_file);
- fputs(Char(s),f);
- fclose(f);
- }
- }
- }
- } else {
- // Check the suffix for a .c file. If so, we're going to
- // declare everything we see as "extern"
-
- ForceExtern = check_suffix(infilename);
- // Strip off suffix
-
- c = infilename + strlen(infilename);
- while (c != infilename) {
- if (*c == '.') {
- *c = 0;
- break;
- } else {
- c--;
- }
- }
- if (!outfile_name) {
- char *cc = infilename + strlen(infilename);
- while (cc != infilename) {
- if (*cc == '/') {
- cc++;
- break;
- }
- cc--;
- }
- sprintf(fn_runtime,"%s_wrap.c",infilename);
- strcpy(infile,infilename);
- outfile_name = fn_runtime;
- } else {
- sprintf(fn_runtime,"%s",outfile_name);
- }
- {
- // Try to identify the output directory
- char *cc = outfile_name;
- char *lastc = outfile_name;
- while (*cc) {
- if (*cc == '/') lastc = cc+1;
- cc++;
- }
- cc = outfile_name;
- char *dd = output_dir;
- while (cc != lastc) {
- *dd = *cc;
- dd++;
- cc++;
- }
- *dd = 0;
- // Patch up the input filename
- cc = infilename + strlen(infilename);
- while (cc != infilename) {
- if (*cc == '/') {
- cc++;
- break;
- }
- cc--;
- }
- strcpy(infile,cc);
- }
-
- // Define the __cplusplus symbol
- if (CPlusPlus)
- Preprocessor_define((DOH *) "__cplusplus 1", 0);
-
- // Run the preprocessor
- if (Verbose)
- printf ("Preprocessing...\n");
- {
- int i;
- String *fs = NewString("%include \"swig.swg\"\n");
- String *ds = Swig_include(input_file);
- if (!ds) {
- Printf(stderr,"Unable to find '%s'\n", input_file);
- SWIG_exit (EXIT_FAILURE);
- }
-
- if (lang_config) {
- Printf(fs,"\n%%include \"%s\"\n", lang_config);
- }
- Printf(fs,"\n%%file(\"include\") \"%s\" {\n", Swig_last_file());
- Append(fs, ds);
- Append(fs,"\n}\n");
- Delete(ds);
- for (i = 0; i < Len(libfiles); i++) {
- Printf(fs,"\n%%include \"%s\"\n", Getitem(libfiles,i));
- }
- Seek(fs,0,SEEK_SET);
- cpps = Preprocessor_parse(fs);
- if (cpp_only) {
- Printf(stdout,"%s", cpps);
- while (freeze);
- SWIG_exit (EXIT_SUCCESS);
- }
- }
- if ((f_runtime = fopen(fn_runtime,"w")) == 0) {
- fprintf(stderr,"Unable to open %s\n", fn_runtime);
- exit(0);
- }
- f_header = NewString("");
- f_wrappers = NewString("");
- f_init = NewString("");
-
- Swig_register_filebyname("header",f_header);
- Swig_register_filebyname("runtime", f_runtime);
- Swig_register_filebyname("wrapper", f_wrappers);
- Swig_register_filebyname("init", f_init);
-
- // Set up the typemap for handling new return strings
- {
- if (CPlusPlus)
- Swig_typemap_register((char*)"newfree",(char*)"p.char",(char*)"",(char*)"delete [] $source;\n",0);
- else
- Swig_typemap_register((char*)"newfree",(char*)"p.char",(char*)"",(char*)"free($source);\n",0);
- }
-
- // Pass control over to the specific language interpreter
-
- if (Verbose) {
- fprintf (stdout, "Starting language-specific parse...\n");
- fflush (stdout);
- }
- // parser_init();
- {
- DOH *top;
- Seek(cpps,0,SEEK_SET);
- top = LParse_parse(cpps);
- if (tree_debug) Swig_dump_tree(top);
- generate(top);
- }
- // lang->parse();
- if (Verbose) {
- fprintf (stdout, "Finished language-specific parse.\n");
- fflush (stdout);
- }
- Dump(f_header,f_runtime);
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init,f_runtime);
- fclose(f_runtime);
- if (checkout) {
- // File was checked out from the SWIG library. Remove it now
- remove(input_file);
+ c--;
}
}
- if (tm_debug) Swig_typemap_debug();
- while (freeze);
+ if (!outfile_name) {
+ char *cc = infilename + strlen(infilename);
+ while (cc != infilename) {
+ if (*cc == '/') {
+ cc++;
+ break;
+ }
+ cc--;
+ }
+ sprintf(fn_runtime,"%s_wrap.c",infilename);
+ strcpy(infile,infilename);
+ outfile_name = fn_runtime;
+ } else {
+ sprintf(fn_runtime,"%s",outfile_name);
+ }
+ {
+ // Try to identify the output directory
+ char *cc = outfile_name;
+ char *lastc = outfile_name;
+ while (*cc) {
+ if (*cc == '/') lastc = cc+1;
+ cc++;
+ }
+ cc = outfile_name;
+ char *dd = output_dir;
+ while (cc != lastc) {
+ *dd = *cc;
+ dd++;
+ cc++;
+ }
+ *dd = 0;
+ // Patch up the input filename
+ cc = infilename + strlen(infilename);
+ while (cc != infilename) {
+ if (*cc == '/') {
+ cc++;
+ break;
+ }
+ cc--;
+ }
+ strcpy(infile,cc);
+ }
return 0;
}
-// --------------------------------------------------------------------------
-// SWIG_exit(int exit_code)
-//
-// Cleanup and either freeze or exit
-// --------------------------------------------------------------------------
-void SWIG_exit(int exit_code) {
- if (f_runtime) {
- fclose(f_runtime);
- remove(fn_runtime);
+extern void generate(DOH *top);
+
+extern "C"
+DOH *swig11_run(DOH *node) {
+ if ((f_runtime = fopen(fn_runtime,"w")) == 0) {
+ fprintf(stderr,"Unable to open %s\n", fn_runtime);
+ Swig_exit(1);
}
- while (freeze);
- exit (exit_code);
+ f_header = NewString("");
+ f_wrappers = NewString("");
+ f_init = NewString("");
+
+ Swig_register_filebyname("header",f_header);
+ Swig_register_filebyname("runtime", f_runtime);
+ Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("init", f_init);
+
+ // Set up the typemap for handling new return strings
+ if (CPlusPlus)
+ Swig_typemap_register((char*)"newfree",(char*)"p.char",(char*)"",(char*)"delete [] $source;\n",0);
+ else
+ Swig_typemap_register((char*)"newfree",(char*)"p.char",(char*)"",(char*)"free($source);\n",0);
+
+ generate(node);
+
+ Dump(f_header,f_runtime);
+ Dump(f_wrappers, f_runtime);
+ Wrapper_pretty_print(f_init,f_runtime);
+ fclose(f_runtime);
+ return node;
}
-
-// --------------------------------------------------------------------------
-// swig_pragma(char *name, char *value)
-//
-// Handle pragma directives. Not many supported right now
-// --------------------------------------------------------------------------
-
-void swig_pragma(char *name, char *value) {
-
- if (strcmp(name,"make_default") == 0) {
- GenerateDefault = 1;
- }
- if (strcmp(name,"no_default") == 0) {
- GenerateDefault = 0;
- }
+extern "C"
+void swig11module() {
+ Swig_register_module("tcl8","swig:top", swig11_init, swig11_run);
+ Swig_register_module("python","swig:top", swig11_init, swig11_run);
+ Swig_register_module("perl5","swig:top", swig11_init, swig11_run);
+ Swig_register_module("ruby","swig:top", swig11_init, swig11_run);
+ Swig_register_module("guile","swig:top", swig11_init, swig11_run);
+ Swig_register_module("mzscheme","swig:top", swig11_init, swig11_run);
+ Swig_register_module("swig11","swig:top", swig11_init, swig11_run);
}
diff --git a/Source/Modules1.1/mzscheme.cxx b/Source/Modules1.1/mzscheme.cxx
index 51b98db89..f3ac22096 100644
--- a/Source/Modules1.1/mzscheme.cxx
+++ b/Source/Modules1.1/mzscheme.cxx
@@ -51,14 +51,14 @@ MZSCHEME::parse_args (int argc, char *argv[])
{
int i;
- sprintf (LibDir, "%s", mzscheme_path);
+ Swig_swiglib_set("mzscheme");
// Look for certain command line options
for (i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp (argv[i], "-help") == 0) {
fputs (mzscheme_usage, stderr);
- SWIG_exit (0);
+ Swig_exit (0);
}
else if (strcmp (argv[i], "-prefix") == 0) {
if (argv[i + 1]) {
@@ -116,7 +116,7 @@ MZSCHEME::initialize (String *modname)
if (Swig_insert_file ("mzscheme.swg", f_header) == -1) {
Printf (stderr, "SWIG : Fatal error. ");
Printf (stderr, "Unable to locate 'mzscheme.swg' in SWIG library.\n");
- SWIG_exit (1);
+ Swig_exit (1);
}
}
diff --git a/Source/Modules1.1/perl5.cxx b/Source/Modules1.1/perl5.cxx
index e82f2037d..5573b4c96 100644
--- a/Source/Modules1.1/perl5.cxx
+++ b/Source/Modules1.1/perl5.cxx
@@ -87,7 +87,7 @@ PERL5::parse_args(int argc, char *argv[]) {
int i = 1;
cmodule = NewString("");
- strcpy(LibDir,"perl5");
+ Swig_swiglib_set("perl5");
for (i = 1; i < argc; i++) {
if (argv[i]) {
if(strcmp(argv[i],"-package") == 0) {
@@ -157,12 +157,12 @@ PERL5::initialize(String *modname)
if (Swig_insert_file("common.swg", f_runtime) == -1) {
Printf(stderr,"SWIG : Fatal error. Unable to locate 'common.swg' in SWIG library.\n");
- SWIG_exit (EXIT_FAILURE);
+ Swig_exit (EXIT_FAILURE);
}
if (Swig_insert_file("perl5.swg", f_runtime) == -1) {
Printf(stderr,"SWIG : Fatal error. Unable to locate 'perl5.swg' in SWIG library.\n");
- SWIG_exit (EXIT_FAILURE);
+ Swig_exit (EXIT_FAILURE);
}
if (!module) module = NewString(modname);
@@ -200,7 +200,7 @@ PERL5::initialize(String *modname)
sprintf(filen,"%s%s.pm", output_dir,m);
if ((f_pm = fopen(filen,"w")) == 0) {
Printf(stderr,"Unable to open %s\n", filen);
- SWIG_exit (EXIT_FAILURE);
+ Swig_exit (EXIT_FAILURE);
}
}
if (!blessed) {
diff --git a/Source/Modules1.1/python.cxx b/Source/Modules1.1/python.cxx
index 95347b2f8..12012b53a 100644
--- a/Source/Modules1.1/python.cxx
+++ b/Source/Modules1.1/python.cxx
@@ -59,7 +59,7 @@ static DOH *is_shadow(SwigType *t) {
void
PYTHON::parse_args(int argc, char *argv[]) {
int i;
- strcpy(LibDir,"python");
+ Swig_swiglib_set("python");
for (i = 1; i < argc; i++) {
if (argv[i]) {
@@ -150,11 +150,11 @@ PYTHON::initialize(String *modname) {
if (Swig_insert_file("common.swg", f_runtime) == -1) {
Printf(stderr,"SWIG : Fatal error. Unable to locate common.swg. (Possible installation problem).\n");
- SWIG_exit (EXIT_FAILURE);
+ Swig_exit (EXIT_FAILURE);
}
if (Swig_insert_file("python.swg", f_runtime) == -1) {
Printf(stderr,"SWIG : Fatal error. Unable to locate python.swg. (Possible installation problem).\n");
- SWIG_exit (EXIT_FAILURE);
+ Swig_exit (EXIT_FAILURE);
}
if (!module) module = NewString(modname);
@@ -168,7 +168,7 @@ PYTHON::initialize(String *modname) {
Append(module,"c");
if ((f_shadow = fopen(filen,"w")) == 0) {
Printf(stderr,"Unable to open %s\n", filen);
- SWIG_exit (EXIT_FAILURE);
+ Swig_exit (EXIT_FAILURE);
}
Printf(f_shadow,"# This file was created automatically by SWIG.\n");
Printf(f_shadow,"import %s\n", interface ? interface : module);
diff --git a/Source/Modules1.1/ruby.cxx b/Source/Modules1.1/ruby.cxx
index 9b9af1d42..0513f1b4e 100644
--- a/Source/Modules1.1/ruby.cxx
+++ b/Source/Modules1.1/ruby.cxx
@@ -150,11 +150,11 @@ void RUBY::parse_args(int argc, char *argv[]) {
}
}
/* Set location of SWIG library */
- strcpy(LibDir,"ruby");
+ Swig_swiglib_set("ruby");
/* Add a symbol to the parser for conditional compilation */
Preprocessor_define((void *) "SWIGRUBY", 0);
- SWIG_config_file("ruby.i");
+ Swig_set_config_file("ruby.i");
}
@@ -164,7 +164,7 @@ static void insert_file(char *filename, File *file) {
"SWIG : Fatal error. "
"Unable to locate %s. (Possible installation problem).\n",
filename);
- SWIG_exit (EXIT_FAILURE);
+ Swig_exit (EXIT_FAILURE);
}
}
diff --git a/Source/Modules1.1/swig11.h b/Source/Modules1.1/swig11.h
index 522be91c9..57e363ed6 100644
--- a/Source/Modules1.1/swig11.h
+++ b/Source/Modules1.1/swig11.h
@@ -31,7 +31,6 @@ extern DOH *f_header; // Headers
extern DOH *f_wrappers; // Wrappers
extern DOH *f_init; // Initialization code
extern FILE *f_input;
-extern char LibDir[512]; // Library directory
extern int CPlusPlus; // C++ mode
extern int AddMethods; // AddMethods mode
extern int NewObject; // NewObject mode
@@ -95,8 +94,6 @@ extern void new_create_function(char *, char *, SwigType *, ParmList *);
extern void emit_set_get(DOH *node);
extern void emit_set_action(DOHString_or_char *decl);
-extern int SWIG_main(int, char **, Language *);
-
/* These are in the new core */
extern "C" void *Preprocessor_define(void *, int);
@@ -104,7 +101,6 @@ extern "C" void *Preprocessor_define(void *, int);
extern int emit_args(DOH *node, Wrapper *f);
extern void emit_func_call(DOH *node, Wrapper *f);
-extern void SWIG_exit(int); /* use EXIT_{SUCCESS,FAILURE} */
extern int check_numopt(ParmList *);
extern void SWIG_config_file(const String_or_char *);
diff --git a/Source/Modules1.1/swigmain.cxx b/Source/Modules1.1/swigmain.cxx
deleted file mode 100644
index 3c4e30af2..000000000
--- a/Source/Modules1.1/swigmain.cxx
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Simplified Wrapper and Interface Generator (SWIG)
- *
- * Author : David Beazley
- *
- * Department of Computer Science
- * University of Chicago
- * 1100 E 58th Street
- * Chicago, IL 60637
- * beazley@cs.uchicago.edu
- *
- * Please read the file LICENSE for the copyright and terms by which SWIG
- * can be used and distributed.
- *******************************************************************************/
-
-static char cvsroot[] = "$Header$";
-
-/***********************************************************************
- * $Header$
- *
- * swigmain.cxx
- *
- * The main program.
- *
- ***********************************************************************/
-
-#ifndef MACSWIG
-#include "swigconfig.h"
-#endif
-#include "swig11.h"
-#include "tcl8.h"
-#include "python.h"
-
-
-#include "perl5.h"
-#include "guile.h"
-#ifdef OLD
-#include "java.h"
-#endif
-#include "mzscheme.h"
-#include "ruby.h"
-
-#include
-
-#ifndef SWIG_LANG
-#define SWIG_LANG PYTHON
-#endif
-
-#ifdef MACSWIG
-#include
-#include
-#endif
-
-static char *usage = (char*)"\
-swig filename\n\n\
-Target Language Options:\n\
- -tcl - Generate Tcl wrappers.\n\
- -python - Generate Python wrappers.\n\
- -perl5 - Generate Perl5 wrappers.\n\
- -java - Generate Java wrappers.\n\
- -guile - Generate Guile wrappers.\n\
- -mzscheme - Generate Mzscheme wrappers.\n\
- -ruby - Generate Ruby wrappers.\n";
-
-//-----------------------------------------------------------------
-// main()
-//
-// Main program. Initializes the files and starts the parser.
-//-----------------------------------------------------------------
-
-
-int main(int argc, char **argv) {
- int i;
- Language *dl = new SWIG_LANG;
- extern int SWIG_main(int, char **, Language *);
-
- #ifdef MACSWIG
- SIOUXSettings.asktosaveonclose = false;
- argc = ccommand(&argv);
- #endif
-
- Swig_init_args(argc,argv);
-
- // Get options
- for (i = 1; i < argc; i++) {
- if (argv[i]) {
- if(strcmp(argv[i],"-tcl") == 0) {
- fprintf(stderr,"swig: -tcl option now implies -tcl8\n");
- dl = new TCL8;
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-tcl8") == 0) {
- dl = new TCL8;
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-python") == 0) {
- dl = new PYTHON;
- Swig_mark_arg(i);
-
- } else if (strcmp(argv[i],"-perl5") == 0) {
- dl = new PERL5;
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-guile") == 0) {
- dl = new GUILE;
- Swig_mark_arg(i);
-#ifdef OLD
- } else if (strcmp(argv[i],"-java") == 0) {
- dl = new JAVA;
- Swig_mark_arg(i);
-#endif
- } else if (strcmp(argv[i],"-mzscheme") == 0) {
- dl = new MZSCHEME;
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-ruby") == 0) {
- dl = new RUBY;
- Swig_mark_arg(i);
- } else if (strcmp(argv[i],"-help") == 0) {
- fputs(usage,stderr);
- Swig_mark_arg(i);
- }
- }
- }
- return SWIG_main(argc,argv,dl);
-}
diff --git a/Source/Modules1.1/tcl8.cxx b/Source/Modules1.1/tcl8.cxx
index 9615c8a4c..be350002d 100644
--- a/Source/Modules1.1/tcl8.cxx
+++ b/Source/Modules1.1/tcl8.cxx
@@ -50,7 +50,7 @@ static Hash *repeatcmd = 0;
void
TCL8::parse_args(int argc, char *argv[]) {
int i;
- strcpy(LibDir,"tcl");
+ Swig_swiglib_set("tcl");
for (i = 1; i < argc; i++) {
if (argv[i]) {
@@ -84,7 +84,7 @@ TCL8::parse_args(int argc, char *argv[]) {
Preprocessor_define((void *) "SWIGTCL 1",0);
Preprocessor_define((void *) "SWIGTCL8 1", 0);
- SWIG_config_file("tcl8.swg");
+ Swig_set_config_file("tcl8.swg");
}
/* -----------------------------------------------------------------------------
@@ -109,11 +109,11 @@ TCL8::initialize(String *modname) {
}
if (Swig_insert_file("common.swg",f_runtime) == -1) {
Printf(stderr,"SWIG : Fatal error. Unable to locate 'common.swg' in SWIG library.\n");
- SWIG_exit (EXIT_FAILURE);
+ Swig_exit (EXIT_FAILURE);
}
if (Swig_insert_file("swigtcl8.swg",f_runtime) == -1) {
Printf(stderr,"SWIG : Fatal error. Unable to locate 'swigtcl8.swg' in SWIG library.\n");
- SWIG_exit (EXIT_FAILURE);
+ Swig_exit (EXIT_FAILURE);
}
if (!module) module = NewString(modname);
@@ -947,7 +947,7 @@ TCL8::cpp_open_class(DOH *node) {
if (!included_object) {
if (Swig_insert_file("object.swg",f_header) == -1) {
Printf(stderr,"SWIG : Fatal error. Unable to locate 'object.swg' in SWIG library.\n");
- SWIG_exit (EXIT_FAILURE);
+ Swig_exit (EXIT_FAILURE);
}
included_object = 1;
}
diff --git a/Source/Swig/Makefile.in b/Source/Swig/Makefile.in
index 1bee11538..9503e0ab2 100644
--- a/Source/Swig/Makefile.in
+++ b/Source/Swig/Makefile.in
@@ -6,9 +6,9 @@ srcdir = @srcdir@
VPATH = @srcdir@
SRCS = map.c wrapfunc.c naming.c tree.c stype.c scanner.c include.c getopt.c misc.c \
- parms.c cwrap.c typemap.c module.c
+ parms.c cwrap.c typemap.c module.c main.c
OBJS = map.o wrapfunc.o naming.o tree.o stype.o scanner.o include.o getopt.o misc.o \
- parms.o cwrap.o typemap.o module.o
+ parms.o cwrap.o typemap.o module.o main.o
prefix = @prefix@
exec_prefix = @exec_prefix@
diff --git a/Source/Swig/getopt.c b/Source/Swig/getopt.c
index f83f18bbc..7c71bee8b 100644
--- a/Source/Swig/getopt.c
+++ b/Source/Swig/getopt.c
@@ -111,8 +111,6 @@ Swig_arg_error() {
Printf(stderr,"Use 'swig -help' for available options.\n");
exit(1);
}
-
-
diff --git a/Source/Swig/module.c b/Source/Swig/module.c
index 44cf248c9..3c5916858 100644
--- a/Source/Swig/module.c
+++ b/Source/Swig/module.c
@@ -182,7 +182,7 @@ DOH *Swig_run_modules(DOH *node) {
}
ml = Getattr(LoadedModules,tag);
if ((!ml) || (Len(ml) == 0)) {
- Printf(stderr,"No module for object '%s'\n", tag);
+ Printf(stderr,"Internal error. No module defined for handling '%s'\n", tag);
return 0;
}
newnode = 0;
@@ -192,7 +192,7 @@ DOH *Swig_run_modules(DOH *node) {
m = (Module *) Data(Getitem(ml,i));
assert(m);
newnode = (*m->startfunc)(node);
- if (!newnode) return 0; /* Done */
+ if (!newnode) return node; /* Done */
newtag = Getattr(newnode,"tag");
if (!newtag) {
Printf(stderr,"Fatal error. Module '%s' returns untagged object.\n", m->modname);
diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
index 5eeea2dd0..67e6d16fd 100644
--- a/Source/Swig/swig.h
+++ b/Source/Swig/swig.h
@@ -424,7 +424,8 @@ extern void Swig_except_clear();
#define Getchild(x) Getattr(x,"child")
#define Setchild(x,c) Setattr(x,"child",c)
-extern int Swig_main(int argc, char *argv[]);
+extern int Swig_main(int argc, char **argv, char **modules);
+extern void Swig_exit(int n);
#endif