Skip to content

Commit

Permalink
Add a way to detect whether structs need a "legacy" definition. (#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple authored Jan 6, 2023
1 parent 19ae346 commit bedd8db
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,17 @@ function isWeaklyTypedEnum(label) {
return weakEnumList.includes(label);
}

let legacyStructList = undefined;
function isLegacyStruct(label) {
if (legacyStructList === undefined) {
let f = this.global.resource('legacy-struct-list');
// NOTE: This has to be sync, so we can use this data in if conditions.
let rawData = fs.readFileSync(f, { encoding: 'utf8', flag: 'r' });
legacyStructList = YAML.parse(rawData);
}
return legacyStructList.includes(label);
}

function incrementDepth(depth) {
return depth + 1;
}
Expand Down Expand Up @@ -920,6 +931,7 @@ exports.zapTypeToDecodableClusterObjectType =
zapTypeToDecodableClusterObjectType;
exports.zapTypeToPythonClusterObjectType = zapTypeToPythonClusterObjectType;
exports.isWeaklyTypedEnum = isWeaklyTypedEnum;
exports.isLegacyStruct = isLegacyStruct;
exports.getPythonFieldDefault = getPythonFieldDefault;
exports.incrementDepth = incrementDepth;
exports.zcl_events_fields_by_event_name = zcl_events_fields_by_event_name;
Expand Down

0 comments on commit bedd8db

Please sign in to comment.