WIP
This commit is contained in:
parent
e7417745fd
commit
b0b4683f7d
File diff suppressed because it is too large
Load Diff
|
@ -231,7 +231,9 @@ public class DataTypeWriter {
|
||||||
code.append(annotator.getPrefix(composite, component));
|
code.append(annotator.getPrefix(composite, component));
|
||||||
|
|
||||||
String fieldName = component.getFieldName();
|
String fieldName = component.getFieldName();
|
||||||
if (fieldName == null || fieldName.length() == 0) {
|
String originalName = fieldName;
|
||||||
|
boolean needsFixing = fieldName != null && fieldName.contains("?");
|
||||||
|
if (fieldName == null || fieldName.length() == 0 || needsFixing) {
|
||||||
fieldName = component.getDefaultFieldName();
|
fieldName = component.getDefaultFieldName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,8 +252,12 @@ public class DataTypeWriter {
|
||||||
code.append(annotator.getSuffix(composite, component));
|
code.append(annotator.getSuffix(composite, component));
|
||||||
|
|
||||||
String comment = component.getComment();
|
String comment = component.getComment();
|
||||||
if (comment != null && comment.length() > 0) {
|
String commentText = comment != null && comment.length() > 0 ? comment : "";
|
||||||
code.append(" ").append(comment(comment));
|
if (needsFixing) {
|
||||||
|
commentText += (commentText.length() > 0 ? " " : "") + "(fix name \"" + originalName + "\")";
|
||||||
|
}
|
||||||
|
if (commentText.length() > 0) {
|
||||||
|
code.append(" ").append(comment(commentText));
|
||||||
}
|
}
|
||||||
code.append(EOL);
|
code.append(EOL);
|
||||||
}
|
}
|
||||||
|
@ -297,8 +303,6 @@ public class DataTypeWriter {
|
||||||
String dataTypeName = dataType.getDisplayName();
|
String dataTypeName = dataType.getDisplayName();
|
||||||
|
|
||||||
if (!isIntegral(typedefName, dataTypeName)) {
|
if (!isIntegral(typedefName, dataTypeName)) {
|
||||||
DataType baseType = typeDef.getBaseDataType();
|
|
||||||
|
|
||||||
// Add dependency only if it's not a pointer
|
// Add dependency only if it's not a pointer
|
||||||
if (!isPointerType(dataType)) {
|
if (!isPointerType(dataType)) {
|
||||||
DataType depType = getImmediateDependencyType(dataType);
|
DataType depType = getImmediateDependencyType(dataType);
|
||||||
|
@ -314,24 +318,17 @@ public class DataTypeWriter {
|
||||||
|
|
||||||
private void writeBuiltInBlock(BuiltInDataType dt, StringBuilder code, Set<String> dependencies) {
|
private void writeBuiltInBlock(BuiltInDataType dt, StringBuilder code, Set<String> dependencies) {
|
||||||
String declaration = dt.getCTypeDeclaration(this.dataOrganization);
|
String declaration = dt.getCTypeDeclaration(this.dataOrganization);
|
||||||
if (declaration != null && !dt.getDisplayName().equals("bool")) {
|
if (declaration != null) {
|
||||||
code.append(declaration);
|
code.append(declaration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPointerType(DataType dt) {
|
private boolean isPointerType(DataType dt) {
|
||||||
return dt instanceof Pointer;
|
return dt instanceof Pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isBuiltInType(DataType dt) {
|
private boolean isBuiltInType(DataType dt) {
|
||||||
return dt instanceof BuiltInDataType ||
|
return dt instanceof BuiltInDataType;
|
||||||
dt.getDisplayName().equals("void") ||
|
|
||||||
dt.getDisplayName().equals("char") ||
|
|
||||||
dt.getDisplayName().equals("int") ||
|
|
||||||
dt.getDisplayName().equals("short") ||
|
|
||||||
dt.getDisplayName().equals("long") ||
|
|
||||||
dt.getDisplayName().equals("float") ||
|
|
||||||
dt.getDisplayName().equals("double");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DataType getImmediateDependencyType(DataType dt) {
|
private DataType getImmediateDependencyType(DataType dt) {
|
||||||
|
@ -348,23 +345,6 @@ public class DataTypeWriter {
|
||||||
return dt;
|
return dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DataType getBaseDataType(DataType dt) {
|
|
||||||
while (dt != null) {
|
|
||||||
if (dt instanceof Array) {
|
|
||||||
dt = ((Array) dt).getDataType();
|
|
||||||
} else if (dt instanceof Pointer) {
|
|
||||||
dt = ((Pointer) dt).getDataType();
|
|
||||||
} else if (dt instanceof BitFieldDataType) {
|
|
||||||
dt = ((BitFieldDataType) dt).getBaseDataType();
|
|
||||||
} else if (dt instanceof TypeDef) {
|
|
||||||
dt = ((TypeDef) dt).getBaseDataType();
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dt;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getTypeDeclaration(String name, DataType dataType, int instanceLength) {
|
private String getTypeDeclaration(String name, DataType dataType, int instanceLength) {
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
name = "";
|
name = "";
|
||||||
|
@ -399,7 +379,15 @@ public class DataTypeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
String prefix = getDataTypePrefix(dataType);
|
String prefix = getDataTypePrefix(dataType);
|
||||||
String componentString = prefix + dataType.getDisplayName();
|
|
||||||
|
String dataTypeString;
|
||||||
|
if (dataType instanceof AbstractIntegerDataType) {
|
||||||
|
dataTypeString = ((AbstractIntegerDataType)dataType).getCDeclaration();
|
||||||
|
} else {
|
||||||
|
dataTypeString = dataType.getDisplayName();
|
||||||
|
}
|
||||||
|
|
||||||
|
String componentString = prefix + dataTypeString;
|
||||||
if (name.length() != 0) {
|
if (name.length() != 0) {
|
||||||
componentString = componentString + " " + name;
|
componentString = componentString + " " + name;
|
||||||
}
|
}
|
||||||
|
@ -408,7 +396,12 @@ public class DataTypeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getDataTypePrefix(DataType dataType) {
|
private String getDataTypePrefix(DataType dataType) {
|
||||||
dataType = getBaseDataType(dataType);
|
// Don't add struct/union prefix for typedefs - they already have their own name
|
||||||
|
if (dataType instanceof TypeDef) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only add struct/union prefix for direct struct/union references (not typedefs)
|
||||||
if (dataType instanceof Structure) {
|
if (dataType instanceof Structure) {
|
||||||
return "struct ";
|
return "struct ";
|
||||||
} else if (dataType instanceof Union) {
|
} else if (dataType instanceof Union) {
|
||||||
|
|
Loading…
Reference in New Issue