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:
parent
d6ec7eb278
commit
0c2b454eb3
1 changed files with 2 additions and 2 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue