/* ----------------------------------------------------------------------------- GSFramework Copyright 2001-2013 Emmanuel Julien. All Rights Reserved. ----------------------------------------------------------------------------- */ #ifndef __NSCRIPTOBJECT__ #define __NSCRIPTOBJECT__ #include "script/script_vm.h" namespace GS { namespace Script { /* @short Abstract script object. @author Emmanuel Julien (ejulien@gsworks.fr) */ class Object { protected: IVM &vm; public: IVM &GetVM() const { return vm; } /// Perform a set operation on this object. bool Set(const char *name, const Variant &p) { return vm.Set(name, p, this); } /// Perform a get operation on this object. bool Get(const char *name, Variant &p) { return vm.Get(name, p, this); } /// Append a variant to this object. bool Append(const Variant &p) { return vm.Append(p, this); } /// Setup a function call on this object. bool SetupFunctionCall(const char *func, const Object *function_object = 0) { return vm.SetupFunctionCall(func, function_object, this); } /// Push null function call argument. bool PushFunctionCallNullArgument() { return vm.PushNullArgument(); } /// Push function call argument. bool PushFunctionCallArgument(const Variant &arg) { return vm.PushArgument(arg); } /// Execute a function call on this object, return value as a variant. bool DoFunctionCall(Variant *return_value = 0) { return vm.DoFunctionCall(return_value); } Object &operator= (const Object &b) { vm = b.GetVM(); return *this; } Object(IVM &v) : vm(v) {} virtual ~Object() {} }; } // Script } // GS #endif // __NSCRIPTOBJECT__