AppModel: Generate composite type mappings

This commit is contained in:
Katy Coe
2020-07-13 19:52:04 +02:00
parent fdf198084f
commit 6e796a200f
4 changed files with 90 additions and 41 deletions

View File

@@ -21,7 +21,7 @@ namespace Il2CppInspector.Cpp
private readonly AppModel appModel;
private TypeModel model => appModel.ILModel;
private CppTypeCollection types => appModel.TypeCollection;
private CppTypeCollection types => appModel.CppTypeCollection;
// Version number and header file to generate structures for
public UnityVersion UnityVersion => appModel.UnityVersion;
@@ -245,8 +245,8 @@ namespace Il2CppInspector.Cpp
}
// "Flush" the list of visited types, generating C structures for each one
private List<(TypeInfo ilType, CppType valueType, CppType referenceType, CppType fieldsType)> GenerateVisitedFieldStructs() {
var structs = new List<(TypeInfo ilType, CppType valueType, CppType referenceType, CppType fieldsType)>(TodoTypeStructs.Count);
private List<(TypeInfo ilType, CppComplexType valueType, CppComplexType referenceType, CppComplexType fieldsType)> GenerateVisitedFieldStructs() {
var structs = new List<(TypeInfo ilType, CppComplexType valueType, CppComplexType referenceType, CppComplexType fieldsType)>(TodoTypeStructs.Count);
foreach (var ti in TodoFieldStructs) {
if (ti.IsEnum || ti.IsValueType) {
var (valueType, boxedType) = GenerateValueFieldStruct(ti);
@@ -432,8 +432,10 @@ namespace Il2CppInspector.Cpp
/// Type declarations that have previously been generated by this instance of CppDeclarationGenerator will not be generated again.
/// </summary>
/// <returns>A string containing C type declarations</returns>
public List<(TypeInfo ilType, CppType valueType, CppType referenceType, CppType fieldsType, CppType vtableType, CppType staticsType)> GenerateRemainingTypeDeclarations() {
var decl = GenerateVisitedFieldStructs().Select(s => (s.ilType, s.valueType, s.referenceType, s.fieldsType, (CppType) null, (CppType) null)).ToList();
public List<(TypeInfo ilType, CppComplexType valueType, CppComplexType referenceType, CppComplexType fieldsType,
CppComplexType vtableType, CppComplexType staticsType)> GenerateRemainingTypeDeclarations() {
var decl = GenerateVisitedFieldStructs().Select(s =>
(s.ilType, s.valueType, s.referenceType, s.fieldsType, (CppComplexType) null, (CppComplexType) null)).ToList();
foreach (var ti in TodoTypeStructs) {
var (cls, statics, vtable) = GenerateTypeStruct(ti);