Implement get_object() and get_objects()

fixes #7564
This commit is contained in:
Gunnar Beutner 2015-01-28 08:36:17 +01:00
parent 88e1aadbf2
commit eb2f2dd8a2
2 changed files with 8 additions and 8 deletions

View File

@ -45,8 +45,8 @@ REGISTER_SCRIPTFUNCTION(exit, &Application::Exit);
REGISTER_SCRIPTFUNCTION(typeof, &ScriptUtils::TypeOf); REGISTER_SCRIPTFUNCTION(typeof, &ScriptUtils::TypeOf);
REGISTER_SCRIPTFUNCTION(keys, &ScriptUtils::Keys); REGISTER_SCRIPTFUNCTION(keys, &ScriptUtils::Keys);
REGISTER_SCRIPTFUNCTION(random, &Utility::Random); REGISTER_SCRIPTFUNCTION(random, &Utility::Random);
REGISTER_SCRIPTFUNCTION(__get_object, &ScriptUtils::GetObject); REGISTER_SCRIPTFUNCTION(get_object, &ScriptUtils::GetObject);
REGISTER_SCRIPTFUNCTION(__get_objects, &ScriptUtils::GetObjects); REGISTER_SCRIPTFUNCTION(get_objects, &ScriptUtils::GetObjects);
REGISTER_SCRIPTFUNCTION(assert, &ScriptUtils::Assert); REGISTER_SCRIPTFUNCTION(assert, &ScriptUtils::Assert);
REGISTER_SCRIPTFUNCTION(string, &ScriptUtils::CastString); REGISTER_SCRIPTFUNCTION(string, &ScriptUtils::CastString);
REGISTER_SCRIPTFUNCTION(number, &ScriptUtils::CastNumber); REGISTER_SCRIPTFUNCTION(number, &ScriptUtils::CastNumber);
@ -246,9 +246,9 @@ Array::Ptr ScriptUtils::Keys(const Dictionary::Ptr& dict)
return result; 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) if (!dtype)
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type name")); 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); 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) if (!dtype)
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type name")); BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type name"));

View File

@ -47,8 +47,8 @@ public:
static Array::Ptr Range(const std::vector<Value>& arguments); static Array::Ptr Range(const std::vector<Value>& arguments);
static Type::Ptr TypeOf(const Value& value); static Type::Ptr TypeOf(const Value& value);
static Array::Ptr Keys(const Dictionary::Ptr& dict); static Array::Ptr Keys(const Dictionary::Ptr& dict);
static DynamicObject::Ptr GetObject(const String& type, const String& name); static DynamicObject::Ptr GetObject(const Type::Ptr& type, const String& name);
static Array::Ptr GetObjects(const String& type); static Array::Ptr GetObjects(const Type::Ptr& type);
static void Assert(const Value& arg); static void Assert(const Value& arg);
private: private: