Codegen. Windows compat. Fix OATPP_MACRO_NUM_ARGS.

This commit is contained in:
lganzzzo 2019-08-16 03:45:12 +03:00
parent 0537ef7e5d
commit 259250674c
6 changed files with 19 additions and 20 deletions

View File

@ -62,7 +62,7 @@
//////////////////////////////////////////////////////////////////////////
#define OATPP_MACRO_API_CONTROLLER_MACRO_SELECTOR(MACRO, TYPE, ...) \
OATPP_MACRO_MACRO_SELECTOR(MACRO, (__VA_ARGS__)) (TYPE, __VA_ARGS__)
OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_SELECTOR(MACRO, (__VA_ARGS__)) (TYPE, __VA_ARGS__))
//////////////////////////////////////////////////////////////////////////
@ -201,7 +201,7 @@ OATPP_API_CALL_1(NAME, METHOD, PATH, __VA_ARGS__)
* @return - std::shared_ptr to &id:oatpp::web::protocol::http::incoming::Response;
*/
#define API_CALL(METHOD, PATH, ...) \
OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_API_CALL_MACRO_, (__VA_ARGS__)) (METHOD, PATH, __VA_ARGS__)
OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_API_CALL_MACRO_, (__VA_ARGS__)) (METHOD, PATH, __VA_ARGS__))
// API_CALL_ASYNC MACRO
@ -262,4 +262,4 @@ OATPP_API_CALL_ASYNC_1(NAME, METHOD, PATH, __VA_ARGS__)
* @return - &id:oatpp::async::CoroutineStarterForResult;<const std::shared_ptr<&id:oatpp::web::protocol::http::incoming::Response;>&>.
*/
#define API_CALL_ASYNC(METHOD, PATH, ...) \
OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_API_CALL_ASYNC_MACRO_, (__VA_ARGS__)) (METHOD, PATH, __VA_ARGS__)
OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_API_CALL_ASYNC_MACRO_, (__VA_ARGS__)) (METHOD, PATH, __VA_ARGS__))

View File

@ -77,7 +77,7 @@ OATPP_MACRO_API_CONTROLLER_PARAM(OATPP_MACRO_API_CONTROLLER_BODY_DTO, OATPP_MACR
//////////////////////////////////////////////////////////////////////////
#define OATPP_MACRO_API_CONTROLLER_MACRO_SELECTOR(MACRO, TYPE, ...) \
OATPP_MACRO_MACRO_SELECTOR(MACRO, (__VA_ARGS__)) (TYPE, __VA_ARGS__)
OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_SELECTOR(MACRO, (__VA_ARGS__)) (TYPE, __VA_ARGS__))
//////////////////////////////////////////////////////////////////////////
@ -378,10 +378,10 @@ std::shared_ptr<oatpp::web::protocol::http::outgoing::Response> NAME(\
// Chooser
#define OATPP_MACRO_API_CONTROLLER_ENDPOINT_MACRO_0(METHOD, PATH, NAME) \
OATPP_MACRO_API_CONTROLLER_ENDPOINT_0(NAME, METHOD, PATH)
OATPP_MACRO_EXPAND(OATPP_MACRO_API_CONTROLLER_ENDPOINT_0(NAME, METHOD, PATH))
#define OATPP_MACRO_API_CONTROLLER_ENDPOINT_MACRO_1(METHOD, PATH, NAME, ...) \
OATPP_MACRO_API_CONTROLLER_ENDPOINT_1(NAME, METHOD, PATH, __VA_ARGS__)
OATPP_MACRO_EXPAND(OATPP_MACRO_API_CONTROLLER_ENDPOINT_1(NAME, METHOD, PATH, __VA_ARGS__))
/**
* Codegen macoro to be used in `oatpp::web::server::api::ApiController` to generate Endpoint.
@ -391,7 +391,7 @@ OATPP_MACRO_API_CONTROLLER_ENDPOINT_1(NAME, METHOD, PATH, __VA_ARGS__)
* @return - std::shared_ptr to &id:oatpp::web::protocol::http::outgoing::Response;.
*/
#define ENDPOINT(METHOD, PATH, ...) \
OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_MACRO_API_CONTROLLER_ENDPOINT_MACRO_, (__VA_ARGS__)) (METHOD, PATH, __VA_ARGS__)
OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_MACRO_API_CONTROLLER_ENDPOINT_MACRO_, (__VA_ARGS__)) (METHOD, PATH, __VA_ARGS__))
// ENDPOINT ASYNC MACRO // ------------------------------------------------------

