-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for global structs/enums/bitmaps to Python codegen. (#34561)
- Loading branch information
1 parent
388b1a7
commit 2637921
Showing
7 changed files
with
570 additions
and
496 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class {{asType label}}(IntFlag): | ||
{{#zcl_bitmap_items}} | ||
k{{asUpperCamelCase label}} = {{asHex mask}} | ||
{{/zcl_bitmap_items}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{{! Takes cluster (possibly "Globals") as argument, already upper-camel-cased. }} | ||
class {{asType label}}(MatterIntEnum): | ||
{{#zcl_enum_items}} | ||
k{{asUpperCamelCase label}} = {{asHex value 2}} | ||
{{/zcl_enum_items}} | ||
{{#unless (isInConfigList (concat cluster "::" 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 an unknown | ||
# enum value. This specific value should never be transmitted. | ||
kUnknownEnumValue = {{first_unused_enum_value mode="first_unused"}}, | ||
{{else}} | ||
# 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. See | ||
# src/app/common/templates/config-data.yaml. | ||
{{/unless}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{! Takes cluster (possibly "Globals") as argument, already upper-camel-cased. }} | ||
@dataclass | ||
class {{asUpperCamelCase name}}(ClusterObject): | ||
@ChipUtility.classproperty | ||
def descriptor(cls) -> ClusterObjectDescriptor: | ||
return ClusterObjectDescriptor( | ||
Fields=[ | ||
{{#zcl_struct_items}} | ||
ClusterObjectFieldDescriptor(Label="{{ asLowerCamelCase label }}", Tag={{ fieldIdentifier }}, Type={{zapTypeToPythonClusterObjectType type ns=../cluster}}), | ||
{{/zcl_struct_items}} | ||
]) | ||
|
||
{{#zcl_struct_items}} | ||
{{ asLowerCamelCase label }}: '{{zapTypeToPythonClusterObjectType type ns=../cluster}}' = {{getPythonFieldDefault type ns=../cluster}} | ||
{{/zcl_struct_items}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters