mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-27 09:20:51 +00:00
Lunatic translator: a couple of set-struct commands, "-I" option for default dir.
git-svn-id: https://svn.eduke32.com/eduke32@3439 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
0796c0e66e
commit
c0ebbbbb42
1 changed files with 42 additions and 13 deletions
|
@ -85,10 +85,14 @@ local g_directory = "" -- with trailing slash if not empty
|
||||||
local g_maxerrors = 20
|
local g_maxerrors = 20
|
||||||
local g_numerrors = 0
|
local g_numerrors = 0
|
||||||
|
|
||||||
|
-- Default directory to search for GAME.CON etc.
|
||||||
|
-- Stand-alone LunaCON only.
|
||||||
|
local g_defaultDir = nil
|
||||||
|
|
||||||
-- Warning options. Key names are the same as cmdline options, e.g.
|
-- Warning options. Key names are the same as cmdline options, e.g.
|
||||||
-- -Wno-bad-identifier for disabling the "bad identifier" warning.
|
-- -Wno-bad-identifier for disabling the "bad identifier" warning.
|
||||||
local g_warn = { ["not-redefined"]=true, ["bad-identifier"]=true,
|
local g_warn = { ["not-redefined"]=true, ["bad-identifier"]=true,
|
||||||
["number-conversion"]=true, }
|
["number-conversion"]=true, ["system-gamevar"]=true, }
|
||||||
|
|
||||||
-- Code generation options.
|
-- Code generation options.
|
||||||
local g_cgopt = { ["no"]=false, ["_incomplete"]=false, }
|
local g_cgopt = { ["no"]=false, ["_incomplete"]=false, }
|
||||||
|
@ -361,8 +365,11 @@ end
|
||||||
local function parse_number(pos, numstr)
|
local function parse_number(pos, numstr)
|
||||||
local num = tonumber((numstr:gsub("h$", "")))
|
local num = tonumber((numstr:gsub("h$", "")))
|
||||||
|
|
||||||
if (num==nil or num < -0x80000000 or num > 0xffffffff) then
|
-- num==nil for Rio Lua, which doesn't handle large hex literals.
|
||||||
|
if (num==nil or not (num >= -0x80000000 and num <= 0xffffffff)) then
|
||||||
perrprintf(pos, "number %s out of the range of a 32-bit integer", numstr)
|
perrprintf(pos, "number %s out of the range of a 32-bit integer", numstr)
|
||||||
|
-- Be careful not to write bound checks like
|
||||||
|
-- "if (i<LOWBOUND or i>HIGHBOUND) then error('...') end":
|
||||||
num = NaN
|
num = NaN
|
||||||
elseif (num >= 0x80000000 and numstr:sub(1,2):lower()~="0x") then
|
elseif (num >= 0x80000000 and numstr:sub(1,2):lower()~="0x") then
|
||||||
if (g_warn["number-conversion"]) then
|
if (g_warn["number-conversion"]) then
|
||||||
|
@ -573,9 +580,16 @@ local function do_include_file(dirname, filename)
|
||||||
local fd, msg = io.open(dirname..filename)
|
local fd, msg = io.open(dirname..filename)
|
||||||
if (fd == nil) then
|
if (fd == nil) then
|
||||||
-- strip up to and including first slash:
|
-- strip up to and including first slash:
|
||||||
filename = string.gsub(filename, "^.-/", "")
|
filename = filename:gsub("^.-/", "")
|
||||||
fd, msg = io.open(dirname..filename)
|
fd, msg = io.open(dirname..filename)
|
||||||
|
|
||||||
|
-- As a last resort, try the "default directory"
|
||||||
|
if (fd==nil and g_defaultDir) then
|
||||||
|
-- strip up to and including last slash (if any):
|
||||||
|
filename = filename:gsub("^.*/", "")
|
||||||
|
fd, msg = io.open(g_defaultDir.."/"..filename)
|
||||||
|
end
|
||||||
|
|
||||||
if (fd == nil) then
|
if (fd == nil) then
|
||||||
printf("[%d] Fatal error: couldn't open %s", g_recurslevel, msg)
|
printf("[%d] Fatal error: couldn't open %s", g_recurslevel, msg)
|
||||||
g_numerrors = inf
|
g_numerrors = inf
|
||||||
|
@ -596,6 +610,8 @@ local function do_include_file(dirname, filename)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- XXX: File name that's displayed here may not be the actual opened one
|
||||||
|
-- (esp. for stand-alone version).
|
||||||
printf("%s[%d] Translating file \"%s\"", (g_recurslevel==-1 and "\n---- ") or "",
|
printf("%s[%d] Translating file \"%s\"", (g_recurslevel==-1 and "\n---- ") or "",
|
||||||
g_recurslevel+1, dirname..filename);
|
g_recurslevel+1, dirname..filename);
|
||||||
|
|
||||||
|
@ -818,7 +834,7 @@ function Cmd.gamevar(identifier, initval, flags)
|
||||||
end
|
end
|
||||||
|
|
||||||
local flagsnosys = bit.band(oflags, bit.bnot(GVFLAG.SYSTEM))
|
local flagsnosys = bit.band(oflags, bit.bnot(GVFLAG.SYSTEM))
|
||||||
if (flagsnosys ~= flags) then
|
if (flagsnosys ~= flags and g_warn["system-gamevar"]) then
|
||||||
warnprintf("overrode initial value of `%s', but kept "..
|
warnprintf("overrode initial value of `%s', but kept "..
|
||||||
"flags (%d)", identifier, flagsnosys)
|
"flags (%d)", identifier, flagsnosys)
|
||||||
end
|
end
|
||||||
|
@ -1162,6 +1178,13 @@ local function GetStructCmd(accessfunc)
|
||||||
return pattern
|
return pattern
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function SetStructCmd(accessfunc)
|
||||||
|
local pattern = setstructcmd / function(idx, memb, var)
|
||||||
|
return format("%s=%s", accessfunc(true, idx, memb), var)
|
||||||
|
end
|
||||||
|
return pattern
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Various inner command handling functions / string capture strings.
|
-- Various inner command handling functions / string capture strings.
|
||||||
local handle =
|
local handle =
|
||||||
|
@ -1225,11 +1248,13 @@ local Cinner = {
|
||||||
/ handle.state,
|
/ handle.state,
|
||||||
|
|
||||||
--- 1. get*, set*
|
--- 1. get*, set*
|
||||||
getactor = GetStructCmd(Access.xsprite),
|
|
||||||
getinput = getstructcmd,
|
|
||||||
getplayer = GetStructCmd(Access.player),
|
|
||||||
getprojectile = getstructcmd,
|
|
||||||
getsector = GetStructCmd(Access.sector),
|
getsector = GetStructCmd(Access.sector),
|
||||||
|
getwall = GetStructCmd(Access.wall),
|
||||||
|
getactor = GetStructCmd(Access.xsprite),
|
||||||
|
getplayer = GetStructCmd(Access.player),
|
||||||
|
|
||||||
|
getinput = getstructcmd,
|
||||||
|
getprojectile = getstructcmd,
|
||||||
getthisprojectile = getstructcmd,
|
getthisprojectile = getstructcmd,
|
||||||
gettspr = getstructcmd,
|
gettspr = getstructcmd,
|
||||||
-- NOTE: {get,set}userdef is the only struct that can be accessed without
|
-- NOTE: {get,set}userdef is the only struct that can be accessed without
|
||||||
|
@ -1241,20 +1266,20 @@ local Cinner = {
|
||||||
-- We disallow them unless CONs in the wild crop up that actually used
|
-- We disallow them unless CONs in the wild crop up that actually used
|
||||||
-- these.
|
-- these.
|
||||||
getuserdef = (arraypat + sp1)/{} * singlememberpat * sp1 * tok.wvar,
|
getuserdef = (arraypat + sp1)/{} * singlememberpat * sp1 * tok.wvar,
|
||||||
getwall = GetStructCmd(Access.wall),
|
|
||||||
|
|
||||||
getactorvar = getperxvarcmd,
|
getactorvar = getperxvarcmd,
|
||||||
getplayervar = getperxvarcmd,
|
getplayervar = getperxvarcmd,
|
||||||
|
|
||||||
setactor = setstructcmd,
|
setsector = SetStructCmd(Access.sector),
|
||||||
|
setwall = SetStructCmd(Access.wall),
|
||||||
|
setactor = SetStructCmd(Access.xsprite),
|
||||||
|
setplayer = SetStructCmd(Access.player),
|
||||||
|
|
||||||
setinput = setstructcmd,
|
setinput = setstructcmd,
|
||||||
setplayer = setstructcmd,
|
|
||||||
setprojectile = setstructcmd,
|
setprojectile = setstructcmd,
|
||||||
setsector = setstructcmd,
|
|
||||||
setthisprojectile = setstructcmd,
|
setthisprojectile = setstructcmd,
|
||||||
settspr = setstructcmd,
|
settspr = setstructcmd,
|
||||||
setuserdef = (arraypat + sp1)/{} * singlememberpat * sp1 * tok.rvar,
|
setuserdef = (arraypat + sp1)/{} * singlememberpat * sp1 * tok.rvar,
|
||||||
setwall = setstructcmd,
|
|
||||||
|
|
||||||
setactorvar = setperxvarcmd,
|
setactorvar = setperxvarcmd,
|
||||||
setplayervar = setperxvarcmd,
|
setplayervar = setperxvarcmd,
|
||||||
|
@ -2269,6 +2294,10 @@ local function handle_cmdline_arg(str)
|
||||||
-- TEMP
|
-- TEMP
|
||||||
g_cgopt["_incomplete"] = true
|
g_cgopt["_incomplete"] = true
|
||||||
ok = true
|
ok = true
|
||||||
|
elseif (kind=="I" and #str >= 3) then
|
||||||
|
-- default directory (only ONCE, not search path)
|
||||||
|
g_defaultDir = str:sub(3)
|
||||||
|
ok = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if (not ok) then
|
if (not ok) then
|
||||||
|
|
Loading…
Reference in a new issue