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.
This commit is contained in:
Shane Liesegang 2019-07-20 07:05:38 +02:00 committed by GitHub
commit 0c2b454eb3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;
}