From 888a86589d91ab5ffc74e61b5fc33f17666048ec Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Thu, 12 Oct 2023 18:44:14 +0000 Subject: [PATCH 1/5] Allow for enums that are not used in a DataModel struct to be generated differently --- src/app/common/templates/config-data.yaml | 13 +++ .../templates/app/cluster-enums-check.zapt | 2 + .../templates/app/cluster-enums.zapt | 7 ++ .../python/chip/clusters/Objects.py | 63 ++++++------ .../templates/python-cluster-Objects-py.zapt | 7 ++ .../python/templates/templates.json | 5 +- .../zap-generated/cluster-enums-check.h | 98 ------------------- .../app-common/zap-generated/cluster-enums.h | 63 ++++++------ 8 files changed, 89 insertions(+), 169 deletions(-) diff --git a/src/app/common/templates/config-data.yaml b/src/app/common/templates/config-data.yaml index 40251139dae555..50d174a8a52902 100644 --- a/src/app/common/templates/config-data.yaml +++ b/src/app/common/templates/config-data.yaml @@ -12,6 +12,19 @@ WeakEnums: - RadioFaultEnum - StepMode +EnumsNotUsedInDataModelStruct: + # List of enums that are not used in a DataModel Struct. By adding an enum + # to this list you prevent incorrectly assuming from code that you are + # able to use kUnknownEnumValue safely. This happens for derivate clusters + # such as ModeBase where there are CommonTag, DerivedClusterTags, MfgTags. + - "DishwasherMode::ModeTag" + - "LaundryWasherMode::ModeTag" + - "RefrigeratorAndTemperatureControlledCabinetMode::ModeTag" + - "RvcRunMode::ModeTag" + - "RvcRunMode::StatusCode" + - "RvcCleanMode::ModeTag" + - "RvcCleanMode::StatusCode" + CommandHandlerInterfaceOnlyClusters: # List of clusters that are implemented entirely with # CommandHandlerInterface and hence do not need generated command dispatch. diff --git a/src/app/zap-templates/templates/app/cluster-enums-check.zapt b/src/app/zap-templates/templates/app/cluster-enums-check.zapt index e673a7af185278..630614a1da1ee3 100644 --- a/src/app/zap-templates/templates/app/cluster-enums-check.zapt +++ b/src/app/zap-templates/templates/app/cluster-enums-check.zapt @@ -9,6 +9,7 @@ namespace app { namespace Clusters { {{#zcl_clusters}} {{#zcl_enums}} +{{#unless (isInConfigList (concat (asUpperCamelCase ../name) "::" label) "EnumsNotUsedInDataModelStruct")}} static auto __attribute__((unused)) EnsureKnownEnumValue({{asUpperCamelCase ../name}}::{{asType label}} val) { using EnumType = {{asUpperCamelCase ../name}}::{{asType label}}; @@ -33,6 +34,7 @@ static auto __attribute__((unused)) EnsureKnownEnumValue({{asUpperCamelCase ../n return static_cast({{first_unused_enum_value mode="first_unused"}}); } } +{{/unless}} {{/zcl_enums}} {{/zcl_clusters}} diff --git a/src/app/zap-templates/templates/app/cluster-enums.zapt b/src/app/zap-templates/templates/app/cluster-enums.zapt index 4394ed79a7c25a..e41c615d26d0ba 100644 --- a/src/app/zap-templates/templates/app/cluster-enums.zapt +++ b/src/app/zap-templates/templates/app/cluster-enums.zapt @@ -24,11 +24,18 @@ enum class {{asType label}} : {{asUnderlyingZclType name}} { {{#zcl_enum_items}} k{{asUpperCamelCase label}} = {{asHex value 2}}, {{/zcl_enum_items}} +{{#unless (isInConfigList (concat (asUpperCamelCase ../name) "::" label) "EnumsNotUsedInDataModelStruct")}} // All received enum values that are not listed above will be mapped // to kUnknownEnumValue. This is a helper enum value that should only // be used by code to process how it handles receiving and unknown // enum value. This specific should never be transmitted. kUnknownEnumValue = {{first_unused_enum_value mode="first_unused"}}, +{{else}} +// kUnknownEnumValue intentionally not defined. This enum is not used +// in a DataModel struct, likely because it is a part of a derivative +// cluster. As a result having kUnknownEnumValue in this enum is error +// prone, and was removed. +{{/unless}} }; {{#if (isInConfigList label "WeakEnums")}} #else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 300e8b56cb66c7..6e3ed958fccfde 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -15261,11 +15261,10 @@ class ModeTag(MatterIntEnum): kDelicate = 0x4001 kHeavy = 0x4002 kWhites = 0x4003 - # All received enum values that are not listed above will be mapped - # to kUnknownEnumValue. This is a helper enum value that should only - # be used by code to process how it handles receiving and unknown - # enum value. This specific should never be transmitted. - kUnknownEnumValue = 0, + # kUnknownEnumValue intentionally not defined. This enum is not used + # in a DataModel struct, likely because it is a part of a derivative + # cluster. As a result having kUnknownEnumValue in this enum is error + # prone, and was removed. class Bitmaps: class Feature(IntFlag): @@ -15532,11 +15531,10 @@ class Enums: class ModeTag(MatterIntEnum): kRapidCool = 0x4000 kRapidFreeze = 0x4001 - # All received enum values that are not listed above will be mapped - # to kUnknownEnumValue. This is a helper enum value that should only - # be used by code to process how it handles receiving and unknown - # enum value. This specific should never be transmitted. - kUnknownEnumValue = 0, + # kUnknownEnumValue intentionally not defined. This enum is not used + # in a DataModel struct, likely because it is a part of a derivative + # cluster. As a result having kUnknownEnumValue in this enum is error + # prone, and was removed. class Bitmaps: class Feature(IntFlag): @@ -16013,11 +16011,10 @@ class Enums: class ModeTag(MatterIntEnum): kIdle = 0x4000 kCleaning = 0x4001 - # All received enum values that are not listed above will be mapped - # to kUnknownEnumValue. This is a helper enum value that should only - # be used by code to process how it handles receiving and unknown - # enum value. This specific should never be transmitted. - kUnknownEnumValue = 0, + # kUnknownEnumValue intentionally not defined. This enum is not used + # in a DataModel struct, likely because it is a part of a derivative + # cluster. As a result having kUnknownEnumValue in this enum is error + # prone, and was removed. class StatusCode(MatterIntEnum): kStuck = 0x41 @@ -16028,11 +16025,10 @@ class StatusCode(MatterIntEnum): kWaterTankLidOpen = 0x46 kMopCleaningPadMissing = 0x47 kBatteryLow = 0x48 - # All received enum values that are not listed above will be mapped - # to kUnknownEnumValue. This is a helper enum value that should only - # be used by code to process how it handles receiving and unknown - # enum value. This specific should never be transmitted. - kUnknownEnumValue = 0, + # kUnknownEnumValue intentionally not defined. This enum is not used + # in a DataModel struct, likely because it is a part of a derivative + # cluster. As a result having kUnknownEnumValue in this enum is error + # prone, and was removed. class Bitmaps: class Feature(IntFlag): @@ -16300,19 +16296,17 @@ class ModeTag(MatterIntEnum): kDeepClean = 0x4000 kVacuum = 0x4001 kMop = 0x4002 - # All received enum values that are not listed above will be mapped - # to kUnknownEnumValue. This is a helper enum value that should only - # be used by code to process how it handles receiving and unknown - # enum value. This specific should never be transmitted. - kUnknownEnumValue = 0, + # kUnknownEnumValue intentionally not defined. This enum is not used + # in a DataModel struct, likely because it is a part of a derivative + # cluster. As a result having kUnknownEnumValue in this enum is error + # prone, and was removed. class StatusCode(MatterIntEnum): kCleaningInProgress = 0x40 - # All received enum values that are not listed above will be mapped - # to kUnknownEnumValue. This is a helper enum value that should only - # be used by code to process how it handles receiving and unknown - # enum value. This specific should never be transmitted. - kUnknownEnumValue = 0, + # kUnknownEnumValue intentionally not defined. This enum is not used + # in a DataModel struct, likely because it is a part of a derivative + # cluster. As a result having kUnknownEnumValue in this enum is error + # prone, and was removed. class Bitmaps: class Feature(IntFlag): @@ -17039,11 +17033,10 @@ class ModeTag(MatterIntEnum): kNormal = 0x4000 kHeavy = 0x4001 kLight = 0x4002 - # All received enum values that are not listed above will be mapped - # to kUnknownEnumValue. This is a helper enum value that should only - # be used by code to process how it handles receiving and unknown - # enum value. This specific should never be transmitted. - kUnknownEnumValue = 0, + # kUnknownEnumValue intentionally not defined. This enum is not used + # in a DataModel struct, likely because it is a part of a derivative + # cluster. As a result having kUnknownEnumValue in this enum is error + # prone, and was removed. class Bitmaps: class Feature(IntFlag): diff --git a/src/controller/python/templates/python-cluster-Objects-py.zapt b/src/controller/python/templates/python-cluster-Objects-py.zapt index 9fada4b5792c4e..b41f8de5992a68 100644 --- a/src/controller/python/templates/python-cluster-Objects-py.zapt +++ b/src/controller/python/templates/python-cluster-Objects-py.zapt @@ -54,11 +54,18 @@ class {{asUpperCamelCase name}}(Cluster): {{#zcl_enum_items}} k{{asUpperCamelCase label}} = {{asHex value 2}} {{/zcl_enum_items}} +{{#unless (isInConfigList (concat (asUpperCamelCase ../name) "::" label) "EnumsNotUsedInDataModelStruct")}} # All received enum values that are not listed above will be mapped # to kUnknownEnumValue. This is a helper enum value that should only # be used by code to process how it handles receiving and unknown # enum value. This specific should never be transmitted. kUnknownEnumValue = {{first_unused_enum_value mode="first_unused"}}, +{{else}} + # kUnknownEnumValue intentionally not defined. This enum is not used + # in a DataModel struct, likely because it is a part of a derivative + # cluster. As a result having kUnknownEnumValue in this enum is error + # prone, and was removed. +{{/unless}} {{#last}} {{/last}} diff --git a/src/controller/python/templates/templates.json b/src/controller/python/templates/templates.json index e5d15198c5aac8..0fb4defaa2b345 100644 --- a/src/controller/python/templates/templates.json +++ b/src/controller/python/templates/templates.json @@ -8,6 +8,9 @@ "templates/chip/helper.js", "controller/python/templates/helper.js" ], + "resources": { + "config-data": "../../../../src/app/common/templates/config-data.yaml" + }, "override": "../../../../src/app/zap-templates/common/override.js", "partials": [ { @@ -35,4 +38,4 @@ "output": "src/controller/python/chip/clusters/Objects.py" } ] -} +} \ No newline at end of file diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h index 949458b352d355..a68a5dcc8cc234 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h @@ -1237,34 +1237,6 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(GroupKeyManagement::Gro } } -static auto __attribute__((unused)) EnsureKnownEnumValue(LaundryWasherMode::ModeTag val) -{ - using EnumType = LaundryWasherMode::ModeTag; - switch (val) - { - case EnumType::kNormal: - case EnumType::kDelicate: - case EnumType::kHeavy: - case EnumType::kWhites: - return val; - default: - return static_cast(0); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(RefrigeratorAndTemperatureControlledCabinetMode::ModeTag val) -{ - using EnumType = RefrigeratorAndTemperatureControlledCabinetMode::ModeTag; - switch (val) - { - case EnumType::kRapidCool: - case EnumType::kRapidFreeze: - return val; - default: - return static_cast(0); - } -} - static auto __attribute__((unused)) EnsureKnownEnumValue(LaundryWasherControls::NumberOfRinsesEnum val) { using EnumType = LaundryWasherControls::NumberOfRinsesEnum; @@ -1280,76 +1252,6 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(LaundryWasherControls:: } } -static auto __attribute__((unused)) EnsureKnownEnumValue(RvcRunMode::ModeTag val) -{ - using EnumType = RvcRunMode::ModeTag; - switch (val) - { - case EnumType::kIdle: - case EnumType::kCleaning: - return val; - default: - return static_cast(0); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(RvcRunMode::StatusCode val) -{ - using EnumType = RvcRunMode::StatusCode; - switch (val) - { - case EnumType::kStuck: - case EnumType::kDustBinMissing: - case EnumType::kDustBinFull: - case EnumType::kWaterTankEmpty: - case EnumType::kWaterTankMissing: - case EnumType::kWaterTankLidOpen: - case EnumType::kMopCleaningPadMissing: - case EnumType::kBatteryLow: - return val; - default: - return static_cast(0); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(RvcCleanMode::ModeTag val) -{ - using EnumType = RvcCleanMode::ModeTag; - switch (val) - { - case EnumType::kDeepClean: - case EnumType::kVacuum: - case EnumType::kMop: - return val; - default: - return static_cast(0); - } -} -static auto __attribute__((unused)) EnsureKnownEnumValue(RvcCleanMode::StatusCode val) -{ - using EnumType = RvcCleanMode::StatusCode; - switch (val) - { - case EnumType::kCleaningInProgress: - return val; - default: - return static_cast(0); - } -} - -static auto __attribute__((unused)) EnsureKnownEnumValue(DishwasherMode::ModeTag val) -{ - using EnumType = DishwasherMode::ModeTag; - switch (val) - { - case EnumType::kNormal: - case EnumType::kHeavy: - case EnumType::kLight: - return val; - default: - return static_cast(0); - } -} - static auto __attribute__((unused)) EnsureKnownEnumValue(AirQuality::AirQualityEnum val) { using EnumType = AirQuality::AirQualityEnum; diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index 81baf06ac090c4..eec30fdb3976ea 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h @@ -1507,11 +1507,10 @@ enum class ModeTag : uint16_t kDelicate = 0x4001, kHeavy = 0x4002, kWhites = 0x4003, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 0, + // kUnknownEnumValue intentionally not defined. This enum is not used + // in a DataModel struct, likely because it is a part of a derivative + // cluster. As a result having kUnknownEnumValue in this enum is error + // prone, and was removed. }; // Bitmap for Feature @@ -1528,11 +1527,10 @@ enum class ModeTag : uint16_t { kRapidCool = 0x4000, kRapidFreeze = 0x4001, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 0, + // kUnknownEnumValue intentionally not defined. This enum is not used + // in a DataModel struct, likely because it is a part of a derivative + // cluster. As a result having kUnknownEnumValue in this enum is error + // prone, and was removed. }; // Bitmap for Feature @@ -1573,11 +1571,10 @@ enum class ModeTag : uint16_t { kIdle = 0x4000, kCleaning = 0x4001, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 0, + // kUnknownEnumValue intentionally not defined. This enum is not used + // in a DataModel struct, likely because it is a part of a derivative + // cluster. As a result having kUnknownEnumValue in this enum is error + // prone, and was removed. }; // Enum for StatusCode @@ -1591,11 +1588,10 @@ enum class StatusCode : uint8_t kWaterTankLidOpen = 0x46, kMopCleaningPadMissing = 0x47, kBatteryLow = 0x48, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 0, + // kUnknownEnumValue intentionally not defined. This enum is not used + // in a DataModel struct, likely because it is a part of a derivative + // cluster. As a result having kUnknownEnumValue in this enum is error + // prone, and was removed. }; // Bitmap for Feature @@ -1613,22 +1609,20 @@ enum class ModeTag : uint16_t kDeepClean = 0x4000, kVacuum = 0x4001, kMop = 0x4002, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 0, + // kUnknownEnumValue intentionally not defined. This enum is not used + // in a DataModel struct, likely because it is a part of a derivative + // cluster. As a result having kUnknownEnumValue in this enum is error + // prone, and was removed. }; // Enum for StatusCode enum class StatusCode : uint8_t { kCleaningInProgress = 0x40, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 0, + // kUnknownEnumValue intentionally not defined. This enum is not used + // in a DataModel struct, likely because it is a part of a derivative + // cluster. As a result having kUnknownEnumValue in this enum is error + // prone, and was removed. }; // Bitmap for Feature @@ -1666,11 +1660,10 @@ enum class ModeTag : uint16_t kNormal = 0x4000, kHeavy = 0x4001, kLight = 0x4002, - // All received enum values that are not listed above will be mapped - // to kUnknownEnumValue. This is a helper enum value that should only - // be used by code to process how it handles receiving and unknown - // enum value. This specific should never be transmitted. - kUnknownEnumValue = 0, + // kUnknownEnumValue intentionally not defined. This enum is not used + // in a DataModel struct, likely because it is a part of a derivative + // cluster. As a result having kUnknownEnumValue in this enum is error + // prone, and was removed. }; // Bitmap for Feature From 0a58760393b0f3731f7cbe3d2fda08bae5944597 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Thu, 12 Oct 2023 19:22:50 +0000 Subject: [PATCH 2/5] Restyle --- src/controller/python/templates/templates.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controller/python/templates/templates.json b/src/controller/python/templates/templates.json index 0fb4defaa2b345..bffd9dfa2de7cc 100644 --- a/src/controller/python/templates/templates.json +++ b/src/controller/python/templates/templates.json @@ -38,4 +38,4 @@ "output": "src/controller/python/chip/clusters/Objects.py" } ] -} \ No newline at end of file +} From 7cd9038b2d7d06f9473286f7d9fd1fb8435b8dd7 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Thu, 12 Oct 2023 20:24:13 +0000 Subject: [PATCH 3/5] Address PR comment --- src/app/common/templates/config-data.yaml | 2 +- .../templates/app/cluster-enums-check.zapt | 2 +- .../templates/app/cluster-enums.zapt | 9 ++-- .../python/chip/clusters/Objects.py | 49 +++++++++++-------- .../templates/python-cluster-Objects-py.zapt | 9 ++-- 5 files changed, 40 insertions(+), 31 deletions(-) diff --git a/src/app/common/templates/config-data.yaml b/src/app/common/templates/config-data.yaml index 50d174a8a52902..8b810aafda88d9 100644 --- a/src/app/common/templates/config-data.yaml +++ b/src/app/common/templates/config-data.yaml @@ -12,7 +12,7 @@ WeakEnums: - RadioFaultEnum - StepMode -EnumsNotUsedInDataModelStruct: +EnumsNotUsedAsTypeInXML: # List of enums that are not used in a DataModel Struct. By adding an enum # to this list you prevent incorrectly assuming from code that you are # able to use kUnknownEnumValue safely. This happens for derivate clusters diff --git a/src/app/zap-templates/templates/app/cluster-enums-check.zapt b/src/app/zap-templates/templates/app/cluster-enums-check.zapt index 630614a1da1ee3..cf66cef8a3d5c2 100644 --- a/src/app/zap-templates/templates/app/cluster-enums-check.zapt +++ b/src/app/zap-templates/templates/app/cluster-enums-check.zapt @@ -9,7 +9,7 @@ namespace app { namespace Clusters { {{#zcl_clusters}} {{#zcl_enums}} -{{#unless (isInConfigList (concat (asUpperCamelCase ../name) "::" label) "EnumsNotUsedInDataModelStruct")}} +{{#unless (isInConfigList (concat (asUpperCamelCase ../name) "::" label) "EnumsNotUsedAsTypeInXML")}} static auto __attribute__((unused)) EnsureKnownEnumValue({{asUpperCamelCase ../name}}::{{asType label}} val) { using EnumType = {{asUpperCamelCase ../name}}::{{asType label}}; diff --git a/src/app/zap-templates/templates/app/cluster-enums.zapt b/src/app/zap-templates/templates/app/cluster-enums.zapt index e41c615d26d0ba..4703d267622a67 100644 --- a/src/app/zap-templates/templates/app/cluster-enums.zapt +++ b/src/app/zap-templates/templates/app/cluster-enums.zapt @@ -24,17 +24,18 @@ enum class {{asType label}} : {{asUnderlyingZclType name}} { {{#zcl_enum_items}} k{{asUpperCamelCase label}} = {{asHex value 2}}, {{/zcl_enum_items}} -{{#unless (isInConfigList (concat (asUpperCamelCase ../name) "::" label) "EnumsNotUsedInDataModelStruct")}} +{{#unless (isInConfigList (concat (asUpperCamelCase ../name) "::" label) "EnumsNotUsedAsTypeInXML")}} // All received enum values that are not listed above will be mapped // to kUnknownEnumValue. This is a helper enum value that should only // be used by code to process how it handles receiving and unknown // enum value. This specific should never be transmitted. kUnknownEnumValue = {{first_unused_enum_value mode="first_unused"}}, {{else}} -// kUnknownEnumValue intentionally not defined. This enum is not used -// in a DataModel struct, likely because it is a part of a derivative +// kUnknownEnumValue intentionally not defined. This enum never goes +// through DataModel::Decode, likely because it is a part of a derived // cluster. As a result having kUnknownEnumValue in this enum is error -// prone, and was removed. +// prone, and was removed. See +// src/app/common/templates/config-data.yaml. {{/unless}} }; {{#if (isInConfigList label "WeakEnums")}} diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 6e3ed958fccfde..31c1cefa96b774 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -15261,10 +15261,11 @@ class ModeTag(MatterIntEnum): kDelicate = 0x4001 kHeavy = 0x4002 kWhites = 0x4003 - # kUnknownEnumValue intentionally not defined. This enum is not used - # in a DataModel struct, likely because it is a part of a derivative + # kUnknownEnumValue intentionally not defined. This enum never goes + # through DataModel::Decode, likely because it is a part of a derived # cluster. As a result having kUnknownEnumValue in this enum is error - # prone, and was removed. + # prone, and was removed. See + # src/app/common/templates/config-data.yaml. class Bitmaps: class Feature(IntFlag): @@ -15531,10 +15532,11 @@ class Enums: class ModeTag(MatterIntEnum): kRapidCool = 0x4000 kRapidFreeze = 0x4001 - # kUnknownEnumValue intentionally not defined. This enum is not used - # in a DataModel struct, likely because it is a part of a derivative + # kUnknownEnumValue intentionally not defined. This enum never goes + # through DataModel::Decode, likely because it is a part of a derived # cluster. As a result having kUnknownEnumValue in this enum is error - # prone, and was removed. + # prone, and was removed. See + # src/app/common/templates/config-data.yaml. class Bitmaps: class Feature(IntFlag): @@ -16011,10 +16013,11 @@ class Enums: class ModeTag(MatterIntEnum): kIdle = 0x4000 kCleaning = 0x4001 - # kUnknownEnumValue intentionally not defined. This enum is not used - # in a DataModel struct, likely because it is a part of a derivative + # kUnknownEnumValue intentionally not defined. This enum never goes + # through DataModel::Decode, likely because it is a part of a derived # cluster. As a result having kUnknownEnumValue in this enum is error - # prone, and was removed. + # prone, and was removed. See + # src/app/common/templates/config-data.yaml. class StatusCode(MatterIntEnum): kStuck = 0x41 @@ -16025,10 +16028,11 @@ class StatusCode(MatterIntEnum): kWaterTankLidOpen = 0x46 kMopCleaningPadMissing = 0x47 kBatteryLow = 0x48 - # kUnknownEnumValue intentionally not defined. This enum is not used - # in a DataModel struct, likely because it is a part of a derivative + # kUnknownEnumValue intentionally not defined. This enum never goes + # through DataModel::Decode, likely because it is a part of a derived # cluster. As a result having kUnknownEnumValue in this enum is error - # prone, and was removed. + # prone, and was removed. See + # src/app/common/templates/config-data.yaml. class Bitmaps: class Feature(IntFlag): @@ -16296,17 +16300,19 @@ class ModeTag(MatterIntEnum): kDeepClean = 0x4000 kVacuum = 0x4001 kMop = 0x4002 - # kUnknownEnumValue intentionally not defined. This enum is not used - # in a DataModel struct, likely because it is a part of a derivative + # kUnknownEnumValue intentionally not defined. This enum never goes + # through DataModel::Decode, likely because it is a part of a derived # cluster. As a result having kUnknownEnumValue in this enum is error - # prone, and was removed. + # prone, and was removed. See + # src/app/common/templates/config-data.yaml. class StatusCode(MatterIntEnum): kCleaningInProgress = 0x40 - # kUnknownEnumValue intentionally not defined. This enum is not used - # in a DataModel struct, likely because it is a part of a derivative + # kUnknownEnumValue intentionally not defined. This enum never goes + # through DataModel::Decode, likely because it is a part of a derived # cluster. As a result having kUnknownEnumValue in this enum is error - # prone, and was removed. + # prone, and was removed. See + # src/app/common/templates/config-data.yaml. class Bitmaps: class Feature(IntFlag): @@ -17033,10 +17039,11 @@ class ModeTag(MatterIntEnum): kNormal = 0x4000 kHeavy = 0x4001 kLight = 0x4002 - # kUnknownEnumValue intentionally not defined. This enum is not used - # in a DataModel struct, likely because it is a part of a derivative + # kUnknownEnumValue intentionally not defined. This enum never goes + # through DataModel::Decode, likely because it is a part of a derived # cluster. As a result having kUnknownEnumValue in this enum is error - # prone, and was removed. + # prone, and was removed. See + # src/app/common/templates/config-data.yaml. class Bitmaps: class Feature(IntFlag): diff --git a/src/controller/python/templates/python-cluster-Objects-py.zapt b/src/controller/python/templates/python-cluster-Objects-py.zapt index b41f8de5992a68..b5f8ed80ca03d9 100644 --- a/src/controller/python/templates/python-cluster-Objects-py.zapt +++ b/src/controller/python/templates/python-cluster-Objects-py.zapt @@ -54,17 +54,18 @@ class {{asUpperCamelCase name}}(Cluster): {{#zcl_enum_items}} k{{asUpperCamelCase label}} = {{asHex value 2}} {{/zcl_enum_items}} -{{#unless (isInConfigList (concat (asUpperCamelCase ../name) "::" label) "EnumsNotUsedInDataModelStruct")}} +{{#unless (isInConfigList (concat (asUpperCamelCase ../name) "::" label) "EnumsNotUsedAsTypeInXML")}} # All received enum values that are not listed above will be mapped # to kUnknownEnumValue. This is a helper enum value that should only # be used by code to process how it handles receiving and unknown # enum value. This specific should never be transmitted. kUnknownEnumValue = {{first_unused_enum_value mode="first_unused"}}, {{else}} - # kUnknownEnumValue intentionally not defined. This enum is not used - # in a DataModel struct, likely because it is a part of a derivative + # kUnknownEnumValue intentionally not defined. This enum never goes + # through DataModel::Decode, likely because it is a part of a derived # cluster. As a result having kUnknownEnumValue in this enum is error - # prone, and was removed. + # prone, and was removed. See + # src/app/common/templates/config-data.yaml. {{/unless}} {{#last}} From eb0794c49a738cee3a725d4bd63f88069e17caec Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Thu, 12 Oct 2023 20:45:05 +0000 Subject: [PATCH 4/5] Address PR comment --- .../app-common/zap-generated/cluster-enums.h | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index eec30fdb3976ea..ba56a33649b0f0 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h @@ -1507,10 +1507,11 @@ enum class ModeTag : uint16_t kDelicate = 0x4001, kHeavy = 0x4002, kWhites = 0x4003, - // kUnknownEnumValue intentionally not defined. This enum is not used - // in a DataModel struct, likely because it is a part of a derivative + // kUnknownEnumValue intentionally not defined. This enum never goes + // through DataModel::Decode, likely because it is a part of a derived // cluster. As a result having kUnknownEnumValue in this enum is error - // prone, and was removed. + // prone, and was removed. See + // src/app/common/templates/config-data.yaml. }; // Bitmap for Feature @@ -1527,10 +1528,11 @@ enum class ModeTag : uint16_t { kRapidCool = 0x4000, kRapidFreeze = 0x4001, - // kUnknownEnumValue intentionally not defined. This enum is not used - // in a DataModel struct, likely because it is a part of a derivative + // kUnknownEnumValue intentionally not defined. This enum never goes + // through DataModel::Decode, likely because it is a part of a derived // cluster. As a result having kUnknownEnumValue in this enum is error - // prone, and was removed. + // prone, and was removed. See + // src/app/common/templates/config-data.yaml. }; // Bitmap for Feature @@ -1571,10 +1573,11 @@ enum class ModeTag : uint16_t { kIdle = 0x4000, kCleaning = 0x4001, - // kUnknownEnumValue intentionally not defined. This enum is not used - // in a DataModel struct, likely because it is a part of a derivative + // kUnknownEnumValue intentionally not defined. This enum never goes + // through DataModel::Decode, likely because it is a part of a derived // cluster. As a result having kUnknownEnumValue in this enum is error - // prone, and was removed. + // prone, and was removed. See + // src/app/common/templates/config-data.yaml. }; // Enum for StatusCode @@ -1588,10 +1591,11 @@ enum class StatusCode : uint8_t kWaterTankLidOpen = 0x46, kMopCleaningPadMissing = 0x47, kBatteryLow = 0x48, - // kUnknownEnumValue intentionally not defined. This enum is not used - // in a DataModel struct, likely because it is a part of a derivative + // kUnknownEnumValue intentionally not defined. This enum never goes + // through DataModel::Decode, likely because it is a part of a derived // cluster. As a result having kUnknownEnumValue in this enum is error - // prone, and was removed. + // prone, and was removed. See + // src/app/common/templates/config-data.yaml. }; // Bitmap for Feature @@ -1609,20 +1613,22 @@ enum class ModeTag : uint16_t kDeepClean = 0x4000, kVacuum = 0x4001, kMop = 0x4002, - // kUnknownEnumValue intentionally not defined. This enum is not used - // in a DataModel struct, likely because it is a part of a derivative + // kUnknownEnumValue intentionally not defined. This enum never goes + // through DataModel::Decode, likely because it is a part of a derived // cluster. As a result having kUnknownEnumValue in this enum is error - // prone, and was removed. + // prone, and was removed. See + // src/app/common/templates/config-data.yaml. }; // Enum for StatusCode enum class StatusCode : uint8_t { kCleaningInProgress = 0x40, - // kUnknownEnumValue intentionally not defined. This enum is not used - // in a DataModel struct, likely because it is a part of a derivative + // kUnknownEnumValue intentionally not defined. This enum never goes + // through DataModel::Decode, likely because it is a part of a derived // cluster. As a result having kUnknownEnumValue in this enum is error - // prone, and was removed. + // prone, and was removed. See + // src/app/common/templates/config-data.yaml. }; // Bitmap for Feature @@ -1660,10 +1666,11 @@ enum class ModeTag : uint16_t kNormal = 0x4000, kHeavy = 0x4001, kLight = 0x4002, - // kUnknownEnumValue intentionally not defined. This enum is not used - // in a DataModel struct, likely because it is a part of a derivative + // kUnknownEnumValue intentionally not defined. This enum never goes + // through DataModel::Decode, likely because it is a part of a derived // cluster. As a result having kUnknownEnumValue in this enum is error - // prone, and was removed. + // prone, and was removed. See + // src/app/common/templates/config-data.yaml. }; // Bitmap for Feature From 2425575d05714e6460227d7b4cab4e31928ab6c6 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Fri, 13 Oct 2023 11:56:19 -0400 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Boris Zbarsky --- src/app/common/templates/config-data.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/common/templates/config-data.yaml b/src/app/common/templates/config-data.yaml index 8b810aafda88d9..945530ce3f8123 100644 --- a/src/app/common/templates/config-data.yaml +++ b/src/app/common/templates/config-data.yaml @@ -13,9 +13,9 @@ WeakEnums: - StepMode EnumsNotUsedAsTypeInXML: - # List of enums that are not used in a DataModel Struct. By adding an enum + # List of enums that are not used as a type in XML. By adding an enum # to this list you prevent incorrectly assuming from code that you are - # able to use kUnknownEnumValue safely. This happens for derivate clusters + # able to use kUnknownEnumValue safely. This happens for derived clusters # such as ModeBase where there are CommonTag, DerivedClusterTags, MfgTags. - "DishwasherMode::ModeTag" - "LaundryWasherMode::ModeTag"