mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-25 13:41:05 +00:00
- moved AddNativeField to PSymbolTable, too.
This commit is contained in:
parent
8dc11317dd
commit
afd6743965
4 changed files with 36 additions and 27 deletions
|
@ -2314,9 +2314,12 @@ PStruct::PStruct(FName name, PTypeBase *outer, bool isnative)
|
|||
|
||||
void PStruct::SetDefaultValue(void *base, unsigned offset, TArray<FTypeAndOffset> *special)
|
||||
{
|
||||
for (const PField *field : Fields)
|
||||
auto it = Symbols.GetIterator();
|
||||
PSymbolTable::MapType::Pair *pair;
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
if (!(field->Flags & VARF_Transient))
|
||||
auto field = dyn_cast<PField>(pair->Value);
|
||||
if (field && !(field->Flags & VARF_Transient))
|
||||
{
|
||||
field->Type->SetDefaultValue(base, unsigned(offset + field->Offset), special);
|
||||
}
|
||||
|
@ -2331,9 +2334,12 @@ void PStruct::SetDefaultValue(void *base, unsigned offset, TArray<FTypeAndOffset
|
|||
|
||||
void PStruct::SetPointer(void *base, unsigned offset, TArray<size_t> *special)
|
||||
{
|
||||
for (const PField *field : Fields)
|
||||
auto it = Symbols.GetIterator();
|
||||
PSymbolTable::MapType::Pair *pair;
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
if (!(field->Flags & VARF_Transient))
|
||||
auto field = dyn_cast<PField>(pair->Value);
|
||||
if (field && !(field->Flags & VARF_Transient))
|
||||
{
|
||||
field->Type->SetPointer(base, unsigned(offset + field->Offset), special);
|
||||
}
|
||||
|
@ -2383,9 +2389,7 @@ bool PStruct::ReadValue(FSerializer &ar, const char *key, void *addr) const
|
|||
|
||||
PField *PStruct::AddField(FName name, PType *type, uint32_t flags)
|
||||
{
|
||||
auto field = Symbols.AddField(name, type, flags, Size, &Align);
|
||||
if (field != nullptr) Fields.Push(field);
|
||||
return field;
|
||||
return Symbols.AddField(name, type, flags, Size, &Align);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -2399,15 +2403,7 @@ PField *PStruct::AddField(FName name, PType *type, uint32_t flags)
|
|||
|
||||
PField *PStruct::AddNativeField(FName name, PType *type, size_t address, uint32_t flags, int bitvalue)
|
||||
{
|
||||
PField *field = new PField(name, type, flags|VARF_Native|VARF_Transient, address, bitvalue);
|
||||
|
||||
if (Symbols.AddSymbol(field) == nullptr)
|
||||
{ // name is already in use
|
||||
field->Destroy();
|
||||
return nullptr;
|
||||
}
|
||||
Fields.Push(field);
|
||||
return field;
|
||||
return Symbols.AddNativeField(name, type, address, flags, bitvalue);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -3305,20 +3301,12 @@ PField *PClass::AddField(FName name, PType *type, uint32_t flags)
|
|||
//
|
||||
// PClass :: AddNativeField
|
||||
//
|
||||
// This looks the same as the struct version but that will change later.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
PField *PClass::AddNativeField(FName name, PType *type, size_t address, uint32_t flags, int bitvalue)
|
||||
{
|
||||
PField *field = new PField(name, type, flags | VARF_Native | VARF_Transient, address, bitvalue);
|
||||
|
||||
if (Symbols.AddSymbol(field) == nullptr)
|
||||
{ // name is already in use
|
||||
field->Destroy();
|
||||
return nullptr;
|
||||
}
|
||||
Fields.Push(field);
|
||||
auto field = Symbols.AddNativeField(name, type, address, flags, bitvalue);
|
||||
if (field != nullptr) Fields.Push(field);
|
||||
return field;
|
||||
}
|
||||
|
||||
|
|
|
@ -546,7 +546,6 @@ class PStruct : public PContainerType
|
|||
public:
|
||||
PStruct(FName name, PTypeBase *outer, bool isnative = false);
|
||||
|
||||
TArray<PField *> Fields;
|
||||
bool isNative;
|
||||
// Some internal structs require explicit construction and destruction of fields the VM cannot handle directly so use these two functions for it.
|
||||
VMFunction *mConstructor = nullptr;
|
||||
|
|
|
@ -265,6 +265,27 @@ PField *PSymbolTable::AddField(FName name, PType *type, uint32_t flags, unsigned
|
|||
return field;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PStruct :: AddField
|
||||
//
|
||||
// Appends a new native field to the struct. Returns either the new field
|
||||
// or nullptr if a symbol by that name already exists.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
PField *PSymbolTable::AddNativeField(FName name, PType *type, size_t address, uint32_t flags, int bitvalue)
|
||||
{
|
||||
PField *field = new PField(name, type, flags | VARF_Native | VARF_Transient, address, bitvalue);
|
||||
|
||||
if (AddSymbol(field) == nullptr)
|
||||
{ // name is already in use
|
||||
field->Destroy();
|
||||
return nullptr;
|
||||
}
|
||||
return field;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// PClass :: WriteFields
|
||||
|
|
|
@ -216,6 +216,7 @@ struct PSymbolTable
|
|||
// not copied and will be freed when the symbol table is destroyed.
|
||||
PSymbol *AddSymbol (PSymbol *sym);
|
||||
PField *AddField(FName name, PType *type, uint32_t flags, unsigned &Size, unsigned *Align = nullptr);
|
||||
PField *AddNativeField(FName name, PType *type, size_t address, uint32_t flags, int bitvalue);
|
||||
bool ReadFields(FSerializer &ar, void *addr, const char *TypeName) const;
|
||||
void WriteFields(FSerializer &ar, const void *addr, const void *def = nullptr) const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue