Skip to content

Commit d6ee831

Browse files
authored
adding support for apiMaturity handling to Events (#1637)
* adding ApiMaturity to DBs * adding/removing needed commas from SQL commands * adding to XSD * add missing comma in query loader * Adding UnitTest * removing TODOs * removing the template change
1 parent b82c54c commit d6ee831

File tree

10 files changed

+27
-7
lines changed

10 files changed

+27
-7
lines changed

src-electron/db/db-mapping.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ exports.map = {
187187
conformance: x.CONFORMANCE,
188188
isOptional: dbApi.fromDbBool(x.IS_OPTIONAL),
189189
isFabricSensitive: dbApi.fromDbBool(x.IS_FABRIC_SENSITIVE),
190-
priority: x.PRIORITY
190+
priority: x.PRIORITY,
191+
apiMaturity: x.API_MATURITY
191192
}
192193
},
193194

src-electron/db/query-endpoint.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ SELECT
457457
E.SIDE,
458458
E.IS_OPTIONAL,
459459
E.IS_FABRIC_SENSITIVE,
460-
E.PRIORITY
460+
E.PRIORITY,
461+
E.API_MATURITY
461462
FROM
462463
EVENT AS E
463464
LEFT JOIN

src-electron/db/query-event.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ SELECT
116116
CONFORMANCE,
117117
IS_OPTIONAL,
118118
IS_FABRIC_SENSITIVE,
119-
PRIORITY
119+
PRIORITY,
120+
API_MATURITY
120121
FROM
121122
EVENT
122123
WHERE
@@ -152,7 +153,8 @@ SELECT
152153
E.CONFORMANCE,
153154
E.IS_OPTIONAL,
154155
E.IS_FABRIC_SENSITIVE,
155-
E.PRIORITY
156+
E.PRIORITY,
157+
E.API_MATURITY
156158
FROM
157159
EVENT AS E
158160
INNER JOIN

src-electron/db/query-loader.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ INSERT INTO EVENT (
6363
IS_OPTIONAL,
6464
IS_FABRIC_SENSITIVE,
6565
PRIORITY,
66+
API_MATURITY,
6667
INTRODUCED_IN_REF,
6768
REMOVED_IN_REF
6869
) VALUES (
69-
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
70+
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
7071
(SELECT SPEC_ID FROM SPEC WHERE CODE = ? AND PACKAGE_REF = ?),
7172
(SELECT SPEC_ID FROM SPEC WHERE CODE = ? AND PACKAGE_REF = ?)
7273
)
@@ -285,6 +286,7 @@ function eventMap(clusterId, packageId, events) {
285286
dbApi.toDbBool(event.isOptional),
286287
dbApi.toDbBool(event.isFabricSensitive),
287288
event.priority,
289+
event.apiMaturity,
288290
event.introducedIn,
289291
packageId,
290292
event.removedIn,

src-electron/db/zap-schema.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ CREATE TABLE IF NOT EXISTS "EVENT" (
236236
"IS_OPTIONAL" integer,
237237
"IS_FABRIC_SENSITIVE" integer,
238238
"PRIORITY" text,
239+
"API_MATURITY" text,
239240
"INTRODUCED_IN_REF" integer,
240241
"REMOVED_IN_REF" integer,
241242
"MANUFACTURER_CODE_DERIVED" AS (COALESCE(MANUFACTURER_CODE, 0)),

src-electron/zcl/zcl-loader-silabs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ function prepareCluster(cluster, context, isExtension = false) {
569569
side: event.$.side,
570570
conformance: conformParser.parseConformanceFromXML(event),
571571
priority: event.$.priority,
572+
apiMaturity: event.$.apiMaturity,
572573
description: event.description ? event.description[0].trim() : '',
573574
isOptional: conformParser.getOptionalAttributeFromXML(event, 'event'),
574575
isFabricSensitive: event.$.isFabricSensitive == 'true'

test/gen-matter-api-maturity.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ test(
106106
// Maturity for structures should be correct
107107
expect(ept).toContain('struct StableStruct {')
108108
expect(ept).toContain('struct ProvisionalStruct (provisional) {')
109+
110+
// Maturity for Event should be correct.
111+
expect(ept).toContain('info event StableEvent = 1{')
112+
expect(ept).toContain('info event ProvisionalEvent = 2 (provisional){')
109113
},
110114
testUtil.timeout.long()
111115
)

test/gen-template/matter-api-maturity/codegen_test.zapt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cluster {{asUpperCamelCase name}} = {{code}}
1616

1717
{{/zcl_bitmaps}}
1818
{{#zcl_events}}
19-
{{priority}} event {{asUpperCamelCase name preserveAcronyms=true}} = {{code}} {
19+
{{priority}} event {{asUpperCamelCase name preserveAcronyms=true}} = {{code}} {{~#if apiMaturity}} ({{apiMaturity}}) {{~/if~}} {
2020
{{#zcl_event_fields}}
2121
{{#if isOptional~}}optional {{/if~}}
2222
{{~#if isNullable~}}nullable {{/if~}}
@@ -45,7 +45,7 @@ cluster {{asUpperCamelCase name}} = {{code}}
4545
{{! ensure indent ~}}
4646
{{#if isOptional~}} optional {{/if~}}
4747
{{~#unless isWritableAttribute~}} readonly {{/unless~}}
48-
{{~#if isNullable~}} nullable {{/if~}}
48+
{{~#if isNullable~}} nullable {{/if~}}
4949
{{type}} attribute {{asLowerCamelCase name~}} {{~#if isArray~}} [] {{~/if}} = {{code~}}
5050
{{~#if apiMaturity}} ({{apiMaturity}}) {{~/if~}};
5151
{{/unless}}

test/resource/meta/api_maturity.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,12 @@ limitations under the License.
6161
<field id="1" name="arg1" type="INT8U" isNullable="true"/>
6262
<field id="2" name="arg2" type="INT32U" array="true"/>
6363
</event>
64+
65+
<event code="0x0002" name="ProvisionalEvent" priority="info" side="server" apiMaturity="provisional">
66+
<description>A Provisional Test event</description>
67+
<field id="1" name="arg1" type="INT8U" isNullable="true"/>
68+
<field id="2" name="arg2" type="INT32U" array="true"/>
69+
</event>
70+
6471
</cluster>
6572
</configurator>

zcl-builtin/shared/schema/zcl.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ This schema describes the format of the XML files, that describe the ZCL specifi
424424
<xs:attribute name="name" type="xs:string"/>
425425
<xs:attribute name="side" use="required" type="zclSide"/>
426426
<xs:attribute name="priority" type="xs:string"/>
427+
<xs:attribute name="apiMaturity" type="zclApiMaturity"/>
427428
<xs:attribute name="isFabricSensitive" type="xs:boolean"/>
428429
</xs:complexType>
429430
</xs:element>

0 commit comments

Comments
 (0)