Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/system/Component.h
Show All 26 Lines | |||||
#include "simulation2/system/ParamNode.h" | #include "simulation2/system/ParamNode.h" | ||||
#include "simulation2/system/SimContext.h" | #include "simulation2/system/SimContext.h" | ||||
#include "simulation2/serialization/ISerializer.h" | #include "simulation2/serialization/ISerializer.h" | ||||
#include "simulation2/serialization/IDeserializer.h" | #include "simulation2/serialization/IDeserializer.h" | ||||
#define REGISTER_COMPONENT_TYPE(cname) \ | #define REGISTER_COMPONENT_TYPE(cname) \ | ||||
void RegisterComponentType_##cname(CComponentManager& mgr) \ | void RegisterComponentType_##cname(CComponentManager& mgr) \ | ||||
{ \ | { \ | ||||
IComponent::RegisterComponentType(mgr, CCmp##cname::GetInterfaceId(), CID_##cname, CCmp##cname::Allocate, CCmp##cname::Deallocate, #cname, CCmp##cname::GetSchema()); \ | IComponent::RegisterComponentType(mgr, CCmp##cname::GetInterfaceId(), CID_##cname, CCmp##cname::Allocate, CCmp##cname::Deallocate, sizeof(CCmp##cname), alignof(CCmp##cname), #cname, CCmp##cname::GetSchema()); \ | ||||
CCmp##cname::ClassInit(mgr); \ | CCmp##cname::ClassInit(mgr); \ | ||||
} | } | ||||
#define DEFAULT_COMPONENT_ALLOCATOR(cname) \ | #define DEFAULT_COMPONENT_ALLOCATOR(cname) \ | ||||
static IComponent* Allocate(const ScriptInterface&, JS::HandleValue) { return new CCmp##cname(); } \ | static IComponent* Allocate(void* slot, const ScriptInterface&, JS::HandleValue) { return new (slot) CCmp##cname(); } \ | ||||
static void Deallocate(IComponent* cmp) { delete static_cast<CCmp##cname*> (cmp); } \ | static void Deallocate(IComponent* cmp) { \ | ||||
static_cast<CCmp##cname*>(cmp)->~CCmp##cname(); /* deallocation is handled by ComponentDataHolder */\ | |||||
} \ | |||||
int GetComponentTypeId() const override \ | int GetComponentTypeId() const override \ | ||||
{ \ | { \ | ||||
return CID_##cname; \ | return CID_##cname; \ | ||||
} | } | ||||
#define DEFAULT_MOCK_COMPONENT() \ | #define DEFAULT_MOCK_COMPONENT() \ | ||||
int GetComponentTypeId() const override \ | int GetComponentTypeId() const override \ | ||||
{ \ | { \ | ||||
Show All 16 Lines |
Wildfire Games · Phabricator