mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +00:00
- Moved WriteFields into SymbolTable as well.
This commit is contained in:
parent
96631e8808
commit
8dc11317dd
3 changed files with 28 additions and 22 deletions
|
@ -2280,25 +2280,6 @@ PMap *NewMap(PType *keytype, PType *valuetype)
|
||||||
|
|
||||||
IMPLEMENT_CLASS(PStruct, false, false)
|
IMPLEMENT_CLASS(PStruct, false, false)
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// WriteFields
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
static void WriteFields(FSerializer &ar, const void *addr, const TArray<PField *> &fields)
|
|
||||||
{
|
|
||||||
for (unsigned i = 0; i < fields.Size(); ++i)
|
|
||||||
{
|
|
||||||
const PField *field = fields[i];
|
|
||||||
// Skip fields without or with native serialization
|
|
||||||
if (!(field->Flags & (VARF_Transient | VARF_Meta)))
|
|
||||||
{
|
|
||||||
field->Type->WriteValue(ar, field->SymbolName.GetChars(), (const uint8_t *)addr + field->Offset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// PStruct - Default Constructor
|
// PStruct - Default Constructor
|
||||||
|
@ -2369,7 +2350,7 @@ void PStruct::WriteValue(FSerializer &ar, const char *key,const void *addr) cons
|
||||||
{
|
{
|
||||||
if (ar.BeginObject(key))
|
if (ar.BeginObject(key))
|
||||||
{
|
{
|
||||||
WriteFields(ar, addr, Fields);
|
Symbols.WriteFields(ar, addr);
|
||||||
ar.EndObject();
|
ar.EndObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2642,7 +2623,7 @@ static void RecurseWriteFields(const PClass *type, FSerializer &ar, const void *
|
||||||
key.Format("class:%s", type->TypeName.GetChars());
|
key.Format("class:%s", type->TypeName.GetChars());
|
||||||
if (ar.BeginObject(key.GetChars()))
|
if (ar.BeginObject(key.GetChars()))
|
||||||
{
|
{
|
||||||
WriteFields(ar, addr, type->Fields);
|
type->Symbols.WriteFields(ar, addr);
|
||||||
ar.EndObject();
|
ar.EndObject();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -265,11 +265,35 @@ PField *PSymbolTable::AddField(FName name, PType *type, uint32_t flags, unsigned
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// PClass :: WriteFields
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void PSymbolTable::WriteFields(FSerializer &ar, const void *addr, const void *def) const
|
||||||
|
{
|
||||||
|
auto it = MapType::ConstIterator(Symbols);
|
||||||
|
MapType::ConstPair *pair;
|
||||||
|
|
||||||
|
while (it.NextPair(pair))
|
||||||
|
{
|
||||||
|
const PField *field = dyn_cast<PField>(pair->Value);
|
||||||
|
// Skip fields without or with native serialization
|
||||||
|
if (field && !(field->Flags & (VARF_Transient | VARF_Meta)))
|
||||||
|
{
|
||||||
|
// todo: handle defaults in WriteValue
|
||||||
|
//auto defp = def == nullptr ? nullptr : (const uint8_t *)def + field->Offset;
|
||||||
|
field->Type->WriteValue(ar, field->SymbolName.GetChars(), (const uint8_t *)addr + field->Offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// PClass :: ReadFields
|
// PClass :: ReadFields
|
||||||
//
|
//
|
||||||
// This will need some changes later.
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
bool PSymbolTable::ReadFields(FSerializer &ar, void *addr, const char *TypeName) const
|
bool PSymbolTable::ReadFields(FSerializer &ar, void *addr, const char *TypeName) const
|
||||||
|
|
|
@ -217,6 +217,7 @@ struct PSymbolTable
|
||||||
PSymbol *AddSymbol (PSymbol *sym);
|
PSymbol *AddSymbol (PSymbol *sym);
|
||||||
PField *AddField(FName name, PType *type, uint32_t flags, unsigned &Size, unsigned *Align = nullptr);
|
PField *AddField(FName name, PType *type, uint32_t flags, unsigned &Size, unsigned *Align = nullptr);
|
||||||
bool ReadFields(FSerializer &ar, void *addr, const char *TypeName) const;
|
bool ReadFields(FSerializer &ar, void *addr, const char *TypeName) const;
|
||||||
|
void WriteFields(FSerializer &ar, const void *addr, const void *def = nullptr) const;
|
||||||
|
|
||||||
// Similar to AddSymbol but always succeeds. Returns the symbol that used
|
// Similar to AddSymbol but always succeeds. Returns the symbol that used
|
||||||
// to be in the table with this name, if any.
|
// to be in the table with this name, if any.
|
||||||
|
|
Loading…
Reference in a new issue