lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


zhiguo zhao wrote:
> after I write this, I fall.
> 
> LUA_API int luaopen_misc(lua_State *L)
> {
> lua_CFunction tosf;
> lua_getglobal( L, "tostring" );
> printf("get tostring from global, type(%s)\n", lua_typename(L,-1));
> printf("get tostring from global, tostring(%s)\n", lua_tostring(L,-1));
> tosf = lua_tocfunction( L, -1 );
> printf("get tostring lua_CFunction pointer(%p)\n", tosf);
> lua_pop(L,1);

This is expected. Since tostring() is not a C function in LuaJIT,
you cannot get a C function pointer from it.

Anyway, there are no more tests needed. Lanes simply shouldn't
make such an assumption and needs to be fixed by the author(s).
E.g. lua_topointer + lua_pushlightuserdata are much more effective
for use in cross-state caching.

--Mike