Skip to content

Commit e316329

Browse files
authored
Drop enum support for larger than 16 bit. (#30984)
* 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. * Fix missing comma * also remove references of bitmap24. Those were removed from the spec * Zap regen
1 parent 7378446 commit e316329

File tree

9 files changed

+9
-21
lines changed

9 files changed

+9
-21
lines changed

scripts/py_matter_idl/examples/matter_idl_plugin/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def toEnumEntryName(enumEntry, enumName):
5656
def toProtobufType(zapType: str) -> str:
5757
""" Convert zap type to protobuf type """
5858
u32Types = [
59-
"uint32", "enum8", "enum16", "enum32", "bitmap8",
59+
"uint32", "enum8", "enum16", "bitmap8",
6060
"bitmap16", "bitmap32", "cluster_id", "attrib_id",
6161
"event_id", "command_id", "endpoint_no", "group_id",
6262
"devtype_id", "fabric_idx", "vendor_id", "status_code",

scripts/py_matter_idl/matter_idl/data_model_xml/handlers/handlers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def EndProcessing(self):
245245
if not self._enum.entries:
246246
return
247247

248-
# try to find the best enum size that fits out of enum8, enum32 and enum32
248+
# try to find the best enum size that fits out of enum8 and enum16
249249
# TODO: this is a pure heuristic. XML containing this would be better.
250250
# https://github.com/csa-data-model/projects/issues/345
251251
acceptable = {8, 16}

scripts/py_matter_idl/matter_idl/generators/java/__init__.py

-4
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ def FieldToGlobalName(field: Field, context: TypeLookupContext) -> Optional[str]
126126
# non-named enums
127127
'enum8': 'uint8_t',
128128
'enum16': 'uint16_t',
129-
'enum32': 'uint32_t',
130-
'enum64': 'uint64_t',
131129
}
132130

133131

@@ -320,8 +318,6 @@ def _IsUsingGlobalCallback(field: Field, context: TypeLookupContext):
320318
"int64u",
321319
"enum8",
322320
"enum16",
323-
"enum32",
324-
"enum64",
325321
"bitmap8",
326322
"bitmap16",
327323
"bitmap32",

scripts/py_matter_idl/matter_idl/generators/kotlin/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ def FieldToGlobalName(field: Field, context: TypeLookupContext) -> Optional[str]
126126
# non-named enums
127127
'enum8': 'uint8_t',
128128
'enum16': 'uint16_t',
129-
'enum32': 'uint32_t',
130-
'enum64': 'uint64_t',
131129
}
132130

133131

