diff --git a/scripts/py_matter_idl/matter_idl/test_zapxml.py b/scripts/py_matter_idl/matter_idl/test_zapxml.py
index 6e6cd3d8761ca9..5ea15e27e8f9c2 100755
--- a/scripts/py_matter_idl/matter_idl/test_zapxml.py
+++ b/scripts/py_matter_idl/matter_idl/test_zapxml.py
@@ -234,6 +234,36 @@ def testFabricScopedAndSensitive(self):
qualities=StructQuality.FABRIC_SCOPED)],
)]))
+ def testGlobalEnum(self):
+ idl = XmlToIdl('''
+
+
+
+
+
+
+
+
+
+
+ ''')
+ e1 = Enum(
+ name='One',
+ base_type="ENUM8",
+ entries=[
+ ConstantEntry(name="Three", code=3),
+ ]
+ )
+ e2 = Enum(
+ name='Two',
+ base_type="ENUM8",
+ entries=[
+ ConstantEntry(name="Big", code=100),
+ ConstantEntry(name="Bigger", code=2000),
+ ]
+ )
+ self.assertEqual(idl, Idl(global_enums=[e1, e2]))
+
def testEnum(self):
idl = XmlToIdl('''
@@ -308,6 +338,28 @@ def testFeatures(self):
Cluster(name='TestFeatures', code=20, bitmaps=[bitmap])
])),
+ def testGlobalStruct(self):
+ idl = XmlToIdl('''
+
+
+
+
+
+
+
+ ''')
+ struct = Struct(
+ name='SomeStruct',
+ qualities=StructQuality.FABRIC_SCOPED,
+ fields=[
+ Field(data_type=DataType(name='int16u'),
+ code=0, name='FirstMember'),
+ Field(data_type=DataType(name='int32u'),
+ code=1, name='SecondMember')
+ ]
+ )
+ self.assertEqual(idl, Idl(global_structs=[struct]))
+
def testStruct(self):
idl = XmlToIdl('''
diff --git a/scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py
index 866ce71f914214..cc5ccd9483091d 100644
--- a/scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py
+++ b/scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py
@@ -225,7 +225,7 @@ def FinalizeProcessing(self, idl: Idl):
# - inside a cluster if a code exists
# - inside top level if no codes were associated
if not self._cluster_codes:
- LOGGER.error('Struct %s has no cluster codes' % self._struct.name)
+ idl.global_structs.append(self._struct)
return
for code in self._cluster_codes:
@@ -270,9 +270,9 @@ def GetNextProcessor(self, name, attrs):
def FinalizeProcessing(self, idl: Idl):
if not self._cluster_codes:
- LOGGER.error("Found enum without a cluster code: %s" %
- (self._enum.name))
+ idl.global_enums.append(self._enum)
return
+
found = set()
for c in idl.clusters:
if c.code in self._cluster_codes:
@@ -313,14 +313,11 @@ def GetNextProcessor(self, name, attrs):
return BaseHandler(self.context)
def FinalizeProcessing(self, idl: Idl):
- # We have two choices of adding an enum:
+ # We have two choices of adding a bitmap:
# - inside a cluster if a code exists
# - inside top level if a code does not exist
if not self._cluster_codes:
- # Log only instead of critical, as not our XML is well formed.
- # For example at the time of writing this, SwitchFeature in switch-cluster.xml
- # did not have a code associated with it.
- LOGGER.error("Bitmap %r has no cluster codes" % self._bitmap)
+ idl.global_bitmaps.append(self._bitmap)
return
for code in self._cluster_codes: