From 4dd3e7cb9221bc8c64e1d75700f79914de0540a2 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Thu, 13 Aug 2020 06:56:28 +0200 Subject: [PATCH] C++: Add GetType no-alias option and GetComplexType --- Il2CppInspector.Common/Cpp/CppTypeCollection.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Il2CppInspector.Common/Cpp/CppTypeCollection.cs b/Il2CppInspector.Common/Cpp/CppTypeCollection.cs index 980077b..017e3be 100644 --- a/Il2CppInspector.Common/Cpp/CppTypeCollection.cs +++ b/Il2CppInspector.Common/Cpp/CppTypeCollection.cs @@ -502,7 +502,7 @@ namespace Il2CppInspector.Cpp #endregion // Get a type from its name, handling typedef aliases and pointer types - public CppType GetType(string typeName) { + public CppType GetType(string typeName, bool returnUnaliased = false) { // Separate type name from pointers var baseName = typeName.Replace("*", ""); @@ -513,7 +513,7 @@ namespace Il2CppInspector.Cpp // Typedef alias if (TypedefAliases.TryGetValue(baseName, out CppType aliasType)) - type = aliasType.AsAlias(baseName); + type = returnUnaliased? aliasType : aliasType.AsAlias(baseName); // Non-aliased type else { @@ -533,6 +533,9 @@ namespace Il2CppInspector.Cpp return type; } + // Get a type, casting it to CppComplexType; deliberately throws exception if the type is not a CppComplexType + public CppComplexType GetComplexType(string typeName) => (CppComplexType) GetType(typeName, returnUnaliased: true); + // Get all of the types in a logical group public IEnumerable GetTypeGroup(string groupName) => Types.Values.Where(t => t.Group == groupName);