scripts/py_matter_idl/matter_idl/generators/type_definitions.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,10 @@ def is_struct(self) -> bool:
164164
# Data types, held by ZAP in chip-types.xml and generally by the spec.
165165
__CHIP_SIZED_TYPES__ = {
166166
"bitmap16": BasicInteger(idl_name="bitmap16", byte_count=2, is_signed=False),
167-
"bitmap24": BasicInteger(idl_name="bitmap24", byte_count=3, is_signed=False),
168167
"bitmap32": BasicInteger(idl_name="bitmap32", byte_count=4, is_signed=False),
169168
"bitmap64": BasicInteger(idl_name="bitmap64", byte_count=8, is_signed=False),
170169
"bitmap8": BasicInteger(idl_name="bitmap8", byte_count=1, is_signed=False),
171170
"enum16": BasicInteger(idl_name="enum16", byte_count=2, is_signed=False),
172-
"enum24": BasicInteger(idl_name="enum24", byte_count=3, is_signed=False),
173-
"enum32": BasicInteger(idl_name="enum32", byte_count=4, is_signed=False),
174171
"enum8": BasicInteger(idl_name="enum8", byte_count=1, is_signed=False),
175172
"int16s": BasicInteger(idl_name="int16s", byte_count=2, is_signed=True),
176173
"int16u": BasicInteger(idl_name="int16u", byte_count=2, is_signed=False),
@@ -336,7 +333,7 @@ def is_enum_type(self, name: str):
336333
Handles both standard names (like enum8) as well as enumerations defined
337334
within the current lookup context.
338335
"""
339-
if name.lower() in ["enum8", "enum16", "enum24", "enum32"]:
336+
if name.lower() in ["enum8", "enum16"]:
340337
return True
341338
return any(map(lambda e: e.name == name, self.all_enums))
342339

@@ -348,7 +345,7 @@ def is_struct_type(self, name: str):
348345

349346
def is_untyped_bitmap_type(self, name: str):
350347
"""Determine if the given type is a untyped bitmap (just an interger size)."""
351-
return name.lower() in {"bitmap8", "bitmap16", "bitmap24", "bitmap32", "bitmap64"}
348+
return name.lower() in {"bitmap8", "bitmap16", "bitmap32", "bitmap64"}
352349

353350
def is_bitmap_type(self, name: str):
354351
"""
@@ -386,9 +383,9 @@ def ParseDataType(data_type: DataType, lookup: TypeLookupContext) -> Union[Basic
386383
return BasicString(idl_name=lowercase_name, is_binary=False, max_length=data_type.max_length)
387384
elif lowercase_name in ['octet_string', 'long_octet_string']:
388385
return BasicString(idl_name=lowercase_name, is_binary=True, max_length=data_type.max_length)
389-
elif lowercase_name in ['enum8', 'enum16', 'enum24', 'enum32']:
386+
elif lowercase_name in ['enum8', 'enum16']:
390387
return IdlEnumType(idl_name=lowercase_name, base_type=__CHIP_SIZED_TYPES__[lowercase_name])
391-
elif lowercase_name in ['bitmap8', 'bitmap16', 'bitmap24', 'bitmap32', 'bitmap64']:
388+
elif lowercase_name in ['bitmap8', 'bitmap16', 'bitmap32', 'bitmap64']:
392389
return IdlBitmapType(idl_name=lowercase_name, base_type=__CHIP_SIZED_TYPES__[lowercase_name])
393390

394391
int_type = __CHIP_SIZED_TYPES__.get(lowercase_name, None)

scripts/py_matter_idl/matter_idl/test_supported_types.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ def testAllTypesSupported(self):
7272
# handled as a non-integer type
7373
"boolean", "single", "double",
7474
# handled as specific bitmaps
75-
"bitmap8", "bitmap16", "bitmap24", "bitmap32", "bitmap64",
76-
# handled as specific enums
77-
"enum8", "enum16", "enum24", "enum32",
75+
"bitmap8", "bitmap16", "bitmap32", "bitmap64",
76+
# handled as specific enums. Note that spec defines enumerations only for 8 and 16
77+
"enum8", "enum16",
7878

7979
# TODO: these may be bugs to fix
8080
"unknown"

src/app/tests/suites/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ src/app/tests/suites/examples/gen_readme_example.sh
314314
| boolean | 1 | BOOLEAN | 0x10 | Boolean | uint8_t |
315315
| bitmap8 | 1 | BITMAP8 | 0x18 | 8-bit bitmap | uint8_t |
316316
| bitmap16 | 2 | BITMAP16 | 0x19 | 16-bit bitmap | uint16_t |
317-
| bitmap24 | 3 | BITMAP24 | 0x1A | 24-bit bitmap | uint32_t |
318317
| bitmap32 | 4 | BITMAP32 | 0x1B | 32-bit bitmap | uint32_t |
319318
| bitmap64 | 8 | BITMAP64 | 0x1F | 64-bit bitmap | uint8_t \* |
320319
| int8u | 1 | INT8U | 0x20 | Unsigned 8-bit integer | uint8_t |

src/app/zap-templates/zcl/data-model/chip/chip-types.xml

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ limitations under the License.
2727
<type id="0x10" description="Boolean" name="boolean" size="1" discrete="true" />
2828
<type id="0x18" description="8-bit bitmap" name="bitmap8" size="1" discrete="true" />
2929
<type id="0x19" description="16-bit bitmap" name="bitmap16" size="2" discrete="true" />
30-
<type id="0x1A" description="24-bit bitmap" name="bitmap24" size="3" discrete="true" />
3130
<type id="0x1B" description="32-bit bitmap" name="bitmap32" size="4" discrete="true" />
3231
<type id="0x1F" description="64-bit bitmap" name="bitmap64" size="8" discrete="true" />
3332
<type id="0x20" description="Unsigned 8-bit integer" name="int8u" size="1" analog="true" />

zzz_generated/app-common/app-common/zap-generated/attribute-type.h

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)