Skip to content

Commit

Permalink
Enable some complex type tests. (#12315)
Browse files Browse the repository at this point in the history
Codegen fixes are as follows:

* CHIPClusters: just skip structs-inside-structs as command arguments.
  This is pretty much dead code anyway, that is close to being
  removed, and existing uses of it don't involve such arguments.

* java: skip structs-inside-structs inside command arguments for now, so codegen does not fail.

* darwin: fix shadowing problems in handling of
  lists-inside-structs-indside-lists.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Aug 10, 2023
1 parent 4bf2904 commit 3586281
Show file tree
Hide file tree
Showing 24 changed files with 3,751 additions and 1,906 deletions.
9 changes: 1 addition & 8 deletions src/app/tests/suites/TestCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,6 @@ tests:

- label:
"Send Test Command With Nested Struct Argument and arg1.c.b is true"
disabled: true
command: "testNestedStructArgumentRequest"
arguments:
values:
Expand All @@ -939,7 +938,6 @@ tests:
value: true

- label: "Send Test Command With Nested Struct Argument arg1.c.b is false"
disabled: true
command: "testNestedStructArgumentRequest"
arguments:
values:
Expand Down Expand Up @@ -968,7 +966,6 @@ tests:
- label:
"Send Test Command With Nested Struct List Argument and all fields b
of arg1.d are true"
disabled: true
command: "testNestedStructListArgumentRequest"
arguments:
values:
Expand Down Expand Up @@ -1023,12 +1020,11 @@ tests:
response:
values:
- name: "value"
value: false
value: true

- label:
"Send Test Command With Nested Struct List Argument and some fields b
of arg1.d are false"
disabled: true
command: "testNestedStructListArgumentRequest"
arguments:
values:
Expand Down Expand Up @@ -1236,7 +1232,6 @@ tests:
- label:
"Send Test Command With List of Nested Struct List Argument and all
fields b of elements of arg1.d are true"
disabled: true
command: "testListNestedStructListArgumentRequest"
arguments:
values:
Expand Down Expand Up @@ -1298,7 +1293,6 @@ tests:
- label:
"Send Test Command With Nested Struct List Argument and some fields b
of elements of arg1.d are false"
disabled: true
command: "testListNestedStructListArgumentRequest"
arguments:
values:
Expand Down Expand Up @@ -2084,7 +2078,6 @@ tests:
- label: "Read attribute NULLABLE_CHAR_STRING"
command: "readAttribute"
attribute: "nullable_char_string"
disabled: true
response:
value: "☉T☉"

Expand Down
5 changes: 4 additions & 1 deletion src/app/zap-templates/templates/app/CHIPClusters-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Controller {

// {{asUpperCamelCase name}} Cluster Commands
{{#chip_cluster_commands}}
CHIP_ERROR {{asUpperCamelCase clusterName}}Cluster::{{asUpperCamelCase name}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback{{#chip_cluster_command_arguments_with_structs_expanded}}, {{chipType}} {{asLowerCamelCase label}}{{/chip_cluster_command_arguments_with_structs_expanded}})
CHIP_ERROR {{asUpperCamelCase clusterName}}Cluster::{{asUpperCamelCase name}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback{{#chip_cluster_command_arguments_with_structs_expanded}}{{#if_is_struct type}}{{else}}, {{chipType}} {{asLowerCamelCase label}}{{/if_is_struct}}{{/chip_cluster_command_arguments_with_structs_expanded}})
{
CHIP_ERROR err = CHIP_NO_ERROR;
TLV::TLVWriter * writer = nullptr;
Expand All @@ -44,6 +44,8 @@ CHIP_ERROR {{asUpperCamelCase clusterName}}Cluster::{{asUpperCamelCase name}}(Ca
SuccessOrExit(err = sender->PrepareCommand(cmdParams));

{{#chip_cluster_command_arguments_with_structs_expanded}}
{{#if_is_struct type}}
{{else}}
{{#first}}
VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
{{/first}}
Expand All @@ -53,6 +55,7 @@ CHIP_ERROR {{asUpperCamelCase clusterName}}Cluster::{{asUpperCamelCase name}}(Ca
{{else}}
SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), {{asLowerCamelCase label}}));
{{/if}}
{{/if_is_struct}}
{{else}}
// Command takes no arguments.
{{/chip_cluster_command_arguments_with_structs_expanded}}
Expand Down
2 changes: 1 addition & 1 deletion src/app/zap-templates/templates/app/CHIPClusters.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public:

// Cluster Commands
{{/first}}
CHIP_ERROR {{asUpperCamelCase name}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback{{#chip_cluster_command_arguments_with_structs_expanded}}, {{chipType}} {{asLowerCamelCase label}}{{/chip_cluster_command_arguments_with_structs_expanded}});
CHIP_ERROR {{asUpperCamelCase name}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback{{#chip_cluster_command_arguments_with_structs_expanded}}{{#if_is_struct type}}{{else}}, {{chipType}} {{asLowerCamelCase label}}{{/if_is_struct}}{{/chip_cluster_command_arguments_with_structs_expanded}});
{{/chip_cluster_commands}}

// Cluster Attributes
Expand Down
2 changes: 1 addition & 1 deletion src/app/zap-templates/zcl/data-model/chip/test-cluster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ limitations under the License.
<arg name="arg1" type="NestedStructList"/>
</command>

<command source="client" code="0x0C" name="TestListNestedStructListArgumentRequest" optional="false">
<command source="client" code="0x0C" name="TestListNestedStructListArgumentRequest" response="BooleanResponse" optional="false">
<description>
Command that takes an argument which is a list of Nested Struct List.
The response returns false if there is some struct in arg1 (either
Expand Down
6 changes: 3 additions & 3 deletions src/controller/data_model/controller-clusters.zap
Original file line number Diff line number Diff line change
Expand Up @@ -11520,7 +11520,7 @@
"mfgCode": null,
"source": "client",
"incoming": 0,
"outgoing": 0
"outgoing": 1
},
{
"name": "TestListStructArgumentRequest",
Expand All @@ -11544,15 +11544,15 @@
"mfgCode": null,
"source": "client",
"incoming": 0,
"outgoing": 0
"outgoing": 1
},
{
"name": "TestListNestedStructListArgumentRequest",
"code": 12,
"mfgCode": null,
"source": "client",
"incoming": 0,
"outgoing": 0
"outgoing": 1
},
{
"name": "TestListInt8UReverseRequest",
Expand Down
6 changes: 3 additions & 3 deletions src/controller/java/templates/ChipClusters-java.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ public class ChipClusters {
{{#chip_cluster_commands}}

public void {{asLowerCamelCase name}}({{#if hasSpecificResponse}}{{asUpperCamelCase responseName}}Callback{{else}}DefaultClusterCallback{{/if}} callback
{{#chip_cluster_command_arguments_with_structs_expanded}}{{>java_type_for_argument}} {{asLowerCamelCase label}}{{/chip_cluster_command_arguments_with_structs_expanded}}) {
{{asLowerCamelCase name}}(chipClusterPtr, callback{{#chip_cluster_command_arguments_with_structs_expanded}}, {{asLowerCamelCase label}}{{/chip_cluster_command_arguments_with_structs_expanded}});
{{#chip_cluster_command_arguments_with_structs_expanded}}{{#if_is_struct type}}{{else}}{{>java_type_for_argument}} {{asLowerCamelCase label}}{{/if_is_struct}}{{/chip_cluster_command_arguments_with_structs_expanded}}) {
{{asLowerCamelCase name}}(chipClusterPtr, callback{{#chip_cluster_command_arguments_with_structs_expanded}}{{#if_is_struct type}}{{else}}, {{asLowerCamelCase label}}{{/if_is_struct}}{{/chip_cluster_command_arguments_with_structs_expanded}});
}

{{/chip_cluster_commands}}
{{#chip_cluster_commands}}
private native void {{asLowerCamelCase name}}(long chipClusterPtr, {{#if hasSpecificResponse}}{{asUpperCamelCase responseName}}Callback{{else}}DefaultClusterCallback{{/if}} Callback
{{#chip_cluster_command_arguments_with_structs_expanded}}{{>java_type_for_argument}} {{asLowerCamelCase label}}{{/chip_cluster_command_arguments_with_structs_expanded}});
{{#chip_cluster_command_arguments_with_structs_expanded}}{{#if_is_struct type}}{{else}}{{>java_type_for_argument}} {{asLowerCamelCase label}}{{/if_is_struct}}{{/chip_cluster_command_arguments_with_structs_expanded}});
{{/chip_cluster_commands}}
{{#chip_cluster_responses}}
public interface {{asUpperCamelCase name}}Callback {
Expand Down
6 changes: 5 additions & 1 deletion src/controller/java/templates/ClusterInfo-java.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,12 @@ public class ClusterInfoMapping {
{{! TODO: fill out parameter types }}
{{#if (zcl_command_arguments_count this.id)}}
{{#chip_cluster_command_arguments_with_structs_expanded}}
{{#if_is_struct type}}
{{else}}
CommandParameterInfo {{asLowerCamelCase ../../name}}{{asLowerCamelCase ../name}}{{asLowerCamelCase label}}CommandParameterInfo = new CommandParameterInfo("{{asLowerCamelCase label}}", {{asJavaBasicType type}}.class);
{{asLowerCamelCase ../../name}}{{asLowerCamelCase ../name}}CommandParams.put("{{asLowerCamelCase label}}",{{asLowerCamelCase ../../name}}{{asLowerCamelCase ../name}}{{asLowerCamelCase label}}CommandParameterInfo);
{{#not_last}} {{/not_last}}
{{/if_is_struct}}
{{/chip_cluster_command_arguments_with_structs_expanded}}
{{else}}
{{/if}}
Expand All @@ -283,9 +286,10 @@ public class ClusterInfoMapping {
(cluster, callback, commandArguments) -> {
((ChipClusters.{{asUpperCamelCase ../name}}Cluster) cluster)
.{{asLowerCamelCase name}}((ChipClusters.{{asUpperCamelCase ../name}}Cluster.{{asUpperCamelCase responseName}}Callback) callback
{{#chip_cluster_command_arguments_with_structs_expanded}},
{{#chip_cluster_command_arguments_with_structs_expanded}}{{#if_is_struct type}}{{else}},
({{#if isOptional}}Optional<{{/if}}{{asJavaBoxedType type}}{{#if isOptional}}>{{/if}})
commandArguments.get("{{asLowerCamelCase label}}")
{{/if_is_struct}}
{{/chip_cluster_command_arguments_with_structs_expanded}}
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
, {{#if isOptional}}Optional<{{else if isNullable}}@Nullable {{/if}}{{asJavaBoxedType type}}{{#if isOptional}}>{{/if}}
{{#if_is_struct type}}{{else}}, {{#if isOptional}}Optional<{{else if isNullable}}@Nullable {{/if}}{{asJavaBoxedType type}}{{#if isOptional}}>{{/if}}{{/if_is_struct}}
122 changes: 122 additions & 0 deletions src/controller/java/zap-generated/CHIPClusters-JNI.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3586281

Please sign in to comment.