View File

@ -141,4 +141,4 @@ TYPE NAME
* @param QUALIFIER_NAME - additional (optional) field to specify serialized name of the field. If not specified it will be same as NAME.
*/
#define DTO_FIELD(TYPE, ...) \
OATPP_MACRO_MACRO_SELECTOR(OATPP_MACRO_DTO_FIELD_, (__VA_ARGS__)) (TYPE, __VA_ARGS__)
OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_SELECTOR(OATPP_MACRO_DTO_FIELD_, (__VA_ARGS__)) (TYPE, __VA_ARGS__))

View File

@ -34,11 +34,11 @@ ENV::log("macro", "param: %d/%d: '%s'", INDEX, COUNT, #X);
#define OATPP_MACRO_FOREACH_EXAMPLE(...) OATPP_MACRO_FOREACH(OATPP_MACRO_FOREACH_EXAMPLE_FUNC, (__VA_ARGS__))
#define OATPP_MACRO__NUM_ARGS(X100, X99, X98, X97, X96, X95, X94, X93, X92, X91, X90, X89, X88, X87, X86, X85, X84, X83, X82, X81, X80, X79, X78, X77, X76, X75, X74, X73, X72, X71, X70, X69, X68, X67, X66, X65, X64, X63, X62, X61, X60, X59, X58, X57, X56, X55, X54, X53, X52, X51, X50, X49, X48, X47, X46, X45, X44, X43, X42, X41, X40, X39, X38, X37, X36, X35, X34, X33, X32, X31, X30, X29, X28, X27, X26, X25, X24, X23, X22, X21, X20, X19, X18, X17, X16, X15, X14, X13, X12, X11, X10, X9, X8, X7, X6, X5, X4, X3, X2, X1, N, ...) N
#define OATPP_MACRO__NUM_ARGS(X64, X63, X62, X61, X60, X59, X58, X57, X56, X55, X54, X53, X52, X51, X50, X49, X48, X47, X46, X45, X44, X43, X42, X41, X40, X39, X38, X37, X36, X35, X34, X33, X32, X31, X30, X29, X28, X27, X26, X25, X24, X23, X22, X21, X20, X19, X18, X17, X16, X15, X14, X13, X12, X11, X10, X9, X8, X7, X6, X5, X4, X3, X2, X1, N, ...) N
#define OATPP_MACRO_NUM_ARGS(...) OATPP_MACRO__NUM_ARGS(__VA_ARGS__, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
#define OATPP_MACRO_NUM_ARGS(...) OATPP_MACRO_EXPAND(OATPP_MACRO__NUM_ARGS(__VA_ARGS__, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1))
#define OATPP_MACRO_HAS_ARGS_ARR(...) OATPP_MACRO__NUM_ARGS(__VA_ARGS__, true, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0)
#define OATPP_MACRO_HAS_ARGS_ARR(...) OATPP_MACRO_EXPAND(OATPP_MACRO__NUM_ARGS(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0))
//////////////////////////////////////////////////////////////////////
@ -55,7 +55,6 @@ ENV::log("macro", "param: %d/%d: '%s'", INDEX, COUNT, #X);
#define OATPP_MACRO_FIRSTARG_STR(X, ...) #X
#define OATPP_MACRO_RESTARGS(X, ...) __VA_ARGS__
#define OATPP_MACRO_SECONDRESTARGS(X, Y, ...) __VA_ARGS__
#define OATPP_MACRO_FIRSTARG_EXPAND(X, ...) X
@ -71,14 +70,14 @@ ENV::log("macro", "param: %d/%d: '%s'", INDEX, COUNT, #X);
/////////
#define OATPP_MACRO_FOREACH_OR_EMPTY_0(MACRO)
#define OATPP_MACRO_FOREACH_OR_EMPTY_1(MACRO, ...) OATPP_MACRO_FOREACH(MACRO, __VA_ARGS__)
#define OATPP_MACRO_FOREACH_OR_EMPTY_1(MACRO, ...) OATPP_MACRO_EXPAND(OATPP_MACRO_FOREACH(MACRO, __VA_ARGS__))
/*
* @param MACRO
* @param LIST_OF_PARAMETERS
*/
#define OATPP_MACRO_FOREACH_OR_EMPTY(...) \
OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_MACRO_FOREACH_OR_EMPTY_, (__VA_ARGS__)) (__VA_ARGS__)
OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_MACRO_FOREACH_OR_EMPTY_, (__VA_ARGS__)) (__VA_ARGS__))
//
@ -86,7 +85,7 @@ OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_MACRO_FOREACH_OR_EMPTY_, (__VA_ARGS__))
FIRST_MACRO(0, 0, FIRST_ARG)
#define OATPP_MACRO_FOREACH_FIRST_AND_REST_1(FIRST_MACRO, MACRO, FIRST_ARG, ...) \
FIRST_MACRO(0, 0, FIRST_ARG) OATPP_MACRO_FOREACH(MACRO, __VA_ARGS__)
OATPP_MACRO_EXPAND(FIRST_MACRO(0, 0, FIRST_ARG) OATPP_MACRO_FOREACH(MACRO, __VA_ARGS__))
/*
* @param FIRST_MACRO
@ -94,7 +93,7 @@ FIRST_MACRO(0, 0, FIRST_ARG) OATPP_MACRO_FOREACH(MACRO, __VA_ARGS__)
* @param LIST_OF_PARAMETERS
*/
#define OATPP_MACRO_FOREACH_FIRST_AND_REST(FIRST_MACRO, MACRO, ...) \
OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_MACRO_FOREACH_FIRST_AND_REST_, (__VA_ARGS__)) (FIRST_MACRO, MACRO, __VA_ARGS__)
OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_BINARY_SELECTOR(OATPP_MACRO_FOREACH_FIRST_AND_REST_, (__VA_ARGS__)) (FIRST_MACRO, MACRO, __VA_ARGS__))
/////////

