Skip to content

Commit

Permalink
Ensure fieldType is a scalar if arrayLen is -1 (#638)
Browse files Browse the repository at this point in the history
* handle nested types
  • Loading branch information
scottbell committed Nov 16, 2023
1 parent 44c7e08 commit 2ec60c0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/Ros.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ Ros.prototype.getMessageDetails = function(message, callback, failedCallback) {
Ros.prototype.decodeTypeDefs = function(defs) {
var that = this;

// calls itself recursively to resolve type definition using hints.
var decodeTypeDefsRec = function(theType, hints) {
// calls itself recursively to resolve type definition using hints.
var typeDefDict = {};
for (var i = 0; i < theType.fieldnames.length; i++) {
var arrayLen = theType.fieldarraylen[i];
Expand All @@ -672,6 +672,7 @@ Ros.prototype.decodeTypeDefs = function(defs) {
if (sub) {
var subResult = decodeTypeDefsRec(sub, hints);
if (arrayLen === -1) {
typeDefDict[fieldName] = subResult; // add this decoding result to dictionary
}
else {
typeDefDict[fieldName] = [subResult];
Expand Down

0 comments on commit 2ec60c0

Please sign in to comment.