-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CppGenerator: same header included multiple times #28
Comments
untested: // collect includes to avoid duplicates
Set<String> includes= new HashSet<String>();
for (int idx = 0; idx < aClass.getClassAttributes().size(); idx++) {
ClassAttribute anAttribute = (ClassAttribute) aClass.getClassAttributes().get(idx);
// If this attribute is a class, we need to do an import on that class
if (anAttribute.getAttributeKind() == ClassAttribute.ClassAttributeType.CLASSREF) {
includes.add("#include <" + anAttribute.getType() + ".h>");
}
// If this attribute is a list with class type, we also need to do an import on that class
if ((anAttribute.getAttributeKind() == ClassAttribute.ClassAttributeType.FIXED_LIST
|| anAttribute.getAttributeKind() == ClassAttribute.ClassAttributeType.VARIABLE_LIST)
&& !anAttribute.getUnderlyingTypeIsPrimitive()) {
includes.add("#include <" + anAttribute.getType() + ".h>");
}
// if this attribute is a variable-length list that holds a class, we need to
// do an import on the class that is in the list.
if (anAttribute.getAttributeKind() == ClassAttribute.ClassAttributeType.VARIABLE_LIST) {
hasVariableLengthList = true;
}
}
// print collected includes
for (String include : includes) {
pw.println(include);
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If multiple class attributes are objects of the same class, the corresponding header is included multiple times.
See
xmlpg/src/main/java/edu/nps/moves/xmlpg/CppGenerator.java
Line 192 in 11f88b3
Possible solution: store includes in
Set<String>
.The text was updated successfully, but these errors were encountered: