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

Look for more flash space savings in cluster-objects.cpp #29561

Merged
merged 7 commits into from
Oct 5, 2023
40 changes: 13 additions & 27 deletions src/app/zap-templates/templates/app/cluster-objects-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ CHIP_ERROR FlightCheckDecodeAndEnterStruct(TLV::TLVReader & reader, TLV::TLVType
CHIP_ERROR err = CHIP_NO_ERROR;
VerifyOrReturnError(TLV::kTLVType_Structure == temp_reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE);
ReturnErrorOnFailure(temp_reader.EnterContainer(outer));
while ((err = temp_reader.Next()) == CHIP_NO_ERROR)
{
if (!TLV::IsContextTag(temp_reader.GetTag()))
{
continue;
}
}
while ((err = temp_reader.Next()) == CHIP_NO_ERROR) {}
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
VerifyOrReturnError(err == CHIP_END_OF_TLV, err);
ReturnErrorOnFailure(temp_reader.ExitContainer(outer));

Expand Down Expand Up @@ -85,19 +79,15 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader) {

CHIP_ERROR err = CHIP_NO_ERROR;
while ((err = reader.Next()) == CHIP_NO_ERROR) {
if (!TLV::IsContextTag(reader.GetTag()))
[[maybe_unused]] const TLV::Tag tag = reader.GetTag();
{{#zcl_command_arguments}}
if (tag == TLV::ContextTag(to_underlying(Fields::k{{asUpperCamelCase label}})))
{
continue;
ReturnErrorOnFailure(DataModel::Decode(reader, {{asLowerCamelCase label}}));
}
switch (TLV::TagNumFromTag(reader.GetTag()))
else
{{/zcl_command_arguments}}
{
{{#zcl_command_arguments}}
case to_underlying(Fields::k{{asUpperCamelCase label}}):
ReturnErrorOnFailure(DataModel::Decode(reader, {{asLowerCamelCase label}}));
break;
{{/zcl_command_arguments}}
default:
break;
}
}

Expand Down Expand Up @@ -148,19 +138,15 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader) {

CHIP_ERROR err = CHIP_NO_ERROR;
while ((err = reader.Next()) == CHIP_NO_ERROR) {
if (!TLV::IsContextTag(reader.GetTag()))
[[maybe_unused]] const TLV::Tag tag = reader.GetTag();
{{#zcl_event_fields}}
if (tag == TLV::ContextTag(to_underlying(Fields::k{{asUpperCamelCase name}})))
{
continue;
ReturnErrorOnFailure(DataModel::Decode(reader, {{asLowerCamelCase name}}));
}
switch (TLV::TagNumFromTag(reader.GetTag()))
else
{{/zcl_event_fields}}
{
{{#zcl_event_fields}}
case to_underlying(Fields::k{{asUpperCamelCase name}}):
ReturnErrorOnFailure(DataModel::Decode(reader, {{asLowerCamelCase name}}));
break;
{{/zcl_event_fields}}
default:
break;
}
}

Expand Down
Loading