From 5878545a35abbe1f87bfbef7a214f3458b953939 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 13 Dec 2023 11:29:38 -0500 Subject: [PATCH 1/4] Drop enum support for larger than 16 bit. Spec 7.19.2 Daa Types explicitly says that enumerations may only go up to enum16 and chip-types.xml agrees with that. --- .../py_matter_idl/examples/matter_idl_plugin/__init__.py | 2 +- .../matter_idl/data_model_xml/handlers/handlers.py | 2 +- .../py_matter_idl/matter_idl/generators/java/__init__.py | 4 ---- .../py_matter_idl/matter_idl/generators/kotlin/__init__.py | 2 -- .../py_matter_idl/matter_idl/generators/type_definitions.py | 6 ++---- scripts/py_matter_idl/matter_idl/test_supported_types.py | 4 ++-- 6 files changed, 6 insertions(+), 14 deletions(-) diff --git a/scripts/py_matter_idl/examples/matter_idl_plugin/__init__.py b/scripts/py_matter_idl/examples/matter_idl_plugin/__init__.py index 762f960364cc2d..26463550e6a28a 100644 --- a/scripts/py_matter_idl/examples/matter_idl_plugin/__init__.py +++ b/scripts/py_matter_idl/examples/matter_idl_plugin/__init__.py @@ -56,7 +56,7 @@ def toEnumEntryName(enumEntry, enumName): def toProtobufType(zapType: str) -> str: """ Convert zap type to protobuf type """ u32Types = [ - "uint32", "enum8", "enum16", "enum32", "bitmap8", + "uint32", "enum8", "enum16", "bitmap8", "bitmap16", "bitmap32", "cluster_id", "attrib_id", "event_id", "command_id", "endpoint_no", "group_id", "devtype_id", "fabric_idx", "vendor_id", "status_code", diff --git a/scripts/py_matter_idl/matter_idl/data_model_xml/handlers/handlers.py b/scripts/py_matter_idl/matter_idl/data_model_xml/handlers/handlers.py index 5fa6f06482439c..2a909bbbfb4d23 100644 --- a/scripts/py_matter_idl/matter_idl/data_model_xml/handlers/handlers.py +++ b/scripts/py_matter_idl/matter_idl/data_model_xml/handlers/handlers.py @@ -245,7 +245,7 @@ def EndProcessing(self): if not self._enum.entries: return - # try to find the best enum size that fits out of enum8, enum32 and enum32 + # try to find the best enum size that fits out of enum8 and enum16 # TODO: this is a pure heuristic. XML containing this would be better. # https://github.com/csa-data-model/projects/issues/345 acceptable = {8, 16} diff --git a/scripts/py_matter_idl/matter_idl/generators/java/__init__.py b/scripts/py_matter_idl/matter_idl/generators/java/__init__.py index 98ac58a3a4ce37..caceed7866e9d4 100644 --- a/scripts/py_matter_idl/matter_idl/generators/java/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/java/__init__.py @@ -126,8 +126,6 @@ def FieldToGlobalName(field: Field, context: TypeLookupContext) -> Optional[str] # non-named enums 'enum8': 'uint8_t', 'enum16': 'uint16_t', - 'enum32': 'uint32_t', - 'enum64': 'uint64_t', } @@ -320,8 +318,6 @@ def _IsUsingGlobalCallback(field: Field, context: TypeLookupContext): "int64u", "enum8", "enum16", - "enum32", - "enum64", "bitmap8", "bitmap16", "bitmap32", diff --git a/scripts/py_matter_idl/matter_idl/generators/kotlin/__init__.py b/scripts/py_matter_idl/matter_idl/generators/kotlin/__init__.py index 680c865e5d73e2..b069319d7f586c 100644 --- a/scripts/py_matter_idl/matter_idl/generators/kotlin/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/kotlin/__init__.py @@ -126,8 +126,6 @@ def FieldToGlobalName(field: Field, context: TypeLookupContext) -> Optional[str] # non-named enums 'enum8': 'uint8_t', 'enum16': 'uint16_t', - 'enum32': 'uint32_t', - 'enum64': 'uint64_t', } diff --git a/scripts/py_matter_idl/matter_idl/generators/type_definitions.py b/scripts/py_matter_idl/matter_idl/generators/type_definitions.py index b5243e4f9c7162..cf1afc22b79cbe 100644 --- a/scripts/py_matter_idl/matter_idl/generators/type_definitions.py +++ b/scripts/py_matter_idl/matter_idl/generators/type_definitions.py @@ -169,8 +169,6 @@ def is_struct(self) -> bool: "bitmap64": BasicInteger(idl_name="bitmap64", byte_count=8, is_signed=False), "bitmap8": BasicInteger(idl_name="bitmap8", byte_count=1, is_signed=False), "enum16": BasicInteger(idl_name="enum16", byte_count=2, is_signed=False), - "enum24": BasicInteger(idl_name="enum24", byte_count=3, is_signed=False), - "enum32": BasicInteger(idl_name="enum32", byte_count=4, is_signed=False), "enum8": BasicInteger(idl_name="enum8", byte_count=1, is_signed=False), "int16s": BasicInteger(idl_name="int16s", byte_count=2, is_signed=True), "int16u": BasicInteger(idl_name="int16u", byte_count=2, is_signed=False), @@ -336,7 +334,7 @@ def is_enum_type(self, name: str): Handles both standard names (like enum8) as well as enumerations defined within the current lookup context. """ - if name.lower() in ["enum8", "enum16", "enum24", "enum32"]: + if name.lower() in ["enum8", "enum16"]: return True return any(map(lambda e: e.name == name, self.all_enums)) @@ -386,7 +384,7 @@ def ParseDataType(data_type: DataType, lookup: TypeLookupContext) -> Union[Basic return BasicString(idl_name=lowercase_name, is_binary=False, max_length=data_type.max_length) elif lowercase_name in ['octet_string', 'long_octet_string']: return BasicString(idl_name=lowercase_name, is_binary=True, max_length=data_type.max_length) - elif lowercase_name in ['enum8', 'enum16', 'enum24', 'enum32']: + elif lowercase_name in ['enum8', 'enum16']: return IdlEnumType(idl_name=lowercase_name, base_type=__CHIP_SIZED_TYPES__[lowercase_name]) elif lowercase_name in ['bitmap8', 'bitmap16', 'bitmap24', 'bitmap32', 'bitmap64']: return IdlBitmapType(idl_name=lowercase_name, base_type=__CHIP_SIZED_TYPES__[lowercase_name]) diff --git a/scripts/py_matter_idl/matter_idl/test_supported_types.py b/scripts/py_matter_idl/matter_idl/test_supported_types.py index 62f7d4c59956c5..70ea5d7ac7e62f 100755 --- a/scripts/py_matter_idl/matter_idl/test_supported_types.py +++ b/scripts/py_matter_idl/matter_idl/test_supported_types.py @@ -73,8 +73,8 @@ def testAllTypesSupported(self): "boolean", "single", "double", # handled as specific bitmaps "bitmap8", "bitmap16", "bitmap24", "bitmap32", "bitmap64", - # handled as specific enums - "enum8", "enum16", "enum24", "enum32", + # handled as specific enums. Note that spec defines enumerations only for 8 and 16 + "enum8", "enum16" # TODO: these may be bugs to fix "unknown" From 84ad8d1f0adbbb8ea7d9b6b37fa98f4b6dc88ef0 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 13 Dec 2023 11:42:50 -0500 Subject: [PATCH 2/4] Fix missing comma --- scripts/py_matter_idl/matter_idl/test_supported_types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/py_matter_idl/matter_idl/test_supported_types.py b/scripts/py_matter_idl/matter_idl/test_supported_types.py index 70ea5d7ac7e62f..be40d73ceefcb5 100755 --- a/scripts/py_matter_idl/matter_idl/test_supported_types.py +++ b/scripts/py_matter_idl/matter_idl/test_supported_types.py @@ -74,7 +74,7 @@ def testAllTypesSupported(self): # handled as specific bitmaps "bitmap8", "bitmap16", "bitmap24", "bitmap32", "bitmap64", # handled as specific enums. Note that spec defines enumerations only for 8 and 16 - "enum8", "enum16" + "enum8", "enum16", # TODO: these may be bugs to fix "unknown" From 32f104220aaec11547e148a1f8d665ebe4143820 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 13 Dec 2023 14:44:40 -0500 Subject: [PATCH 3/4] also remove references of bitmap24. Those were removed from the spec --- .../py_matter_idl/matter_idl/generators/type_definitions.py | 5 ++--- scripts/py_matter_idl/matter_idl/test_supported_types.py | 2 +- src/app/tests/suites/README.md | 1 - src/app/zap-templates/zcl/data-model/chip/chip-types.xml | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/scripts/py_matter_idl/matter_idl/generators/type_definitions.py b/scripts/py_matter_idl/matter_idl/generators/type_definitions.py index cf1afc22b79cbe..5f80f1e5ddf998 100644 --- a/scripts/py_matter_idl/matter_idl/generators/type_definitions.py +++ b/scripts/py_matter_idl/matter_idl/generators/type_definitions.py @@ -164,7 +164,6 @@ def is_struct(self) -> bool: # Data types, held by ZAP in chip-types.xml and generally by the spec. __CHIP_SIZED_TYPES__ = { "bitmap16": BasicInteger(idl_name="bitmap16", byte_count=2, is_signed=False), - "bitmap24": BasicInteger(idl_name="bitmap24", byte_count=3, is_signed=False), "bitmap32": BasicInteger(idl_name="bitmap32", byte_count=4, is_signed=False), "bitmap64": BasicInteger(idl_name="bitmap64", byte_count=8, is_signed=False), "bitmap8": BasicInteger(idl_name="bitmap8", byte_count=1, is_signed=False), @@ -346,7 +345,7 @@ def is_struct_type(self, name: str): def is_untyped_bitmap_type(self, name: str): """Determine if the given type is a untyped bitmap (just an interger size).""" - return name.lower() in {"bitmap8", "bitmap16", "bitmap24", "bitmap32", "bitmap64"} + return name.lower() in {"bitmap8", "bitmap16", "bitmap32", "bitmap64"} def is_bitmap_type(self, name: str): """ @@ -386,7 +385,7 @@ def ParseDataType(data_type: DataType, lookup: TypeLookupContext) -> Union[Basic return BasicString(idl_name=lowercase_name, is_binary=True, max_length=data_type.max_length) elif lowercase_name in ['enum8', 'enum16']: return IdlEnumType(idl_name=lowercase_name, base_type=__CHIP_SIZED_TYPES__[lowercase_name]) - elif lowercase_name in ['bitmap8', 'bitmap16', 'bitmap24', 'bitmap32', 'bitmap64']: + elif lowercase_name in ['bitmap8', 'bitmap16', 'bitmap32', 'bitmap64']: return IdlBitmapType(idl_name=lowercase_name, base_type=__CHIP_SIZED_TYPES__[lowercase_name]) int_type = __CHIP_SIZED_TYPES__.get(lowercase_name, None) diff --git a/scripts/py_matter_idl/matter_idl/test_supported_types.py b/scripts/py_matter_idl/matter_idl/test_supported_types.py index be40d73ceefcb5..f6eec7cf844342 100755 --- a/scripts/py_matter_idl/matter_idl/test_supported_types.py +++ b/scripts/py_matter_idl/matter_idl/test_supported_types.py @@ -72,7 +72,7 @@ def testAllTypesSupported(self): # handled as a non-integer type "boolean", "single", "double", # handled as specific bitmaps - "bitmap8", "bitmap16", "bitmap24", "bitmap32", "bitmap64", + "bitmap8", "bitmap16", "bitmap32", "bitmap64", # handled as specific enums. Note that spec defines enumerations only for 8 and 16 "enum8", "enum16", diff --git a/src/app/tests/suites/README.md b/src/app/tests/suites/README.md index de391a64cebfc0..39236e3b1517d6 100644 --- a/src/app/tests/suites/README.md +++ b/src/app/tests/suites/README.md @@ -314,7 +314,6 @@ src/app/tests/suites/examples/gen_readme_example.sh | boolean | 1 | BOOLEAN | 0x10 | Boolean | uint8_t | | bitmap8 | 1 | BITMAP8 | 0x18 | 8-bit bitmap | uint8_t | | bitmap16 | 2 | BITMAP16 | 0x19 | 16-bit bitmap | uint16_t | -| bitmap24 | 3 | BITMAP24 | 0x1A | 24-bit bitmap | uint32_t | | bitmap32 | 4 | BITMAP32 | 0x1B | 32-bit bitmap | uint32_t | | bitmap64 | 8 | BITMAP64 | 0x1F | 64-bit bitmap | uint8_t \* | | int8u | 1 | INT8U | 0x20 | Unsigned 8-bit integer | uint8_t | diff --git a/src/app/zap-templates/zcl/data-model/chip/chip-types.xml b/src/app/zap-templates/zcl/data-model/chip/chip-types.xml index a9466ff6d79ffc..ffbf74cb78804c 100644 --- a/src/app/zap-templates/zcl/data-model/chip/chip-types.xml +++ b/src/app/zap-templates/zcl/data-model/chip/chip-types.xml @@ -27,7 +27,6 @@ limitations under the License. - From 822d51419dc79e8f0545e04ccbb8e62338682bb9 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 13 Dec 2023 15:00:24 -0500 Subject: [PATCH 4/4] Zap regen --- .../app-common/app-common/zap-generated/attribute-type.h | 1 - 1 file changed, 1 deletion(-) diff --git a/zzz_generated/app-common/app-common/zap-generated/attribute-type.h b/zzz_generated/app-common/app-common/zap-generated/attribute-type.h index e79d1281b33a8c..c14a0614f6a1c4 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attribute-type.h +++ b/zzz_generated/app-common/app-common/zap-generated/attribute-type.h @@ -27,7 +27,6 @@ enum ZCL_BOOLEAN_ATTRIBUTE_TYPE = 0x10, // Boolean ZCL_BITMAP8_ATTRIBUTE_TYPE = 0x18, // 8-bit bitmap ZCL_BITMAP16_ATTRIBUTE_TYPE = 0x19, // 16-bit bitmap - ZCL_BITMAP24_ATTRIBUTE_TYPE = 0x1A, // 24-bit bitmap ZCL_BITMAP32_ATTRIBUTE_TYPE = 0x1B, // 32-bit bitmap ZCL_BITMAP64_ATTRIBUTE_TYPE = 0x1F, // 64-bit bitmap ZCL_INT8U_ATTRIBUTE_TYPE = 0x20, // Unsigned 8-bit integer