/* ----------------------------------------------------------------------------- GSFramework Copyright 2001-2013 Emmanuel Julien. All Rights Reserved. ----------------------------------------------------------------------------- */ #ifndef __NSCRIPTUNIT__ #define __NSCRIPTUNIT__ #include "script/script_vm.h" #include "data/nvariant.h" namespace GS { namespace NML { class Tag; } namespace Script { /*! @short Script unit. @author Emmanuel Julien (ejulien@gsworks.fr) */ class Unit { protected: Object *self; uint iface_type; ///< Interface object type. void *iface_object; ///< Interface object. public: sVM vm; const Object *Self() const { return self; } List parm_list; String script_file, ///< Script file to process. script_class; ///< Class to instantiate upon setup. /// Set unit interface object. void SetInterfaceObject(void *p, uint type) { iface_object = p; iface_type = type; } /// Get unit interface object. void GetInterfaceObject(void *&p, uint &type) { p = iface_object; type = iface_type; } /*! @name Runtime. @{ */ /// Open component. virtual bool Open(); /// Close component. virtual void Close(); /// Is unit open. bool IsOpen() const { return asbool(self); } /// Setup a function call in the VM. virtual bool SetupFunctionCall(const char *func, const Object *func_object = 0); /// Push user object function call argument. virtual bool PushUserObjectFunctionCallArgument(void *, uint, bool managed = false); /// Push function call argument. virtual bool PushFunctionCallArgument(const Variant &); /// Execute a function call in the VM, return value as a variant. virtual bool DoFunctionCall(Variant *return_value = 0); /// @} bool FromMetaTag(NML::Tag &); NML::Tag *AsMetaTag() const; Unit(IVM *); virtual ~Unit(); }; } // Script } // GS #endif // __NSCRIPTUNIT__