1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #include "base/object.hpp"
4 #include "base/dictionary.hpp"
5 #include "base/function.hpp"
6 #include "base/functionwrapper.hpp"
7 #include "base/scriptframe.hpp"
9 using namespace icinga;
11 static String ObjectToString()
13 ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
14 Object::Ptr self = static_cast<Object::Ptr>(vframe->Self);
15 REQUIRE_NOT_NULL(self);
16 return self->ToString();
19 static void ObjectNotifyAttribute(const String& attribute)
21 ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
22 Object::Ptr self = static_cast<Object::Ptr>(vframe->Self);
23 REQUIRE_NOT_NULL(self);
24 self->NotifyField(self->GetReflectionType()->GetFieldId(attribute));
27 static Object::Ptr ObjectClone()
29 ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
30 Object::Ptr self = static_cast<Object::Ptr>(vframe->Self);
31 REQUIRE_NOT_NULL(self);
35 Object::Ptr Object::GetPrototype()
37 static Dictionary::Ptr prototype = new Dictionary({
38 { "to_string", new Function("Object#to_string", ObjectToString, {}, true) },
39 { "notify_attribute", new Function("Object#notify_attribute", ObjectNotifyAttribute, { "attribute" }, false) },
40 { "clone", new Function("Object#clone", ObjectClone, {}, true) }