- changed TObjPtr to take a pointer as its template argument and not the class it points to.

This addresses the main issue with TObjPtr, namely that using it required pulling in the entire class hierarchy in basic headers like r_defs which polluted nearly every single source file in the project.
This commit is contained in:
Christoph Oelckers 2017-03-08 13:34:26 +01:00
commit b8f7e305db
37 changed files with 124 additions and 140 deletions

View file

@ -3257,7 +3257,7 @@ void FParser::SF_SpawnMissile()
void FParser::SF_MapThingNumExist()
{
TArray<TObjPtr<AActor> > &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings;
auto &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings;
int intval;
@ -3295,7 +3295,7 @@ void FParser::SF_MapThingNumExist()
void FParser::SF_MapThings()
{
TArray<TObjPtr<AActor> > &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings;
auto &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings;
t_return.type = svt_int;
t_return.value.i = SpawnedThings.Size();

View file

@ -375,7 +375,7 @@ void T_AddSpawnedThing(AActor * ac)
{
if (DFraggleThinker::ActiveThinker)
{
TArray<TObjPtr<AActor> > &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings;
auto &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings;
SpawnedThings.Push(GC::ReadBarrier(ac));
}
}

View file

@ -388,7 +388,7 @@ IMPLEMENT_POINTERS_START(DFraggleThinker)
IMPLEMENT_POINTER(LevelScript)
IMPLEMENT_POINTERS_END
TObjPtr<DFraggleThinker> DFraggleThinker::ActiveThinker;
TObjPtr<DFraggleThinker*> DFraggleThinker::ActiveThinker;
//==========================================================================
//

View file

@ -174,11 +174,11 @@ struct DFsVariable : public DObject
public:
FString Name;
TObjPtr<DFsVariable> next; // for hashing
TObjPtr<DFsVariable*> next; // for hashing
int type; // svt_string or svt_int: same as in svalue_t
FString string;
TObjPtr<AActor> actor;
TObjPtr<AActor*> actor;
union value_t
{
@ -241,7 +241,7 @@ public:
int start_index;
int end_index;
int loop_index;
TObjPtr<DFsSection> next; // for hashing
TObjPtr<DFsSection*> next; // for hashing
DFsSection()
{
@ -320,27 +320,27 @@ public:
// {} sections
TObjPtr<DFsSection> sections[SECTIONSLOTS];
TObjPtr<DFsSection*> sections[SECTIONSLOTS];
// variables:
TObjPtr<DFsVariable> variables[VARIABLESLOTS];
TObjPtr<DFsVariable*> variables[VARIABLESLOTS];
// ptr to the parent script
// the parent script is the script above this level
// eg. individual linetrigger scripts are children
// of the levelscript, which is a child of the
// global_script
TObjPtr<DFsScript> parent;
TObjPtr<DFsScript*> parent;
// haleyjd: 8-17
// child scripts.
// levelscript holds ptrs to all of the level's scripts
// here.
TObjPtr<DFsScript> children[MAXSCRIPTS];
TObjPtr<DFsScript*> children[MAXSCRIPTS];
TObjPtr<AActor> trigger; // object which triggered this script
TObjPtr<AActor*> trigger; // object which triggered this script
bool lastiftrue; // haleyjd: whether last "if" statement was
// true or false
@ -665,7 +665,7 @@ public:
void OnDestroy() override;
void Serialize(FSerializer &arc);
TObjPtr<DFsScript> script;
TObjPtr<DFsScript*> script;
// where we are
int save_point;
@ -674,10 +674,10 @@ public:
int wait_data; // data for wait: tagnum, counter, script number etc
// saved variables
TObjPtr<DFsVariable> variables[VARIABLESLOTS];
TObjPtr<DFsVariable*> variables[VARIABLESLOTS];
TObjPtr<DRunningScript> prev, next; // for chain
TObjPtr<AActor> trigger;
TObjPtr<DRunningScript*> prev, next; // for chain
TObjPtr<AActor*> trigger;
};
//-----------------------------------------------------------------------------
@ -691,9 +691,9 @@ class DFraggleThinker : public DThinker
HAS_OBJECT_POINTERS
public:
TObjPtr<DFsScript> LevelScript;
TObjPtr<DRunningScript> RunningScripts;
TArray<TObjPtr<AActor> > SpawnedThings;
TObjPtr<DFsScript*> LevelScript;
TObjPtr<DRunningScript*> RunningScripts;
TArray<TObjPtr<AActor*> > SpawnedThings;
bool nocheckposition;
bool setcolormaterial;
@ -708,7 +708,7 @@ public:
bool wait_finished(DRunningScript *script);
void AddRunningScript(DRunningScript *runscr);
static TObjPtr<DFraggleThinker> ActiveThinker;
static TObjPtr<DFraggleThinker*> ActiveThinker;
};
//-----------------------------------------------------------------------------

View file

@ -153,7 +153,7 @@ AActor* actorvalue(const svalue_t &svalue)
}
else
{
TArray<TObjPtr<AActor> > &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings;
auto &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings;
// this requires some creativity. We use the intvalue
// as the thing number of a thing in the level.
intval = intvalue(svalue);