diff --git a/lib/base/array.cpp b/lib/base/array.cpp index 55a53b71e..4365b3dd8 100644 --- a/lib/base/array.cpp +++ b/lib/base/array.cpp @@ -26,7 +26,7 @@ using namespace icinga; -REGISTER_PRIMITIVE_TYPE(Array, Array::GetPrototype()); +REGISTER_PRIMITIVE_TYPE(Array, Object, Array::GetPrototype()); /** * Restrieves a value from an array. diff --git a/lib/base/dictionary.cpp b/lib/base/dictionary.cpp index 6c3e7b771..33d043b6d 100644 --- a/lib/base/dictionary.cpp +++ b/lib/base/dictionary.cpp @@ -25,7 +25,7 @@ using namespace icinga; -REGISTER_PRIMITIVE_TYPE(Dictionary, Dictionary::GetPrototype()); +REGISTER_PRIMITIVE_TYPE(Dictionary, Object, Dictionary::GetPrototype()); /** * Retrieves a value from a dictionary. diff --git a/lib/base/function.cpp b/lib/base/function.cpp index 176980768..6d0e850a6 100644 --- a/lib/base/function.cpp +++ b/lib/base/function.cpp @@ -23,7 +23,7 @@ using namespace icinga; -REGISTER_PRIMITIVE_TYPE_NOINST(Function, Function::GetPrototype()); +REGISTER_PRIMITIVE_TYPE_NOINST(Function, Object, Function::GetPrototype()); Function::Function(const Callback& function, bool side_effect_free) : m_Callback(function), m_SideEffectFree(side_effect_free) diff --git a/lib/base/object.cpp b/lib/base/object.cpp index e341640a6..1eff59e21 100644 --- a/lib/base/object.cpp +++ b/lib/base/object.cpp @@ -25,7 +25,7 @@ using namespace icinga; -REGISTER_PRIMITIVE_TYPE(Object, Object::GetPrototype()); +REGISTER_PRIMITIVE_TYPE(Object, None, Object::GetPrototype()); /** * Default constructor for the Object class. diff --git a/lib/base/primitivetype.cpp b/lib/base/primitivetype.cpp index fd2e485c9..6da74c466 100644 --- a/lib/base/primitivetype.cpp +++ b/lib/base/primitivetype.cpp @@ -22,8 +22,8 @@ using namespace icinga; -PrimitiveType::PrimitiveType(const String& name, const ObjectFactory& factory) - : m_Name(name), m_Factory(factory) +PrimitiveType::PrimitiveType(const String& name, const String& base, const ObjectFactory& factory) + : m_Name(name), m_Base(base), m_Factory(factory) { } String PrimitiveType::GetName(void) const @@ -33,7 +33,10 @@ String PrimitiveType::GetName(void) const Type::Ptr PrimitiveType::GetBaseType(void) const { - return Type::Ptr(); + if (m_Base == "None") + return Type::Ptr(); + else + return Type::GetByName(m_Base); } int PrimitiveType::GetAttributes(void) const diff --git a/lib/base/primitivetype.hpp b/lib/base/primitivetype.hpp index 53aa901cd..4853bd192 100644 --- a/lib/base/primitivetype.hpp +++ b/lib/base/primitivetype.hpp @@ -30,7 +30,7 @@ namespace icinga class I2_BASE_API PrimitiveType : public Type { public: - PrimitiveType(const String& name, const ObjectFactory& factory = ObjectFactory()); + PrimitiveType(const String& name, const String& base, const ObjectFactory& factory = ObjectFactory()); virtual String GetName(void) const; virtual Type::Ptr GetBaseType(void) const; @@ -44,6 +44,7 @@ protected: private: String m_Name; + String m_Base; ObjectFactory m_Factory; }; @@ -51,18 +52,18 @@ private: namespace { namespace UNIQUE_NAME(prt) { namespace prt ## type { \ void RegisterBuiltinType(void) \ { \ - icinga::Type::Ptr t = new PrimitiveType(#type); \ + icinga::Type::Ptr t = new PrimitiveType(#type, "None"); \ t->SetPrototype(prototype); \ icinga::Type::Register(t); \ } \ INITIALIZE_ONCE_WITH_PRIORITY(RegisterBuiltinType, 15); \ } } } -#define REGISTER_PRIMITIVE_TYPE_FACTORY(type, prototype, factory) \ +#define REGISTER_PRIMITIVE_TYPE_FACTORY(type, base, prototype, factory) \ namespace { namespace UNIQUE_NAME(prt) { namespace prt ## type { \ void RegisterPrimitiveType(void) \ { \ - icinga::Type::Ptr t = new PrimitiveType(#type, factory);\ + icinga::Type::Ptr t = new PrimitiveType(#type, #base, factory);\ t->SetPrototype(prototype); \ icinga::Type::Register(t); \ type::TypeInstance = t; \ @@ -71,11 +72,11 @@ private: } } } \ DEFINE_TYPE_INSTANCE(type) -#define REGISTER_PRIMITIVE_TYPE(type, prototype) \ - REGISTER_PRIMITIVE_TYPE_FACTORY(type, prototype, DefaultObjectFactory) +#define REGISTER_PRIMITIVE_TYPE(type, base, prototype) \ + REGISTER_PRIMITIVE_TYPE_FACTORY(type, base, prototype, DefaultObjectFactory) -#define REGISTER_PRIMITIVE_TYPE_NOINST(type, prototype) \ - REGISTER_PRIMITIVE_TYPE_FACTORY(type, prototype, NULL) +#define REGISTER_PRIMITIVE_TYPE_NOINST(type, base, prototype) \ + REGISTER_PRIMITIVE_TYPE_FACTORY(type, base, prototype, NULL) }