+ {
+ /* copy the data */
+ size_t size = lua_objlen(src, -1);
+ void* src_block = lua_touserdata(src, -1);
+ void* dst_block = lua_newuserdata(dst, size);
+ memcpy(dst_block, src_block, size);
+
+ /* copy the metatable if any */
+ int has_meta_table = lua_getmetatable(src, -1);
+ /* src: ... udata mt? */
+ if (has_meta_table) {
+ XBT_DEBUG("%sCopying metatable of userdata", get_spaces(indent));
+ /* src: ... udata mt */
+ move_value_impl(src, dst, "metatable");
+ /* src: ... udata
+ dst: visited ... udata mt */
+ lua_setmetatable(dst, -2);
+ /* dst: visited ... udata */
+
+ XBT_DEBUG("%sMetatable of userdata copied", get_spaces(indent));
+ }
+ else {
+ XBT_DEBUG("%sNo metatable for this userdata", get_spaces(indent));
+ /* src: ... udata */
+ }
+ }
+ break;