Skip to content

Commit

Permalink
Address PR comment
Browse files Browse the repository at this point in the history
  • Loading branch information
tehampson committed Oct 12, 2023
1 parent 0a58760 commit 7cd9038
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/app/common/templates/config-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}};
Expand Down
9 changes: 5 additions & 4 deletions src/app/zap-templates/templates/app/cluster-enums.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -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")}}
Expand Down
49 changes: 28 additions & 21 deletions src/controller/python/chip/clusters/Objects.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down

0 comments on commit 7cd9038

Please sign in to comment.