diff --git a/Il2CppInspector.Common/CppUtils/CppDeclarationGenerator.cs b/Il2CppInspector.Common/CppUtils/CppDeclarationGenerator.cs index 98a5d24..a21b5f2 100755 --- a/Il2CppInspector.Common/CppUtils/CppDeclarationGenerator.cs +++ b/Il2CppInspector.Common/CppUtils/CppDeclarationGenerator.cs @@ -156,11 +156,10 @@ namespace Il2CppInspector.CppUtils if (ti.IsEnum) { // Enums should be represented using enum syntax // They otherwise behave like value types - var namer = GlobalsNamespace.MakeNamer((field) => $"{name}_{field.Name}".ToCIdentifier()); csrc.Append($"enum {name} : {AsCType(ti.GetEnumUnderlyingType())} {{\n"); foreach (var field in ti.DeclaredFields) { if (field.Name != "value__") - csrc.Append($" {namer.GetName(field)} = {field.DefaultValue},\n"); + csrc.Append($" {EnumNamer.GetName(field)} = {field.DefaultValue},\n"); } csrc.Append($"}};\n"); @@ -525,7 +524,7 @@ namespace Il2CppInspector.CppUtils /// /// public string GenerateMethodDeclaration(MethodBase method) { - return GenerateMethodDeclaration(method, MethodNamer.GetName(method), method.DeclaringType); + return GenerateMethodDeclaration(method, GlobalNamer.GetName(method), method.DeclaringType); } /// @@ -565,7 +564,8 @@ namespace Il2CppInspector.CppUtils }); GlobalsNamespace = CreateNamespace(); - MethodNamer = TypeNamespace.MakeNamer((method) => $"{TypeNamer.GetName(method.DeclaringType)}_{method.Name.ToCIdentifier()}"); + GlobalNamer = GlobalsNamespace.MakeNamer((method) => $"{TypeNamer.GetName(method.DeclaringType)}_{method.Name.ToCIdentifier()}"); + EnumNamer = GlobalsNamespace.MakeNamer((field) => $"{TypeNamer.GetName(field.DeclaringType)}_{field.Name.ToCIdentifier()}"); } // Reserve C/C++ keywords and built-in names @@ -590,10 +590,11 @@ namespace Il2CppInspector.CppUtils public Namespace.Namer TypeNamer { get; private set; } /// - /// Namespace for global variables and methods + /// Namespace for global variables, enum values and methods /// public Namespace GlobalsNamespace { get; private set; } - public Namespace.Namer MethodNamer { get; private set; } + public Namespace.Namer GlobalNamer { get; private set; } + public Namespace.Namer EnumNamer { get; private set; } #endregion } }