Skip to content

Commit

Permalink
Stop generating attribute accessors for AttributeAccessInterface-only…
Browse files Browse the repository at this point in the history
… attributes.

Those accessors can't work correctly and are just a bug waiting to happen if
someone tries to use them.
  • Loading branch information
bzbarsky-apple committed Apr 27, 2023
1 parent cc6c414 commit e8dee4d
Show file tree
Hide file tree
Showing 6 changed files with 1,618 additions and 6,656 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ namespace {{asUpperCamelCase parent.label}} {
namespace Attributes {

{{/first}}
{{#unless (isStrEqual storagePolicy "attributeAccessInterface")}}
{{#if_is_struct type}}
{{else if (canHaveSimpleAccessors this)}}
#error Attribute "{{name}}" in cluster "{{../name}}" is struct-typed and must be added to the attributeAccessInterfaceAttributes object in src/app/zap-templates/zcl/zcl.json and src/app/zap-templates/zcl/zcl-with-test-extensions.json
{{/if_is_struct}}
namespace {{asUpperCamelCase label}} {

{{#*inline "clusterId"}}Clusters::{{asUpperCamelCase parent.label}}::Id{{/inline}}
Expand Down Expand Up @@ -133,7 +135,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, {{zapTypeToEncodableClusterObjectTy

} // namespace {{asUpperCamelCase label}}

{{/if_is_struct}}
{{/unless}}
{{#last}}
} // namespace Attributes
} // {{asUpperCamelCase parent.label}}
Expand Down
5 changes: 2 additions & 3 deletions src/app/zap-templates/templates/app/attributes/Accessors.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ namespace {{asUpperCamelCase parent.label}} {
namespace Attributes {

{{/first}}
{{#if_is_struct type}}
{{else if (canHaveSimpleAccessors this)}}
{{#unless (isStrEqual storagePolicy "attributeAccessInterface")}}
namespace {{asUpperCamelCase label}} {
EmberAfStatus Get(chip::EndpointId endpoint, {{accessorGetterType this}} value); // {{type}}
EmberAfStatus Set(chip::EndpointId endpoint, {{zapTypeToEncodableClusterObjectType type ns=parent.name forceNotNullable=true forceNotOptional=true}} value);
Expand All @@ -34,7 +33,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, {{zapTypeToEncodableClusterObjectTy
{{/if}}
} // namespace {{asUpperCamelCase label}}

{{/if_is_struct}}
{{/unless}}
{{#last}}
} // namespace Attributes
} // {{asUpperCamelCase parent.label}}
Expand Down
13 changes: 13 additions & 0 deletions src/app/zap-templates/zcl/zcl-with-test-extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,19 @@
"PacketUnicastTxCount",
"CurrentMaxRate",
"OverrunCount"
],
"Channel": [
"Lineup",
"CurrentChannel"
],
"Media Playback": [
"SampledPosition"
],
"Application Launcher": [
"CurrentApp"
],
"Application Basic": [
"Application"
]
},
"defaultReportingPolicy": "mandatory",
Expand Down
13 changes: 13 additions & 0 deletions src/app/zap-templates/zcl/zcl.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,19 @@
"PacketUnicastTxCount",
"CurrentMaxRate",
"OverrunCount"
],
"Channel": [
"Lineup",
"CurrentChannel"
],
"Media Playback": [
"SampledPosition"
],
"Application Launcher": [
"CurrentApp"
],
"Application Basic": [
"Application"
]
},
"defaultReportingPolicy": "mandatory",
Expand Down
Loading

0 comments on commit e8dee4d

Please sign in to comment.