Fixes for DfHack::Process foolery.

develop
Warmist 2012-03-11 14:59:32 +02:00
parent 237d7b433a
commit 081aee1363
5 changed files with 8 additions and 16 deletions

@ -46,7 +46,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector <PluginCommand>
lua::state st=lua::glua::Get(); lua::state st=lua::glua::Get();
//maybe remake it to run automaticaly //maybe remake it to run automaticaly
lua::RegisterConsole(st); lua::RegisterConsole(st);
lua::RegisterProcess(st,c->p); lua::RegisterProcess(st);
lua::RegisterHexsearch(st); lua::RegisterHexsearch(st);
lua::RegisterMisc(st); lua::RegisterMisc(st);
lua::RegisterVersionInfo(st); lua::RegisterVersionInfo(st);

@ -8,6 +8,6 @@
namespace lua namespace lua
{ {
void RegisterProcess(lua::state &st,DFHack::Process *p); void RegisterProcess(lua::state &st);
} }
#endif #endif

@ -19,9 +19,9 @@ function GetTextRegion()
ranges__=Process.getMemRanges() ranges__=Process.getMemRanges()
--print("Ranges:"..#ranges__) --print("Ranges:"..#ranges__)
for k,v in pairs(ranges__) do for k,v in pairs(ranges__) do
--for k2,v2 in pairs(v) do for k2,v2 in pairs(v) do
-- print(string.format("%d %s->%s",k,tostring(k2),tostring(v2))) --print(string.format("%d %s->%s",k,tostring(k2),tostring(v2)))
--end end
--local num --local num
--flgs="" --flgs=""
--if(v["read"])then flgs=flgs..'r' end --if(v["read"])then flgs=flgs..'r' end

@ -40,7 +40,7 @@ function parseTree(t)
end end
function parseTreeGlobals(t) function parseTreeGlobals(t)
local glob={} local glob={}
print("Parsing global-objects") --print("Parsing global-objects")
for k,v in ipairs(t) do for k,v in ipairs(t) do
if v.xarg~=nil and v.label=="ld:global-object" then if v.xarg~=nil and v.label=="ld:global-object" then
local name=v.xarg["name"]; local name=v.xarg["name"];

@ -2,12 +2,7 @@
static DFHack::Process* GetProcessPtr(lua::state &st) static DFHack::Process* GetProcessPtr(lua::state &st)
{ {
int t=st.gettop(); return DFHack::Core::getInstance().p;
st.getglobal("Process");
st.getfield("__pointer");
DFHack::Process* c=static_cast<DFHack::Process*>(lua_touserdata(st,-1));
st.settop(t);
return c;
} }
static int lua_Process_readDWord(lua_State *S) static int lua_Process_readDWord(lua_State *S)
@ -275,7 +270,7 @@ const luaL_Reg lua_process_func[]=
{NULL,NULL} {NULL,NULL}
}; };
#undef PROC_FUNC #undef PROC_FUNC
void lua::RegisterProcess(lua::state &st,DFHack::Process *p) void lua::RegisterProcess(lua::state &st)
{ {
st.getglobal("Process"); st.getglobal("Process");
if(st.is<lua::nil>()) if(st.is<lua::nil>())
@ -284,9 +279,6 @@ void lua::RegisterProcess(lua::state &st,DFHack::Process *p)
st.newtable(); st.newtable();
} }
st.pushlightuserdata(p);
st.setfield("__pointer");
lua::RegFunctionsLocal(st, lua_process_func); lua::RegFunctionsLocal(st, lua_process_func);
st.setglobal("Process"); st.setglobal("Process");