mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
Single RUNTIME_CLASS() macro for classes and templates
The main purpose of this is to fix compilation errors with GCC/Clang src/dobject.h:87:48: error: expected primary-expression before ‘)’ token
This commit is contained in:
parent
cde450dd8a
commit
2add60a4c4
3 changed files with 7 additions and 8 deletions
|
@ -739,7 +739,7 @@ public:
|
|||
AInventory *FindInventory (FName type, bool subclass = false);
|
||||
template<class T> T *FindInventory ()
|
||||
{
|
||||
return static_cast<T *> (FindInventory (RUNTIME_TEMPLATE_CLASS(T)));
|
||||
return static_cast<T *> (FindInventory (RUNTIME_CLASS(T)));
|
||||
}
|
||||
|
||||
// Adds one item of a particular type. Returns NULL if it could not be added.
|
||||
|
@ -1512,7 +1512,7 @@ public:
|
|||
do
|
||||
{
|
||||
actor = FActorIterator::Next ();
|
||||
} while (actor && !actor->IsKindOf (RUNTIME_TEMPLATE_CLASS(T)));
|
||||
} while (actor && !actor->IsKindOf (RUNTIME_CLASS(T)));
|
||||
return static_cast<T *>(actor);
|
||||
}
|
||||
};
|
||||
|
@ -1563,12 +1563,12 @@ inline AActor *Spawn(FName type, const DVector3 &pos, replace_t allowreplacement
|
|||
|
||||
template<class T> inline T *Spawn(const DVector3 &pos, replace_t allowreplacement)
|
||||
{
|
||||
return static_cast<T *>(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), pos, allowreplacement));
|
||||
return static_cast<T *>(AActor::StaticSpawn(RUNTIME_CLASS(T), pos, allowreplacement));
|
||||
}
|
||||
|
||||
template<class T> inline T *Spawn() // for inventory items we do not need coordinates and replacement info.
|
||||
{
|
||||
return static_cast<T *>(AActor::StaticSpawn(RUNTIME_TEMPLATE_CLASS(T), DVector3(0, 0, 0), NO_REPLACE));
|
||||
return static_cast<T *>(AActor::StaticSpawn(RUNTIME_CLASS(T), DVector3(0, 0, 0), NO_REPLACE));
|
||||
}
|
||||
|
||||
inline PClassActor *PClass::FindActor(FName name)
|
||||
|
|
|
@ -84,8 +84,7 @@ class DPillar;
|
|||
class PClassActor;
|
||||
|
||||
#define RUNTIME_CLASS_CASTLESS(cls) (cls::RegistrationInfo.MyClass) // Passed a native class name, returns a PClass representing that class
|
||||
#define RUNTIME_CLASS(cls) ((cls::MetaClass *)RUNTIME_CLASS_CASTLESS(cls)) // Like above, but returns the true type of the meta object
|
||||
#define RUNTIME_TEMPLATE_CLASS(cls) ((typename cls::MetaClass *)RUNTIME_CLASS_CASTLESS(cls)) // RUNTIME_CLASS, but works with templated parameters on GCC
|
||||
#define RUNTIME_CLASS(cls) ((typename cls::MetaClass *)RUNTIME_CLASS_CASTLESS(cls)) // Like above, but returns the true type of the meta object
|
||||
#define NATIVE_TYPE(object) (object->StaticType()) // Passed an object, returns the type of the C++ class representing the object
|
||||
|
||||
// Enumerations for the meta classes created by ClassReg::RegisterClass()
|
||||
|
|
|
@ -134,10 +134,10 @@ protected:
|
|||
template <class T> class TThinkerIterator : public FThinkerIterator
|
||||
{
|
||||
public:
|
||||
TThinkerIterator (int statnum=MAX_STATNUM+1) : FThinkerIterator (RUNTIME_TEMPLATE_CLASS(T), statnum)
|
||||
TThinkerIterator (int statnum=MAX_STATNUM+1) : FThinkerIterator (RUNTIME_CLASS(T), statnum)
|
||||
{
|
||||
}
|
||||
TThinkerIterator (int statnum, DThinker *prev) : FThinkerIterator (RUNTIME_TEMPLATE_CLASS(T), statnum, prev)
|
||||
TThinkerIterator (int statnum, DThinker *prev) : FThinkerIterator (RUNTIME_CLASS(T), statnum, prev)
|
||||
{
|
||||
}
|
||||
TThinkerIterator (const PClass *subclass, int statnum=MAX_STATNUM+1) : FThinkerIterator(subclass, statnum)
|
||||
|
|
Loading…
Reference in a new issue