From d8415780d92050a1e2dc3216fa6e522475ac35de Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 11 Oct 2024 11:20:14 -0400 Subject: [PATCH] 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. --- .../darwin/Framework/CHIP/templates/helper.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src-electron/generator/matter/darwin/Framework/CHIP/templates/helper.js b/src-electron/generator/matter/darwin/Framework/CHIP/templates/helper.js index 85d2a98429..ba69da54eb 100644 --- a/src-electron/generator/matter/darwin/Framework/CHIP/templates/helper.js +++ b/src-electron/generator/matter/darwin/Framework/CHIP/templates/helper.js @@ -594,6 +594,10 @@ function makeAvailabilityPath(clusterName, options) { return ['global attributes', options.hash.globalAttribute]; } + if (options.hash.deviceType) { + return ['device types', options.hash.deviceType]; + } + return ['clusters', clusterName]; } @@ -626,6 +630,7 @@ function findPathToContainer(availabilityPath) { case 'apis': case 'global attributes': case 'clusters': + case 'device types': return undefined; default: @@ -1254,6 +1259,25 @@ async function async_not(value) { return !toBeNegated; } +function isLessThan(value1, value2) { + return value1 < value2; +} + +function stripPrefix(value, prefix) { + if (value.startsWith(prefix)) { + return value.substring(prefix.length); + } + + return value; +} + +function cleanDeviceName(deviceName) { + deviceName = stripPrefix.call(this, deviceName, 'Matter '); + return appHelper.asUpperCamelCase.call(this, deviceName, { + hash: { preserveAcronyms: true } + }); +} + // // Module exports // @@ -1288,6 +1312,9 @@ exports.async_not = async_not; exports.oldName = oldName; exports.hasOldName = hasOldName; exports.hasRenamedFields = hasRenamedFields; +exports.isLessThan = isLessThan; +exports.stripPrefix = stripPrefix; +exports.cleanDeviceName = cleanDeviceName; exports.meta = { category: dbEnum.helperCategory.matter,