mirror of
https://github.com/esphome/esphome.git
synced 2024-12-29 08:51:43 +01:00
macro argument should be enclosed in parentheses
This commit is contained in:
parent
dc64010c32
commit
63983fb745
1 changed files with 19 additions and 14 deletions
|
@ -8,22 +8,27 @@ namespace esphome {
|
||||||
namespace media_player {
|
namespace media_player {
|
||||||
|
|
||||||
#define MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(ACTION_CLASS, ACTION_COMMAND) \
|
#define MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(ACTION_CLASS, ACTION_COMMAND) \
|
||||||
template<typename... Ts> class ACTION_CLASS : public Action<Ts...>, public Parented<MediaPlayer> { \
|
template<typename... Ts> \
|
||||||
void play(Ts... x) override { \
|
class(ACTION_CLASS) \
|
||||||
this->parent_->make_call().set_command(MediaPlayerCommand::MEDIA_PLAYER_COMMAND_##ACTION_COMMAND).perform(); \
|
: public Action<Ts...>, \
|
||||||
|
public Parented<MediaPlayer>{ \
|
||||||
|
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) \
|
#define MEDIA_PLAYER_SIMPLE_STATE_TRIGGER(TRIGGER_CLASS, TRIGGER_STATE) \
|
||||||
class TRIGGER_CLASS : public Trigger<> { \
|
class(TRIGGER_CLASS) \
|
||||||
public: \
|
: public Trigger<>{ \
|
||||||
explicit TRIGGER_CLASS(MediaPlayer *player) { \
|
public: explicit TRIGGER_CLASS(MediaPlayer * player){player->add_on_state_callback([this, player]() { \
|
||||||
player->add_on_state_callback([this, player]() { \
|
|
||||||
if (player->state == MediaPlayerState::MEDIA_PLAYER_STATE_##TRIGGER_STATE) \
|
if (player->state == MediaPlayerState::MEDIA_PLAYER_STATE_##TRIGGER_STATE) \
|
||||||
this->trigger(); \
|
this->trigger(); \
|
||||||
}); \
|
}); \
|
||||||
} \
|
} \
|
||||||
};
|
} \
|
||||||
|
;
|
||||||
|
|
||||||
MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(PlayAction, PLAY)
|
MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(PlayAction, PLAY)
|
||||||
MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(PauseAction, PAUSE)
|
MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(PauseAction, PAUSE)
|
||||||
|
|
Loading…
Reference in a new issue