mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-12-01 08:31:45 +00:00
- made all internal struct types NativeStructs so that all variables of their types are made references.
This commit is contained in:
parent
360436c201
commit
6cc00e79a6
7 changed files with 27 additions and 6 deletions
|
@ -2457,6 +2457,26 @@ PNativeStruct::PNativeStruct(FName name)
|
|||
HasNativeFields = true;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// NewNativeStruct
|
||||
// Returns a PNativeStruct for the given name and container, making sure not to
|
||||
// create duplicates.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
PNativeStruct *NewNativeStruct(FName name, PTypeBase *outer)
|
||||
{
|
||||
size_t bucket;
|
||||
PType *stype = TypeTable.FindType(RUNTIME_CLASS(PNativeStruct), (intptr_t)outer, (intptr_t)name, &bucket);
|
||||
if (stype == NULL)
|
||||
{
|
||||
stype = new PStruct(name, outer);
|
||||
TypeTable.AddType(stype, RUNTIME_CLASS(PNativeStruct), (intptr_t)outer, (intptr_t)name, bucket);
|
||||
}
|
||||
return static_cast<PNativeStruct *>(stype);
|
||||
}
|
||||
|
||||
/* PField *****************************************************************/
|
||||
|
||||
IMPLEMENT_CLASS(PField, false, false, false, false)
|
||||
|
|
|
@ -922,6 +922,7 @@ PPointer *NewPointer(PType *type, bool isconst = false);
|
|||
PClassPointer *NewClassPointer(PClass *restrict);
|
||||
PEnum *NewEnum(FName name, PTypeBase *outer);
|
||||
PStruct *NewStruct(FName name, PTypeBase *outer);
|
||||
PNativeStruct *NewNativeStruct(FName name, PTypeBase *outer);
|
||||
PPrototype *NewPrototype(const TArray<PType *> &rettypes, const TArray<PType *> &argtypes);
|
||||
|
||||
// Built-in types -----------------------------------------------------------
|
||||
|
|
|
@ -1858,7 +1858,7 @@ void FLevelLocals::AddScroller (int secnum)
|
|||
|
||||
void G_InitLevelLocalsForScript()
|
||||
{
|
||||
PStruct *lstruct = NewStruct("LevelLocals", nullptr);
|
||||
PStruct *lstruct = NewNativeStruct("LevelLocals", nullptr);
|
||||
PField *levelf = new PField("level", lstruct, VARF_Native | VARF_Static, (intptr_t)&level);
|
||||
GlobalSymbols.AddSymbol(levelf);
|
||||
|
||||
|
|
|
@ -161,8 +161,8 @@ void AActor::InitNativeFields()
|
|||
PType *TypeActor = NewPointer(RUNTIME_CLASS(AActor));
|
||||
PType *TypeActorClass = NewClassPointer(RUNTIME_CLASS(AActor));
|
||||
PType *TypeInventory = NewPointer(RUNTIME_CLASS(AInventory));
|
||||
PType *TypePlayer = NewPointer(NewStruct("Player", nullptr));
|
||||
auto TypeSector = NewPointer(NewStruct("Sector", nullptr));
|
||||
PType *TypePlayer = NewPointer(NewNativeStruct("Player", nullptr));
|
||||
auto TypeSector = NewPointer(NewNativeStruct("Sector", nullptr));
|
||||
PType *array5 = NewArray(TypeSInt32, 5);
|
||||
|
||||
auto meta = RUNTIME_CLASS(AActor);
|
||||
|
|
|
@ -3137,7 +3137,7 @@ bool P_IsPlayerTotallyFrozen(const player_t *player)
|
|||
|
||||
void P_InitPlayerForScript()
|
||||
{
|
||||
PStruct *pstruct = NewStruct("Player", nullptr);
|
||||
PStruct *pstruct = NewNativeStruct("Player", nullptr);
|
||||
pstruct->Size = sizeof(player_t);
|
||||
pstruct->Align = alignof(player_t);
|
||||
PArray *parray = NewArray(pstruct, MAXPLAYERS);
|
||||
|
|
|
@ -663,7 +663,7 @@ void InitThingdef()
|
|||
{
|
||||
PType *TypeActor = NewPointer(RUNTIME_CLASS(AActor));
|
||||
|
||||
PStruct *sstruct = NewStruct("Sector", nullptr);
|
||||
PStruct *sstruct = NewNativeStruct("Sector", nullptr);
|
||||
auto sptr = NewPointer(sstruct);
|
||||
sstruct->AddNativeField("soundtarget", TypeActor, myoffsetof(sector_t, SoundTarget));
|
||||
|
||||
|
|
|
@ -1533,7 +1533,7 @@ PType *ZCCCompiler::ResolveUserType(ZCC_BasicType *type, PSymbolTable *symt)
|
|||
{
|
||||
return TypeSInt32; // hack this to an integer until we can resolve the enum mess.
|
||||
}
|
||||
if (ptype->IsKindOf(RUNTIME_CLASS(PClass)))
|
||||
if (ptype->IsKindOf(RUNTIME_CLASS(PNativeStruct))) // native structs and classes cannot be instantiated, they always get used as reference.
|
||||
{
|
||||
return NewPointer(ptype, type->isconst);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue