- Uniform the definition of the keyword warnings through

the supported languages.

- Added keyword list for most of the languages that didn't
  have one.

- "All keywords" warning support, through the -DSWIG_ALLKW
  option.

Read the Changes.current


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5543 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2003-12-12 02:23:52 +00:00
commit ea0f636eae
18 changed files with 593 additions and 60 deletions

View file

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

29
SWIG/Lib/allkw.swg Normal file
View file

@ -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__

View file

@ -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 */

View file

@ -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__

View file

@ -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__

View file

@ -936,3 +936,6 @@
%apply long { size_t };
/* java keywords */
/* please test and activate */
//%include "javakw.swg"

67
SWIG/Lib/java/javakw.swg Normal file
View file

@ -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__

View file

@ -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"

89
SWIG/Lib/php4/phpkw.swg Normal file
View file

@ -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__

View file

@ -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"

54
SWIG/Lib/pike/pikekw.swg Normal file
View file

@ -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__

View file

@ -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 */

View file

@ -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__

View file

@ -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 */

56
SWIG/Lib/ruby/rubykw.swg Normal file
View file

@ -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__

View file

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

View file

@ -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.

10
SWIG/Lib/tcl/tclkw.swg Normal file
View file

@ -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__