Skip to content

Commit

Permalink
Add support for backwards-compat shims for cluster renames on Darwin. (
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple authored Nov 15, 2022
1 parent 00b35d4 commit 22a059d
Showing 1 changed file with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,22 @@ function asObjectiveCNumberType(label, type, asLowerCased) {
return templateUtil.templatePromise(this.global, promise);
}

const compatClusterNameMap = {
UnitTesting: 'TestCluster',
};

function compatClusterNameRemapping(cluster) {
cluster = appHelper.asUpperCamelCase(cluster, {
hash: { preserveAcronyms: false },
});

if (cluster in compatClusterNameMap) {
cluster = compatClusterNameMap[cluster];
}

return cluster;
}

async function asObjectiveCClass(type, cluster, options) {
let pkgIds = await templateUtil.ensureZclPackageIds(this);
let isStruct = await zclHelper
Expand All @@ -152,9 +168,14 @@ async function asObjectiveCClass(type, cluster, options) {
}

if (isStruct) {
return `MTR${appHelper.asUpperCamelCase(cluster, {
hash: { preserveAcronyms: false },
})}Cluster${appHelper.asUpperCamelCase(type)}`;
if (options.hash.compatRemapClusterName) {
cluster = compatClusterNameRemapping.call(this, cluster);
} else {
cluster = appHelper.asUpperCamelCase(cluster, {
hash: { preserveAcronyms: false },
});
}
return `MTR${cluster}Cluster${appHelper.asUpperCamelCase(type)}`;
}

return 'NSNumber';
Expand Down Expand Up @@ -262,6 +283,7 @@ exports.commandHasRequiredField = commandHasRequiredField;
exports.objCEnumName = objCEnumName;
exports.objCEnumItemLabel = objCEnumItemLabel;
exports.hasArguments = hasArguments;
exports.compatClusterNameRemapping = compatClusterNameRemapping;

exports.meta = {
category: dbEnum.helperCategory.matter,
Expand Down

0 comments on commit 22a059d

Please sign in to comment.