All languages now define a macro in the generated C/C++ wrapper file indicating which language is being wrapped, eg #define SWIGJAVA

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11018 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2008-12-30 00:38:34 +00:00
commit 5ec2d8c166
20 changed files with 72 additions and 9 deletions

View file

@ -1,6 +1,12 @@
Version 1.3.37 (in progress) Version 1.3.37 (in progress)
============================ ============================
2008-12-30: wsfulton
Bug #2430756. All the languages now define a macro in the generated C/C++
wrapper file indicating which language is being wrapped. The macro name is the
same as those defined when SWIG is run, eg SWIGJAVA, SWIGOCTAVE, SWIGCSHARP etc
and are listed in the "Conditional Compilation" section in the documentation.
2008-12-23: wsfulton 2008-12-23: wsfulton
[Java] Fix #2153773 - %nojavaexception was clearing the exception feature [Java] Fix #2153773 - %nojavaexception was clearing the exception feature
instead of disabling it. Clearing checked Java exceptions also didn't work. instead of disabling it. Clearing checked Java exceptions also didn't work.

View file

@ -107,7 +107,10 @@ SWIGWIN Defined when running SWIG under Windows
SWIG_VERSION Hexadecimal number containing SWIG version, SWIG_VERSION Hexadecimal number containing SWIG version,
such as 0x010311 (corresponding to SWIG-1.3.11). such as 0x010311 (corresponding to SWIG-1.3.11).
SWIGALLEGROCL Defined when using Allegro CL
SWIGCFFI Defined when using CFFI
SWIGCHICKEN Defined when using CHICKEN SWIGCHICKEN Defined when using CHICKEN
SWIGCLISP Defined when using CLISP
SWIGCSHARP Defined when using C# SWIGCSHARP Defined when using C#
SWIGGUILE Defined when using Guile SWIGGUILE Defined when using Guile
SWIGJAVA Defined when using Java SWIGJAVA Defined when using Java
@ -115,12 +118,14 @@ SWIGLUA Defined when using Lua
SWIGMODULA3 Defined when using Modula-3 SWIGMODULA3 Defined when using Modula-3
SWIGMZSCHEME Defined when using Mzscheme SWIGMZSCHEME Defined when using Mzscheme
SWIGOCAML Defined when using Ocaml SWIGOCAML Defined when using Ocaml
SWIGOCTAVE Defined when using Octave
SWIGPERL Defined when using Perl SWIGPERL Defined when using Perl
SWIGPERL5 Defined when using Perl5 SWIGPERL5 Defined when using Perl5
SWIGPHP Defined when using PHP SWIGPHP Defined when using PHP
SWIGPHP5 Defined when using PHP5 SWIGPHP5 Defined when using PHP5
SWIGPIKE Defined when using Pike SWIGPIKE Defined when using Pike
SWIGPYTHON Defined when using Python SWIGPYTHON Defined when using Python
SWIGR Defined when using R
SWIGRUBY Defined when using Ruby SWIGRUBY Defined when using Ruby
SWIGSEXP Defined when using S-expressions SWIGSEXP Defined when using S-expressions
SWIGTCL Defined when using Tcl SWIGTCL Defined when using Tcl

View file

