Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YAML] Remove unused list freer #15415

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/chip-tool/templates/tests/partials/test_cluster.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class {{filename}}: public TestCommand
{{#if isCommand}}
using RequestType = chip::app::Clusters::{{asUpperCamelCase cluster}}::Commands::{{asUpperCamelCase command}}::Type;

ListFreer listFreer;
{{#if (chip_tests_item_has_list)}} ListFreer listFreer;{{/if}}
RequestType request;
{{#chip_tests_item_parameters}}
{{>commandValue ns=parent.cluster container=(concat "request." (asLowerCamelCase label)) definedValue=definedValue depth=0}}
Expand Down Expand Up @@ -335,7 +335,7 @@ class {{filename}}: public TestCommand
cluster.Associate({{>device}}, endpoint);
{{/if}}

ListFreer listFreer;
{{#if (chip_tests_item_has_list)}} ListFreer listFreer;{{/if}}
{{#chip_tests_item_parameters}}
{{zapTypeToEncodableClusterObjectType type ns=parent.cluster}} {{asLowerCamelCase name}}Argument;
{{>commandValue ns=parent.cluster container=(concat (asLowerCamelCase name) "Argument") definedValue=definedValue depth=0}}
Expand Down
27 changes: 27 additions & 0 deletions src/app/zap-templates/common/ClusterTestGeneration.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,11 +768,38 @@ function ensureIsArray(value, options)
}
}

function chip_tests_item_has_list(options)
{
function hasList(args)
{
for (let i = 0; i < args.length; i++) {
if (args[i].isArray) {
return true;
}

if (args[i].isStruct && hasList(args[i].items)) {
return true;
}
}

return false;
}

return assertCommandOrAttributeOrEvent(this).then(item => {
if (this.isWriteAttribute || this.isCommand) {
return hasList(item.arguments);
}

return false;
});
}

//
// Module exports
//
exports.chip_tests = chip_tests;
exports.chip_tests_items = chip_tests_items;
exports.chip_tests_item_has_list = chip_tests_item_has_list;
exports.chip_tests_item_parameters = chip_tests_item_parameters;
exports.chip_tests_item_response_parameters = chip_tests_item_response_parameters;
exports.chip_tests_pics = chip_tests_pics;
Expand Down
Loading