Don't include ComponentManager.h in ScriptComponent
ScriptComponent does not use ComponentManager, and its derived classes (most ICMP*.cpp files) do not either. Therefore, we can skip a lot of transitive inclusions and speed up recompiling by not including it there. Differential Revision: https://code.wildfiregames.com/D3962 This was SVN commit r25447.
This commit is contained in:
parent
e908733220
commit
a19dc1717f
@ -25,8 +25,9 @@
|
||||
#include "simulation2/serialization/IDeserializer.h"
|
||||
|
||||
CComponentTypeScript::CComponentTypeScript(const ScriptInterface& scriptInterface, JS::HandleValue instance) :
|
||||
m_ScriptInterface(scriptInterface), m_Instance(scriptInterface.GetGeneralJSContext(), instance)
|
||||
m_ScriptInterface(scriptInterface)
|
||||
{
|
||||
m_Instance.init(ScriptRequest(m_ScriptInterface).cx, instance);
|
||||
}
|
||||
|
||||
void CComponentTypeScript::Init(const CParamNode& paramNode, entity_id_t ent)
|
||||
|
@ -18,8 +18,16 @@
|
||||
#ifndef INCLUDED_SCRIPTCOMPONENT
|
||||
#define INCLUDED_SCRIPTCOMPONENT
|
||||
|
||||
// These headers are included because they are required in component implementation,
|
||||
// so including them here transitively makes sense.
|
||||
#include "scriptinterface/FunctionWrapper.h"
|
||||
#include "simulation2/system/Component.h"
|
||||
#include "simulation2/system/CmpPtr.h"
|
||||
#include "simulation2/system/Components.h"
|
||||
#include "simulation2/system/IComponent.h"
|
||||
#include "simulation2/system/ParamNode.h"
|
||||
#include "simulation2/system/SimContext.h"
|
||||
#include "simulation2/serialization/ISerializer.h"
|
||||
#include "simulation2/serialization/IDeserializer.h"
|
||||
|
||||
#include "ps/CLogger.h"
|
||||
|
||||
@ -74,7 +82,7 @@ private:
|
||||
#define REGISTER_COMPONENT_SCRIPT_WRAPPER(cname) \
|
||||
void RegisterComponentType_##cname(CComponentManager& mgr) \
|
||||
{ \
|
||||
mgr.RegisterComponentTypeScriptWrapper(CCmp##cname::GetInterfaceId(), CID_##cname, CCmp##cname::Allocate, CCmp##cname::Deallocate, #cname, CCmp##cname::GetSchema()); \
|
||||
IComponent::RegisterComponentTypeScriptWrapper(mgr, CCmp##cname::GetInterfaceId(), CID_##cname, CCmp##cname::Allocate, CCmp##cname::Deallocate, #cname, CCmp##cname::GetSchema()); \
|
||||
CCmp##cname::ClassInit(mgr); \
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
#ifndef INCLUDED_COMPONENT
|
||||
#define INCLUDED_COMPONENT
|
||||
|
||||
// These headers are included because they are required in component implementation,
|
||||
// so including them here transitively makes sense.
|
||||
#include "simulation2/system/CmpPtr.h"
|
||||
#include "simulation2/system/Components.h"
|
||||
#include "simulation2/system/ComponentManager.h"
|
||||
@ -30,7 +32,7 @@
|
||||
#define REGISTER_COMPONENT_TYPE(cname) \
|
||||
void RegisterComponentType_##cname(CComponentManager& mgr) \
|
||||
{ \
|
||||
mgr.RegisterComponentType(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, #cname, CCmp##cname::GetSchema()); \
|
||||
CCmp##cname::ClassInit(mgr); \
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "simulation2/helpers/Player.h"
|
||||
#include "simulation2/system/Components.h"
|
||||
#include "simulation2/system/Entity.h"
|
||||
#include "simulation2/system/IComponent.h"
|
||||
|
||||
#include <boost/random/linear_congruential.hpp>
|
||||
#include <map>
|
||||
@ -46,9 +47,8 @@ public:
|
||||
typedef int MessageTypeId;
|
||||
|
||||
private:
|
||||
// Component allocation types
|
||||
typedef IComponent* (*AllocFunc)(const ScriptInterface& scriptInterface, JS::HandleValue ctor);
|
||||
typedef void (*DeallocFunc)(IComponent*);
|
||||
using AllocFunc = IComponent::AllocFunc;
|
||||
using DeallocFunc = IComponent::DeallocFunc;
|
||||
|
||||
// ComponentTypes come in three types:
|
||||
// Native: normal C++ component
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2020 Wildfire Games.
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -19,6 +19,8 @@
|
||||
|
||||
#include "IComponent.h"
|
||||
|
||||
#include "simulation2/system/ComponentManager.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
IComponent::~IComponent()
|
||||
@ -31,6 +33,16 @@ std::string IComponent::GetSchema()
|
||||
return "<empty/>";
|
||||
}
|
||||
|
||||
void IComponent::RegisterComponentType(CComponentManager& mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char* name, const std::string& schema)
|
||||
{
|
||||
mgr.RegisterComponentType(iid, cid, alloc, dealloc, name, schema);
|
||||
}
|
||||
|
||||
void IComponent::RegisterComponentTypeScriptWrapper(CComponentManager& mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char* name, const std::string& schema)
|
||||
{
|
||||
mgr.RegisterComponentTypeScriptWrapper(iid, cid, alloc, dealloc, name, schema);
|
||||
}
|
||||
|
||||
void IComponent::HandleMessage(const CMessage& UNUSED(msg), bool UNUSED(global))
|
||||
{
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -32,10 +32,17 @@ class IDeserializer;
|
||||
class IComponent
|
||||
{
|
||||
public:
|
||||
// Component allocation types
|
||||
using AllocFunc = IComponent* (*)(const ScriptInterface& scriptInterface, JS::HandleValue ctor);
|
||||
using DeallocFunc = void (*)(IComponent*);
|
||||
|
||||
virtual ~IComponent();
|
||||
|
||||
static std::string GetSchema();
|
||||
|
||||
static void RegisterComponentType(CComponentManager& mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char* name, const std::string& schema);
|
||||
static void RegisterComponentTypeScriptWrapper(CComponentManager& mgr, EInterfaceId iid, EComponentTypeId cid, AllocFunc alloc, DeallocFunc dealloc, const char* name, const std::string& schema);
|
||||
|
||||
virtual void Init(const CParamNode& paramNode) = 0;
|
||||
virtual void Deinit() = 0;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -23,6 +23,6 @@
|
||||
#define DECLARE_INTERFACE_TYPE(iname) \
|
||||
virtual bool NewJSObject(const ScriptInterface& scriptInterface, JS::MutableHandleObject out) const; \
|
||||
static void InterfaceInit(ScriptInterface& scriptInterface); \
|
||||
static int GetInterfaceId() { return IID_##iname; }
|
||||
static EInterfaceId GetInterfaceId() { return IID_##iname; }
|
||||
|
||||
#endif // INCLUDED_INTERFACE
|
||||
|
Loading…
Reference in New Issue
Block a user