@ -1618,6 +1618,10 @@ int ALLEGROCL::top(Node *n) {
Swig_register_filebyname("lisphead", f_cl); Swig_register_filebyname("lisphead", f_cl);
Swig_banner(f_runtime); Swig_banner(f_runtime);
Printf(f_runtime, "#define SWIGALLEGROCL\n");
Printf(f_runtime, "\n");
Swig_banner_target_lang(f_cl, ";;"); Swig_banner_target_lang(f_cl, ";;");
Printf(f_cl, "\n" Printf(f_cl, "\n"

View file

@ -162,6 +162,10 @@ int CFFI::top(Node *n) {
Swig_register_filebyname("swiglisp", f_null); Swig_register_filebyname("swiglisp", f_null);
Swig_banner(f_runtime); Swig_banner(f_runtime);
Printf(f_runtime, "#define SWIGCFFI\n");
Printf(f_runtime, "\n");
Swig_banner_target_lang(f_lisp, ";;;"); Swig_banner_target_lang(f_lisp, ";;;");
Language::top(n); Language::top(n);

View file

@ -217,11 +217,13 @@ int CHICKEN::top(Node *n) {
Swig_banner(f_runtime); Swig_banner(f_runtime);
Printf(f_runtime, "/* Implementation : CHICKEN */\n\n"); Printf(f_runtime, "#define SWIGCHICKEN\n");
if (no_collection) if (no_collection)
Printf(f_runtime, "#define SWIG_CHICKEN_NO_COLLECTION 1\n"); Printf(f_runtime, "#define SWIG_CHICKEN_NO_COLLECTION 1\n");
Printf(f_runtime, "\n");
/* Set module name */ /* Set module name */
module = Swig_copy_string(Char(Getattr(n, "name"))); module = Swig_copy_string(Char(Getattr(n, "name")));
scmmodule = NewString(module); scmmodule = NewString(module);

View file

@ -360,6 +360,8 @@ public:
Swig_banner(f_runtime); // Print the SWIG banner message Swig_banner(f_runtime); // Print the SWIG banner message
Printf(f_runtime, "#define SWIGCSHARP\n");
if (directorsEnabled()) { if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n"); Printf(f_runtime, "#define SWIG_DIRECTORS\n");
@ -376,6 +378,8 @@ public:
Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h)); Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h));
} }
Printf(f_runtime, "\n");
Swig_name_register((char *) "wrapper", (char *) "CSharp_%f"); Swig_name_register((char *) "wrapper", (char *) "CSharp_%f");
if (old_variable_names) { if (old_variable_names) {
Swig_name_register((char *) "set", (char *) "set_%v"); Swig_name_register((char *) "set", (char *) "set_%v");

View file

@ -324,7 +324,7 @@ public:
Swig_banner(f_runtime); Swig_banner(f_runtime);
Printf(f_runtime, "/* Implementation : GUILE */\n\n"); Printf(f_runtime, "#define SWIGGUILE\n");
if (!use_scm_interface) { if (!use_scm_interface) {
if (SwigRuntime == 1) if (SwigRuntime == 1)
@ -357,6 +357,8 @@ public:
Printf(f_runtime, "\n}\n"); Printf(f_runtime, "\n}\n");
} }
Printf(f_runtime, "\n");
Language::top(n); Language::top(n);
/* Close module */ /* Close module */

View file

@ -369,6 +369,8 @@ public:
Swig_banner(f_runtime); // Print the SWIG banner message Swig_banner(f_runtime); // Print the SWIG banner message
Printf(f_runtime, "#define SWIGJAVA\n");
if (directorsEnabled()) { if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n"); Printf(f_runtime, "#define SWIG_DIRECTORS\n");
@ -385,6 +387,8 @@ public:
Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h)); Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h));
} }
Printf(f_runtime, "\n");
String *wrapper_name = NewString(""); String *wrapper_name = NewString("");
if (Len(package)) { if (Len(package)) {

View file

@ -250,10 +250,15 @@ public:
/* Standard stuff for the SWIG runtime section */ /* Standard stuff for the SWIG runtime section */
Swig_banner(f_runtime); Swig_banner(f_runtime);
Printf(f_runtime, "#define SWIGLUA\n");
// if (NoInclude) { // if (NoInclude) {
// Printf(f_runtime, "#define SWIG_NOINCLUDE\n"); // Printf(f_runtime, "#define SWIG_NOINCLUDE\n");
// } // }
Printf(f_runtime, "\n");
//String *init_name = NewStringf("%(title)s_Init", module); //String *init_name = NewStringf("%(title)s_Init", module);
//Printf(f_header, "#define SWIG_init %s\n", init_name); //Printf(f_header, "#define SWIG_init %s\n", init_name);
//Printf(f_header, "#define SWIG_name \"%s\"\n", module); //Printf(f_header, "#define SWIG_name \"%s\"\n", module);

View file

@ -958,6 +958,9 @@ MODULA3():
Swig_banner(f_runtime); // Print the SWIG banner message Swig_banner(f_runtime); // Print the SWIG banner message
Printf(f_runtime, "#define SWIGMODULA3\n");
Printf(f_runtime, "\n");
Swig_name_register((char *) "wrapper", (char *) "Modula3_%f"); Swig_name_register((char *) "wrapper", (char *) "Modula3_%f");
if (old_variable_names) { if (old_variable_names) {
Swig_name_register((char *) "set", (char *) "set_%v"); Swig_name_register((char *) "set", (char *) "set_%v");

View file

@ -148,6 +148,9 @@ public:
Swig_banner(f_runtime); Swig_banner(f_runtime);
Printf(f_runtime, "#define SWIGMZSCHEME\n");
Printf(f_runtime, "\n");
module = Getattr(n, "name"); module = Getattr(n, "name");
Language::top(n); Language::top(n);

View file

@ -264,6 +264,7 @@ public:
Swig_banner(f_runtime); Swig_banner(f_runtime);
Printf(f_runtime, "#define SWIGOCAML\n");
Printf(f_runtime, "#define SWIG_MODULE \"%s\"\n", module); Printf(f_runtime, "#define SWIG_MODULE \"%s\"\n", module);
/* Module name */ /* Module name */
Printf(f_mlbody, "let module_name = \"%s\"\n", module); Printf(f_mlbody, "let module_name = \"%s\"\n", module);
@ -281,6 +282,8 @@ public:
Printf(f_runtime, "#define SWIG_DIRECTORS\n"); Printf(f_runtime, "#define SWIG_DIRECTORS\n");
} }
Printf(f_runtime, "\n");
/* Produce the enum_to_int and int_to_enum functions */ /* Produce the enum_to_int and int_to_enum functions */
Printf(f_enumtypes_type, "open Swig\n" "type c_enum_type = [ \n `unknown\n"); Printf(f_enumtypes_type, "open Swig\n" "type c_enum_type = [ \n `unknown\n");

View file

@ -111,10 +111,12 @@ public:
Swig_banner(f_runtime); Swig_banner(f_runtime);
Printf(f_runtime, "#define SWIGOCTAVE\n");
Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module); Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module);
Printf(f_runtime, "#define SWIG_name %s\n", module); Printf(f_runtime, "#define SWIG_name %s\n", module);
if (directorsEnabled()) { if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
Swig_banner(f_directors_h); Swig_banner(f_directors_h);
if (dirprot_mode()) { if (dirprot_mode()) {
// Printf(f_directors_h, "#include <map>\n"); // Printf(f_directors_h, "#include <map>\n");
@ -122,6 +124,7 @@ public:
} }
} }
Printf(f_runtime, "\n");
Printf(s_global_tab, "\nstatic const struct swig_octave_member swig_globals[] = {\n"); Printf(s_global_tab, "\nstatic const struct swig_octave_member swig_globals[] = {\n");
Printf(f_init, "static void SWIG_init_user(octave_swig_type* module_ns)\n{\n"); Printf(f_init, "static void SWIG_init_user(octave_swig_type* module_ns)\n{\n");

