Skip to content

Commit

Permalink
Fix Darwin helpers to allow working with device types. (#1452)
Browse files Browse the repository at this point in the history
1) Add device types to availability macro generation.
2) Add some helpers that allow properly generating device type metadata.
  • Loading branch information
bzbarsky-apple authored Oct 11, 2024
1 parent 2e03156 commit d841578
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down Expand Up @@ -626,6 +630,7 @@ function findPathToContainer(availabilityPath) {
case 'apis':
case 'global attributes':
case 'clusters':
case 'device types':
return undefined;

default:
Expand Down Expand Up @@ -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
//
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d841578

Please sign in to comment.