Skip to content

Commit

Permalink
Missed some first/last iterations
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Oct 4, 2023
1 parent c1d4c90 commit c735e5c
Show file tree
Hide file tree
Showing 3 changed files with 495 additions and 455 deletions.
10 changes: 7 additions & 3 deletions src/app/zap-templates/partials/cluster-objects-struct.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,25 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader) {
return std::get<CHIP_ERROR>(__element);
}

{{#zcl_struct_items}}
{{#first}}
CHIP_ERROR err = CHIP_NO_ERROR;
[[maybe_unused]] const uint8_t __context_tag = std::get<uint8_t>(__element);
const uint8_t __context_tag = std::get<uint8_t>(__element);

{{#zcl_struct_items}}
{{/first~}}
{{! NOTE: using if/else instead of switch because it seems to generate smaller code. ~}}
if (__context_tag == to_underlying(Fields::k{{asUpperCamelCase label}}))
{
err = DataModel::Decode(reader, {{asLowerCamelCase label}});
}
else
{{/zcl_struct_items}}
{{#last}}
{
}

ReturnErrorOnFailure(err);
{{/last}}
{{/zcl_struct_items}}
}
}

Expand Down
13 changes: 8 additions & 5 deletions src/app/zap-templates/templates/app/cluster-objects-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,11 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader) {
}

{{#zcl_command_arguments~}}

{{#first}}
CHIP_ERROR err = CHIP_NO_ERROR;
const uint8_t __context_tag = std::get<uint8_t>(__element);
{{/first~}}

{{/first~}}
{{! NOTE: using if/else instead of switch because it seems to generate smaller code. ~}}
if (__context_tag == to_underlying(Fields::k{{asUpperCamelCase label}}))
{
Expand Down Expand Up @@ -160,21 +159,25 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader) {
return std::get<CHIP_ERROR>(__element);
}

{{#zcl_event_fields}}
{{#first}}
CHIP_ERROR err = CHIP_NO_ERROR;
[[maybe_unused]] const uint8_t __context_tag = std::get<uint8_t>(__element);
const uint8_t __context_tag = std::get<uint8_t>(__element);

{{#zcl_event_fields}}
{{/first~}}
{{! NOTE: using if/else instead of switch because it seems to generate smaller code. ~}}
if (__context_tag == to_underlying(Fields::k{{asUpperCamelCase name}}))
{
err = DataModel::Decode(reader, {{asLowerCamelCase name}});
}
else
{{/zcl_event_fields}}
{{#last}}
{
}

ReturnErrorOnFailure(err);
{{/last}}
{{/zcl_event_fields}}
}
}
} // namespace {{asUpperCamelCase name}}.
Expand Down
Loading

0 comments on commit c735e5c

Please sign in to comment.