Skip to content

Commit d841578

Browse files
Fix Darwin helpers to allow working with device types. (#1452)
1) Add device types to availability macro generation. 2) Add some helpers that allow properly generating device type metadata.
1 parent 2e03156 commit d841578

File tree

1 file changed

+27
-0
lines changed
  • src-electron/generator/matter/darwin/Framework/CHIP/templates

1 file changed

+27
-0
lines changed

src-electron/generator/matter/darwin/Framework/CHIP/templates/helper.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,10 @@ function makeAvailabilityPath(clusterName, options) {
594594
return ['global attributes', options.hash.globalAttribute];
595595
}
596596

597+
if (options.hash.deviceType) {
598+
return ['device types', options.hash.deviceType];
599+
}
600+
597601
return ['clusters', clusterName];
598602
}
599603

@@ -626,6 +630,7 @@ function findPathToContainer(availabilityPath) {
626630
case 'apis':
627631
case 'global attributes':
628632
case 'clusters':
633+
case 'device types':
629634
return undefined;
630635

631636
default:
@@ -1254,6 +1259,25 @@ async function async_not(value) {
12541259
return !toBeNegated;
12551260
}
12561261

1262+
function isLessThan(value1, value2) {
1263+
return value1 < value2;
1264+
}
1265+
1266+
function stripPrefix(value, prefix) {
1267+
if (value.startsWith(prefix)) {
1268+
return value.substring(prefix.length);
1269+
}
1270+
1271+
return value;
1272+
}
1273+
1274+
function cleanDeviceName(deviceName) {
1275+
deviceName = stripPrefix.call(this, deviceName, 'Matter ');
1276+
return appHelper.asUpperCamelCase.call(this, deviceName, {
1277+
hash: { preserveAcronyms: true }
1278+
});
1279+
}
1280+
12571281
//
12581282
// Module exports
12591283
//
@@ -1288,6 +1312,9 @@ exports.async_not = async_not;
12881312
exports.oldName = oldName;
12891313
exports.hasOldName = hasOldName;
12901314
exports.hasRenamedFields = hasRenamedFields;
1315+
exports.isLessThan = isLessThan;
1316+
exports.stripPrefix = stripPrefix;
1317+
exports.cleanDeviceName = cleanDeviceName;
12911318

12921319
exports.meta = {
12931320
category: dbEnum.helperCategory.matter,

0 commit comments

Comments
 (0)