[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Pushing custom-type elements into the stack.
- From: "Wesley Smith" <wesley.hoke@...>
- Date: Thu, 16 Aug 2007 17:46:46 -0700
I would highly recommend picking up programming in Lua. It has all
kind of stuff in there like this. You will learn Lua much faster!
int stackDump(lua_State *L)
{
int i;
int top = lua_gettop(L);
printf("stack dump %d:\n", top);
for(i=top; i >= 1; i--) {
int t = lua_type(L, i);
switch(t)
{
case LUA_TSTRING:
printf("%d \t'%s' string\n", i, lua_tostring(L, i));
break;
case LUA_TBOOLEAN:
printf(lua_toboolean(L, i) ? "\ttrue\n" : "\tfalse\n");
break;
case LUA_TNUMBER:
printf("%d \t'%f' number\n", i, lua_tonumber(L, i));
break;
case LUA_TLIGHTUSERDATA:
printf("%d \t'%x'\n", i, lua_touserdata(L, i));
break;
case LUA_TUSERDATA:
printf("%d ", i);
lua_getglobal(L, "print");
lua_pushvalue(L, i);
lua_call(L, 1, 0);
//printf("%d \t'%x %s'\n", i, lua_touserdata(L, i), T::name);
break;
case LUA_TFUNCTION:
printf("%d \t'func: %x'\n", i, lua_tocfunction(L, i));
break;
case LUA_TTABLE:
printf("%d ", i);
lua_getglobal(L, "print");
lua_pushvalue(L, i);
lua_call(L, 1, 0);
break;
default:
printf("%d \t'%s'\n", i, lua_typename(L, t));
break;
}
}
return 0;
}