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

Merge pull request #1247 from aws-lumberyard-dev/LYN-3510
main
SJ 5 years ago committed by GitHub
commit 92594af647
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -15,22 +15,30 @@
#pragma once #pragma once
#include <AzCore/EBus/EBus.h> #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 AZ::EBusTraits
{ {
public: public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// EBusTraits overrides // EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single; static constexpr AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; static constexpr AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Put your public methods here
}; };
using ${Name}RequestBus = AZ::EBus<${Name}Requests>; using ${SanitizedCppName}RequestBus = AZ::EBus<${SanitizedCppName}Requests, ${SanitizedCppName}BusTraits>;
using ${SanitizedCppName}Interface = AZ::Interface<${SanitizedCppName}Requests>;
} // namespace ${Name} } // namespace ${SanitizedCppName}

@ -15,24 +15,40 @@
#include <AzCore/Serialization/SerializeContext.h> #include <AzCore/Serialization/SerializeContext.h>
#include <${Name}EditorSystemComponent.h> #include <${Name}EditorSystemComponent.h>
namespace ${Name} namespace ${SanitizedCppName}
{ {
void ${Name}EditorSystemComponent::Reflect(AZ::ReflectContext* context) void ${SanitizedCppName}EditorSystemComponent::Reflect(AZ::ReflectContext* context)
{ {
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context)) if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{ {
serializeContext->Class<${Name}EditorSystemComponent, AZ::Component>()->Version(1); serializeContext->Class<${SanitizedCppName}EditorSystemComponent, AZ::Component>()->Version(1);
} }
} }
void ${Name}EditorSystemComponent::Activate() ${SanitizedCppName}EditorSystemComponent::${SanitizedCppName}EditorSystemComponent()
{
if (${SanitizedCppName}Interface::Get() == nullptr)
{
${SanitizedCppName}Interface::Register(this);
}
}
${SanitizedCppName}EditorSystemComponent::~${SanitizedCppName}EditorSystemComponent()
{
if (${SanitizedCppName}Interface::Get() == this)
{
${SanitizedCppName}Interface::Unregister(this);
}
}
void ${SanitizedCppName}EditorSystemComponent::Activate()
{ {
AzToolsFramework::EditorEvents::Bus::Handler::BusConnect(); AzToolsFramework::EditorEvents::Bus::Handler::BusConnect();
} }
void ${Name}EditorSystemComponent::Deactivate() void ${SanitizedCppName}EditorSystemComponent::Deactivate()
{ {
AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect(); AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect();
} }
} // namespace ${Name} } // namespace ${SanitizedCppName}

@ -18,32 +18,33 @@
#include <AzToolsFramework/Entity/EditorEntityContextBus.h> #include <AzToolsFramework/Entity/EditorEntityContextBus.h>
namespace ${Name} namespace ${SanitizedCppName}
{ {
/// System component for ${Name} editor /// System component for ${SanitizedCppName} editor
class ${Name}EditorSystemComponent class ${SanitizedCppName}EditorSystemComponent
: public AZ::Component : public AZ::Component
, private AzToolsFramework::EditorEvents::Bus::Handler , private AzToolsFramework::EditorEvents::Bus::Handler
{ {
public: public:
AZ_COMPONENT(${Name}EditorSystemComponent, "${EditorSysCompClassId}"); AZ_COMPONENT(${SanitizedCppName}EditorSystemComponent, "${EditorSysCompClassId}");
static void Reflect(AZ::ReflectContext* context); static void Reflect(AZ::ReflectContext* context);
${Name}EditorSystemComponent() = default; ${SanitizedCppName}EditorSystemComponent();
~${SanitizedCppName}EditorSystemComponent();
private: private:
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided) static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{ {
provided.push_back(AZ_CRC("${Name}EditorService")); provided.push_back(AZ_CRC("${SanitizedCppName}EditorService"));
} }
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required) static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
{ {
required.push_back(AZ_CRC("${Name}Service")); required.push_back(AZ_CRC("${SanitizedCppName}Service"));
} }
// AZ::Component // AZ::Component
void Activate() override; void Activate() override;
void Deactivate() override; void Deactivate() override;
}; };
} // namespace ${Name} } // namespace ${SanitizedCppName}

