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

Function PushFieldInfoSubTable

library/LuaTypes.cpp:1399–1441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1397}
1398
1399static void PushFieldInfoSubTable(lua_State *state, const struct_field_info *field)
1400{
1401 if (!field) {
1402 lua_pushnil(state);
1403 return;
1404 }
1405
1406 lua_newtable(state); // new field info
1407 Lua::TableInsert(state, "mode", field->mode);
1408 Lua::TableInsert(state, "name", field->name);
1409 Lua::TableInsert(state, "offset", field->offset);
1410 Lua::TableInsert(state, "count", field->count);
1411
1412 if (field->type) {
1413 Lua::TableInsert(state, "type_name", field->type->getFullName());
1414
1415 lua_pushlightuserdata(state, const_cast<type_identity*>(field->type));
1416 lua_setfield(state, -2, "type_identity");
1417
1418 PushTypeIdentity(state, field->type);
1419 lua_setfield(state, -2, "type");
1420 }
1421
1422 if (field->extra) {
1423 if (field->extra->index_enum) {
1424 PushTypeIdentity(state, field->extra->index_enum);
1425 lua_setfield(state, -2, "index_enum");
1426 }
1427 if (field->extra->ref_target) {
1428 PushTypeIdentity(state, field->extra->ref_target);
1429 lua_setfield(state, -2, "ref_target");
1430 }
1431 if (field->extra->union_tag_field) {
1432 Lua::TableInsert(state, "union_tag_field", field->extra->union_tag_field);
1433 }
1434 if (field->extra->union_tag_attr) {
1435 Lua::TableInsert(state, "union_tag_attr", field->extra->union_tag_attr);
1436 }
1437 if (field->extra->original_name) {
1438 Lua::TableInsert(state, "original_name", field->extra->original_name);
1439 }
1440 }
1441}
1442
1443/**
1444 * Metamethod: __index for struct._fields

Callers 3

meta_fieldinfo_indexFunction · 0.85
meta_fieldinfo_nextFunction · 0.85
AddFieldInfoTableFunction · 0.85

Calls 6

lua_pushnilFunction · 0.85
TableInsertFunction · 0.85
lua_pushlightuserdataFunction · 0.85
lua_setfieldFunction · 0.85
PushTypeIdentityFunction · 0.85
getFullNameMethod · 0.45

Tested by

no test coverage detected