AppModel: Add AppType.Name
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user