From f2c410a8c0c2646a715503a1beda3b4fc0ccf14a Mon Sep 17 00:00:00 2001 From: Artem Serebriyskiy Date: Sun, 23 Mar 2014 14:05:05 +0400 Subject: [PATCH] Fixing issue 152 --- Examples/test-suite/lua/cpp_basic_runme.lua | 3 +++ Lib/lua/luarun.swg | 7 ++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/lua/cpp_basic_runme.lua b/Examples/test-suite/lua/cpp_basic_runme.lua index 3e2fb963e..8a72f1bad 100644 --- a/Examples/test-suite/lua/cpp_basic_runme.lua +++ b/Examples/test-suite/lua/cpp_basic_runme.lua @@ -73,3 +73,6 @@ f.func_ptr=func1_ptr assert(cb.test_func_ptr(f,2)==16) f.func_ptr=func2_ptr assert(cb.test_func_ptr(f,2)==-8) + +-- Test that __tostring metamethod produce no internal asserts +f2_name = tostring(f2) diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index face9c6c9..d3561b1bc 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -991,17 +991,14 @@ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L) /* there should be 1 param passed in (1) userdata (not the metatable) */ assert(lua_isuserdata(L,1)); /* just in case */ - unsigned long userData = (unsigned long)lua_touserdata(L,1); /* get the userdata address for later */ + void* userData = lua_touserdata(L,1); /* get the userdata address for later */ lua_getmetatable(L,1); /* get the meta table */ assert(lua_istable(L,-1)); /* just in case */ lua_getfield(L, -1, ".type"); const char *className = lua_tostring(L, -1); - char output[256]; - snprintf(output, 255, "<%s userdata: %lX>", className, userData); - - lua_pushstring(L, (const char*)output); + lua_pushfstring(L, "<%s userdata: %p>", className, userData); return 1; }