Skip to content

Commit

Permalink
Handle otherwiseConform tags when parsing CSA datamodel XML (#29953)
Browse files Browse the repository at this point in the history
* Handle otherwiseConform for attributes ... found it in pump cc

* Add unit test

---------

Co-authored-by: Andrei Litvin <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Dec 5, 2023
1 parent ce4788e commit 7464484
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def GetNextProcessor(self, name: str, attrs):
return BaseHandler(self.context)


class MandatoryConfirmFieldHandler(BaseHandler):
class MandatoryConformFieldHandler(BaseHandler):
def __init__(self, context: Context, field: Field):
super().__init__(context, handled=HandledDepth.SINGLE_TAG)
self._field = field
Expand All @@ -125,7 +125,7 @@ def GetNextProcessor(self, name: str, attrs):
ApplyConstraint(attrs, self._field)
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
elif name == "mandatoryConform":
return MandatoryConfirmFieldHandler(self.context, self._field)
return MandatoryConformFieldHandler(self.context, self._field)
elif name == "optionalConform":
self._field.qualities |= FieldQuality.OPTIONAL
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
Expand Down Expand Up @@ -325,8 +325,11 @@ def GetNextProcessor(self, name: str, attrs):
elif name == "optionalConform":
self._attribute.definition.qualities |= FieldQuality.OPTIONAL
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
elif name == "otherwiseConform":
self._attribute.definition.qualities |= FieldQuality.OPTIONAL
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
elif name == "mandatoryConform":
return MandatoryConfirmFieldHandler(self.context, self._attribute.definition)
return MandatoryConformFieldHandler(self.context, self._attribute.definition)
elif name == "deprecateConform":
self._deprecated = True
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
Expand Down
12 changes: 12 additions & 0 deletions scripts/py_matter_idl/matter_idl/test_data_model_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,17 @@ def testAttributes(self):
<access read="true" readPrivilege="view"/>
<mandatoryConform/>
</attribute>
<attribute id="0x0001" name="TestConform" type="enum8">
<access read="true" readPrivilege="view"/>
<otherwiseConform>
<mandatoryConform>
<feature name="PRSCONST"/>
</mandatoryConform>
<optionalConform>
<feature name="AUTO"/>
</optionalConform>
</otherwiseConform>
</attribute>
</attributes>
</cluster>
''')
Expand All @@ -215,6 +226,7 @@ def testAttributes(self):
}
readonly attribute OutputInfoStruct outputList[] = 0;
readonly attribute optional enum8 testConform = 1;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute event_id eventList[] = 65530;
Expand Down

0 comments on commit 7464484

Please sign in to comment.