View File

@ -47,7 +47,7 @@
(*((TYPE*) oatpp::base::Environment::getComponent(typeid(TYPE).name(), QUALIFIER)))
#define OATPP_GET_COMPONENT(...) \
OATPP_MACRO_MACRO_SELECTOR(OATPP_MACRO_GET_COMPONENT_, (__VA_ARGS__)) (__VA_ARGS__)
OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_SELECTOR(OATPP_MACRO_GET_COMPONENT_, (__VA_ARGS__)) (__VA_ARGS__))
#define OATPP_MACRO_COMPONENT_1(TYPE, NAME) \
@ -64,7 +64,7 @@ TYPE& NAME = (*((TYPE*) oatpp::base::Environment::getComponent(typeid(TYPE).name
* If there is one component registered only then TYPE info is enought to search for component.
*/
#define OATPP_COMPONENT(TYPE, ...) \
OATPP_MACRO_MACRO_SELECTOR(OATPP_MACRO_COMPONENT_, (__VA_ARGS__)) (TYPE, __VA_ARGS__)
OATPP_MACRO_EXPAND(OATPP_MACRO_MACRO_SELECTOR(OATPP_MACRO_COMPONENT_, (__VA_ARGS__)) (TYPE, __VA_ARGS__))
/**
* Create component that then can be injected in other application classes.

View File

@ -60,8 +60,8 @@ class Test : public DTO {
DTO_INIT(Test, DTO)
DTO_FIELD(String, field_string);
DTO_FIELD(Int32, field_int32);
DTO_FIELD(String, field_string, "string-field-name-qualifier");
DTO_FIELD(Int32, field_int32, "int32-field-name-qualifier");
DTO_FIELD(Int64, field_int64);
DTO_FIELD(Float32, field_float32);
DTO_FIELD(Float64, field_float64);