@@ -40,6 +40,8 @@ void CodeGen::Generate(ZTypeRegistry* p_Registry, const std::filesystem::path& p
4040 m_SDKEnumsHeader << std::endl;
4141 m_SDKEnumsHeader << " #pragma once" << std::endl;
4242 m_SDKEnumsHeader << std::endl;
43+ m_SDKEnumsHeader << " #include <cstdint>" << std::endl;
44+ m_SDKEnumsHeader << std::endl;
4345
4446 m_ReflectiveClassesHeaderFile << " /*" << std::endl;
4547 m_ReflectiveClassesHeaderFile << " * WARNING: This file is automatically generated. DO NOT MODIFY unless you know what you're doing." << std::endl;
@@ -271,6 +273,24 @@ std::string NormalizeName(STypeID* p_Type)
271273 return s_TypeName;
272274}
273275
276+ std::string GetEnumUnderlyingType (STypeID* p_Type)
277+ {
278+ switch (p_Type->typeInfo ()->m_nTypeSize ) {
279+ case 1 :
280+ return " int8_t" ;
281+
282+ case 2 :
283+ return " int16_t" ;
284+
285+ case 4 :
286+ return " int32_t" ;
287+
288+ default :
289+ printf (" Unsupported enum size %d for type %s. Defaulting to int32_t.\n " , p_Type->typeInfo ()->m_nTypeSize , p_Type->typeInfo ()->m_pTypeName );
290+ return " int32_t" ;
291+ }
292+ }
293+
274294void CodeGen::GenerateEnum (STypeID* p_Type)
275295{
276296 auto s_Type = reinterpret_cast <IEnumType*>(p_Type->typeInfo ());
@@ -284,12 +304,12 @@ void CodeGen::GenerateEnum(STypeID* p_Type)
284304 std::ostringstream s_Stream;
285305
286306 s_Stream << " // 0x" << std::hex << std::uppercase << p_Type << " (Size: 0x" << std::hex << std::uppercase << s_Type->m_nTypeSize << " )" << std::dec << std::endl;
287- s_Stream << " enum class " << s_Type->m_pTypeName << std::endl;
307+ s_Stream << " enum class " << s_Type->m_pTypeName << " : " << GetEnumUnderlyingType (p_Type) << std::endl;
288308 s_Stream << " {" << std::endl;
289309
290310#if _M_X64
291311 // TODO: Remove this. Temporary workaround until I figure out what's going on.
292- s_Type->m_entries .m_pAllocationEnd = nullptr ;
312+ s_Type->m_entries .m_pAllocationEnd = s_Type-> m_entries . m_pEnd ;
293313 for (auto it = s_Type->m_entries .begin (); it != s_Type->m_entries .end (); ++it)
294314 {
295315 s_Enum[it->m_nValue ] = it->m_pName ;
@@ -322,12 +342,12 @@ void CodeGen::GenerateEnum(STypeID* p_Type)
322342 {
323343 std::ostringstream s_Stream;
324344
325- s_Stream << " enum class " << NormalizeName (p_Type) << std::endl;
345+ s_Stream << " enum class " << NormalizeName (p_Type) << " : " << GetEnumUnderlyingType (p_Type) << std::endl;
326346 s_Stream << " {" << std::endl;
327347
328348#if _M_X64
329349 // TODO: Remove this. Temporary workaround until I figure out what's going on.
330- s_Type->m_entries .m_pAllocationEnd = nullptr ;
350+ s_Type->m_entries .m_pAllocationEnd = s_Type-> m_entries . m_pEnd ;
331351 for (auto it = s_Type->m_entries .begin (); it != s_Type->m_entries .end (); ++it)
332352 {
333353 s_Enum[it->m_nValue ] = it->m_pName ;
@@ -932,12 +952,12 @@ void CodeGen::GenerateReflectiveEnum(STypeID* p_Type)
932952 std::ostringstream s_Stream;
933953
934954 s_Stream << " // Size: 0x" << std::hex << std::uppercase << s_Type->m_nTypeSize << std::dec << std::endl;
935- s_Stream << " enum class " << NormalizeName (p_Type) << std::endl;
955+ s_Stream << " enum class " << NormalizeName (p_Type) << " : " << GetEnumUnderlyingType (p_Type) << std::endl;
936956 s_Stream << " {" << std::endl;
937957
938958#if _M_X64
939959 // TODO: Remove this. Temporary workaround until I figure out what's going on.
940- s_Type->m_entries .m_pAllocationEnd = nullptr ;
960+ s_Type->m_entries .m_pAllocationEnd = s_Type-> m_entries . m_pEnd ;
941961 for (auto it = s_Type->m_entries .begin (); it != s_Type->m_entries .end (); ++it)
942962 s_Stream << " \t " << it->m_pName << " = " << std::dec << it->m_nValue << " ," << std::endl;
943963#else
0 commit comments