update structures; implement struct_field_info_extra

develop
Ben Lubar 2020-03-21 13:21:35 -05:00
parent 9852d92a98
commit b29d009b14
No known key found for this signature in database
GPG Key ID: 92939677AB59EDA4
4 changed files with 16 additions and 8 deletions

@ -508,8 +508,8 @@ static void read_field(lua_State *state, const struct_field_info *field, void *p
return;
case struct_field_info::CONTAINER:
if (!field->eid || !field->type->isContainer() ||
field->eid == ((container_identity*)field->type)->getIndexEnumType())
if (!field->extra || !field->extra->index_enum || !field->type->isContainer() ||
field->extra->index_enum == ((container_identity*)field->type)->getIndexEnumType())
{
field->type->lua_read(state, 2, ptr);
return;
@ -1445,7 +1445,7 @@ static void GetAdHocMetatable(lua_State *state, const struct_field_info *field)
case struct_field_info::CONTAINER:
{
auto ctype = (container_identity*)field->type;
MakeContainerMetatable(state, ctype, ctype->getItemType(), -1, field->eid);
MakeContainerMetatable(state, ctype, ctype->getItemType(), -1, field->extra ? field->extra->index_enum : nullptr);
break;
}
@ -1456,12 +1456,12 @@ static void GetAdHocMetatable(lua_State *state, const struct_field_info *field)
case struct_field_info::STATIC_ARRAY:
MakeContainerMetatable(state, &df::buffer_container_identity::base_instance,
field->type, field->count, field->eid);
field->type, field->count, field->extra ? field->extra->index_enum : nullptr);
break;
case struct_field_info::STL_VECTOR_PTR:
MakeContainerMetatable(state, &df::identity_traits<std::vector<void*> >::identity,
field->type, -1, field->eid);
field->type, -1, field->extra ? field->extra->index_enum : nullptr);
break;
default:

@ -252,6 +252,13 @@ namespace DFHack
virtual void lua_write(lua_State *state, int fname_idx, void *ptr, int val_index);
};
struct struct_field_info_extra {
enum_identity *index_enum;
type_identity *ref_target;
const char *union_tag_field;
const char *union_tag_attr;
};
struct struct_field_info {
enum Mode {
END,
@ -270,7 +277,7 @@ namespace DFHack
size_t offset;
type_identity *type;
size_t count;
enum_identity *eid;
const struct_field_info_extra *extra;
};
class DFHACK_EXPORT struct_identity : public compound_identity {
@ -452,6 +459,7 @@ namespace df
using DFHack::struct_identity;
using DFHack::union_identity;
using DFHack::struct_field_info;
using DFHack::struct_field_info_extra;
using DFHack::bitfield_item_info;
using DFHack::bitfield_identity;
using DFHack::enum_identity;

@ -1 +1 @@
Subproject commit ef09097be76a58b5911b5bf65bee7c3cd6d7bb16
Subproject commit 6ad3e99e1ed26f1b0af210f941ace905a70b50e7

@ -40,7 +40,7 @@ CheckedStructure::CheckedStructure(const struct_field_info *field) :
}
identity = field->type;
eid = field->eid;
eid = field->extra ? field->extra->index_enum : nullptr;
inside_structure = true;
switch (field->mode)
{