[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: setglobals and Lua 5.0
- From: "zeusedit" <jussi.jumppanen@...>
- Date: Fri, 02 May 2003 05:49:49 -0000
I am hoping this will be my last problem with my port from
the older Lua 4.0 to the newer Lua 5.0 version.
So far my "__index" hook is nearly working as a replace for
the older "setglobals" approach.
But the latest glitch is with the following type of Zeus
macro:
function key_macro()
local int test = strlen("test")
end
key_macro() -- run the macro
In this case as before the zeus_hook gets called and as before
it passes the call on to zeus_function for processing.
But the problem is the "strlen" function is a Lua function and
not a Zeus function :(
With the older "setglobals" approach it would appear that Lua
would filter these calls from me, as the zeus_hook was only
called for symbols that where unresolved to Lua.
With this newer approach I am getting all function calls which
I guess is the expected result since this is the whole idea of
the "__index" hook.
So currently when I the zeus_function is called with "strlen" I
just terminate the macro with an unknown function error.
I also tried ignoring the unknown functions by just returning,
but that approach just generates an alert :( My guess is just
returning is leaving the stack in an unstable state.
So my question is how would I determine if the symbol is
meant for Lua or is an unresolved symbol meant for Zeus?
Is there some way to only hook into unresolved symbols?
What I really want is a way to have Lua handle most cases, and
then only call my code if it can't find a function.
Or do I try to run the function in the zeus_hook:
int MacroLua::zeus_hook(lua_State *L)
{
// ??? need check for Lua functions?
//-- in: table, index
//-- out: closed zeus_func
//-- copy global name
lua_pushvalue(L, 2);
//-- bind it to zeus_func as upvalue
lua_pushcclosure(L, zeus_function, 1);
return 1;
}
and then then only pass the unresolved calls onto the
zeus_function?
Thanks in advance.
Cheers Jussi