// the _ argument can be used to group comma separated list of parameter types #define COMMAND_LIST_IMPL(x, _) \ x( Increment, int, int ) \ x( Sum, int, _(int, int) ) \ x( Split, std::tuple<_(int, int)>, int ) #define EXPAND(...) __VA_ARGS__ // apply x macro on each command #define COMMAND_LIST(x) COMMAND_LIST_IMPL(x, EXPAND) // generate Command classes #define x(Name, Result, Args) struct Name : Command<Result(Args)> {}; inline namespace Commands { COMMAND_LIST(x) } #undef x void register_all() { // generate registeration code #define x(Name, Result, Args) register_command<Name>(); COMMAND_LIST(x) #undef x } template<typename C, typename ...Args> typename C::result_type execute_command(Args&& ...args) {
{ .command = BRL_CMD_NOOP }, { .command = BRL_CMD_OFFLINE }, { .command = BRL_CMD_BLK(ALERT) }, { .command = BRL_CMD_BLK(PASSXT) }, { .command = BRL_CMD_BLK(PASSAT) }, { .command = BRL_CMD_BLK(PASSPS2) }, { .command = BRL_CMD_BLK(TOUCH) }, }; #define COMMAND_LIST(name) .commands = { \ .table = commandList_##name, \ .count = ARRAY_COUNT(commandList_##name), \ } const CommandGroupEntry commandGroupTable[] = { { COMMAND_LIST(modes), .listAfter = listHotkeys, .name = WS_C("Special Modes") }, { COMMAND_LIST(cursor), .name = WS_C("Cursor Functions") }, { COMMAND_LIST(vertical), .name = WS_C("Vertical Navigation") }, { COMMAND_LIST(horizontal), .name = WS_C("Horizontal Navigation") },