Skip to content

Commit bedd8db

Browse files
Add a way to detect whether structs need a "legacy" definition. (#883)
1 parent 19ae346 commit bedd8db

File tree

1 file changed

+12
-0
lines changed
  • src-electron/generator/matter/app/zap-templates/templates/app

1 file changed

+12
-0
lines changed

src-electron/generator/matter/app/zap-templates/templates/app/helper.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,17 @@ function isWeaklyTypedEnum(label) {
808808
return weakEnumList.includes(label);
809809
}
810810

811+
let legacyStructList = undefined;
812+
function isLegacyStruct(label) {
813+
if (legacyStructList === undefined) {
814+
let f = this.global.resource('legacy-struct-list');
815+
// NOTE: This has to be sync, so we can use this data in if conditions.
816+
let rawData = fs.readFileSync(f, { encoding: 'utf8', flag: 'r' });
817+
legacyStructList = YAML.parse(rawData);
818+
}
819+
return legacyStructList.includes(label);
820+
}
821+
811822
function incrementDepth(depth) {
812823
return depth + 1;
813824
}
@@ -920,6 +931,7 @@ exports.zapTypeToDecodableClusterObjectType =
920931
zapTypeToDecodableClusterObjectType;
921932
exports.zapTypeToPythonClusterObjectType = zapTypeToPythonClusterObjectType;
922933
exports.isWeaklyTypedEnum = isWeaklyTypedEnum;
934+
exports.isLegacyStruct = isLegacyStruct;
923935
exports.getPythonFieldDefault = getPythonFieldDefault;
924936
exports.incrementDepth = incrementDepth;
925937
exports.zcl_events_fields_by_event_name = zcl_events_fields_by_event_name;

0 commit comments

Comments
 (0)