-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[YAML] Generates write attribute methods for non writeable attributes (…
…#9554) * Add {{clusterName}}ClusterTest interfaces with write methods for non-writeable attributes * Add Objc Test{{clusterName}} interfaces with write methods for non-writeable attributes * Remove some disabled flags from some tests trying to write to ClusterRevision/FeatureMap * Update generated content
- Loading branch information
1 parent
535feb0
commit 96e825a
Showing
23 changed files
with
10,671 additions
and
616 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "CHIP Tests templates", | ||
"version": "chip-v1", | ||
"helpers": [ | ||
"../../../zap-templates/common/StringHelper.js", | ||
"../../../zap-templates/templates/app/helper.js", | ||
"../../../zap-templates/templates/chip/helper.js" | ||
], | ||
"override": "../../../zap-templates/common/override.js", | ||
"partials": [ | ||
{ | ||
"name": "header", | ||
"path": "../../../zap-templates/partials/header.zapt" | ||
} | ||
], | ||
"templates": [ | ||
{ | ||
"path": "../../../zap-templates/templates/app/tests/CHIPClusters.zapt", | ||
"name": "Tests C++ API Header", | ||
"output": "tests/CHIPClusters.h" | ||
}, | ||
{ | ||
"path": "../../../zap-templates/templates/app/tests/CHIPClusters-src.zapt", | ||
"name": "Tests C++ API", | ||
"output": "tests/CHIPClusters.cpp" | ||
} | ||
] | ||
} |
49 changes: 49 additions & 0 deletions
49
src/app/zap-templates/templates/app/tests/CHIPClusters-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,49 @@ | ||
{{#if (chip_has_client_clusters)}} | ||
{{> header}} | ||
|
||
#include "CHIPClusters.h" | ||
|
||
#include <app/InteractionModelEngine.h> | ||
#include <app/util/basic-types.h> | ||
|
||
#include <app-common/zap-generated/ids/Attributes.h> | ||
#include <zap-generated/CHIPClientCallbacks.h> | ||
|
||
using namespace chip::app::Clusters; | ||
using namespace chip::System; | ||
using namespace chip::Encoding::LittleEndian; | ||
|
||
namespace chip { | ||
namespace Controller { | ||
|
||
{{#chip_client_clusters}} | ||
|
||
{{#chip_server_cluster_attributes}} | ||
{{#unless isWritableAttribute}} | ||
{{#unless isList}} | ||
{{#unless isStruct}} | ||
CHIP_ERROR {{asUpperCamelCase parent.name}}ClusterTest::WriteAttribute{{asUpperCamelCase name}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, {{chipType}} {{asLowerCamelCase name}}) | ||
{ | ||
app::WriteClientHandle handle; | ||
chip::app::AttributePathParams attributePath; | ||
attributePath.mNodeId = mDevice->GetDeviceId(); | ||
attributePath.mEndpointId = mEndpoint; | ||
attributePath.mClusterId = mClusterId; | ||
attributePath.mFieldId = {{#if isGlobalAttribute}}Globals{{else}}{{asUpperCamelCase parent.name}}{{/if}}::Attributes::Ids::{{asUpperCamelCase name}}; | ||
attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); | ||
|
||
ReturnErrorOnFailure(app::InteractionModelEngine::GetInstance()->NewWriteClient(handle)); | ||
ReturnErrorOnFailure(handle.EncodeScalarAttributeWritePayload(attributePath, {{asLowerCamelCase name}})); | ||
|
||
return mDevice->SendWriteAttributeRequest(std::move(handle), onSuccessCallback, onFailureCallback); | ||
} | ||
|
||
{{/unless}} | ||
{{/unless}} | ||
{{/unless}} | ||
{{/chip_server_cluster_attributes}} | ||
{{/chip_client_clusters}} | ||
|
||
} // namespace Controller | ||
} // namespace chip | ||
{{/if}} |
32 changes: 32 additions & 0 deletions
32
src/app/zap-templates/templates/app/tests/CHIPClusters.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,32 @@ | ||
{{#if (chip_has_client_clusters)}} | ||
{{> header}} | ||
|
||
#pragma once | ||
|
||
#include <zap-generated/CHIPClusters.h> | ||
|
||
namespace chip { | ||
namespace Controller { | ||
|
||
{{#chip_client_clusters}} | ||
class DLL_EXPORT {{asUpperCamelCase name}}ClusterTest : public {{asUpperCamelCase name}}Cluster | ||
{ | ||
public: | ||
{{asUpperCamelCase name}}ClusterTest() : {{asUpperCamelCase name}}Cluster() {} | ||
~{{asUpperCamelCase name}}ClusterTest() {} | ||
|
||
{{#chip_server_cluster_attributes}} | ||
{{#unless isWritableAttribute}} | ||
{{#unless isList}} | ||
{{#unless isStruct}} | ||
CHIP_ERROR WriteAttribute{{asUpperCamelCase name}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, {{chipType}} value); | ||
{{/unless}} | ||
{{/unless}} | ||
{{/unless}} | ||
{{/chip_server_cluster_attributes}} | ||
}; | ||
|
||
{{/chip_client_clusters}} | ||
} // namespace Controller | ||
} // namespace chip | ||
{{/if}} |
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
50 changes: 50 additions & 0 deletions
50
src/darwin/Framework/CHIP/templates/CHIPTestClustersObjc-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,50 @@ | ||
{{#if (chip_has_client_clusters)}} | ||
{{> header}} | ||
#import <Foundation/Foundation.h> | ||
|
||
#import "CHIPCallbackBridge_internal.h" | ||
#import "CHIPCluster_internal.h" | ||
#import "CHIPDevice.h" | ||
#import "CHIPDevice_Internal.h" | ||
|
||
#import "zap-generated/tests/CHIPClusters.h" | ||
#import "zap-generated/CHIPTestClustersObjc.h" | ||
|
||
using chip::Callback::Cancelable; | ||
|
||
{{#chip_client_clusters}} | ||
|
||
@interface CHIPTest{{asUpperCamelCase name}} () | ||
@property (readonly) chip::Controller::{{asUpperCamelCase name}}ClusterTest cppCluster; | ||
@end | ||
|
||
@implementation CHIPTest{{asUpperCamelCase name}} | ||
|
||
- (chip::Controller::ClusterBase *)getCluster | ||
{ | ||
return &_cppCluster; | ||
} | ||
|
||
{{#chip_server_cluster_attributes}} | ||
{{#unless isWritableAttribute}} | ||
{{#unless isList}} | ||
{{#unless isStruct}} | ||
{{#*inline "attribute"}}Attribute{{asUpperCamelCase name}}{{/inline}} | ||
{{#*inline "callbackName"}}DefaultSuccess{{/inline}} | ||
{{#*inline "callbackParams"}}, {{#if (isString type)}}[self asSpan:{{/if}}value{{#if (isString type)}}]{{/if}}{{/inline}} | ||
- (void)write{{>attribute}}WithValue:({{asObjectiveCBasicType type}})value responseHandler:(ResponseHandler)responseHandler | ||
{ | ||
new CHIP{{>callbackName}}CallbackBridge(self.callbackQueue, responseHandler, ^(Cancelable * success, Cancelable * failure) { | ||
return self.cppCluster.Write{{>attribute}}(success, failure{{>callbackParams}}); | ||
}); | ||
} | ||
|
||
{{/unless}} | ||
{{/unless}} | ||
{{/unless}} | ||
{{/chip_server_cluster_attributes}} | ||
|
||
@end | ||
|
||
{{/chip_client_clusters}} | ||
{{/if}} |
33 changes: 33 additions & 0 deletions
33
src/darwin/Framework/CHIP/templates/CHIPTestClustersObjc.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,33 @@ | ||
{{#if (chip_has_client_clusters)}} | ||
{{> header}} | ||
|
||
#import <CHIP/CHIPClustersObjc.h> | ||
|
||
@class CHIPDevice; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
{{#chip_client_clusters}} | ||
|
||
/** | ||
* Cluster {{name}} | ||
* {{description}} | ||
*/ | ||
@interface CHIPTest{{asUpperCamelCase name}} : CHIP{{asUpperCamelCase name}} | ||
|
||
{{#chip_server_cluster_attributes}} | ||
{{#unless isWritableAttribute}} | ||
{{#unless isList}} | ||
{{#unless isStruct}} | ||
- (void)writeAttribute{{asUpperCamelCase name}}WithValue:({{asObjectiveCBasicType type}})value responseHandler:(ResponseHandler)responseHandler; | ||
{{/unless}} | ||
{{/unless}} | ||
{{/unless}} | ||
{{/chip_server_cluster_attributes}} | ||
|
||
@end | ||
|
||
{{/chip_client_clusters}} | ||
|
||
NS_ASSUME_NONNULL_END | ||
{{/if}} |
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
Oops, something went wrong.