AppModel: Add AppType.Name

This commit is contained in:
Katy Coe
2020-07-18 03:47:11 +02:00
parent 307cf29dcd
commit f5e5037a9b
3 changed files with 9 additions and 8 deletions

View File

@@ -66,7 +66,7 @@ namespace Il2CppInspector.Model
IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable) CppTypeCollection).GetEnumerator();
// The C++ declaration generator for this binary
internal CppDeclarationGenerator declarationGenerator; // TODO: Make private when name integration completed
private CppDeclarationGenerator declarationGenerator;
// Convenience properties

View File

@@ -29,7 +29,7 @@ namespace Il2CppInspector.Model
// The VA of the Il2CppClass object which defines this type (ClassName__TypeInfo)
public ulong TypeClassAddress { get; internal set; }
// The VA of the Il2CppType* (VA of the pointer to the Il2CppType) object which references this type
// The VA of the Il2CppType* (VA of the pointer to the Il2CppType) object which references this type (ClassName__TypeRef)
public ulong TypeRefPtrAddress { get; internal set; }
public AppType(TypeInfo ilType, CppComplexType cppType, CppComplexType valueType = null,
@@ -41,6 +41,11 @@ namespace Il2CppInspector.Model
TypeRefPtrAddress = cppTypeRefPtr;
}
// The C++ name of the type
// TODO: Known issue here where we should be using CppDeclarationGenerator.TypeNamer to ensure uniqueness
// Prefer Foo over Foo__Boxed; if there is no C++ type defined, just convert the IL type to a C identifier
public string Name => CppValueType?.Name ?? CppType?.Name ?? ILType.Name.ToCIdentifier();
public override string ToString() => ILType.FullName + " -> " + CppType.Name;
}
}

View File

@@ -155,18 +155,14 @@ typedef __int64 int64_t;
foreach (var type in model.Types.Values) {
// A type may have no addresses, for example an unreferenced array type
// Value types must not used the boxed definition
// TODO: Replace this with a future property of 'type' which gives the name
var name = type.CppValueType?.Name ?? type.CppType?.Name ?? model.declarationGenerator.TypeNamer.GetName(type.ILType);
if (type.TypeClassAddress != 0xffffffff_ffffffff) {
writeTypedName(type.TypeClassAddress, $"struct {name}__Class *", $"{name}__TypeInfo");
writeTypedName(type.TypeClassAddress, $"struct {type.Name}__Class *", $"{type.Name}__TypeInfo");
writeComment(type.TypeClassAddress, type.ILType.CSharpName);
}
if (type.TypeRefPtrAddress != 0xffffffff_ffffffff) {
// A generic type definition does not have any direct C++ types, but may have a reference
writeTypedName(type.TypeRefPtrAddress, "struct Il2CppType *", $"{name}__TypeRef");
writeTypedName(type.TypeRefPtrAddress, "struct Il2CppType *", $"{type.Name}__TypeRef");
writeComment(type.TypeRefPtrAddress, type.ILType.CSharpName);
}
}