[Lua] Add keyword warnings for Lua keywords and Basic Functions.
This commit is contained in:
parent
dcf121f534
commit
1097fc99ff
5 changed files with 76 additions and 8 deletions
|
|
@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release.
|
|||
Version 3.0.0 (in progress)
|
||||
============================
|
||||
|
||||
2014-02-19: olly
|
||||
[Lua] Add keyword warnings for Lua keywords and Basic Functions.
|
||||
|
||||
2014-02-19: olly
|
||||
-Wallkw now includes keywords for all languages with keyword
|
||||
warnings (previously Go and R were missing).
|
||||
|
|
|
|||
|
|
@ -7,10 +7,6 @@ local env = _ENV -- Lua 5.2
|
|||
if not env then env = getfenv () end -- Lua 5.1
|
||||
setmetatable(env, {__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
|
||||
|
||||
-- assert(kn.end(5) == 5) -- Curretly SWIG/Lua doesn't rename keywords
|
||||
-- assert(kn.nil(7) == 7)
|
||||
|
||||
-- But you can always access wrongly named members using string constants
|
||||
assert(kn["end"](5) == 5)
|
||||
assert(kn["nil"](7) == 7)
|
||||
-- Check renaming of Lua keywords
|
||||
assert(kn.c_end(5) == 5)
|
||||
assert(kn.c_nil(7) == 7)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
%include <d/dkw.swg>
|
||||
%include <go/gokw.swg>
|
||||
%include <java/javakw.swg>
|
||||
%include <lua/luakw.swg>
|
||||
%include <ocaml/ocamlkw.swg>
|
||||
%include <perl5/perlkw.swg>
|
||||
%include <php/phpkw.swg>
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@
|
|||
* includes
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%include <luatypemaps.swg> /* The typemaps */
|
||||
%include <luatypemaps.swg> /* The typemaps */
|
||||
%include <luaruntime.swg> /* The runtime stuff */
|
||||
%include <luakw.swg> /* Warnings for Lua keywords */
|
||||
|
||||
//%include <typemaps/swigmacros.swg>
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
|||
67
Lib/lua/luakw.swg
Normal file
67
Lib/lua/luakw.swg
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
Warnings for Lua keywords, built-in names and bad names.
|
||||
*/
|
||||
|
||||
#define LUAKW(x) %keywordwarn("'" `x` "' is a Lua keyword, renaming to 'c_" `x` "'", rename="c_%s") `x`
|
||||
#define LUABN(x) %namewarn(%warningmsg(SWIGWARN_PARSE_BUILTIN_NAME, "'" `x` "' conflicts with a basic function in Lua"), %$not %$ismember) `x`
|
||||
|
||||
/*
|
||||
Warnings for Lua keywords
|
||||
http://www.lua.org/manual/5.2/manual.html#3.1
|
||||
*/
|
||||
|
||||
LUAKW(and);
|
||||
LUAKW(break);
|
||||
LUAKW(do);
|
||||
LUAKW(else);
|
||||
LUAKW(elseif);
|
||||
LUAKW(end);
|
||||
LUAKW(false);
|
||||
LUAKW(for);
|
||||
LUAKW(function);
|
||||
LUAKW(goto);
|
||||
LUAKW(if);
|
||||
LUAKW(in);
|
||||
LUAKW(local);
|
||||
LUAKW(nil);
|
||||
LUAKW(not);
|
||||
LUAKW(or);
|
||||
LUAKW(repeat);
|
||||
LUAKW(return);
|
||||
LUAKW(then);
|
||||
LUAKW(true);
|
||||
LUAKW(until);
|
||||
LUAKW(while);
|
||||
|
||||
/*
|
||||
Basic functions
|
||||
http://www.lua.org/manual/5.2/manual.html#6.1
|
||||
*/
|
||||
|
||||
LUABN(assert);
|
||||
LUABN(collectgarbage);
|
||||
LUABN(dofile);
|
||||
LUABN(error);
|
||||
LUABN(_G); // Not actually a function
|
||||
LUABN(getmetatable);
|
||||
LUABN(ipairs);
|
||||
LUABN(load);
|
||||
LUABN(loadfile);
|
||||
LUABN(next);
|
||||
LUABN(pairs);
|
||||
LUABN(pcall);
|
||||
LUABN(print);
|
||||
LUABN(rawequal);
|
||||
LUABN(rawget);
|
||||
LUABN(rawlen);
|
||||
LUABN(rawset);
|
||||
LUABN(select);
|
||||
LUABN(setmetatable);
|
||||
LUABN(tonumber);
|
||||
LUABN(tostring);
|
||||
LUABN(type);
|
||||
LUABN(_VERSION); // Not actually a function
|
||||
LUABN(xpcall);
|
||||
|
||||
#undef LUABN
|
||||
#undef LUAKW
|
||||
Loading…
Add table
Add a link
Reference in a new issue