From 0c2b454eb3e8738201bbab24ee640c9e140d87a7 Mon Sep 17 00:00:00 2001 From: Shane Liesegang Date: Sat, 20 Jul 2019 07:05:38 +0200 Subject: [PATCH] Lua userdata print pointing to wrapped memory This is actually a fix to some functionality that I submitted many years ago. :) At the time I set the string conversion to output the userdata address, but since that points to an internal SWIG structure, it's way more useful to the user to point to the actual memory being wrapped in that userdata. --- Lib/lua/luarun.swg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 9636cdc9b..ac0033ff6 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -1040,7 +1040,7 @@ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L) /* there should be 1 param passed in (1) userdata (not the metatable) */ const char *className; - void* userData; + swig_lua_userdata* userData; assert(lua_isuserdata(L,1)); /* just in case */ userData = lua_touserdata(L,1); /* get the userdata address for later */ lua_getmetatable(L,1); /* get the meta table */ @@ -1049,7 +1049,7 @@ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L) lua_getfield(L, -1, ".type"); className = lua_tostring(L, -1); - lua_pushfstring(L, "<%s userdata: %p>", className, userData); + lua_pushfstring(L, "<%s userdata: %p>", className, userData->ptr); return 1; }