From 199d4dc57f0b03c701661769cc42118755376845 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 9 May 2006 22:10:43 +0000 Subject: [PATCH] - Backported the improved hierarchical dumpclasses command from the FP code. SVN r94 (trunk) --- docs/rh-log.txt | 1 + src/dobject.h | 88 +++++++++++++++++-------------------------------- 2 files changed, 32 insertions(+), 57 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 4761e8a190..4545365f4c 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,5 @@ May 9, 2006 +- Backported the improved hierarchical dumpclasses command from the FP code. - Updated Jim's Makefile.linux. - Added support for wrapping midtextures vertically. - Since zdoom.wad is now zdoom.pk3, the default mapinfos can use full pathnames. diff --git a/src/dobject.h b/src/dobject.h index 4242d1c1f7..f9aab5504d 100644 --- a/src/dobject.h +++ b/src/dobject.h @@ -38,6 +38,8 @@ #include "tarray.h" #include "doomtype.h" +class TypeInfo; + class FArchive; class DObject; @@ -130,57 +132,21 @@ private: void CopyMeta (const FMetaTable *other); }; -struct TypeInfo -{ - static void StaticInit (); - static void StaticFreeData (TypeInfo *type); +#define RUNTIME_TYPE(object) (object->GetClass()) // Passed an object, returns the type of that object +#define RUNTIME_CLASS(cls) (&cls::_StaticType) // Passed a class name, returns a TypeInfo representing that class +struct ClassReg +{ + TypeInfo *MyClass; const char *Name; TypeInfo *ParentType; unsigned int SizeOf; - const size_t *Pointers; // object pointers defined by this class *only* + POINTY_TYPE(DObject) *Pointers; void (*ConstructNative)(void *); - FActorInfo *ActorInfo; - unsigned int HashNext; - unsigned short TypeIndex; - bool bRuntimeClass; // class was defined at run-time, not compile-time - FMetaTable Meta; - const size_t *FlatPointers; // object pointers defined by this class and all its superclasses; not initialized by default - void RegisterType (); - DObject *CreateNew () const; - TypeInfo *CreateDerivedClass (char *name, unsigned int size); - void BuildFlatPointers (); - - // Returns true if this type is an ancestor of (or same as) the passed type. - bool IsAncestorOf (const TypeInfo *ti) const - { - while (ti) - { - if (this == ti) - return true; - ti = ti->ParentType; - } - return false; - } - inline bool IsDescendantOf (const TypeInfo *ti) const - { - return ti->IsAncestorOf (this); - } - - static const TypeInfo *FindType (const char *name); - static const TypeInfo *IFindType (const char *name); - - static TArray m_Types; - static TArray m_RuntimeActors; - - enum { HASH_SIZE = 256 }; - static unsigned int TypeHash[HASH_SIZE]; + void RegisterClass(); }; -#define RUNTIME_TYPE(object) (object->GetClass()) // Passed an object, returns the type of that object -#define RUNTIME_CLASS(cls) (&cls::_StaticType) // Passed a class name, returns a TypeInfo representing that class - enum EInPlace { EC_InPlace }; #define DECLARE_ABSTRACT_CLASS(cls,parent) \ @@ -255,23 +221,24 @@ class DObject public: \ static TypeInfo _StaticType; \ virtual TypeInfo *StaticType() const { return &_StaticType; } \ + static ClassReg RegistrationInfo; + static void InPlaceConstructor (void *mem); private: \ typedef DObject ThisClass; + // Per-instance variables. There are three. public: + DWORD ObjectFlags; // Flags for this object +private: + TypeInfo *Class; // This object's type + size_t Index; // This object's index in the global object table + DObject (); DObject (TypeInfo *inClass); virtual ~DObject (); - inline bool IsKindOf (const TypeInfo *base) const - { - return base->IsAncestorOf (GetClass ()); - } - - inline bool IsA (const TypeInfo *type) const - { - return (type == GetClass()); - } + inline bool IsKindOf (const TypeInfo *base) const; + inline bool IsA (const TypeInfo *type) const; virtual void Serialize (FArchive &arc); @@ -289,8 +256,6 @@ public: // use this method. static void PointerSubstitution (DObject *old, DObject *notOld); - DWORD ObjectFlags; - static void STACK_ARGS StaticShutdown (); TypeInfo *GetClass() const @@ -333,8 +298,6 @@ protected: } private: - TypeInfo *Class; - static TArray Objects; static TArray FreeIndices; static TArray ToDestroy; @@ -345,7 +308,18 @@ private: void RemoveFromArray (); static bool Inactive; - size_t Index; }; +#include "dobjtype.h" + +inline bool DObject::IsKindOf (const TypeInfo *base) const +{ + return base->IsAncestorOf (GetClass ()); +} + +inline bool DObject::IsA (const TypeInfo *type) const +{ + return (type == GetClass()); +} + #endif //__DOBJECT_H__