Lua: Some fixes related to sysrc.lua
- Detect syntax errors in sysrc.lua and abort compile - Print special errors for parse errors on sysrc.lua (if above fails). - Print errors from sysrc.lua specially.
This commit is contained in:
parent
d5e75bbb61
commit
82a1ce3c9c
3 changed files with 8 additions and 2 deletions
|
@ -42,7 +42,7 @@ struct encoder
|
|||
}
|
||||
i++;
|
||||
}
|
||||
output << out.str() << std::endl;
|
||||
output << out.str();
|
||||
return i;
|
||||
}
|
||||
size_t operator()()
|
||||
|
|
|
@ -7,6 +7,7 @@ __all__.files: $(OBJECTS)
|
|||
echo >__all__.ldflags
|
||||
|
||||
sysrc.cpp: sysrc.lua
|
||||
luac -p $<
|
||||
../../buildaux/txt2cstr.exe lua_sysrc_script $< >$@
|
||||
|
||||
sysrc.cpp.dep: sysrc.cpp
|
||||
|
|
|
@ -124,6 +124,8 @@ namespace
|
|||
|
||||
#define TEMPORARY "LUAINTERP_INTERNAL_COMMAND_TEMPORARY"
|
||||
|
||||
const char* eval_sysrc_lua = "local fn = loadstring(" TEMPORARY ", \"<built-in>\"); if fn then fn(); else "
|
||||
"print2(\"Parse error in sysrc.lua script\"); end;";
|
||||
const char* eval_lua_lua = "local fn = loadstring(" TEMPORARY "); if fn then fn(); else print("
|
||||
"\"Parse error in Lua statement\"); end;";
|
||||
const char* run_lua_lua = "dofile(" TEMPORARY ");";
|
||||
|
@ -245,7 +247,10 @@ namespace
|
|||
|
||||
void run_sysrc_lua(lua::state& L)
|
||||
{
|
||||
do_eval_lua(L, lua_sysrc_script);
|
||||
L.pushstring(lua_sysrc_script);
|
||||
L.setglobal(TEMPORARY);
|
||||
luareader_fragment = eval_sysrc_lua;
|
||||
run_lua_fragment(L);
|
||||
}
|
||||
|
||||
void run_synchronous_paint(struct lua_render_context* ctx)
|
||||
|
|
Loading…
Add table
Reference in a new issue