[Lua] Add support for Lua 5.2 (patch SF#3514593 from Miles Bader)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12968 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
fec1ecc6c5
commit
e3eb54594e
18 changed files with 73 additions and 20 deletions
|
|
@ -2,7 +2,9 @@ require("import") -- the import fn
|
|||
import("abstract_access") -- import code
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
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})
|
||||
|
||||
-- trying to instantiate pure virual classes
|
||||
-- should fail
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ import("cpp_basic") -- import code
|
|||
cb=cpp_basic -- renaming import
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
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})
|
||||
|
||||
f=cb.Foo(4)
|
||||
assert(f.num==4)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ require("import") -- the import fn
|
|||
import("disown") -- import code
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
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})
|
||||
|
||||
for x=0,100 do
|
||||
a=disown.A()
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ require("import") -- the import fn
|
|||
import("enums") -- import lib
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
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})
|
||||
|
||||
-- check values
|
||||
assert(enums.CSP_ITERATION_FWD==0)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import("exception_order") -- import lib into global
|
|||
eo=exception_order --alias
|
||||
|
||||
-- catching undefined variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
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})
|
||||
|
||||
a = eo.A()
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ require("import") -- the import fn
|
|||
import("import_nomodule") -- import code
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
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})
|
||||
|
||||
f = import_nomodule.create_Foo()
|
||||
import_nomodule.test1(f,42)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ import("li_carrays") -- import code
|
|||
for k,v in pairs(li_carrays) do _G[k]=v end
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
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})
|
||||
|
||||
-- Testing for %array_functions(int,intArray)
|
||||
ary = new_intArray(2)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import("li_std_string") -- import lib
|
|||
for k,v in pairs(li_std_string) do _G[k]=v end -- move to global
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
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})
|
||||
|
||||
-- helper to check type
|
||||
function is_std_string(s)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ require("import") -- the import fn
|
|||
import("li_typemaps") -- import code
|
||||
|
||||
-- catch "undefined" global variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
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})
|
||||
|
||||
-- Check double INPUT typemaps
|
||||
assert(li_typemaps.in_double(22.22) == 22.22)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ for k,v in pairs(operator_overload) do _G[k]=v end -- move to global
|
|||
Op_sanity_check()
|
||||
|
||||
-- catching undefined variables
|
||||
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||
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})
|
||||
|
||||
-- test routine:
|
||||
a=Op()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue