diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index b7e12aada..17514d021 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -212,6 +212,10 @@ A target language is given the 'Experimental' status when

Anyone using an experimental target language is strongly urged to assist with development of the target language module if they wish to use it.

+

+SWIG displays a warning when an experimental target language is used in order to set expectations and emphasize the experimental status of the target language. +The usual warning suppression techniques can be used if required. +

The above is a short summary and further details are outlined in the Experimental status section in the Extending chapter. diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 140090140..968bdbac8 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -534,6 +534,7 @@ example.i(4) : Syntax error in input(1).

  • 521. Illegal destructor name name. Ignored.
  • 522. Use of an illegal constructor name 'name' in %extend is deprecated, the constructor name should be 'name'.
  • 523. Use of an illegal destructor name 'name' in %extend is deprecated, the destructor name should be 'name'. +
  • 524. Experimental target language. Target language language specified by lang is an experimental language. Please read about SWIG experimental languages, htmllink.

    17.9.6 Doxygen comments (560-599)

    diff --git a/Makefile.in b/Makefile.in index 33b712d2c..3394f49dc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -468,7 +468,7 @@ check-maintainer-clean: maintainer-clean $(srcdir)/Lib/swigwarn.swg: $(srcdir)/Source/Include/swigwarn.h mkdir -p Lib - echo "/* SWIG warning codes */" > $@ + echo "/* SWIG warning codes - generated from swigwarn.h - do not edit */" > $@ cat $? | grep "^#define WARN\|/\*.*\*/\|^[ \t]*$$" | sed 's/^#define \(WARN.*[0-9][0-9]*\)\(.*\)$$/%define SWIG\1 %enddef\2/' >> $@ ##################################################################### diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 9f863f194..fde82bd96 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -18,6 +18,8 @@ * Even though symbolic constants are used in the SWIG source, this is * not always the case in SWIG interface files. Do not change the * numbers in this file. + * + * This file is used as the input for generating Lib/swigwarn.swg. * ----------------------------------------------------------------------------- */ #ifndef SWIGWARN_H_ @@ -208,6 +210,7 @@ #define WARN_LANG_ILLEGAL_DESTRUCTOR 521 #define WARN_LANG_EXTEND_CONSTRUCTOR 522 #define WARN_LANG_EXTEND_DESTRUCTOR 523 +#define WARN_LANG_EXPERIMENTAL 524 /* -- Doxygen comments -- */ diff --git a/Source/Makefile.am b/Source/Makefile.am index 74aff08c9..8b76694e8 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -65,9 +65,8 @@ eswig_SOURCES = CParse/cscanner.c \ Modules/lua.cxx \ Modules/main.cxx \ Modules/modula3.cxx \ - Modules/module.cxx \ Modules/mzscheme.cxx \ - Modules/nested.cxx \ + Modules/nested.cxx \ Modules/ocaml.cxx \ Modules/octave.cxx \ Modules/overload.cxx \ @@ -132,7 +131,7 @@ distclean-local: # swig executable as a way of checking before and after the 'beautifying'. # Single files can be beautified with the beautify-file target, eg: 'make beautify-file INDENTFILE=chosenfile.c' -SWIGTYPEDEFS=-T bool -T File -T DohObjInfo -T Parm -T Language -T List -T Typetab -T ModuleFactory -T ErrorMessageFormat -T Symtab -T Hash -T Scanner -T String -T DohBase -T Node -T String_or_char -T SwigType -T Dispatcher -T Wrapper -T DohStringMethods -T DohFileMethods -T DohListMethods -T DohHashMethods -T DOH -T DohIterator -T ParmList -T FILE -T HashNode -T DOHObj_or_char -T DOHFile -T DOHString -T DOHString_or_char -T UpcallData +SWIGTYPEDEFS=-T bool -T File -T DohObjInfo -T Parm -T Language -T List -T TargetLanguageModule -T Typetab -T ModuleFactory -T ErrorMessageFormat -T Symtab -T Hash -T Scanner -T String -T DohBase -T Node -T String_or_char -T SwigType -T Dispatcher -T Wrapper -T DohStringMethods -T DohFileMethods -T DohListMethods -T DohHashMethods -T DOH -T DohIterator -T ParmList -T FILE -T HashNode -T DOHObj_or_char -T DOHFile -T DOHString -T DOHString_or_char -T UpcallData INDENTBAKSDIR=../IndentBaks beautify: diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index e94e36cac..58cc4f7d3 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -459,7 +459,7 @@ static void SWIG_dump_runtime() { SWIG_exit(EXIT_SUCCESS); } -void SWIG_getoptions(int argc, char *argv[]) { +static void getoptions(int argc, char *argv[]) { int i; // Get options for (i = 1; i < argc; i++) { @@ -878,7 +878,7 @@ void SWIG_getoptions(int argc, char *argv[]) { } } -int SWIG_main(int argc, char *argv[], Language *l) { +int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) { char *c; /* Initialize the SWIG core */ @@ -892,7 +892,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { // Set lang to a dummy value if no target language was specified so we // can process options enough to handle -version, etc. - lang = l ? l : new Language; + lang = tlm ? tlm->fac() : new Language; // Set up some default symbols (available in both SWIG interface files // and C files) @@ -956,13 +956,13 @@ int SWIG_main(int argc, char *argv[], Language *l) { /* Check for SWIG_FEATURES environment variable */ - SWIG_getoptions(argc, argv); + getoptions(argc, argv); // Define the __cplusplus symbol if (CPlusPlus) Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0); - if (!l) { + if (!tlm) { Printf(stderr, "No target language specified\n"); return 1; } @@ -1312,6 +1312,13 @@ int SWIG_main(int argc, char *argv[], Language *l) { // Check the extension for a c/c++ file. If so, we're going to declare everything we see as "extern" ForceExtern = check_extension(input_file); + if (tlm->status == Experimental) { + Swig_warning(WARN_LANG_EXPERIMENTAL, "SWIG", 1, "Experimental target language. " + "Target language %s specified by %s is an experimental language. " + "Please read about SWIG experimental languages, http://swig.org/Doc4.0/Introduction.html#Introduction_experimental_status.\n", + tlm->help ? tlm->help : "", tlm->name); + } + lang->top(top); if (browse) { diff --git a/Source/Modules/module.cxx b/Source/Modules/module.cxx deleted file mode 100644 index aa48689ab..000000000 --- a/Source/Modules/module.cxx +++ /dev/null @@ -1,59 +0,0 @@ -/* ----------------------------------------------------------------------------- - * This file is part of SWIG, which is licensed as a whole under version 3 - * (or any later version) of the GNU General Public License. Some additional - * terms also apply to certain portions of SWIG. The full details of the SWIG - * license and copyrights can be found in the LICENSE and COPYRIGHT files - * included with the SWIG source code as distributed by the SWIG developers - * and at http://www.swig.org/legal.html. - * - * module.cxx - * - * This file is responsible for the module system. - * ----------------------------------------------------------------------------- */ - -#include "swigmod.h" - -struct Module { - ModuleFactory fac; - char *name; - Module *next; - Module(const char *n, ModuleFactory f) { - fac = f; - name = new char[strlen(n) + 1]; - strcpy(name, n); - next = 0; - } ~Module() { - delete[]name; - } -}; - -static Module *modules = 0; - -/* ----------------------------------------------------------------------------- - * void Swig_register_module() - * - * Register a module. - * ----------------------------------------------------------------------------- */ - -void Swig_register_module(const char *n, ModuleFactory f) { - Module *m = new Module(n, f); - m->next = modules; - modules = m; -} - -/* ----------------------------------------------------------------------------- - * Language *Swig_find_module() - * - * Given a command line option, locates the factory function. - * ----------------------------------------------------------------------------- */ - -ModuleFactory Swig_find_module(const char *name) { - Module *m = modules; - while (m) { - if (strcmp(m->name, name) == 0) { - return m->fac; - } - m = m->next; - } - return 0; -} diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index aaf6de7a8..6f91c083e 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -26,79 +26,73 @@ can be dynamically loaded in future versions. */ extern "C" { - Language *swig_tcl(void); - Language *swig_python(void); - Language *swig_perl5(void); - Language *swig_ruby(void); + Language *swig_allegrocl(void); + Language *swig_cffi(void); + Language *swig_chicken(void); + Language *swig_clisp(void); + Language *swig_csharp(void); + Language *swig_d(void); + Language *swig_go(void); Language *swig_guile(void); + Language *swig_java(void); + Language *swig_javascript(void); + Language *swig_lua(void); Language *swig_modula3(void); Language *swig_mzscheme(void); - Language *swig_java(void); + Language *swig_ocaml(void); + Language *swig_octave(void); + Language *swig_perl5(void); Language *swig_php(void); Language *swig_php4(void); Language *swig_php5(void); - Language *swig_ocaml(void); - Language *swig_octave(void); Language *swig_pike(void); - Language *swig_sexp(void); - Language *swig_xml(void); - Language *swig_chicken(void); - Language *swig_csharp(void); - Language *swig_allegrocl(void); - Language *swig_lua(void); - Language *swig_clisp(void); - Language *swig_cffi(void); - Language *swig_uffi(void); + Language *swig_python(void); Language *swig_r(void); + Language *swig_ruby(void); Language *swig_scilab(void); - Language *swig_go(void); - Language *swig_d(void); - Language *swig_javascript(void); + Language *swig_sexp(void); + Language *swig_tcl(void); + Language *swig_uffi(void); + Language *swig_xml(void); } -struct swig_module { - const char *name; - ModuleFactory fac; - const char *help; -}; - /* Association of command line options to language modules. Place an entry for new language modules here, keeping the list sorted alphabetically. */ -static swig_module modules[] = { - {"-allegrocl", swig_allegrocl, "ALLEGROCL"}, - {"-chicken", swig_chicken, "CHICKEN"}, - {"-clisp", swig_clisp, "CLISP"}, - {"-cffi", swig_cffi, "CFFI"}, - {"-csharp", swig_csharp, "C#"}, - {"-d", swig_d, "D"}, - {"-go", swig_go, "Go"}, - {"-guile", swig_guile, "Guile"}, - {"-java", swig_java, "Java"}, - {"-javascript", swig_javascript, "Javascript"}, - {"-lua", swig_lua, "Lua"}, - {"-modula3", swig_modula3, "Modula 3"}, - {"-mzscheme", swig_mzscheme, "Mzscheme"}, - {"-ocaml", swig_ocaml, "Ocaml"}, - {"-octave", swig_octave, "Octave"}, - {"-perl", swig_perl5, "Perl"}, - {"-perl5", swig_perl5, 0}, - {"-php", swig_php, 0}, - {"-php4", swig_php4, 0}, - {"-php5", swig_php5, 0}, - {"-php7", swig_php, "PHP7"}, - {"-pike", swig_pike, "Pike"}, - {"-python", swig_python, "Python"}, - {"-r", swig_r, "R (aka GNU S)"}, - {"-ruby", swig_ruby, "Ruby"}, - {"-scilab", swig_scilab, "Scilab"}, - {"-sexp", swig_sexp, "Lisp S-Expressions"}, - {"-tcl", swig_tcl, "Tcl"}, - {"-tcl8", swig_tcl, 0}, - {"-uffi", swig_uffi, "Common Lisp / UFFI"}, - {"-xml", swig_xml, "XML"}, - {NULL, NULL, NULL} +static TargetLanguageModule modules[] = { + {"-allegrocl", swig_allegrocl, "ALLEGROCL", Supported}, + {"-chicken", swig_chicken, "CHICKEN", Supported}, + {"-clisp", swig_clisp, "CLISP", Supported}, + {"-cffi", swig_cffi, "CFFI", Supported}, + {"-csharp", swig_csharp, "C#", Supported}, + {"-d", swig_d, "D", Supported}, + {"-go", swig_go, "Go", Supported}, + {"-guile", swig_guile, "Guile", Supported}, + {"-java", swig_java, "Java", Supported}, + {"-javascript", swig_javascript, "Javascript", Supported}, + {"-lua", swig_lua, "Lua", Supported}, + {"-modula3", swig_modula3, "Modula 3", Supported}, + {"-mzscheme", swig_mzscheme, "Mzscheme", Supported}, + {"-ocaml", swig_ocaml, "Ocaml", Supported}, + {"-octave", swig_octave, "Octave", Supported}, + {"-perl", swig_perl5, "Perl", Supported}, + {"-perl5", swig_perl5, NULL, Supported}, + {"-php", swig_php, NULL, Supported}, + {"-php4", swig_php4, NULL, Supported}, + {"-php5", swig_php5, NULL, Supported}, + {"-php7", swig_php, "PHP7", Supported}, + {"-pike", swig_pike, "Pike", Supported}, + {"-python", swig_python, "Python", Supported}, + {"-r", swig_r, "R (aka GNU S)", Supported}, + {"-ruby", swig_ruby, "Ruby", Supported}, + {"-scilab", swig_scilab, "Scilab", Supported}, + {"-sexp", swig_sexp, "Lisp S-Expressions", Supported}, + {"-tcl", swig_tcl, "Tcl", Supported}, + {"-tcl8", swig_tcl, NULL, Supported}, + {"-uffi", swig_uffi, "Common Lisp / UFFI", Supported}, + {"-xml", swig_xml, "XML", Supported}, + {NULL, NULL, NULL, Disabled} }; #ifdef MACSWIG @@ -230,8 +224,7 @@ static void merge_options_files(int *argc, char ***argv) { int main(int margc, char **margv) { int i; - Language *dl = 0; - ModuleFactory fac = 0; + const TargetLanguageModule *language_module = 0; int argc; char **argv; @@ -244,26 +237,40 @@ int main(int margc, char **margv) { argc = ccommand(&argv); #endif - /* Register built-in modules */ - for (i = 0; modules[i].name; i++) { - Swig_register_module(modules[i].name, modules[i].fac); - } - Swig_init_args(argc, argv); /* Get options */ for (i = 1; i < argc; i++) { if (argv[i]) { - fac = Swig_find_module(argv[i]); - if (fac) { - dl = (fac) (); + bool is_target_language_module = false; + for (int j = 0; modules[j].name; j++) { + if (strcmp(modules[j].name, argv[i]) == 0) { + language_module = &modules[j]; + is_target_language_module = true; + break; + } + } + if (is_target_language_module) { Swig_mark_arg(i); + if (language_module->status == Disabled) { + if (language_module->help) + Printf(stderr, "Target language option %s (%s) is no longer supported.\n", language_module->name, language_module->help); + else + Printf(stderr, "Target language option %s is no longer supported.\n", language_module->name); + SWIG_exit(EXIT_FAILURE); + } } else if ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "--help") == 0)) { if (strcmp(argv[i], "--help") == 0) strcpy(argv[i], "-help"); - Printf(stdout, "Target Language Options\n"); + Printf(stdout, "Supported Target Language Options\n"); for (int j = 0; modules[j].name; j++) { - if (modules[j].help) { + if (modules[j].help && modules[j].status == Supported) { + Printf(stdout, " %-15s - Generate %s wrappers\n", modules[j].name, modules[j].help); + } + } + Printf(stdout, "\nExperimental Target Language Options\n"); + for (int j = 0; modules[j].name; j++) { + if (modules[j].help && modules[j].status == Experimental) { Printf(stdout, " %-15s - Generate %s wrappers\n", modules[j].name, modules[j].help); } } @@ -272,7 +279,7 @@ int main(int margc, char **margv) { } } - int res = SWIG_main(argc, argv, dl); + int res = SWIG_main(argc, argv, language_module); return res; } diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 9626166a6..ef49c5684 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -354,7 +354,21 @@ private: static Language *this_; }; -int SWIG_main(int, char **, Language *); +extern "C" { + void SWIG_typemap_lang(const char *); + typedef Language *(*ModuleFactory) (void); +} + +enum Status {Disabled, Experimental, Supported}; + +struct TargetLanguageModule { + const char *name; + ModuleFactory fac; + const char *help; + Status status; +}; + +int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm); void emit_parameter_variables(ParmList *l, Wrapper *f); void emit_return_variable(Node *n, SwigType *rt, Wrapper *f); void SWIG_exit(int); /* use EXIT_{SUCCESS,FAILURE} */ @@ -391,14 +405,6 @@ void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f); void Swig_director_parms_fixup(ParmList *parms); /* directors.cxx end */ -extern "C" { - void SWIG_typemap_lang(const char *); - typedef Language *(*ModuleFactory) (void); -} - -void Swig_register_module(const char *name, ModuleFactory fac); -ModuleFactory Swig_find_module(const char *name); - /* Utilities */ int is_public(Node *n);