Sanitize project name before substituting it in C++ template files

Merge pull request #1247 from aws-lumberyard-dev/LYN-3510
This commit is contained in:
SJ
2021-06-10 16:56:20 -07:00
committed by GitHub
16 changed files with 197 additions and 103 deletions
@@ -15,20 +15,30 @@
#pragma once
#include <AzCore/EBus/EBus.h>
#include <AzCore/Interface/Interface.h>
namespace ${Name}
namespace ${SanitizedCppName}
{
class ${Name}Requests
class ${SanitizedCppName}Requests
{
public:
AZ_RTTI(${SanitizedCppName}Requests, "${Random_Uuid}");
virtual ~${SanitizedCppName}Requests() = default;
// Put your public methods here
};
class ${SanitizedCppName}BusTraits
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
static constexpr AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static constexpr AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
//////////////////////////////////////////////////////////////////////////
// Put your public methods here
};
using ${Name}RequestBus = AZ::EBus<${Name}Requests>;
} // namespace ${Name}
using ${SanitizedCppName}RequestBus = AZ::EBus<${SanitizedCppName}Requests, ${SanitizedCppName}BusTraits>;
using ${SanitizedCppName}Interface = AZ::Interface<${SanitizedCppName}Requests>;
} // namespace ${SanitizedCppName}
@@ -17,21 +17,21 @@
#include "${Name}SystemComponent.h"
namespace ${Name}
namespace ${SanitizedCppName}
{
class ${Name}Module
class ${SanitizedCppName}Module
: public AZ::Module
{
public:
AZ_RTTI(${Name}Module, "${ModuleClassId}", AZ::Module);
AZ_CLASS_ALLOCATOR(${Name}Module, AZ::SystemAllocator, 0);
AZ_RTTI(${SanitizedCppName}Module, "${ModuleClassId}", AZ::Module);
AZ_CLASS_ALLOCATOR(${SanitizedCppName}Module, AZ::SystemAllocator, 0);
${Name}Module()
${SanitizedCppName}Module()
: AZ::Module()
{
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
m_descriptors.insert(m_descriptors.end(), {
${Name}SystemComponent::CreateDescriptor(),
${SanitizedCppName}SystemComponent::CreateDescriptor(),
});
}
@@ -41,10 +41,10 @@ namespace ${Name}
AZ::ComponentTypeList GetRequiredSystemComponents() const override
{
return AZ::ComponentTypeList{
azrtti_typeid<${Name}SystemComponent>(),
azrtti_typeid<${SanitizedCppName}SystemComponent>(),
};
}
};
}// namespace ${Name}
}// namespace ${SanitizedCppName}
AZ_DECLARE_MODULE_CLASS(Gem_${Name}, ${Name}::${Name}Module)
AZ_DECLARE_MODULE_CLASS(Gem_${SanitizedCppName}, ${SanitizedCppName}::${SanitizedCppName}Module)
@@ -18,19 +18,19 @@
#include "${Name}SystemComponent.h"
namespace ${Name}
namespace ${SanitizedCppName}
{
void ${Name}SystemComponent::Reflect(AZ::ReflectContext* context)
void ${SanitizedCppName}SystemComponent::Reflect(AZ::ReflectContext* context)
{
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
serialize->Class<${Name}SystemComponent, AZ::Component>()
serialize->Class<${SanitizedCppName}SystemComponent, AZ::Component>()
->Version(0)
;
if (AZ::EditContext* ec = serialize->GetEditContext())
{
ec->Class<${Name}SystemComponent>("${Name}", "[Description of functionality provided by this System Component]")
ec->Class<${SanitizedCppName}SystemComponent>("${SanitizedCppName}", "[Description of functionality provided by this System Component]")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System"))
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
@@ -39,37 +39,53 @@ namespace ${Name}
}
}
void ${Name}SystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
void ${SanitizedCppName}SystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("${Name}Service"));
provided.push_back(AZ_CRC("${SanitizedCppName}Service"));
}
void ${Name}SystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
void ${SanitizedCppName}SystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC("${Name}Service"));
incompatible.push_back(AZ_CRC("${SanitizedCppName}Service"));
}
void ${Name}SystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
void ${SanitizedCppName}SystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{
AZ_UNUSED(required);
}
void ${Name}SystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
void ${SanitizedCppName}SystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
AZ_UNUSED(dependent);
}
${SanitizedCppName}SystemComponent::${SanitizedCppName}SystemComponent()
{
if (${SanitizedCppName}Interface::Get() == nullptr)
{
${SanitizedCppName}Interface::Register(this);
}
}
void ${Name}SystemComponent::Init()
${SanitizedCppName}SystemComponent::~${SanitizedCppName}SystemComponent()
{
if (${SanitizedCppName}Interface::Get() == this)
{
${SanitizedCppName}Interface::Unregister(this);
}
}
void ${SanitizedCppName}SystemComponent::Init()
{
}
void ${Name}SystemComponent::Activate()
void ${SanitizedCppName}SystemComponent::Activate()
{
${Name}RequestBus::Handler::BusConnect();
${SanitizedCppName}RequestBus::Handler::BusConnect();
}
void ${Name}SystemComponent::Deactivate()
void ${SanitizedCppName}SystemComponent::Deactivate()
{
${Name}RequestBus::Handler::BusDisconnect();
${SanitizedCppName}RequestBus::Handler::BusDisconnect();
}
}
@@ -18,14 +18,14 @@
#include <${Name}/${Name}Bus.h>
namespace ${Name}
namespace ${SanitizedCppName}
{
class ${Name}SystemComponent
class ${SanitizedCppName}SystemComponent
: public AZ::Component
, protected ${Name}RequestBus::Handler
, protected ${SanitizedCppName}RequestBus::Handler
{
public:
AZ_COMPONENT(${Name}SystemComponent, "${SysCompClassId}");
AZ_COMPONENT(${SanitizedCppName}SystemComponent, "${SysCompClassId}");
static void Reflect(AZ::ReflectContext* context);
@@ -34,9 +34,12 @@ namespace ${Name}
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
${SanitizedCppName}SystemComponent();
~${SanitizedCppName}SystemComponent();
protected:
////////////////////////////////////////////////////////////////////////
// ${Name}RequestBus interface implementation
// ${SanitizedCppName}RequestBus interface implementation
////////////////////////////////////////////////////////////////////////