add new %begin directive for inserting code at top of wrapper file

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11133 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-02-20 07:52:24 +00:00
commit efa11dee52
31 changed files with 334 additions and 162 deletions

View file

@ -21,6 +21,7 @@ char cvsroot_allegrocl_cxx[] = "$Id$";
static File *f_cl = 0;
String *f_clhead = NewString("");
String *f_clwrap = NewString("(swig-in-package ())\n\n");
static File *f_begin;
static File *f_runtime;
static File *f_cxx_header = 0;
static File *f_cxx_wrapper = 0;
@ -1598,27 +1599,30 @@ int ALLEGROCL::top(Node *n) {
Generate_Wrapper = CPlusPlus || CWrap;
if (Generate_Wrapper) {
f_runtime = NewFile(cxx_filename, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(cxx_filename, "w", SWIG_output_files());
if (!f_begin) {
Close(f_cl);
Delete(f_cl);
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
SWIG_exit(EXIT_FAILURE);
}
} else
f_runtime = NewString("");
f_begin = NewString("");
f_runtime = NewString("");
f_cxx_header = f_runtime;
f_cxx_wrapper = NewString("");
Swig_register_filebyname("header", f_cxx_header);
Swig_register_filebyname("wrapper", f_cxx_wrapper);
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("lisp", f_clwrap);
Swig_register_filebyname("lisphead", f_cl);
Swig_banner(f_runtime);
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGALLEGROCL\n");
Printf(f_runtime, "\n");
@ -1664,10 +1668,12 @@ int ALLEGROCL::top(Node *n) {
Delete(f_clhead);
Delete(f_clwrap);
Printf(f_runtime, "%s\n", f_cxx_wrapper);
Dump(f_runtime, f_begin);
Printf(f_begin, "%s\n", f_cxx_wrapper);
Close(f_runtime);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
Delete(f_cxx_wrapper);
// Swig_print_tree(n);

View file

@ -22,6 +22,7 @@ public:
String *f_clhead;
String *f_clwrap;
bool CWrap; // generate wrapper file for C code?
File *f_begin;
File *f_runtime;
File *f_cxx_header;
File *f_cxx_wrapper;
@ -127,8 +128,8 @@ int CFFI::top(Node *n) {
}
if (CPlusPlus || CWrap) {
f_runtime = NewFile(cxx_filename, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(cxx_filename, "w", SWIG_output_files());
if (!f_begin) {
Close(f_lisp);
Delete(f_lisp);
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
@ -145,15 +146,17 @@ int CFFI::top(Node *n) {
SWIG_exit(EXIT_FAILURE);
}
} else {
f_runtime = NewString("");
f_begin = NewString("");
f_clos = NewString("");
}
f_runtime = NewString("");
f_cxx_header = f_runtime;
f_cxx_wrapper = NewString("");
Swig_register_filebyname("header", f_cxx_header);
Swig_register_filebyname("wrapper", f_cxx_wrapper);
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("lisphead", f_clhead);
if (!no_swig_lisp)
@ -161,8 +164,9 @@ int CFFI::top(Node *n) {
else
Swig_register_filebyname("swiglisp", f_null);
Swig_banner(f_runtime);
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGCFFI\n");
Printf(f_runtime, "\n");
@ -178,8 +182,10 @@ int CFFI::top(Node *n) {
Delete(f_cl);
Delete(f_clhead);
Delete(f_clwrap);
Close(f_runtime);
Dump(f_runtime, f_begin);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
Delete(f_cxx_wrapper);
Delete(f_null);

View file

@ -30,6 +30,7 @@ static char *module = 0;
static char *chicken_path = (char *) "chicken";
static int num_methods = 0;
static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_header = 0;
static File *f_wrappers = 0;
@ -188,11 +189,12 @@ int CHICKEN::top(Node *n) {
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
f_runtime = NewFile(outfile, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@ -205,6 +207,7 @@ int CHICKEN::top(Node *n) {
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
@ -215,8 +218,9 @@ int CHICKEN::top(Node *n) {
clos_methods = NewString("");
scm_const_defs = NewString("");
Swig_banner(f_runtime);
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGCHICKEN\n");
if (no_collection)
@ -308,15 +312,17 @@ int CHICKEN::top(Node *n) {
/* Close all of the files */
Delete(primitive_names);
Delete(scmmodule);
Dump(f_header, f_runtime);
Dump(f_wrappers, f_runtime);
Wrapper_pretty_print(f_init, f_runtime);
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
Dump(f_wrappers, f_begin);
Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_sym_size);
Delete(f_init);
Close(f_runtime);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
return SWIG_OK;
}

View file

@ -87,6 +87,7 @@ int CLISP::top(Node *n) {
}
Swig_register_filebyname("header", f_null);
Swig_register_filebyname("begin", f_null);
Swig_register_filebyname("runtime", f_null);
Swig_register_filebyname("wrapper", f_null);

View file

@ -24,6 +24,7 @@ class CSHARP:public Language {
const String *protected_string;
Hash *swig_types_hash;
File *f_begin;
File *f_runtime;
File *f_runtime_h;
File *f_header;
@ -102,6 +103,7 @@ public:
public_string(NewString("public")),
protected_string(NewString("protected")),
swig_types_hash(NULL),
f_begin(NULL),
f_runtime(NULL),
f_runtime_h(NULL),
f_header(NULL),
@ -286,8 +288,8 @@ public:
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewFile(outfile, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
@ -304,6 +306,7 @@ public:
}
}
f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@ -313,6 +316,7 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("director", f_directors);
@ -358,8 +362,9 @@ public:
if (!dllimport)
dllimport = Copy(module_class_name);
Swig_banner(f_runtime); // Print the SWIG banner message
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGCSHARP\n");
if (directorsEnabled()) {
@ -367,6 +372,7 @@ public:
/* Emit initial director header and director code: */
Swig_banner(f_directors_h);
Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_class_name);
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_class_name);
@ -571,10 +577,11 @@ public:
n_dmethods = 0;
/* Close all of the files */
Dump(f_header, f_runtime);
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
if (directorsEnabled()) {
Dump(f_directors, f_runtime);
Dump(f_directors, f_begin);
Dump(f_directors_h, f_runtime_h);
Printf(f_runtime_h, "\n");
@ -589,13 +596,14 @@ public:
f_directors_h = NULL;
}
Dump(f_wrappers, f_runtime);
Wrapper_pretty_print(f_init, f_runtime);
Dump(f_wrappers, f_begin);
Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
Close(f_runtime);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
return SWIG_OK;
}

View file

@ -47,6 +47,7 @@ Guile Options (available with -guile)\n\
-exportprimitive - Add the (export ...) code from scmstub into the\n\
GOOPS file.\n";
static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_header = 0;
static File *f_wrappers = 0;
@ -299,11 +300,12 @@ public:
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
f_runtime = NewFile(outfile, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@ -311,6 +313,7 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
@ -322,8 +325,9 @@ public:
goopscode = NewString("");
goopsexport = NewString("");
Swig_banner(f_runtime);
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGGUILE\n");
if (!use_scm_interface) {
@ -393,14 +397,16 @@ public:
Delete(goopstext);
/* Close all of the files */
Dump(f_header, f_runtime);
Dump(f_wrappers, f_runtime);
Wrapper_pretty_print(f_init, f_runtime);
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
Dump(f_wrappers, f_begin);
Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
Close(f_runtime);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
return SWIG_OK;
}

View file

@ -24,6 +24,7 @@ class JAVA:public Language {
const String *protected_string;
Hash *swig_types_hash;
File *f_begin;
File *f_runtime;
File *f_runtime_h;
File *f_header;
@ -99,6 +100,7 @@ public:
public_string(NewString("public")),
protected_string(NewString("protected")),
swig_types_hash(NULL),
f_begin(NULL),
f_runtime(NULL),
f_runtime_h(NULL),
f_header(NULL),
@ -295,8 +297,8 @@ public:
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewFile(outfile, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
@ -313,6 +315,7 @@ public:
}
}
f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@ -320,6 +323,7 @@ public:
f_directors = NewString("");
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("runtime", f_runtime);
@ -367,15 +371,16 @@ public:
jnipackage = NewString("");
package_path = NewString("");
Swig_banner(f_runtime); // Print the SWIG banner message
Swig_banner(f_begin);
Printf(f_runtime, "#define SWIGJAVA\n");
Printf(f_runtime, "\n#define SWIGJAVA\n");
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
/* Emit initial director header and director code: */
Swig_banner(f_directors_h);
Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_class_name);
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_class_name);
@ -666,8 +671,10 @@ public:
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
Close(f_runtime);
Dump(f_runtime, f_begin);
Delete(f_runtime);
Close(f_begin);
Delete(f_begin);
return SWIG_OK;
}

View file

@ -92,6 +92,7 @@ NEW LANGUAGE NOTE:END ************************************************/
class LUA:public Language {
private:
File *f_begin;
File *f_runtime;
File *f_header;
File *f_wrappers;
@ -132,6 +133,7 @@ public:
* --------------------------------------------------------------------- */
LUA() {
f_begin = 0;
f_runtime = 0;
f_header = 0;
f_wrappers = 0;
@ -213,11 +215,12 @@ public:
String *outfile = Getattr(n, "outfile");
/* Open the output file */
f_runtime = NewFile(outfile, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@ -226,6 +229,7 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("initbeforefunc", f_initbeforefunc);
@ -249,8 +253,9 @@ public:
current=NO_CPP;
/* Standard stuff for the SWIG runtime section */
Swig_banner(f_runtime);
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGLUA\n");
// if (NoInclude) {
@ -293,13 +298,14 @@ public:
this basically combines several of the strings together
and then writes it all to a file
NEW LANGUAGE NOTE:END ************************************************/
Dump(f_header, f_runtime);
Dump(f_wrappers, f_runtime);
Dump(f_initbeforefunc, f_runtime);
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
Dump(f_wrappers, f_begin);
Dump(f_initbeforefunc, f_begin);
/* for the Lua code it needs to be properly excaped to be added into the C/C++ code */
EscapeCode(s_luacode);
Printf(f_runtime, "const char* SWIG_LUACODE=\n \"%s\";\n\n",s_luacode);
Wrapper_pretty_print(f_init, f_runtime);
Printf(f_begin, "const char* SWIG_LUACODE=\n \"%s\";\n\n",s_luacode);
Wrapper_pretty_print(f_init, f_begin);
/* Close all of the files */
Delete(s_luacode);
Delete(s_cmd_tab);
@ -309,8 +315,9 @@ public:
Delete(f_wrappers);
Delete(f_init);
Delete(f_initbeforefunc);
Close(f_runtime);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
/* Done */
return SWIG_OK;

View file

@ -379,6 +379,7 @@ static void SWIG_dump_runtime() {
}
Swig_banner(runtime);
Printf(runtime, "\n");
s = Swig_include_sys("swiglabels.swg");
if (!s) {

View file

@ -172,6 +172,7 @@ private:
const String *empty_string;
Hash *swig_types_hash;
File *f_begin;
File *f_runtime;
File *f_header;
File *f_wrappers;
@ -237,6 +238,7 @@ public:
MODULA3():
empty_string(NewString("")),
swig_types_hash(NULL),
f_begin(NULL),
f_runtime(NULL),
f_header(NULL),
f_wrappers(NULL),
@ -902,11 +904,12 @@ MODULA3():
/* Initialize all of the output files */
outfile = Getattr(n, "outfile");
f_runtime = NewFile(outfile, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@ -916,6 +919,7 @@ MODULA3():
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
@ -956,8 +960,9 @@ MODULA3():
module_imports = NewString("");
upcasts_code = NewString("");
Swig_banner(f_runtime); // Print the SWIG banner message
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGMODULA3\n");
Printf(f_runtime, "\n");
@ -1146,14 +1151,16 @@ MODULA3():
typemapfilename = NULL;
/* Close all of the files */
Dump(f_header, f_runtime);
Dump(f_wrappers, f_runtime);
Wrapper_pretty_print(f_init, f_runtime);
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
Dump(f_wrappers, f_begin);
Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
Close(f_runtime);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
return SWIG_OK;
}

View file

@ -39,6 +39,7 @@ static String *module = 0;
static char *mzscheme_path = (char *) "mzscheme";
static String *init_func_def = 0;
static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_header = 0;
static File *f_wrappers = 0;
@ -129,11 +130,12 @@ public:
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
f_runtime = NewFile(outfile, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@ -141,13 +143,15 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
init_func_def = NewString("");
Swig_register_filebyname("init", init_func_def);
Swig_banner(f_runtime);
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGMZSCHEME\n");
Printf(f_runtime, "\n");
@ -188,14 +192,16 @@ public:
}
/* Close all of the files */
Dump(f_header, f_runtime);
Dump(f_wrappers, f_runtime);
Wrapper_pretty_print(f_init, f_runtime);
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
Dump(f_wrappers, f_begin);
Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
Close(f_runtime);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
return SWIG_OK;
}

View file

@ -38,6 +38,7 @@ static Hash *seen_enumvalues = 0;
static Hash *seen_constructors = 0;
static File *f_header = 0;
static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_wrappers = 0;
static File *f_directors = 0;
@ -214,11 +215,12 @@ public:
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
f_runtime = NewFile(outfile, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@ -247,6 +249,7 @@ public:
Swig_register_filebyname("init", init_func_def);
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("mli", f_mlibody);
Swig_register_filebyname("ml", f_mlbody);
@ -262,8 +265,9 @@ public:
Swig_name_register("get", "%v__get__");
}
Swig_banner(f_runtime);
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGOCAML\n");
Printf(f_runtime, "#define SWIG_MODULE \"%s\"\n", module);
/* Module name */
@ -324,16 +328,18 @@ public:
SwigType_emit_type_table(f_runtime, f_wrappers);
/* Close all of the files */
Dump(f_runtime, f_begin);
Dump(f_directors_h, f_header);
Dump(f_header, f_runtime);
Dump(f_header, f_begin);
Dump(f_directors, f_wrappers);
Dump(f_wrappers, f_runtime);
Wrapper_pretty_print(f_init, f_runtime);
Dump(f_wrappers, f_begin);
Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
Close(f_runtime);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
Dump(f_enumtypes_type, f_mlout);
Dump(f_enumtypes_value, f_mlout);

View file

@ -18,6 +18,7 @@ Octave Options (available with -octave)\n\
class OCTAVE:public Language {
private:
File *f_begin;
File *f_runtime;
File *f_header;
File *f_doc;
@ -37,7 +38,7 @@ private:
Hash *docs;
public:
OCTAVE():f_runtime(0), f_header(0), f_doc(0), f_wrappers(0),
OCTAVE():f_begin(0), f_runtime(0), f_header(0), f_doc(0), f_wrappers(0),
f_init(0), f_initbeforefunc(0), f_directors(0), f_directors_h(0),
s_global_tab(0), s_members_tab(0), class_name(0) {
/* Add code to manage protected constructors and directors */
@ -94,11 +95,12 @@ public:
String *module = Getattr(n, "name");
String *outfile = Getattr(n, "outfile");
f_runtime = NewFile(outfile, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewString("");
f_header = NewString("");
f_doc = NewString("");
f_wrappers = NewString("");
@ -107,6 +109,7 @@ public:
f_directors_h = NewString("");
f_directors = NewString("");
s_global_tab = NewString("");
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("doc", f_doc);
@ -116,8 +119,9 @@ public:
Swig_register_filebyname("director", f_directors);
Swig_register_filebyname("director_h", f_directors_h);
Swig_banner(f_runtime);
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGOCTAVE\n");
Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module);
Printf(f_runtime, "#define SWIG_name %s\n", module);
@ -155,15 +159,16 @@ public:
Printv(f_wrappers, s_global_tab, NIL);
SwigType_emit_type_table(f_runtime, f_wrappers);
Dump(f_header, f_runtime);
Dump(f_doc, f_runtime);
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
Dump(f_doc, f_begin);
if (directorsEnabled()) {
Dump(f_directors_h, f_runtime);
Dump(f_directors, f_runtime);
Dump(f_directors_h, f_begin);
Dump(f_directors, f_begin);
}
Dump(f_wrappers, f_runtime);
Dump(f_initbeforefunc, f_runtime);
Wrapper_pretty_print(f_init, f_runtime);
Dump(f_wrappers, f_begin);
Dump(f_initbeforefunc, f_begin);
Wrapper_pretty_print(f_init, f_begin);
Delete(s_global_tab);
Delete(f_initbeforefunc);
@ -173,8 +178,9 @@ public:
Delete(f_header);
Delete(f_directors);
Delete(f_directors_h);
Close(f_runtime);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
return SWIG_OK;
}

View file

@ -78,6 +78,7 @@ static String *command_tab = 0;
static String *constant_tab = 0;
static String *variable_tab = 0;
static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_header = 0;
static File *f_wrappers = 0;
@ -223,11 +224,12 @@ public:
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
f_runtime = NewFile(outfile, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@ -235,6 +237,7 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
@ -253,8 +256,9 @@ public:
constant_tab = NewString("static swig_constant_info swig_constants[] = {\n");
variable_tab = NewString("static swig_variable_info swig_variables[] = {\n");
Swig_banner(f_runtime);
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGPERL\n");
Printf(f_runtime, "#define SWIG_CASTRANK_MODE\n");
Printf(f_runtime, "\n");
@ -522,14 +526,16 @@ public:
Delete(underscore_module);
/* Close all of the files */
Dump(f_header, f_runtime);
Dump(f_wrappers, f_runtime);
Wrapper_pretty_print(f_init, f_runtime);
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
Dump(f_wrappers, f_begin);
Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
Close(f_runtime);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
return SWIG_OK;
}

View file

@ -71,6 +71,7 @@ static String *prefix = 0;
static String *shadow_classname = 0;
static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_h = 0;
static File *f_phpcode = 0;
@ -259,11 +260,12 @@ public:
String *outfile = Getattr(n, "outfile");
/* main output file */
f_runtime = NewFile(outfile, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewString("");
/* sections of the output file */
s_init = NewString("/* init section */\n");
@ -282,6 +284,7 @@ public:
s_phpclasses = NewString("/* PHP Proxy Classes */\n");
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", s_init);
Swig_register_filebyname("rinit", r_init);
@ -290,8 +293,9 @@ public:
Swig_register_filebyname("header", s_header);
Swig_register_filebyname("wrapper", s_wrappers);
Swig_banner(f_runtime);
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGPHP\n");
Printf(f_runtime, "\n");
@ -316,6 +320,7 @@ public:
Swig_banner(f_phpcode);
Printf(f_phpcode, "\n");
Printf(f_phpcode, "// Try to load our extension if it's not already loaded.\n");
Printf(f_phpcode, "if (!extension_loaded(\"%s\")) {\n", module);
Printf(f_phpcode, " if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {\n");
@ -393,7 +398,7 @@ public:
Swig_banner(f_h);
Printf(f_h, "\n\n");
Printf(f_h, "\n");
Printf(f_h, "#ifndef PHP_%s_H\n", cap_module);
Printf(f_h, "#define PHP_%s_H\n\n", cap_module);
Printf(f_h, "extern zend_module_entry %s_module_entry;\n", module);
@ -522,16 +527,19 @@ public:
Printf(s_wrappers, "/* end wrapper section */\n");
Printf(s_vdecl, "/* end vdecl subsection */\n");
Printv(f_runtime, s_header, s_vdecl, s_wrappers, NIL);
Printv(f_runtime, all_cs_entry, "\n\n", s_entry, "{NULL, NULL, NULL}\n};\n\n", NIL);
Printv(f_runtime, s_init, NIL);
Dump(f_runtime, f_begin);
Printv(f_begin, s_header, s_vdecl, s_wrappers, NIL);
Printv(f_begin, all_cs_entry, "\n\n", s_entry, "{NULL, NULL, NULL}\n};\n\n", NIL);
Printv(f_begin, s_init, NIL);
Delete(s_header);
Delete(s_wrappers);
Delete(s_init);
Delete(s_vdecl);
Delete(all_cs_entry);
Delete(s_entry);
Close(f_runtime);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
Printf(f_phpcode, "%s\n%s\n", pragma_incl, pragma_code);
if (s_fakeoowrappers) {

View file

@ -39,6 +39,7 @@ Pike Options (available with -pike)\n\
class PIKE:public Language {
private:
File *f_begin;
File *f_runtime;
File *f_header;
File *f_wrappers;
@ -69,6 +70,7 @@ public:
* --------------------------------------------------------------------- */
PIKE() {
f_begin = 0;
f_runtime = 0;
f_header = 0;
f_wrappers = 0;
@ -123,11 +125,12 @@ public:
String *outfile = Getattr(n, "outfile");
/* Open the output file */
f_runtime = NewFile(outfile, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewString("");
f_init = NewString("");
f_classInit = NewString("");
f_header = NewString("");
@ -136,13 +139,15 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("classInit", f_classInit);
/* Standard stuff for the SWIG runtime section */
Swig_banner(f_runtime);
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGPIKE\n");
Printf(f_runtime, "\n");
@ -164,17 +169,19 @@ public:
SwigType_emit_type_table(f_runtime, f_wrappers);
/* Close all of the files */
Dump(f_header, f_runtime);
Dump(f_wrappers, f_runtime);
Wrapper_pretty_print(f_init, f_runtime);
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
Dump(f_wrappers, f_begin);
Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
Delete(f_classInit);
Close(f_runtime);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
/* Done */
return SWIG_OK;

View file

@ -28,6 +28,7 @@ static int shadow = 1;
static int use_kw = 0;
static int director_method_index = 0;
static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_runtime_h = 0;
static File *f_header = 0;
@ -513,11 +514,17 @@ public:
String *outfile = Getattr(n, "outfile");
String *outfile_h = !no_header_file ? Getattr(n, "outfile_h") : 0;
f_runtime = NewFile(outfile, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
f_directors_h = NewString("");
f_directors = NewString("");
if (directorsEnabled()) {
if (!no_header_file) {
@ -531,15 +538,10 @@ public:
}
}
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
f_directors_h = NewString("");
f_directors = NewString("");
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("director", f_directors);
@ -548,8 +550,9 @@ public:
const_code = NewString("");
methods = NewString("");
Swig_banner(f_runtime);
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGPYTHON\n");
if (directorsEnabled()) {
@ -641,6 +644,7 @@ public:
if (directorsEnabled()) {
Swig_banner(f_directors_h);
Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module);
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module);
if (dirprot_mode()) {
@ -855,19 +859,20 @@ public:
}
/* Close all of the files */
Dump(f_header, f_runtime);
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
if (directorsEnabled()) {
Dump(f_directors_h, f_runtime_h);
Printf(f_runtime_h, "\n");
Printf(f_runtime_h, "#endif\n");
if (f_runtime_h != f_runtime)
if (f_runtime_h != f_begin)
Close(f_runtime_h);
Dump(f_directors, f_runtime);
Dump(f_directors, f_begin);
}
Dump(f_wrappers, f_runtime);
Wrapper_pretty_print(f_init, f_runtime);
Dump(f_wrappers, f_begin);
Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
@ -875,8 +880,9 @@ public:
Delete(f_directors);
Delete(f_directors_h);
Close(f_runtime);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
return SWIG_OK;
}

View file

@ -424,6 +424,7 @@ protected:
String *sfile;
String *f_init;
String *s_classes;
String *f_begin;
String *f_runtime;
String *f_wrapper;
String *s_header;
@ -487,6 +488,7 @@ R::R() :
sfile(0),
f_init(0),
s_classes(0),
f_begin(0),
f_runtime(0),
f_wrapper(0),
s_header(0),
@ -767,6 +769,7 @@ void R::init() {
sfile = NewString("");
f_init = NewString("");
s_header = NewString("");
f_begin = NewString("");
f_runtime = NewString("");
f_wrapper = NewString("");
s_classes = NewString("");
@ -811,6 +814,7 @@ int R::top(Node *n) {
Swig_register_filebyname("sinit", s_init);
Swig_register_filebyname("sinitroutine", s_init_routine);
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("header", s_header);
@ -818,8 +822,9 @@ int R::top(Node *n) {
Swig_register_filebyname("s", sfile);
Swig_register_filebyname("sclasses", s_classes);
Swig_banner(f_runtime);
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGR\n");
Printf(f_runtime, "\n");
@ -862,7 +867,9 @@ int R::top(Node *n) {
Delete(f_init);
Delete(s_header);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
return SWIG_OK;
}
@ -903,16 +910,10 @@ int R::DumpCode(Node *n) {
SWIG_exit(EXIT_FAILURE);
}
Printf(runtime, "/* Runtime */\n");
Printf(runtime, "%s", f_begin);
Printf(runtime, "%s\n", f_runtime);
Printf(runtime, "/* Header */\n");
Printf(runtime, "%s\n", s_header);
Printf(runtime, "/* Wrapper */\n");
Printf(runtime, "%s\n", f_wrapper);
Printf(runtime, "/* Init code */\n");
Printf(runtime, "%s\n", f_init);
Close(runtime);

View file

@ -158,6 +158,7 @@ private:
File *f_directors;
File *f_directors_h;
File *f_directors_helpers;
File *f_begin;
File *f_runtime;
File *f_runtime_h;
File *f_header;
@ -762,6 +763,7 @@ public:
classes = 0;
klass = 0;
special_methods = 0;
f_begin = 0;
f_runtime = 0;
f_header = 0;
f_wrappers = 0;
@ -992,12 +994,21 @@ public:
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewFile(outfile, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
f_directors_h = NewString("");
f_directors = NewString("");
f_directors_helpers = NewString("");
f_initbeforefunc = NewString("");
if (directorsEnabled()) {
if (!outfile_h) {
Printf(stderr, "Unable to determine outfile_h\n");
@ -1010,17 +1021,10 @@ public:
}
}
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
f_directors_h = NewString("");
f_directors = NewString("");
f_directors_helpers = NewString("");
f_initbeforefunc = NewString("");
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("director", f_directors);
@ -1035,8 +1039,9 @@ public:
registerMagicMethods();
Swig_banner(f_runtime);
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGRUBY\n");
if (directorsEnabled()) {
@ -1060,6 +1065,7 @@ public:
Replaceall(module_macro, "::", "__");
Swig_banner(f_directors_h);
Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_macro);
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_macro);
Printf(f_directors_h, "namespace Swig {\n");
@ -1112,27 +1118,29 @@ public:
SwigType_emit_type_table(f_runtime, f_wrappers);
/* Close all of the files */
Dump(f_header, f_runtime);
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
if (directorsEnabled()) {
Dump(f_directors_helpers, f_runtime);
Dump(f_directors, f_runtime);
Dump(f_directors_helpers, f_begin);
Dump(f_directors, f_begin);
Dump(f_directors_h, f_runtime_h);
Printf(f_runtime_h, "\n");
Printf(f_runtime_h, "#endif\n");
Close(f_runtime_h);
}
Dump(f_wrappers, f_runtime);
Dump(f_initbeforefunc, f_runtime);
Wrapper_pretty_print(f_init, f_runtime);
Dump(f_wrappers, f_begin);
Dump(f_initbeforefunc, f_begin);
Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
Delete(f_initbeforefunc);
Close(f_runtime);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
return SWIG_OK;
}

View file

@ -68,6 +68,7 @@ public:
String *f_sink = NewString("");
Swig_register_filebyname("header", f_sink);
Swig_register_filebyname("wrapper", f_sink);
Swig_register_filebyname("begin", f_sink);
Swig_register_filebyname("runtime", f_sink);
Swig_register_filebyname("init", f_sink);

View file

@ -46,6 +46,7 @@ static int nosafe = 0;
static File *f_header = 0;
static File *f_wrappers = 0;
static File *f_init = 0;
static File *f_begin = 0;
static File *f_runtime = 0;
@ -137,11 +138,12 @@ public:
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
f_runtime = NewFile(outfile, "w", SWIG_output_files());
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@ -149,6 +151,7 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
@ -159,8 +162,9 @@ public:
methods_tab = NewString("");
const_tab = NewString("");
Swig_banner(f_runtime);
Swig_banner(f_begin);
Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGTCL\n");
Printf(f_runtime, "\n");
@ -245,12 +249,15 @@ public:
}
/* Close all of the files */
Printv(f_runtime, f_header, f_wrappers, NIL);
Wrapper_pretty_print(f_init, f_runtime);
Dump(f_runtime, f_begin);
Printv(f_begin, f_header, f_wrappers, NIL);
Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
Close(f_runtime);
Close(f_begin);
Delete(f_runtime);
Delete(f_begin);
return SWIG_OK;
}

View file

@ -237,6 +237,7 @@ int UFFI::top(Node *n) {
}
Swig_register_filebyname("header", f_null);
Swig_register_filebyname("begin", f_null);
Swig_register_filebyname("runtime", f_null);
Swig_register_filebyname("wrapper", f_cl);