Add R keyword support. Rename keywords for successful compilation of Java and C# code. More consistent keyword warnings across the different languages.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10530 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
de6d6ccaa8
commit
9c323f4a70
14 changed files with 53 additions and 16 deletions
|
|
@ -1,6 +1,15 @@
|
||||||
Version 1.3.36 (in progress)
|
Version 1.3.36 (in progress)
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
|
06/19/2008: wsfulton
|
||||||
|
[Java, C#] C# and Java keywords will be renamed instead of just issuing a warning
|
||||||
|
and then generating uncompileable code. Warning 314 gives the new name when a
|
||||||
|
keyword is found.
|
||||||
|
|
||||||
|
06/19/2008: wsfulton
|
||||||
|
[R] Keyword handling added. R Keywords will be renamed as necessary.
|
||||||
|
Warning 314 gives the new name when a keyword is found.
|
||||||
|
|
||||||
06/17/2008: mgossage
|
06/17/2008: mgossage
|
||||||
[Lua] Added missing support for bool& and bool*. Added runtest for li_typemaps testcase.
|
[Lua] Added missing support for bool& and bool*. Added runtest for li_typemaps testcase.
|
||||||
(Bug #1938142)
|
(Bug #1938142)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
%module keyword_rename
|
%module keyword_rename
|
||||||
%warnfilter(SWIGWARN_PARSE_KEYWORD);
|
|
||||||
|
#pragma SWIG nowarn=SWIGWARN_PARSE_KEYWORD
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
||||||
#define KW(x, y) int x (int y) { return y;}
|
#define KW(x, y) int x (int y) { return y;}
|
||||||
|
|
@ -21,6 +23,10 @@ KW(use, next)
|
||||||
KW(implements, native)
|
KW(implements, native)
|
||||||
KW(byte, final)
|
KW(byte, final)
|
||||||
|
|
||||||
|
/* C# Keywords */
|
||||||
|
KW(string, out)
|
||||||
|
struct sealed {};
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
/* Warnings for certain CHICKEN keywords. From Section 7.1.1 of
|
/* Warnings for certain CHICKEN keywords. From Section 7.1.1 of
|
||||||
Revised^5 Report on the Algorithmic Language Scheme */
|
Revised^5 Report on the Algorithmic Language Scheme */
|
||||||
#define CHICKENKW(x) %namewarn("314:" #x " is a R^5RS syntatic keyword") #x
|
#define CHICKENKW(x) %namewarn("314: '" #x "' is a R^5RS syntatic keyword") #x
|
||||||
|
|
||||||
CHICKENKW(else);
|
CHICKENKW(else);
|
||||||
CHICKENKW(=>);
|
CHICKENKW(=>);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define CSHARP_CSHARPKW_SWG_
|
#define CSHARP_CSHARPKW_SWG_
|
||||||
|
|
||||||
/* Warnings for C# keywords */
|
/* Warnings for C# keywords */
|
||||||
#define CSHARPKW(x) %namewarn("314:" #x " is a csharp keyword") #x
|
#define CSHARPKW(x) %keywordwarn("'" `x` "' is a C# keyword, renaming to '_" `x` "'",rename="_%s") `x`
|
||||||
|
|
||||||
/*
|
/*
|
||||||
from
|
from
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define JAVA_JAVAKW_SWG_
|
#define JAVA_JAVAKW_SWG_
|
||||||
|
|
||||||
/* Warnings for Java keywords */
|
/* Warnings for Java keywords */
|
||||||
#define JAVAKW(x) %namewarn("314:" #x " is a java keyword") #x
|
#define JAVAKW(x) %keywordwarn("'" `x` "' is a java keyword, renaming to '_"`x`"'",rename="_%s") `x`
|
||||||
|
|
||||||
/*
|
/*
|
||||||
from
|
from
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define OCAML_OCAMLKW_SWG_
|
#define OCAML_OCAMLKW_SWG_
|
||||||
|
|
||||||
/* Warnings for Ocaml keywords */
|
/* Warnings for Ocaml keywords */
|
||||||
#define OCAMLKW(x) %namewarn("314:" #x " is a ocaml keyword and it will properly renamed") #x
|
#define OCAMLKW(x) %namewarn("314: '" #x "' is a ocaml keyword and it will properly renamed") #x
|
||||||
|
|
||||||
/*
|
/*
|
||||||
from
|
from
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* Warnings for Perl keywords */
|
/* Warnings for Perl keywords */
|
||||||
#define PERLKW(x) %keywordwarn(`x` " is a perl keyword") `x`
|
#define PERLKW(x) %keywordwarn("'" `x` "' is a perl keyword") `x`
|
||||||
#define PERLBN(x) %builtinwarn(`x` " conflicts with a built-in name in perl") "::" `x`
|
#define PERLBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in perl") "::" `x`
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,15 @@
|
||||||
* when used as class methods.
|
* when used as class methods.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#define PHPKW(x) %keywordwarn(`x` " is a php keyword, renamed as c_"`x`,sourcefmt="%(lower)s", rename="c_%s",fullname=1) `x`
|
#define PHPKW(x) %keywordwarn("'" `x` "' is a php keyword, renamed as 'c_" `x` "'",sourcefmt="%(lower)s", rename="c_%s",fullname=1) `x`
|
||||||
|
|
||||||
%define PHPCN(x)
|
%define PHPCN(x)
|
||||||
%keywordwarn(`x` " is a php reserved class name, class renamed as c_"`x`,%$isclass,rename="c_%s") `x`;
|
%keywordwarn("'" `x` "' is a php reserved class name, class renamed as 'c_" `x` "'",%$isclass,rename="c_%s") `x`;
|
||||||
%keywordwarn(`x` " is a php reserved class name, constructor renamed as c_"`x`,%$isconstructor,rename="c_%s") `x`;
|
%keywordwarn("'" `x` "' is a php reserved class name, constructor renamed as 'c_" `x` "'",%$isconstructor,rename="c_%s") `x`;
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
#define PHPBN1(x) %builtinwarn(`x` " conflicts with a built-in name in php",sourcefmt="%(lower)s",fullname=1) `x`
|
#define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in php",sourcefmt="%(lower)s",fullname=1) `x`
|
||||||
#define PHPBN2(x) %builtinwarn(`x` " conflicts with a built-in name in php") "::" `x`
|
#define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in php") "::" `x`
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define PIKE_PIKEKW_SWG_
|
#define PIKE_PIKEKW_SWG_
|
||||||
|
|
||||||
/* Warnings for Pike keywords */
|
/* Warnings for Pike keywords */
|
||||||
#define PIKEKW(x) %namewarn("314:" #x " is a pike keyword") #x
|
#define PIKEKW(x) %namewarn("314: '" #x "' is a pike keyword") #x
|
||||||
|
|
||||||
/*
|
/*
|
||||||
from
|
from
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
Warnings for Python keywords, built-in names and bad names.
|
Warnings for Python keywords, built-in names and bad names.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PYTHONKW(x) %keywordwarn(`x` " is a python keyword, symbol will be renamed as '_" `x`"'", rename="_%s") `x`
|
#define PYTHONKW(x) %keywordwarn("'" `x` "' is a python keyword, renaming to '_" `x` "'", rename="_%s") `x`
|
||||||
#define PYTHONBN(x) %builtinwarn(`x` " conflicts with a built-in name in python") "::"`x`
|
#define PYTHONBN(x) %builtinwarn("'" `x` "' conflicts with a built-in name in python") "::"`x`
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@
|
||||||
SWIGEXPORT void SWIG_init(void) {
|
SWIGEXPORT void SWIG_init(void) {
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
%include <rkw.swg>
|
||||||
|
|
||||||
#define %Rruntime %insert("s")
|
#define %Rruntime %insert("s")
|
||||||
|
|
||||||
#define SWIG_Object SEXP
|
#define SWIG_Object SEXP
|
||||||
|
|
|
||||||
17
Lib/r/rkw.swg
Normal file
17
Lib/r/rkw.swg
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
Warnings for R keywords, built-in names and bad names.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define RKW(x) %keywordwarn("'" `x` "' is a R keyword, renaming to '_" `x`"'", rename="_%s") `x`
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Warnings for R keywords
|
||||||
|
REFERENCE ????
|
||||||
|
*/
|
||||||
|
|
||||||
|
RKW(except);
|
||||||
|
RKW(in);
|
||||||
|
RKW(next);
|
||||||
|
|
||||||
|
#undef RKW
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define RUBY_RUBYKW_SWG_
|
#define RUBY_RUBYKW_SWG_
|
||||||
|
|
||||||
/* Warnings for Ruby keywords */
|
/* Warnings for Ruby keywords */
|
||||||
#define RUBYKW(x) %keywordwarn("'" `x` "' is a ruby keyword, and it will renamed as 'C_"`x`"'",rename="C_%s",fullname=1) `x`
|
#define RUBYKW(x) %keywordwarn("'" `x` "' is a ruby keyword, renaming to 'C_" `x` "'",rename="C_%s",fullname=1) `x`
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1841,6 +1841,9 @@ int R::functionWrapper(Node *n) {
|
||||||
String *name = Getattr(p,"name");
|
String *name = Getattr(p,"name");
|
||||||
String *lname = Getattr(p,"lname");
|
String *lname = Getattr(p,"lname");
|
||||||
|
|
||||||
|
// R keyword renaming
|
||||||
|
if (name && Swig_name_warning(p, 0, name, 0))
|
||||||
|
name = 0;
|
||||||
|
|
||||||
/* If we have a :: in the parameter name because we are accessing a static member of a class, say, then
|
/* If we have a :: in the parameter name because we are accessing a static member of a class, say, then
|
||||||
we need to remove that prefix. */
|
we need to remove that prefix. */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue