From c0e6cf2442fb8583afdb90798824e72245bb93e2 Mon Sep 17 00:00:00 2001 From: Song GUO Date: Wed, 26 Jan 2022 06:14:21 +0800 Subject: [PATCH] [cluster object] Change MatchesFabricIndex to GetFabricIndex (#13902) * [cluster object] Change MatchesFabricIndex to GetFabricIndex * Run Codegen * Fix comment --- src/app/AttributeAccessInterface.h | 2 +- src/app/data-model/FabricScoped.h | 10 +++++----- .../partials/cluster-objects-struct.zapt | 6 +++--- .../app-common/zap-generated/cluster-objects.h | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/app/AttributeAccessInterface.h b/src/app/AttributeAccessInterface.h index 6825cf9018df69..6c5231d648e7c2 100644 --- a/src/app/AttributeAccessInterface.h +++ b/src/app/AttributeAccessInterface.h @@ -106,7 +106,7 @@ class AttributeValueEncoder // If we are encoding for a fabric filtered attribute read and the fabric index does not match that present in the // request, skip encoding this list item. VerifyOrReturnError(!mAttributeValueEncoder.mIsFabricFiltered || - aArg.MatchesFabricIndex(mAttributeValueEncoder.mAccessingFabricIndex), + aArg.GetFabricIndex() == mAttributeValueEncoder.mAccessingFabricIndex, CHIP_NO_ERROR); return mAttributeValueEncoder.EncodeListItem(std::forward(aArg)); } diff --git a/src/app/data-model/FabricScoped.h b/src/app/data-model/FabricScoped.h index 0297c54a3456e4..960d1e74734885 100644 --- a/src/app/data-model/FabricScoped.h +++ b/src/app/data-model/FabricScoped.h @@ -28,21 +28,21 @@ namespace DataModel { /* * Check whether a cluster object struct is fabric scoped. * A fabric scoped struct contains a field of "FabricIndex" type, however, we cannot tell the difference between that field and - * other uint8_t fields. Thus we add a MatchesFabricIndex member function for checking the fabric id. Here, IsFabricScoped check the - * presence of MatchesFabricIndex function. This template can be used with std::enable_if. + * other uint8_t fields. Thus we add a GetFabricIndex member function for getting the fabric id. Here, IsFabricScoped checks the + * presence of GetFabricIndex function. This template can be used with std::enable_if. */ template class IsFabricScoped { private: template - static auto TestHasMatchesFabricIndex(int) -> TemplatedTrueType; + static auto TestHasFabricIndex(int) -> TemplatedTrueType; template - static auto TestHasMatchesFabricIndex(long) -> std::false_type; + static auto TestHasFabricIndex(long) -> std::false_type; public: - static constexpr bool value = decltype(TestHasMatchesFabricIndex>(0))::value; + static constexpr bool value = decltype(TestHasFabricIndex>(0))::value; }; } // namespace DataModel diff --git a/src/app/zap-templates/partials/cluster-objects-struct.zapt b/src/app/zap-templates/partials/cluster-objects-struct.zapt index 6241a15be788e2..2ce3270f147f28 100644 --- a/src/app/zap-templates/partials/cluster-objects-struct.zapt +++ b/src/app/zap-templates/partials/cluster-objects-struct.zapt @@ -17,8 +17,8 @@ namespace {{asUpperCamelCase name}} { CHIP_ERROR Decode(TLV::TLVReader &reader); {{/unless}} {{#if struct_is_fabric_scoped}} - bool MatchesFabricIndex(FabricIndex fabricIndex_) const { - return {{ asLowerCamelCase struct_fabric_idx_field }} == fabricIndex_; + auto GetFabricIndex() const { + return {{ asLowerCamelCase struct_fabric_idx_field }}; } {{/if}} }; @@ -74,4 +74,4 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader &reader) { } } // namespace {{asUpperCamelCase name}} -{{/if}} \ No newline at end of file +{{/if}} diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index b46c1cbef6488c..06d5de3b2867c0 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -6463,7 +6463,7 @@ struct Type DataModel::Nullable> targets; CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; - bool MatchesFabricIndex(FabricIndex fabricIndex_) const { return fabricIndex == fabricIndex_; } + auto GetFabricIndex() const { return fabricIndex; } }; struct DecodableType @@ -6493,7 +6493,7 @@ struct Type CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); - bool MatchesFabricIndex(FabricIndex fabricIndex_) const { return fabricIndex == fabricIndex_; } + auto GetFabricIndex() const { return fabricIndex; } }; using DecodableType = Type; @@ -8640,7 +8640,7 @@ struct Type CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); - bool MatchesFabricIndex(FabricIndex fabricIndex_) const { return fabricIndex == fabricIndex_; } + auto GetFabricIndex() const { return fabricIndex; } }; using DecodableType = Type; @@ -14405,7 +14405,7 @@ struct Type CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); - bool MatchesFabricIndex(FabricIndex fabricIndex_) const { return fabricIndex == fabricIndex_; } + auto GetFabricIndex() const { return fabricIndex; } }; using DecodableType = Type; @@ -14428,7 +14428,7 @@ struct Type CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); - bool MatchesFabricIndex(FabricIndex fabricIndex_) const { return fabricIndex == fabricIndex_; } + auto GetFabricIndex() const { return fabricIndex; } }; using DecodableType = Type; @@ -15145,7 +15145,7 @@ struct Type CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); - bool MatchesFabricIndex(FabricIndex fabricIndex_) const { return fabricIndex == fabricIndex_; } + auto GetFabricIndex() const { return fabricIndex; } }; using DecodableType = Type; @@ -33643,7 +33643,7 @@ struct Type CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; CHIP_ERROR Decode(TLV::TLVReader & reader); - bool MatchesFabricIndex(FabricIndex fabricIndex_) const { return fabricIndex == fabricIndex_; } + auto GetFabricIndex() const { return fabricIndex; } }; using DecodableType = Type;