-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This splits up CHIPClusters.cpp into a couple of different files: - CHIPClusters.cpp contains no template specialized methods. - CHIPClustersInvoke.cpp contains all template specialized methods for invoking commands. - CHIPClustersWrite.cpp contains all template specialized methods for doing writes. This resulted in a speed-up of about 30s (from 1m50s to 1m20s) when doing an incremental compilation of chip-tool after touching CHIPClusters.cpp. It does this by better leveraging -jX builds to parallelize compilation. More importantly, this might also provide a pattern for others (like Android) that is running into OOM issues with clang compiling CHIPClusters.cpp.
- Loading branch information
1 parent
30fd6f9
commit d3e2f1e
Showing
39 changed files
with
2,898 additions
and
1,734 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
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
67 changes: 67 additions & 0 deletions
67
src/app/zap-templates/templates/app/CHIPClustersInvoke-src.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,67 @@ | ||
{{> header}} | ||
|
||
{{#if (chip_has_client_clusters)}} | ||
#include "CHIPClusters.h" | ||
|
||
#include <cstdint> | ||
|
||
|
||
#include <app/InteractionModelEngine.h> | ||
#include <app/chip-zcl-zpro-codec.h> | ||
#include <app/util/basic-types.h> | ||
#include <app/CommandSender.h> | ||
#include <app-common/zap-generated/cluster-objects.h> | ||
#include <app-common/zap-generated/ids/Attributes.h> | ||
#include <controller/CommandSenderAllocator.h> | ||
#include <lib/core/CHIPSafeCasts.h> | ||
#include <lib/support/BufferWriter.h> | ||
#include <lib/support/CodeUtils.h> | ||
#include <lib/support/SafeInt.h> | ||
#include <lib/support/CHIPMem.h> | ||
#include <lib/support/logging/CHIPLogging.h> | ||
#include <system/SystemPacketBuffer.h> | ||
#include <zap-generated/CHIPClientCallbacks.h> | ||
|
||
namespace chip { | ||
|
||
using namespace app::Clusters; | ||
using namespace System; | ||
using namespace Encoding::LittleEndian; | ||
|
||
namespace Controller { | ||
|
||
// TODO(#4502): onCompletion is not used by IM for now. | ||
// TODO(#4503): length should be passed to commands when byte string is in argument list. | ||
// TODO(#4503): Commands should take group id as an argument. | ||
|
||
{{#chip_client_clusters}} | ||
|
||
{{#chip_cluster_commands}} | ||
{{#*inline "requestType"}}chip::app::Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::Type{{/inline}} | ||
{{#*inline "responseType"}}chip::app::{{#if hasSpecificResponse}}Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase response.name}}::DecodableType{{else}}DataModel::NullObjectType{{/if}}{{/inline}} | ||
template CHIP_ERROR ClusterBase::InvokeCommand<{{>requestType}}, {{>responseType}}>(const {{>requestType}} &, void *, CommandResponseSuccessCallback<{{>responseType}}>, CommandResponseFailureCallback); | ||
{{/chip_cluster_commands}} | ||
{{/chip_client_clusters}} | ||
|
||
template <typename RequestDataT, typename ResponseDataT> | ||
CHIP_ERROR ClusterBase::InvokeCommand(const RequestDataT & requestData, void * context, | ||
CommandResponseSuccessCallback<ResponseDataT> successCb, CommandResponseFailureCallback failureCb) | ||
{ | ||
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); | ||
ReturnErrorOnFailure(mDevice->LoadSecureSessionParametersIfNeeded()); | ||
|
||
auto onSuccessCb = [context, successCb](const app::ConcreteCommandPath & commandPath, const app::StatusIB & aStatus, const ResponseDataT & responseData) { | ||
successCb(context, responseData); | ||
}; | ||
|
||
auto onFailureCb = [context, failureCb](const app::StatusIB & aStatus, CHIP_ERROR aError) { | ||
failureCb(context, app::ToEmberAfStatus(aStatus.mStatus)); | ||
}; | ||
|
||
return InvokeCommandRequest<ResponseDataT>(mDevice->GetExchangeManager(), mDevice->GetSecureSession().Value(), mEndpoint, | ||
requestData, onSuccessCb, onFailureCb); | ||
}; | ||
|
||
} // namespace Controller | ||
} // namespace chip | ||
{{/if}} |
77 changes: 77 additions & 0 deletions
77
src/app/zap-templates/templates/app/CHIPClustersWrite-src.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 @@ | ||
{{> header}} | ||
|
||
{{#if (chip_has_client_clusters)}} | ||
#include "CHIPClusters.h" | ||
|
||
#include <cstdint> | ||
|
||
|
||
#include <app/InteractionModelEngine.h> | ||
#include <app/chip-zcl-zpro-codec.h> | ||
#include <app/util/basic-types.h> | ||
#include <app/CommandSender.h> | ||
#include <app-common/zap-generated/cluster-objects.h> | ||
#include <app-common/zap-generated/ids/Attributes.h> | ||
#include <controller/CommandSenderAllocator.h> | ||
#include <lib/core/CHIPSafeCasts.h> | ||
#include <lib/support/BufferWriter.h> | ||
#include <lib/support/CodeUtils.h> | ||
#include <lib/support/SafeInt.h> | ||
#include <lib/support/CHIPMem.h> | ||
#include <lib/support/logging/CHIPLogging.h> | ||
#include <system/SystemPacketBuffer.h> | ||
#include <zap-generated/CHIPClientCallbacks.h> | ||
|
||
namespace chip { | ||
|
||
using namespace app::Clusters; | ||
using namespace System; | ||
using namespace Encoding::LittleEndian; | ||
|
||
namespace Controller { | ||
|
||
// TODO(#4502): onCompletion is not used by IM for now. | ||
// TODO(#4503): length should be passed to commands when byte string is in argument list. | ||
// TODO(#4503): Commands should take group id as an argument. | ||
|
||
{{#chip_client_clusters}} | ||
|
||
// {{asUpperCamelCase name}} Cluster Attributes | ||
{{#chip_server_cluster_attributes}} | ||
{{#if isWritableAttribute}} | ||
{{#*inline "attributeTypeInfo"}}chip::app::Clusters::{{asUpperCamelCase parent.name}}::Attributes::{{asUpperCamelCase name}}::TypeInfo{{/inline}} | ||
template CHIP_ERROR ClusterBase::WriteAttribute<{{>attributeTypeInfo}}>(const {{>attributeTypeInfo}}::Type & requestData, void *context, | ||
WriteResponseSuccessCallback successCb, WriteResponseFailureCallback failureCb); | ||
{{/if}} | ||
{{/chip_server_cluster_attributes}} | ||
{{/chip_client_clusters}} | ||
|
||
template <typename AttributeInfo> | ||
CHIP_ERROR ClusterBase::WriteAttribute(const typename AttributeInfo::Type & requestData, void * context, | ||
WriteResponseSuccessCallback successCb, WriteResponseFailureCallback failureCb) | ||
{ | ||
VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); | ||
ReturnErrorOnFailure(mDevice->LoadSecureSessionParametersIfNeeded()); | ||
|
||
auto onSuccessCb = [context, successCb](const app::ConcreteAttributePath & commandPath) { | ||
if (successCb != nullptr) | ||
{ | ||
successCb(context); | ||
} | ||
}; | ||
|
||
auto onFailureCb = [context, failureCb](const app::ConcreteAttributePath * commandPath, | ||
app::StatusIB status, CHIP_ERROR aError) { | ||
if (failureCb != nullptr) | ||
{ | ||
failureCb(context, app::ToEmberAfStatus(status.mStatus)); | ||
} | ||
}; | ||
|
||
return chip::Controller::WriteAttribute<AttributeInfo>(mDevice->GetExchangeManager(), mDevice->GetSecureSession().Value(), mEndpoint, | ||
requestData, onSuccessCb, onFailureCb); | ||
} | ||
|
||
} // namespace Controller | ||
} // namespace chip | ||
{{/if}} |
18 changes: 18 additions & 0 deletions
18
zzz_generated/all-clusters-app/zap-generated/CHIPClustersInvoke.cpp
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
zzz_generated/all-clusters-app/zap-generated/CHIPClustersWrite.cpp
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
zzz_generated/bridge-app/zap-generated/CHIPClustersInvoke.cpp
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
zzz_generated/bridge-app/zap-generated/CHIPClustersWrite.cpp
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.