Skip to content

Commit

Permalink
Implement codegen for global things
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Jul 28, 2024
1 parent f51ac2f commit bbaf1af
Show file tree
Hide file tree
Showing 55 changed files with 4,610 additions and 271 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6826,6 +6826,7 @@ internal cluster UnitTesting = 4294048773 {
SimpleBitmap f = 5;
single g = 6;
double h = 7;
optional TestGlobalEnum i = 8;
}

fabric_scoped struct TestFabricScoped {
Expand Down Expand Up @@ -6858,6 +6859,7 @@ internal cluster UnitTesting = 4294048773 {
int8u a = 0;
boolean b = 1;
SimpleStruct c = 2;
optional TestGlobalStruct d = 3;
}

struct NestedStructList {
Expand Down Expand Up @@ -6943,6 +6945,8 @@ internal cluster UnitTesting = 4294048773 {
timedwrite attribute boolean timedWriteBoolean = 48;
attribute boolean generalErrorBoolean = 49;
attribute boolean clusterErrorBoolean = 50;
attribute TestGlobalEnum globalEnum = 51;
attribute TestGlobalStruct globalStruct = 52;
attribute optional boolean unsupported = 255;
attribute nullable boolean nullableBoolean = 16384;
attribute nullable Bitmap8MaskMap nullableBitmap8 = 16385;
Expand Down Expand Up @@ -6978,6 +6982,8 @@ internal cluster UnitTesting = 4294048773 {
attribute nullable int16u nullableRangeRestrictedInt16u = 16424;
attribute nullable int16s nullableRangeRestrictedInt16s = 16425;
attribute optional int8u writeOnlyInt8u = 16426;
attribute nullable TestGlobalEnum nullableGlobalEnum = 16435;
attribute nullable TestGlobalStruct nullableGlobalStruct = 16436;
attribute int8u meiInt8u = 4294070017;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
Expand Down Expand Up @@ -7129,6 +7135,11 @@ internal cluster UnitTesting = 4294048773 {
SimpleEnum arg2 = 1;
}

response struct GlobalEchoResponse = 14 {
TestGlobalStruct field1 = 0;
TestGlobalEnum field2 = 1;
}

request struct TestNullableOptionalRequestRequest {
optional nullable int8u arg1 = 0;
}
Expand Down Expand Up @@ -7182,6 +7193,11 @@ internal cluster UnitTesting = 4294048773 {
octet_string payload = 0;
}

request struct GlobalEchoRequestRequest {
TestGlobalStruct field1 = 0;
TestGlobalEnum field2 = 1;
}

request struct TestDifferentVendorMeiRequestRequest {
int8u arg1 = 0;
}
Expand Down Expand Up @@ -7265,6 +7281,9 @@ internal cluster UnitTesting = 4294048773 {
the string back. If the string is large then it would require a session that
supports large payloads. */
command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24;
/** Command that takes arguments that are global structs/enums and the
response just echoes them back. */
command GlobalEchoRequest(GlobalEchoRequestRequest): GlobalEchoResponse = 25;
/** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */
command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5475,6 +5475,7 @@ internal cluster UnitTesting = 4294048773 {
SimpleBitmap f = 5;
single g = 6;
double h = 7;
optional TestGlobalEnum i = 8;
}

fabric_scoped struct TestFabricScoped {
Expand Down Expand Up @@ -5507,6 +5508,7 @@ internal cluster UnitTesting = 4294048773 {
int8u a = 0;
boolean b = 1;
SimpleStruct c = 2;
optional TestGlobalStruct d = 3;
}

struct NestedStructList {
Expand Down Expand Up @@ -5592,6 +5594,8 @@ internal cluster UnitTesting = 4294048773 {
timedwrite attribute boolean timedWriteBoolean = 48;
attribute boolean generalErrorBoolean = 49;
attribute boolean clusterErrorBoolean = 50;
attribute TestGlobalEnum globalEnum = 51;
attribute TestGlobalStruct globalStruct = 52;
attribute optional boolean unsupported = 255;
attribute nullable boolean nullableBoolean = 16384;
attribute nullable Bitmap8MaskMap nullableBitmap8 = 16385;
Expand Down Expand Up @@ -5627,6 +5631,8 @@ internal cluster UnitTesting = 4294048773 {
attribute nullable int16u nullableRangeRestrictedInt16u = 16424;
attribute nullable int16s nullableRangeRestrictedInt16s = 16425;
attribute optional int8u writeOnlyInt8u = 16426;
attribute nullable TestGlobalEnum nullableGlobalEnum = 16435;
attribute nullable TestGlobalStruct nullableGlobalStruct = 16436;
attribute int8u meiInt8u = 4294070017;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
Expand Down Expand Up @@ -5778,6 +5784,11 @@ internal cluster UnitTesting = 4294048773 {
SimpleEnum arg2 = 1;
}

response struct GlobalEchoResponse = 14 {
TestGlobalStruct field1 = 0;
TestGlobalEnum field2 = 1;
}

request struct TestNullableOptionalRequestRequest {
optional nullable int8u arg1 = 0;
}
Expand Down Expand Up @@ -5831,6 +5842,11 @@ internal cluster UnitTesting = 4294048773 {
octet_string payload = 0;
}

request struct GlobalEchoRequestRequest {
TestGlobalStruct field1 = 0;
TestGlobalEnum field2 = 1;
}

request struct TestDifferentVendorMeiRequestRequest {
int8u arg1 = 0;
}
Expand Down Expand Up @@ -5914,6 +5930,9 @@ internal cluster UnitTesting = 4294048773 {
the string back. If the string is large then it would require a session that
supports large payloads. */
command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24;
/** Command that takes arguments that are global structs/enums and the
response just echoes them back. */
command GlobalEchoRequest(GlobalEchoRequestRequest): GlobalEchoResponse = 25;
/** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */
command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962;
}
Expand Down
19 changes: 19 additions & 0 deletions examples/chef/devices/rootnode_contactsensor_27f76aeaf5.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,7 @@ internal cluster UnitTesting = 4294048773 {
SimpleBitmap f = 5;
single g = 6;
double h = 7;
optional TestGlobalEnum i = 8;
}

fabric_scoped struct TestFabricScoped {
Expand Down Expand Up @@ -1526,6 +1527,7 @@ internal cluster UnitTesting = 4294048773 {
int8u a = 0;
boolean b = 1;
SimpleStruct c = 2;
optional TestGlobalStruct d = 3;
}

struct NestedStructList {
Expand Down Expand Up @@ -1611,6 +1613,8 @@ internal cluster UnitTesting = 4294048773 {
timedwrite attribute boolean timedWriteBoolean = 48;
attribute boolean generalErrorBoolean = 49;
attribute boolean clusterErrorBoolean = 50;
attribute TestGlobalEnum globalEnum = 51;
attribute TestGlobalStruct globalStruct = 52;
attribute optional boolean unsupported = 255;
attribute nullable boolean nullableBoolean = 16384;
attribute nullable Bitmap8MaskMap nullableBitmap8 = 16385;
Expand Down Expand Up @@ -1646,6 +1650,8 @@ internal cluster UnitTesting = 4294048773 {
attribute nullable int16u nullableRangeRestrictedInt16u = 16424;
attribute nullable int16s nullableRangeRestrictedInt16s = 16425;
attribute optional int8u writeOnlyInt8u = 16426;
attribute nullable TestGlobalEnum nullableGlobalEnum = 16435;
attribute nullable TestGlobalStruct nullableGlobalStruct = 16436;
attribute int8u meiInt8u = 4294070017;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
Expand Down Expand Up @@ -1797,6 +1803,11 @@ internal cluster UnitTesting = 4294048773 {
SimpleEnum arg2 = 1;
}

response struct GlobalEchoResponse = 14 {
TestGlobalStruct field1 = 0;
TestGlobalEnum field2 = 1;
}

request struct TestNullableOptionalRequestRequest {
optional nullable int8u arg1 = 0;
}
Expand Down Expand Up @@ -1850,6 +1861,11 @@ internal cluster UnitTesting = 4294048773 {
octet_string payload = 0;
}

request struct GlobalEchoRequestRequest {
TestGlobalStruct field1 = 0;
TestGlobalEnum field2 = 1;
}

request struct TestDifferentVendorMeiRequestRequest {
int8u arg1 = 0;
}
Expand Down Expand Up @@ -1933,6 +1949,9 @@ internal cluster UnitTesting = 4294048773 {
the string back. If the string is large then it would require a session that
supports large payloads. */
command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24;
/** Command that takes arguments that are global structs/enums and the
response just echoes them back. */
command GlobalEchoRequest(GlobalEchoRequestRequest): GlobalEchoResponse = 25;
/** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */
command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962;
}
Expand Down
29 changes: 29 additions & 0 deletions src/app/zap-templates/zcl/data-model/chip/test-cluster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ limitations under the License.
<item name="f" type="SimpleBitmap" optional="false"/>
<item name="g" type="single" optional="false"/>
<item name="h" type="double" optional="false"/>
<item name="i" type="TestGlobalEnum" optional="true"/>
</struct>

<struct name="NestedStruct">
<cluster code="0xFFF1FC05"/>
<item name="a" type="int8u" optional="false"/>
<item name="b" type="boolean" optional="false"/>
<item name="c" type="SimpleStruct" optional="false"/>
<item name="d" type="TestGlobalStruct" optional="true"/>
</struct>

<struct name="NestedStructList">
Expand Down Expand Up @@ -198,6 +200,9 @@ limitations under the License.
<attribute side="server" code="0x0032" define="CLUSTER_ERROR_BOOLEAN"
type="boolean" writable="true" optional="false">cluster_error_boolean</attribute>

<attribute side="server" code="0x0033" define="GLOBAL_ENUM" type="TestGlobalEnum" writable="true">global_enum</attribute>
<attribute side="server" code="0x0034" define="GLOBAL_STRUCT" type="TestGlobalStruct" writable="true">global_struct</attribute>

<attribute side="server" code="0x4000" define="NULLABLE_BOOLEAN" type="boolean" writable="true" default="false" isNullable="true" optional="false">nullable_boolean</attribute>
<attribute side="server" code="0x4001" define="NULLABLE_BITMAP8" type="Bitmap8MaskMap" writable="true" default="0" isNullable="true" optional="false">nullable_bitmap8</attribute>
<attribute side="server" code="0x4002" define="NULLABLE_BITMAP16" type="Bitmap16MaskMap" writable="true" default="0" isNullable="true" optional="false">nullable_bitmap16</attribute>
Expand Down Expand Up @@ -232,8 +237,14 @@ limitations under the License.
<attribute side="server" code="0x4028" define="NULLABLE_RANGE_RESTRICTED_INT16U" type="int16u" min="100" max="1000" writable="true" isNullable="true" optional="false" default="200">nullable_range_restricted_int16u</attribute>
<attribute side="server" code="0x4029" define="NULLABLE_RANGE_RESTRICTED_INT16S" type="int16s" min="-150" max="200" writable="true" isNullable="true" optional="false" default="-5">nullable_range_restricted_int16s</attribute>

<!-- NOTE: write_only_int8u should not have been added in the 0x4... range
where the nullable versions of attributes go, but now we have to be a
bit careful about our attribute IDs as a result. -->
<attribute side="server" code="0x402A" define="WRITE_ONLY_INT8U" type="int8u" writable="true" default="0" optional="true">write_only_int8u</attribute>

<attribute side="server" code="0x4033" define="NULLABLE_GLOBAL_ENUM" type="TestGlobalEnum" isNullable="true" writable="true">nullable_global_enum</attribute>
<attribute side="server" code="0x4034" define="NULLABLE_GLOBAL_STRUCT" type="TestGlobalStruct" isNullable="true" writable="true">nullable_global_struct</attribute>

<!-- Attribute MEI sample having a different vendor ID than the cluster. -->
<attribute side="server" code="0xFFF24F01" define="MEI_INT8U" type="int8u" writable="true" default="0" optional="false">mei_int8u</attribute>

Expand Down Expand Up @@ -474,6 +485,16 @@ limitations under the License.
<arg name="payload" type="octet_string"/>
</command>

<command source="client" code="0x19" name="GlobalEchoRequest"
response="GlobalEchoResponse" optional="true">
<description>
Command that takes arguments that are global structs/enums and the
response just echoes them back.
</description>
<arg name="field1" type="TestGlobalStruct"/>
<arg name="field2" type="TestGlobalEnum"/>
</command>

<command source="client" code="0xFFF200AA" name="TestDifferentVendorMeiRequest"
optional="true" response="TestDifferentVendorMeiResponse">
<description>
Expand Down Expand Up @@ -622,6 +643,14 @@ limitations under the License.
<arg name="payload" type="octet_string"/>
</command>

<command source="server" code="0x0E" name="GlobalEchoResponse" optional="true" disableDefaultResponse="true">
<description>
Response to GlobalEchoRequest.
</description>
<arg name="field1" type="TestGlobalStruct"/>
<arg name="field2" type="TestGlobalEnum"/>
</command>

<command source="server" code="0xFFF200BB" name="TestDifferentVendorMeiResponse" optional="true" disableDefaultResponse="true">
<description>
Response to TestDifferentVendorMeiRequest, which is a command having a different MEI vendor ID than the cluster.
Expand Down
4 changes: 3 additions & 1 deletion src/app/zap-templates/zcl/zcl-with-test-extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@
"struct_attr",
"nullable_struct",
"general_error_boolean",
"cluster_error_boolean"
"cluster_error_boolean",
"global_struct",
"nullable_global_struct"
],
"Thread Network Diagnostics": [
"Channel",
Expand Down
4 changes: 3 additions & 1 deletion src/app/zap-templates/zcl/zcl.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,9 @@
"struct_attr",
"nullable_struct",
"general_error_boolean",
"cluster_error_boolean"
"cluster_error_boolean",
"global_struct",
"nullable_global_struct"
],
"Thread Network Diagnostics": [
"Channel",
Expand Down
19 changes: 19 additions & 0 deletions src/controller/data_model/controller-clusters.matter
Original file line number Diff line number Diff line change
Expand Up @@ -9676,6 +9676,7 @@ internal cluster UnitTesting = 4294048773 {
SimpleBitmap f = 5;
single g = 6;
double h = 7;
optional TestGlobalEnum i = 8;
}

fabric_scoped struct TestFabricScoped {
Expand Down Expand Up @@ -9708,6 +9709,7 @@ internal cluster UnitTesting = 4294048773 {
int8u a = 0;
boolean b = 1;
SimpleStruct c = 2;
optional TestGlobalStruct d = 3;
}

struct NestedStructList {
Expand Down Expand Up @@ -9793,6 +9795,8 @@ internal cluster UnitTesting = 4294048773 {
timedwrite attribute boolean timedWriteBoolean = 48;
attribute boolean generalErrorBoolean = 49;
attribute boolean clusterErrorBoolean = 50;
attribute TestGlobalEnum globalEnum = 51;
attribute TestGlobalStruct globalStruct = 52;
attribute optional boolean unsupported = 255;
attribute nullable boolean nullableBoolean = 16384;
attribute nullable Bitmap8MaskMap nullableBitmap8 = 16385;
Expand Down Expand Up @@ -9828,6 +9832,8 @@ internal cluster UnitTesting = 4294048773 {
attribute nullable int16u nullableRangeRestrictedInt16u = 16424;
attribute nullable int16s nullableRangeRestrictedInt16s = 16425;
attribute optional int8u writeOnlyInt8u = 16426;
attribute nullable TestGlobalEnum nullableGlobalEnum = 16435;
attribute nullable TestGlobalStruct nullableGlobalStruct = 16436;
attribute int8u meiInt8u = 4294070017;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
Expand Down Expand Up @@ -9979,6 +9985,11 @@ internal cluster UnitTesting = 4294048773 {
SimpleEnum arg2 = 1;
}

response struct GlobalEchoResponse = 14 {
TestGlobalStruct field1 = 0;
TestGlobalEnum field2 = 1;
}

request struct TestNullableOptionalRequestRequest {
optional nullable int8u arg1 = 0;
}
Expand Down Expand Up @@ -10032,6 +10043,11 @@ internal cluster UnitTesting = 4294048773 {
octet_string payload = 0;
}

request struct GlobalEchoRequestRequest {
TestGlobalStruct field1 = 0;
TestGlobalEnum field2 = 1;
}

request struct TestDifferentVendorMeiRequestRequest {
int8u arg1 = 0;
}
Expand Down Expand Up @@ -10115,6 +10131,9 @@ internal cluster UnitTesting = 4294048773 {
the string back. If the string is large then it would require a session that
supports large payloads. */
command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24;
/** Command that takes arguments that are global structs/enums and the
response just echoes them back. */
command GlobalEchoRequest(GlobalEchoRequestRequest): GlobalEchoResponse = 25;
/** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */
command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962;
}
Expand Down
Loading

0 comments on commit bbaf1af

Please sign in to comment.