From 3ce1734080a7e28ef7385e8c5f22d74631041499 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 11 Oct 2014 21:26:11 +0200 Subject: playing with some more obscure lua data types --- src/crawl/crawl.cpp | 2 +- src/libluaglue/LuaVM.cpp | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/crawl/crawl.cpp b/src/crawl/crawl.cpp index 3e5239c..4abd37c 100755 --- a/src/crawl/crawl.cpp +++ b/src/crawl/crawl.cpp @@ -94,7 +94,7 @@ int main( int /* argc */, char *argv[] ) // go through all type of modules and load them with the proper loader string modulePath = luaVm.getString( "crawler.module_path" ); bool modulesSearchRecursive = luaVm.getBoolean( "crawler.modules_search_recursive" ); - LOG( logNOTICE ) << "Loading modules from path '" << modulePath << "'" + LOG( logNOTICE ) << "Loading modules from path '" << modulePath << "' " << ( modulesSearchRecursive ? "(recursive)" : "" ); vector normalizerModules; diff --git a/src/libluaglue/LuaVM.cpp b/src/libluaglue/LuaVM.cpp index fb40c85..e75a1c9 100644 --- a/src/libluaglue/LuaVM.cpp +++ b/src/libluaglue/LuaVM.cpp @@ -149,13 +149,34 @@ void LuaVM::dumpStackElement( lua_State *l, int i, int indent ) lua_CFunction f = lua_tocfunction( l, i ); char buf[33]; snprintf( buf, 32, "function[%016" PRIxPTR "]", (uintptr_t)f ); + // TODO: int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); cout << "LUA_TFUNCTION " << buf; break; } -//#define LUA_TLIGHTUSERDATA 2 -//#define LUA_TUSERDATA 7 -//#define LUA_TTHREAD 8 + case LUA_TLIGHTUSERDATA: { + void *p = lua_touserdata( l, i ); + char buf[33]; + snprintf( buf, 32, "void *[%016" PRIxPTR "]", (uintptr_t)p ); + cout << "LUA_TLIGHTUSERDATA " << buf; + break; + } + + case LUA_TUSERDATA: { + void *p = lua_touserdata( l, i ); + char buf[33]; + snprintf( buf, 32, "void *[%016" PRIxPTR "]", (uintptr_t)p ); + // TODO: is there a tostring entry in the metatable? + cout << "LUA_TUSERDATA " << buf; + break; + } + + case LUA_TTHREAD: { + //lua_State *thread = lua_tothread( l, i ); + // TODO: more information like status of the thread? + cout << "LUA_TTHREAD "; + break; + } default: cout << lua_typename( l, type ) << " "; -- cgit v1.2.3-54-g00ecf