Skip to content

Commit

Permalink
Use Objective-C naming convention for Cluster method names (#6442)
Browse files Browse the repository at this point in the history
* Use ObjC naming convention for Cluster Method names

* Add generated files

* Update CHIP Tool

* Restyled by clang-format

* Fix tests

* Regenrate the test source

* Fix responseHandler name

* Regenerate tests

* Regen everything again

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Jun 7, 2021
1 parent 81bfb05 commit 3770818
Show file tree
Hide file tree
Showing 14 changed files with 8,701 additions and 8,687 deletions.
916 changes: 454 additions & 462 deletions examples/chip-tool/gen/CHIPClustersObjc.h

Large diffs are not rendered by default.

4,365 changes: 2,176 additions & 2,189 deletions examples/chip-tool/gen/CHIPClustersObjc.mm

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions src/app/zap-templates/templates/app/CHIPClustersObjc-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -590,25 +590,25 @@ private:

{{#chip_server_cluster_commands}}
{{#if (zcl_command_arguments_count this.id)}}
- (void){{asCamelCased name}}:{{#chip_server_cluster_command_arguments}}{{#if (isFirstElement index)}}{{else}}{{asCamelCased label}}:{{/if}}({{asObjectiveCBasicType type}}){{asCamelCased label}} {{/chip_server_cluster_command_arguments}}completionHandler:(ResponseHandler)completionHandler
- (void){{asCamelCased name}}:{{#chip_server_cluster_command_arguments}}{{#if (isFirstElement index)}}{{else}}{{asCamelCased label}}:{{/if}}({{asObjectiveCBasicType type}}){{asCamelCased label}} {{/chip_server_cluster_command_arguments}}responseHandler:(ResponseHandler)responseHandler
{{else}}
- (void){{asCamelCased name}}:(ResponseHandler)completionHandler
- (void){{asCamelCased name}}:(ResponseHandler)responseHandler
{{/if}}
{
{{#if (hasSpecificResponse name)}}
CHIP{{asCamelCased parent.name false}}Cluster{{asCamelCased name false}}ResponseCallbackBridge * onSuccess = new CHIP{{asCamelCased parent.name false}}Cluster{{asCamelCased name false}}ResponseCallbackBridge(completionHandler, [self callbackQueue]);
CHIP{{asCamelCased parent.name false}}Cluster{{asCamelCased name false}}ResponseCallbackBridge * onSuccess = new CHIP{{asCamelCased parent.name false}}Cluster{{asCamelCased name false}}ResponseCallbackBridge(responseHandler, [self callbackQueue]);
{{else}}
CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
{{/if}}
if (!onSuccess) {
completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
return;
}

CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
if (!onFailure) {
delete onSuccess;
completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
return;
}

Expand All @@ -620,28 +620,28 @@ private:
if (err != CHIP_NO_ERROR) {
delete onSuccess;
delete onFailure;
completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
}
}
{{/chip_server_cluster_commands}}

{{#chip_server_cluster_attributes}}
- (void)readAttribute{{asCamelCased name false}}:(ResponseHandler)completionHandler
- (void)readAttribute{{asCamelCased name false}}WithResponseHandler:(ResponseHandler)responseHandler
{
{{#if isList}}
CHIP{{asCamelCased parent.name false}}{{asCamelCased name false}}AttributeCallbackBridge * onSuccess = new CHIP{{asCamelCased parent.name false}}{{asCamelCased name false}}AttributeCallbackBridge(completionHandler, [self callbackQueue]);
CHIP{{asCamelCased parent.name false}}{{asCamelCased name false}}AttributeCallbackBridge * onSuccess = new CHIP{{asCamelCased parent.name false}}{{asCamelCased name false}}AttributeCallbackBridge(responseHandler, [self callbackQueue]);
{{else}}
CHIP{{asCallbackAttributeType atomicTypeId}}AttributeCallbackBridge * onSuccess = new CHIP{{asCallbackAttributeType atomicTypeId}}AttributeCallbackBridge(completionHandler, [self callbackQueue]{{#if (isString type)}},{{#if (isOctetString type)}}true{{else}}false{{/if}}{{/if}});
CHIP{{asCallbackAttributeType atomicTypeId}}AttributeCallbackBridge * onSuccess = new CHIP{{asCallbackAttributeType atomicTypeId}}AttributeCallbackBridge(responseHandler, [self callbackQueue]{{#if (isString type)}},{{#if (isOctetString type)}}true{{else}}false{{/if}}{{/if}});
{{/if}}
if (!onSuccess) {
completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
return;
}

CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
if (!onFailure) {
delete onSuccess;
completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
return;
}

Expand All @@ -653,23 +653,23 @@ private:
if (err != CHIP_NO_ERROR) {
delete onSuccess;
delete onFailure;
completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
}
}

{{#if (isWritableAttribute)}}
- (void)writeAttribute{{asCamelCased name false}}:({{asObjectiveCBasicType type}})value completionHandler:(ResponseHandler)completionHandler
- (void)writeAttribute{{asCamelCased name false}}WithValue:({{asObjectiveCBasicType type}})value responseHandler:(ResponseHandler)responseHandler
{
CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
if (!onSuccess) {
completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
return;
}

CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
if (!onFailure) {
delete onSuccess;
completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
return;
}

Expand All @@ -688,24 +688,24 @@ private:
if (err != CHIP_NO_ERROR) {
delete onSuccess;
delete onFailure;
completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
}
}

{{/if}}
{{#if (isReportableAttribute)}}
- (void) configureAttribute{{asCamelCased name false}}:(uint16_t)minInterval maxInterval:(uint16_t)maxInterval{{#unless (isDiscreteType)}} change:({{chipType}})change{{/unless}} completionHandler:(ResponseHandler)completionHandler
- (void) configureAttribute{{asCamelCased name false}}WithMinInterval:(uint16_t)minInterval maxInterval:(uint16_t)maxInterval{{#unless (isDiscreteType)}} change:({{chipType}})change{{/unless}} responseHandler:(ResponseHandler)responseHandler
{
CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]);
CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
if (!onSuccess) {
completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
return;
}

CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]);
CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
if (!onFailure) {
delete onSuccess;
completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
return;
}

Expand All @@ -718,11 +718,11 @@ private:
if (err != CHIP_NO_ERROR) {
delete onSuccess;
delete onFailure;
completionHandler([CHIPError errorForCHIPErrorCode:err], nil);
responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
}
}

- (void) reportAttribute{{asCamelCased name false}}:(ResponseHandler)reportHandler
- (void) reportAttribute{{asCamelCased name false}}WithResponseHandler:(ResponseHandler)reportHandler
{
CHIP{{asCallbackAttributeType atomicTypeId}}AttributeCallbackBridge * onReport = new CHIP{{asCallbackAttributeType atomicTypeId}}AttributeCallbackBridge(reportHandler, [self callbackQueue]{{#if (isString type)}},{{#if (isOctetString type)}}true{{else}}false{{/if}}{{/if}}, true);
if (!onReport) {
Expand Down
12 changes: 6 additions & 6 deletions src/app/zap-templates/templates/app/CHIPClustersObjc.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ NS_ASSUME_NONNULL_BEGIN

{{#chip_server_cluster_commands}}
{{#if (zcl_command_arguments_count this.id)}}
- (void){{asCamelCased name}}:{{#chip_server_cluster_command_arguments}}{{#if (isFirstElement index)}}{{else}}{{asCamelCased label}}:{{/if}}({{asObjectiveCBasicType type}}){{asCamelCased label}} {{/chip_server_cluster_command_arguments}}completionHandler:(ResponseHandler)completionHandler;
- (void){{asCamelCased name}}:{{#chip_server_cluster_command_arguments}}{{#if (isFirstElement index)}}{{else}}{{asCamelCased label}}:{{/if}}({{asObjectiveCBasicType type}}){{asCamelCased label}} {{/chip_server_cluster_command_arguments}}responseHandler:(ResponseHandler)responseHandler;
{{else}}
- (void){{asCamelCased name}}:(ResponseHandler)completionHandler;
- (void){{asCamelCased name}}:(ResponseHandler)responseHandler;
{{/if}}
{{/chip_server_cluster_commands}}

{{#chip_server_cluster_attributes}}
- (void)readAttribute{{asCamelCased name false}}:(ResponseHandler)completionHandler;
- (void)readAttribute{{asCamelCased name false}}WithResponseHandler:(ResponseHandler)responseHandler;
{{#if (isWritableAttribute)}}
- (void)writeAttribute{{asCamelCased name false}}:({{asObjectiveCBasicType type}})value completionHandler:(ResponseHandler)completionHandler;
- (void)writeAttribute{{asCamelCased name false}}WithValue:({{asObjectiveCBasicType type}})value responseHandler:(ResponseHandler)responseHandler;
{{/if}}
{{#if (isReportableAttribute)}}
- (void) configureAttribute{{asCamelCased name false}}:(uint16_t)minInterval maxInterval:(uint16_t)maxInterval{{#unless (isDiscreteType)}} change:({{chipType}})change{{/unless}} completionHandler:(ResponseHandler)completionHandler;
- (void) reportAttribute{{asCamelCased name false}}:(ResponseHandler)reportHandler;
- (void) configureAttribute{{asCamelCased name false}}WithMinInterval:(uint16_t)minInterval maxInterval:(uint16_t)maxInterval{{#unless (isDiscreteType)}} change:({{chipType}})change{{/unless}} responseHandler:(ResponseHandler)responseHandler;
- (void) reportAttribute{{asCamelCased name false}}WithResponseHandler:(ResponseHandler)responseHandler;
{{/if}}
{{/chip_server_cluster_attributes}}

Expand Down
Loading

0 comments on commit 3770818

Please sign in to comment.