diff --git a/SWIG/Source/Include/swigver.h b/SWIG/Source/Include/swigver.h index 1242cf9ad..355276b29 100644 --- a/SWIG/Source/Include/swigver.h +++ b/SWIG/Source/Include/swigver.h @@ -1,7 +1,5 @@ /* SWIG version information */ -#define SWIG_MAJOR_VERSION 1 -#define SWIG_MINOR_VERSION 3 +#define SWIG_VERSION "1.3u-20000226-1923" #define SWIG_SPIN "(Alpha 1)" - diff --git a/SWIG/Source/Modules1.1/guile.cxx b/SWIG/Source/Modules1.1/guile.cxx index f6c9232a6..744523841 100644 --- a/SWIG/Source/Modules1.1/guile.cxx +++ b/SWIG/Source/Modules1.1/guile.cxx @@ -213,7 +213,7 @@ GUILE::headers (void) // Write out hex conversion functions if (!NoInclude) { - if (insert_file ("guile.swg", f_header) == -1) { + if (Swig_insert_file ("guile.swg", f_header) == -1) { fprintf (stderr, "SWIG : Fatal error. "); fprintf (stderr, "Unable to locate 'guile.swg' in SWIG library.\n"); SWIG_exit (1); diff --git a/SWIG/Source/Modules1.1/java.cxx b/SWIG/Source/Modules1.1/java.cxx index 05484f99f..9feb7f032 100644 --- a/SWIG/Source/Modules1.1/java.cxx +++ b/SWIG/Source/Modules1.1/java.cxx @@ -404,7 +404,7 @@ void JAVA::headers(void) // Include header file code fragment into the output // if (file::include("java.swg",f_header) == -1) { - if (insert_file("java.swg",f_header) == -1) { + if (Swig_insert_file("java.swg",f_header) == -1) { fprintf(stderr,"Fatal Error. Unable to locate 'java.swg'.\n"); SWIG_exit(1); } diff --git a/SWIG/Source/Modules1.1/perl5.cxx b/SWIG/Source/Modules1.1/perl5.cxx index 9913b74c5..245e386be 100644 --- a/SWIG/Source/Modules1.1/perl5.cxx +++ b/SWIG/Source/Modules1.1/perl5.cxx @@ -295,12 +295,12 @@ void PERL5::headers(void) emit_banner(f_header); if (!alt_header) { - if (insert_file("headers.swg", f_header) == -1) { + if (Swig_insert_file("headers.swg", f_header) == -1) { fprintf(stderr,"Perl5 : Fatal error. Unable to locate headers.swg. Possible installation problem.\n"); SWIG_exit(1); } } else { - if (insert_file(alt_header, f_header) == -1) { + if (Swig_insert_file(alt_header, f_header) == -1) { fprintf(stderr,"SWIG : Fatal error. Unable to locate %s.\n",alt_header); SWIG_exit(1); } @@ -311,13 +311,13 @@ void PERL5::headers(void) } // Get special SWIG related declarations - if (insert_file("perl5.swg", f_header) == -1) { + if (Swig_insert_file("perl5.swg", f_header) == -1) { fprintf(stderr,"SWIG : Fatal error. Unable to locate 'perl5.swg' in SWIG library.\n"); SWIG_exit(1); } // Get special SWIG related declarations - if (insert_file("perl5mg.swg", f_header) == -1) { + if (Swig_insert_file("perl5mg.swg", f_header) == -1) { fprintf(stderr,"SWIG : Fatal error. Unable to locate 'perl5mg.swg' in SWIG library.\n"); SWIG_exit(1); } @@ -2225,8 +2225,14 @@ void PERL5::pragma(char *lang, char *code, char *value) { } else if (strcmp(code,"include") == 0) { // Include a file into the .pm file if (value) { - if (get_file(value,pragma_include) == -1) { + FILE *f = Swig_open(value); + if (!f) { fprintf(stderr,"%s : Line %d. Unable to locate file %s\n", input_file, line_number,value); + } else { + char buffer[4096]; + while (fgets(buffer,4095,f)) { + pragma_include << buffer; + } } } } else { diff --git a/SWIG/Source/Modules1.1/python.cxx b/SWIG/Source/Modules1.1/python.cxx index 1bdba757a..51e0a8adb 100644 --- a/SWIG/Source/Modules1.1/python.cxx +++ b/SWIG/Source/Modules1.1/python.cxx @@ -262,7 +262,7 @@ void PYTHON::headers(void) if (NoInclude) fprintf(f_runtime,"#define SWIG_NOINCLUDE\n"); - if (insert_file("python.swg", f_runtime) == -1) { + if (Swig_insert_file("python.swg", f_runtime) == -1) { fprintf(stderr,"SWIG : Fatal error. Unable to locate python.swg. (Possible installation problem).\n"); SWIG_exit(1); } @@ -1455,8 +1455,14 @@ void PYTHON::pragma(char *lang, char *cmd, char *value) { } else if (strcmp(cmd,"include") == 0) { if (shadow) { if (value) { - if (get_file(value,pragma_include) == -1) { - fprintf(stderr,"%s : Line %d. Unable to locate file %s\n", input_file, line_number, value); + FILE *f = Swig_open(value); + if (!f) { + fprintf(stderr,"%s : Line %d. Unable to locate file %s\n", input_file, line_number,value); + } else { + char buffer[4096]; + while (fgets(buffer,4095,f)) { + pragma_include << buffer; + } } } } diff --git a/SWIG/Source/Modules1.1/tcl8.cxx b/SWIG/Source/Modules1.1/tcl8.cxx index a634d6e42..5c1d70e99 100644 --- a/SWIG/Source/Modules1.1/tcl8.cxx +++ b/SWIG/Source/Modules1.1/tcl8.cxx @@ -241,7 +241,7 @@ void TCL8::headers(void) fprintf(f_runtime,"#define SWIG_NOINCLUDE\n"); } - if (insert_file("swigtcl8.swg",f_runtime) == -1) { + if (Swig_insert_file("swigtcl8.swg",f_runtime) == -1) { fprintf(stderr,"SWIG : Fatal error. Unable to locate 'swigtcl8.swg' in SWIG library.\n"); SWIG_exit(1); } @@ -1224,7 +1224,7 @@ void TCL8::cpp_open_class(char *classname, char *rename, char *ctype, int strip) if (shadow) { static int included_object = 0; if (!included_object) { - if (insert_file("object.swg",f_header) == -1) { + if (Swig_insert_file("object.swg",f_header) == -1) { fprintf(stderr,"SWIG : Fatal error. Unable to locate 'object.swg' in SWIG library.\n"); SWIG_exit(1); } diff --git a/SWIG/Source/SWIG1.1/Makefile.in b/SWIG/Source/SWIG1.1/Makefile.in index 06e304954..e8630a1b2 100644 --- a/SWIG/Source/SWIG1.1/Makefile.in +++ b/SWIG/Source/SWIG1.1/Makefile.in @@ -14,11 +14,11 @@ RANLIB = @RANLIB@ TARGET = libswig11.a -OBJS = parser.o main.o scanner.o symbol.o types.o include.o parms.o \ +OBJS = parser.o main.o scanner.o symbol.o types.o parms.o \ emit.o cplus.o lang.o hash.o sstring.o wrapfunc.o \ typemap.o naming.o -SRCS = main.cxx scanner.cxx symbol.cxx include.cxx types.cxx parms.cxx \ +SRCS = main.cxx scanner.cxx symbol.cxx types.cxx parms.cxx \ emit.cxx cplus.cxx lang.cxx hash.cxx \ sstring.cxx wrapfunc.cxx typemap.cxx naming.cxx diff --git a/SWIG/Source/SWIG1.1/emit.cxx b/SWIG/Source/SWIG1.1/emit.cxx index dcf5d0775..678a9c25b 100644 --- a/SWIG/Source/SWIG1.1/emit.cxx +++ b/SWIG/Source/SWIG1.1/emit.cxx @@ -205,93 +205,6 @@ char *emit_local(int i) { return arg; } -// ----------------------------------------------------------------------------- -// int emit_args(char *d, DataType *rt, ParmList *l, FILE *f) -// -// Creates a list of variable declarations for both the return value -// and function parameters. -// -// The return value is always called _result and arguments label as -// _arg0, _arg1, _arg2, etc... -// -// Returns the number of parameters associated with a function. -// ----------------------------------------------------------------------------- - -int emit_args(DataType *rt, ParmList *l, FILE *f) { - - Parm *p; - int i; - char temp[64]; - String def; - char *tm; - - // Declare the return variable - - if ((rt->type != T_VOID) || (rt->is_pointer)) { - if ((rt->type == T_USER) && (!rt->is_pointer)) { - - // Special case for return by "value" - - rt->is_pointer++; - fprintf(f,"\t %s _result;\n", rt->print_type()); - rt->is_pointer--; - } else { - - // Normal return value - - fprintf(f,"\t %s _result;\n", rt->print_type()); - } - } - - // Emit function arguments - - i = 0; - p = l->get_first(); - while (p != 0) { - if ((p->t->type != T_VOID) || (p->t->is_pointer)) { - sprintf(temp,"_arg%d", i); - if (p->defvalue) { - if ((p->t->is_reference) || ((p->t->type == T_USER) && (p->call_type == CALL_REFERENCE))) - fprintf(f,"\t %s _arg%d = &%s;\n", p->t->print_type(),i, p->defvalue); - else - fprintf(f,"\t %s _arg%d = %s;\n", p->t->print_type(),i, p->defvalue); - } else { - fprintf(f,"\t %s _arg%d;\n", p->t->print_type(),i); - tm = typemap_lookup("arginit", typemap_lang, p->t, p->name,"",temp); - if (tm) { - def << tm; - } - } - - // Check for ignore or default typemaps - - tm = typemap_lookup("default",typemap_lang,p->t,p->name,"",temp); - if (tm) - def << tm; - tm = typemap_lookup("ignore",typemap_lang,p->t,p->name,"",temp); - - if (tm) { - def << tm; - p->ignore = 1; - } - tm = typemap_check("build",typemap_lang,p->t,p->name); - if (tm) { - p->ignore = 1; - } - i++; - } - p = l->get_next(); - } - - fprintf(f,"%s",def.get()); - - // i now contains number of parameters - - return(i); - - } - - // ----------------------------------------------------------------------------- // int emit_args(char *d, DataType *rt, ParmList *l, WrapperFunction &f) // @@ -375,86 +288,6 @@ int emit_args(DataType *rt, ParmList *l, WrapperFunction &f) { return(i); } -// ----------------------------------------------------------------------------- -// int emit_func_call(char *decl, DataType *t, ParmList *l, FILE *f) -// -// Emits code for a function call. -// ----------------------------------------------------------------------------- - -void emit_func_call(char *decl, DataType *t, ParmList *l, FILE *f) { - - int i; - Parm *p; - -// fprintf(f,"#line %d \"%s\"\n", line_number, input_file); - fprintf(f,"\t "); - - // First check if there is a return value - - if ((t->type != T_VOID) || (t->is_pointer)) { - if ((t->type == T_USER) && (!t->is_pointer)) { - - // Special case for return by "value" - // Caution : This *will* cause a memory leak if not - // used properly. - - if (CPlusPlus) { - fprintf(f,"_result = new %s(", t->print_type()); - } else { - t->is_pointer++; - fprintf(f,"_result = %s malloc(sizeof(", t->print_cast()); - t->is_pointer--; - fprintf(f,"%s));\n", t->print_type()); - fprintf(f,"\t*(_result) = "); - } - } else { - // Check if this is a C++ reference - if (t->is_reference) { - t->is_pointer--; - fprintf(f,"%s& _result_ref = ", t->print_full()); - t->is_pointer++; - } else { - - // Normal return values - fprintf(f,"_result = %s", t->print_cast()); - } - } - } - - // Now print out function call - - fprintf(f,"%s(",decl); - - i = 0; - p = l->get_first(); - while(p != 0) { - if ((p->t->type != T_VOID) || (p->t->is_pointer)){ - fprintf(f,"%s",p->t->print_arraycast()); - if ((!p->t->is_reference) && (p->call_type & CALL_VALUE)) fprintf(f,"&"); - if ((!(p->call_type & CALL_VALUE)) && - ((p->t->is_reference) || (p->call_type & CALL_REFERENCE))) - fprintf(f,"*"); - fprintf(f,"_arg%d",i); - i++; - } - p = l->get_next(); - if (p != 0) - fprintf(f,","); - } - - fprintf(f,")"); - if ((t->type == T_USER) && (!t->is_pointer)) { - if (CPlusPlus) { - fprintf(f,")"); - } - } - fprintf(f,";\n"); - if (t->is_reference) { - fprintf(f,"\t _result = %s &_result_ref;\n", t->print_cast()); - } -} - - // ----------------------------------------------------------------------------- // int emit_func_call(char *decl, DataType *t, ParmList *l, WrapperFunction &f) @@ -562,27 +395,6 @@ void emit_func_call(char *decl, DataType *t, ParmList *l, WrapperFunction &f) { } } -// ----------------------------------------------------------------------------- -// void emit_hex(FILE *f) -// -// Emits the default C-code to handle pointers. This is normally contained -// in the SWIG library file 'swigptr.swg' -// ----------------------------------------------------------------------------- - -void emit_hex(FILE *f) { - - int stat; - - // Look for a pointer configuration file - - stat = insert_file("swigptr.swg", f); - - if (stat == -1) { - fprintf(stderr,"** Fatal error. Unable to locate 'swigptr.swg'\n"); - SWIG_exit(1); - } -} - // ----------------------------------------------------------------------------- // void emit_set_get(char *name, char *iname, DataType *type) // diff --git a/SWIG/Source/SWIG1.1/include.cxx b/SWIG/Source/SWIG1.1/include.cxx deleted file mode 100644 index 9b3d94a9e..000000000 --- a/SWIG/Source/SWIG1.1/include.cxx +++ /dev/null @@ -1,93 +0,0 @@ -/* ----------------------------------------------------------------------------- - * include.cxx - * - * File inclusion functions. This file is deprecated. These are only a - * thin wrapper over the functions in Swig/include.c. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1998-2000. The University of Chicago - * Copyright (C) 1995-1998. The University of Utah and The Regents of the - * University of California. - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -static char cvsroot[] = "$Header$"; - -#include "internal.h" - -extern "C" FILE *Swig_open(void *); - -// ----------------------------------------------------------------------------- -// check_suffix(char *name) -// -// Checks the suffix of a file to see if we should emit extern declarations. -// ----------------------------------------------------------------------------- - -int -check_suffix(char *name) { - char *c; - if (!name) return 0; - if (strlen(name) == 0) return 0; - c = name+strlen(name)-1; - while (c != name) { - if (*c == '.') break; - c--; - } - if (c == name) return 0; - if ((strcmp(c,".c") == 0) || - (strcmp(c,".C") == 0) || - (strcmp(c,".cc") == 0) || - (strcmp(c,".cxx") == 0) || - (strcmp(c,".c++") == 0) || - (strcmp(c,".cpp") == 0)) { - return 1; - } - return 0; -} - -// ----------------------------------------------------------------------------- -// int insert_file(char *filename, FILE *f) -// -// Appends the contents of filename to stream f. -// ----------------------------------------------------------------------------- -int insert_file(char *filename, FILE *f) { - FILE *in_file; - char buffer[1024]; - if ((in_file = Swig_open((void *) filename)) == NULL) { - return -1; - } - while (fgets(buffer,1023,in_file)) { - fputs(buffer, f); - } - fclose(in_file); - return 0; -} - -// ----------------------------------------------------------------------------- -// int get_file(char *name, String &str) -// -// Looks for a file and converts it into a String. -// ----------------------------------------------------------------------------- -int get_file(char *name, String &str) { - FILE *f; - char buffer[1024]; - f = Swig_open((void *) name); - if (!f) { - fprintf(stderr,"SWIG Error. Unable to find %s. Possible installation problem.\n",name); - FatalError(); - return -1; - } - while (fgets(buffer,1023,f)) { - str << buffer; - } - fclose(f); - return 0; -} - - - - - - diff --git a/SWIG/Source/SWIG1.1/main.cxx b/SWIG/Source/SWIG1.1/main.cxx index ca4ebc7e8..f93ac6f28 100644 --- a/SWIG/Source/SWIG1.1/main.cxx +++ b/SWIG/Source/SWIG1.1/main.cxx @@ -77,6 +77,34 @@ static char *usage = "\ -version - Print SWIG version number\n\ -help - This output.\n\n"; +// ----------------------------------------------------------------------------- +// check_suffix(char *name) +// +// Checks the suffix of a file to see if we should emit extern declarations. +// ----------------------------------------------------------------------------- + +int +check_suffix(char *name) { + char *c; + if (!name) return 0; + if (strlen(name) == 0) return 0; + c = name+strlen(name)-1; + while (c != name) { + if (*c == '.') break; + c--; + } + if (c == name) return 0; + if ((strcmp(c,".c") == 0) || + (strcmp(c,".C") == 0) || + (strcmp(c,".cc") == 0) || + (strcmp(c,".cxx") == 0) || + (strcmp(c,".c++") == 0) || + (strcmp(c,".cpp") == 0)) { + return 1; + } + return 0; +} + //----------------------------------------------------------------- // main() // @@ -342,10 +370,10 @@ int SWIG_main(int argc, char *argv[], Language *l) { sprintf(fn_wrapper,"%s%s_wrap.wrap",output_dir,infile); sprintf(fn_init,"%s%s_wrap.init",output_dir,infile); - printf("%s\n", input_file); - printf("%s\n", fn_cpp); - printf("%s\n", fn_wrapper); - printf("%s\n", fn_init); + // printf("%s\n", input_file); + // printf("%s\n", fn_cpp); + // printf("%s\n", fn_wrapper); + // printf("%s\n", fn_init); // Define the __cplusplus symbol if (CPlusPlus) @@ -440,9 +468,9 @@ int SWIG_main(int argc, char *argv[], Language *l) { fclose(f_wrappers); fclose(f_init); - insert_file(fn_header, f_runtime); - insert_file(fn_wrapper,f_runtime); - insert_file(fn_init,f_runtime); + Swig_insert_file(fn_header, f_runtime); + Swig_insert_file(fn_wrapper,f_runtime); + Swig_insert_file(fn_init,f_runtime); fclose(f_runtime); diff --git a/SWIG/Source/SWIG1.1/swig11.h b/SWIG/Source/SWIG1.1/swig11.h index dc9c44e4f..a6af489ad 100644 --- a/SWIG/Source/SWIG1.1/swig11.h +++ b/SWIG/Source/SWIG1.1/swig11.h @@ -459,11 +459,6 @@ extern void cplus_emit_variable_set(char *classname, char *classtype, char *clas extern char *cplus_base_class(char *name); -/* Function for building search directories */ - -extern int insert_file(char *, FILE *); -extern int get_file(char *filename, String &str); - /* These are in the new core */ extern "C" { @@ -473,6 +468,8 @@ extern "C" { extern void Swig_check_options(); extern void Swig_arg_error(); extern void *Preprocessor_define(void *, int); + extern int Swig_insert_file(const void *filename, void *outfile); + extern FILE *Swig_open(const void *filename); } // ----------------------------------------------------------------------- diff --git a/SWIG/Source/Swig/include.c b/SWIG/Source/Swig/include.c index fc72872bc..a35fea411 100644 --- a/SWIG/Source/Swig/include.c +++ b/SWIG/Source/Swig/include.c @@ -28,7 +28,7 @@ static int bytes_read = 0; /* Bytes read */ * ----------------------------------------------------------------------------- */ void -Swig_add_directory(DOH *dirname) { +Swig_add_directory(const DOH *dirname) { if (!directories) directories = NewList(); assert(directories); if (!String_check(dirname)) { @@ -86,7 +86,7 @@ Swig_search_path() { * ----------------------------------------------------------------------------- */ FILE * -Swig_open(DOH *name) { +Swig_open(const DOH *name) { FILE *f; DOH *filename; DOH *spath = 0; @@ -143,7 +143,7 @@ Swig_read_file(FILE *f) { * ----------------------------------------------------------------------------- */ DOH * -Swig_include(DOH *name) { +Swig_include(const DOH *name) { FILE *f; DOH *str; f = Swig_open(name); @@ -157,7 +157,23 @@ Swig_include(DOH *name) { return str; } - +/* ----------------------------------------------------------------------------- + * Swig_insert_file() + * + * Copies the contents of a file into another file + * ----------------------------------------------------------------------------- */ + +int +Swig_insert_file(const DOH *filename, DOH *outfile) { + char buffer[4096]; + int nbytes; + FILE *f = Swig_open(filename); + if (!f) return -1; + while ((nbytes = Read(f,buffer,4096)) > 0) { + Write(outfile,buffer,nbytes); + } + return 0; +} diff --git a/SWIG/Source/Swig/swig.h b/SWIG/Source/Swig/swig.h index 44aa0b2ff..3c16133ae 100644 --- a/SWIG/Source/Swig/swig.h +++ b/SWIG/Source/Swig/swig.h @@ -28,12 +28,13 @@ extern "C" { /* --- File interface --- */ -extern void Swig_add_directory(DOH *dirname); +extern void Swig_add_directory(const DOH *dirname); extern DOH *Swig_last_file(); extern DOH *Swig_search_path(); -extern FILE *Swig_open(DOH *name); +extern FILE *Swig_open(const DOH *name); extern DOH *Swig_read_file(FILE *f); -extern DOH *Swig_include(DOH *name); +extern DOH *Swig_include(const DOH *name); +extern int Swig_insert_file(const DOH *name, DOH *outfile); #define SWIG_FILE_DELIMETER "/"