From 877aa520169f61e129cdf051df429beb4023a1ef Mon Sep 17 00:00:00 2001 From: Thien-Thi Nguyen Date: Thu, 31 Aug 2000 18:04:30 +0000 Subject: [PATCH] Use `EXIT_SUCCESS' and `EXIT_FAILURE'. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@761 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules1.1/guile.cxx | 34 ++-- Source/Modules1.1/java.cxx | 50 ++--- Source/Modules1.1/mzscheme.cxx | 6 +- Source/Modules1.1/perl5.cxx | 202 +++++++++---------- Source/Modules1.1/python.cxx | 154 +++++++-------- Source/Modules1.1/ruby.cxx | 8 +- Source/Modules1.1/tcl8.cxx | 86 ++++---- Source/SWIG1.1/main.cxx | 10 +- Source/SWIG1.1/parser.yxx | 348 ++++++++++++++++----------------- Source/SWIG1.1/scanner.cxx | 80 ++++---- Source/SWIG1.1/swig11.h | 2 +- 11 files changed, 490 insertions(+), 490 deletions(-) diff --git a/Source/Modules1.1/guile.cxx b/Source/Modules1.1/guile.cxx index 92f9be5c4..77656d54e 100644 --- a/Source/Modules1.1/guile.cxx +++ b/Source/Modules1.1/guile.cxx @@ -79,7 +79,7 @@ GUILE::parse_args (int argc, char *argv[]) if (argv[i]) { if (strcmp (argv[i], "-help") == 0) { fputs (guile_usage, stderr); - SWIG_exit (0); + SWIG_exit (EXIT_SUCCESS); } // Silent recognition (no side effects) of "-with-smobs" is here // as a convenience to users. This will be removed after 1.3a4 @@ -236,7 +236,7 @@ GUILE::headers (void) Printf (f_runtime, "/* Implementation : GUILE */\n\n"); // Write out directives and declarations - + if (NoInclude) { Printf(f_runtime, "#define SWIG_NOINCLUDE\n"); } @@ -382,7 +382,7 @@ is_a_pointer (SwigType *t) static char * guile_typemap_lookup(const char *op, SwigType *type, String_or_char *pname, String_or_char *source, - String_or_char *target, Wrapper *f) + String_or_char *target, Wrapper *f) { char *tm; tm = Swig_typemap_lookup((char*) op, type, pname, source, target, f); @@ -392,7 +392,7 @@ guile_typemap_lookup(const char *op, SwigType *type, String_or_char *pname, Stri tm = Swig_typemap_lookup((char*) op, (char*) "int", pname, source, target, f); } return tm; -} +} /* Lookup a typemap, replace all relevant parameters and write it to the given generalized file. Return 0 if no typemap found. */ @@ -497,7 +497,7 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l) 0, proc_name, f); /* Open prototype and signature */ - + Printv(f->def, "static SCM\n", wname," (", 0); Printv(signature, "(", proc_name, 0); @@ -547,7 +547,7 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l) source, target, numargs, proc_name, f, 0); /* Pass output arguments back to the caller. */ - + guile_do_typemap(outarg, "argout", pt, pn, source, target, numargs, proc_name, f, 0); @@ -565,7 +565,7 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l) } } } - + // free up any memory allocated for the arguments. guile_do_typemap(cleanup, "freearg", pt, pn, @@ -573,17 +573,17 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l) } /* Close prototype and signature */ - + Printv(signature, ")\n", 0); Printf(f->def, ")\n{\n"); - + /* Define the scheme name in C */ /* FIXME: This is only needed for the code in exception.i since typemaps can always use $name. I propose to define a new macro SWIG_exception_in(ERROR, MESSAGE, FUNCTION) and use it instead of SWIG_exception(ERROR, MESSAGE). */ Printv(f->def, "#define SCHEME_NAME \"", proc_name, "\"\n", 0); - + // Now write code to make the function call Printv(f->code, tab4, "gh_defer_ints();\n", 0); emit_func_call (name, d, l, f); @@ -618,7 +618,7 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l) // Look for any remaining cleanup if (NewObject) { - guile_do_typemap(f->code, "newfree", d, iname, + guile_do_typemap(f->code, "newfree", d, iname, (char*)"result", (char*)"", 0, proc_name, f, 0); } @@ -671,7 +671,7 @@ GUILE::create_function (char *name, char *iname, SwigType *d, ParmList *l) Printv(signature, "\n", 0); Printv(procdoc, "\f\n", signature, 0); } - + Delete(proc_name); Delete(outarg); Delete(cleanup); @@ -699,7 +699,7 @@ GUILE::link_variable (char *name, char *iname, SwigType *t) char var_name[256]; char *tm; Wrapper *f; - + f = NewWrapper(); // evaluation function names @@ -730,7 +730,7 @@ GUILE::link_variable (char *name, char *iname, SwigType *t) "\"Unable to set %s. Variable is read only.\", SCM_EOL);\n", proc_name, proc_name); } - else if ((tm = guile_typemap_lookup ("varin", + else if ((tm = guile_typemap_lookup ("varin", t, name, (char*)"s_0", name, f))) { Printf (f_wrappers, "%s\n", tm); } @@ -764,7 +764,7 @@ GUILE::link_variable (char *name, char *iname, SwigType *t) // Now return the value of the variable (regardless // of evaluating or setting) - if ((tm = guile_typemap_lookup ("varout", + if ((tm = guile_typemap_lookup ("varout", t, name, name, (char*)"gswig_result", f))) { Printf (f_wrappers, "%s\n", tm); } @@ -791,7 +791,7 @@ GUILE::link_variable (char *name, char *iname, SwigType *t) if (procdoc) { /* Compute documentation */ String *signature = NewString(""); - + if (Status & STAT_READONLY) { Printv(signature, "(", proc_name, ")\n", 0); Printv(signature, "Returns constant ", 0); @@ -878,7 +878,7 @@ GUILE::declare_const (char *name, char *, SwigType *type, char *value) if (SwigType_type(type) == T_STRING) { Printf (f_header, "\"%s\";\n", value); } else if (SwigType_type(type) == T_CHAR) { - Printf (f_header, "\'%s\';\n", value); + Printf (f_header, "\'%s\';\n", value); } else { Printf (f_header, "%s;\n", value); } diff --git a/Source/Modules1.1/java.cxx b/Source/Modules1.1/java.cxx index 7b66d4f1d..18b7011d5 100644 --- a/Source/Modules1.1/java.cxx +++ b/Source/Modules1.1/java.cxx @@ -21,7 +21,7 @@ ******************************************************************************* */ -/* !!!!!!! +/* !!!!!!! * DB 7/24/00: Is there any way to clean up the implementation of this module? * I've tried to bring it as far as I can with core changes, but it's getting * to be a little rough. @@ -85,7 +85,7 @@ char *JAVA::SwigTcToJniType(DataType *t, int ret) { case T_UCHAR: return (char*)"jbyteArray"; case T_SCHAR: return (char*)"jbyteArray"; case T_BOOL: return (char*)"jbooleanArray"; - case T_VOID: + case T_VOID: case T_USER: return (char*)"jlong"; } } else if(DataType_is_pointer(t) > 1) { @@ -275,7 +275,7 @@ void JAVA::writeRegisterNatives() Printf(f_wrappers,"JNINativeMethod nativeMethods[] = {\n"); Printv(f_wrappers, registerNativesList, 0); Printf(f_wrappers, "};\n"); - + Printf(f_wrappers,"\nint numberOfNativeMethods=sizeof(nativeMethods)/sizeof(JNINativeMethod);\n\n"); // The registerNatives function @@ -428,7 +428,7 @@ void JAVA::headers(void) // if (file::include("java.swg",f_header) == -1) { if (Swig_insert_file("java.swg",f_header) == -1) { Printf(stderr,"Fatal Error. Unable to locate 'java.swg'.\n"); - SWIG_exit(1); + SWIG_exit (EXIT_FAILURE); } } @@ -439,7 +439,7 @@ void JAVA::headers(void) // name has already been specified. // --------------------------------------------------------------------- -void JAVA::initialize() +void JAVA::initialize() { if (!module) { Printf(stderr,"*** Error. No module name specified.\n"); @@ -461,15 +461,15 @@ void JAVA::initialize() } else { package = c_pkgstr = jni_pkgstr = (char*)""; } - + sprintf(bigbuf, "Java_%s%s", c_pkgstr, module); c_pkgstr = Swig_copy_string(bigbuf); sprintf(bigbuf, "%s_%%f", c_pkgstr); Swig_name_register((char*)"wrapper", Swig_copy_string(bigbuf)); Swig_name_register((char*)"set", (char*)"set_%v"); Swig_name_register((char*)"get", (char*)"get_%v"); - Swig_name_register((char*)"member", (char*)"%c_%m"); - + Swig_name_register((char*)"member", (char*)"%c_%m"); + // Generate the java class sprintf(bigbuf, "%s.java", module); if((f_java = fopen(bigbuf, "w")) == 0) { @@ -551,7 +551,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l) if(!classdef_emitted) emit_classdef(); // Make a wrapper name for this function - + char *jniname = makeValidJniName(iname); char *wname = Swig_name_wrapper(jniname); free(jniname); @@ -632,7 +632,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l) // Add to Jni function header Printv(f->def, ", ", jnitype, " ", source, 0); - + // Get typemap for this argument tm = typemap_lookup((char*)"in",typemap_lang,pt,pn,source,target,f); if (tm) { @@ -667,7 +667,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l) target_copy = Swig_copy_string(Wrapper_new_localv(f,target,Char(basic_jniptrtype), target, 0)); target_length = Swig_copy_string(Wrapper_new_localv(f,target,"jsize", target, "=", Char(source_length),0)); if(local_i == NULL) local_i = Swig_copy_string(Wrapper_new_local(f,"i","int i")); - + DOHString *scalarFunc = NewStringf("Get%sArrayElements",scalarType); Printv(f->code, tab4, target_copy, " = ", JNICALL(scalarFunc), source, ", 0);\n", 0); @@ -677,7 +677,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l) Printv(f->code, tab8, target, "[i] = *(", DataType_lstr(pt,0), ")&", target_copy, "[i];\n", 0); } else { DataType_del_pointer(pt); - Printv(f->code, tab8, target, "[i] = (", DataType_lstr(pt,0), ")", target_copy, "[i];\n", 0); + Printv(f->code, tab8, target, "[i] = (", DataType_lstr(pt,0), ")", target_copy, "[i];\n", 0); DataType_add_pointer(pt); } Delete(scalarFunc); @@ -728,7 +728,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l) if(DataType_is_pointer(pt) > 1) { Printv(outarg, tab8, "*(", DataType_lstr(pt,0), ")&", target_copy, "[i] = ", target, "[i];\n", 0); } else { - Printv(outarg, tab8, target_copy, "[i] = (", basic_jnitype, ") ", target, "[i];\n", 0); + Printv(outarg, tab8, target_copy, "[i] = (", basic_jnitype, ") ", target, "[i];\n", 0); } DOHString *scalarFunc = NewStringf("Release%sArrayElements",scalarType); Printv(outarg, tab4, JNICALL(scalarFunc), source, ", ", target_copy, ", 0);\n", 0); @@ -755,7 +755,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l) if(!native_func) emit_func_call(name,t,l,f); - // Return value if necessary + // Return value if necessary if((DataType_type(t) != T_VOID) && !native_func) { if ((tm = typemap_lookup((char*)"out",typemap_lang,t,iname,(char*)"result",(char*)"_jresult"))) { @@ -809,18 +809,18 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l) } // Wrap things up (in a manner of speaking) - if(DataType_type(t) != T_VOID) + if(DataType_type(t) != T_VOID) Printv(f->code, tab4, "return _jresult;\n", 0); Printf(f->code, "}\n"); // Substitute the cleanup code (some exception handlers like to have this) Replace(f->code,"$cleanup",cleanup, DOH_REPLACE_ANY); - + // Emit the function - + if(!native_func) Wrapper_print(f,f_wrappers); - + // If registerNatives is active, store the table entry for this method if (useRegisterNatives) { Printv(registerNativesList, @@ -828,7 +828,7 @@ void JAVA::create_function(char *name, char *iname, DataType *t, ParmList *l) "\"", name, "\", \"(", javaParameterSignature, ")", javaReturnSignature, "\", ", wname, "},\n", 0); - + } Delete(cleanup); @@ -879,7 +879,7 @@ void JAVA::declare_const(char *name, char *iname, DataType *type, char *value) { if(!jtype) jtype = SwigTcToJavaType(type, 0, 0); if(strcmp(jname, value) == 0 || strstr(value,"::") != NULL) { Printf(stderr, "ignoring enum constant: %s\n", jname); - } else + } else Printf(jfile, " public final static %s %s = %s;\n\n", jtype, jname, value); } else { if(DataType_type(type) == T_STRING) { @@ -947,7 +947,7 @@ void JAVA::pragma(char *lang, char *code, char *value) { void JAVA::add_typedef(DataType *t, char *name) { if(!shadow) return; - + // First check to see if there aren't too many pointers if (DataType_is_pointer(t) > 1) return; @@ -1109,9 +1109,9 @@ void JAVA::cpp_member_func(char *name, char *iname, DataType *t, ParmList *l) { } } - if((DataType_Gettypecode(t) != T_VOID) && shadowrettype) + if((DataType_Gettypecode(t) != T_VOID) && shadowrettype) Printf(nativecall, "))"); - + Printf(nativecall,");\n"); Printf(f_shadow, ") {\n"); @@ -1187,7 +1187,7 @@ void JAVA::cpp_static_func(char *name, char *iname, DataType *t, ParmList *l) { } - if((DataType_type(t) != T_VOID) && shadowrettype) + if((DataType_type(t) != T_VOID) && shadowrettype) Printf(nativecall,"))"); Printf(nativecall,");\n"); @@ -1314,7 +1314,7 @@ void JAVA::cpp_inherit(char **baseclass, int) { if(cnt > 1) Printf(stderr, "Warning: %s inherits from multiple base classes. Multiple inheritance is not supported.\n", shadow_classname); - + shadow_baseclass = Swig_copy_string(*baseclass); } diff --git a/Source/Modules1.1/mzscheme.cxx b/Source/Modules1.1/mzscheme.cxx index 358c1f783..291056ce2 100644 --- a/Source/Modules1.1/mzscheme.cxx +++ b/Source/Modules1.1/mzscheme.cxx @@ -59,7 +59,7 @@ MZSCHEME::parse_args (int argc, char *argv[]) if (argv[i]) { if (strcmp (argv[i], "-help") == 0) { fputs (mzscheme_usage, stderr); - SWIG_exit (0); + SWIG_exit (EXIT_SUCCESS); } else if (strcmp (argv[i], "-prefix") == 0) { if (argv[i + 1]) { @@ -185,7 +185,7 @@ MZSCHEME::headers (void) 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 (EXIT_FAILURE); } } } @@ -734,7 +734,7 @@ MZSCHEME::usage_returns (char *iname, DataType *d, ParmList *l, DOHString *usage int have_param = 0, j; param = NewString(""); - + Clear(usage); Printf(usage,"returns "); diff --git a/Source/Modules1.1/perl5.cxx b/Source/Modules1.1/perl5.cxx index 06f2bfd2d..c1e0bcf61 100644 --- a/Source/Modules1.1/perl5.cxx +++ b/Source/Modules1.1/perl5.cxx @@ -1,15 +1,15 @@ -/* ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- * perl5.cxx * * Generate Perl5 wrappers - * + * * Author(s) : David Beazley (beazley@cs.uchicago.edu) * Loic Dachary (loic@ceic.com) * David Fletcher * Gary Holt * * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. + * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ /* DB: I had to take some features related to package naming out of this to @@ -49,7 +49,7 @@ static int is_static = 0; static int blessed = 0; /* Enable object oriented features */ static Hash *classes = 0; /* A hash table for storing the classes we've seen so far */ -static Hash *symbols = 0; +static Hash *symbols = 0; static int have_constructor = 0; static int have_destructor= 0; static int have_data_members = 0; @@ -151,7 +151,7 @@ PERL5::parse() { classes = NewHash(); symbols = NewHash(); - + vinit = NewString(""); pm = NewString(""); func_stubs = NewString(""); @@ -168,12 +168,12 @@ PERL5::parse() { 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(1); + 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(1); + SWIG_exit (EXIT_FAILURE); } yyparse(); } @@ -182,7 +182,7 @@ PERL5::parse() { /* ----------------------------------------------------------------------------- * PERL5::set_module() * ----------------------------------------------------------------------------- */ -void +void PERL5::set_module(char *mod_name) { if (import_file) { if (!(Cmp(import_file,input_file+strlen(input_file)-Len(import_file)))) { @@ -195,7 +195,7 @@ PERL5::set_module(char *mod_name) { } if (module) return; - + module = NewString(mod_name); /* Create a C module name and put it in 'cmodule' */ @@ -215,7 +215,7 @@ PERL5::initialize() if (!module){ Printf(stderr,"*** Error. No module name specified.\n"); - SWIG_exit(1); + SWIG_exit (EXIT_FAILURE); } if (!package) { @@ -231,7 +231,7 @@ PERL5::initialize() realpackage = NewString(package); } - /* Create a .pm file + /* Create a .pm file * Need to strip off any prefixes that might be found in * the module name */ @@ -247,7 +247,7 @@ PERL5::initialize() 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(0); + SWIG_exit (EXIT_FAILURE); } } if (!blessed) { @@ -305,7 +305,7 @@ PERL5::initialize() Printf(f_pm,"@ISA = qw(Exporter DynaLoader);\n"); } else { Printf(f_pm,"@ISA = qw(Exporter);\n"); - } + } /* Start creating magic code */ @@ -351,7 +351,7 @@ PERL5::close(void) { 0); Printf(f_header,"%s\n", magic); - + String *type_table = NewString(""); SwigType_emit_type_table(f_runtime,type_table); @@ -379,7 +379,7 @@ PERL5::close(void) { Printv(vinit,tab4, "XSRETURN(1);\n", "}\n", 0); Printf(f_wrappers,"%s", vinit); - Printf(f_pm,"package %s;\n", package); + Printf(f_pm,"package %s;\n", package); if (!is_static) { Printf(f_pm,"bootstrap %s;\n", realpackage); @@ -410,7 +410,7 @@ PERL5::close(void) { "}\n\n", 0); - /* Output a CLEAR method. This is just a place-holder, but by providing it we + /* Output a CLEAR method. This is just a place-holder, but by providing it we * can make declarations such as * %$u = ( x => 2, y=>3, z =>4 ); * @@ -468,9 +468,9 @@ get_pointer(char *iname, char *srcname, char *src, char *dest, /* If we're passing a void pointer, we give the pointer conversion a NULL pointer, otherwise pass in the expected type. */ - + if (SwigType_type(t) == T_VOID) Printf(f, " 0 ) < 0) {\n"); - else + else Printv(f, "SWIGTYPE", SwigType_manglestr(t), ") < 0) {\n",0); Printv(f, @@ -492,7 +492,7 @@ PERL5::create_command(char *cname, char *iname) { } } -/* ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- * PERL5::create_function() * ----------------------------------------------------------------------------- */ void @@ -505,7 +505,7 @@ PERL5::create_function(char *name, char *iname, SwigType *d, ParmList *l) char *tm; String *cleanup, *outarg; int numopt = 0; - int need_save, num_saved = 0; + int need_save, num_saved = 0; f = NewWrapper(); cleanup = NewString(""); @@ -560,18 +560,18 @@ PERL5::create_function(char *name, char *iname, SwigType *d, ParmList *l) Printf(f->code," %s = (%s)SvIV(ST(%d));\n", target, SwigType_lstr(pt,0),j); break; case T_CHAR : - + Printf(f->code," %s = (char) *SvPV(ST(%d),PL_na);\n", target, j); break; - + case T_DOUBLE : case T_FLOAT : Printf(f->code," %s = (%s)SvNV(ST(%d));\n", target, SwigType_lstr(pt,0), j); break; - + case T_VOID : break; - + case T_USER: SwigType_add_pointer(pt); sprintf(temp,"argument %d", i+1); @@ -595,7 +595,7 @@ PERL5::create_function(char *name, char *iname, SwigType *d, ParmList *l) } } /* The source is going to be an array of saved values. */ - sprintf(temp,"_saved[%d]",num_saved); + sprintf(temp,"_saved[%d]",num_saved); if (j>= (pcount-numopt)) Printf(f->code," } \n"); j++; @@ -624,7 +624,7 @@ PERL5::create_function(char *name, char *iname, SwigType *d, ParmList *l) Delete(tempstr); need_save = 1; } - /* If we need a saved variable, we need to emit to emit some code for that + /* If we need a saved variable, we need to emit to emit some code for that This only applies if the argument actually existed (not ignore) */ if ((need_save) && (!Getignore(p))) { Printv(f->code, tab4, temp, " = ", source, ";\n", 0); @@ -667,7 +667,7 @@ PERL5::create_function(char *name, char *iname, SwigType *d, ParmList *l) tab4, "sv_setpv((SV*)ST(argvi++),ctemp);\n", 0); break; - + case T_USER: SwigType_add_pointer(d); SwigType_remember(d); @@ -675,7 +675,7 @@ PERL5::create_function(char *name, char *iname, SwigType *d, ParmList *l) tab4, "SWIG_MakePtr(ST(argvi++), (void *) result, SWIGTYPE", SwigType_manglestr(d),");\n", 0); SwigType_del_pointer(d); break; - + case T_STRING: Printf(f->code," sv_setpv((SV*)ST(argvi++),(char *) result);\n"); break; @@ -693,7 +693,7 @@ PERL5::create_function(char *name, char *iname, SwigType *d, ParmList *l) } /* If there were any output args, take care of them. */ - + Printv(f->code,outarg,0); /* If there was any cleanup, do that. */ @@ -737,7 +737,7 @@ PERL5::create_function(char *name, char *iname, SwigType *d, ParmList *l) * Create a stub for this function, provided it's not a member function * * Really we only need to create a stub if this function involves - * complex datatypes. If it does, we'll make a small wrapper to + * complex datatypes. If it does, we'll make a small wrapper to * process the arguments. If it doesn't, we'll just make a symbol * table entry. * -------------------------------------------------------------------- */ @@ -745,7 +745,7 @@ PERL5::create_function(char *name, char *iname, SwigType *d, ParmList *l) if ((blessed) && (!member_func)) { int need_stub = 0; String *func = NewString(""); - + /* We'll make a stub since we may need it anyways */ Printv(func, "sub ", iname, " {\n", @@ -786,7 +786,7 @@ PERL5::create_function(char *name, char *iname, SwigType *d, ParmList *l) Printv(func, tab4, "my $result = ", package, "::", iname, "(@args);\n", 0); /* Now check to see what kind of return result was found. - * If this function is returning a result by 'value', SWIG did an + * If this function is returning a result by 'value', SWIG did an * implicit malloc/new. We'll mark the object like it was created * in Perl so we can garbage collect it. */ @@ -838,7 +838,7 @@ PERL5::create_function(char *name, char *iname, SwigType *d, ParmList *l) DelWrapper(f); } -/* ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- * PERL5::link_variable() * ----------------------------------------------------------------------------- */ @@ -889,9 +889,9 @@ void PERL5::link_variable(char *name, char *iname, SwigType *t) case T_CHAR : Printv(setf->code, tab4, name, " = (char) *SvPV(sv,PL_na);\n", 0); break; - + case T_USER: - + SwigType_add_pointer(t); Wrapper_add_local(setf,"_temp", "void *_temp"); get_pointer(iname,(char*)"value",(char*)"sv",(char*)"_temp", t, setf->code, (char*)"return(1)"); @@ -902,7 +902,7 @@ void PERL5::link_variable(char *name, char *iname, SwigType *t) case T_STRING: Wrapper_add_local(setf,"_a","char *_a"); Printf(setf->code," _a = (char *) SvPV(sv,PL_na);\n"); - + if (CPlusPlus) Printv(setf->code, tab4, "if (", name, ") delete [] ", name, ";\n", @@ -951,11 +951,11 @@ void PERL5::link_variable(char *name, char *iname, SwigType *t) Printf(setf->code," return 1;\n}\n"); Replace(setf->code,"$name",iname, DOH_REPLACE_ANY); Wrapper_print(setf,magic); - + } /* Now write a function to evaluate the variable */ - + Printf(getf->def,"SWIGCLASS_STATIC int %s(SV *sv, MAGIC *mg) {\n", val_name); Printv(getf->code, tab4, "MAGIC_PPERL\n", @@ -968,7 +968,7 @@ void PERL5::link_variable(char *name, char *iname, SwigType *t) Printf(getf->code,"%s\n", tm); } else { switch(SwigType_type(t)) { - + case T_INT : case T_BOOL: case T_UINT: case T_SHORT : case T_USHORT: case T_LONG : case T_ULONG: @@ -995,11 +995,11 @@ void PERL5::link_variable(char *name, char *iname, SwigType *t) tab4, "rsv = SvRV(sv);\n", tab4, "sv_setiv(rsv,(IV) &", name, ");\n", 0); - + Wrapper_add_local(getf,"rsv","SV *rsv"); Printv(vinit, tab4, "SWIG_MakePtr(sv, (void *) &", name, ",SWIGTYPE", SwigType_manglestr(t), ");\n",0); SwigType_del_pointer(t); - + break; case T_STRING: @@ -1016,7 +1016,7 @@ void PERL5::link_variable(char *name, char *iname, SwigType *t) Delete(ta); Delete(aop); break; - } + } Delete(ta); Delete(aop); } @@ -1026,7 +1026,7 @@ void PERL5::link_variable(char *name, char *iname, SwigType *t) tab4, "rsv = SvRV(sv);\n", tab4, "sv_setiv(rsv,(IV) ", name, ");\n", 0); - + Wrapper_add_local(getf,"rsv","SV *rsv"); Printv(vinit, tab4, "SWIG_MakePtr(sv,(void *) 1, SWIGTYPE", SwigType_manglestr(t), ");\n",0); break; @@ -1039,19 +1039,19 @@ void PERL5::link_variable(char *name, char *iname, SwigType *t) Replace(getf->code,"$name",iname, DOH_REPLACE_ANY); Wrapper_print(getf,magic); - + /* Now add symbol to the PERL interpreter */ if ((Status & STAT_READONLY) || (!setable)) { Printv(vinit, tab4, "swig_create_magic(sv,\"", package, "::", iname, "\",MAGIC_CAST MAGIC_CLASS swig_magic_readonly, MAGIC_CAST MAGIC_CLASS ", val_name, ");\n",0); } else { Printv(vinit, tab4, "swig_create_magic(sv,\"", package, "::", iname, "\", MAGIC_CAST MAGIC_CLASS ", set_name, ", MAGIC_CAST MAGIC_CLASS ", val_name, ");\n",0); - } - + } + /* If we're blessed, try to figure out what to do with the variable 1. If it's a Perl object of some sort, create a tied-hash around it. 2. Otherwise, just hack Perl's symbol table */ - + if (blessed) { if (is_shadow(t)) { Printv(var_stubs, @@ -1182,7 +1182,7 @@ PERL5::declare_const(char *name, char *, SwigType *type, char *value) Printf(f_header,"%s\n",setrv); have_ref_func = 1; } - Printv(vinit, tab4, "swig_setrv(\"", package, "::", name, "\", (void *) ", value, ", \"", + Printv(vinit, tab4, "swig_setrv(\"", package, "::", name, "\", (void *) ", value, ", \"", SwigType_manglestr(type), "\");\n", 0); break; @@ -1210,7 +1210,7 @@ PERL5::declare_const(char *name, char *, SwigType *type, char *value) } /* ----------------------------------------------------------------------------- - * PERL5::usage_func() + * PERL5::usage_func() * ----------------------------------------------------------------------------- */ char * PERL5::usage_func(char *iname, SwigType *, ParmList *l) { @@ -1221,7 +1221,7 @@ PERL5::usage_func(char *iname, SwigType *, ParmList *l) { if (!temp) temp = NewString(""); Clear(temp); Printf(temp,"%s(",iname); - + /* Now go through and print parameters */ p = l; i = 0; @@ -1244,7 +1244,7 @@ PERL5::usage_func(char *iname, SwigType *, ParmList *l) { Putc(',',temp); } else { p = Getnext(p); - if (p) + if (p) if ((i>0) && (!Getignore(p))) Putc(',',temp); } @@ -1267,22 +1267,22 @@ PERL5::add_native(char *name, char *funcname, SwigType *, ParmList *) { } /**************************************************************************** - *** OBJECT-ORIENTED FEATURES + *** OBJECT-ORIENTED FEATURES **************************************************************************** - *** These extensions provide a more object-oriented interface to C++ - *** classes and structures. The code here is based on extensions + *** These extensions provide a more object-oriented interface to C++ + *** classes and structures. The code here is based on extensions *** provided by David Fletcher and Gary Holt. - *** - *** I have generalized these extensions to make them more general purpose - *** and to resolve object-ownership problems. *** - *** The approach here is very similar to the Python module : - *** 1. All of the original methods are placed into a single - *** package like before except that a 'c' is appended to the - *** package name. + *** I have generalized these extensions to make them more general purpose + *** and to resolve object-ownership problems. *** - *** 2. All methods and function calls are wrapped with a new - *** perl function. While possibly inefficient this allows + *** The approach here is very similar to the Python module : + *** 1. All of the original methods are placed into a single + *** package like before except that a 'c' is appended to the + *** package name. + *** + *** 2. All methods and function calls are wrapped with a new + *** perl function. While possibly inefficient this allows *** us to catch complex function arguments (which are hard to *** track otherwise). *** @@ -1299,7 +1299,7 @@ PERL5::add_native(char *name, char *funcname, SwigType *, ParmList *) { *** *** 6. Object ownership is maintained by having a hash table *** within in each package called "this". It is unlikely - *** that C++ program will use this so it's a somewhat + *** that C++ program will use this so it's a somewhat *** safe variable name. *** ****************************************************************************/ @@ -1321,7 +1321,7 @@ PERL5::cpp_open_class(char *classname, char *rname, char *ctype, int strip) { Delete(real_classname); real_classname = 0; Delete(base_class); base_class = 0; Delete(fullclassname); fullclassname = 0; - + /* If the class is being renamed to something else, use the renaming */ if (rname) { class_name = NewString(rname); @@ -1366,7 +1366,7 @@ PERL5::cpp_close_class() { if (Cmp(class_name,realpackage)) Printv(pm, "@ISA = qw( ",realpackage, 0); - else + else Printv(pm, "@ISA = qw( ", 0); if (base_class) { @@ -1378,7 +1378,7 @@ PERL5::cpp_close_class() { Printf(pm, "%%OWNER = ();\n"); if (have_data_members) { - Printv(pm, + Printv(pm, "%BLESSEDMEMBERS = (\n", blessedmembers, ");\n\n", 0); } @@ -1425,7 +1425,7 @@ PERL5::cpp_close_class() { tab4, "return $val;\n", "}\n\n", 0); - + /* Output a STORE method. This is also common to all classes (might move to base class) */ Printv(pm, @@ -1534,16 +1534,16 @@ PERL5::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) { } p = Getnext(p); } - + /* Okay. We've made argument adjustments, now call into the package */ Printv(func, tab4, "my $result = ", package, "::", Swig_name_member(class_name,realname), "(@args);\n", 0); - + /* Now check to see what kind of return result was found. - * If this function is returning a result by 'value', SWIG did an + * If this function is returning a result by 'value', SWIG did an * implicit malloc/new. We'll mark the object like it was created * in Perl so we can garbage collect it. */ @@ -1556,7 +1556,7 @@ PERL5::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) { need_wrapper = 1; } else if (is_shadow(t)) { - + Printv(func,tab4, "return undef if (!defined($result));\n", 0); /* If we're returning an object by value, put it's reference @@ -1579,7 +1579,7 @@ PERL5::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) { need_wrapper = 1; } else { - /* Hmmm. This doesn't appear to be anything I know about so just + /* Hmmm. This doesn't appear to be anything I know about so just return it unmodified */ Printv(func, tab4,"return $result;\n", "}\n", 0); @@ -1621,7 +1621,7 @@ void PERL5::cpp_variable(char *name, char *iname, SwigType *t) { /* Emit a pair of get/set functions for the variable */ member_func = 1; - this->Language::cpp_variable(name, iname, t); + this->Language::cpp_variable(name, iname, t); member_func = 0; if (iname) realname = iname; @@ -1631,10 +1631,10 @@ void PERL5::cpp_variable(char *name, char *iname, SwigType *t) { Printf(cname,"%s::%s", class_name, realname); if (Getattr(symbols,cname)) { Delete(cname); - return; + return; } Setattr(symbols,cname,cname); - + /* Store name of key for future reference */ Printf(member_keys,"'%s', ", realname); @@ -1642,12 +1642,12 @@ void PERL5::cpp_variable(char *name, char *iname, SwigType *t) { if (is_shadow(t)) { - /* This is a Perl object that we have already seen. Add an + /* This is a Perl object that we have already seen. Add an entry to the members list*/ Printv(blessedmembers, tab4, realname, " => '", is_shadow(t), "',\n", 0); - + } } have_data_members++; @@ -1659,7 +1659,7 @@ void PERL5::cpp_variable(char *name, char *iname, SwigType *t) { * * Emits a blessed constructor for our class. In addition to our construct * we manage a Perl hash table containing all of the pointers created by - * the constructor. This prevents us from accidentally trying to free + * the constructor. This prevents us from accidentally trying to free * something that wasn't necessarily allocated by malloc or new * ----------------------------------------------------------------------------- */ void @@ -1678,7 +1678,7 @@ PERL5::cpp_constructor(char *name, char *iname, ParmList *l) { if (blessed) { - if (iname) + if (iname) realname = iname; else { if (class_renamed) realname = class_name; @@ -1692,17 +1692,17 @@ PERL5::cpp_constructor(char *name, char *iname, ParmList *l) { } Setattr(symbols,cname, cname); if ((Cmp(realname,class_name) == 0) || ((!iname) && (ObjCClass)) ){ - + /* Emit a blessed constructor */ Printf(pcode, "sub new {\n"); } else { - + /* Constructor doesn't match classname so we'll just use the normal name */ Printv(pcode, "sub ", Swig_name_construct(realname), " () {\n", 0); - + } Printv(pcode, tab4, "my $self = shift;\n", @@ -1712,12 +1712,12 @@ PERL5::cpp_constructor(char *name, char *iname, ParmList *l) { * Now we have to go through and patch up the argument list. If any * arguments to our function correspond to other Perl objects, we * need to extract them from a tied-hash table object. */ - + p = l; i = 0; while(p) { SwigType *pt = Gettype(p); - + if (is_shadow(pt)) { /* Yep. This smells alot like an object, patch up the arguments */ Printf(pcode, " $args[%d] = tied(%%{$args[%d]});\n", i, i); @@ -1725,7 +1725,7 @@ PERL5::cpp_constructor(char *name, char *iname, ParmList *l) { p = Getnext(p); i++; } - + Printv(pcode, tab4, "$self = ", package, "::", Swig_name_construct(realname), "(@args);\n", tab4, "return undef if (!defined($self));\n", @@ -1747,7 +1747,7 @@ PERL5::cpp_constructor(char *name, char *iname, ParmList *l) { /* ----------------------------------------------------------------------------- * PERL5::cpp_destructor() * ----------------------------------------------------------------------------- */ -void +void PERL5::cpp_destructor(char *name, char *newname) { String *realname; member_func = 1; @@ -1764,7 +1764,7 @@ PERL5::cpp_destructor(char *name, char *newname) { Printv(pcode, "sub DESTROY {\n", - tab4, "return unless $_[0]->isa('HASH');\n", + tab4, "return unless $_[0]->isa('HASH');\n", tab4, "my $self = tied(%{$_[0]});\n", tab4, "delete $ITERATORS{$self};\n", tab4, "if (exists $OWNER{$self}) {\n", @@ -1772,9 +1772,9 @@ PERL5::cpp_destructor(char *name, char *newname) { tab8, "delete $OWNER{$self};\n", tab4, "}\n}\n\n", 0); - + have_destructor = 1; - + } member_func = 0; } @@ -1782,7 +1782,7 @@ PERL5::cpp_destructor(char *name, char *newname) { /* ----------------------------------------------------------------------------- * PERL5::cpp_static_func() * ----------------------------------------------------------------------------- */ -void +void PERL5::cpp_static_func(char *name, char *iname, SwigType *t, ParmList *l) { this->Language::cpp_static_func(name,iname,t,l); char *realname; @@ -1793,11 +1793,11 @@ PERL5::cpp_static_func(char *name, char *iname, SwigType *t, ParmList *l) { Printv(pcode, "*", realname, " = *", realpackage, "::", Swig_name_member(class_name,realname), ";\n", 0); } } - + /* ----------------------------------------------------------------------------- * PERL5::cpp_inherit() * ------------------------------------------------------------------------------ */ -void +void PERL5::cpp_inherit(char **baseclass, int) { char *bc; int i = 0, have_first = 0; @@ -1806,7 +1806,7 @@ PERL5::cpp_inherit(char **baseclass, int) { return; } - /* Inherit variables and constants from base classes, but not + /* Inherit variables and constants from base classes, but not functions (since Perl can handle that okay). */ this->Language::cpp_inherit(baseclass, INHERIT_CONST | INHERIT_VAR); @@ -1830,7 +1830,7 @@ PERL5::cpp_inherit(char **baseclass, int) { } } -/* ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- * PERL5::cpp_declare_const() * ----------------------------------------------------------------------------- */ void @@ -1838,7 +1838,7 @@ PERL5::cpp_declare_const(char *name, char *iname, SwigType *type, char *value) { String *realname; int oldblessed = blessed; char cname[256]; - + /* Create a normal constant */ blessed = 0; this->Language::cpp_declare_const(name, iname, type, value); @@ -1849,10 +1849,10 @@ PERL5::cpp_declare_const(char *name, char *iname, SwigType *type, char *value) { realname = name; else realname = iname; - + sprintf(cname,"%s::%s",Char(class_name),Char(realname)); if (Getattr(symbols, cname)) { - return; + return; } Setattr(symbols, cname,cname); @@ -1864,7 +1864,7 @@ PERL5::cpp_declare_const(char *name, char *iname, SwigType *type, char *value) { /* ----------------------------------------------------------------------------- * PERL5::cpp_class_decl() * ----------------------------------------------------------------------------- */ -void +void PERL5::cpp_class_decl(char *name, char *rename, char *type) { String *stype; if (blessed) { @@ -1884,12 +1884,12 @@ PERL5::cpp_class_decl(char *name, char *rename, char *type) { /* ----------------------------------------------------------------------------- * PERL5::add_typedef() * ----------------------------------------------------------------------------- */ -void +void PERL5::add_typedef(SwigType *t, char *name) { if (!blessed) return; if (is_shadow(t)) { - cpp_class_decl(name,Char(is_shadow(t)),""); + cpp_class_decl(name,Char(is_shadow(t)),""); } } diff --git a/Source/Modules1.1/python.cxx b/Source/Modules1.1/python.cxx index b91e74b89..f46032dba 100644 --- a/Source/Modules1.1/python.cxx +++ b/Source/Modules1.1/python.cxx @@ -1,12 +1,12 @@ -/* ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- * python.cxx * * Python 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. + * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ static char cvsroot[] = "$Header$"; @@ -16,14 +16,14 @@ static char cvsroot[] = "$Header$"; static String *const_code = 0; static String *shadow_methods = 0; -static String *module = 0; +static String *module = 0; static String *interface = 0; static String *global_name = 0; static int shadow = 0; static int have_defarg = 0; static int have_output; -static int use_kw = 0; -static int noopt = 1; +static int use_kw = 0; +static int noopt = 1; static FILE *f_shadow; static Hash *hash; static Hash *symbols; @@ -62,7 +62,7 @@ PYTHON::parse_args(int argc, char *argv[]) { int i; strcpy(LibDir,"python"); - for (i = 1; i < argc; i++) { + for (i = 1; i < argc; i++) { if (argv[i]) { if(strcmp(argv[i],"-module") == 0) { if (argv[i+1]) { @@ -72,7 +72,7 @@ PYTHON::parse_args(int argc, char *argv[]) { i++; } else { Swig_arg_error(); - } + } /* Added edz@bsn.com */ } else if(strcmp(argv[i],"-interface") == 0) { @@ -121,7 +121,7 @@ PYTHON::parse_args(int argc, char *argv[]) { * ----------------------------------------------------------------------------- */ void PYTHON::parse() { - + hash = NewHash(); symbols = NewHash(); const_code = NewString(""); @@ -135,16 +135,16 @@ PYTHON::parse() { Swig_banner(f_runtime); Printf(f_runtime,"#define SWIGPYTHON\n"); - if (NoInclude) + if (NoInclude) Printf(f_runtime,"#define SWIG_NOINCLUDE\n"); 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(1); + 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(1); + SWIG_exit (EXIT_FAILURE); } yyparse(); } @@ -180,7 +180,7 @@ PYTHON::import(char *filename) { import_file = NewString(filename); } -/* ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- * PYTHON::add_method() * ----------------------------------------------------------------------------- */ void @@ -200,7 +200,7 @@ PYTHON::initialize(void) { if (!module) { Printf(stderr,"*** Error. No module name specified.\n"); - SWIG_exit(1); + SWIG_exit (EXIT_FAILURE); } /* If shadow classing is enabled, we're going to change the module name to "modulec" */ if (shadow) { @@ -211,12 +211,12 @@ PYTHON::initialize(void) { Append(module,"c"); if ((f_shadow = fopen(filen,"w")) == 0) { Printf(stderr,"Unable to open %s\n", filen); - SWIG_exit(0); + SWIG_exit (EXIT_FAILURE); } Printf(f_shadow,"# This file was created automatically by SWIG.\n"); Printf(f_shadow,"import %s\n", interface ? interface : module); - // Include some information in the code + // Include some information in the code Printf(f_header,"\n/*-----------------------------------------------\n @(target):= %s.so\n\ ------------------------------------------------*/\n", interface ? interface : module); @@ -225,7 +225,7 @@ PYTHON::initialize(void) { } Printf(f_header,"#define SWIG_init init%s\n\n", module); - Printf(f_header,"#define SWIG_name \"%s\"\n", module); + Printf(f_header,"#define SWIG_name \"%s\"\n", module); /* Output the start of the init function. */ Printf(f_init,"static PyObject *SWIG_globals;\n"); @@ -290,7 +290,7 @@ PYTHON::close(void) { } } -/* ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- * PYTHON::get_pointer() * ----------------------------------------------------------------------------- */ void @@ -298,7 +298,7 @@ PYTHON::get_pointer(char *src, char *dest, SwigType *t, String *f, char *ret) { SwigType *lt; SwigType_remember(t); Printv(f,tab4, "if ((SWIG_ConvertPtr(", src, ",(void **) &", dest, ",", 0); - + lt = Swig_clocal_type(t); if (Cmp(lt,"p.void") == 0) { Printv(f, "0,1)) == -1) return ", ret, ";\n", 0); @@ -368,8 +368,8 @@ PYTHON::create_function(char *name, char *iname, SwigType *d, ParmList *l) { Wrapper_add_local(f,"resultobj", "PyObject *resultobj"); /* Get the function usage string for later use */ - - usage = usage_func(iname,d,l); + + usage = usage_func(iname,d,l); /* Write code to extract function parameters. */ pcount = emit_args(d, l, f); @@ -379,7 +379,7 @@ PYTHON::create_function(char *name, char *iname, SwigType *d, ParmList *l) { Printf(parse_args," if(!PyArg_ParseTupleAndKeywords(args,kwargs,\""); Printf(arglist,",kwnames"); } - + i = 0; j = 0; numopt = check_numopt(l); @@ -394,7 +394,7 @@ PYTHON::create_function(char *name, char *iname, SwigType *d, ParmList *l) { sprintf(source,"obj%d",i); sprintf(target,Char(Getlname(p))); sprintf(argnum,"%d",j+1); - + if (!Getignore(p)) { Putc(',',arglist); if (j == pcount-numopt) Putc('|',parse_args); /* Optional argument separator */ @@ -438,7 +438,7 @@ PYTHON::create_function(char *name, char *iname, SwigType *d, ParmList *l) { case T_DOUBLE: Putc('d',parse_args); break; - + case T_BOOL: { char tempb[128]; @@ -463,11 +463,11 @@ PYTHON::create_function(char *name, char *iname, SwigType *d, ParmList *l) { break; case T_USER: - + Putc('O',parse_args); sprintf(source,"argo%d", i); sprintf(target,Char(Getlname(p))); - + Wrapper_add_localv(f,source,"PyObject *",source,"=0",0); Printf(arglist,"&%s",source); SwigType_add_pointer(pt); @@ -483,14 +483,14 @@ PYTHON::create_function(char *name, char *iname, SwigType *d, ParmList *l) { break; case T_POINTER: case T_ARRAY: case T_REFERENCE: - + /* Have some sort of pointer variable. Create a temporary local variable for the string and read the pointer value into it. */ - + Putc('O',parse_args); sprintf(source,"argo%d", i); sprintf(target,"%s",Char(Getlname(p))); - + Wrapper_add_localv(f,source,"PyObject *",source,"=0",0); Printf(arglist,"&%s",source); get_pointer(source, target, pt, get_pointers, (char*)"NULL"); @@ -501,8 +501,8 @@ PYTHON::create_function(char *name, char *iname, SwigType *d, ParmList *l) { Printf(stderr,"%s : Line %d. Unable to use type %s as a function argument.\n",input_file, line_number, SwigType_str(pt,0)); break; } - - if (!noarg) + + if (!noarg) Printf(arglist,"&%s",Getlname(p)); } j++; @@ -524,7 +524,7 @@ PYTHON::create_function(char *name, char *iname, SwigType *d, ParmList *l) { Replace(outarg,"$argnum",argnum,DOH_REPLACE_ANY); Replace(outarg,"$arg",source, DOH_REPLACE_ANY); have_output++; - } + } p = Getnext(p); i++; } @@ -538,7 +538,7 @@ PYTHON::create_function(char *name, char *iname, SwigType *d, ParmList *l) { Printv(parse_args, arglist, ")) return NULL;\n", 0); - + /* Now slap the whole first part of the wrapper function together */ Printv(f->code, parse_args, get_pointers, check, 0); @@ -611,7 +611,7 @@ PYTHON::create_function(char *name, char *iname, SwigType *d, ParmList *l) { if ((tm = Swig_typemap_lookup((char*)"ret",d,iname,(char*)"result",(char*)"",0))) { Printf(f->code,"%s\n",tm); } - + Printf(f->code," return resultobj;\n}\n"); /* Substitute the cleanup code */ @@ -631,7 +631,7 @@ PYTHON::create_function(char *name, char *iname, SwigType *d, ParmList *l) { if ((shadow) && (!(shadow & PYSHADOW_MEMBER))) { int need_wrapper = 0; int munge_return = 0; - + /* Check return code for modification */ if (is_shadow(d)) { need_wrapper = 1; @@ -650,7 +650,7 @@ PYTHON::create_function(char *name, char *iname, SwigType *d, ParmList *l) { if (munge_return) { /* If the output of this object has been remapped in any way, we're going to return it as a bare object */ - + if (!Swig_typemap_search((char*)"out",d,iname)) { /* If there are output arguments, we are going to return the value @@ -701,7 +701,7 @@ PYTHON::link_variable(char *name, char *iname, SwigType *t) { Printv(vars, global_name, " = ", module, ".", global_name, "\n", 0); } } - + wname = Char(Swig_name_wrapper(name)); /* Create a function for setting the value of the variable */ @@ -728,7 +728,7 @@ PYTHON::link_variable(char *name, char *iname, SwigType *t) { tab4, name, " = tval;\n", 0); break; - + case T_FLOAT: case T_DOUBLE: Wrapper_add_localv(setf,"tval",SwigType_lstr(t,0), "tval",0); Printv(setf->code, @@ -741,7 +741,7 @@ PYTHON::link_variable(char *name, char *iname, SwigType *t) { tab4, name, " = tval;\n", 0); break; - + case T_CHAR: Wrapper_add_local(setf,"tval","char * tval"); Printv(setf->code, @@ -773,7 +773,7 @@ PYTHON::link_variable(char *name, char *iname, SwigType *t) { tab8, "return 1; \n", tab4, "}\n", 0); - + if (CPlusPlus) { Printv(setf->code, tab4, "if (", name, ") delete [] ", name, ";\n", @@ -800,8 +800,8 @@ PYTHON::link_variable(char *name, char *iname, SwigType *t) { if (dim && Len(dim)) { Printf(setf->code, "strncpy(%s,PyString_AsString(val), %s);\n", name,dim); setable = 1; - } - } + } + } if (!setable) { Printv(setf->code, tab4, "PyErr_SetString(PyExc_TypeError,\"Variable ", iname, @@ -833,10 +833,10 @@ PYTHON::link_variable(char *name, char *iname, SwigType *t) { tab4, "return 1;\n", 0); } - + Printf(setf->code,"}\n"); Wrapper_print(setf,f_wrappers); - + /* Create a function for getting the value of a variable */ Printf(getf->def,"static PyObject *%s_get() {", wname); Wrapper_add_local(getf,"pyobj", "PyObject *pyobj"); @@ -848,7 +848,7 @@ PYTHON::link_variable(char *name, char *iname, SwigType *t) { Replace(getf->code,"$name",iname, DOH_REPLACE_ANY); } else { switch(SwigType_type(t)) { - case T_INT: case T_UINT: + case T_INT: case T_UINT: case T_SHORT: case T_USHORT: case T_LONG: case T_ULONG: case T_SCHAR: case T_UCHAR: case T_BOOL: @@ -898,7 +898,7 @@ PYTHON::link_variable(char *name, char *iname, SwigType *t) { Printf(getf->code," return pyobj;\n}\n"); Wrapper_print(getf,f_wrappers); - + /* Now add this to the variable linking mechanism */ Printf(f_init,"\t SWIG_addvarlink(SWIG_globals,\"%s\",%s_get, %s_set);\n", iname, wname, wname); @@ -955,7 +955,7 @@ PYTHON::declare_const(char *name, char *, SwigType *type, char *value) { } if ((shadow) && (!(shadow & PYSHADOW_MEMBER))) { Printv(vars,name, " = ", module, ".", name, "\n", 0); - } + } } /* ----------------------------------------------------------------------------- @@ -1007,7 +1007,7 @@ PYTHON::usage_func(char *iname, SwigType *, ParmList *l) { /* ----------------------------------------------------------------------------- * PYTHON::add_native() * ----------------------------------------------------------------------------- */ -void +void PYTHON::add_native(char *name, char *funcname, SwigType *, ParmList *) { add_method(name, funcname,0); if (shadow) { @@ -1018,7 +1018,7 @@ PYTHON::add_native(char *name, char *funcname, SwigType *, ParmList *) { /* ----------------------------------------------------------------------------- * PYTHON::cpp_class_decl() - Register a class definition * ----------------------------------------------------------------------------- */ -void +void PYTHON::cpp_class_decl(char *name, char *rename, char *type) { String *stype; if (shadow) { @@ -1039,7 +1039,7 @@ PYTHON::cpp_class_decl(char *name, char *rename, char *type) { /* ----------------------------------------------------------------------------- * PYTHON::pragma() * ----------------------------------------------------------------------------- */ -void +void PYTHON::pragma(char *lang, char *cmd, char *value) { if (strcmp(lang,(char*)"python") == 0) { @@ -1080,7 +1080,7 @@ struct PyPragma { m_text = NewString(text); next = 0; } - ~PyPragma() { + ~PyPragma() { Delete(m_method); Delete(m_text); if (next) delete next; @@ -1092,7 +1092,7 @@ static PyPragma *pragmas = 0; /* ----------------------------------------------------------------------------- * PYTHON::cpp_pragma() - Handle C++ pragmas * ----------------------------------------------------------------------------- */ -void +void PYTHON::cpp_pragma(Pragma *plist) { PyPragma *pyp1 = 0, *pyp2 = 0; if (pragmas) { @@ -1139,13 +1139,13 @@ PYTHON::cpp_pragma(Pragma *plist) { } } -/* ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- * PYTHON::emitAddPragmas() * * Search the current class pragma for any text belonging to name. * Append the text properly spaced to the output string. * ----------------------------------------------------------------------------- */ -void +void PYTHON::emitAddPragmas(String *output, char* name, char* spacing) { PyPragma *p = pragmas; while (p) { @@ -1180,10 +1180,10 @@ static int class_renamed = 0; /* ----------------------------------------------------------------------------- * PYTHON::cpp_open_class() * ----------------------------------------------------------------------------- */ -void +void PYTHON::cpp_open_class(char *classname, char *rname, char *ctype, int strip) { this->Language::cpp_open_class(classname, rname, ctype, strip); - + if (shadow) { /* Create new strings for building up a wrapper function */ setattr = NewString(""); @@ -1222,7 +1222,7 @@ PYTHON::cpp_open_class(char *classname, char *rname, char *ctype, int strip) { tab8, "method = ", class_name, ".__setmethods__.get(name,None)\n", tab8, "if method: return method(self,value)\n", 0); - + Printv(getattr, tab4, "def __getattr__(self,name):\n", 0); Printv(csetattr, tab4, "__setmethods__ = {\n", 0); Printv(cgetattr, tab4, "__getmethods__ = {\n", 0); @@ -1232,7 +1232,7 @@ PYTHON::cpp_open_class(char *classname, char *rname, char *ctype, int strip) { /* ----------------------------------------------------------------------------- * PYTHON::cpp_member_func() * ----------------------------------------------------------------------------- */ -void +void PYTHON::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) { char *realname; int oldshadow; @@ -1245,13 +1245,13 @@ PYTHON::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) { shadow = oldshadow; if (shadow) { realname = iname ? iname : name; - + /* Check to see if we've already seen this */ sprintf(cname,"python:%s::%s",class_name,realname); if (Getattr(symbols,cname)) return; Setattr(symbols,cname,cname); - - if (strcmp(realname,"__repr__") == 0) + + if (strcmp(realname,"__repr__") == 0) have_repr = 1; if (!is_shadow(t) && !noopt) { @@ -1263,12 +1263,12 @@ PYTHON::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) { Printv(pyclass,tab4, "def ", realname, "(*args, **kwargs):\n", 0); else Printv(pyclass, tab4, "def ", realname, "(*args):\n", 0); - + if (use_kw) Printv(pyclass, tab8, "val = apply(", module, ".", Swig_name_member(class_name,realname), ",args, kwargs)\n", 0); else Printv(pyclass, tab8, "val = apply(", module, ".", Swig_name_member(class_name,realname), ",args)\n",0); - + /* Check to see if the return type is an object */ if (is_shadow(t)) { if (!Swig_typemap_search((char*)"out",t,Swig_name_member(class_name,realname))) { @@ -1292,7 +1292,7 @@ PYTHON::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) { /* ----------------------------------------------------------------------------- * PYTHON::cpp_constructor() * ----------------------------------------------------------------------------- */ -void +void PYTHON::cpp_constructor(char *name, char *iname, ParmList *l) { char *realname; int oldshadow = shadow; @@ -1304,13 +1304,13 @@ PYTHON::cpp_constructor(char *name, char *iname, ParmList *l) { if (shadow) { realname = iname ? iname : class_name; - + /* Check to see if we've already seen this */ sprintf(cname,":python:constructor:%s::%s",class_name,realname); if (Getattr(symbols,cname)) return; Setattr(symbols,cname,cname); - if (!have_constructor) { + if (!have_constructor) { if (use_kw) Printv(construct, tab4, "def __init__(self,*args,**kwargs):\n", 0); else @@ -1346,7 +1346,7 @@ PYTHON::cpp_constructor(char *name, char *iname, ParmList *l) { /* ----------------------------------------------------------------------------- * PYTHON::cpp_destructor() * ----------------------------------------------------------------------------- */ -void +void PYTHON::cpp_destructor(char *name, char *newname) { char *realname; int oldshadow = shadow; @@ -1357,12 +1357,12 @@ PYTHON::cpp_destructor(char *name, char *newname) { if (shadow) { if (newname) realname = newname; else realname = class_renamed ? class_name : name; - + Printv(pyclass, tab4, "def __del__(self,", module, "=", module, "):\n", 0); emitAddPragmas(pyclass,(char*)"__del__",(char*)tab8); Printv(pyclass, tab8, "if self.thisown == 1 :\n", tab8, tab4, module, ".", Swig_name_destroy(realname), "(self)\n", 0); - + have_destructor = 1; } } @@ -1370,11 +1370,11 @@ PYTHON::cpp_destructor(char *name, char *newname) { /* ----------------------------------------------------------------------------- * PYTHON::cpp_close_class() - Close a class and write wrappers * ----------------------------------------------------------------------------- */ -void +void PYTHON::cpp_close_class() { String *ptrclass; String *repr; - + ptrclass = NewString(""); repr = NewString(""); @@ -1479,7 +1479,7 @@ PYTHON::cpp_inherit(char **baseclass,int) { /* ----------------------------------------------------------------------------- * PYTHON::cpp_variable() - Add a member variable * ----------------------------------------------------------------------------- */ -void +void PYTHON::cpp_variable(char *name, char *iname, SwigType *t) { char *realname; int inhash = 0; @@ -1500,10 +1500,10 @@ PYTHON::cpp_variable(char *name, char *iname, SwigType *t) { if (Getattr(symbols,cname)) return; Setattr(symbols,cname,cname); - + /* Figure out if we've seen this datatype before */ if (is_shadow(t)) inhash = 1; - + if (Status & STAT_READONLY) { /* *setattr << tab8 << tab4 << "raise RuntimeError, \'Member is read-only\'\n"; */ } else { @@ -1520,7 +1520,7 @@ PYTHON::cpp_variable(char *name, char *iname, SwigType *t) { /* ----------------------------------------------------------------------------- * PYTHON::cpp_declare_const() * ----------------------------------------------------------------------------- */ -void +void PYTHON::cpp_declare_const(char *name, char *iname, SwigType *type, char *value) { char *realname; int oldshadow = shadow; @@ -1540,11 +1540,11 @@ PYTHON::cpp_declare_const(char *name, char *iname, SwigType *type, char *value) Printv(cinit, tab4, realname, " = ", module, ".", Swig_name_member(class_name,realname), "\n", 0); } } - + /* ----------------------------------------------------------------------------- * PYTHON::add_typedef() - Manage typedef's for shadow classes * ----------------------------------------------------------------------------- */ -void +void PYTHON::add_typedef(SwigType *t, char *name) { if (!shadow) return; if (is_shadow(t)) { diff --git a/Source/Modules1.1/ruby.cxx b/Source/Modules1.1/ruby.cxx index 890765362..9e439210c 100644 --- a/Source/Modules1.1/ruby.cxx +++ b/Source/Modules1.1/ruby.cxx @@ -175,7 +175,7 @@ static void insert_file(char *filename, File *file) { "SWIG : Fatal error. " "Unable to locate %s. (Possible installation problem).\n", filename); - SWIG_exit(1); + SWIG_exit (EXIT_FAILURE); } } @@ -358,7 +358,7 @@ String *RUBY::make_wrapper_name(char *cname) { /* -------------------------------------------------------------------------- * RUBY::add_native() * -------------------------------------------------------------------------- */ -void +void RUBY::add_native(char *name, char *funcname, SwigType *, ParmList *) { Printf(stderr,"%s : Line %d. Adding native function %s not supported (ignored).\n", input_file, line_number, funcname); } @@ -678,7 +678,7 @@ void RUBY::create_function(char *name, char *iname, SwigType *t, ParmList *l) { void RUBY::link_variable(char *name, char *iname, SwigType *t) { char *tm; - + String *getfname, *setfname; Wrapper *getf, *setf; @@ -1217,7 +1217,7 @@ void RUBY::cpp_destructor(char *name, char *newname) { Printv(freebody, Swig_name_destroy(name), "(", Swig_cparm_name(0,0), ")", 0); } else { /* When no addmethods mode, swig emits no destroy function. */ - if (CPlusPlus) + if (CPlusPlus) Printv(freebody, Swig_cppdestructor_call(), 0); else Printv(freebody, Swig_cdestructor_call(), 0); diff --git a/Source/Modules1.1/tcl8.cxx b/Source/Modules1.1/tcl8.cxx index 90e4cde3a..f9fc482bf 100644 --- a/Source/Modules1.1/tcl8.cxx +++ b/Source/Modules1.1/tcl8.cxx @@ -1,12 +1,12 @@ -/* ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- * tcl8.cxx * * Tcl8.0 wrapper 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. + * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ static char cvsroot[] = "$Header$"; @@ -40,10 +40,10 @@ static int have_destructor; static String *class_name = 0; static String *class_type = 0; static String *real_classname = 0; -static Hash *repeatcmd = 0; +static Hash *repeatcmd = 0; -/* ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- * TCL8::parse_args() * ----------------------------------------------------------------------------- */ @@ -95,7 +95,7 @@ TCL8::parse_args(int argc, char *argv[]) { SWIG_config_file("tcl8.swg"); } -/* ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- * TCL8::parse() * ----------------------------------------------------------------------------- */ @@ -110,18 +110,18 @@ TCL8::parse() { repeatcmd = NewHash(); Swig_banner(f_runtime); - + /* Include a Tcl configuration file */ if (NoInclude) { Printf(f_runtime,"#define SWIG_NOINCLUDE\n"); } /* 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(1); + 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(1); + SWIG_exit (EXIT_FAILURE); } */ yyparse(); @@ -165,11 +165,11 @@ TCL8::initialize() { if ((!ns_name) && (nspace)) { Printf(stderr,"Tcl error. Must specify a namespace.\n"); - SWIG_exit(1); + SWIG_exit (EXIT_FAILURE); } if (!init_name) { Printf(stderr,"*** Error. No module name specified.\n"); - SWIG_exit(1); + SWIG_exit (EXIT_FAILURE); } Printf(f_header,"#define SWIG_init %s\n", init_name); if (!module) module = NewString("swig"); @@ -203,7 +203,7 @@ TCL8::initialize() { if (nspace) { Printf(f_init,"Tcl_Eval(interp,\"namespace eval %s { }\");\n", ns_name); } - + Printf(cmd_info, "\nstatic _swig_command_info _swig_commands[] = {\n"); Printf(var_info, "\nstatic _swig_var_info _swig_variables[] = {\n"); Printv(f_init, @@ -252,7 +252,7 @@ TCL8::create_command(char *cname, char *iname) { String *wname = Swig_name_wrapper(cname); Printv(cmd_info, tab4, "{ SWIG_prefix \"", iname, "\", ", wname, ", NULL},\n", 0); - + /* Add interpreter name to repeatcmd hash table. This hash is used in C++ code generation to try and find repeated wrapper functions. */ @@ -263,7 +263,7 @@ TCL8::create_command(char *cname, char *iname) { * TCL8::create_function() * ----------------------------------------------------------------------------- */ -void +void TCL8::create_function(char *name, char *iname, SwigType *d, ParmList *l) { Parm *p; int pcount,i,j; @@ -314,7 +314,7 @@ TCL8::create_function(char *name, char *iname, SwigType *d, ParmList *l) { Replace(incode,"$arg",source, DOH_REPLACE_ANY); } else { switch(SwigType_type(pt)) { - case T_INT: + case T_INT: case T_UINT: Putc('i', argstr); Printf(args,",&%s",target); @@ -353,20 +353,20 @@ TCL8::create_function(char *name, char *iname, SwigType *d, ParmList *l) { Putc('f',argstr); Printf(args,",&%s", target); break; - + case T_DOUBLE: Putc('d',argstr); Printf(args,",&%s", target); break; - + case T_CHAR : Putc('c',argstr); Printf(args,",&%s",target); break; - + case T_VOID : break; - + case T_USER: SwigType_add_pointer(pt); SwigType_remember(pt); @@ -374,7 +374,7 @@ TCL8::create_function(char *name, char *iname, SwigType *d, ParmList *l) { Printv(args, ",&", target, ", SWIGTYPE", SwigType_manglestr(pt), 0); SwigType_del_pointer(pt); break; - + case T_STRING: Putc('s',argstr); Printf(args,",&%s",target); @@ -385,7 +385,7 @@ TCL8::create_function(char *name, char *iname, SwigType *d, ParmList *l) { Putc('p',argstr); Printv(args, ",&", target, ", SWIGTYPE", SwigType_manglestr(pt), 0); break; - + default : Printf(stderr,"%s : Line %d: Unable to use type %s as a function argument.\n", input_file, line_number, SwigType_str(pt,0)); @@ -442,29 +442,29 @@ TCL8::create_function(char *name, char *iname, SwigType *d, ParmList *l) { case T_UCHAR: Printv(f->code, "Tcl_SetObjResult(interp,Tcl_NewIntObj((long) result));\n",0); break; - + /* Is a single character. We return it as a string */ case T_CHAR : Printv(f->code, "Tcl_SetObjResult(interp,Tcl_NewStringObj(&result,1));\n",0); break; - + case T_DOUBLE : case T_FLOAT : Printv(f->code, "Tcl_SetObjResult(interp,Tcl_NewDoubleObj((double) result));\n",0); break; - + case T_USER : - + /* Okay. We're returning malloced memory at this point. Probably dangerous, but safe programming is for wimps. */ SwigType_add_pointer(d); SwigType_remember(d); Printv(f->code, "Tcl_SetObjResult(interp,SWIG_NewPointerObj((void *) result,SWIGTYPE", SwigType_manglestr(d), "));\n", 0); - + SwigType_del_pointer(d); break; - + case T_STRING: Printv(f->code, "Tcl_SetObjResult(interp,Tcl_NewStringObj(result,-1));\n",0); break; @@ -620,7 +620,7 @@ TCL8::link_variable(char *name, char *iname, SwigType *t) { 0); break; - case T_CHAR: + case T_CHAR: Printv(set->code, "*(addr) = *value;\n",0); Wrapper_add_local(get,"temp", "char temp[2]"); Printv(get->code, "temp[0] = *addr; temp[1] = 0;\n", @@ -674,7 +674,7 @@ TCL8::link_variable(char *name, char *iname, SwigType *t) { Printf(set->code, "strncpy(addr,value,%s);\n", dim); setable = 1; readonly = Status & STAT_READONLY; - } + } Printv(get->code, "Tcl_SetVar2(interp,name1,name2,addr, flags);\n",0); } else { Printf(stderr,"%s:%d: Array variable '%s' will be read-only.\n", input_file, line_number, name); @@ -729,7 +729,7 @@ TCL8::link_variable(char *name, char *iname, SwigType *t) { DelWrapper(set); } Printv(var_info, tab4,"{ SWIG_prefix \"", iname, "\", (void *) ", isarray ? "" : "&", name, ",", getname, ",", 0); - + if (readonly) { static int readonlywrap = 0; if (!readonlywrap) { @@ -753,7 +753,7 @@ TCL8::link_variable(char *name, char *iname, SwigType *t) { void TCL8::declare_const(char *name, char *, SwigType *type, char *value) { int OldStatus = Status; - SwigType *t; + SwigType *t; char var_name[256]; char *tm; String *rvalue; @@ -761,7 +761,7 @@ TCL8::declare_const(char *name, char *, SwigType *type, char *value) { /* Make a static variable */ sprintf(var_name,"_wrap_const_%s",name); - + if (SwigType_type(type) == T_STRING) { rvalue = NewStringf("\"%s\"",value); } else if (SwigType_type(type) == T_CHAR) { @@ -788,7 +788,7 @@ TCL8::declare_const(char *name, char *, SwigType *type, char *value) { Printf(f_init,"\t %s_char = new char[32];\n",var_name); else Printf(f_init,"\t %s_char = (char *) malloc(32);\n",var_name); - + Printf(f_init,"\t sprintf(%s_char,\"%%ld\", (long) %s);\n", var_name, var_name); sprintf(var_name,"%s_char",var_name); t = NewString("char"); @@ -807,7 +807,7 @@ TCL8::declare_const(char *name, char *, SwigType *type, char *value) { Printf(f_init,"\t %s_char = new char[32];\n",var_name); else Printf(f_init,"\t %s_char = (char *) malloc(32);\n",var_name); - + Printf(f_init,"\t sprintf(%s_char,\"%%lu\", (unsigned long) %s);\n", var_name, var_name); sprintf(var_name,"%s_char",var_name); t = NewSwigType(T_CHAR); @@ -820,7 +820,7 @@ TCL8::declare_const(char *name, char *, SwigType *type, char *value) { Printf(f_header,"static %s %s = (%s) (%s);\n", SwigType_lstr(type,0), var_name, SwigType_lstr(type,0), value); link_variable(var_name,name,type); break; - + case T_CHAR: SwigType_add_pointer(type); Printf(f_header,"static %s %s = \"%s\";\n", SwigType_lstr(type,0), var_name, value); @@ -840,7 +840,7 @@ TCL8::declare_const(char *name, char *, SwigType *type, char *value) { Printf(f_init,"\t %s_char = new char[%d];\n",var_name,(int) Len(SwigType_manglestr(type))+ 20); else Printf(f_init,"\t %s_char = (char *) malloc(%d);\n",var_name, (int) Len(SwigType_manglestr(type))+ 20); - + t = NewSwigType(T_CHAR); SwigType_add_pointer(t); SwigType_remember(type); @@ -877,7 +877,7 @@ TCL8::usage_string(char *iname, SwigType *, ParmList *l) { } else { Printf(temp,"%s ", iname); } - + /* Now go through and print parameters */ i = 0; pcount = ParmList_len(l); @@ -905,8 +905,8 @@ TCL8::usage_string(char *iname, SwigType *, ParmList *l) { } return Char(temp); } - -/* ----------------------------------------------------------------------------- + +/* ----------------------------------------------------------------------------- * TCL8::add_native() * ----------------------------------------------------------------------------- */ @@ -927,11 +927,11 @@ TCL8::cpp_open_class(char *classname, char *rename, char *ctype, int strip) { 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(1); + SWIG_exit (EXIT_FAILURE); } included_object = 1; } - + Clear(attributes); Printf(attributes, "static _swig_attribute _swig_"); Printv(attributes, classname, "_attributes[] = {\n", 0); @@ -979,7 +979,7 @@ TCL8::cpp_close_class() { Printf(attributes, " {0,0,0}\n};\n"); Printv(code,attributes,0); - Printv(code, "static _swig_class _wrap_class_", class_name, " = { \"", class_name, + Printv(code, "static _swig_class _wrap_class_", class_name, " = { \"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",",0); if (have_constructor) { @@ -1013,7 +1013,7 @@ void TCL8::cpp_member_func(char *name, char *iname, SwigType *t, ParmList *l) { strcpy(temp, Char(Swig_name_member(class_name,realname))); rname = Getattr(repeatcmd,temp); if (!rname) rname = Swig_name_wrapper(temp); - + Printv(methods, tab4, "{\"", realname, "\", ", rname, "}, \n", 0); } } diff --git a/Source/SWIG1.1/main.cxx b/Source/SWIG1.1/main.cxx index 7e0ae9bd5..88e5d2698 100644 --- a/Source/SWIG1.1/main.cxx +++ b/Source/SWIG1.1/main.cxx @@ -237,7 +237,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { Swig_mark_arg(i); } else if (strcmp(argv[i],"-swiglib") == 0) { printf("%s\n", LibDir); - SWIG_exit(0); + SWIG_exit (EXIT_SUCCESS); } else if (strcmp(argv[i],"-o") == 0) { Swig_mark_arg(i); if (argv[i+1]) { @@ -253,7 +253,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { 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(0); + SWIG_exit (EXIT_SUCCESS); } else if (strncmp(argv[i],"-l",2) == 0) { // Add a new directory search path Append(libfiles,argv[i]+2); @@ -287,7 +287,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { // Parse language dependent options lang->parse_args(argc,argv); - if (help) SWIG_exit(0); // Exit if we're in help mode + 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(); @@ -399,7 +399,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { String *ds = Swig_include(input_file); if (!ds) { Printf(stderr,"Unable to find '%s'\n", input_file); - SWIG_exit(1); + SWIG_exit (EXIT_FAILURE); } if (lang_config) { Printf(fs,"\n%%include \"%s\"\n", lang_config); @@ -416,7 +416,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (cpp_only) { Printf(stdout,"%s", cpps); while (freeze); - SWIG_exit(0); + SWIG_exit (EXIT_SUCCESS); } // Initialize the scanner diff --git a/Source/SWIG1.1/parser.yxx b/Source/SWIG1.1/parser.yxx index c1c14d214..bd482ff8a 100644 --- a/Source/SWIG1.1/parser.yxx +++ b/Source/SWIG1.1/parser.yxx @@ -1,17 +1,17 @@ %{ -/* ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- * parser.yxx * * YACC parser for SWIG1.1. This grammar is a broken subset of C/C++. * This file is in the process of being deprecated. - * + * * 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. + * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ #define yylex yylex @@ -19,8 +19,8 @@ static char cvsroot[] = "$Header$"; extern "C" int yylex(); -void yyerror (char *s); - +void yyerror (char *s); + extern int line_number; extern int start_line; extern void skip_brace(void); @@ -70,9 +70,9 @@ static SwigType *Active_type = 0; // Used to support variable lists static int Active_extern = 0; // Whether or not list is external static int Active_static = 0; static SwigType *Active_typedef = 0; // Used for typedef lists -static int InArray = 0; // Used when an array declaration is found +static int InArray = 0; // Used when an array declaration is found static DOHString *ArrayString = 0; // Array type attached to parameter names -static DOHString *ArrayBackup = 0; +static DOHString *ArrayBackup = 0; static char *DefArg = 0; // Default argument hack static String *ConstChar = 0; // Used to store raw character constants static ParmList *tm_parm = 0; // Parameter list used to hold typemap parameters @@ -80,7 +80,7 @@ static DOHHash *name_hash = 0; // Hash table containing renaming char *objc_construct = (char *) "new"; // Objective-C constructor char *objc_destruct = (char *) "free"; // Objective-C destructor -static DOHHash *symbols = 0; +static DOHHash *symbols = 0; /* Some macros for building constants */ @@ -96,7 +96,7 @@ static DOHHash *symbols = 0; int cplus_mode; -// Declarations of some functions for handling C++ +// Declarations of some functions for handling C++ extern void cplus_open_class(char *name, char *rname, char *ctype); extern void cplus_member_func(char *, char *, SwigType *, ParmList *, int); @@ -120,7 +120,7 @@ extern void cplus_abort(); void parser_init() { ArrayString = NewString(""); temp_type = NewString(""); -} +} static void my_cplus_declare_const(char *name, char *iname, SwigType *type, char *value) { String *tval; @@ -146,7 +146,7 @@ static void add_pointers(SwigType *t, int npointer) { } } -// Emit an external function declaration +// Emit an external function declaration static void emit_extern_func(char *decl, SwigType *t, ParmList *L, int extern_type, DOHFile *f) { @@ -221,7 +221,7 @@ int promote(int t1, int t2) { return t1; } -/* Generate the scripting name of an object. Takes %name directive into +/* Generate the scripting name of an object. Takes %name directive into account among other things */ static char *make_name(char *name) { @@ -273,7 +273,7 @@ void create_function(int ext, char *name, SwigType *t, ParmList *l) { // If extern, make an extern declaration in the SWIG wrapper file - if (ext) + if (ext) emit_extern_func(name, t, l, ext, f_header); else if (ForceExtern) { emit_extern_func(name, t, l, 1, f_header); @@ -295,7 +295,7 @@ void create_variable(int ext, char *name, SwigType *t) { if (WrapExtern) return; // External wrapper file. Ignore if (Active_static) return; // If static ignore - + init_language(); char *iname = make_name(name); @@ -403,11 +403,11 @@ static void dump_nested(char *parent) { // Fix up the name of the datatype (for building typedefs and other stuff) sprintf(temp,"%s_%s", parent,n->name); - + Append(n->type,parent); Append(n->type,"_"); Append(n->type,n->name); - + // Add the appropriate declaration to the C++ processor cplus_variable(n->name,(char *) 0, n->type); @@ -423,7 +423,7 @@ static void dump_nested(char *parent) { } nested_list = 0; Status = oldstatus; -} +} static DOHList *typelist(Parm *p) { DOHList *l = NewList(); @@ -442,7 +442,7 @@ static void dump_nested(char *parent) { C++ declaration for "yylval" that appears in parser.tab.h. */ -%union { +%union { char *id; struct Declaration { char *id; @@ -465,7 +465,7 @@ static void dump_nested(char *parent) { struct { char *filename; int line; - int flag; + int flag; } loc; SwigType *type; Parm *p; @@ -474,7 +474,7 @@ static void dump_nested(char *parent) { int ivalue; }; -%token ID +%token ID %token HBLOCK WRAPPER POUND RUNTIME HEADER %token STRING %token INCLUDE IMPORT WEXTERN SWIGMACRO INSERT @@ -483,15 +483,15 @@ static void dump_nested(char *parent) { %token TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_TYPEDEF TYPE_RAW %token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE DEFINE PERIOD %token CONST STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET -%token ILLEGAL CONSTANT -%token READONLY READWRITE NAME RENAME ADDMETHODS PRAGMA +%token ILLEGAL CONSTANT +%token READONLY READWRITE NAME RENAME ADDMETHODS PRAGMA %token CVALUE COUT -%token ENUM ENDDEF MACRO +%token ENUM ENDDEF MACRO %token CLASS PRIVATE PUBLIC PROTECTED COLON STATIC VIRTUAL FRIEND OPERATOR THROW TEMPLATE %token NATIVE INLINE %token RAW_MODE ALPHA_MODE TEXT DOC_DISABLE DOC_ENABLE STYLE LOCALSTYLE %token TYPEMAP EXCEPT ECHO NEW APPLY CLEAR DOCONLY -%token TITLE SECTION SUBSECTION SUBSUBSECTION +%token TITLE SECTION SUBSECTION SUBSUBSECTION %token LESSTHAN GREATERTHAN %token USERDIRECTIVE @@ -502,8 +502,8 @@ static void dump_nested(char *parent) { %left OR %left XOR %left AND -%left LSHIFT RSHIFT -%left PLUS MINUS +%left LSHIFT RSHIFT +%left PLUS MINUS %left STAR SLASH %left UMINUS NOT LNOT %left DCOLON @@ -522,7 +522,7 @@ static void dump_nested(char *parent) { %type expr; %type ename stylearg objc_inherit; %type stylelist styletail; -%type objc_ret_type objc_arg_type; +%type objc_ret_type objc_arg_type; %type objc_protolist objc_separator; %type objc_args; @@ -538,8 +538,8 @@ program : command { } } ; - -command : command statement { + +command : command statement { scanner_clear_start(); Error = 0; } @@ -625,11 +625,11 @@ statement : INCLUDE STRING LBRACE { } } Delete($2); - } stail { } + } stail { } /* Global variable that smells like a function pointer */ - | extern strict_type LPAREN STAR { + | extern strict_type LPAREN STAR { skip_decl(); Printf(stderr,"%s : Line %d. Function pointers not currently supported.\n", input_file, line_number); @@ -646,7 +646,7 @@ statement : INCLUDE STRING LBRACE { /* Global variable that smells like a function pointer */ - | STATIC strict_type LPAREN STAR { + | STATIC strict_type LPAREN STAR { skip_decl(); Printf(stderr,"%s : Line %d. Function pointers not currently supported.\n", input_file, line_number); @@ -665,8 +665,8 @@ statement : INCLUDE STRING LBRACE { create_function($1, $3.id, $2, $5); Delete($2); Delete($5); - } stail { } - + } stail { } + /* A function declaration with code after it */ | extern type declaration LPAREN parms RPAREN func_end { @@ -680,7 +680,7 @@ statement : INCLUDE STRING LBRACE { /* A function declared without any return datatype */ - | extern declaration LPAREN parms RPAREN cpp_const { + | extern declaration LPAREN parms RPAREN cpp_const { init_language(); SwigType *t = NewString("int"); add_pointers(t,$2.is_pointer); @@ -754,11 +754,11 @@ statement : INCLUDE STRING LBRACE { } /* %rename directive */ - | RENAME ID ID SEMI { + | RENAME ID ID SEMI { if (!name_hash) name_hash = NewHash(); Setattr(name_hash,$2,$3); } - + /* %new directive */ | NEW { @@ -811,7 +811,7 @@ statement : INCLUDE STRING LBRACE { /* %title directive */ | TITLE STRING styletail { - } + } /* %section directive */ @@ -833,7 +833,7 @@ statement : INCLUDE STRING LBRACE { | TEXT HBLOCK { } - + | typedef_decl { } @@ -852,7 +852,7 @@ statement : INCLUDE STRING LBRACE { Printf(f_header, "%s\n", $2); } } - + /* Super-secret undocumented for people who really know what's going on feature */ | WRAPPER HBLOCK { @@ -895,7 +895,7 @@ statement : INCLUDE STRING LBRACE { } else { if (Swig_insert_file($5,f) < 0) { Printf(stderr,"%s:%d: Couldn't find '%s'. Possible installation problem.\n", input_file, line_number, $5); - SWIG_exit(1); + SWIG_exit (EXIT_FAILURE); } } } @@ -937,7 +937,7 @@ statement : INCLUDE STRING LBRACE { /* Disable code generation */ | DOCONLY { } - + /* Init directive--to avoid errors in other modules */ | INIT ID initlist { @@ -968,7 +968,7 @@ statement : INCLUDE STRING LBRACE { } else if ($3.type == T_SYMBOL) { // Add a symbol to the SWIG symbol table if (add_symbol($2)) { - Printf(stderr,"%s : Line %d. Warning. Symbol %s already defined.\n", + Printf(stderr,"%s : Line %d. Warning. Symbol %s already defined.\n", input_file,line_number, $2); } } @@ -984,7 +984,7 @@ statement : INCLUDE STRING LBRACE { /* Enumerations */ - | extern ENUM ename LBRACE { scanner_clear_start(); } enumlist RBRACE SEMI { + | extern ENUM ename LBRACE { scanner_clear_start(); } enumlist RBRACE SEMI { init_language(); if ($3) { if (temp_type) Delete(temp_type); @@ -1213,7 +1213,7 @@ statement : INCLUDE STRING LBRACE { | EXCEPT SEMI { Swig_except_clear(); } - + /* Miscellaenous stuff */ | SEMI { } @@ -1320,7 +1320,7 @@ typedef_decl : TYPEDEF type declaration { init_language(); Active_typedef = Copy($2); // This datatype is going to be readonly - + add_pointers($2,$3.is_pointer); SwigType_push($2,ArrayString); SwigType_typedef($2,$3.id); @@ -1332,13 +1332,13 @@ typedef_decl : TYPEDEF type declaration { /* ------------------------------------------------------------------------ Typedef list - + The following rules are used to manage typedef lists. Only a temporary hack until the SWIG 2.0 parser gets online. Active_typedef contains the datatype of the last typedef (if applicable) ------------------------------------------------------------------------ */ - + typedeflist : COMMA declaration typedeflist { if (Active_typedef) { @@ -1374,7 +1374,7 @@ pragma : PRAGMA LPAREN ID COMMA ID stylearg RPAREN { } | PRAGMA ID stylearg { - if (!WrapExtern) + if (!WrapExtern) swig_pragma($2,$3); } | PRAGMA LPAREN ID RPAREN ID stylearg { @@ -1404,7 +1404,7 @@ stail : SEMI { } } } Delete(temp_typeptr); - } stail { } + } stail { } | COMMA declaration LPAREN parms RPAREN cpp_const { init_language(); temp_typeptr = Copy(Active_type); @@ -1466,7 +1466,7 @@ parm_type : type pname { if (InArray) { // Add array string to the type SwigType_push($1, ArrayString); - } + } $$ = NewParm($1,$2); Setvalue($$,DefArg); Delete($1); @@ -1517,7 +1517,7 @@ parm_type : type pname { ; pname : ID def_args { - $$ = $1; + $$ = $1; InArray = 0; if ($2.type == T_CHAR) DefArg = Swig_copy_string(Char(ConstChar)); @@ -1526,8 +1526,8 @@ pname : ID def_args { if ($2.id) free($2.id); } | ID array { - $$ = $1; - InArray = $2; + $$ = $1; + InArray = $2; DefArg = 0; } | array { @@ -1597,7 +1597,7 @@ array : LBRACKET RBRACKET array2 { array2 : array { $$ = $1; } - | empty { + | empty { $$ = 0; Clear(ArrayString); } @@ -1780,7 +1780,7 @@ definetype : { scanner_check_typedef(); } expr { if (ConstChar) Delete(ConstChar); ConstChar = NewStringf("'%(escape)s'", $1); } - ; + ; /* Initialization function links */ @@ -1794,18 +1794,18 @@ initlist : initlist COMMA ID { | empty { $$.names = (char **) malloc(NI_NAMES*sizeof(char*)); $$.count = 0; - for (i = 0; i < NI_NAMES; i++) + for (i = 0; i < NI_NAMES; i++) $$.names[i] = (char *) 0; } ; /* Some stuff for handling enums */ -ename : ID { $$ = $1; } +ename : ID { $$ = $1; } | empty { $$ = (char *) 0;} ; -/* SWIG enum list. +/* SWIG enum list. */ enumlist : enumlist COMMA edecl {} @@ -1817,12 +1817,12 @@ edecl : ID { temp_typeptr = NewSwigType(T_INT); create_constant($1, temp_typeptr, $1); Delete(temp_typeptr); - } + } | ID EQUAL { scanner_check_typedef();} etype { temp_typeptr = NewSwigType($4.type); // Use enum name instead of value // OLD create_constant($1, temp_typeptr, $4.id); - if ($4.type == T_CHAR) + if ($4.type == T_CHAR) create_constant($1,temp_typeptr, $4.id); else create_constant($1, temp_typeptr, $1); @@ -1831,12 +1831,12 @@ edecl : ID { } | empty { } ; - + etype : expr { $$ = $1; if (($$.type != T_INT) && ($$.type != T_UINT) && ($$.type != T_LONG) && ($$.type != T_ULONG) && - ($$.type != T_SHORT) && ($$.type != T_USHORT) && + ($$.type != T_SHORT) && ($$.type != T_USHORT) && ($$.type != T_SCHAR) && ($$.type != T_UCHAR)) { Printf(stderr,"%s : Lind %d. Type error. Expecting an int\n", input_file, line_number); @@ -1848,14 +1848,14 @@ etype : expr { $$.id = $1; $$.type = T_INT; } - ; + ; /* Arithmetic expressions. Used for constants and other cool stuff. Really, we're not doing anything except string concatenation, but this does allow us to parse many constant declarations. */ -expr : NUM_INT { +expr : NUM_INT { $$.id = $1; $$.type = T_INT; } @@ -1870,7 +1870,7 @@ expr : NUM_INT { | NUM_LONG { $$.id = $1; $$.type = T_LONG; - } + } | NUM_ULONG { $$.id = $1; $$.type = T_ULONG; @@ -1884,7 +1884,7 @@ expr : NUM_INT { $$.id = (char *) malloc(strlen($4.id)+Len($2)+3); sprintf($$.id,"(%s)%s",Char($2),$4.id); $$.type = SwigType_type($2); - } + } | ID { $$.id = $1; $$.type = T_INT; @@ -2012,15 +2012,15 @@ expr : NUM_INT { cpp : cpp_class { } | cpp_other {} ; - -cpp_class : + +cpp_class : /* A class/struct/union definition */ extern cpptype ID inherit LBRACE { char *iname; init_language(); SwigType_new_scope(); - + sprintf(temp_name,"CPP_CLASS:%s\n",$3); if (add_symbol(temp_name)) { Printf(stderr,"%s : Line %d. Error. %s %s is multiply defined.\n", input_file, line_number, $2, $3); @@ -2028,9 +2028,9 @@ cpp_class : } if ((!CPlusPlus) && (strcmp($2,"class") == 0)) Printf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number); - + iname = make_name($3); - if (iname == $3) + if (iname == $3) cplus_open_class($3, 0, $2); else cplus_open_class($3, iname, $2); @@ -2059,25 +2059,25 @@ cpp_class : } free($4.names); } - + // Dumped nested declarations (if applicable) dump_nested($3); - + // Save and collapse current scope SwigType_set_scope_name($3); cplus_register_scope(SwigType_pop_scope()); - cplus_class_close((char *) 0); + cplus_class_close((char *) 0); cplus_mode = CPLUS_PUBLIC; } /* Class with a typedef */ - + | TYPEDEF cpptype ID inherit LBRACE { char *iname; init_language(); SwigType_new_scope(); - + sprintf(temp_name,"CPP_CLASS:%s\n",$3); if (add_symbol(temp_name)) { Printf(stderr,"%s : Line %d. Error. %s %s is multiply defined.\n", input_file, line_number, $2, $3); @@ -2085,9 +2085,9 @@ cpp_class : } if ((!CPlusPlus) && (strcmp($2,"class") == 0)) Printf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number); - + iname = make_name($3); - if ($3 == iname) + if ($3 == iname) cplus_open_class($3, 0, $2); else cplus_open_class($3, iname, $2); @@ -2097,7 +2097,7 @@ cpp_class : cplus_mode = CPLUS_PUBLIC; scanner_clear_start(); nested_list = 0; - + // Merge in scope from base classes cplus_inherit_scope($4.count,$4.names); @@ -2120,10 +2120,10 @@ cpp_class : } free($4.names); } - + if ($9.is_pointer > 0) { Printf(stderr,"%s : Line %d. typedef struct { } *id not supported properly. Winging it...\n", input_file, line_number); - + } // Create dump nested class code if ($9.is_pointer > 0) { @@ -2131,15 +2131,15 @@ cpp_class : } else { dump_nested($9.id); } - + // Collapse any datatypes created in the the class - + SwigType_set_scope_name($3); cplus_register_scope(SwigType_pop_scope()); if ($9.is_pointer > 0) { cplus_class_close($3); } else { - cplus_class_close($9.id); + cplus_class_close($9.id); } // Create a typedef in global scope if ($9.is_pointer == 0) { @@ -2164,7 +2164,7 @@ cpp_class : SwigType_new_scope(); if ((!CPlusPlus) && (strcmp($2,"class") == 0)) Printf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number); - + iname = make_name((char*)""); if (strlen(iname)) cplus_open_class((char *)"", iname, $2); @@ -2189,16 +2189,16 @@ cpp_class : } // Create a datatype for correctly processing the typedef Active_typedef = NewString($7.id); - + // Dump nested classes - if ($7.is_pointer == 0) + if ($7.is_pointer == 0) dump_nested($7.id); - + // Go back to previous scope - + cplus_register_scope(SwigType_pop_scope()); - if ($7.is_pointer == 0) - cplus_class_close($7.id); + if ($7.is_pointer == 0) + cplus_class_close($7.id); cplus_mode = CPLUS_PUBLIC; } typedeflist { } ; @@ -2210,15 +2210,15 @@ cpp_other :/* A dummy class name */ init_language(); iname = make_name($3); lang->cpp_class_decl($3,iname,$2); - } + } /* A static C++ member function (declared out of scope) */ - + | extern type declaration DCOLON ID LPAREN parms RPAREN SEMI { init_language(); - if (!CPlusPlus) + if (!CPlusPlus) Printf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number); - + add_pointers($2,$3.is_pointer); if ($3.is_reference) SwigType_add_reference($2); // Fix up the function name @@ -2231,13 +2231,13 @@ cpp_other :/* A dummy class name */ Delete($2); Delete($7); } - + /* A static C++ member data */ | extern type declaration DCOLON ID SEMI { init_language(); - if (!CPlusPlus) + if (!CPlusPlus) Printf(stderr,"%s : Line %d. *** WARNING ***. C++ mode is disabled (enable using -c++)\n", input_file, line_number); - + add_pointers($2,$3.is_pointer); // Fix up the function name sprintf(temp_name,"%s::%s",$3.id,$5); @@ -2255,7 +2255,7 @@ cpp_other :/* A dummy class name */ Printf(stderr,"%s : Line %d. Operator overloading not supported (ignored).\n", input_file, line_number); skip_decl(); Delete($2); - } + } /* Template catch */ @@ -2279,10 +2279,10 @@ cpp_other :/* A dummy class name */ ; added_members : cpp_member cpp_members { } - | objc_method objc_methods { } + | objc_method objc_methods { } | empty { } ; - + cpp_members : cpp_member cpp_members {} | ADDMETHODS LBRACE { AddMethods = 1; @@ -2317,9 +2317,9 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end { Delete($1); Delete($4); } - + /* Virtual member function */ - + | VIRTUAL type declaration LPAREN parms RPAREN cpp_vend { char *iname; init_language(); @@ -2415,7 +2415,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end { scanner_clear_start(); Delete($1); } - + /* Static Member data */ @@ -2475,7 +2475,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end { | NAME LPAREN ID RPAREN { strcpy(yy_rename,$3); Rename_true = 1; - } + } /* New mode */ | NEW { @@ -2512,7 +2512,7 @@ cpp_member : type declaration LPAREN parms RPAREN cpp_end { Printf(stderr,"%s : Line %d. Friends are not allowed--members only! (ignored)\n", input_file, line_number); skip_decl(); scanner_clear_start(); - } + } /* An operator: Illegal */ | type type_extra OPERATOR { @@ -2549,7 +2549,7 @@ cpp_pragma : PRAGMA ID stylearg { variable declaration information and generate the associated wrapper code later. Yikes! - This really only works in a limited sense. Since we use the + This really only works in a limited sense. Since we use the code attached to the nested class to generate both C/C++ code, it can't have any SWIG directives in it. It also needs to be parsable by SWIG or this whole thing is going to puke. @@ -2557,8 +2557,8 @@ cpp_pragma : PRAGMA ID stylearg { /* A struct sname { } id; declaration */ - | cpptype ID LBRACE { start_line = line_number; skip_brace(); - } nested_decl SEMI { + | cpptype ID LBRACE { start_line = line_number; skip_brace(); + } nested_decl SEMI { if (cplus_mode == CPLUS_PUBLIC) { cplus_register_type($2); @@ -2569,7 +2569,7 @@ cpp_pragma : PRAGMA ID stylearg { } else { Nested *n = (Nested *) malloc(sizeof(Nested)); n->code = NewString(""); - Printv(n->code, "typedef ", $1, " ", + Printv(n->code, "typedef ", $1, " ", Char(CCode), " $classname_", $5.id, ";\n", 0); n->name = Swig_copy_string($5.id); n->line = start_line; @@ -2584,7 +2584,7 @@ cpp_pragma : PRAGMA ID stylearg { } /* An unnamed structure definition */ | cpptype LBRACE { start_line = line_number; skip_brace(); - } declaration SEMI { + } declaration SEMI { if (cplus_mode == CPLUS_PUBLIC) { if (strcmp($1,"class") == 0) { Printf(stderr,"%s : Line %d. Warning. Nested classes not currently supported (ignored)\n", input_file, line_number); @@ -2615,20 +2615,20 @@ cpp_pragma : PRAGMA ID stylearg { } /* Other miscellaneous errors */ - | type stars LPAREN { + | type stars LPAREN { skip_decl(); Printf(stderr,"%s : Line %d. Function pointers not currently supported (ignored).\n", input_file, line_number); - + } | strict_type LPAREN STAR { skip_decl(); Printf(stderr,"%s : Line %d. Function pointers not currently supported (ignored).\n", input_file, line_number); - + } - | ID LPAREN STAR { + | ID LPAREN STAR { skip_decl(); Printf(stderr,"%s : Line %d. Function pointers not currently supported (ignored).\n", input_file, line_number); - + } | doc_enable { } | SEMI { } @@ -2641,7 +2641,7 @@ nested_decl : declaration { $$ = $1;} type_extra : stars {} | AND {} | empty {} - ; + ; cpp_tail : SEMI { } | COMMA declaration def_args { @@ -2649,26 +2649,26 @@ cpp_tail : SEMI { } if (cplus_mode == CPLUS_PUBLIC) { temp_typeptr = Copy(Active_type); add_pointers(temp_typeptr, $2.is_pointer); - cplus_variable($2.id,(char *) 0,temp_typeptr); + cplus_variable($2.id,(char *) 0,temp_typeptr); Delete(temp_typeptr); } scanner_clear_start(); - } cpp_tail { } + } cpp_tail { } | COMMA declaration array def_args { init_language(); if (cplus_mode == CPLUS_PUBLIC) { temp_typeptr = Copy(Active_type); add_pointers(temp_typeptr, $2.is_pointer); - cplus_variable($2.id,(char *) 0,temp_typeptr); + cplus_variable($2.id,(char *) 0,temp_typeptr); Delete(temp_typeptr); } scanner_clear_start(); - } cpp_tail { } + } cpp_tail { } ; -cpp_end : cpp_const SEMI { +cpp_end : cpp_const SEMI { Clear(CCode); - } + } | cpp_const LBRACE { skip_brace(); } ; @@ -2726,7 +2726,7 @@ inherit : COLON base_list { } ; -base_list : base_specifier { +base_list : base_specifier { int i; $$.names = (char **) malloc(NI_NAMES*sizeof(char *)); $$.count = 0; @@ -2739,7 +2739,7 @@ base_list : base_specifier { } } - | base_list COMMA base_specifier { + | base_list COMMA base_specifier { $$ = $1; if ($3) { $$.names[$$.count] = Swig_copy_string($3); @@ -2747,13 +2747,13 @@ base_list : base_specifier { } } ; - -base_specifier : ID { + +base_specifier : ID { Printf(stderr,"%s : Line %d. No access specifier given for base class %s (ignored).\n", input_file,line_number,$1); $$ = (char *) 0; } - | VIRTUAL ID { + | VIRTUAL ID { Printf(stderr,"%s : Line %d. No access specifier given for base class %s (ignored).\n", input_file,line_number,$2); $$ = (char *) 0; @@ -2775,7 +2775,7 @@ base_specifier : ID { input_file,line_number,$1); $$ = (char *) 0; } - } + } | access_specifier VIRTUAL ID { if (strcmp($1,"public") == 0) { $$ = $3; @@ -2785,29 +2785,29 @@ base_specifier : ID { $$ = (char *) 0; } } - ; + ; access_specifier : PUBLIC { $$ = (char*)"public"; } | PRIVATE { $$ = (char*)"private"; } | PROTECTED { $$ = (char*)"protected"; } ; - - + + cpptype : CLASS { $$ = (char*)"class"; } | STRUCT { $$ = (char*)"struct"; } | UNION {$$ = (char*)"union"; } ; -cpp_const : CONST {} +cpp_const : CONST {} | THROW LPAREN parms RPAREN { Delete($3);} | empty {} ; /* Constructor initializer */ -ctor_end : cpp_const ctor_initializer SEMI { +ctor_end : cpp_const ctor_initializer SEMI { Clear(CCode); - } + } | cpp_const ctor_initializer LBRACE { skip_brace(); } ; @@ -2822,7 +2822,7 @@ mem_initializer_list : mem_initializer { } mem_initializer : ID LPAREN expr_list RPAREN { } | ID LPAREN RPAREN { } ; - + expr_list : expr { } | expr_list COMMA expr { } ; @@ -2832,7 +2832,7 @@ expr_list : expr { } /* Objective-C parsing */ /**************************************************************/ -objective_c : OC_INTERFACE ID objc_inherit { +objective_c : OC_INTERFACE ID objc_inherit { ObjCClass = 1; init_language(); cplus_mode = CPLUS_PROTECTED; @@ -2844,7 +2844,7 @@ objective_c : OC_INTERFACE ID objc_inherit { } scanner_clear_start(); cplus_open_class($2, (char *) 0, (char*)""); // Open up a new C++ class - } LBRACE objc_data RBRACE objc_methods OC_END { + } LBRACE objc_data RBRACE objc_methods OC_END { if ($3) { char *inames[1]; inames[0] = $3; @@ -2878,7 +2878,7 @@ objective_c : OC_INTERFACE ID objc_inherit { lang->cpp_class_decl($3.names[i],iname,(char*)""); free($3.names[i]); } - } + } free($3.names); } ; @@ -2888,7 +2888,7 @@ objc_inherit : COLON ID objc_protolist { $$ = $2;} ; -objc_protolist : LESSTHAN { skip_template(); +objc_protolist : LESSTHAN { skip_template(); /* CCode.strip(); // Strip whitespace CCode.replace("<","< "); CCode.replace(">"," >"); */ @@ -2898,15 +2898,15 @@ objc_protolist : LESSTHAN { skip_template(); $$ = (char*)""; } ; - + objc_data : objc_vars objc_data { } - | OC_PUBLIC { + | OC_PUBLIC { cplus_mode = CPLUS_PUBLIC; } objc_data { } | OC_PRIVATE { cplus_mode = CPLUS_PRIVATE; } objc_data { } - | OC_PROTECTED { + | OC_PROTECTED { cplus_mode = CPLUS_PROTECTED; } objc_data { } | error { @@ -2927,13 +2927,13 @@ objc_data : objc_vars objc_data { } ; objc_vars : objc_var objc_vartail SEMI { - + } ; /* An objective-C member variable */ -objc_var : type declaration { +objc_var : type declaration { if (cplus_mode == CPLUS_PUBLIC) { int oldstatus = Status; char *iname; @@ -2944,12 +2944,12 @@ objc_var : type declaration { iname = make_name($2.id); if (iname == $2.id) iname = 0; cplus_variable($2.id,iname,$1); - Status = oldstatus; + Status = oldstatus; } scanner_clear_start(); Delete($1); } - | type declaration array { + | type declaration array { if (cplus_mode == CPLUS_PUBLIC) { int oldstatus = Status; char *iname; @@ -2961,7 +2961,7 @@ objc_var : type declaration { iname = make_name($2.id); if (iname == $2.id) iname = 0; cplus_variable($2.id,iname,$1); - Status = oldstatus; + Status = oldstatus; } scanner_clear_start(); Delete($1); @@ -2971,7 +2971,7 @@ objc_var : type declaration { Rename_true = 1; } objc_var { }; -objc_vartail : COMMA declaration objc_vartail { +objc_vartail : COMMA declaration objc_vartail { if (cplus_mode == CPLUS_PUBLIC) { int oldstatus = Status; char *iname; @@ -2981,7 +2981,7 @@ objc_vartail : COMMA declaration objc_vartail { iname = make_name($2.id); if (iname == $2.id) iname = 0; cplus_variable($2.id,iname,t); - Status = oldstatus; + Status = oldstatus; Delete(t); } scanner_clear_start(); @@ -2997,7 +2997,7 @@ objc_vartail : COMMA declaration objc_vartail { iname = make_name($2.id); if (iname == $2.id) iname = 0; cplus_variable($2.id,iname,t); - Status = oldstatus; + Status = oldstatus; Delete(t); } scanner_clear_start(); @@ -3016,7 +3016,7 @@ objc_methods : objc_method objc_methods { }; Rename_true = 1; } objc_methods { } | error { - skip_decl(); + skip_decl(); if (!Error) { { static int last_error_line = -1; @@ -3050,7 +3050,7 @@ objc_method : MINUS objc_ret_type ID objc_args objc_end { Delete($4); } } - | PLUS objc_ret_type ID objc_args objc_end { + | PLUS objc_ret_type ID objc_args objc_end { char *iname; // An objective-C class function // This is like a c++ static member function @@ -3073,10 +3073,10 @@ objc_end : SEMI { Clear(CCode); } | LBRACE { skip_brace(); } ; -objc_ret_type : LPAREN type RPAREN { +objc_ret_type : LPAREN type RPAREN { $$ = $2; } - | LPAREN type stars RPAREN { + | LPAREN type stars RPAREN { $$ = $2; add_pointers($$,$3); } @@ -3085,16 +3085,16 @@ objc_ret_type : LPAREN type RPAREN { } ; -objc_arg_type : LPAREN parm RPAREN { +objc_arg_type : LPAREN parm RPAREN { $$ = Copy(Gettype($2)); Delete($2); } - | empty { + | empty { $$ = NewString("id"); } ; - -objc_args : objc_args objc_separator objc_arg_type ID { + +objc_args : objc_args objc_separator objc_arg_type ID { Parm *p= NewParm($3,$4); /* p->objc_separator = $2; */ $$ = $1; @@ -3110,13 +3110,13 @@ objc_args : objc_args objc_separator objc_arg_type ID { Setnext(pp,p); } } - | empty { + | empty { $$ = 0; } ; objc_separator : COLON { $$ = Swig_copy_string((char*)":"); } - | ID COLON { $$ = (char *) malloc(strlen($1)+2); + | ID COLON { $$ = (char *) malloc(strlen($1)+2); strcpy($$,$1); strcat($$,":"); free($1); @@ -3155,19 +3155,19 @@ stylearg : EQUAL NUM_INT { | EQUAL STRING { $$ = $2; } - | empty { + | empty { $$ = 0; } ; /* -------------------------------------------------------------- - * Type-map parameters + * Type-map parameters * -------------------------------------------------------------- */ tm_method : ID { $$ = $1; - } + } | CONST { $$ = Swig_copy_string((char*)"const"); } @@ -3239,10 +3239,10 @@ typemap_parm : type typemap_name { ; typemap_name : ID typemap_args { - $$ = $1; + $$ = $1; InArray = 0; } - | ID array { + | ID array { ArrayBackup = Copy(ArrayString); } typemap_args { $$ = $1; @@ -3251,7 +3251,7 @@ typemap_name : ID typemap_args { Append(ArrayString,ArrayBackup); Delete(ArrayBackup); } - | array { + | array { ArrayBackup = Copy(ArrayString); } typemap_args { $$ = (char *) malloc(1); @@ -3285,16 +3285,16 @@ uservalue : ID SEMI { } | STRING SEMI { } | LBRACE RBRACE { } ; - - - + + + /* Parsing of expressions, but only for throw away code */ -/* Might need someday +/* Might need someday dummyexpr : NUM_INT { } | NUM_FLOAT { } | NUM_UNSIGNED { } - | NUM_LONG { } + | NUM_LONG { } | NUM_ULONG { } | SIZEOF LPAREN type RPAREN { } | ID { } @@ -3322,7 +3322,7 @@ empty : ; void error_recover() { int c; c = yylex(); - while ((c > 0) && (c != SEMI)) + while ((c > 0) && (c != SEMI)) c = yylex(); } diff --git a/Source/SWIG1.1/scanner.cxx b/Source/SWIG1.1/scanner.cxx index 139ace2aa..12de8e429 100644 --- a/Source/SWIG1.1/scanner.cxx +++ b/Source/SWIG1.1/scanner.cxx @@ -1,15 +1,15 @@ -/* ----------------------------------------------------------------------------- +/* ----------------------------------------------------------------------------- * scanner.cxx * * SWIG1.1 tokenizer. - * + * * 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. + * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ static char cvsroot[] = "$Header$"; @@ -29,7 +29,7 @@ struct InFile { DOHFile *f; int line_number; char *in_file; - int extern_mode; + int extern_mode; int force_extern; int inline_mode; struct InFile *prev; @@ -40,7 +40,7 @@ InFile *in_head; DOHFile *LEX_in = 0; static DOHString *header = 0; static DOHString *comment = 0; - DOHString *CCode = 0; // String containing C code + DOHString *CCode = 0; // String containing C code static char *yybuffer = 0; static char yytext[YYBSIZE]; @@ -72,7 +72,7 @@ void scanner_init() { /************************************************************** * scanner_file(FILE *f) * - * Start reading from new file + * Start reading from new file **************************************************************/ void scanner_file(DOHFile *f) { InFile *in; @@ -80,7 +80,7 @@ void scanner_file(DOHFile *f) { in = (InFile *) malloc(sizeof(InFile)); in->f = f; in->in_file = input_file; - in->extern_mode = WrapExtern; + in->extern_mode = WrapExtern; in->force_extern = ForceExtern; in->inline_mode = 0; if (!in_head) in->prev = 0; @@ -93,7 +93,7 @@ void scanner_file(DOHFile *f) { /************************************************************** * scanner_close() * - * Close current input file and go to next + * Close current input file and go to next **************************************************************/ void scanner_close() { @@ -127,7 +127,7 @@ void scanner_close() { char nextchar() { int c = 0; - + while (LEX_in) { c = Getc(LEX_in); if (c == EOF) { @@ -139,7 +139,7 @@ char nextchar() { if (!LEX_in) return 0; if (yylen >= YYBSIZE) { Printf(stderr,"** FATAL ERROR. Buffer overflow in scanner.cxx.\nReport this to swig-dev@cs.uchicago.edu.\n"); - SWIG_exit(1); + SWIG_exit (EXIT_FAILURE); } yytext[yylen] = c; yylen++; @@ -165,7 +165,7 @@ void retract(int n) { /************************************************************** * start_inline(char *text, int line) - * + * * This grabs a chunk of text and tries to inline it into * the current file. (This is kind of wild, but cool when * it works). @@ -195,7 +195,7 @@ void start_inline(char *text, int line) { /************************************************************** * yycomment(char *, int line) * - * Inserts a comment into a documentation entry. + * Inserts a comment into a documentation entry. **************************************************************/ void yycomment(char *, int, int) { @@ -279,7 +279,7 @@ void skip_to_end(void) { break; case 1: if (isspace(c)) { - if (strncmp(yytext,"@end",4) == 0) return; + if (strncmp(yytext,"@end",4) == 0) return; else { yylen = 0; state = 0; @@ -294,7 +294,7 @@ void skip_to_end(void) { input_file); FatalError(); return; -} +} /************************************************************** * void skip_decl(void) @@ -302,8 +302,8 @@ void skip_to_end(void) { * This tries to skip over an entire declaration. For example * * friend ostream& operator<<(ostream&, const char *s); - * - * or + * + * or * friend ostream& operator<<(ostream&, const char *s) { }; * **************************************************************/ @@ -346,7 +346,7 @@ static void get_escape() { int result = 0; int state = 0; char c; - + while(1) { c = nextchar(); if (c == 0) break; @@ -427,9 +427,9 @@ static void get_escape() { yytext[yylen-1] = (char) result; return; } - if (isdigit(c)) + if (isdigit(c)) result = (result << 4) + (c - '0'); - else + else result = (result << 4) + (10 + tolower(c) - 'a'); yylen--; break; @@ -437,7 +437,7 @@ static void get_escape() { } return; } - + /************************************************************** * int yylook() * @@ -469,9 +469,9 @@ int yylook(void) { state = 0; yylen = 0; } - + /* Look for single character symbols */ - + else if (c == '(') return (LPAREN); else if (c == ')') return (RPAREN); else if (c == ';') return (SEMI); @@ -502,7 +502,7 @@ int yylook(void) { else if (c == '<') state = 60; else if (c == '>') state = 61; else if (c == '~') return (NOT); - else if (c == '!') return (LNOT); + else if (c == '!') return (LNOT); else if (c == '\\') { state = 99; } @@ -510,8 +510,8 @@ int yylook(void) { else if (c == ']') return (RBRACKET); /* Look for multi-character sequences */ - - else if (c == '/') state = 1; // Comment (maybe) + + else if (c == '/') state = 1; // Comment (maybe) else if (c == '\"') state = 2; // Possibly a string else if (c == '#') state = 3; // CPP else if (c == '%') state = 4; // Directive @@ -639,7 +639,7 @@ int yylook(void) { state = 99; } break; - + case 40: /* Process an include block */ if ((c = nextchar()) == 0) { Printf(stderr,"%s : EOF. Unterminated include block detected.\n", input_file); @@ -689,7 +689,7 @@ int yylook(void) { return LESSTHAN; } break; - case 61: + case 61: if ((c = nextchar()) == 0) return (0); if (c == '>') return RSHIFT; else { @@ -834,7 +834,7 @@ int yylook(void) { yytext[yylen] = 0; yylval.id = Swig_copy_string(yytext); return(NUM_LONG); - } + } case 88: /* An unsigned integer of some sort */ @@ -848,7 +848,7 @@ int yylook(void) { yytext[yylen] = 0; yylval.id = Swig_copy_string(yytext); return(NUM_UNSIGNED); - } + } case 9: if ((c = nextchar()) == 0) return (0); @@ -884,8 +884,8 @@ int yylook(void) { Printf(stderr,"%s : Line %d ::Illegal character '%c'=%d.\n",input_file, line_number,c,c); FatalError(); } - state = 0; - Error = 1; + state = 0; + Error = 1; return(ILLEGAL); } } @@ -909,7 +909,7 @@ void scanner_ignore_typedef() { *************************************************************/ extern "C" int yylex(void) { - + int l; if (!scan_init) { @@ -917,10 +917,10 @@ extern "C" int yylex(void) { // if (LEX_in == NULL) LEX_in = stdin; // scanner_file(LEX_in); } - + l = yylook(); - /* We got some sort of non-white space object. We set the start_line + /* We got some sort of non-white space object. We set the start_line variable unless it has already been set */ if (!start_line) { @@ -978,7 +978,7 @@ extern "C" int yylex(void) { return(TYPE_BOOL); } // C++ keywords - + if (CPlusPlus) { if (strcmp(yytext,"class") == 0) return(CLASS); if (strcmp(yytext,"private") == 0) return(PRIVATE); @@ -1020,7 +1020,7 @@ extern "C" int yylex(void) { return(TYPEDEF); } - // Ignored keywords + // Ignored keywords if (strcmp(yytext,"volatile") == 0) return(yylex()); @@ -1049,7 +1049,7 @@ extern "C" int yylex(void) { } if (strcmp(yytext,"%constant") == 0) return(CONSTANT); if (strcmp(yytext,"%macro") == 0) return(SWIGMACRO); - + if (strcmp(yytext,"%section") == 0) { yylval.ivalue = line_number; return(SECTION); @@ -1065,7 +1065,7 @@ extern "C" int yylex(void) { if (strcmp(yytext,"%title") == 0) { yylval.ivalue = line_number; return(TITLE); - } + } if (strcmp(yytext,"%style") == 0) return(STYLE); if (strcmp(yytext,"%localstyle") == 0) return(LOCALSTYLE); if (strcmp(yytext,"%typedef") == 0) { @@ -1092,14 +1092,14 @@ extern "C" int yylex(void) { } // Have an unknown identifier, as a last step, we'll // do a typedef lookup on it. - + if (check_typedef) { if (SwigType_istypedef(yytext)) { yylval.type = NewString(yytext); return(TYPE_TYPEDEF); } } - + yylval.id = Swig_copy_string(yytext); return(ID); default: diff --git a/Source/SWIG1.1/swig11.h b/Source/SWIG1.1/swig11.h index 7aaa9bede..9d54f9d8b 100644 --- a/Source/SWIG1.1/swig11.h +++ b/Source/SWIG1.1/swig11.h @@ -59,7 +59,7 @@ extern char output_dir[512]; // Output directory extern int Verbose; extern int IsVirtual; -#define FatalError() if ((error_count++) > 20) { fprintf(stderr,"Confused by earlier errors. Bailing out\n"); SWIG_exit(1); } +#define FatalError() if ((error_count++) > 20) { fprintf(stderr,"Confused by earlier errors. Bailing out\n"); SWIG_exit (EXIT_FAILURE); } /* Miscellaneous stuff */