* Push the pointer using given identity. */
| 200 | * Push the pointer using given identity. |
| 201 | */ |
| 202 | void LuaWrapper::push_object_internal(lua_State *state, const type_identity *type, void *ptr, bool in_method) |
| 203 | { |
| 204 | /* |
| 205 | * If NULL pointer or no type, push something simple |
| 206 | */ |
| 207 | |
| 208 | if (!ptr || !type) |
| 209 | { |
| 210 | if (!ptr) |
| 211 | lua_pushnil(state); |
| 212 | else |
| 213 | lua_pushlightuserdata(state, ptr); |
| 214 | |
| 215 | return; |
| 216 | } |
| 217 | |
| 218 | /* |
| 219 | * Resolve actual class using vtable |
| 220 | */ |
| 221 | |
| 222 | if (type->type() == IDTYPE_CLASS) |
| 223 | { |
| 224 | const virtual_identity *class_vid = virtual_identity::get(virtual_ptr(ptr)); |
| 225 | if (class_vid) |
| 226 | type = class_vid; |
| 227 | } |
| 228 | |
| 229 | /* |
| 230 | * Resolve metatable by identity, and push the object |
| 231 | */ |
| 232 | |
| 233 | lua_pushlightuserdata(state, const_cast<type_identity*>(type)); // () -> type |
| 234 | |
| 235 | if (!LookupTypeInfo(state, in_method)) // type -> metatable? |
| 236 | BuildTypeMetatable(state, type); // () -> metatable |
| 237 | |
| 238 | push_object_ref(state, ptr); // metatable -> userdata |
| 239 | } |
| 240 | |
| 241 | static void fetch_container_details(lua_State *state, int meta, const type_identity **pitem, int *pcount) |
| 242 | { |
nothing calls this directly
no test coverage detected