From: Gunnar Beutner Date: Mon, 17 Aug 2015 05:59:44 +0000 (+0200) Subject: Implement the 'base' field for the Type class X-Git-Tag: v2.4.0~414 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a546a67934d8fbc0b9851acc96e297c5ee14fd9a;p=icinga2 Implement the 'base' field for the Type class fixes #9921 --- diff --git a/lib/base/type.cpp b/lib/base/type.cpp index b8058bb45..02c07939f 100644 --- a/lib/base/type.cpp +++ b/lib/base/type.cpp @@ -71,7 +71,7 @@ Object::Ptr Type::Instantiate(void) const ObjectFactory factory = GetFactory(); if (!factory) - return Object::Ptr(); + BOOST_THROW_EXCEPTION(std::runtime_error("Type does not have a factory function.")); return factory(); } @@ -115,6 +115,8 @@ Value Type::GetField(int id) const { if (id == 0) return GetPrototype(); + else if (id == 1) + return GetBaseType(); return Object::GetField(id); } @@ -148,6 +150,8 @@ int TypeType::GetFieldId(const String& name) const { if (name == "prototype") return 0; + else if (name == "base") + return 1; return -1; } @@ -156,13 +160,15 @@ Field TypeType::GetFieldInfo(int id) const { if (id == 0) return Field(0, "Object", "prototype", NULL, 0); + else if (id == 1) + return Field(1, "Object", "base", NULL, 0); throw std::runtime_error("Invalid field ID."); } int TypeType::GetFieldCount(void) const { - return 1; + return 2; } ObjectFactory TypeType::GetFactory(void) const