From 36889ff53165b58f75f016c9f082f75a601ada90 Mon Sep 17 00:00:00 2001 From: brdandu Date: Mon, 28 Oct 2024 15:20:42 -0400 Subject: [PATCH] - Adding base types for derived types in the atomic xml file - This is done by adding baseType column to the atomic table and then mapping it appropriately to baseType for the zcl_atomics helper such that derived types can refer to base types - Github: ZAP#1438 --- src-electron/db/db-mapping.js | 2 +- src-electron/db/query-atomic.js | 2 +- src-electron/db/query-loader.js | 4 +- src-electron/db/zap-schema.sql | 2 +- src-electron/zcl/zcl-loader-silabs.js | 2 +- test/gen-matter-1.test.js | 14 +++-- test/gen-template/matter/simple-test.zapt | 4 +- .../matter/data-model/chip/chip-types.xml | 58 +++++++++---------- 8 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src-electron/db/db-mapping.js b/src-electron/db/db-mapping.js index 71449cf2c5..0fe7464de0 100644 --- a/src-electron/db/db-mapping.js +++ b/src-electron/db/db-mapping.js @@ -391,7 +391,7 @@ exports.map = { isSigned: dbApi.fromDbBool(x.IS_SIGNED), isComposite: dbApi.fromDbBool(x.IS_COMPOSITE), isFloat: dbApi.fromDbBool(x.IS_FLOAT), - isBaseline: dbApi.fromDbBool(x.IS_BASELINE) + baseType: x.BASE_TYPE } }, diff --git a/src-electron/db/query-atomic.js b/src-electron/db/query-atomic.js index 078bfb6819..207dbfed40 100644 --- a/src-electron/db/query-atomic.js +++ b/src-electron/db/query-atomic.js @@ -39,7 +39,7 @@ SELECT IS_SIGNED, IS_COMPOSITE, IS_FLOAT, - IS_BASELINE + BASE_TYPE FROM ATOMIC ` diff --git a/src-electron/db/query-loader.js b/src-electron/db/query-loader.js index fc56689f8f..d3c36aff42 100644 --- a/src-electron/db/query-loader.js +++ b/src-electron/db/query-loader.js @@ -1005,7 +1005,7 @@ INSERT OR IGNORE INTO GLOBAL_ATTRIBUTE_BIT ( async function insertAtomics(db, packageId, data) { return dbApi.dbMultiInsert( db, - 'INSERT INTO ATOMIC (PACKAGE_REF, NAME, DESCRIPTION, ATOMIC_IDENTIFIER, ATOMIC_SIZE, IS_DISCRETE, IS_SIGNED, IS_STRING, IS_LONG, IS_CHAR, IS_COMPOSITE, IS_FLOAT, IS_BASELINE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', + 'INSERT INTO ATOMIC (PACKAGE_REF, NAME, DESCRIPTION, ATOMIC_IDENTIFIER, ATOMIC_SIZE, IS_DISCRETE, IS_SIGNED, IS_STRING, IS_LONG, IS_CHAR, IS_COMPOSITE, IS_FLOAT, BASE_TYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', data.map((at) => [ packageId, at.name, @@ -1019,7 +1019,7 @@ async function insertAtomics(db, packageId, data) { at.isChar, at.isComposite, at.isFloat, - at.isBaseline + at.baseType ]) ) } diff --git a/src-electron/db/zap-schema.sql b/src-electron/db/zap-schema.sql index a1b24f153a..50c84ae123 100644 --- a/src-electron/db/zap-schema.sql +++ b/src-electron/db/zap-schema.sql @@ -598,7 +598,7 @@ CREATE TABLE IF NOT EXISTS "ATOMIC" ( "IS_SIGNED" integer default false, "IS_COMPOSITE" integer default false, "IS_FLOAT" integer default false, - "IS_BASELINE" integer default false, + "BASE_TYPE" text, foreign key (PACKAGE_REF) references PACKAGE(PACKAGE_ID) ON DELETE CASCADE ON UPDATE CASCADE UNIQUE(PACKAGE_REF, NAME, ATOMIC_IDENTIFIER) ); diff --git a/src-electron/zcl/zcl-loader-silabs.js b/src-electron/zcl/zcl-loader-silabs.js index b8abb72ae7..27b8481a92 100644 --- a/src-electron/zcl/zcl-loader-silabs.js +++ b/src-electron/zcl/zcl-loader-silabs.js @@ -321,7 +321,7 @@ function prepareAtomic(a) { a.$.name.toLowerCase() === 'single' || a.$.name.toLowerCase() === 'double' || a.$.name.toLowerCase() === 'float', - isBaseline: a.$.baseline == 'true' + baseType: a.$.baseType } } /** diff --git a/test/gen-matter-1.test.js b/test/gen-matter-1.test.js index afa3840267..e04c023c59 100644 --- a/test/gen-matter-1.test.js +++ b/test/gen-matter-1.test.js @@ -210,11 +210,15 @@ test( 'return DecodeIntoEmberBuffer(decoder, isNullable, out);' ) - // Testing baseline types based on xml defining them - expect(simpleTest).toContain('#DEFINE ZCL_BASELINE_INT32U_DATA_TYPE') - expect(simpleTest).toContain('#DEFINE ZCL_BASELINE_INT32S_DATA_TYPE') - expect(simpleTest).toContain('#DEFINE ZCL_BASELINE_CHAR_STRING_DATA_TYPE') - expect(simpleTest).toContain('#DEFINE ZCL_BASELINE_BOOLEAN_DATA_TYPE') + // Testing base types based on xml defining them + expect(simpleTest).toContain('Baseline type for bitmap8 : int8u') + expect(simpleTest).toContain('Baseline type for bitmap32 : int32u') + expect(simpleTest).toContain('Baseline type for bitmap64 : int64u') + expect(simpleTest).toContain('Baseline type for enum8 : int8u') + expect(simpleTest).toContain('Baseline type for enum16 : int16u') + expect(simpleTest).toContain( + 'Baseline type for ipv6adr : long_octet_string' + ) let deviceType = genResult.content['device-types.txt'] expect(deviceType).toContain( diff --git a/test/gen-template/matter/simple-test.zapt b/test/gen-template/matter/simple-test.zapt index 00acf392f0..ff99f231ac 100644 --- a/test/gen-template/matter/simple-test.zapt +++ b/test/gen-template/matter/simple-test.zapt @@ -44,8 +44,8 @@ switch (AttributeBaseType(metadata->attributeType)) // Extract all baseline types: {{#zcl_atomics}} -{{#if isBaseline}} -#DEFINE ZCL_BASELINE_{{as_delimited_macro name}}_DATA_TYPE +{{#if baseType}} +Baseline type for {{name}} : {{baseType}} {{/if}} {{/zcl_atomics}} diff --git a/zcl-builtin/matter/data-model/chip/chip-types.xml b/zcl-builtin/matter/data-model/chip/chip-types.xml index c56985515b..7b9ef33376 100644 --- a/zcl-builtin/matter/data-model/chip/chip-types.xml +++ b/zcl-builtin/matter/data-model/chip/chip-types.xml @@ -18,39 +18,39 @@ limitations under the License. - - + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -77,7 +77,7 @@ limitations under the License. - +