@ -17,21 +17,21 @@
#include <${Name}SystemComponent.h> #include <${Name}SystemComponent.h>
namespace ${Name} namespace ${SanitizedCppName}
{ {
class ${Name}Module class ${SanitizedCppName}Module
: public AZ::Module : public AZ::Module
{ {
public: public:
AZ_RTTI(${Name}Module, "${ModuleClassId}", AZ::Module); AZ_RTTI(${SanitizedCppName}Module, "${ModuleClassId}", AZ::Module);
AZ_CLASS_ALLOCATOR(${Name}Module, AZ::SystemAllocator, 0); AZ_CLASS_ALLOCATOR(${SanitizedCppName}Module, AZ::SystemAllocator, 0);
${Name}Module() ${SanitizedCppName}Module()
: AZ::Module() : AZ::Module()
{ {
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here. // Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
m_descriptors.insert(m_descriptors.end(), { m_descriptors.insert(m_descriptors.end(), {
${Name}SystemComponent::CreateDescriptor(), ${SanitizedCppName}SystemComponent::CreateDescriptor(),
}); });
} }
@ -41,10 +41,10 @@ namespace ${Name}
AZ::ComponentTypeList GetRequiredSystemComponents() const override AZ::ComponentTypeList GetRequiredSystemComponents() const override
{ {
return AZ::ComponentTypeList { 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 <AzCore/Serialization/EditContext.h> #include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/EditContextConstants.inl> #include <AzCore/Serialization/EditContextConstants.inl>
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)) if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{ {
serialize->Class<${Name}SystemComponent, AZ::Component>() serialize->Class<${SanitizedCppName}SystemComponent, AZ::Component>()
->Version(0) ->Version(0)
; ;
if (AZ::EditContext* ec = serialize->GetEditContext()) 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, "") ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System")) ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System"))
->Attribute(AZ::Edit::Attributes::AutoExpand, true) ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
@ -39,45 +39,61 @@ 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); AZ_UNUSED(required);
} }
void ${Name}SystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent) void ${SanitizedCppName}SystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{ {
AZ_UNUSED(dependent); AZ_UNUSED(dependent);
} }
void ${Name}SystemComponent::Init() ${SanitizedCppName}SystemComponent::${SanitizedCppName}SystemComponent()
{
if (${SanitizedCppName}Interface::Get() == nullptr)
{
${SanitizedCppName}Interface::Register(this);
}
}
${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();
AZ::TickBus::Handler::BusConnect(); AZ::TickBus::Handler::BusConnect();
} }
void ${Name}SystemComponent::Deactivate() void ${SanitizedCppName}SystemComponent::Deactivate()
{ {
AZ::TickBus::Handler::BusDisconnect(); AZ::TickBus::Handler::BusDisconnect();
${Name}RequestBus::Handler::BusDisconnect(); ${SanitizedCppName}RequestBus::Handler::BusDisconnect();
} }
void ${Name}SystemComponent::OnTick(float /*deltaTime*/, AZ::ScriptTimePoint /*time*/) void ${SanitizedCppName}SystemComponent::OnTick(float /*deltaTime*/, AZ::ScriptTimePoint /*time*/)
{ {
} }
} // namespace ${Name} } // namespace ${SanitizedCppName}

@ -18,15 +18,15 @@
#include <AzCore/Component/TickBus.h> #include <AzCore/Component/TickBus.h>
#include <${Name}/${Name}Bus.h> #include <${Name}/${Name}Bus.h>
namespace ${Name} namespace ${SanitizedCppName}
{ {
class ${Name}SystemComponent class ${SanitizedCppName}SystemComponent
: public AZ::Component : public AZ::Component
, protected ${Name}RequestBus::Handler , protected ${SanitizedCppName}RequestBus::Handler
, public AZ::TickBus::Handler , public AZ::TickBus::Handler
{ {
public: public:
AZ_COMPONENT(${Name}SystemComponent, "${SysCompClassId}"); AZ_COMPONENT(${SanitizedCppName}SystemComponent, "${SysCompClassId}");
static void Reflect(AZ::ReflectContext* context); static void Reflect(AZ::ReflectContext* context);
@ -35,9 +35,12 @@ namespace ${Name}
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required); static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent); static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
${SanitizedCppName}SystemComponent();
~${SanitizedCppName}SystemComponent();
protected: protected:
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// ${Name}RequestBus interface implementation // ${SanitizedCppName}RequestBus interface implementation
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -54,4 +57,4 @@ namespace ${Name}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
}; };
} // namespace ${Name} } // namespace ${SanitizedCppName}

@ -14,7 +14,7 @@
#include <AzTest/AzTest.h> #include <AzTest/AzTest.h>
class ${Name}EditorTest class ${SanitizedCppName}EditorTest
: public ::testing::Test : public ::testing::Test
{ {
protected: protected:
@ -29,7 +29,7 @@ protected:
} }
}; };
TEST_F(${Name}EditorTest, SanityTest) TEST_F(${SanitizedCppName}EditorTest, SanityTest)
{ {
ASSERT_TRUE(true); ASSERT_TRUE(true);
} }

