Merge branch 'sjml-patch-1-lua-print'

* sjml-patch-1-lua-print:
  removing unnecessary bits
  closer match to Python's output
  typo
  actually seeing both is useful
  matching code conventions
  Lua userdata print pointing to wrapped memory
This commit is contained in:
William S Fulton 2019-08-19 07:48:23 +01:00
commit 87a0dd2d90

View file

@ -1039,17 +1039,11 @@ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L)
{ {
/* there should be 1 param passed in /* there should be 1 param passed in
(1) userdata (not the metatable) */ (1) userdata (not the metatable) */
const char *className; swig_lua_userdata* userData;
void* userData;
assert(lua_isuserdata(L,1)); /* just in case */ assert(lua_isuserdata(L,1)); /* just in case */
userData = lua_touserdata(L,1); /* get the userdata address for later */ userData = (swig_lua_userdata*)lua_touserdata(L,1); /* get the userdata address */
lua_getmetatable(L,1); /* get the meta table */
assert(lua_istable(L,-1)); /* just in case */
lua_getfield(L, -1, ".type"); lua_pushfstring(L, "<userdata of type '%s' at %p>", userData->type->str, userData->ptr);
className = lua_tostring(L, -1);
lua_pushfstring(L, "<%s userdata: %p>", className, userData);
return 1; return 1;
} }