Skip to content

Commit

Permalink
Add more files to be managed and known by GN (#32140)
Browse files Browse the repository at this point in the history
* A first attempt at cleanup: moved ObjectList.h and some renames

* Another rename pass

* Final rename pass

* Restyle

* Fix typo in include

* Fix typo and include dependencies

* Remove handled files from linter check

* Added 3 more mock files to be tracked by gn

* Added some comments about layering issues and added EventManagement.h since that seems safe

* Added more headers that are safe and restyle

* Spell out what we could not add in IM because broken dependencies

* Also track AppDelegate

* Update the comments to not trigger the very basic linter we have

* Fix typo

* Restyle

* Pull linkedlist into support rather than separate source set
  • Loading branch information
andy31415 authored Feb 20, 2024
1 parent 6b27278 commit a3d0a86
Show file tree
Hide file tree
Showing 26 changed files with 132 additions and 104 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,35 +93,25 @@ jobs:
--known-failure app/AttributeAccessInterface.h \
--known-failure app/AttributeAccessToken.h \
--known-failure app/att-storage.h \
--known-failure app/BufferedReadCallback.h \
--known-failure app/CommandHandler.h \
--known-failure app/CommandHandlerInterface.h \
--known-failure app/CommandPathParams.h \
--known-failure app/CommandPathRegistry.h \
--known-failure app/CommandResponseSender.h \
--known-failure app/CommandSender.h \
--known-failure app/CommandSenderLegacyCallback.h \
--known-failure app/CompatEnumNames.h \
--known-failure app/ConcreteAttributePath.h \
--known-failure app/ConcreteCommandPath.h \
--known-failure app/data-model/ListLargeSystemExtensions.h \
--known-failure app/EventHeader.h \
--known-failure app/EventLoggingDelegate.h \
--known-failure app/EventLogging.h \
--known-failure app/EventLoggingTypes.h \
--known-failure app/EventManagement.h \
--known-failure app/InteractionModelHelper.h \
--known-failure app/ObjectList.h \
--known-failure app/ReadClient.h \
--known-failure app/ReadHandler.h \
--known-failure app/ReadPrepareParams.h \
--known-failure app/reporting/tests/MockReportScheduler.cpp \
--known-failure app/reporting/tests/MockReportScheduler.h \
--known-failure app/server/AppDelegate.h \
--known-failure app/TestEventTriggerDelegate.h \
--known-failure app/util/af.h \
--known-failure app/util/af-types.h \
--known-failure app/util/attribute-metadata.h \
--known-failure app/util/attribute-storage.cpp \
--known-failure app/util/attribute-storage.h \
--known-failure app/util/attribute-storage-null-handling.h \
Expand All @@ -141,11 +131,7 @@ jobs:
--known-failure app/util/im-client-callbacks.h \
--known-failure app/util/MatterCallbacks.h \
--known-failure app/util/message.cpp \
--known-failure app/util/mock/Constants.h \
--known-failure app/util/mock/Functions.h \
--known-failure app/util/mock/MockNodeConfig.h \
--known-failure app/util/odd-sized-integers.h \
--known-failure app/util/types_stub.h \
--known-failure app/util/util.cpp \
--known-failure app/util/util.h \
--known-failure app/WriteClient.h \
Expand Down
2 changes: 1 addition & 1 deletion src/app/AttributePathExpandIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extern bool emberAfEndpointIndexIsEnabled(uint16_t index);
namespace chip {
namespace app {

AttributePathExpandIterator::AttributePathExpandIterator(ObjectList<AttributePathParams> * aAttributePath)
AttributePathExpandIterator::AttributePathExpandIterator(SingleLinkedListNode<AttributePathParams> * aAttributePath)
{
mpAttributePath = aAttributePath;

Expand Down
4 changes: 2 additions & 2 deletions src/app/AttributePathExpandIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace app {
class AttributePathExpandIterator
{
public:
AttributePathExpandIterator(ObjectList<AttributePathParams> * aAttributePath);
AttributePathExpandIterator(SingleLinkedListNode<AttributePathParams> * aAttributePath);

/**
* Proceed the iterator to the next attribute path in the given cluster info.
Expand Down Expand Up @@ -105,7 +105,7 @@ class AttributePathExpandIterator
inline bool Valid() const { return mpAttributePath != nullptr; }

private:
ObjectList<AttributePathParams> * mpAttributePath;
SingleLinkedListNode<AttributePathParams> * mpAttributePath;

ConcreteAttributePath mOutputPath;

Expand Down
26 changes: 26 additions & 0 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ source_set("revision_info") {
source_set("paths") {
sources = [
"AttributePathParams.h",
"CommandPathParams.h",
"CommandPathRegistry.h",
"ConcreteAttributePath.h",
"ConcreteClusterPath.h",
"ConcreteCommandPath.h",
"ConcreteEventPath.h",
"DataVersionFilter.h",
"EventPathParams.h",
Expand All @@ -96,6 +100,7 @@ source_set("paths") {
# This source sets also depends on basic-types.h that is not in any dependency we can use
public_deps = [
":app_config",
"${chip_root}/src/app/util:types",
"${chip_root}/src/lib/core",
"${chip_root}/src/lib/core:types",
]
Expand Down Expand Up @@ -222,12 +227,14 @@ static_library("app") {
"CommandHandler.cpp",
"CommandResponseHelper.h",
"CommandResponseSender.cpp",
"CommandResponseSender.h",
"CommandSender.cpp",
"DefaultAttributePersistenceProvider.cpp",
"DefaultAttributePersistenceProvider.h",
"DeferredAttributePersistenceProvider.cpp",
"DeferredAttributePersistenceProvider.h",
"EventManagement.cpp",
"EventManagement.h",
"FailSafeContext.cpp",
"FailSafeContext.h",
"OTAUserConsentCommon.h",
Expand All @@ -242,6 +249,21 @@ static_library("app") {
"TimerDelegates.h",
"WriteClient.cpp",
"WriteHandler.cpp",

# TODO: the following items cannot be included due to interaction-model circularity
# (app depending on im and im including these headers):
# Name with _ so that linter does not recognize it
# "CommandHandler._h"
# "CommandSender._h",
# "ReadClient._h",
# "ReadHandler._h",
# "WriteClient._h",
# "WriteHandler._h"

# TODO: the following items cannot be included due to platform includes not being
# able to depend on src/app
# Name with _ so that linter does not recognize it
# "_AttributeAccessInterface._h",
]

public_deps = [
Expand All @@ -261,9 +283,13 @@ static_library("app") {
if (chip_enable_read_client) {
sources += [
"BufferedReadCallback.cpp",
"BufferedReadCallback.h",
"ClusterStateCache.cpp",
"ClusterStateCache.h",
"ReadClient.cpp",

# TODO: cannot include "ReadClient._h" because interaction-model backreference
# Name with _ so that linter does not recognize it
]
}

Expand Down
10 changes: 5 additions & 5 deletions src/app/EventLoggingTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

#include <access/SubjectDescriptor.h>
#include <app/EventPathParams.h>
#include <app/ObjectList.h>
#include <app/util/basic-types.h>
#include <lib/core/CHIPCore.h>
#include <lib/core/Optional.h>
#include <lib/core/TLV.h>
#include <lib/support/LinkedList.h>
#include <system/SystemPacketBuffer.h>

inline constexpr size_t kNumPriorityLevel = 3;
Expand Down Expand Up @@ -151,10 +151,10 @@ struct EventLoadOutContext
EventNumber mStartingEventNumber = 0;
Timestamp mPreviousTime;
Timestamp mCurrentTime;
EventNumber mCurrentEventNumber = 0;
size_t mEventCount = 0;
const ObjectList<EventPathParams> * mpInterestedEventPaths = nullptr;
bool mFirst = true;
EventNumber mCurrentEventNumber = 0;
size_t mEventCount = 0;
const SingleLinkedListNode<EventPathParams> * mpInterestedEventPaths = nullptr;
bool mFirst = true;
Access::SubjectDescriptor mSubjectDescriptor;
};
} // namespace app
Expand Down
2 changes: 1 addition & 1 deletion src/app/EventManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ CHIP_ERROR EventManagement::CopyEventsSince(const TLVReader & aReader, size_t aD
return err;
}

CHIP_ERROR EventManagement::FetchEventsSince(TLVWriter & aWriter, const ObjectList<EventPathParams> * apEventPathList,
CHIP_ERROR EventManagement::FetchEventsSince(TLVWriter & aWriter, const SingleLinkedListNode<EventPathParams> * apEventPathList,
EventNumber & aEventMin, size_t & aEventCount,
const Access::SubjectDescriptor & aSubjectDescriptor)
{
Expand Down
4 changes: 2 additions & 2 deletions src/app/EventManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
#include <access/SubjectDescriptor.h>
#include <app/MessageDef/EventDataIB.h>
#include <app/MessageDef/StatusIB.h>
#include <app/ObjectList.h>
#include <app/util/basic-types.h>
#include <lib/core/TLVCircularBuffer.h>
#include <lib/support/CHIPCounter.h>
#include <lib/support/LinkedList.h>
#include <messaging/ExchangeMgr.h>
#include <platform/CHIPDeviceConfig.h>
#include <system/SystemClock.h>
Expand Down Expand Up @@ -359,7 +359,7 @@ class EventManagement
* available.
*
*/
CHIP_ERROR FetchEventsSince(chip::TLV::TLVWriter & aWriter, const ObjectList<EventPathParams> * apEventPathList,
CHIP_ERROR FetchEventsSince(chip::TLV::TLVWriter & aWriter, const SingleLinkedListNode<EventPathParams> * apEventPathList,
EventNumber & aEventMin, size_t & aEventCount,
const Access::SubjectDescriptor & aSubjectDescriptor);
/**
Expand Down
32 changes: 17 additions & 15 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ CHIP_ERROR InteractionModelEngine::ParseAttributePaths(const Access::SubjectDesc
// This avoids the 'parse all paths' approach that is employed in ReadHandler since we want to
// avoid allocating out of the path store during this minimal initial processing stage.
//
ObjectList<AttributePathParams> paramsList;
SingleLinkedListNode<AttributePathParams> paramsList;

ReturnErrorOnFailure(path.Init(pathReader));
ReturnErrorOnFailure(path.ParsePath(paramsList.mValue));
Expand Down Expand Up @@ -1513,12 +1513,12 @@ bool InteractionModelEngine::HasConflictWriteRequests(const WriteHandler * apWri
return false;
}

void InteractionModelEngine::ReleaseAttributePathList(ObjectList<AttributePathParams> *& aAttributePathList)
void InteractionModelEngine::ReleaseAttributePathList(SingleLinkedListNode<AttributePathParams> *& aAttributePathList)
{
ReleasePool(aAttributePathList, mAttributePathPool);
}

CHIP_ERROR InteractionModelEngine::PushFrontAttributePathList(ObjectList<AttributePathParams> *& aAttributePathList,
CHIP_ERROR InteractionModelEngine::PushFrontAttributePathList(SingleLinkedListNode<AttributePathParams> *& aAttributePathList,
AttributePathParams & aAttributePath)
{
CHIP_ERROR err = PushFront(aAttributePathList, aAttributePath, mAttributePathPool);
Expand All @@ -1530,10 +1530,10 @@ CHIP_ERROR InteractionModelEngine::PushFrontAttributePathList(ObjectList<Attribu
return err;
}

void InteractionModelEngine::RemoveDuplicateConcreteAttributePath(ObjectList<AttributePathParams> *& aAttributePaths)
void InteractionModelEngine::RemoveDuplicateConcreteAttributePath(SingleLinkedListNode<AttributePathParams> *& aAttributePaths)
{
ObjectList<AttributePathParams> * prev = nullptr;
auto * path1 = aAttributePaths;
SingleLinkedListNode<AttributePathParams> * prev = nullptr;
auto * path1 = aAttributePaths;

while (path1 != nullptr)
{
Expand Down Expand Up @@ -1585,12 +1585,12 @@ void InteractionModelEngine::RemoveDuplicateConcreteAttributePath(ObjectList<Att
}
}

void InteractionModelEngine::ReleaseEventPathList(ObjectList<EventPathParams> *& aEventPathList)
void InteractionModelEngine::ReleaseEventPathList(SingleLinkedListNode<EventPathParams> *& aEventPathList)
{
ReleasePool(aEventPathList, mEventPathPool);
}

CHIP_ERROR InteractionModelEngine::PushFrontEventPathParamsList(ObjectList<EventPathParams> *& aEventPathList,
CHIP_ERROR InteractionModelEngine::PushFrontEventPathParamsList(SingleLinkedListNode<EventPathParams> *& aEventPathList,
EventPathParams & aEventPath)
{
CHIP_ERROR err = PushFront(aEventPathList, aEventPath, mEventPathPool);
Expand All @@ -1602,12 +1602,12 @@ CHIP_ERROR InteractionModelEngine::PushFrontEventPathParamsList(ObjectList<Event
return err;
}

void InteractionModelEngine::ReleaseDataVersionFilterList(ObjectList<DataVersionFilter> *& aDataVersionFilterList)
void InteractionModelEngine::ReleaseDataVersionFilterList(SingleLinkedListNode<DataVersionFilter> *& aDataVersionFilterList)
{
ReleasePool(aDataVersionFilterList, mDataVersionFilterPool);
}

CHIP_ERROR InteractionModelEngine::PushFrontDataVersionFilterList(ObjectList<DataVersionFilter> *& aDataVersionFilterList,
CHIP_ERROR InteractionModelEngine::PushFrontDataVersionFilterList(SingleLinkedListNode<DataVersionFilter> *& aDataVersionFilterList,
DataVersionFilter & aDataVersionFilter)
{
CHIP_ERROR err = PushFront(aDataVersionFilterList, aDataVersionFilter, mDataVersionFilterPool);
Expand All @@ -1620,12 +1620,13 @@ CHIP_ERROR InteractionModelEngine::PushFrontDataVersionFilterList(ObjectList<Dat
}

template <typename T, size_t N>
void InteractionModelEngine::ReleasePool(ObjectList<T> *& aObjectList, ObjectPool<ObjectList<T>, N> & aObjectPool)
void InteractionModelEngine::ReleasePool(SingleLinkedListNode<T> *& aObjectList,
ObjectPool<SingleLinkedListNode<T>, N> & aObjectPool)
{
ObjectList<T> * current = aObjectList;
SingleLinkedListNode<T> * current = aObjectList;
while (current != nullptr)
{
ObjectList<T> * nextObject = current->mpNext;
SingleLinkedListNode<T> * nextObject = current->mpNext;
aObjectPool.ReleaseObject(current);
current = nextObject;
}
Expand All @@ -1634,9 +1635,10 @@ void InteractionModelEngine::ReleasePool(ObjectList<T> *& aObjectList, ObjectPoo
}

template <typename T, size_t N>
CHIP_ERROR InteractionModelEngine::PushFront(ObjectList<T> *& aObjectList, T & aData, ObjectPool<ObjectList<T>, N> & aObjectPool)
CHIP_ERROR InteractionModelEngine::PushFront(SingleLinkedListNode<T> *& aObjectList, T & aData,
ObjectPool<SingleLinkedListNode<T>, N> & aObjectPool)
{
ObjectList<T> * object = aObjectPool.CreateObject();
SingleLinkedListNode<T> * object = aObjectPool.CreateObject();
if (object == nullptr)
{
return CHIP_ERROR_NO_MEMORY;
Expand Down
26 changes: 13 additions & 13 deletions src/app/InteractionModelEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <app/EventPathParams.h>
#include <app/MessageDef/AttributeReportIBs.h>
#include <app/MessageDef/ReportDataMessage.h>
#include <app/ObjectList.h>
#include <app/ReadClient.h>
#include <app/ReadHandler.h>
#include <app/StatusResponse.h>
Expand All @@ -54,6 +53,7 @@
#include <lib/core/CHIPCore.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/DLLUtil.h>
#include <lib/support/LinkedList.h>
#include <lib/support/Pool.h>
#include <lib/support/logging/CHIPLogging.h>
#include <messaging/ExchangeContext.h>
Expand Down Expand Up @@ -187,22 +187,22 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,

reporting::ReportScheduler * GetReportScheduler() { return mReportScheduler; }

void ReleaseAttributePathList(ObjectList<AttributePathParams> *& aAttributePathList);
void ReleaseAttributePathList(SingleLinkedListNode<AttributePathParams> *& aAttributePathList);

CHIP_ERROR PushFrontAttributePathList(ObjectList<AttributePathParams> *& aAttributePathList,
CHIP_ERROR PushFrontAttributePathList(SingleLinkedListNode<AttributePathParams> *& aAttributePathList,
AttributePathParams & aAttributePath);

// If a concrete path indicates an attribute that is also referenced by a wildcard path in the request,
// the path SHALL be removed from the list.
void RemoveDuplicateConcreteAttributePath(ObjectList<AttributePathParams> *& aAttributePaths);
void RemoveDuplicateConcreteAttributePath(SingleLinkedListNode<AttributePathParams> *& aAttributePaths);

void ReleaseEventPathList(ObjectList<EventPathParams> *& aEventPathList);
void ReleaseEventPathList(SingleLinkedListNode<EventPathParams> *& aEventPathList);

CHIP_ERROR PushFrontEventPathParamsList(ObjectList<EventPathParams> *& aEventPathList, EventPathParams & aEventPath);
CHIP_ERROR PushFrontEventPathParamsList(SingleLinkedListNode<EventPathParams> *& aEventPathList, EventPathParams & aEventPath);

void ReleaseDataVersionFilterList(ObjectList<DataVersionFilter> *& aDataVersionFilterList);
void ReleaseDataVersionFilterList(SingleLinkedListNode<DataVersionFilter> *& aDataVersionFilterList);

CHIP_ERROR PushFrontDataVersionFilterList(ObjectList<DataVersionFilter> *& aDataVersionFilterList,
CHIP_ERROR PushFrontDataVersionFilterList(SingleLinkedListNode<DataVersionFilter> *& aDataVersionFilterList,
DataVersionFilter & aDataVersionFilter);

CHIP_ERROR RegisterCommandHandler(CommandHandlerInterface * handler);
Expand Down Expand Up @@ -576,9 +576,9 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
static void ResumeSubscriptionsTimerCallback(System::Layer * apSystemLayer, void * apAppState);

template <typename T, size_t N>
void ReleasePool(ObjectList<T> *& aObjectList, ObjectPool<ObjectList<T>, N> & aObjectPool);
void ReleasePool(SingleLinkedListNode<T> *& aObjectList, ObjectPool<SingleLinkedListNode<T>, N> & aObjectPool);
template <typename T, size_t N>
CHIP_ERROR PushFront(ObjectList<T> *& aObjectList, T & aData, ObjectPool<ObjectList<T>, N> & aObjectPool);
CHIP_ERROR PushFront(SingleLinkedListNode<T> *& aObjectList, T & aData, ObjectPool<SingleLinkedListNode<T>, N> & aObjectPool);

Messaging::ExchangeManager * mpExchangeMgr = nullptr;

Expand Down Expand Up @@ -606,13 +606,13 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
"CHIP_IM_MAX_NUM_READS is too small to match the requirements of spec 8.5.1");
#endif

ObjectPool<ObjectList<AttributePathParams>,
ObjectPool<SingleLinkedListNode<AttributePathParams>,
CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_READS + CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_SUBSCRIPTIONS>
mAttributePathPool;
ObjectPool<ObjectList<EventPathParams>,
ObjectPool<SingleLinkedListNode<EventPathParams>,
CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_READS + CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_SUBSCRIPTIONS>
mEventPathPool;
ObjectPool<ObjectList<DataVersionFilter>,
ObjectPool<SingleLinkedListNode<DataVersionFilter>,
CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_READS + CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_SUBSCRIPTIONS>
mDataVersionFilterPool;

Expand Down
2 changes: 1 addition & 1 deletion src/app/ReadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void ReadHandler::OnSubscriptionResumed(const SessionHandle & sessionHandle,

MoveToState(HandlerState::CanStartReporting);

ObjectList<AttributePathParams> * attributePath = mpAttributePathList;
SingleLinkedListNode<AttributePathParams> * attributePath = mpAttributePathList;
while (attributePath)
{
mManagementCallback.GetInteractionModelEngine()->GetReportingEngine().SetDirty(attributePath->mValue);
Expand Down
Loading

0 comments on commit a3d0a86

Please sign in to comment.