View file

@ -256,7 +256,7 @@ public:
Printf(f_runtime, "#define SWIGPERL\n"); Printf(f_runtime, "#define SWIGPERL\n");
Printf(f_runtime, "#define SWIG_CASTRANK_MODE\n"); Printf(f_runtime, "#define SWIG_CASTRANK_MODE\n");
Printf(f_runtime, "\n");
// Is the imported module in another package? (IOW, does it use the // Is the imported module in another package? (IOW, does it use the
// %module(package="name") option and it's different than the package // %module(package="name") option and it's different than the package

View file

@ -264,8 +264,6 @@ public:
SWIG_exit(EXIT_FAILURE); SWIG_exit(EXIT_FAILURE);
} }
Swig_banner(f_runtime);
/* sections of the output file */ /* sections of the output file */
s_init = NewString("/* init section */\n"); s_init = NewString("/* init section */\n");
r_init = NewString("/* rinit section */\n"); r_init = NewString("/* rinit section */\n");
@ -291,6 +289,11 @@ public:
Swig_register_filebyname("header", s_header); Swig_register_filebyname("header", s_header);
Swig_register_filebyname("wrapper", s_wrappers); Swig_register_filebyname("wrapper", s_wrappers);
Swig_banner(f_runtime);
Printf(f_runtime, "#define SWIGPHP\n");
Printf(f_runtime, "\n");
/* Set the module name */ /* Set the module name */
module = Copy(Getattr(n, "name")); module = Copy(Getattr(n, "name"));
cap_module = NewStringf("%(upper)s", module); cap_module = NewStringf("%(upper)s", module);

