Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
derek.kingston committed Jul 20, 2017
2 parents 693c409 + d54a688 commit a02c348
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/avtas/lmcp/lmcpgen/CppMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,9 @@ public static String unpack_attributes(MDMInfo[] infos, MDMInfo info, File outfi
str += ws + " uint16_t version = buf.getUShort();\n";
str += ws + " " + name + " = (" + type + "*) avtas::lmcp::Factory::createObject( series_id, msgtype, version );\n";
str += ws + " if (" + name + " != nullptr) " + name + "->unpack(buf);\n";
if (!st.fields[i].isOptional) {
str += ws + " else assert(" + name + " != nullptr);\n";
}
str += ws + " }\n";
str += ws + "}\n";
}
Expand Down Expand Up @@ -713,6 +716,7 @@ else if (st.fields[i].isEnum) {
str += ws + " uint16_t version = buf.getUShort();\n";
str += ws + " " + type + "* e = (" + type + "*) avtas::lmcp::Factory::createObject( series_id, msgtype, version );\n";
str += ws + " if ( e != nullptr) e->unpack(buf); \n";
str += ws + " else assert( e != nullptr); \n";
if (st.fields[i].length == -1) {
str += ws + " " + name + ".push_back(e);\n";
}
Expand Down
15 changes: 13 additions & 2 deletions src/avtas/lmcp/lmcpgen/DocMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,20 @@ public static String buildStructs(MDMInfo info, MDMInfo[] infos, String ws) thro
str.append("<tr><td class=\"field\"><a name=\"").append(info.seriesName).append("_datatype_").append(struct.name).append("_field_").
append(struct.fields[j].name).append("\"><B>").append(struct.fields[j].name).append("</B></a><br>");
str.append("<p class=\"comment\">").append(processComment(struct.fields[j].comment, infos, info)).append("</p>\n");
if (struct.fields[j].defaultVal.length() != 0) {
str.append("<p class=\"comment\">Default Value = ").append(struct.fields[j].defaultVal).append("</p></td>\n");
if (struct.fields[j].defaultVal.length() != 0 || struct.fields[j].isOptional || struct.fields[j].maxArrayLength > 0) {
str.append("<p class=\"comment\">");
if (struct.fields[j].isOptional) {
str.append("<i>[Optional]</i>").append("&nbsp;&nbsp;");
}
if (struct.fields[j].defaultVal.length() != 0) {
str.append("Default Value = ").append(struct.fields[j].defaultVal).append("&nbsp;&nbsp;");
}
if (struct.fields[j].maxArrayLength > 0) {
str.append("Max Length = ").append(Integer.toString(struct.fields[j].maxArrayLength));
}
str.append("</p>\n");
}
str.append("</td>\n");

if (struct.fields[j].isStruct) {
if (struct.fields[j].type.equals(MDMInfo.LMCP_OBJECT_NAME)) {
Expand Down
5 changes: 3 additions & 2 deletions src/avtas/lmcp/lmcpgen/FieldInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ public class FieldInfo {
public boolean isScalar = false;
public boolean isArray = false;
public boolean isLargeArray = false;
public boolean isOptional = false;
public boolean isEnum = false;
public boolean isStruct = false;
public boolean isMap = false;
public boolean isOptional = false;
public int maxArrayLength = 0;

/** Creates a new instance of FieldInfo */
public FieldInfo() {
Expand All @@ -63,7 +64,7 @@ public boolean isReallyScalar() {

@Override
public String toString() {
return "FieldInfo{" + "name=" + name + ", comment=" + comment + ", length=" + length + ", type=" + type + ", defaultVal=" + defaultVal + ", units=" + units + ", seriesName=" + seriesName + ", isScalar=" + isScalar + ", isArray=" + isArray + ", isLargeArray=" + isLargeArray + ", isEnum=" + isEnum + ", isStruct=" + isStruct + ", isMap=" + isMap + ", isOptional=" + isOptional + '}';
return "FieldInfo{" + "name=" + name + ", comment=" + comment + ", length=" + length + ", type=" + type + ", defaultVal=" + defaultVal + ", units=" + units + ", seriesName=" + seriesName + ", isScalar=" + isScalar + ", isArray=" + isArray + ", isLargeArray=" + isLargeArray + ", maxArrayLength=" + maxArrayLength + ", isEnum=" + isEnum + ", isStruct=" + isStruct + ", isOptional=" + isOptional + ", isMap=" + isMap + '}';
}

}
2 changes: 1 addition & 1 deletion src/avtas/lmcp/lmcpgen/MDM.DTD
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Name CDATA #REQUIRED
Series CDATA ''
Units CDATA 'None'
LargeArray CDATA ''
LargeArray (false|true) 'false'
MaxArrayLength CDATA ''
Optional (false|true) 'false'
>
Expand Down
12 changes: 9 additions & 3 deletions src/avtas/lmcp/lmcpgen/MDMReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,15 @@ else if (type.startsWith("<") && type.endsWith(">")) {

// large array tag
f.isLargeArray = Boolean.valueOf(XMLUtil.getAttribute(fieldNodes[j], "LargeArray", "false"));

// Optional tag
// optional
f.isOptional = Boolean.valueOf(XMLUtil.getAttribute(fieldNodes[j], "Optional", "false"));

// max length of array
String arrLen = XMLUtil.getAttribute(fieldNodes[j], "MaxArrayLength", "0");
if(arrLen != "") {
f.maxArrayLength = Integer.valueOf(arrLen);
}
}
}

Expand Down Expand Up @@ -321,7 +327,7 @@ else if (isEnum(f.type, f.seriesName, infos)) {
}

public static void checkDefault(StructInfo s, FieldInfo f) throws Exception {
if (MDMInfo.isNumber(f.type)) {
if (MDMInfo.isNumber(f.type) && !f.isArray) {
if (f.defaultVal.isEmpty()) {
f.defaultVal = "0";
}
Expand Down

0 comments on commit a02c348

Please sign in to comment.