-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix chip-tool handling of same-named structs in different clusters. (#…
…26253) The chip-tool code was assuming that the only way a struct with the same name could occur in multiple clusters was if it was the same struct, shared by the two clusters. But that's just not true in the spec. For example, there are totally different TargetStruct structs in different clusters. This fixes chip-tool to do the same thing as cluster-objects in terms of deciding what the set of structs we have to deal with is.
1 parent
c6ba480
commit 1091044
Showing
13 changed files
with
2,822 additions
and
2,531 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::{{namespace}}::Structs::{{name}}::DecodableType & value); | ||
|
18 changes: 18 additions & 0 deletions
18
examples/chip-tool/templates/partials/StructLoggerImpl.zapt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::{{namespace}}::Structs::{{name}}::DecodableType & value) | ||
{ | ||
DataModelLogger::LogString(label, indent, "{"); | ||
{{#zcl_struct_items}} | ||
{ | ||
CHIP_ERROR err = LogValue("{{asUpperCamelCase label}}", indent + 1, value.{{asLowerCamelCase label}}); | ||
if (err != CHIP_NO_ERROR) | ||
{ | ||
DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for '{{asUpperCamelCase label}}'"); | ||
return err; | ||
} | ||
} | ||
{{/zcl_struct_items}} | ||
DataModelLogger::LogString(indent, "}"); | ||
|
||
return CHIP_NO_ERROR; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
static CHIP_ERROR Setup(const char * label, chip::app::Clusters::{{namespace}}::Structs::{{name}}::Type & request, Json::Value & value); | ||
|
||
static void Finalize(chip::app::Clusters::{{namespace}}::Structs::{{name}}::Type & request); | ||
|
47 changes: 47 additions & 0 deletions
47
examples/chip-tool/templates/partials/StructParserImpl.zapt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::{{namespace}}::Structs::{{name}}::Type & request, Json::Value & value) | ||
{ | ||
VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); | ||
|
||
// Copy to track which members we already processed. | ||
Json::Value valueCopy(value); | ||
|
||
{{#zcl_struct_items}} | ||
{{#unless isOptional}} | ||
{{~! Fabric index fields are not sent on writes, so don't force people to | ||
provide them. ~}} | ||
{{#unless (is_num_equal fieldIdentifier 254)}} | ||
ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("{{parent.name}}.{{asLowerCamelCase label}}", "{{asLowerCamelCase label}}", value.isMember("{{asLowerCamelCase label}}"))); | ||
{{/unless}} | ||
{{/unless}} | ||
{{/zcl_struct_items}} | ||
|
||
char labelWithMember[kMaxLabelLength]; | ||
{{#zcl_struct_items}} | ||
{{#if isOptional}} | ||
if (value.isMember("{{asLowerCamelCase label}}")) | ||
{ | ||
{{else if (is_num_equal fieldIdentifier 254)}} | ||
if (value.isMember("{{asLowerCamelCase label}}")) | ||
{ | ||
{{/if}} | ||
snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "{{asLowerCamelCase label}}"); | ||
ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.{{asLowerCamelCase label}}, value["{{asLowerCamelCase label}}"])); | ||
{{#if isOptional}} | ||
} | ||
{{else if (is_num_equal fieldIdentifier 254)}} | ||
} | ||
{{/if}} | ||
valueCopy.removeMember("{{asLowerCamelCase label}}"); | ||
|
||
{{/zcl_struct_items}} | ||
|
||
return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); | ||
} | ||
|
||
void ComplexArgumentParser::Finalize(chip::app::Clusters::{{namespace}}::Structs::{{name}}::Type & request) | ||
{ | ||
{{#zcl_struct_items}} | ||
ComplexArgumentParser::Finalize(request.{{asLowerCamelCase label}}); | ||
{{/zcl_struct_items}} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3,105 changes: 1,581 additions & 1,524 deletions
3,105
zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
269 changes: 163 additions & 106 deletions
269
zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h
Large diffs are not rendered by default.
Oops, something went wrong.
1,591 changes: 824 additions & 767 deletions
1,591
zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
177 changes: 117 additions & 60 deletions
177
zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h
Large diffs are not rendered by default.
Oops, something went wrong.