This commit is contained in:
Guus Waals 2025-05-29 20:09:23 +08:00
parent 31ee70e8c0
commit e7417745fd
2 changed files with 127 additions and 321 deletions

File diff suppressed because it is too large Load Diff

View File

@ -239,9 +239,9 @@ public class DataTypeWriter {
// Add dependency only if it's not a pointer (pointers can be forward declared)
if (!isPointerType(componentDataType)) {
DataType baseType = getBaseDataType(componentDataType);
if (baseType != null && !isBuiltInType(baseType)) {
dependencies.add(baseType.getDisplayName());
DataType depType = getImmediateDependencyType(componentDataType);
if (depType != null && !isBuiltInType(depType)) {
dependencies.add(depType.getDisplayName());
}
}
@ -301,7 +301,7 @@ public class DataTypeWriter {
// Add dependency only if it's not a pointer
if (!isPointerType(dataType)) {
DataType depType = getBaseDataType(dataType);
DataType depType = getImmediateDependencyType(dataType);
if (depType != null && !isBuiltInType(depType)) {
dependencies.add(depType.getDisplayName());
}
@ -334,6 +334,20 @@ public class DataTypeWriter {
dt.getDisplayName().equals("double");
}
private DataType getImmediateDependencyType(DataType dt) {
// Only unwrap arrays and bitfields, but preserve typedefs and other types
while (dt != null) {
if (dt instanceof Array) {
dt = ((Array) dt).getDataType();
} else if (dt instanceof BitFieldDataType) {
dt = ((BitFieldDataType) dt).getBaseDataType();
} else {
break;
}
}
return dt;
}
private DataType getBaseDataType(DataType dt) {
while (dt != null) {
if (dt instanceof Array) {