From: Gunnar Beutner Date: Wed, 28 Jan 2015 07:36:17 +0000 (+0100) Subject: Implement get_object() and get_objects() X-Git-Tag: v2.3.0~330 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb2f2dd8a244e1cd192fa859bd4ac8ada87776e9;p=icinga2 Implement get_object() and get_objects() fixes #7564 --- diff --git a/lib/base/scriptutils.cpp b/lib/base/scriptutils.cpp index d053529ab..762f34c6a 100644 --- a/lib/base/scriptutils.cpp +++ b/lib/base/scriptutils.cpp @@ -45,8 +45,8 @@ REGISTER_SCRIPTFUNCTION(exit, &Application::Exit); REGISTER_SCRIPTFUNCTION(typeof, &ScriptUtils::TypeOf); REGISTER_SCRIPTFUNCTION(keys, &ScriptUtils::Keys); REGISTER_SCRIPTFUNCTION(random, &Utility::Random); -REGISTER_SCRIPTFUNCTION(__get_object, &ScriptUtils::GetObject); -REGISTER_SCRIPTFUNCTION(__get_objects, &ScriptUtils::GetObjects); +REGISTER_SCRIPTFUNCTION(get_object, &ScriptUtils::GetObject); +REGISTER_SCRIPTFUNCTION(get_objects, &ScriptUtils::GetObjects); REGISTER_SCRIPTFUNCTION(assert, &ScriptUtils::Assert); REGISTER_SCRIPTFUNCTION(string, &ScriptUtils::CastString); REGISTER_SCRIPTFUNCTION(number, &ScriptUtils::CastNumber); @@ -246,9 +246,9 @@ Array::Ptr ScriptUtils::Keys(const Dictionary::Ptr& dict) return result; } -DynamicObject::Ptr ScriptUtils::GetObject(const String& type, const String& name) +DynamicObject::Ptr ScriptUtils::GetObject(const Type::Ptr& type, const String& name) { - DynamicType::Ptr dtype = DynamicType::GetByName(type); + DynamicType::Ptr dtype = DynamicType::GetByName(type->GetName()); if (!dtype) BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type name")); @@ -256,9 +256,9 @@ DynamicObject::Ptr ScriptUtils::GetObject(const String& type, const String& name return dtype->GetObject(name); } -Array::Ptr ScriptUtils::GetObjects(const String& type) +Array::Ptr ScriptUtils::GetObjects(const Type::Ptr& type) { - DynamicType::Ptr dtype = DynamicType::GetByName(type); + DynamicType::Ptr dtype = DynamicType::GetByName(type->GetName()); if (!dtype) BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type name")); diff --git a/lib/base/scriptutils.hpp b/lib/base/scriptutils.hpp index 2ed000275..2f6deb584 100644 --- a/lib/base/scriptutils.hpp +++ b/lib/base/scriptutils.hpp @@ -47,8 +47,8 @@ public: static Array::Ptr Range(const std::vector& arguments); static Type::Ptr TypeOf(const Value& value); static Array::Ptr Keys(const Dictionary::Ptr& dict); - static DynamicObject::Ptr GetObject(const String& type, const String& name); - static Array::Ptr GetObjects(const String& type); + static DynamicObject::Ptr GetObject(const Type::Ptr& type, const String& name); + static Array::Ptr GetObjects(const Type::Ptr& type); static void Assert(const Value& arg); private: