Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S3: Update server-side cluster handlers to reference fields from cluster objects instead #8974

Closed
mrjerryjohns opened this issue Aug 12, 2021 · 0 comments · Fixed by #10354
Closed

Comments

@mrjerryjohns
Copy link
Contributor

Problem

Once #8972 is complete, the various cluster handlers should be updated to reference fields from the passed in cluster command objects instead of the individual args.

In addition, for clusters that generate data responses, the logic should be updated to utilize the new AddResponse method on the CommandHandler/InvokeResponder class that is passed in the command response object. This will move away from blitting raw TLV.

bzbarsky-apple added a commit to bzbarsky-apple/connectedhomeip that referenced this issue Oct 8, 2021
…nts.

This commit was generated by running:

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,]+,([^,)]+ commandData\)\n{\n)/\1\2/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1\3    auto & \2 = commandData.\2;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1\4    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1\5    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1\6    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1\7    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n    auto & \6 = commandData.\6;\n\n/g;'

find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1\8    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n    auto & \6 = commandData.\6;\n    auto & \7 = commandData.\7;\n\n/g;'

find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1\9    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n    auto & \6 = commandData.\6;\n    auto & \7 = commandData.\7;\n    auto & \8 = commandData.\8;\n\n/g;'

and then restyling.

For all of those regexps the idea is to grab the first two arguments
(command obj and command path) as-is, as well as the last
(commandData) argument.  The endpoint argument is dropped, because
almost nothing uses it right now and it's easier to fix up the things
that do (to use the command path) than to fix up all the things that
don't (to not have it).  For the other arguments, each one is
rewritten into a variable at the top of the function, assigned from
the corresponding member of the field struct.  There are multiple
passes because each pass only deals with functions that have a fixed
number of arguments.

Fixes project-chip#8974
Fixes project-chip#8977
bzbarsky-apple added a commit to bzbarsky-apple/connectedhomeip that referenced this issue Oct 8, 2021
…nts.

This commit was generated by running:

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,]+,([^,)]+ commandData\)\n{\n)/\1 const \2/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \3    auto & \2 = commandData.\2;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \4    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \5    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \6    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \7    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n    auto & \6 = commandData.\6;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \8    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n    auto & \6 = commandData.\6;\n    auto & \7 = commandData.\7;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \9    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n    auto & \6 = commandData.\6;\n    auto & \7 = commandData.\7;\n    auto & \8 = commandData.\8;\n\n/g;'

and then restyling.

For all of those regexps the idea is to grab the first two arguments
(command obj and command path) as-is, as well as the last
(commandData) argument.  The endpoint argument is dropped, because
almost nothing uses it right now and it's easier to fix up the things
that do (to use the command path) than to fix up all the things that
don't (to not have it).  For the other arguments, each one is
rewritten into a variable at the top of the function, assigned from
the corresponding member of the field struct.  There are multiple
passes because each pass only deals with functions that have a fixed
number of arguments.

Fixes project-chip#8974
Fixes project-chip#8977
bzbarsky-apple added a commit to bzbarsky-apple/connectedhomeip that referenced this issue Oct 11, 2021
…nts.

This commit was generated by running:

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,]+,([^,)]+ commandData\)\n{\n)/\1 const \2/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \3    auto & \2 = commandData.\2;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \4    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \5    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \6    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \7    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n    auto & \6 = commandData.\6;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \8    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n    auto & \6 = commandData.\6;\n    auto & \7 = commandData.\7;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \9    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n    auto & \6 = commandData.\6;\n    auto & \7 = commandData.\7;\n    auto & \8 = commandData.\8;\n\n/g;'

and then restyling.

For all of those regexps the idea is to grab the first two arguments
(command obj and command path) as-is, as well as the last
(commandData) argument.  The endpoint argument is dropped, because
almost nothing uses it right now and it's easier to fix up the things
that do (to use the command path) than to fix up all the things that
don't (to not have it).  For the other arguments, each one is
rewritten into a variable at the top of the function, assigned from
the corresponding member of the field struct.  There are multiple
passes because each pass only deals with functions that have a fixed
number of arguments.

Fixes project-chip#8974
Fixes project-chip#8977
bzbarsky-apple added a commit that referenced this issue Oct 12, 2021
…lbacks (#10354)

* Update server-side command codegen to not output arguments for each field.

* Regenerate generated files

* Rewrite cluster callback implementations to not have per-field arguments.

This commit was generated by running:

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,]+,([^,)]+ commandData\)\n{\n)/\1 const \2/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \3    auto & \2 = commandData.\2;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \4    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \5    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \6    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \7    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n    auto & \6 = commandData.\6;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \8    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n    auto & \6 = commandData.\6;\n    auto & \7 = commandData.\7;\n\n/g;'

  find src/app/clusters examples/tv-app/linux/include/content-launcher examples/window-app/common/src -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef; } s/(bool emberAf[a-zA-Z0-9]*Cluster[a-zA-Z0-9]*Callback\([^,]+,[^,]+,)[^,)]+,[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),[^,)]+ ([a-zA-Z0-9]+),([^,)]+ commandData\)\n{\n)/\1 const \9    auto & \2 = commandData.\2;\n    auto & \3 = commandData.\3;\n    auto & \4 = commandData.\4;\n    auto & \5 = commandData.\5;\n    auto & \6 = commandData.\6;\n    auto & \7 = commandData.\7;\n    auto & \8 = commandData.\8;\n\n/g;'

and then restyling.

For all of those regexps the idea is to grab the first two arguments
(command obj and command path) as-is, as well as the last
(commandData) argument.  The endpoint argument is dropped, because
almost nothing uses it right now and it's easier to fix up the things
that do (to use the command path) than to fix up all the things that
don't (to not have it).  For the other arguments, each one is
rewritten into a variable at the top of the function, assigned from
the corresponding member of the field struct.  There are multiple
passes because each pass only deals with functions that have a fixed
number of arguments.

Fixes #8974
Fixes #8977

* Manual fixups to deal with missing endpoint arguments.

* Manually remove declarations for arguments that are unused.

* Manually fix cases where the argument name did not match the struct member name.

In some of these cases the argument is actually unused so can just be
removed.

* Manual changes to deal with CHAR_STRING command fields.

The type of these has changed, and this actually fixes a bunch of bugs.

* Manual changes to make the scenes cluster compile for now.

It doesn't work right, because we don't have the right types for scene
field sets.

* Manual fixups for lists in groups cluster.

* Manual changes for const-correctness for door lock.

* Manual last fixups

* Restore the GetGroupMembership group id logging.

* Apply suggestions about endpoint id from code review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant