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

fix __VA_ARGS__ on windows unfold error and register_handler name error #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions common/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace purecpp{

template<typename Self, typename Function>
int register_handler(Self&& self, std::string const& name, const Function& f) {
register_handler(name, f, &self);
purecpp::router::get().register_handler(name, f, &self);

return 0;
}
Expand All @@ -55,13 +55,15 @@ BOOST_DLL_ALIAS(purecpp::get_key, get_key);
#define CAT( A, B ) A ## B
#define SELECT( NAME, NUM ) CAT( NAME ## _, NUM )

#define EXPAND( ... ) __VA_ARGS__

#define VA_NARGS_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
#define VA_NARGS(...) VA_NARGS_IMPL(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
#define VA_SIZE(...) VA_NARGS(__VA_ARGS__)
#define VA_NARGS(...) EXPAND(VA_NARGS_IMPL(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1))
#define VA_SIZE(...) EXPAND(VA_NARGS(__VA_ARGS__))

#define VA_SELECT( NAME, ... ) SELECT( NAME, VA_SIZE(__VA_ARGS__) )(__VA_ARGS__)
#define VA_SELECT( NAME, ... ) EXPAND(SELECT( NAME, VA_SIZE(__VA_ARGS__) )(__VA_ARGS__))

#define ADD_SERVICE( ... ) VA_SELECT( MY_OVERLOADED, __VA_ARGS__ )
#define ADD_SERVICE( ... ) EXPAND(VA_SELECT( MY_OVERLOADED, __VA_ARGS__ ))

#define MY_OVERLOADED_1( f ) int ANONYMOUS_VARIABLE(var) = purecpp::register_handler(#f, f);
#define MY_OVERLOADED_2( f, t ) int ANONYMOUS_VARIABLE(var) = purecpp::register_handler(#f, f, t);