[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua vs. multi-threads / events driven based application / async operation
- From: Ziv Barber <zivbarber@...>
- Date: Fri, 23 Jan 2009 13:00:30 +0200
Hi,
First, I have to say that Lua is a great scripting language, easy to add to any program, compiled on many compilers, not need additional libraries - which is great for many project - thanks!
Now, for my problems with Lua:
I added Lua few months ago to a Windows based GUI application and I found some limitations with Lua:
1. I didn't find out how to stop a script from running from another thread.
2. I didn't find out how to give a pointer to Lua when registering a new function so when this function will be called it'll get it.
For example:
lua_State *myLua;
MyClass myClass;
...
lua_pushcclosure ( myLua, MyClass::MyFuncCode, 0 );
lua_setglobal ( myLua, "my_func" );
MyClass::MyFuncCode is static but I want also to have the "this" pointer to myClass when MyClass::MyFuncCode is executed.
3. Somehow registering the IO functions always failed:
// This code always fail:
luaopen_io ( myLua );
lua_settop ( myLua, 0 );
// This code fail too:
luaopen_loadlib ( myLua );
lua_settop ( myLua, 0 );
LUA_API void lua_replace (lua_State *L, int idx) {
StkId o;
lua_lock(L);
/* explicit test for incompatible code */
if (idx == LUA_ENVIRONINDEX && L->ci == L->base_ci)
luaG_runerror(L, "no calling environment"); <---- ***************************** it crash here
api_checknelems(L, 1);
o = index2adr(L, idx);
api_checkvalidindex(L, o);
if (idx == LUA_ENVIRONINDEX) {
Closure *func = curr_func(L);
api_check(L, ttistable(L->top - 1));
func->c.env = hvalue(L->top - 1);
luaC_barrier(L, func, L->top - 1);
}
else {
setobj(L, o, L->top - 1);
if (idx < LUA_GLOBALSINDEX) /* function upvalue? */
luaC_barrier(L, curr_func(L), L->top - 1);
}
L->top--;
lua_unlock(L);
}
What's the meaning of "no calling environment"?
thanks!