C++: Add GetType no-alias option and GetComplexType

This commit is contained in:
Katy Coe
2020-08-13 06:56:28 +02:00
parent 75de69e338
commit 4dd3e7cb92

View File

@@ -502,7 +502,7 @@ namespace Il2CppInspector.Cpp
#endregion #endregion
// Get a type from its name, handling typedef aliases and pointer types // 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 // Separate type name from pointers
var baseName = typeName.Replace("*", ""); var baseName = typeName.Replace("*", "");
@@ -513,7 +513,7 @@ namespace Il2CppInspector.Cpp
// Typedef alias // Typedef alias
if (TypedefAliases.TryGetValue(baseName, out CppType aliasType)) if (TypedefAliases.TryGetValue(baseName, out CppType aliasType))
type = aliasType.AsAlias(baseName); type = returnUnaliased? aliasType : aliasType.AsAlias(baseName);
// Non-aliased type // Non-aliased type
else { else {
@@ -533,6 +533,9 @@ namespace Il2CppInspector.Cpp
return type; 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 // Get all of the types in a logical group
public IEnumerable<CppType> GetTypeGroup(string groupName) => Types.Values.Where(t => t.Group == groupName); public IEnumerable<CppType> GetTypeGroup(string groupName) => Types.Values.Where(t => t.Group == groupName);