@ -14,7 +14,7 @@
#include <AzTest/AzTest.h> #include <AzTest/AzTest.h>
class ${Name}Test class ${SanitizedCppName}Test
: public ::testing::Test : public ::testing::Test
{ {
protected: protected:
@ -29,7 +29,7 @@ protected:
} }
}; };
TEST_F(${Name}Test, SanityTest) TEST_F(${SanitizedCppName}Test, SanityTest)
{ {
ASSERT_TRUE(true); ASSERT_TRUE(true);
} }

@ -15,20 +15,30 @@
#pragma once #pragma once
#include <AzCore/EBus/EBus.h> #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 AZ::EBusTraits
{ {
public: public:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// EBusTraits overrides // EBusTraits overrides
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single; static constexpr AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::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" #include "${Name}SystemComponent.h"
namespace ${Name} namespace ${SanitizedCppName}
{ {
class ${Name}Module class ${SanitizedCppName}Module
: public AZ::Module : public AZ::Module
{ {
public: public:
AZ_RTTI(${Name}Module, "${ModuleClassId}", AZ::Module); AZ_RTTI(${SanitizedCppName}Module, "${ModuleClassId}", AZ::Module);
AZ_CLASS_ALLOCATOR(${Name}Module, AZ::SystemAllocator, 0); AZ_CLASS_ALLOCATOR(${SanitizedCppName}Module, AZ::SystemAllocator, 0);
${Name}Module() ${SanitizedCppName}Module()
: AZ::Module() : AZ::Module()
{ {
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here. // Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
m_descriptors.insert(m_descriptors.end(), { m_descriptors.insert(m_descriptors.end(), {
${Name}SystemComponent::CreateDescriptor(), ${SanitizedCppName}SystemComponent::CreateDescriptor(),
}); });
} }
@ -41,10 +41,10 @@ namespace ${Name}
AZ::ComponentTypeList GetRequiredSystemComponents() const override AZ::ComponentTypeList GetRequiredSystemComponents() const override
{ {
return AZ::ComponentTypeList{ 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" #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)) if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{ {
serialize->Class<${Name}SystemComponent, AZ::Component>() serialize->Class<${SanitizedCppName}SystemComponent, AZ::Component>()
->Version(0) ->Version(0)
; ;
if (AZ::EditContext* ec = serialize->GetEditContext()) 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, "") ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System")) ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System"))
->Attribute(AZ::Edit::Attributes::AutoExpand, true) ->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); AZ_UNUSED(required);
} }
void ${Name}SystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent) void ${SanitizedCppName}SystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent)
{ {
AZ_UNUSED(dependent); AZ_UNUSED(dependent);
} }
void ${Name}SystemComponent::Init() ${SanitizedCppName}SystemComponent::${SanitizedCppName}SystemComponent()
{
if (${SanitizedCppName}Interface::Get() == nullptr)
{
${SanitizedCppName}Interface::Register(this);
}
}
${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> #include <${Name}/${Name}Bus.h>
namespace ${Name} namespace ${SanitizedCppName}
{ {
class ${Name}SystemComponent class ${SanitizedCppName}SystemComponent
: public AZ::Component : public AZ::Component
, protected ${Name}RequestBus::Handler , protected ${SanitizedCppName}RequestBus::Handler
{ {
public: public:
AZ_COMPONENT(${Name}SystemComponent, "${SysCompClassId}"); AZ_COMPONENT(${SanitizedCppName}SystemComponent, "${SysCompClassId}");
static void Reflect(AZ::ReflectContext* context); static void Reflect(AZ::ReflectContext* context);
@ -34,9 +34,12 @@ namespace ${Name}
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required); static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent); static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
${SanitizedCppName}SystemComponent();
~${SanitizedCppName}SystemComponent();
protected: protected:
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// ${Name}RequestBus interface implementation // ${SanitizedCppName}RequestBus interface implementation
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////

@ -374,7 +374,7 @@ function(ly_setup_cmake_install)
string(APPEND builtinpackages "ly_associate_package(PACKAGE_NAME ${package_name} TARGETS ${targets} PACKAGE_HASH ${package_hash})\n") string(APPEND builtinpackages "ly_associate_package(PACKAGE_NAME ${package_name} TARGETS ${targets} PACKAGE_HASH ${package_hash})\n")
endforeach() endforeach()
ly_get_absolute_pal_filename(pal_builtin_file ${CMAKE_CURRENT_BINARY_DIR}/cmake/3rdParty/Platform/${PAL_PLATFORM_NAME}/BuiltInPackages_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) set(pal_builtin_file ${CMAKE_CURRENT_BINARY_DIR}/cmake/3rdParty/Platform/${PAL_PLATFORM_NAME}/BuiltInPackages_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
file(GENERATE OUTPUT ${pal_builtin_file} file(GENERATE OUTPUT ${pal_builtin_file}
CONTENT ${builtinpackages} CONTENT ${builtinpackages}
) )

@ -1232,10 +1232,12 @@ def create_from_template(destination_path: str,
with_this = replace.pop(0) with_this = replace.pop(0)
replacements.append((replace_this, with_this)) replacements.append((replace_this, with_this))
sanitized_cpp_name = utils.sanitize_identifier_for_cpp(destination_name)
# dst name is Name # dst name is Name
replacements.append(("${Name}", destination_name)) replacements.append(("${Name}", destination_name))
replacements.append(("${NameUpper}", destination_name.upper())) replacements.append(("${NameUpper}", destination_name.upper()))
replacements.append(("${NameLower}", destination_name.lower())) replacements.append(("${NameLower}", destination_name.lower()))
replacements.append(("${SanitizedCppName}", sanitized_cpp_name))
if _instantiate_template(template_json_data, if _instantiate_template(template_json_data,
destination_name, destination_name,
@ -1536,10 +1538,12 @@ def create_project(project_path: str,
with_this = replace.pop(0) with_this = replace.pop(0)
replacements.append((replace_this, with_this)) replacements.append((replace_this, with_this))
sanitized_cpp_name = utils.sanitize_identifier_for_cpp(project_name)
# project name # project name
replacements.append(("${Name}", project_name)) replacements.append(("${Name}", project_name))
replacements.append(("${NameUpper}", project_name.upper())) replacements.append(("${NameUpper}", project_name.upper()))
replacements.append(("${NameLower}", project_name.lower())) replacements.append(("${NameLower}", project_name.lower()))
replacements.append(("${SanitizedCppName}", sanitized_cpp_name))
# module id is a uuid with { and - # module id is a uuid with { and -
if module_id: if module_id:
@ -1890,6 +1894,10 @@ def create_gem(gem_path: str,
# gem name is now the last component of the gem_path # gem name is now the last component of the gem_path
gem_name = os.path.basename(gem_path) gem_name = os.path.basename(gem_path)
if not utils.validate_identifier(gem_name):
logger.error(f'Gem name must be fewer than 64 characters, contain only alphanumeric, "_" or "-" characters, and start with a letter. {gem_name}')
return 1
# gem name cannot be the same as a restricted platform name # gem name cannot be the same as a restricted platform name
if gem_name in restricted_platforms: if gem_name in restricted_platforms:
logger.error(f'Gem path cannot be a restricted name. {gem_name}') logger.error(f'Gem path cannot be a restricted name. {gem_name}')
@ -1927,10 +1935,13 @@ def create_gem(gem_path: str,
with_this = replace.pop(0) with_this = replace.pop(0)
replacements.append((replace_this, with_this)) replacements.append((replace_this, with_this))
sanitized_cpp_name = utils.sanitize_identifier_for_cpp(gem_name)
# gem name # gem name
replacements.append(("${Name}", gem_name)) replacements.append(("${Name}", gem_name))
replacements.append(("${NameUpper}", gem_name.upper())) replacements.append(("${NameUpper}", gem_name.upper()))
replacements.append(("${NameLower}", gem_name.lower())) replacements.append(("${NameLower}", gem_name.lower()))
replacements.append(("${SanitizedCppName}", sanitized_cpp_name))
# module id is a uuid with { and - # module id is a uuid with { and -
if module_id: if module_id:

@ -401,13 +401,6 @@ def get_templates_for_generic_creation(): # temporary until we have a better wa
return list(filter(filter_project_and_gem_templates_out, get_all_templates())) return list(filter(filter_project_and_gem_templates_out, get_all_templates()))
def get_all_restricted() -> list:
engine_restricted = get_engine_restricted()
restricted_data = get_restricted()
restricted_data.extend(engine_restricted)
return restricted_data
def find_engine_data(json_data: dict, def find_engine_data(json_data: dict,
engine_path: str or pathlib.Path = None) -> dict or None: engine_path: str or pathlib.Path = None) -> dict or None:
if not engine_path: if not engine_path:

@ -36,6 +36,23 @@ def validate_identifier(identifier: str) -> bool:
return True return True
def sanitize_identifier_for_cpp(identifier: str) -> str:
"""
Convert the provided identifier to a valid C++ identifier
:param identifier: the name which needs to to sanitized
:return: str: sanitized identifier
"""
if not identifier:
return ''
sanitized_identifier = list(identifier)
for index, character in enumerate(sanitized_identifier):
if not (character.isalnum() or character == '_'):
sanitized_identifier[index] = '_'
return "".join(sanitized_identifier)
def validate_uuid4(uuid_string: str) -> bool: def validate_uuid4(uuid_string: str) -> bool:
""" """
Determine if the uuid supplied is valid. Determine if the uuid supplied is valid.

Loading…
Cancel
Save