From fa4e7b42196fa42a0f5750d3723944a082bc39a4 Mon Sep 17 00:00:00 2001 From: linhsu0723 Date: Sun, 9 Apr 2023 02:34:04 +0800 Subject: [PATCH] Use RTTI macros for Object also --- include/mitsuba/core/object.h | 7 ++----- src/libcore/object.cpp | 7 +------ 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/include/mitsuba/core/object.h b/include/mitsuba/core/object.h index 1d616cf4d..ddc0a2ad0 100644 --- a/include/mitsuba/core/object.h +++ b/include/mitsuba/core/object.h @@ -56,9 +56,6 @@ class MTS_EXPORT_CORE Object { */ void decRef(bool autoDeallocate = true) const; - /// Retrieve this object's class - virtual const Class *getClass() const; - /** * \brief Return a human-readable string representation * of the object's contents. @@ -77,13 +74,13 @@ class MTS_EXPORT_CORE Object { /// Free the memory taken by staticInitialization() static void staticShutdown(); + + MTS_DECLARE_CLASS() protected: /** \brief Virtual private deconstructor. * (Will only be called by \ref ref) */ virtual ~Object(); -public: - static Class *m_theClass; ///< Pointer to the object's class descriptor private: #if !defined(_MSC_VER) volatile mutable int m_refCount; diff --git a/src/libcore/object.cpp b/src/libcore/object.cpp index 866ea561d..b23a36502 100644 --- a/src/libcore/object.cpp +++ b/src/libcore/object.cpp @@ -78,8 +78,6 @@ static RefCountTracker *__ref_tracker = NULL; } // namespace #endif -Class *MTS_CLASS(Object) = new Class("Object", false, ""); - Object::Object() : m_refCount(0) { #if DEBUG_REFCOUNTS == 1 @@ -126,10 +124,6 @@ void Object::decRef(bool autoDeallocate) const { } } -const Class *Object::getClass() const { - return m_theClass; -} - std::string Object::toString() const { std::ostringstream oss; oss << getClass()->getName(); @@ -160,4 +154,5 @@ void Object::staticShutdown() { #endif } +MTS_IMPLEMENT_CLASS(Object, false, ) MTS_NAMESPACE_END