MCPcopy Create free account
hub / github.com/DFHack/dfhack / lua_insert2

Method lua_insert2

library/LuaTypes.cpp:340–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338}
339
340bool container_identity::lua_insert2(lua_State *state, int fname_idx, void *ptr, int idx, int val_index) const
341{
342 auto id = (type_identity*)lua_touserdata(state, UPVAL_ITEM_ID);
343
344 char tmp[32];
345 void *pitem = &tmp;
346
347 if (id->isPrimitive())
348 {
349 if (id->isConstructed())
350 luaL_error(state, "Temporaries of type %s not supported", id->getFullName().c_str());
351
352 assert(id->byte_size() <= sizeof(tmp));
353 id->lua_write(state, fname_idx, pitem, val_index);
354 }
355 else
356 {
357 pitem = get_object_internal(state, id, val_index, false);
358 if (!pitem)
359 field_error(state, fname_idx, "incompatible object type", "insert");
360 }
361
362 return insert(ptr, idx, pitem);
363}
364
365void ptr_container_identity::lua_item_reference(lua_State *state, int fname_idx, void *ptr, int idx) const
366{

Callers 1

method_container_insertFunction · 0.45

Calls 7

lua_touserdataFunction · 0.85
luaL_errorFunction · 0.85
insertFunction · 0.85
c_strMethod · 0.80
byte_sizeMethod · 0.80
lua_writeMethod · 0.80
getFullNameMethod · 0.45

Tested by

no test coverage detected