Go to the documentation of this file. 18 #ifndef INCLUDED_COMPONENT 19 #define INCLUDED_COMPONENT 30 #define REGISTER_COMPONENT_TYPE(cname) \ 31 void RegisterComponentType_##cname(CComponentManager& mgr) \ 33 mgr.RegisterComponentType(CCmp##cname::GetInterfaceId(), CID_##cname, CCmp##cname::Allocate, CCmp##cname::Deallocate, #cname, CCmp##cname::GetSchema()); \ 34 CCmp##cname::ClassInit(mgr); \ 37 #define REGISTER_COMPONENT_SCRIPT_WRAPPER(cname) \ 38 void RegisterComponentType_##cname(CComponentManager& mgr) \ 40 mgr.RegisterComponentTypeScriptWrapper(CCmp##cname::GetInterfaceId(), CID_##cname, CCmp##cname::Allocate, CCmp##cname::Deallocate, #cname, CCmp##cname::GetSchema()); \ 41 CCmp##cname::ClassInit(mgr); \ 44 #define DEFAULT_COMPONENT_ALLOCATOR(cname) \ 45 static IComponent* Allocate(ScriptInterface&, JS::HandleValue) { return new CCmp##cname(); } \ 46 static void Deallocate(IComponent* cmp) { delete static_cast<CCmp##cname*> (cmp); } \ 47 virtual int GetComponentTypeId() const \ 52 #define DEFAULT_SCRIPT_WRAPPER(cname) \ 53 static void ClassInit(CComponentManager& UNUSED(componentManager)) { } \ 54 static IComponent* Allocate(ScriptInterface& scriptInterface, JS::HandleValue instance) \ 56 return new CCmp##cname(scriptInterface, instance); \ 58 static void Deallocate(IComponent* cmp) \ 60 delete static_cast<CCmp##cname*> (cmp); \ 62 CCmp##cname(ScriptInterface& scriptInterface, JS::HandleValue instance) : m_Script(scriptInterface, instance) { } \ 63 static std::string GetSchema() \ 65 return "<a:component type='script-wrapper'/><empty/>"; \ 67 virtual void Init(const CParamNode& paramNode) \ 69 m_Script.Init(paramNode, GetEntityId()); \ 71 virtual void Deinit() \ 75 virtual void HandleMessage(const CMessage& msg, bool global) \ 77 m_Script.HandleMessage(msg, global); \ 79 virtual void Serialize(ISerializer& serialize) \ 81 m_Script.Serialize(serialize); \ 83 virtual void Deserialize(const CParamNode& paramNode, IDeserializer& deserialize) \ 85 m_Script.Deserialize(paramNode, deserialize, GetEntityId()); \ 87 virtual JS::Value GetJSInstance() const \ 89 return m_Script.GetInstance(); \ 91 virtual int GetComponentTypeId() const \ 96 CComponentTypeScript m_Script; \ 99 #define DEFAULT_MOCK_COMPONENT() \ 100 virtual int GetComponentTypeId() const \ 104 virtual void Init(const CParamNode& UNUSED(paramNode)) \ 107 virtual void Deinit() \ 110 virtual void Serialize(ISerializer& UNUSED(serialize)) \ 113 virtual void Deserialize(const CParamNode& UNUSED(paramNode), IDeserializer& UNUSED(deserialize)) \ 117 #endif // INCLUDED_COMPONENT