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

Function read_bitfield

library/LuaTypes.cpp:1088–1097  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1086}
1087
1088static void read_bitfield(lua_State *state, uint8_t *ptr, bitfield_identity *id, int idx)
1089{
1090 int size = std::max(1, id->getBits()[idx].size);
1091
1092 int value = getBitfieldField(ptr, idx, size);
1093 if (size <= 1)
1094 lua_pushboolean(state, value != 0);
1095 else
1096 lua_pushinteger(state, value);
1097}
1098
1099/**
1100 * Metamethod: __index for bitfields.

Callers 2

meta_bitfield_indexFunction · 0.85
meta_bitfield_nextiFunction · 0.85

Calls 2

lua_pushbooleanFunction · 0.85
lua_pushintegerFunction · 0.85

Tested by

no test coverage detected