View file

@ -143,6 +143,9 @@ public:
/* Standard stuff for the SWIG runtime section */ /* Standard stuff for the SWIG runtime section */
Swig_banner(f_runtime); Swig_banner(f_runtime);
Printf(f_runtime, "#define SWIGPIKE\n");
Printf(f_runtime, "\n");
Printf(f_header, "#define SWIG_init pike_module_init\n"); Printf(f_header, "#define SWIG_init pike_module_init\n");
Printf(f_header, "#define SWIG_name \"%s\"\n\n", module); Printf(f_header, "#define SWIG_name \"%s\"\n\n", module);

View file

@ -601,6 +601,8 @@ public:
Printf(f_runtime, "#define SWIG_PYTHON_CLASSIC\n"); Printf(f_runtime, "#define SWIG_PYTHON_CLASSIC\n");
} }
Printf(f_runtime, "\n");
Printf(f_header, "#if (PY_VERSION_HEX <= 0x02000000)\n"); Printf(f_header, "#if (PY_VERSION_HEX <= 0x02000000)\n");
Printf(f_header, "# if !defined(SWIG_PYTHON_CLASSIC)\n"); Printf(f_header, "# if !defined(SWIG_PYTHON_CLASSIC)\n");
Printf(f_header, "# error \"This python version requires swig to be run with the '-classic' option\"\n"); Printf(f_header, "# error \"This python version requires swig to be run with the '-classic' option\"\n");

View file

@ -816,9 +816,14 @@ int R::top(Node *n) {
Swig_register_filebyname("header", s_header); Swig_register_filebyname("header", s_header);
Swig_register_filebyname("wrapper", f_wrapper); Swig_register_filebyname("wrapper", f_wrapper);
Swig_register_filebyname("s", sfile); Swig_register_filebyname("s", sfile);
Swig_register_filebyname("sclasses", s_classes); Swig_register_filebyname("sclasses", s_classes);
Swig_banner(f_runtime);
Printf(f_runtime, "#define SWIGR\n");
Printf(f_runtime, "\n");
Swig_banner_target_lang(s_init, "#"); Swig_banner_target_lang(s_init, "#");
outputCommandLineArguments(s_init); outputCommandLineArguments(s_init);
@ -898,9 +903,6 @@ int R::DumpCode(Node *n) {
SWIG_exit(EXIT_FAILURE); SWIG_exit(EXIT_FAILURE);
} }
Swig_banner(runtime);
Printf(runtime, "/* Runtime */\n"); Printf(runtime, "/* Runtime */\n");
Printf(runtime, "%s\n", f_runtime); Printf(runtime, "%s\n", f_runtime);

View file

@ -1043,6 +1043,8 @@ public:
Printf(f_runtime, "#define SWIG_DIRECTORS\n"); Printf(f_runtime, "#define SWIG_DIRECTORS\n");
} }
Printf(f_runtime, "\n");
/* typedef void *VALUE */ /* typedef void *VALUE */
SwigType *value = NewSwigType(T_VOID); SwigType *value = NewSwigType(T_VOID);
SwigType_add_pointer(value); SwigType_add_pointer(value);

View file

@ -160,6 +160,9 @@ public:
Swig_banner(f_runtime); Swig_banner(f_runtime);
Printf(f_runtime, "#define SWIGTCL\n");
Printf(f_runtime, "\n");
/* Set the module name, namespace, and prefix */ /* Set the module name, namespace, and prefix */
module = NewStringf("%(lower)s", Getattr(n, "name")); module = NewStringf("%(lower)s", Getattr(n, "name"));