Skip to content

Commit

Permalink
Removing zcl_baseline_types since that is not needed
Browse files Browse the repository at this point in the history
Github: ZAP#1438
  • Loading branch information
brdandu committed Oct 28, 2024
1 parent 36889ff commit eacbfb4
Show file tree
Hide file tree
Showing 7 changed files with 4,830 additions and 4,959 deletions.
13 changes: 0 additions & 13 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -11633,7 +11633,6 @@ This module contains the API for templating. For more detailed instructions, rea
* [~zcl_attributes_client(options)](#module_Templating API_ static zcl helpers..zcl_attributes_client) ⇒
* [~zcl_attributes_server(options)](#module_Templating API_ static zcl helpers..zcl_attributes_server) ⇒
* [~zcl_atomics(options)](#module_Templating API_ static zcl helpers..zcl_atomics) ⇒
* [~zcl_baseline_types(options)](#module_Templating API_ static zcl helpers..zcl_baseline_types) ⇒
* [~zcl_cluster_largest_label_length()](#module_Templating API_ static zcl helpers..zcl_cluster_largest_label_length) ⇒
* [~largestLabelLength(An)](#module_Templating API_ static zcl helpers..largestLabelLength) ⇒
* [~zcl_command_arguments_count(commandId)](#module_Templating API_ static zcl helpers..zcl_command_arguments_count) ⇒
Expand Down Expand Up @@ -12059,18 +12058,6 @@ Block helper iterating over all atomic types.
| --- | --- |
| options | <code>\*</code> |

<a name="module_Templating API_ static zcl helpers..zcl_baseline_types"></a>

### Templating API: static zcl helpers~zcl\_baseline\_types(options) ⇒
Block helper iterating over all baseline types in matter from atomics.

**Kind**: inner method of [<code>Templating API: static zcl helpers</code>](#module_Templating API_ static zcl helpers)
**Returns**: Promise of content.

| Param | Type |
| --- | --- |
| options | <code>\*</code> |

<a name="module_Templating API_ static zcl helpers..zcl_cluster_largest_label_length"></a>

### Templating API: static zcl helpers~zcl\_cluster\_largest\_label\_length() ⇒
Expand Down
13 changes: 0 additions & 13 deletions docs/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -3333,7 +3333,6 @@ This module contains the API for templating. For more detailed instructions, rea
* [~zcl_attributes_client(options)](#module_Templating API_ static zcl helpers..zcl_attributes_client) ⇒
* [~zcl_attributes_server(options)](#module_Templating API_ static zcl helpers..zcl_attributes_server) ⇒
* [~zcl_atomics(options)](#module_Templating API_ static zcl helpers..zcl_atomics) ⇒
* [~zcl_baseline_types(options)](#module_Templating API_ static zcl helpers..zcl_baseline_types) ⇒
* [~zcl_cluster_largest_label_length()](#module_Templating API_ static zcl helpers..zcl_cluster_largest_label_length) ⇒
* [~largestLabelLength(An)](#module_Templating API_ static zcl helpers..largestLabelLength) ⇒
* [~zcl_command_arguments_count(commandId)](#module_Templating API_ static zcl helpers..zcl_command_arguments_count) ⇒
Expand Down Expand Up @@ -3759,18 +3758,6 @@ Block helper iterating over all atomic types.
| --- | --- |
| options | <code>\*</code> |

<a name="module_Templating API_ static zcl helpers..zcl_baseline_types"></a>

### Templating API: static zcl helpers~zcl\_baseline\_types(options) ⇒
Block helper iterating over all baseline types in matter from atomics.

**Kind**: inner method of [<code>Templating API: static zcl helpers</code>](#module_Templating API_ static zcl helpers)
**Returns**: Promise of content.

| Param | Type |
| --- | --- |
| options | <code>\*</code> |

<a name="module_Templating API_ static zcl helpers..zcl_cluster_largest_label_length"></a>

### Templating API: static zcl helpers~zcl\_cluster\_largest\_label\_length() ⇒
Expand Down
4,827 changes: 2,415 additions & 2,412 deletions docs/zap-schema.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 0 additions & 63 deletions src-electron/generator/helper-zcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -887,68 +887,6 @@ async function zcl_atomics(options) {
return templateUtil.templatePromise(this.global, promise)
}

/**
* Block helper iterating over all baseline types in matter from atomics.
*
* @param {*} options
* @returns Promise of content.
*/
async function zcl_baseline_types(options) {
const baselineTypes = []
const baselinekeys = new Set()
let atomictypes = await templateUtil
.ensureZclPackageIds(this)
.then((packageIds) =>
Promise.all(
packageIds.map((packageId) =>
queryZcl.selectAllAtomics(this.global.db, packageId)
)
)
)
.then((x) => x.flat())

for (let i = 0; i < atomictypes.length; i++) {
// Creating a key to determine distinct baseline types
const key =
`${atomictypes[i].size}-${atomictypes[i].isSigned}-${atomictypes[i].isString}-${atomictypes[i].isLong}-` +
(atomictypes[i].isString ? `${atomictypes[i].name}-` : '-') +
(atomictypes[i].name.toLowerCase().includes('single') ||
atomictypes[i].name.toLowerCase().includes('double')
? `${atomictypes[i].name}`
: '')

if (
!baselinekeys.has(key) &&
(atomictypes[i].size || atomictypes[i].isString) &&
atomictypes[i].size != 0 &&
(!atomictypes[i].isComposite || atomictypes[i].isString)
) {
baselinekeys.add(key)
baselineTypes.push(atomictypes[i])
}
}
// Sort the baselineTypes array
baselineTypes.sort((a, b) => {
// Sort by isFloat (false before true)
if (a.isFloat !== b.isFloat) {
return a.isFloat ? 1 : -1 // Sort false before true
}
// Sort by isSigned (false before true)
if (a.isSigned !== b.isSigned) {
return a.isSigned ? 1 : -1 // Sort false before true
}
// Sort by size (numerically)
const sizeComparison = Number(a.size) - Number(b.size)
if (sizeComparison !== 0) {
return sizeComparison // If sizes are different, return comparison
}
// Sort by isString (false before true)
return a.isString === b.isString ? 0 : a.isString ? 1 : -1
})

return templateUtil.collectBlocks(baselineTypes, options, this)
}

/**
*
*
Expand Down Expand Up @@ -3153,4 +3091,3 @@ exports.as_zcl_data_type_size = as_zcl_data_type_size
exports.zcl_command_responses = zcl_command_responses
exports.zcl_struct_items_by_struct_and_cluster_name =
zcl_struct_items_by_struct_and_cluster_name
exports.zcl_baseline_types = zcl_baseline_types
23 changes: 0 additions & 23 deletions test/gen-matter-1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,29 +187,6 @@ test(
'ExternalAddon : This is example of test external addon helper.'
)

// Test baseline data types for Matter
expect(simpleTest).toContain(
'return DecodeStringLikeIntoEmberBuffer<ByteSpan, ShortPascalString>(decoder, isNullable, out);'
)
expect(simpleTest).toContain(
'return DecodeStringLikeIntoEmberBuffer<CharSpan, ShortPascalString>(decoder, isNullable, out);'
)
expect(simpleTest).toContain(
'return DecodeIntoEmberBuffer<uint8_t>(decoder, isNullable, out);'
)
expect(simpleTest).toContain(
'return DecodeIntoEmberBuffer<OddSizedInteger<3, false>>(decoder, isNullable, out);'
)
expect(simpleTest).toContain(
'return DecodeIntoEmberBuffer<int16_t>(decoder, isNullable, out);'
)
expect(simpleTest).toContain(
'return DecodeIntoEmberBuffer<single>(decoder, isNullable, out);'
)
expect(simpleTest).toContain(
'return DecodeIntoEmberBuffer<double>(decoder, isNullable, out);'
)

// Testing base types based on xml defining them
expect(simpleTest).toContain('Baseline type for bitmap8 : int8u')
expect(simpleTest).toContain('Baseline type for bitmap32 : int32u')
Expand Down
23 changes: 0 additions & 23 deletions test/gen-template/matter/simple-test.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,6 @@ ExternalAddon : {{test_external_addon_all_commands_helper}}
ExternalAddon : {{test_external_addon_all_events_helper}}
ExternalAddon : {{test_external_addon_helper}}

switch (AttributeBaseType(metadata->attributeType))
{
case ZCL_BOOLEAN_ATTRIBUTE_TYPE: // Boolean
return DecodeIntoEmberBuffer<bool>(decoder, isNullable, out);
{{#zcl_baseline_types}}
{{#if size}}
{{#unless isFloat}}
case ZCL_INT{{multiply size 8}}{{#if_compare ./isSigned true operator='==='}}S{{else}}U{{/if_compare}}_ATTRIBUTE_TYPE: // {{#if_compare ./isSigned true operator='==='}}Signed{{else}}Unsigned{{/if_compare}} {{multiply size 8}}-bit integer
return DecodeIntoEmberBuffer<{{#if (is_power_of_two (multiply size 8))}}{{#if_compare ./isSigned true operator='==='}}{{else}}u{{/if_compare}}int{{multiply size 8}}_t{{else}}OddSizedInteger<{{size}}, {{isSigned}}>{{/if}}>(decoder, isNullable, out);
{{else}}
case ZCL_{{as_delimited_macro name}}_ATTRIBUTE_TYPE: // {{multiply size 8}}-bit float
return DecodeIntoEmberBuffer<{{name}}>(decoder, isNullable, out);
{{/unless}}
{{else}}
case ZCL_{{as_delimited_macro name}}_ATTRIBUTE_TYPE: // {{name}}
return DecodeStringLikeIntoEmberBuffer<{{#if_compare "octet" ./name operator='in'}}Byte{{else}}Char{{/if_compare}}Span, {{#if_compare "long" ./name operator='in'}}Long{{else}}Short{{/if_compare}}PascalString>(decoder, isNullable, out);
{{/if}}
{{/zcl_baseline_types}}
default:
ChipLogError(DataManagement, "Attribute type 0x%x not handled", static_cast<int>(metadata->attributeType));
return CHIP_IM_GLOBAL_STATUS(Failure);
}

// Extract all baseline types:
{{#zcl_atomics}}
{{#if baseType}}
Expand Down
Loading

0 comments on commit eacbfb4

Please sign in to comment.