From 63983fb74564d0f89ea47e490fe1ff956a8a8e94 Mon Sep 17 00:00:00 2001 From: Tomasz Duda Date: Fri, 9 Aug 2024 16:26:04 +0200 Subject: [PATCH] macro argument should be enclosed in parentheses --- esphome/components/media_player/automation.h | 33 +++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/esphome/components/media_player/automation.h b/esphome/components/media_player/automation.h index fc3ce7a764..c808832fdd 100644 --- a/esphome/components/media_player/automation.h +++ b/esphome/components/media_player/automation.h @@ -8,22 +8,27 @@ namespace esphome { namespace media_player { #define MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(ACTION_CLASS, ACTION_COMMAND) \ - template class ACTION_CLASS : public Action, public Parented { \ - void play(Ts... x) override { \ - this->parent_->make_call().set_command(MediaPlayerCommand::MEDIA_PLAYER_COMMAND_##ACTION_COMMAND).perform(); \ - } \ - }; + template \ + class(ACTION_CLASS) \ + : public Action, \ + public Parented{ \ + void play(Ts... x) override{this->parent_->make_call() \ + .set_command(MediaPlayerCommand::MEDIA_PLAYER_COMMAND_##ACTION_COMMAND) \ + .perform(); \ + } \ + } \ + ; #define MEDIA_PLAYER_SIMPLE_STATE_TRIGGER(TRIGGER_CLASS, TRIGGER_STATE) \ - class TRIGGER_CLASS : public Trigger<> { \ - public: \ - explicit TRIGGER_CLASS(MediaPlayer *player) { \ - player->add_on_state_callback([this, player]() { \ - if (player->state == MediaPlayerState::MEDIA_PLAYER_STATE_##TRIGGER_STATE) \ - this->trigger(); \ - }); \ - } \ - }; + class(TRIGGER_CLASS) \ + : public Trigger<>{ \ + public: explicit TRIGGER_CLASS(MediaPlayer * player){player->add_on_state_callback([this, player]() { \ + if (player->state == MediaPlayerState::MEDIA_PLAYER_STATE_##TRIGGER_STATE) \ + this->trigger(); \ + }); \ + } \ + } \ + ; MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(PlayAction, PLAY) MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(PauseAction, PAUSE)