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

@ -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;
}