mirror of
https://github.com/LukeFZ/Il2CppInspectorRedux.git
synced 2026-01-30 22:49:41 +05:00
add implicit reference to enum class if a struct has a enum pointer as an instance field
this is only needed due to the forward definition code only being capable of generating struct types. closes #38
This commit is contained in:
@@ -497,6 +497,7 @@ namespace Il2CppInspector.Cpp
|
||||
// Allow auto-generation of forward declarations
|
||||
// This will break type generation unless the ultimate wanted type is a pointer
|
||||
// Note this can still be the case with indirectionCount == 0 if .AsPointer() is called afterwards
|
||||
|
||||
if (!Types.ContainsKey(baseName))
|
||||
Struct(baseName);
|
||||
|
||||
|
||||
@@ -82,7 +82,24 @@ public class CppTypeDependencyGraph
|
||||
// finally, process all instance fields.
|
||||
// the reference type depends on the type of the field
|
||||
foreach (var field in typeInfo.DeclaredFields.Where(f => f.IsInstanceField))
|
||||
AddReference(typeNode, GetNode(field.FieldType), field.FieldType.IsPassedByReference);
|
||||
{
|
||||
// if the field type is a pointer and the element type an enum, we have to add a reference to the enum.
|
||||
// this is a workaround for type emitting only being able to generate forward definitions for *struct* types, and not enum types
|
||||
if (field.FieldType.IsPointer)
|
||||
{
|
||||
// support multiple pointer levels
|
||||
var type = field.FieldType;
|
||||
while (type.IsPointer)
|
||||
type = type.ElementType;
|
||||
|
||||
if (type.IsEnum)
|
||||
AddReference(typeNode, GetNode(type), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddReference(typeNode, GetNode(field.FieldType), field.FieldType.IsPassedByReference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<TypeInfo> DeriveDependencyOrderedTypes(TypeInfo typeInfo)
|
||||
|
||||
Reference in New Issue
Block a user