diff --git a/SWIG/CHANGES.current b/SWIG/CHANGES.current index d4e3e0762..62c0b1ce8 100644 --- a/SWIG/CHANGES.current +++ b/SWIG/CHANGES.current @@ -1,5 +1,94 @@ Version 1.3.20 (In progress) ============================ +12/11/2003: mmatus (Marcelo Matus) + + "All keywords" warning support, through the -DSWIG_ALLKW + option. + + This option allows you to include all the known keywords + for all the supported languages, and can be used as: + + swig -DSWIG_ALLKW .... + + This will help to the process of adding a test-suite file + that can be compiled in all the swig supported languages, + and it will be also helpful for users who want to create + multi-language libraries. + + These are the changes (mostly addition of files): + + - For the language that already has some sort of keyword + list warning, move them to an external file kw.swg file: + + move keywords from python.swg -> pythonkw.swg + move keywords from chicken.swg -> chickenkw.swg + + and include pythonkw.swg from python.swg, and etc. + + - For the language that has no keyword list, and for the + ones that I could find a list, add the kw.swg file, ie: + + csharp/csharpkw.swg + java/javakw.swg + php4/phpkw.swg + pike/pikekw.swg + ruby/rubykw.swg + + + add a line in java.swg to include javakw.swg, and so on + for all the other languages, but now it is commented!!!, + like in java.swg: + + /* java keywords */ + /* please test and activate */ + //%include "javakw.swg" + + ie, there will be no change in how swig runs normally + until the language mantainer test and uncomment that line. + + So, please check each kw.swg file (I left the link + source of the keyword list), and after testing, allow + its inclusion. + + - Added the file allkw.swg, which includes all the kw.swg + files. + + For the languages that has no kw.swg file right now, and + if they need one, add it into the language directory, + and add a line into allkw.swg to include it from here. + + - Includes allkw.swg at the end of swig.swg if the option + SWIG_ALLKW is defined. The old -lallkw.swg option + couldn't be used since it include the file after it + would be needed. + + + Maybe there is a better name for the option, and been a + defined, it looks kind of ugly. Maybe is better to + translate it into a command line option... any ideas?. + + In any way, the ideal situation will be that this option + is added to the default rules in the related test-suite + Makefiles, so, when creating a new test, swig will always + warn you if you are using a bad name, considering all + the language where it needs to run. + + Right now you can test it by using: + + make check-python-test-suite SWIG="swig -DSWIG_ALLKW" + + or using your favorite target language. + + And yes, there are several examples that are using some + reserved keyword, specially from csharp. + + Remember: the keyword warnings are not included by default + in any of language that before didn't define its own + keyword list. To enable them as the default behaviour, + the inclusion of the kw.swg file has to be uncommented at + each language.swg file. + + 12/11/2003: cheetah (William Fulton) SF bug #854634 Added support for accepting the Unix directory separator '/' on diff --git a/SWIG/Lib/allkw.swg b/SWIG/Lib/allkw.swg new file mode 100644 index 000000000..5f18bdd95 --- /dev/null +++ b/SWIG/Lib/allkw.swg @@ -0,0 +1,29 @@ +#ifndef __Lib_allkw_swg__ +#define __Lib_allkw_swg__ + + +/* + Include all the known keyword warnings. Very useful for adding test + files to the test-suite, or check if your own library is ok for all + the swig supported languages. + + Use as + + swig -DSWIG_ALLKW ... + + If you add a new language, remember to create a separete kw.swg + file, and add it here. + +*/ + +%include "chicken/chickenkw.swg" +%include "csharp/csharpkw.swg" +%include "java/javakw.swg" +%include "php4/phpkw.swg" +%include "pike/pikekw.swg" +%include "python/pythonkw.swg" +%include "ruby/rubykw.swg" +%include "tcl/tclkw.swg" + + +#endif //__Lib_allkw_swg__ diff --git a/SWIG/Lib/chicken/chicken.swg b/SWIG/Lib/chicken/chicken.swg index b48cbeeca..1095f4f33 100644 --- a/SWIG/Lib/chicken/chicken.swg +++ b/SWIG/Lib/chicken/chicken.swg @@ -611,31 +611,8 @@ $result = C_SCHEME_UNDEFINED; %ignorewarn("389:operator[] ignored (consider using %extend)") operator[]; #endif - -/* Warnings for certain CHICKEN keywords. From Section 7.1.1 of - Revised^5 Report on the Algorithmic Language Scheme */ -#define CHICKW(x) %namewarn("314:" #x " is a R^5RS syntatic keyword") #x - -CHICKW(else); -CHICKW(=>); -CHICKW(define); -CHICKW(unquote); -CHICKW(unquote-splicing); -CHICKW(quote); -CHICKW(lambda); -CHICKW(if); -CHICKW(set!); -CHICKW(begin); -CHICKW(cond); -CHICKW(and); -CHICKW(or); -CHICKW(case); -CHICKW(let); -CHICKW(let*); -CHICKW(letrec); -CHICKW(do); -CHICKW(delay); -CHICKW(quasiquote); +/* Warnings for certain CHICKEN keywords */ +%include "chickenkw.swg" /* TinyCLOS <--> Low-level CHICKEN */ diff --git a/SWIG/Lib/chicken/chickenkw.swg b/SWIG/Lib/chicken/chickenkw.swg new file mode 100644 index 000000000..b164a2e77 --- /dev/null +++ b/SWIG/Lib/chicken/chickenkw.swg @@ -0,0 +1,30 @@ +#ifndef __chicken_chickenkw_swg__ +#define __chicken_chickenkw_swg__ + +/* Warnings for certain CHICKEN keywords. From Section 7.1.1 of + Revised^5 Report on the Algorithmic Language Scheme */ +#define CHICKW(x) %namewarn("314:" #x " is a R^5RS syntatic keyword") #x + +CHICKW(else); +CHICKW(=>); +CHICKW(define); +CHICKW(unquote); +CHICKW(unquote-splicing); +CHICKW(quote); +CHICKW(lambda); +CHICKW(if); +CHICKW(set!); +CHICKW(begin); +CHICKW(cond); +CHICKW(and); +CHICKW(or); +CHICKW(case); +CHICKW(let); +CHICKW(let*); +CHICKW(letrec); +CHICKW(do); +CHICKW(delay); +CHICKW(quasiquote); + + +#endif //__chicken_chickenkw_swg__ diff --git a/SWIG/Lib/csharp/csharpkw.swg b/SWIG/Lib/csharp/csharpkw.swg new file mode 100644 index 000000000..dd0e1b1df --- /dev/null +++ b/SWIG/Lib/csharp/csharpkw.swg @@ -0,0 +1,93 @@ +#ifndef __csharp_csharpkw_swg__ +#define __csharp_csharpkw_swg__ + +/* Warnings for Csharp keywords */ +#define CSHARPKW(x) %namewarn("314:" #x " is a csharp keyword") #x + +/* + from + http://www.jaggersoft.com/csharp_grammar.html#1.7%20Keywords + +*/ + +CSHARPKW(abstract); +CSHARPKW(as); +CSHARPKW(base); +CSHARPKW(bool); +CSHARPKW(break); +CSHARPKW(byte); +CSHARPKW(case); +CSHARPKW(catch); +CSHARPKW(char); +CSHARPKW(checked); +CSHARPKW(class); +CSHARPKW(const); +CSHARPKW(continue); +CSHARPKW(decimal); +CSHARPKW(default); +CSHARPKW(delegate); +CSHARPKW(do); +CSHARPKW(double); +CSHARPKW(else); +CSHARPKW(enum); +CSHARPKW(event); +CSHARPKW(explicit); +CSHARPKW(extern); +CSHARPKW(false); +CSHARPKW(finally); +CSHARPKW(fixed); +CSHARPKW(float); +CSHARPKW(for); +CSHARPKW(foreach); +CSHARPKW(goto); +CSHARPKW(if); +CSHARPKW(implicit); +CSHARPKW(in); +CSHARPKW(int); +CSHARPKW(interface); +CSHARPKW(internal); +CSHARPKW(is); +CSHARPKW(lock); +CSHARPKW(long); +CSHARPKW(namespace); +CSHARPKW(new); +CSHARPKW(null); +CSHARPKW(object); +CSHARPKW(operator); +CSHARPKW(out); +CSHARPKW(override); +CSHARPKW(params); +CSHARPKW(private); +CSHARPKW(protected); +CSHARPKW(public); +CSHARPKW(readonly); +CSHARPKW(ref); +CSHARPKW(return); +CSHARPKW(sbyte); +CSHARPKW(sealed); +CSHARPKW(short); +CSHARPKW(sizeof); +CSHARPKW(stackalloc); +CSHARPKW(static); +CSHARPKW(struct); +CSHARPKW(switch); +CSHARPKW(this); +CSHARPKW(throw); +CSHARPKW(true); +CSHARPKW(try); +CSHARPKW(typeof); +CSHARPKW(uint); +CSHARPKW(ulong); +CSHARPKW(unchecked); +CSHARPKW(unsafe); +CSHARPKW(ushort); +CSHARPKW(using); +CSHARPKW(virtual); +CSHARPKW(void); +CSHARPKW(volatile); +CSHARPKW(while); + +/* swig seems to managing this one right */ +// CSHARPKW(string); + +#endif //__csharp_csharpkw_swg__ diff --git a/SWIG/Lib/java/java.swg b/SWIG/Lib/java/java.swg index 239b030c4..a82be2f63 100644 --- a/SWIG/Lib/java/java.swg +++ b/SWIG/Lib/java/java.swg @@ -936,3 +936,6 @@ %apply long { size_t }; +/* java keywords */ +/* please test and activate */ +//%include "javakw.swg" diff --git a/SWIG/Lib/java/javakw.swg b/SWIG/Lib/java/javakw.swg new file mode 100644 index 000000000..5a5c1cbef --- /dev/null +++ b/SWIG/Lib/java/javakw.swg @@ -0,0 +1,67 @@ +#ifndef __java_javakw_swg__ +#define __java_javakw_swg__ + +/* Warnings for Java keywords */ +#define JAVAKW(x) %namewarn("314:" #x " is a java keyword") #x + +/* + from + http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html +*/ + +JAVAKW(abstract); +JAVAKW(double); +JAVAKW(int); +JAVAKW(strictfp); +JAVAKW(boolean); +JAVAKW(else); +JAVAKW(interface); +JAVAKW(super); +JAVAKW(break); +JAVAKW(extends); +JAVAKW(long); +JAVAKW(switch); +JAVAKW(byte); +JAVAKW(final); +JAVAKW(native); +JAVAKW(synchronized); +JAVAKW(case); +JAVAKW(finally); +JAVAKW(new); +JAVAKW(this); +JAVAKW(catch); +JAVAKW(float); +JAVAKW(package); +JAVAKW(throw); +JAVAKW(char); +JAVAKW(for); +JAVAKW(private); +JAVAKW(throws); +JAVAKW(class); +JAVAKW(goto); +JAVAKW(protected); +JAVAKW(transient); +JAVAKW(const); +JAVAKW(if); +JAVAKW(public); +JAVAKW(try); +JAVAKW(continue); +JAVAKW(implements); +JAVAKW(return); +JAVAKW(void); +JAVAKW(default); +JAVAKW(import); +JAVAKW(short); +JAVAKW(volatile); +JAVAKW(do); +JAVAKW(instanceof); +JAVAKW(static); +JAVAKW(while); + + +/* others bad names */ + +// Not really sure about this, but sometimes it produce problems +// %namewarn("314:clone is a java reserved method name") *::clone; + +#endif //__java_javakw_swg__ diff --git a/SWIG/Lib/php4/php4.swg b/SWIG/Lib/php4/php4.swg index 99d6ebbd2..16596417d 100644 --- a/SWIG/Lib/php4/php4.swg +++ b/SWIG/Lib/php4/php4.swg @@ -497,3 +497,7 @@ deliberate error cos this code looks bogus to me /* Some ANSI C typemaps */ %apply long { size_t }; + +/* php kewords */ +/* please test and activate */ +//%include "phpkw.swg" diff --git a/SWIG/Lib/php4/phpkw.swg b/SWIG/Lib/php4/phpkw.swg new file mode 100644 index 000000000..ee2bcca95 --- /dev/null +++ b/SWIG/Lib/php4/phpkw.swg @@ -0,0 +1,89 @@ +#ifndef __php_phpkw_swg__ +#define __php_phpkw_swg__ + +/* Warnings for Php keywords */ +#define PHPKW(x) %namewarn("314:" #x " is a php keyword") #x + +/* + from + http://aspn.activestate.com/ASPN/docs/PHP/reserved.html + +*/ + + +PHPKW(and); +PHPKW($argc); +PHPKW($argv); +PHPKW(as); +PHPKW(break); +PHPKW(case); +PHPKW(cfunction); +PHPKW(class); +PHPKW(continue); +PHPKW(declare); +PHPKW(default); +PHPKW(die); +PHPKW(do); +PHPKW(E_ALL); +PHPKW(echo); +PHPKW(E_ERROR); +PHPKW(else); +PHPKW(elseif); +PHPKW(enddeclare); +PHPKW(endfor); +PHPKW(endforeach); +PHPKW(endif); +PHPKW(endswitch); +PHPKW(endwhile); +PHPKW(E_PARSE); +PHPKW(eval); +PHPKW(E_WARNING); +PHPKW(exit); +PHPKW(extends); +PHPKW(FALSE); +PHPKW(__FILE__); +PHPKW(for); +PHPKW(foreach); +PHPKW(function); +PHPKW(global); +PHPKW($HTTP_COOKIE_VARS); +PHPKW($HTTP_ENV_VARS); +PHPKW($HTTP_GET_VARS); +PHPKW($HTTP_POST_FILES); +PHPKW($HTTP_POST_VARS); +PHPKW($HTTP_SERVER_VARS); +PHPKW(if); +PHPKW(include); +PHPKW(include_once); +PHPKW(__LINE__); +PHPKW(list); +PHPKW(new); +PHPKW(not); +PHPKW(NULL); +PHPKW(old_function); +PHPKW(or); +PHPKW(parent); +PHPKW(PHP_OS); +PHPKW($PHP_SELF); +PHPKW(PHP_VERSION); +PHPKW(print); +PHPKW(require); +PHPKW(require_once); +PHPKW(return); +PHPKW(__sleep); +PHPKW(static); +PHPKW(stdClass); +PHPKW(switch); +PHPKW($this); +PHPKW(TRUE); +PHPKW(var); +PHPKW(virtual); +PHPKW(__wakeup); +PHPKW(while); +PHPKW(xor); + + +// This is conflicting with _std_deque.i!. +PHPKW(empty); + +#endif //__php_phpkw_swg__ diff --git a/SWIG/Lib/pike/pike.swg b/SWIG/Lib/pike/pike.swg index 592d6c152..4a8fb986e 100644 --- a/SWIG/Lib/pike/pike.swg +++ b/SWIG/Lib/pike/pike.swg @@ -334,3 +334,7 @@ PIKE_MODULE_INIT swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]); } %} + +/* pike keywords */ +/* please test and activate */ +//%include "pikekw.swg" diff --git a/SWIG/Lib/pike/pikekw.swg b/SWIG/Lib/pike/pikekw.swg new file mode 100644 index 000000000..1bcfbb61b --- /dev/null +++ b/SWIG/Lib/pike/pikekw.swg @@ -0,0 +1,54 @@ +#ifndef __pike_pikekw_swg__ +#define __pike_pikekw_swg__ + +/* Warnings for Pike keywords */ +#define PIKEKW(x) %namewarn("314:" #x " is a pike keyword") #x + +/* + from + http://www.http://docs.linux.cz/pike/tutorial_C.html + +*/ + + +PIKEKW(array); +PIKEKW(break); +PIKEKW(case); +PIKEKW(catch); +PIKEKW(continue); +PIKEKW(default); +PIKEKW(do); +PIKEKW(else); +PIKEKW(float); +PIKEKW(for); +PIKEKW(foreach); +PIKEKW(function); +PIKEKW(gauge); +PIKEKW(if); +PIKEKW(inherit); +PIKEKW(inline); +PIKEKW(int); +PIKEKW(lambda); +PIKEKW(mapping); +PIKEKW(mixed); +PIKEKW(multiset); +PIKEKW(nomask); +PIKEKW(object); +PIKEKW(predef); +PIKEKW(private); +PIKEKW(program); +PIKEKW(protected); +PIKEKW(public); +PIKEKW(return); +PIKEKW(sscanf); +PIKEKW(static); +PIKEKW(switch); +PIKEKW(typeof); +PIKEKW(varargs); +PIKEKW(void); +PIKEKW(while); + +// Swig manages this one right +// PIKEKW(string); + +#endif //__pike_pikekw_swg__ diff --git a/SWIG/Lib/python/python.swg b/SWIG/Lib/python/python.swg index f79ad67c3..8f05eae37 100644 --- a/SWIG/Lib/python/python.swg +++ b/SWIG/Lib/python/python.swg @@ -742,38 +742,8 @@ DIRECTOROUT_TYPEMAP(std::size_t, PyInt_AsLong); #endif -/* Warnings for certain Python keywords */ -#define PYKW(x) %namewarn("314:" #x " is a python keyword") #x - -PYKW(and); -PYKW(assert); -PYKW(break); -PYKW(class); -PYKW(continue); -PYKW(def); -PYKW(del); -PYKW(elif); -PYKW(else); -PYKW(except); -PYKW(exec); -PYKW(finally); -PYKW(for); -PYKW(from); -PYKW(global); -PYKW(if); -PYKW(import); -PYKW(in); -PYKW(is); -PYKW(lambda); -PYKW(not); -PYKW(or); -PYKW(pass); -PYKW(print); -PYKW(raise); -PYKW(return); -PYKW(try); -PYKW(while); - +/* Warnings for Python keywords */ +%include "pythonkw.swg" /* The start of the Python initialization function */ diff --git a/SWIG/Lib/python/pythonkw.swg b/SWIG/Lib/python/pythonkw.swg new file mode 100644 index 000000000..c8e95574d --- /dev/null +++ b/SWIG/Lib/python/pythonkw.swg @@ -0,0 +1,37 @@ +#ifndef __python_pythonkw_swg__ +#define __python_pythonkw_swg__ + +/* Warnings for Python keywords */ +#define PYKW(x) %namewarn("314:" #x " is a python keyword") #x + +PYKW(and); +PYKW(assert); +PYKW(break); +PYKW(class); +PYKW(continue); +PYKW(def); +PYKW(del); +PYKW(elif); +PYKW(else); +PYKW(except); +PYKW(exec); +PYKW(finally); +PYKW(for); +PYKW(from); +PYKW(global); +PYKW(if); +PYKW(import); +PYKW(in); +PYKW(is); +PYKW(lambda); +PYKW(not); +PYKW(or); +PYKW(pass); +PYKW(print); +PYKW(raise); +PYKW(return); +PYKW(try); +PYKW(while); + + +#endif //__python_pythonkw_swg__ diff --git a/SWIG/Lib/ruby/ruby.swg b/SWIG/Lib/ruby/ruby.swg index 805ace816..04b2cc9ab 100644 --- a/SWIG/Lib/ruby/ruby.swg +++ b/SWIG/Lib/ruby/ruby.swg @@ -630,4 +630,8 @@ typedef unsigned long VALUE; %ignorewarn("386:operator->* ignored") operator->*; %ignorewarn("389:operator[] ignored (consider using %extend)") operator[]; +/* ruby keywords */ +/* please test and activate */ +// %include "rubykw.swg" + #endif /* __cplusplus */ diff --git a/SWIG/Lib/ruby/rubykw.swg b/SWIG/Lib/ruby/rubykw.swg new file mode 100644 index 000000000..fd4f0f542 --- /dev/null +++ b/SWIG/Lib/ruby/rubykw.swg @@ -0,0 +1,56 @@ +#ifndef __ruby_rubykw_swg__ +#define __ruby_rubykw_swg__ + +/* Warnings for Ruby keywords */ +#define RUBYKW(x) %namewarn("314:" #x " is a ruby keyword") #x + + +/* + + from + http://www.ruby-lang.org/en/man-1.4/syntax.html#resword + +*/ + +RUBYKW(BEGIN); +RUBYKW(class); +RUBYKW(ensure); +RUBYKW(nil); +RUBYKW(self); +RUBYKW(when); +RUBYKW(END); +RUBYKW(def); +RUBYKW(false); +RUBYKW(not); +RUBYKW(super); +RUBYKW(while); +RUBYKW(alias); +RUBYKW(for); +RUBYKW(or); +RUBYKW(then); +RUBYKW(yield); +RUBYKW(and); +RUBYKW(do); +RUBYKW(if); +RUBYKW(redo); +RUBYKW(true); +RUBYKW(begin); +RUBYKW(else); +RUBYKW(in); +RUBYKW(rescue); +RUBYKW(undef); +RUBYKW(break); +RUBYKW(elsif); +RUBYKW(module); +RUBYKW(retry); +RUBYKW(unless); +RUBYKW(case); +RUBYKW(end); +RUBYKW(next); +RUBYKW(return); +RUBYKW(until); + +/* swig doesn't like this one */ +// RUBYKW(defined); + +#endif //__ruby_rubykw_swg__ diff --git a/SWIG/Lib/swig.swg b/SWIG/Lib/swig.swg index 6e122080a..be485ac18 100644 --- a/SWIG/Lib/swig.swg +++ b/SWIG/Lib/swig.swg @@ -396,3 +396,22 @@ static int NAME(TYPE x) { %enddef +/* + Include all the known keyword warnings. Very useful for adding test + files to the test-suite, or check if your own library is OK for all + the swig supported languages. + + Use as + + swig -DSWIG_ALLKW ... + + Note that this is not equivalent to + + swig -lallkw.swg + + the last form will have no effect since allkw.swg will be included + to late. +*/ +#ifdef SWIG_ALLKW +%include "allkw.swg" +#endif diff --git a/SWIG/Lib/tcl/tcl8.swg b/SWIG/Lib/tcl/tcl8.swg index 838058775..8c7b050e3 100644 --- a/SWIG/Lib/tcl/tcl8.swg +++ b/SWIG/Lib/tcl/tcl8.swg @@ -553,9 +553,7 @@ } // Some special reserved words in classes - -%namewarn("314:cget is a reserved method name") *::cget; -%namewarn("314:configure is a reserved method name") *::configure; +%include "tclkw.swg" /* C++ overloaded operators. diff --git a/SWIG/Lib/tcl/tclkw.swg b/SWIG/Lib/tcl/tclkw.swg new file mode 100644 index 000000000..64cf611d6 --- /dev/null +++ b/SWIG/Lib/tcl/tclkw.swg @@ -0,0 +1,10 @@ +#ifndef __tcl_tclkw_swg__ +#define __tcl_tclkw_swg__ + +// Some special reserved words in classes + +%namewarn("314:cget is a tcl reserved method name") *::cget; +%namewarn("314:configure is a tcl reserved method name") *::configure; + + +#endif //__tcl_tclkw_swg__