]> granicus.if.org Git - icinga2/commitdiff
Implement get_object() and get_objects()
authorGunnar Beutner <gunnar@beutner.name>
Wed, 28 Jan 2015 07:36:17 +0000 (08:36 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Wed, 28 Jan 2015 07:36:17 +0000 (08:36 +0100)
fixes #7564

lib/base/scriptutils.cpp
lib/base/scriptutils.hpp

index d053529abfeea0085be1099f6651b8a0bda4c6f7..762f34c6ac0223aa6a076f22d6c806cda757b987 100644 (file)
@@ -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"));
index 2ed000275e43e11e999d9d725d02fe6588069b4c..2f6deb584be0f17a190a30f12e3e4f3eafab00b9 100644 (file)
@@ -47,8 +47,8 @@ public:
        static Array::Ptr Range(const std::vector<Value>& 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: