Lunatic: fix one stack index, comment on a problem with ffi.C access.

git-svn-id: https://svn.eduke32.com/eduke32@2710 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-05-29 20:01:58 +00:00
parent 35d989646e
commit fc23045675
3 changed files with 13 additions and 6 deletions

View file

@ -452,7 +452,7 @@ local function printkv(label, table)
print('----------') print('----------')
end end
printkv('_G AFTER SETFENV', _G) --printkv('_G AFTER SETFENV', _G)
---=== Restricted access to C variables from Lunatic ===--- ---=== Restricted access to C variables from Lunatic ===---
@ -469,6 +469,7 @@ local tmpmt = {
} }
oG.setmetatable(det, tmpmt) oG.setmetatable(det, tmpmt)
-- XXX: this is incorrect -- ffi.C also contains C library functions, etc.
-- GLOBAL gv: provides access to C global *scalars* -- GLOBAL gv: provides access to C global *scalars*
gv = { gv = {
-- all non-scalars need to be explicitly listed -- all non-scalars need to be explicitly listed
@ -486,8 +487,8 @@ gv = {
actor = det, actor = det,
ud = det, ud = det,
luaJIT_BC_con_lang, luaJIT_BC_con_lang = det,
luaJIT_BC_lunacon, luaJIT_BC_lunacon = det,
} }
local tmpmt = { local tmpmt = {
__index = ffiC, __index = ffiC,
@ -740,7 +741,7 @@ DBG_.loadGamevarsString = loadGamevarsString
---=== Finishing environment setup ===--- ---=== Finishing environment setup ===---
printkv('_G AFTER DECLS', _G) --printkv('_G AFTER DECLS', _G)
-- PiL 14.2 continued -- PiL 14.2 continued

View file

@ -111,7 +111,7 @@ int32_t El_RunOnce(El_State *estate, const char *fn)
if (i == LUA_ERRSYNTAX) if (i == LUA_ERRSYNTAX)
{ {
OSD_Printf("state \"%s\" syntax error: %s\n", estate->name, lua_tostring(estate->L, 1)); // get err msg OSD_Printf("state \"%s\" syntax error: %s\n", estate->name, lua_tostring(estate->L, -1)); // get err msg
lua_pop(estate->L, 1); lua_pop(estate->L, 1);
return 3; return 3;
} }

View file

@ -84,7 +84,7 @@ if (vol==1 and lev==8) then
end end
--]] --]]
DBG_.printkv('_G in test.elua', _G) --DBG_.printkv('_G in test.elua', _G)
checkfail('print(sprite[100000].ceilingpal)') -- oob read access checkfail('print(sprite[100000].ceilingpal)') -- oob read access
checkfail('setmetatable(sprite, {})') -- set metatable forbidden checkfail('setmetatable(sprite, {})') -- set metatable forbidden
@ -102,6 +102,12 @@ checkfail("new_global = 345") -- we should declare globals
checkfail('gv.CEILING = 3') -- can't redefine constants in 'gv' checkfail('gv.CEILING = 3') -- can't redefine constants in 'gv'
checkfail('string.dump(setevent)') -- string.dump is unavailable checkfail('string.dump(setevent)') -- string.dump is unavailable
-- This is problematic, even though pretty much every access will yield a
-- "missing declaration" error.
-- See http://luajit.org/ext_ffi_api.html#ffi_C about what stuff ffi.C contains.
checkfail('gv.luaJIT_setmode(nil, 0, 0)')
setevent(gv.EVENT_JUMP, function() print("jump!") end) setevent(gv.EVENT_JUMP, function() print("jump!") end)
print('---=== END TEST SCRIPT ===---') print('---=== END TEST SCRIPT ===---')