-
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.
Switch to having only one struct named LabelStruct. (#13380)
This is shared across the fixed label and user label clusters. The struct definition is in the "detail" namespace, with alias namespaces in the two clusters that use it. Consumers are generally expected to use the per-cluster aliases.
- Loading branch information
1 parent
4a1f481
commit 7d2771f
Showing
17 changed files
with
263 additions
and
295 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
16 changes: 16 additions & 0 deletions
16
examples/chip-tool/templates/partials/log_struct_value.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,16 @@ | ||
CHIP_ERROR LogValue(const char * label, size_t indent, {{zapTypeToDecodableClusterObjectType name ns=ns isArgument=true}} value) | ||
{ | ||
ChipLogProgress(chipTool, "%s%s: {", IndentStr(indent).c_str(), label); | ||
{{#zcl_struct_items}} | ||
{ | ||
CHIP_ERROR err = LogValue("{{asUpperCamelCase label}}", indent + 1, value.{{asLowerCamelCase label}}); | ||
if (err != CHIP_NO_ERROR) | ||
{ | ||
ChipLogProgress(chipTool, "%sStruct truncated due to invalid value for '{{asUpperCamelCase label}}'", IndentStr(indent + 1).c_str()); | ||
return err; | ||
} | ||
} | ||
{{/zcl_struct_items}} | ||
ChipLogProgress(chipTool, "%s}", IndentStr(indent).c_str()); | ||
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
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
77 changes: 77 additions & 0 deletions
77
src/app/zap-templates/partials/cluster-objects-struct.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,77 @@ | ||
{{#if header}} | ||
namespace {{asUpperCamelCase name}} { | ||
enum class Fields { | ||
{{#zcl_struct_items}} | ||
k{{asUpperCamelCase label}} = {{fieldIdentifier}}, | ||
{{/zcl_struct_items}} | ||
}; | ||
|
||
struct Type { | ||
public: | ||
{{#zcl_struct_items}} | ||
{{zapTypeToEncodableClusterObjectType type}} {{asLowerCamelCase label}}; | ||
{{/zcl_struct_items}} | ||
|
||
CHIP_ERROR Encode(TLV::TLVWriter &writer, TLV::Tag tag) const; | ||
{{#unless struct_contains_array}} | ||
CHIP_ERROR Decode(TLV::TLVReader &reader); | ||
{{/unless}} | ||
{{#if struct_is_fabric_scoped}} | ||
bool MatchesFabricIndex(FabricIndex fabricIndex_) const { | ||
return {{ asLowerCamelCase struct_fabric_idx_field }} == fabricIndex_; | ||
} | ||
{{/if}} | ||
}; | ||
|
||
{{#if struct_contains_array}} | ||
struct DecodableType { | ||
public: | ||
{{#zcl_struct_items}} | ||
{{zapTypeToDecodableClusterObjectType type}} {{asLowerCamelCase label}}; | ||
{{/zcl_struct_items}} | ||
CHIP_ERROR Decode(TLV::TLVReader &reader); | ||
}; | ||
{{else}} | ||
using DecodableType = Type; | ||
{{/if}} | ||
|
||
} // namespace {{asUpperCamelCase name}} | ||
{{else}} | ||
namespace {{asUpperCamelCase name}} { | ||
CHIP_ERROR Type::Encode(TLV::TLVWriter &writer, TLV::Tag tag) const{ | ||
TLV::TLVType outer; | ||
ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); | ||
{{#zcl_struct_items}} | ||
ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::k{{asUpperCamelCase label}})), {{asLowerCamelCase label}})); | ||
{{/zcl_struct_items}} | ||
ReturnErrorOnFailure(writer.EndContainer(outer)); | ||
return CHIP_NO_ERROR; | ||
} | ||
|
||
CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader) { | ||
CHIP_ERROR err = CHIP_NO_ERROR; | ||
TLV::TLVType outer; | ||
VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); | ||
err = reader.EnterContainer(outer); | ||
ReturnErrorOnFailure(err); | ||
while ((err = reader.Next()) == CHIP_NO_ERROR) { | ||
VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); | ||
switch (TLV::TagNumFromTag(reader.GetTag())) | ||
{ | ||
{{#zcl_struct_items}} | ||
case to_underlying(Fields::k{{asUpperCamelCase label}}): | ||
ReturnErrorOnFailure(DataModel::Decode(reader, {{asLowerCamelCase label}})); | ||
break; | ||
{{/zcl_struct_items}} | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
VerifyOrReturnError(err == CHIP_END_OF_TLV, err); | ||
ReturnErrorOnFailure(reader.ExitContainer(outer)); | ||
return CHIP_NO_ERROR; | ||
} | ||
|
||
} // namespace {{asUpperCamelCase name}} | ||
{{/if}} |
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
12 changes: 0 additions & 12 deletions
12
src/darwin/Framework/CHIP/zap-generated/CHIPAttributeTLVValueDecoder.mm
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.