diff --git a/README.md b/README.md index 364c8c734..f4841b428 100644 --- a/README.md +++ b/README.md @@ -250,7 +250,7 @@ struct person { std::string name; int age; }; -REFLECTION(person, name, age); +YLT_REFL(person, name, age); int main() { person p{.name = "tom", .age = 20}; @@ -274,7 +274,7 @@ struct person { std::string name; int age; }; -REFLECTION(person, name, age); +YLT_REFL(person, name, age); void basic_usage() { std::string xml = R"( @@ -308,7 +308,7 @@ struct person { std::string name; int age; }; -REFLECTION(person, name, age); +YLT_REFL(person, name, age); void basic_usage() { // serialization the structure to the string diff --git a/include/ylt/metric/counter.hpp b/include/ylt/metric/counter.hpp index 750154b22..d7f29e9ec 100644 --- a/include/ylt/metric/counter.hpp +++ b/include/ylt/metric/counter.hpp @@ -16,14 +16,14 @@ struct json_counter_metric_t { std::map labels; std::variant value; }; -REFLECTION(json_counter_metric_t, labels, value); +YLT_REFL(json_counter_metric_t, labels, value); struct json_counter_t { std::string name; std::string help; std::string type; std::vector metrics; }; -REFLECTION(json_counter_t, name, help, type, metrics); +YLT_REFL(json_counter_t, name, help, type, metrics); #endif template diff --git a/include/ylt/metric/histogram.hpp b/include/ylt/metric/histogram.hpp index 4b4fe1406..66c13d018 100644 --- a/include/ylt/metric/histogram.hpp +++ b/include/ylt/metric/histogram.hpp @@ -16,14 +16,14 @@ struct json_histogram_metric_t { int64_t count; double sum; }; -REFLECTION(json_histogram_metric_t, labels, quantiles, count, sum); +YLT_REFL(json_histogram_metric_t, labels, quantiles, count, sum); struct json_histogram_t { std::string name; std::string help; std::string type; std::vector metrics; }; -REFLECTION(json_histogram_t, name, help, type, metrics); +YLT_REFL(json_histogram_t, name, help, type, metrics); #endif template diff --git a/include/ylt/metric/summary.hpp b/include/ylt/metric/summary.hpp index d5a5d4521..661b52eb7 100644 --- a/include/ylt/metric/summary.hpp +++ b/include/ylt/metric/summary.hpp @@ -18,14 +18,14 @@ struct json_summary_metric_t { int64_t count; double sum; }; -REFLECTION(json_summary_metric_t, labels, quantiles, count, sum); +YLT_REFL(json_summary_metric_t, labels, quantiles, count, sum); struct json_summary_t { std::string name; std::string help; std::string type; std::vector metrics; }; -REFLECTION(json_summary_t, name, help, type, metrics); +YLT_REFL(json_summary_t, name, help, type, metrics); #endif struct block_t { diff --git a/include/ylt/reflection/internal/arg_list_macro.hpp b/include/ylt/reflection/internal/arg_list_macro.hpp index 12cb82a1a..d819ba571 100644 --- a/include/ylt/reflection/internal/arg_list_macro.hpp +++ b/include/ylt/reflection/internal/arg_list_macro.hpp @@ -7,5 +7,5 @@ #define WRAP_ARGS_(w, object, ...) \ YLT_CONCAT(WRAP_ARGS, YLT_ARG_COUNT(__VA_ARGS__)) \ - (w, object, __VA_ARGS__) -#define WRAP_ARGS(w, object, ...) WRAP_ARGS_(w, object, __VA_ARGS__) \ No newline at end of file + (w, object, ##__VA_ARGS__) +#define WRAP_ARGS(w, object, ...) WRAP_ARGS_(w, object, ##__VA_ARGS__) \ No newline at end of file diff --git a/include/ylt/reflection/internal/args_count.hpp b/include/ylt/reflection/internal/args_count.hpp index ec93dd61d..69d7a0901 100644 --- a/include/ylt/reflection/internal/args_count.hpp +++ b/include/ylt/reflection/internal/args_count.hpp @@ -2,18 +2,45 @@ #define YLT_MACRO_EXPAND(...) __VA_ARGS__ -#define YLT_ARG_COUNT(...) \ - YLT_MACRO_EXPAND(YLT_ARG_COUNT_IMPL( \ - 0, ##__VA_ARGS__, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, \ - 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 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, 0)) +#ifdef _MSC_VER // Microsoft compilers -#define YLT_ARG_COUNT_IMPL( \ +#define __NARGS( \ + _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, \ + _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, \ + _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, \ + _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, \ + _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, \ + _77, _78, _79, _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, \ + _92, _93, _94, _95, _96, _97, _98, _99, _100, _101, _102, _103, _104, \ + _105, _106, _107, _108, _109, _110, _111, _112, _113, _114, _115, _116, \ + _117, _118, _119, _120, _121, _122, _123, _124, _125, N, ...) \ + N +#define NARGS_1(...) \ + YLT_MACRO_EXPAND(__NARGS( \ + __VA_ARGS__, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, \ + 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 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, 0)) + +#define AUGMENTER(...) unused, __VA_ARGS__ +#define YLT_ARG_COUNT(...) NARGS_1(AUGMENTER(__VA_ARGS__)) + +#else // Others + +#define YLT_ARG_COUNT(...) \ + __NARGS(0, ##__VA_ARGS__, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, \ + 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, \ + 101, 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, 0) +#define __NARGS( \ _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, \ _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, \ _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, \ @@ -24,3 +51,5 @@ _105, _106, _107, _108, _109, _110, _111, _112, _113, _114, _115, _116, \ _117, _118, _119, _120, _121, _122, _123, _124, N, ...) \ N + +#endif diff --git a/include/ylt/reflection/internal/generate/arg_list_macro_gen.hpp b/include/ylt/reflection/internal/generate/arg_list_macro_gen.hpp index 2c7ee341b..7c9186f00 100644 --- a/include/ylt/reflection/internal/generate/arg_list_macro_gen.hpp +++ b/include/ylt/reflection/internal/generate/arg_list_macro_gen.hpp @@ -10,127 +10,251 @@ YLT_MACRO_EXPAND(WRAP_ARGS{i-1}(w,o,__VA_ARGS__))" for i in range(2, 126) ) ) */ -#define WRAP_ARGS2(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS1(w, o, __VA_ARGS__)) -#define WRAP_ARGS3(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS2(w, o, __VA_ARGS__)) -#define WRAP_ARGS4(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS3(w, o, __VA_ARGS__)) -#define WRAP_ARGS5(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS4(w, o, __VA_ARGS__)) -#define WRAP_ARGS6(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS5(w, o, __VA_ARGS__)) -#define WRAP_ARGS7(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS6(w, o, __VA_ARGS__)) -#define WRAP_ARGS8(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS7(w, o, __VA_ARGS__)) -#define WRAP_ARGS9(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS8(w, o, __VA_ARGS__)) -#define WRAP_ARGS10(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS9(w, o, __VA_ARGS__)) -#define WRAP_ARGS11(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS10(w, o, __VA_ARGS__)) -#define WRAP_ARGS12(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS11(w, o, __VA_ARGS__)) -#define WRAP_ARGS13(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS12(w, o, __VA_ARGS__)) -#define WRAP_ARGS14(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS13(w, o, __VA_ARGS__)) -#define WRAP_ARGS15(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS14(w, o, __VA_ARGS__)) -#define WRAP_ARGS16(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS15(w, o, __VA_ARGS__)) -#define WRAP_ARGS17(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS16(w, o, __VA_ARGS__)) -#define WRAP_ARGS18(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS17(w, o, __VA_ARGS__)) -#define WRAP_ARGS19(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS18(w, o, __VA_ARGS__)) -#define WRAP_ARGS20(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS19(w, o, __VA_ARGS__)) -#define WRAP_ARGS21(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS20(w, o, __VA_ARGS__)) -#define WRAP_ARGS22(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS21(w, o, __VA_ARGS__)) -#define WRAP_ARGS23(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS22(w, o, __VA_ARGS__)) -#define WRAP_ARGS24(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS23(w, o, __VA_ARGS__)) -#define WRAP_ARGS25(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS24(w, o, __VA_ARGS__)) -#define WRAP_ARGS26(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS25(w, o, __VA_ARGS__)) -#define WRAP_ARGS27(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS26(w, o, __VA_ARGS__)) -#define WRAP_ARGS28(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS27(w, o, __VA_ARGS__)) -#define WRAP_ARGS29(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS28(w, o, __VA_ARGS__)) -#define WRAP_ARGS30(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS29(w, o, __VA_ARGS__)) -#define WRAP_ARGS31(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS30(w, o, __VA_ARGS__)) -#define WRAP_ARGS32(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS31(w, o, __VA_ARGS__)) -#define WRAP_ARGS33(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS32(w, o, __VA_ARGS__)) -#define WRAP_ARGS34(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS33(w, o, __VA_ARGS__)) -#define WRAP_ARGS35(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS34(w, o, __VA_ARGS__)) -#define WRAP_ARGS36(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS35(w, o, __VA_ARGS__)) -#define WRAP_ARGS37(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS36(w, o, __VA_ARGS__)) -#define WRAP_ARGS38(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS37(w, o, __VA_ARGS__)) -#define WRAP_ARGS39(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS38(w, o, __VA_ARGS__)) -#define WRAP_ARGS40(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS39(w, o, __VA_ARGS__)) -#define WRAP_ARGS41(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS40(w, o, __VA_ARGS__)) -#define WRAP_ARGS42(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS41(w, o, __VA_ARGS__)) -#define WRAP_ARGS43(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS42(w, o, __VA_ARGS__)) -#define WRAP_ARGS44(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS43(w, o, __VA_ARGS__)) -#define WRAP_ARGS45(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS44(w, o, __VA_ARGS__)) -#define WRAP_ARGS46(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS45(w, o, __VA_ARGS__)) -#define WRAP_ARGS47(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS46(w, o, __VA_ARGS__)) -#define WRAP_ARGS48(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS47(w, o, __VA_ARGS__)) -#define WRAP_ARGS49(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS48(w, o, __VA_ARGS__)) -#define WRAP_ARGS50(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS49(w, o, __VA_ARGS__)) -#define WRAP_ARGS51(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS50(w, o, __VA_ARGS__)) -#define WRAP_ARGS52(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS51(w, o, __VA_ARGS__)) -#define WRAP_ARGS53(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS52(w, o, __VA_ARGS__)) -#define WRAP_ARGS54(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS53(w, o, __VA_ARGS__)) -#define WRAP_ARGS55(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS54(w, o, __VA_ARGS__)) -#define WRAP_ARGS56(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS55(w, o, __VA_ARGS__)) -#define WRAP_ARGS57(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS56(w, o, __VA_ARGS__)) -#define WRAP_ARGS58(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS57(w, o, __VA_ARGS__)) -#define WRAP_ARGS59(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS58(w, o, __VA_ARGS__)) -#define WRAP_ARGS60(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS59(w, o, __VA_ARGS__)) -#define WRAP_ARGS61(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS60(w, o, __VA_ARGS__)) -#define WRAP_ARGS62(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS61(w, o, __VA_ARGS__)) -#define WRAP_ARGS63(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS62(w, o, __VA_ARGS__)) -#define WRAP_ARGS64(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS63(w, o, __VA_ARGS__)) -#define WRAP_ARGS65(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS64(w, o, __VA_ARGS__)) -#define WRAP_ARGS66(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS65(w, o, __VA_ARGS__)) -#define WRAP_ARGS67(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS66(w, o, __VA_ARGS__)) -#define WRAP_ARGS68(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS67(w, o, __VA_ARGS__)) -#define WRAP_ARGS69(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS68(w, o, __VA_ARGS__)) -#define WRAP_ARGS70(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS69(w, o, __VA_ARGS__)) -#define WRAP_ARGS71(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS70(w, o, __VA_ARGS__)) -#define WRAP_ARGS72(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS71(w, o, __VA_ARGS__)) -#define WRAP_ARGS73(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS72(w, o, __VA_ARGS__)) -#define WRAP_ARGS74(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS73(w, o, __VA_ARGS__)) -#define WRAP_ARGS75(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS74(w, o, __VA_ARGS__)) -#define WRAP_ARGS76(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS75(w, o, __VA_ARGS__)) -#define WRAP_ARGS77(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS76(w, o, __VA_ARGS__)) -#define WRAP_ARGS78(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS77(w, o, __VA_ARGS__)) -#define WRAP_ARGS79(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS78(w, o, __VA_ARGS__)) -#define WRAP_ARGS80(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS79(w, o, __VA_ARGS__)) -#define WRAP_ARGS81(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS80(w, o, __VA_ARGS__)) -#define WRAP_ARGS82(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS81(w, o, __VA_ARGS__)) -#define WRAP_ARGS83(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS82(w, o, __VA_ARGS__)) -#define WRAP_ARGS84(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS83(w, o, __VA_ARGS__)) -#define WRAP_ARGS85(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS84(w, o, __VA_ARGS__)) -#define WRAP_ARGS86(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS85(w, o, __VA_ARGS__)) -#define WRAP_ARGS87(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS86(w, o, __VA_ARGS__)) -#define WRAP_ARGS88(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS87(w, o, __VA_ARGS__)) -#define WRAP_ARGS89(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS88(w, o, __VA_ARGS__)) -#define WRAP_ARGS90(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS89(w, o, __VA_ARGS__)) -#define WRAP_ARGS91(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS90(w, o, __VA_ARGS__)) -#define WRAP_ARGS92(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS91(w, o, __VA_ARGS__)) -#define WRAP_ARGS93(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS92(w, o, __VA_ARGS__)) -#define WRAP_ARGS94(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS93(w, o, __VA_ARGS__)) -#define WRAP_ARGS95(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS94(w, o, __VA_ARGS__)) -#define WRAP_ARGS96(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS95(w, o, __VA_ARGS__)) -#define WRAP_ARGS97(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS96(w, o, __VA_ARGS__)) -#define WRAP_ARGS98(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS97(w, o, __VA_ARGS__)) -#define WRAP_ARGS99(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS98(w, o, __VA_ARGS__)) -#define WRAP_ARGS100(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS99(w, o, __VA_ARGS__)) -#define WRAP_ARGS101(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS100(w, o, __VA_ARGS__)) -#define WRAP_ARGS102(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS101(w, o, __VA_ARGS__)) -#define WRAP_ARGS103(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS102(w, o, __VA_ARGS__)) -#define WRAP_ARGS104(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS103(w, o, __VA_ARGS__)) -#define WRAP_ARGS105(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS104(w, o, __VA_ARGS__)) -#define WRAP_ARGS106(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS105(w, o, __VA_ARGS__)) -#define WRAP_ARGS107(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS106(w, o, __VA_ARGS__)) -#define WRAP_ARGS108(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS107(w, o, __VA_ARGS__)) -#define WRAP_ARGS109(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS108(w, o, __VA_ARGS__)) -#define WRAP_ARGS110(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS109(w, o, __VA_ARGS__)) -#define WRAP_ARGS111(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS110(w, o, __VA_ARGS__)) -#define WRAP_ARGS112(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS111(w, o, __VA_ARGS__)) -#define WRAP_ARGS113(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS112(w, o, __VA_ARGS__)) -#define WRAP_ARGS114(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS113(w, o, __VA_ARGS__)) -#define WRAP_ARGS115(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS114(w, o, __VA_ARGS__)) -#define WRAP_ARGS116(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS115(w, o, __VA_ARGS__)) -#define WRAP_ARGS117(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS116(w, o, __VA_ARGS__)) -#define WRAP_ARGS118(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS117(w, o, __VA_ARGS__)) -#define WRAP_ARGS119(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS118(w, o, __VA_ARGS__)) -#define WRAP_ARGS120(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS119(w, o, __VA_ARGS__)) -#define WRAP_ARGS121(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS120(w, o, __VA_ARGS__)) -#define WRAP_ARGS122(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS121(w, o, __VA_ARGS__)) -#define WRAP_ARGS123(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS122(w, o, __VA_ARGS__)) -#define WRAP_ARGS124(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS123(w, o, __VA_ARGS__)) -#define WRAP_ARGS125(w, o, _1, ...) w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS124(w, o, __VA_ARGS__)) +#define WRAP_ARGS2(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS1(w, o, __VA_ARGS__)) +#define WRAP_ARGS3(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS2(w, o, __VA_ARGS__)) +#define WRAP_ARGS4(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS3(w, o, __VA_ARGS__)) +#define WRAP_ARGS5(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS4(w, o, __VA_ARGS__)) +#define WRAP_ARGS6(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS5(w, o, __VA_ARGS__)) +#define WRAP_ARGS7(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS6(w, o, __VA_ARGS__)) +#define WRAP_ARGS8(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS7(w, o, __VA_ARGS__)) +#define WRAP_ARGS9(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS8(w, o, __VA_ARGS__)) +#define WRAP_ARGS10(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS9(w, o, __VA_ARGS__)) +#define WRAP_ARGS11(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS10(w, o, __VA_ARGS__)) +#define WRAP_ARGS12(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS11(w, o, __VA_ARGS__)) +#define WRAP_ARGS13(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS12(w, o, __VA_ARGS__)) +#define WRAP_ARGS14(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS13(w, o, __VA_ARGS__)) +#define WRAP_ARGS15(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS14(w, o, __VA_ARGS__)) +#define WRAP_ARGS16(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS15(w, o, __VA_ARGS__)) +#define WRAP_ARGS17(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS16(w, o, __VA_ARGS__)) +#define WRAP_ARGS18(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS17(w, o, __VA_ARGS__)) +#define WRAP_ARGS19(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS18(w, o, __VA_ARGS__)) +#define WRAP_ARGS20(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS19(w, o, __VA_ARGS__)) +#define WRAP_ARGS21(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS20(w, o, __VA_ARGS__)) +#define WRAP_ARGS22(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS21(w, o, __VA_ARGS__)) +#define WRAP_ARGS23(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS22(w, o, __VA_ARGS__)) +#define WRAP_ARGS24(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS23(w, o, __VA_ARGS__)) +#define WRAP_ARGS25(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS24(w, o, __VA_ARGS__)) +#define WRAP_ARGS26(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS25(w, o, __VA_ARGS__)) +#define WRAP_ARGS27(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS26(w, o, __VA_ARGS__)) +#define WRAP_ARGS28(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS27(w, o, __VA_ARGS__)) +#define WRAP_ARGS29(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS28(w, o, __VA_ARGS__)) +#define WRAP_ARGS30(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS29(w, o, __VA_ARGS__)) +#define WRAP_ARGS31(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS30(w, o, __VA_ARGS__)) +#define WRAP_ARGS32(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS31(w, o, __VA_ARGS__)) +#define WRAP_ARGS33(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS32(w, o, __VA_ARGS__)) +#define WRAP_ARGS34(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS33(w, o, __VA_ARGS__)) +#define WRAP_ARGS35(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS34(w, o, __VA_ARGS__)) +#define WRAP_ARGS36(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS35(w, o, __VA_ARGS__)) +#define WRAP_ARGS37(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS36(w, o, __VA_ARGS__)) +#define WRAP_ARGS38(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS37(w, o, __VA_ARGS__)) +#define WRAP_ARGS39(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS38(w, o, __VA_ARGS__)) +#define WRAP_ARGS40(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS39(w, o, __VA_ARGS__)) +#define WRAP_ARGS41(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS40(w, o, __VA_ARGS__)) +#define WRAP_ARGS42(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS41(w, o, __VA_ARGS__)) +#define WRAP_ARGS43(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS42(w, o, __VA_ARGS__)) +#define WRAP_ARGS44(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS43(w, o, __VA_ARGS__)) +#define WRAP_ARGS45(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS44(w, o, __VA_ARGS__)) +#define WRAP_ARGS46(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS45(w, o, __VA_ARGS__)) +#define WRAP_ARGS47(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS46(w, o, __VA_ARGS__)) +#define WRAP_ARGS48(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS47(w, o, __VA_ARGS__)) +#define WRAP_ARGS49(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS48(w, o, __VA_ARGS__)) +#define WRAP_ARGS50(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS49(w, o, __VA_ARGS__)) +#define WRAP_ARGS51(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS50(w, o, __VA_ARGS__)) +#define WRAP_ARGS52(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS51(w, o, __VA_ARGS__)) +#define WRAP_ARGS53(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS52(w, o, __VA_ARGS__)) +#define WRAP_ARGS54(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS53(w, o, __VA_ARGS__)) +#define WRAP_ARGS55(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS54(w, o, __VA_ARGS__)) +#define WRAP_ARGS56(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS55(w, o, __VA_ARGS__)) +#define WRAP_ARGS57(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS56(w, o, __VA_ARGS__)) +#define WRAP_ARGS58(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS57(w, o, __VA_ARGS__)) +#define WRAP_ARGS59(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS58(w, o, __VA_ARGS__)) +#define WRAP_ARGS60(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS59(w, o, __VA_ARGS__)) +#define WRAP_ARGS61(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS60(w, o, __VA_ARGS__)) +#define WRAP_ARGS62(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS61(w, o, __VA_ARGS__)) +#define WRAP_ARGS63(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS62(w, o, __VA_ARGS__)) +#define WRAP_ARGS64(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS63(w, o, __VA_ARGS__)) +#define WRAP_ARGS65(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS64(w, o, __VA_ARGS__)) +#define WRAP_ARGS66(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS65(w, o, __VA_ARGS__)) +#define WRAP_ARGS67(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS66(w, o, __VA_ARGS__)) +#define WRAP_ARGS68(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS67(w, o, __VA_ARGS__)) +#define WRAP_ARGS69(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS68(w, o, __VA_ARGS__)) +#define WRAP_ARGS70(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS69(w, o, __VA_ARGS__)) +#define WRAP_ARGS71(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS70(w, o, __VA_ARGS__)) +#define WRAP_ARGS72(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS71(w, o, __VA_ARGS__)) +#define WRAP_ARGS73(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS72(w, o, __VA_ARGS__)) +#define WRAP_ARGS74(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS73(w, o, __VA_ARGS__)) +#define WRAP_ARGS75(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS74(w, o, __VA_ARGS__)) +#define WRAP_ARGS76(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS75(w, o, __VA_ARGS__)) +#define WRAP_ARGS77(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS76(w, o, __VA_ARGS__)) +#define WRAP_ARGS78(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS77(w, o, __VA_ARGS__)) +#define WRAP_ARGS79(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS78(w, o, __VA_ARGS__)) +#define WRAP_ARGS80(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS79(w, o, __VA_ARGS__)) +#define WRAP_ARGS81(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS80(w, o, __VA_ARGS__)) +#define WRAP_ARGS82(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS81(w, o, __VA_ARGS__)) +#define WRAP_ARGS83(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS82(w, o, __VA_ARGS__)) +#define WRAP_ARGS84(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS83(w, o, __VA_ARGS__)) +#define WRAP_ARGS85(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS84(w, o, __VA_ARGS__)) +#define WRAP_ARGS86(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS85(w, o, __VA_ARGS__)) +#define WRAP_ARGS87(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS86(w, o, __VA_ARGS__)) +#define WRAP_ARGS88(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS87(w, o, __VA_ARGS__)) +#define WRAP_ARGS89(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS88(w, o, __VA_ARGS__)) +#define WRAP_ARGS90(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS89(w, o, __VA_ARGS__)) +#define WRAP_ARGS91(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS90(w, o, __VA_ARGS__)) +#define WRAP_ARGS92(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS91(w, o, __VA_ARGS__)) +#define WRAP_ARGS93(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS92(w, o, __VA_ARGS__)) +#define WRAP_ARGS94(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS93(w, o, __VA_ARGS__)) +#define WRAP_ARGS95(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS94(w, o, __VA_ARGS__)) +#define WRAP_ARGS96(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS95(w, o, __VA_ARGS__)) +#define WRAP_ARGS97(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS96(w, o, __VA_ARGS__)) +#define WRAP_ARGS98(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS97(w, o, __VA_ARGS__)) +#define WRAP_ARGS99(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS98(w, o, __VA_ARGS__)) +#define WRAP_ARGS100(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS99(w, o, __VA_ARGS__)) +#define WRAP_ARGS101(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS100(w, o, __VA_ARGS__)) +#define WRAP_ARGS102(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS101(w, o, __VA_ARGS__)) +#define WRAP_ARGS103(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS102(w, o, __VA_ARGS__)) +#define WRAP_ARGS104(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS103(w, o, __VA_ARGS__)) +#define WRAP_ARGS105(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS104(w, o, __VA_ARGS__)) +#define WRAP_ARGS106(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS105(w, o, __VA_ARGS__)) +#define WRAP_ARGS107(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS106(w, o, __VA_ARGS__)) +#define WRAP_ARGS108(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS107(w, o, __VA_ARGS__)) +#define WRAP_ARGS109(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS108(w, o, __VA_ARGS__)) +#define WRAP_ARGS110(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS109(w, o, __VA_ARGS__)) +#define WRAP_ARGS111(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS110(w, o, __VA_ARGS__)) +#define WRAP_ARGS112(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS111(w, o, __VA_ARGS__)) +#define WRAP_ARGS113(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS112(w, o, __VA_ARGS__)) +#define WRAP_ARGS114(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS113(w, o, __VA_ARGS__)) +#define WRAP_ARGS115(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS114(w, o, __VA_ARGS__)) +#define WRAP_ARGS116(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS115(w, o, __VA_ARGS__)) +#define WRAP_ARGS117(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS116(w, o, __VA_ARGS__)) +#define WRAP_ARGS118(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS117(w, o, __VA_ARGS__)) +#define WRAP_ARGS119(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS118(w, o, __VA_ARGS__)) +#define WRAP_ARGS120(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS119(w, o, __VA_ARGS__)) +#define WRAP_ARGS121(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS120(w, o, __VA_ARGS__)) +#define WRAP_ARGS122(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS121(w, o, __VA_ARGS__)) +#define WRAP_ARGS123(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS122(w, o, __VA_ARGS__)) +#define WRAP_ARGS124(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS123(w, o, __VA_ARGS__)) +#define WRAP_ARGS125(w, o, _1, ...) \ + w(o, _1), YLT_MACRO_EXPAND(WRAP_ARGS124(w, o, __VA_ARGS__)) diff --git a/include/ylt/reflection/member_count.hpp b/include/ylt/reflection/member_count.hpp index 73be4c83d..e323c7ee0 100644 --- a/include/ylt/reflection/member_count.hpp +++ b/include/ylt/reflection/member_count.hpp @@ -4,7 +4,11 @@ #include #include #include +#if __has_include() #include +#else +#include "iguana/ylt/util/expected.hpp" +#endif #include "user_reflect_macro.hpp" diff --git a/include/ylt/reflection/member_names.hpp b/include/ylt/reflection/member_names.hpp index 53b564e40..adbd092be 100644 --- a/include/ylt/reflection/member_names.hpp +++ b/include/ylt/reflection/member_names.hpp @@ -7,6 +7,12 @@ namespace ylt::reflection { +template +struct ylt_alias_struct; + +template +inline constexpr auto get_alias_field_names(); + namespace internal { template @@ -48,6 +54,46 @@ inline constexpr std::string_view get_member_name() { #endif } +template +struct member_tratis {}; + +template +struct member_tratis { + using owner_type = Owner; + using value_type = T; +}; + +template +struct has_alias_field_names_t : std::false_type {}; + +template +struct has_alias_field_names_t< + T, std::void_t::get_alias_field_names())>> + : std::true_type {}; + +template +inline constexpr bool has_alias_field_names_v = + has_alias_field_names_t::value; + +template +struct has_alias_struct_names_t : std::false_type {}; + +template +struct has_alias_struct_names_t< + T, std::void_t::get_alias_struct_name())>> + : std::true_type {}; + +template +inline constexpr bool has_alias_struct_name_v = + has_alias_struct_names_t::value; + +template +inline constexpr void init_arr_with_tuple(const T& tp, U& arr, + std::index_sequence) { + ((arr[Is] = internal::get_member_name(tp))>()), + ...); +} + template inline constexpr std::array> get_member_names() { @@ -63,42 +109,75 @@ get_member_names() { constexpr auto tp = struct_to_tuple(); std::array arr; +#if __cplusplus >= 202002L || defined(_MSC_VER) [&](std::index_sequence) mutable { ((arr[Is] = internal::get_member_name(tp))>()), ...); } (std::make_index_sequence{}); +#else + init_arr_with_tuple(tp, arr, std::make_index_sequence{}); +#endif return arr; } } +template +inline constexpr auto get_member_names_map_impl(T& name_arr, + std::index_sequence) { + return frozen::unordered_map{ + {name_arr[Is], Is}...}; +} + template inline constexpr auto get_member_names_map() { constexpr auto name_arr = get_member_names(); +#if __cplusplus >= 202002L || defined(_MSC_VER) return [&](std::index_sequence) mutable { return frozen::unordered_map{ {name_arr[Is], Is}...}; } (std::make_index_sequence{}); +#else + return get_member_names_map_impl(name_arr, + std::make_index_sequence{}); +#endif +} + +template +inline auto get_member_offset_arr_impl(T& t, Tuple& tp, + std::index_sequence) { + std::array arr; + ((arr[Is] = size_t((const char*)&std::get(tp) - (char*)(&t))), ...); + return arr; } template -inline const auto& get_member_offset_arr() { +inline const auto& get_member_offset_arr(T&& t) { constexpr size_t Count = members_count_v; - constexpr auto tp = struct_to_tuple(); + auto tp = ylt::reflection::object_to_tuple(std::forward(t)); +#if __cplusplus >= 202002L [[maybe_unused]] static std::array arr = {[&]( std::index_sequence) mutable {std::array arr; - ((arr[Is] = size_t((const char*)std::get(tp) - - (char*)(&internal::wrapper::value))), - ...); + ((arr[Is] = size_t((const char*)&std::get(tp) - (char*)(&t))), ...); return arr; } (std::make_index_sequence{}) }; // namespace internal return arr; +#else + [[maybe_unused]] static std::array arr = + get_member_offset_arr_impl(t, tp, std::make_index_sequence{}); + return arr; +#endif +} // namespace ylt::reflection + +template +inline const auto& get_member_offset_arr() { + return get_member_offset_arr(internal::wrapper::value); } // namespace ylt::reflection } // namespace internal @@ -115,10 +194,71 @@ template constexpr auto member_names_map = internal::get_member_names_map(); template -constexpr auto member_names = internal::get_member_names(); +inline auto member_offsets = internal::get_member_offset_arr(); + +template +inline constexpr size_t index_of() { + using T = typename internal::member_tratis< + std::remove_const_t>::owner_type; + constexpr auto name = field_string(); + constexpr auto names = internal::get_member_names(); + for (size_t i = 0; i < names.size(); i++) { + if (name == names[i]) { + return i; + } + } + return names.size(); +} + +template +struct field_alias_t { + std::string_view alias_name; + inline static constexpr auto index = Idx; +}; + +template +inline constexpr auto get_alias_field_names_impl(Tuple& tp, + std::index_sequence) { + return std::array, sizeof...(Is)>{ + std::make_pair(std::tuple_element_t>::index, + std::get(tp).alias_name)...}; +} template -inline auto member_offsets = internal::get_member_offset_arr(); +inline constexpr auto get_alias_field_names() { + if constexpr (internal::has_alias_field_names_v) { + constexpr auto tp = ylt_alias_struct::get_alias_field_names(); + return get_alias_field_names_impl( + tp, std::make_index_sequence>{}); + } + else { + return std::array{}; + } +} + +template +constexpr std::string_view get_struct_name() { + if constexpr (internal::has_alias_struct_name_v) { + return ylt_alias_struct::get_alias_struct_name(); + } + else { + return type_string(); + } +} + +template +inline constexpr std::array> +get_member_names() { + auto arr = internal::get_member_names(); + using U = ylt::reflection::remove_cvref_t; + if constexpr (internal::has_alias_field_names_v) { + constexpr auto alias_arr = get_alias_field_names(); + for (size_t i = 0; i < alias_arr.size(); i++) { + arr[alias_arr[i].first] = alias_arr[i].second; + } + } + return arr; +} template struct FixedString { @@ -135,7 +275,7 @@ struct FixedString { template inline constexpr size_t index_of(std::string_view name) { - constexpr auto& arr = member_names; + constexpr auto arr = get_member_names(); for (size_t i = 0; i < arr.size(); i++) { if (arr[i] == name) { return i; @@ -155,13 +295,13 @@ inline constexpr size_t index_of() { template inline constexpr std::string_view name_of() { static_assert(index < members_count_v, "index out of range"); - constexpr auto& arr = member_names; + constexpr auto arr = get_member_names(); return arr[index]; } template inline constexpr std::string_view name_of(size_t index) { - constexpr auto& arr = member_names; + constexpr auto arr = get_member_names(); if (index >= arr.size()) { return ""; } @@ -169,9 +309,27 @@ inline constexpr std::string_view name_of(size_t index) { return arr[index]; } +template +inline constexpr void for_each_impl(Visit&& func, U& arr, + std::index_sequence) { + if constexpr (std::is_invocable_v) { + (func(arr[Is], Is), ...); + } + else if constexpr (std::is_invocable_v) { + (func(arr[Is]), ...); + } + else { + static_assert(sizeof(Visit) < 0, + "invalid arguments, full arguments: [std::string_view, " + "size_t], at least has std::string_view and make sure keep " + "the order of arguments"); + } +} + template inline constexpr void for_each(Visit&& func) { - constexpr auto& arr = member_names; + constexpr auto arr = get_member_names(); +#if __cplusplus >= 202002L [&](std::index_sequence) mutable { if constexpr (std::is_invocable_v) { (func(arr[Is], Is), ...); @@ -187,6 +345,10 @@ inline constexpr void for_each(Visit&& func) { } } (std::make_index_sequence{}); +#else + for_each_impl(std::forward(func), arr, + std::make_index_sequence{}); +#endif } } // namespace ylt::reflection diff --git a/include/ylt/reflection/member_ptr.hpp b/include/ylt/reflection/member_ptr.hpp index 2a847d8b5..fec004ec9 100644 --- a/include/ylt/reflection/member_ptr.hpp +++ b/include/ylt/reflection/member_ptr.hpp @@ -84,7 +84,7 @@ inline constexpr remove_cvref_t& get_fake_object() noexcept { #include "member_macro.hpp" template -inline constexpr auto tuple_view(T& t) { +inline constexpr auto tuple_view(T&& t) { return internal::object_tuple_view_helper>::tuple_view( t); } @@ -124,8 +124,8 @@ inline constexpr decltype(auto) visit_members(T&& t, Visitor&& visitor) { std::forward(visitor)); } else if constexpr (is_inner_ylt_refl_v) { - return type::refl_object_to_tuple(std::forward(t), - std::forward(visitor)); + return t.refl_visit_members(std::forward(t), + std::forward(visitor)); } else { return internal::tuple_view(std::forward(t), diff --git a/include/ylt/reflection/member_value.hpp b/include/ylt/reflection/member_value.hpp index 85d9dd9c4..eddee0576 100644 --- a/include/ylt/reflection/member_value.hpp +++ b/include/ylt/reflection/member_value.hpp @@ -48,8 +48,49 @@ struct switch_helper { } } }; + +inline constexpr frozen::string filter_str(const frozen::string& str) { + if (str.size() > 3 && str[0] == '_' && str[1] == '_' && str[2] == '_') { + auto ptr = str.data() + 3; + return frozen::string(ptr, str.size() - 3); + } + return str; +} + +template +struct offset_t { + using type = value_type; + size_t value; +}; + +template +inline auto get_variant_type() { + return std::variant>>...>{}; +} + +template +inline constexpr auto get_variant_map_impl(std::index_sequence) { + using U = ylt::reflection::remove_cvref_t; + constexpr auto arr = ylt::reflection::get_member_names(); + auto& offset_arr = get_member_offset_arr(wrapper::value); + using Tuple = decltype(ylt::reflection::object_to_tuple(std::declval())); + using ValueType = decltype(get_variant_type()); + return frozen::unordered_map{ + {filter_str(arr[Is]), + ValueType{std::in_place_index, + offset_t>>{offset_arr[Is]}}}...}; +} + } // namespace internal +template +inline constexpr auto get_variant_map() { + return internal::get_variant_map_impl( + std::make_index_sequence>{}); +} + template inline Member& get(T& t, size_t index) { auto ref_tp = object_to_tuple(t); @@ -138,7 +179,7 @@ inline size_t index_of(T& t, Field& value) { template inline constexpr std::string_view name_of(T& t, Field& value) { size_t index = index_of(t, value); - constexpr auto arr = member_names; + constexpr auto arr = get_member_names(); if (index == arr.size()) { return ""; } @@ -146,6 +187,23 @@ inline constexpr std::string_view name_of(T& t, Field& value) { return arr[index]; } +template +inline constexpr void visit_members_impl0(Visit&& func, + std::index_sequence, + Args&... args) { + constexpr auto arr = get_member_names(); + (func(args, arr[Is]), ...); +} + +template +inline constexpr void visit_members_impl(Visit&& func, + std::index_sequence, + Args&... args) { + constexpr auto arr = get_member_names(); + (func(args, arr[Is], Is), ...); +} + template inline constexpr void for_each(T&& t, Visit&& func) { using Tuple = decltype(object_to_tuple(t)); @@ -156,22 +214,35 @@ inline constexpr void for_each(T&& t, Visit&& func) { }); } else { - constexpr auto arr = member_names; if constexpr (std::is_invocable_v) { visit_members(t, [&](auto&... args) { +#if __cplusplus >= 202002L || defined(_MSC_VER) [&](std::index_sequence) mutable { + constexpr auto arr = get_member_names(); (func(args, arr[Is]), ...); } - (std::make_index_sequence{}); + (std::make_index_sequence{}); +#else + visit_members_impl0(std::forward(func), + std::make_index_sequence{}, + args...); +#endif }); } else if constexpr (std::is_invocable_v) { visit_members(t, [&](auto&... args) { +#if __cplusplus >= 202002L [&](std::index_sequence) mutable { + constexpr auto arr = get_member_names(); (func(args, arr[Is], Is), ...); } - (std::make_index_sequence{}); + (std::make_index_sequence{}); +#else + visit_members_impl(std::forward(func), + std::make_index_sequence{}, + args...); +#endif }); } else { @@ -187,8 +258,10 @@ inline constexpr void for_each(T&& t, Visit&& func) { #if (defined(__GNUC__) && __GNUC__ > 10) || \ ((defined(__clang__) || defined(_MSC_VER)) && __has_include()) +#if __has_include() template inline constexpr auto operator""_ylts() { return s; } #endif +#endif diff --git a/include/ylt/reflection/private_visitor.hpp b/include/ylt/reflection/private_visitor.hpp index c6459dbc8..7aeb8a63f 100644 --- a/include/ylt/reflection/private_visitor.hpp +++ b/include/ylt/reflection/private_visitor.hpp @@ -1,4 +1,6 @@ #pragma once +#include + #include "internal/common_macro.hpp" namespace ylt::reflection { diff --git a/include/ylt/reflection/user_reflect_macro.hpp b/include/ylt/reflection/user_reflect_macro.hpp index 9aeee665c..75808c956 100644 --- a/include/ylt/reflection/user_reflect_macro.hpp +++ b/include/ylt/reflection/user_reflect_macro.hpp @@ -6,6 +6,9 @@ #include "internal/arg_list_macro.hpp" namespace ylt::reflection { +template +using remove_cvref_t = std::remove_cv_t>; + template struct member_traits { using value_type = T; @@ -20,32 +23,34 @@ struct member_traits { template using member_value_type_t = typename member_traits::value_type; -#define YLT_REFL(STRUCT, ...) \ - template \ - inline static constexpr decltype(auto) refl_visit_members( \ - STRUCT &t, Visitor &&visitor) { \ - return visitor(WRAP_ARGS(CONCAT_MEMBER, t, __VA_ARGS__)); \ - } \ - template \ - inline static constexpr decltype(auto) refl_visit_members( \ - const STRUCT &t, Visitor &&visitor) { \ - return visitor(WRAP_ARGS(CONCAT_MEMBER, t, __VA_ARGS__)); \ - } \ - inline static decltype(auto) refl_object_to_tuple(STRUCT &t) { \ - return std::tie(WRAP_ARGS(CONCAT_MEMBER, t, __VA_ARGS__)); \ - } \ - inline static decltype(auto) refl_object_to_tuple(const STRUCT &t) { \ - return std::tie(WRAP_ARGS(CONCAT_MEMBER, t, __VA_ARGS__)); \ - } \ - inline static constexpr decltype(auto) refl_member_names( \ - const ylt::reflection::identity &t) { \ - constexpr std::array arr{ \ - WRAP_ARGS(CONCAT_NAME, t, __VA_ARGS__)}; \ - return arr; \ - } \ - inline static constexpr std::size_t refl_member_count( \ - const ylt::reflection::identity &t) { \ - return (std::size_t)YLT_ARG_COUNT(__VA_ARGS__); \ +#define YLT_REFL(STRUCT, ...) \ + template \ + inline static constexpr decltype(auto) refl_visit_members( \ + STRUCT &t, Visitor &&visitor) { \ + return visitor(WRAP_ARGS(CONCAT_MEMBER, t, ##__VA_ARGS__)); \ + } \ + template \ + inline static constexpr decltype(auto) refl_visit_members( \ + const STRUCT &t, Visitor &&visitor) { \ + return visitor(WRAP_ARGS(CONCAT_MEMBER, t, ##__VA_ARGS__)); \ + } \ + [[maybe_unused]] inline static decltype(auto) refl_object_to_tuple( \ + STRUCT &t) { \ + return std::tie(WRAP_ARGS(CONCAT_MEMBER, t, ##__VA_ARGS__)); \ + } \ + [[maybe_unused]] inline static decltype(auto) refl_object_to_tuple( \ + const STRUCT &t) { \ + return std::tie(WRAP_ARGS(CONCAT_MEMBER, t, ##__VA_ARGS__)); \ + } \ + [[maybe_unused]] inline static constexpr decltype(auto) refl_member_names( \ + const ylt::reflection::identity &t) { \ + constexpr std::array arr{ \ + WRAP_ARGS(CONCAT_NAME, t, ##__VA_ARGS__)}; \ + return arr; \ + } \ + [[maybe_unused]] inline static constexpr std::size_t refl_member_count( \ + const ylt::reflection::identity &t) { \ + return (std::size_t)YLT_ARG_COUNT(__VA_ARGS__); \ } template @@ -78,7 +83,7 @@ inline static decltype(auto) refl_object_to_tuple_impl(T &&t) { #define YLT_REFL_PRIVATE_(STRUCT, ...) \ namespace ylt::reflection { \ inline constexpr auto get_private_ptrs(const identity &t); \ - template struct private_visitor; \ + template struct private_visitor; \ template \ inline static constexpr decltype(auto) refl_visit_members( \ STRUCT &t, Visitor &&visitor) { \ @@ -105,10 +110,10 @@ inline static decltype(auto) refl_object_to_tuple_impl(T &&t) { inline static constexpr decltype(auto) refl_member_names( \ const ylt::reflection::identity &t) { \ constexpr std::array arr{ \ - WRAP_ARGS(CONCAT_NAME, t, __VA_ARGS__)}; \ + WRAP_ARGS(CONCAT_NAME, t, ##__VA_ARGS__)}; \ return arr; \ } \ - YLT_REFL_PRIVATE_(STRUCT, WRAP_ARGS(CONCAT_ADDR, STRUCT, __VA_ARGS__)) + YLT_REFL_PRIVATE_(STRUCT, WRAP_ARGS(CONCAT_ADDR, STRUCT, ##__VA_ARGS__)) template struct is_out_ylt_refl : std::false_type {}; @@ -136,7 +141,7 @@ template struct is_ylt_refl : std::false_type {}; template -inline constexpr bool is_ylt_refl_v = is_ylt_refl::value; +inline constexpr bool is_ylt_refl_v = is_ylt_refl>::value; template struct is_ylt_refl>> @@ -145,4 +150,16 @@ struct is_ylt_refl>> template struct is_ylt_refl>> : std::true_type { }; + +template +struct is_custom_reflect : std::false_type {}; + +template +struct is_custom_reflect< + T, std::void_t> + : std::true_type {}; + +template +inline constexpr bool is_custom_refl_v = + is_custom_reflect>::value; } // namespace ylt::reflection diff --git a/include/ylt/standalone/iguana/common.hpp b/include/ylt/standalone/iguana/common.hpp new file mode 100644 index 000000000..2fc6f1f10 --- /dev/null +++ b/include/ylt/standalone/iguana/common.hpp @@ -0,0 +1,280 @@ +#pragma once +#include + +#include "util.hpp" + +namespace iguana { +struct iguana_adl_t {}; + +namespace detail { +template +struct identity {}; + +struct field_info { + size_t offset; + std::string_view type_name; +}; + +struct base { + virtual void to_pb(std::string& str) const {} + virtual void from_pb(std::string_view str) {} + virtual void to_xml(std::string& str) const {} + virtual void from_xml(std::string_view str) {} + virtual void to_json(std::string& str) const {} + virtual void from_json(std::string_view str) {} + virtual void to_yaml(std::string& str) const {} + virtual void from_yaml(std::string_view str) {} + virtual std::vector get_fields_name() const { return {}; } + virtual std::any get_field_any(std::string_view name) const { return {}; } + virtual iguana::detail::field_info get_field_info( + std::string_view name) const { + return {}; + } + + template + T& get_field_value(std::string_view name) { + auto info = get_field_info(name); + check_field(name, info); + auto ptr = (((char*)this) + info.offset); + return *((T*)ptr); + } + + template + void set_field_value(std::string_view name, T val) { + auto info = get_field_info(name); + check_field(name, info); + + auto ptr = (((char*)this) + info.offset); + + static_assert(std::is_constructible_v, "can not assign"); + + *((FiledType*)ptr) = std::move(val); + } + virtual ~base() {} + + private: + template + void check_field(std::string_view name, const field_info& info) { + if (info.offset == 0) { + throw std::invalid_argument(std::string(name) + " field not exist "); + } + +#if defined(__clang__) || defined(_MSC_VER) || \ + (defined(__GNUC__) && __GNUC__ > 8) + if (info.type_name != iguana::type_string()) { + std::string str = "type is not match: can not assign "; + str.append(iguana::type_string()); + str.append(" to ").append(info.type_name); + + throw std::invalid_argument(str); + } +#endif + } +}; + +inline std::unordered_map()>> + g_pb_map; + +template +struct field_type_t; + +template +struct field_type_t> { + using value_type = std::variant; +}; + +template +constexpr size_t count_variant_size() { + if constexpr (is_variant::value) { + return std::variant_size_v; + } + else { + return 1; + } +} + +template +constexpr size_t tuple_type_count_impl(std::index_sequence) { + return ( + (count_variant_size>>() + + ...)); +} + +template +constexpr size_t tuple_type_count() { + return tuple_type_count_impl( + std::make_index_sequence>{}); +} + +template +constexpr auto inline get_members_impl(Tuple&& tp, std::index_sequence) { + return frozen::unordered_map{ + {std::get(tp).field_no, + T{std::in_place_index, std::move(std::get(tp))}}...}; +} + +template +struct is_custom_reflection : std::false_type {}; + +template +struct is_custom_reflection< + T, std::void_t()))>> + : std::true_type {}; + +template +inline constexpr bool is_custom_reflection_v = + is_custom_reflection>::value; + +// owner_type: parant type, value_type: member value type, SubType: subtype from +// variant +template +struct pb_field_t { + using owner_type = ylt::reflection::remove_cvref_t; + using value_type = Value; + using sub_type = ElementType; + + // constexpr pb_field_t() = default; + auto& value(owner_type& value) const { + auto member_ptr = (value_type*)((char*)(&value) + offset); + return *member_ptr; + } + auto const& value(const owner_type& value) const { + auto member_ptr = (value_type*)((char*)(&value) + offset); + return *member_ptr; + } + + size_t offset; + std::string_view field_name; + + inline static constexpr uint32_t field_no = FieldNo; +}; + +template +constexpr inline auto get_field_no_impl(Array& arr, size_t& index) { + arr[I] = index; + if constexpr (is_variant::value) { + constexpr size_t variant_size = std::variant_size_v; + index += (variant_size); + } + else { + index++; + return; + } +} + +template +inline constexpr auto get_field_no(std::index_sequence) { + std::array arr{}; + size_t index = 0; + (get_field_no_impl< + I, ylt::reflection::remove_cvref_t>>( + arr, index), + ...); + return arr; +} + +template +constexpr inline auto build_pb_variant_fields(size_t offset, + std::string_view name, + std::index_sequence) { + return std::tuple( + pb_field_t>{offset, name}...); +} + +template +constexpr inline auto build_pb_fields_impl(size_t offset, + std::string_view name) { + using value_type = ylt::reflection::remove_cvref_t; + using U = std::remove_reference_t; + + if constexpr (is_variant::value) { + constexpr uint32_t variant_size = std::variant_size_v; + return build_pb_variant_fields( + offset, name, std::make_index_sequence{}); + } + else { + return std::tuple(pb_field_t{offset, name}); + } +} + +template +inline auto build_pb_fields(const Array& offset_arr, + std::index_sequence) { + constexpr auto arr = ylt::reflection::get_member_names(); + constexpr std::array indexs = + get_field_no(std::make_index_sequence{}); + return std::tuple_cat( + build_pb_fields_impl>( + offset_arr[I], arr[I])...); +} + +template +inline auto get_pb_members_tuple(T&& t) { + using U = ylt::reflection::remove_cvref_t; + if constexpr (ylt_refletable_v) { + static auto& offset_arr = ylt::reflection::internal::get_member_offset_arr( + ylt::reflection::internal::wrapper::value); + using Tuple = decltype(ylt::reflection::object_to_tuple(std::declval())); + return build_pb_fields( + offset_arr, std::make_index_sequence>{}); + } + else if constexpr (is_custom_reflection_v) { + return get_members_impl((U*)nullptr); + } + else { + static_assert(!sizeof(T), "not a reflectable type"); + } +} + +template +inline auto get_members(T&& t) { + if constexpr (ylt_refletable_v || is_custom_reflection_v) { + static auto tp = get_pb_members_tuple(std::forward(t)); + using Tuple = std::decay_t; + using value_type = typename field_type_t::value_type; + constexpr auto Size = tuple_type_count(); + return get_members_impl(tp, + std::make_index_sequence{}); + } + else { + static_assert(!sizeof(T), "expected reflection or custom reflection"); + } +} +} // namespace detail + +template +inline bool register_type() { +#if defined(__clang__) || defined(_MSC_VER) || \ + (defined(__GNUC__) && __GNUC__ > 8) + if constexpr (std::is_base_of_v) { + auto it = detail::g_pb_map.emplace(type_string(), [] { + return std::make_shared(); + }); + return it.second; + } + else { + return true; + } +#else + return true; +#endif +} + +template +IGUANA_INLINE constexpr size_t member_offset(T* t, U T::*member) { + return (char*)&(t->*member) - (char*)t; +} + +template +IGUANA_INLINE auto build_pb_field(std::string_view name) { + using owner = + typename ylt::reflection::member_traits::owner_type; + using value_type = + typename ylt::reflection::member_traits::value_type; + size_t offset = member_offset((owner*)nullptr, ptr); + return iguana::detail::pb_field_t{offset, name}; +} +} // namespace iguana \ No newline at end of file diff --git a/include/ylt/standalone/iguana/detail/pb_type.hpp b/include/ylt/standalone/iguana/detail/pb_type.hpp index 2d17cb8e4..d9a2c7910 100644 --- a/include/ylt/standalone/iguana/detail/pb_type.hpp +++ b/include/ylt/standalone/iguana/detail/pb_type.hpp @@ -1,4 +1,5 @@ #pragma once +#include #include namespace iguana { diff --git a/include/ylt/standalone/iguana/detail/traits.hpp b/include/ylt/standalone/iguana/detail/traits.hpp index 57a9fa45d..a62d3238e 100644 --- a/include/ylt/standalone/iguana/detail/traits.hpp +++ b/include/ylt/standalone/iguana/detail/traits.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "iguana/define.h" diff --git a/include/ylt/standalone/iguana/dynamic.hpp b/include/ylt/standalone/iguana/dynamic.hpp index cfb5b116c..47cf20154 100644 --- a/include/ylt/standalone/iguana/dynamic.hpp +++ b/include/ylt/standalone/iguana/dynamic.hpp @@ -1,14 +1,9 @@ #pragma once -#include "reflection.hpp" +#include "common.hpp" namespace iguana { using base = detail::base; -template -IGUANA_INLINE constexpr size_t member_offset(T* t, U T::*member) { - return (char*)&(t->*member) - (char*)t; -} - constexpr inline uint8_t ENABLE_JSON = 0x01; constexpr inline uint8_t ENABLE_YAML = 0x02; constexpr inline uint8_t ENABLE_XML = 0x04; @@ -17,9 +12,10 @@ constexpr inline uint8_t ENABLE_ALL = 0x0F; template struct base_impl : public base { - void to_pb(std::string& str) override { + base_impl() { [[maybe_unused]] static bool r = register_type(); } + void to_pb(std::string& str) const override { if constexpr ((ENABLE_FLAG & ENABLE_PB) != 0) { - to_pb_adl((iguana_adl_t*)nullptr, *(static_cast(this)), str); + to_pb_adl((iguana_adl_t*)nullptr, *(static_cast(this)), str); } else { throw std::runtime_error("Protobuf Disabled"); @@ -35,9 +31,9 @@ struct base_impl : public base { } } - void to_json(std::string& str) override { + void to_json(std::string& str) const override { if constexpr ((ENABLE_FLAG & ENABLE_JSON) != 0) { - to_json_adl((iguana_adl_t*)nullptr, *(static_cast(this)), str); + to_json_adl((iguana_adl_t*)nullptr, *(static_cast(this)), str); } else { throw std::runtime_error("Json Disabled"); @@ -53,9 +49,9 @@ struct base_impl : public base { } } - void to_xml(std::string& str) override { + void to_xml(std::string& str) const override { if constexpr ((ENABLE_FLAG & ENABLE_XML) != 0) { - to_xml_adl((iguana_adl_t*)nullptr, *(static_cast(this)), str); + to_xml_adl((iguana_adl_t*)nullptr, *(static_cast(this)), str); } else { throw std::runtime_error("Xml Disabled"); @@ -71,9 +67,9 @@ struct base_impl : public base { } } - void to_yaml(std::string& str) override { + void to_yaml(std::string& str) const override { if constexpr ((ENABLE_FLAG & ENABLE_YAML) != 0) { - to_yaml_adl((iguana_adl_t*)nullptr, *(static_cast(this)), str); + to_yaml_adl((iguana_adl_t*)nullptr, *(static_cast(this)), str); } else { throw std::runtime_error("Yaml Disabled"); @@ -89,18 +85,21 @@ struct base_impl : public base { } } - iguana::detail::field_info get_field_info(std::string_view name) override { - static constexpr auto map = iguana::get_members(); + iguana::detail::field_info get_field_info( + std::string_view name) const override { + static auto map = + detail::get_members(ylt::reflection::internal::wrapper::value); iguana::detail::field_info info{}; - for (auto& [no, field] : map) { + for (auto const& [no, field] : map) { if (info.offset > 0) { break; } std::visit( - [&](auto val) { + [&](auto const& val) { if (val.field_name == name) { - info.offset = member_offset((T*)this, val.member_ptr); - using value_type = typename decltype(val)::value_type; + info.offset = val.offset; + using value_type = + typename std::remove_reference_t::value_type; #if defined(__clang__) || defined(_MSC_VER) || \ (defined(__GNUC__) && __GNUC__ > 8) info.type_name = type_string(); @@ -114,7 +113,8 @@ struct base_impl : public base { } std::vector get_fields_name() const override { - static constexpr auto map = iguana::get_members(); + static auto map = + detail::get_members(ylt::reflection::internal::wrapper::value); std::vector vec; @@ -133,20 +133,21 @@ struct base_impl : public base { } std::any get_field_any(std::string_view name) const override { - static constexpr auto map = iguana::get_members(); + static auto map = + detail::get_members(ylt::reflection::internal::wrapper::value); std::any result; - for (auto [no, field] : map) { + for (auto const& [no, field] : map) { if (result.has_value()) { break; } std::visit( - [&](auto val) { + [&](auto const& val) { if (val.field_name == name) { - using value_type = typename decltype(val)::value_type; - auto const offset = member_offset((T*)this, val.member_ptr); - auto ptr = (((char*)this) + offset); - result = {*((value_type*)ptr)}; + using value_type = + typename std::remove_reference_t::value_type; + auto ptr = (char*)this + val.offset; + result = *((value_type*)ptr); } }, field); @@ -157,7 +158,7 @@ struct base_impl : public base { virtual ~base_impl() {} - size_t cache_size = 0; + mutable size_t cache_size = 0; }; IGUANA_INLINE std::shared_ptr create_instance(std::string_view name) { diff --git a/include/ylt/standalone/iguana/enum_reflection.hpp b/include/ylt/standalone/iguana/field_reflection.hpp similarity index 96% rename from include/ylt/standalone/iguana/enum_reflection.hpp rename to include/ylt/standalone/iguana/field_reflection.hpp index 9b871f8c9..dc159b8c6 100644 --- a/include/ylt/standalone/iguana/enum_reflection.hpp +++ b/include/ylt/standalone/iguana/field_reflection.hpp @@ -59,6 +59,12 @@ inline constexpr std::string_view enum_string() { return s1; } +template +inline constexpr std::string_view field_string() { + constexpr std::string_view raw_name = enum_string(); + return raw_name.substr(raw_name.rfind(":") + 1); +} + #if defined(__clang__) && (__clang_major__ >= 17) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wenum-constexpr-conversion" diff --git a/include/ylt/standalone/iguana/json_reader.hpp b/include/ylt/standalone/iguana/json_reader.hpp index d433f0170..765815fe3 100644 --- a/include/ylt/standalone/iguana/json_reader.hpp +++ b/include/ylt/standalone/iguana/json_reader.hpp @@ -4,9 +4,18 @@ #include "json_util.hpp" namespace iguana { -template , int> = 0> +template , int> = 0> IGUANA_INLINE void from_json(T &value, It &&it, It &&end); +template , int> = 0> +IGUANA_INLINE void from_json(T &value, const View &view); + +template , int> = 0> +IGUANA_INLINE void from_json(T &value, const View &view); + namespace detail { template , int> = 0> IGUANA_INLINE void from_json_impl(U &value, It &&it, It &&end); -template , int> = 0> +template , int> = 0> IGUANA_INLINE void from_json_impl(U &value, It &&it, It &&end) { from_json(value, it, end); } @@ -86,10 +96,10 @@ IGUANA_INLINE void from_json_impl(U &value, It &&it, It &&end) { } } -template , int> = 0> -IGUANA_INLINE void from_json_impl(U &value, It &&it, It &&end) { - from_json_impl(value.val, it, end); -} +// template , int> = +// 0> IGUANA_INLINE void from_json_impl(U &value, It &&it, It &&end) { +// from_json_impl(value.val, it, end); +// } template , int> = 0> IGUANA_INLINE void from_json_impl(U &value, It &&it, It &&end) { @@ -404,18 +414,20 @@ IGUANA_INLINE void from_json_impl(U &value, It &&it, It &&end) { match<'['>(it, end); skip_ws(it, end); - for_each(value, [&](auto &v, auto i) IGUANA__INLINE_LAMBDA { - constexpr auto I = decltype(i)::value; - if (it == end || *it == ']') { - return; - } - if constexpr (I != 0) { - match<','>(it, end); - skip_ws(it, end); - } - from_json_impl(v, it, end); - skip_ws(it, end); - }); + foreach_tuple( + [&](auto &v, auto i) IGUANA__INLINE_LAMBDA { + constexpr auto I = decltype(i)::value; + if (it == end || *it == ']') { + return; + } + if constexpr (I != 0) { + match<','>(it, end); + skip_ws(it, end); + } + from_json_impl(v, it, end); + skip_ws(it, end); + }, + value); match<']'>(it, end); } @@ -542,7 +554,7 @@ IGUANA_INLINE void from_json_impl(U &value, It &&it, It &&end) { } } // namespace detail -template , int>> +template , int>> IGUANA_INLINE void from_json(T &value, It &&it, It &&end) { skip_ws(it, end); match<'{'>(it, end); @@ -553,80 +565,80 @@ IGUANA_INLINE void from_json(T &value, It &&it, It &&end) { ++it; return; } - std::string_view key = detail::get_key(it, end); + using U = ylt::reflection::remove_cvref_t; + constexpr auto Count = ylt::reflection::members_count_v; + if constexpr (Count > 0) { + std::string_view key = detail::get_key(it, end); #ifdef SEQUENTIAL_PARSE - bool parse_done = false; - for_each(value, [&](const auto member_ptr, auto i) IGUANA__INLINE_LAMBDA { - constexpr auto mkey = iguana::get_name(); - constexpr std::string_view st_key(mkey.data(), mkey.size()); - if (parse_done || (key != st_key)) - IGUANA_UNLIKELY { return; } - skip_ws(it, end); - match<':'>(it, end); - { - using namespace detail; - from_json_impl(value.*member_ptr, it, end); + bool parse_done = false; + ylt::reflection::for_each( + value, [&](auto &field, auto name, auto index) IGUANA__INLINE_LAMBDA { + if (parse_done || (key != name)) + IGUANA_UNLIKELY { return; } + skip_ws(it, end); + match<':'>(it, end); + { + using namespace detail; + from_json_impl(field, it, end); + } + + skip_ws(it, end); + if (*it == '}') + IGUANA_UNLIKELY { + ++it; + parse_done = true; + return; + } + else + IGUANA_LIKELY { match<','>(it, end); } + key = detail::get_key(it, end); + }); + if (parse_done) [[unlikely]] { + return; } - - skip_ws(it, end); - if (*it == '}') - IGUANA_UNLIKELY { - ++it; - parse_done = true; - return; - } - else - IGUANA_LIKELY { match<','>(it, end); } - key = detail::get_key(it, end); - }); - if (parse_done) [[unlikely]] { - return; - } #endif - while (it != end) { - static constexpr auto frozen_map = get_iguana_struct_map(); - if constexpr (frozen_map.size() > 0) { - const auto &member_it = frozen_map.find(key); - skip_ws(it, end); - match<':'>(it, end); - if (member_it != frozen_map.end()) - IGUANA_LIKELY { - std::visit( - [&](auto &&member_ptr) IGUANA__INLINE_LAMBDA { - using V = std::decay_t; - if constexpr (std::is_member_pointer_v) { + while (it != end) { + static auto frozen_map = ylt::reflection::get_variant_map(); + if (frozen_map.size() > 0) { + const auto &member_it = frozen_map.find(key); + skip_ws(it, end); + match<':'>(it, end); + if (member_it != frozen_map.end()) + IGUANA_LIKELY { + std::visit( + [&](auto offset) IGUANA__INLINE_LAMBDA { using namespace detail; - from_json_impl(value.*member_ptr, it, end); - } - else { - static_assert(!sizeof(V), "type not supported"); - } - }, - member_it->second); - } - else - IGUANA_UNLIKELY { + using value_type = typename decltype(offset)::type; + auto member_ptr = + (value_type *)((char *)(&value) + offset.value); + from_json_impl(*member_ptr, it, end); + }, + member_it->second); + } + else + IGUANA_UNLIKELY { #ifdef THROW_UNKNOWN_KEY - throw std::runtime_error("Unknown key: " + std::string(key)); + throw std::runtime_error("Unknown key: " + std::string(key)); #else - detail::skip_object_value(it, end); + detail::skip_object_value(it, end); #endif + } + } + skip_ws(it, end); + if (*it == '}') + IGUANA_UNLIKELY { + ++it; + return; } + else + IGUANA_LIKELY { match<','>(it, end); } + key = detail::get_key(it, end); } - skip_ws(it, end); - if (*it == '}') - IGUANA_UNLIKELY { - ++it; - return; - } - else - IGUANA_LIKELY { match<','>(it, end); } - key = detail::get_key(it, end); } } template , int> = 0> + std::enable_if_t, int> = 0> IGUANA_INLINE void from_json(T &value, It &&it, It &&end) { using namespace detail; from_json_impl(value, it, end); @@ -643,35 +655,15 @@ IGUANA_INLINE void from_json(T &value, It &&it, It &&end, } } -template , int> = 0> +template , int>> IGUANA_INLINE void from_json(T &value, const View &view) { from_json(value, std::begin(view), std::end(view)); } -template < - auto member, - typename Parant = typename member_tratis::owner_type, - typename T> -IGUANA_INLINE void from_json(T &value, std::string_view str) { - constexpr size_t duplicate_count = - iguana::duplicate_count, member>(); - static_assert(duplicate_count != 1, "the member is not belong to the object"); - static_assert(duplicate_count == 2, "has duplicate field name"); - - constexpr auto name = name_of(); - constexpr size_t index = index_of(); - constexpr size_t member_count = member_count_of(); - str = str.substr(str.find(name) + name.size()); - size_t pos = str.find(":") + 1; - if constexpr (index == member_count - 1) { // last field - str = str.substr(pos, str.find("}") - pos + 1); - } - else { - str = str.substr(pos, str.find(",") - pos); - } - - detail::from_json_impl(value.*member, std::begin(str), std::end(str)); +template , int>> +IGUANA_INLINE void from_json(T &value, const View &view) { + from_json(value, std::begin(view), std::end(view)); } template , int> = 0> + std::enable_if_t, int> = 0> IGUANA_INLINE void to_json(T &&t, Stream &s); namespace detail { template @@ -76,11 +76,11 @@ IGUANA_INLINE void to_json_impl(Stream &ss, T value) { ss.append(temp, p - temp); } -template , int> = 0> -IGUANA_INLINE void to_json_impl(Stream &ss, T value) { - to_json_impl(ss, value.val); -} +// template , int> = 0> +// IGUANA_INLINE void to_json_impl(Stream &ss, T value) { +// to_json_impl(ss, value.val); +// } template , int> = 0> @@ -109,11 +109,11 @@ IGUANA_INLINE void render_key(Stream &ss, const T &t) { ss.push_back('"'); } -template , int> = 0> -IGUANA_INLINE void render_key(Stream &ss, const T &t) { - render_key(ss, t.val); -} +// template , int> = 0> +// IGUANA_INLINE void render_key(Stream &ss, const T &t) { +// render_key(ss, t.val); +// } template , int> = 0> @@ -122,7 +122,7 @@ IGUANA_INLINE void render_key(Stream &ss, T &&t) { } template , int> = 0> + std::enable_if_t, int> = 0> IGUANA_INLINE void to_json_impl(Stream &ss, T &&t) { to_json(std::forward(t), ss); } @@ -218,11 +218,9 @@ IGUANA_INLINE void to_json_impl(Stream &ss, const T &v) { ss.push_back(']'); } -constexpr auto write_json_key = [](auto &s, auto i, - auto &t) IGUANA__INLINE_LAMBDA { +constexpr auto write_json_key = [](auto &s, auto name) IGUANA__INLINE_LAMBDA { s.push_back('"'); // will be replaced by string_view later - constexpr auto name = get_name(); s.append(name.data(), name.size()); s.push_back('"'); }; @@ -244,13 +242,14 @@ IGUANA_INLINE void to_json_impl(Stream &s, T &&t) { using U = typename std::decay_t; s.push_back('['); constexpr size_t size = std::tuple_size_v; - for_each(std::forward(t), - [&s, size](auto &v, auto i) IGUANA__INLINE_LAMBDA { - to_json_impl(s, v); + foreach_tuple( + [&s, size](auto &v, auto i) IGUANA__INLINE_LAMBDA { + to_json_impl(s, v); - if (i != size - 1) - IGUANA_LIKELY { s.push_back(','); } - }); + if (i != size - 1) + IGUANA_LIKELY { s.push_back(','); } + }, + std::forward(t)); s.push_back(']'); } @@ -267,28 +266,27 @@ IGUANA_INLINE void to_json_impl(Stream &s, T &&t) { } } // namespace detail template , int>> + std::enable_if_t, int>> IGUANA_INLINE void to_json(T &&t, Stream &s) { using namespace detail; s.push_back('{'); - for_each(std::forward(t), - [&t, &s](const auto &v, auto i) IGUANA__INLINE_LAMBDA { - using M = decltype(iguana_reflect_type(std::forward(t))); - constexpr auto Idx = decltype(i)::value; - constexpr auto Count = M::value(); - static_assert(Idx < Count); - - write_json_key(s, i, t); - s.push_back(':'); - to_json_impl(s, t.*v); - if (Idx < Count - 1) - IGUANA_LIKELY { s.push_back(','); } - }); + using U = ylt::reflection::remove_cvref_t; + constexpr auto Count = ylt::reflection::members_count_v; + if constexpr (Count > 0) { + ylt::reflection::for_each(t, [&](auto &field, auto name, auto index) { + write_json_key(s, name); + s.push_back(':'); + to_json_impl(s, field); + if (index < Count - 1) + IGUANA_LIKELY { s.push_back(','); } + }); + } + s.push_back('}'); } template , int> = 0> + std::enable_if_t, int> = 0> IGUANA_INLINE void to_json(T &&t, Stream &s) { using namespace detail; to_json_impl(s, t); diff --git a/include/ylt/standalone/iguana/pb_reader.hpp b/include/ylt/standalone/iguana/pb_reader.hpp index 83d2425d4..a91a6969a 100644 --- a/include/ylt/standalone/iguana/pb_reader.hpp +++ b/include/ylt/standalone/iguana/pb_reader.hpp @@ -27,7 +27,7 @@ template IGUANA_INLINE void from_pb_impl(T& val, std::string_view& pb_str, uint32_t field_no) { size_t pos = 0; - if constexpr (is_reflection_v) { + if constexpr (ylt_refletable_v) { size_t pos; uint32_t size = detail::decode_varint(pb_str, pos); pb_str = pb_str.substr(pos); @@ -191,14 +191,16 @@ IGUANA_INLINE void from_pb(T& t, std::string_view pb_str) { WireType wire_type = static_cast(key & 0b0111); uint32_t field_number = key >> 3; #ifdef SEQUENTIAL_PARSE - constexpr static auto tp = get_members_tuple(); + static auto tp = detail::get_pb_members_tuple(t); constexpr size_t SIZE = std::tuple_size_v>; bool parse_done = false; + auto ptr = &t; detail::for_each_n( - [&](auto i) IGUANA__INLINE_LAMBDA { - constexpr auto val = std::get(tp); + [&, ptr](auto i) IGUANA__INLINE_LAMBDA { + auto val = std::get(tp); using sub_type = typename std::decay_t::sub_type; using value_type = typename std::decay_t::value_type; + constexpr bool is_variant_v = variant_v; // sub_type is the element type when value_type is the variant type; // otherwise, they are the same. if (parse_done || field_number != val.field_no) { @@ -207,11 +209,13 @@ IGUANA_INLINE void from_pb(T& t, std::string_view pb_str) { pb_str = pb_str.substr(pos); if (wire_type != detail::get_wire_type()) IGUANA_UNLIKELY { throw std::runtime_error("unmatched wire_type"); } - if constexpr (variant_v) { - detail::parse_oneof(val.value(t), val, pb_str); + + auto member_ptr = (value_type*)((char*)(ptr) + val.offset); + if constexpr (is_variant_v) { + detail::parse_oneof(*member_ptr, val, pb_str); } else { - detail::from_pb_impl(val.value(t), pb_str, val.field_no); + detail::from_pb_impl(*member_ptr, pb_str, val.field_no); } if (pb_str.empty()) { parse_done = true; @@ -227,7 +231,7 @@ IGUANA_INLINE void from_pb(T& t, std::string_view pb_str) { #endif while (true) { pb_str = pb_str.substr(pos); - constexpr static auto map = get_members(); + static auto map = detail::get_members(std::forward(t)); auto& member = map.at(field_number); std::visit( [&t, &pb_str, wire_type](auto& val) { diff --git a/include/ylt/standalone/iguana/pb_util.hpp b/include/ylt/standalone/iguana/pb_util.hpp index 5fa7365cd..a2f1923a2 100644 --- a/include/ylt/standalone/iguana/pb_util.hpp +++ b/include/ylt/standalone/iguana/pb_util.hpp @@ -13,8 +13,8 @@ #include #include +#include "common.hpp" #include "detail/pb_type.hpp" -#include "reflection.hpp" #include "util.hpp" namespace iguana { @@ -60,7 +60,7 @@ constexpr inline WireType get_wire_type() { } else if constexpr (std::is_same_v || std::is_same_v || - is_reflection_v || is_sequence_container::value || + ylt_refletable_v || is_sequence_container::value || is_map_container::value) { return WireType::LengthDelimeted; } @@ -419,6 +419,7 @@ IGUANA_INLINE size_t pb_oneof_size(Type&& t, Arr& size_arr) { int len = 0; std::visit( [&len, &size_arr](auto&& value) IGUANA__INLINE_LAMBDA { + using raw_value_type = decltype(value); using value_type = std::remove_const_t>; constexpr auto offset = @@ -427,7 +428,7 @@ IGUANA_INLINE size_t pb_oneof_size(Type&& t, Arr& size_arr) { ((field_no + offset) << 3) | static_cast(get_wire_type()); len = pb_key_value_size( - std::forward(value), size_arr); + std::forward(value), size_arr); }, std::forward(t)); return len; @@ -438,9 +439,9 @@ IGUANA_INLINE size_t pb_oneof_size(Type&& t, Arr& size_arr) { template IGUANA_INLINE size_t pb_key_value_size(Type&& t, Arr& size_arr) { using T = std::remove_const_t>; - if constexpr (is_reflection_v || is_custom_reflection_v) { + if constexpr (ylt_refletable_v || is_custom_reflection_v) { size_t len = 0; - static constexpr auto tuple = get_members_tuple(); + static auto tuple = get_pb_members_tuple(std::forward(t)); constexpr size_t SIZE = std::tuple_size_v>; size_t pre_index = -1; if constexpr (!inherits_from_base_v && key_size != 0) { @@ -452,13 +453,13 @@ IGUANA_INLINE size_t pb_key_value_size(Type&& t, Arr& size_arr) { using field_type = std::tuple_element_t>; - constexpr auto value = std::get(tuple); + auto value = std::get(tuple); using U = typename field_type::value_type; + using sub_type = typename field_type::sub_type; auto& val = value.value(t); if constexpr (variant_v) { constexpr auto offset = - get_variant_index - 1>(); + get_variant_index - 1>(); if constexpr (offset == 0) { len += pb_oneof_size(val, size_arr); } @@ -540,7 +541,7 @@ IGUANA_INLINE size_t pb_key_value_size(Type&& t, Arr& size_arr) { template IGUANA_INLINE size_t pb_value_size(Type&& t, uint32_t*& sz_ptr) { using T = std::remove_const_t>; - if constexpr (is_reflection_v || is_custom_reflection_v) { + if constexpr (ylt_refletable_v || is_custom_reflection_v) { if constexpr (inherits_from_base_v) { return t.cache_size; } diff --git a/include/ylt/standalone/iguana/pb_writer.hpp b/include/ylt/standalone/iguana/pb_writer.hpp index 4c39305a6..eac424011 100644 --- a/include/ylt/standalone/iguana/pb_writer.hpp +++ b/include/ylt/standalone/iguana/pb_writer.hpp @@ -83,6 +83,7 @@ IGUANA_INLINE void to_pb_oneof(Type&& t, It&& it, uint32_t*& sz_ptr) { using T = std::decay_t; std::visit( [&it, &sz_ptr](auto&& value) IGUANA__INLINE_LAMBDA { + using raw_value_type = decltype(value); using value_type = std::remove_const_t>; constexpr auto offset = @@ -90,7 +91,7 @@ IGUANA_INLINE void to_pb_oneof(Type&& t, It&& it, uint32_t*& sz_ptr) { constexpr uint32_t key = ((field_no + offset) << 3) | static_cast(get_wire_type()); - to_pb_impl(std::forward(value), it, sz_ptr); + to_pb_impl(std::forward(value), it, sz_ptr); }, std::forward(t)); } @@ -99,7 +100,7 @@ IGUANA_INLINE void to_pb_oneof(Type&& t, It&& it, uint32_t*& sz_ptr) { template IGUANA_INLINE void to_pb_impl(Type&& t, It&& it, uint32_t*& sz_ptr) { using T = std::remove_const_t>; - if constexpr (is_reflection_v || is_custom_reflection_v) { + if constexpr (ylt_refletable_v || is_custom_reflection_v) { // can't be omitted even if values are empty if constexpr (key != 0) { auto len = pb_value_size(t, sz_ptr); @@ -108,21 +109,21 @@ IGUANA_INLINE void to_pb_impl(Type&& t, It&& it, uint32_t*& sz_ptr) { if (len == 0) IGUANA_UNLIKELY { return; } } - static constexpr auto tuple = get_members_tuple(); + static auto tuple = get_pb_members_tuple(std::forward(t)); constexpr size_t SIZE = std::tuple_size_v>; for_each_n( [&t, &it, &sz_ptr](auto i) IGUANA__INLINE_LAMBDA { using field_type = std::tuple_element_t>; - constexpr auto value = std::get(tuple); + auto value = std::get(tuple); auto& val = value.value(t); using U = typename field_type::value_type; + using sub_type = typename field_type::sub_type; if constexpr (variant_v) { constexpr auto offset = - get_variant_index - 1>(); + get_variant_index - 1>(); if constexpr (offset == 0) { to_pb_oneof(val, it, sz_ptr); } @@ -296,10 +297,11 @@ IGUANA_INLINE void to_proto_impl( std::string_view field_name = "", uint32_t field_no = 0) { std::string sub_str; using T = std::remove_const_t>; - if constexpr (is_reflection_v || is_custom_reflection_v) { - constexpr auto name = get_name(); + if constexpr (ylt_refletable_v || is_custom_reflection_v) { + constexpr auto name = type_string(); out.append("message ").append(name).append(" {\n"); - static constexpr auto tuple = get_members_tuple(); + static T t; + static auto tuple = get_pb_members_tuple(t); constexpr size_t SIZE = std::tuple_size_v>; for_each_n( @@ -307,10 +309,11 @@ IGUANA_INLINE void to_proto_impl( using field_type = std::tuple_element_t>; - constexpr auto value = std::get(tuple); + auto value = std::get(tuple); using U = typename field_type::value_type; - if constexpr (is_reflection_v) { + using sub_type = typename field_type::sub_type; + if constexpr (ylt_refletable_v) { constexpr auto str_type = get_type_string(); build_proto_field( out, str_type, @@ -321,7 +324,6 @@ IGUANA_INLINE void to_proto_impl( } else if constexpr (variant_v) { constexpr size_t var_size = std::variant_size_v; - using sub_type = typename field_type::sub_type; constexpr auto offset = get_variant_index(); @@ -339,7 +341,7 @@ IGUANA_INLINE void to_proto_impl( out.append(" "); build_proto_field(out, str_type, field_name, value.field_no); - if constexpr (is_reflection_v) { + if constexpr (ylt_refletable_v) { build_sub_proto(map, str_type, sub_str); } @@ -362,7 +364,7 @@ IGUANA_INLINE void to_proto_impl( if constexpr (is_lenprefix_v) { // non-packed - if constexpr (is_reflection_v) { + if constexpr (ylt_refletable_v) { constexpr auto str_type = get_type_string(); build_proto_field(out, str_type, field_name, field_no); @@ -388,7 +390,7 @@ IGUANA_INLINE void to_proto_impl( build_proto_field<1>(out, "", field_name, field_no); - if constexpr (is_reflection_v) { + if constexpr (ylt_refletable_v) { constexpr auto str_type = get_type_string(); build_sub_proto(map, str_type, sub_str); } @@ -448,8 +450,11 @@ IGUANA_INLINE void build_sub_proto(Map& map, std::string_view str_type, #endif } // namespace detail -template -IGUANA_INLINE void to_pb(T& t, Stream& out) { +template < + typename T, typename Stream, + std::enable_if_t || detail::is_custom_reflection_v, + int> = 0> +IGUANA_INLINE void to_pb(T const& t, Stream& out) { std::vector size_arr; auto byte_len = detail::pb_key_value_size<0>(t, size_arr); detail::resize(out, byte_len); @@ -491,7 +496,7 @@ IGUANA_INLINE void to_proto_file(Stream& stream, std::string_view ns = "") { #endif template -IGUANA_INLINE void to_pb_adl(iguana_adl_t* p, T& t, Stream& out) { +IGUANA_INLINE void to_pb_adl(iguana_adl_t* p, T const& t, Stream& out) { to_pb(t, out); } diff --git a/include/ylt/standalone/iguana/reflection.hpp b/include/ylt/standalone/iguana/reflection.hpp deleted file mode 100644 index ceb605a44..000000000 --- a/include/ylt/standalone/iguana/reflection.hpp +++ /dev/null @@ -1,1347 +0,0 @@ -// -// Created by Qiyu on 17-6-5. -// - -#ifndef IGUANA_REFLECTION_HPP -#define IGUANA_REFLECTION_HPP -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "detail/string_stream.hpp" -#include "detail/traits.hpp" -#include "enum_reflection.hpp" -#include "frozen/string.h" -#include "frozen/unordered_map.h" - -namespace iguana::detail { -/******************************************/ -/* arg list expand macro, now support 120 args */ -#define MAKE_ARG_LIST_1(op, arg, ...) op(arg) -#define MAKE_ARG_LIST_2(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_1(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_3(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_2(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_4(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_3(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_5(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_4(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_6(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_5(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_7(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_6(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_8(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_7(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_9(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_8(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_10(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_9(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_11(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_10(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_12(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_11(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_13(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_12(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_14(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_13(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_15(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_14(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_16(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_15(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_17(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_16(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_18(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_17(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_19(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_18(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_20(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_19(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_21(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_20(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_22(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_21(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_23(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_22(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_24(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_23(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_25(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_24(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_26(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_25(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_27(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_26(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_28(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_27(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_29(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_28(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_30(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_29(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_31(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_30(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_32(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_31(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_33(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_32(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_34(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_33(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_35(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_34(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_36(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_35(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_37(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_36(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_38(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_37(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_39(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_38(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_40(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_39(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_41(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_40(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_42(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_41(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_43(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_42(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_44(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_43(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_45(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_44(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_46(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_45(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_47(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_46(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_48(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_47(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_49(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_48(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_50(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_49(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_51(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_50(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_52(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_51(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_53(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_52(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_54(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_53(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_55(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_54(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_56(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_55(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_57(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_56(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_58(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_57(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_59(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_58(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_60(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_59(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_61(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_60(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_62(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_61(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_63(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_62(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_64(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_63(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_65(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_64(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_66(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_65(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_67(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_66(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_68(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_67(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_69(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_68(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_70(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_69(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_71(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_70(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_72(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_71(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_73(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_72(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_74(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_73(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_75(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_74(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_76(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_75(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_77(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_76(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_78(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_77(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_79(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_78(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_80(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_79(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_81(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_80(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_82(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_81(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_83(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_82(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_84(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_83(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_85(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_84(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_86(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_85(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_87(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_86(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_88(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_87(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_89(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_88(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_90(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_89(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_91(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_90(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_92(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_91(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_93(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_92(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_94(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_93(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_95(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_94(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_96(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_95(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_97(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_96(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_98(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_97(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_99(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_98(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_100(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_99(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_101(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_100(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_102(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_101(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_103(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_102(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_104(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_103(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_105(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_104(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_106(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_105(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_107(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_106(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_108(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_107(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_109(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_108(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_110(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_109(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_111(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_110(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_112(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_111(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_113(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_112(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_114(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_113(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_115(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_114(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_116(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_115(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_117(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_116(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_118(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_117(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_119(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_118(op, __VA_ARGS__)) -#define MAKE_ARG_LIST_120(op, arg, ...) \ - op(arg), MARCO_EXPAND(MAKE_ARG_LIST_119(op, __VA_ARGS__)) - -#define ADD_VIEW(str) std::string_view(#str, sizeof(#str) - 1) - -#define SEPERATOR , -#define CON_STR_1(element, ...) ADD_VIEW(element) -#define CON_STR_2(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_1(__VA_ARGS__)) -#define CON_STR_3(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_2(__VA_ARGS__)) -#define CON_STR_4(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_3(__VA_ARGS__)) -#define CON_STR_5(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_4(__VA_ARGS__)) -#define CON_STR_6(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_5(__VA_ARGS__)) -#define CON_STR_7(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_6(__VA_ARGS__)) -#define CON_STR_8(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_7(__VA_ARGS__)) -#define CON_STR_9(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_8(__VA_ARGS__)) -#define CON_STR_10(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_9(__VA_ARGS__)) -#define CON_STR_11(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_10(__VA_ARGS__)) -#define CON_STR_12(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_11(__VA_ARGS__)) -#define CON_STR_13(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_12(__VA_ARGS__)) -#define CON_STR_14(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_13(__VA_ARGS__)) -#define CON_STR_15(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_14(__VA_ARGS__)) -#define CON_STR_16(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_15(__VA_ARGS__)) -#define CON_STR_17(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_16(__VA_ARGS__)) -#define CON_STR_18(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_17(__VA_ARGS__)) -#define CON_STR_19(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_18(__VA_ARGS__)) -#define CON_STR_20(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_19(__VA_ARGS__)) -#define CON_STR_21(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_20(__VA_ARGS__)) -#define CON_STR_22(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_21(__VA_ARGS__)) -#define CON_STR_23(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_22(__VA_ARGS__)) -#define CON_STR_24(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_23(__VA_ARGS__)) -#define CON_STR_25(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_24(__VA_ARGS__)) -#define CON_STR_26(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_25(__VA_ARGS__)) -#define CON_STR_27(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_26(__VA_ARGS__)) -#define CON_STR_28(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_27(__VA_ARGS__)) -#define CON_STR_29(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_28(__VA_ARGS__)) -#define CON_STR_30(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_29(__VA_ARGS__)) -#define CON_STR_31(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_30(__VA_ARGS__)) -#define CON_STR_32(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_31(__VA_ARGS__)) -#define CON_STR_33(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_32(__VA_ARGS__)) -#define CON_STR_34(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_33(__VA_ARGS__)) -#define CON_STR_35(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_34(__VA_ARGS__)) -#define CON_STR_36(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_35(__VA_ARGS__)) -#define CON_STR_37(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_36(__VA_ARGS__)) -#define CON_STR_38(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_37(__VA_ARGS__)) -#define CON_STR_39(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_38(__VA_ARGS__)) -#define CON_STR_40(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_39(__VA_ARGS__)) -#define CON_STR_41(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_40(__VA_ARGS__)) -#define CON_STR_42(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_41(__VA_ARGS__)) -#define CON_STR_43(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_42(__VA_ARGS__)) -#define CON_STR_44(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_43(__VA_ARGS__)) -#define CON_STR_45(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_44(__VA_ARGS__)) -#define CON_STR_46(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_45(__VA_ARGS__)) -#define CON_STR_47(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_46(__VA_ARGS__)) -#define CON_STR_48(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_47(__VA_ARGS__)) -#define CON_STR_49(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_48(__VA_ARGS__)) -#define CON_STR_50(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_49(__VA_ARGS__)) -#define CON_STR_51(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_50(__VA_ARGS__)) -#define CON_STR_52(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_51(__VA_ARGS__)) -#define CON_STR_53(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_52(__VA_ARGS__)) -#define CON_STR_54(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_53(__VA_ARGS__)) -#define CON_STR_55(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_54(__VA_ARGS__)) -#define CON_STR_56(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_55(__VA_ARGS__)) -#define CON_STR_57(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_56(__VA_ARGS__)) -#define CON_STR_58(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_57(__VA_ARGS__)) -#define CON_STR_59(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_58(__VA_ARGS__)) -#define CON_STR_60(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_59(__VA_ARGS__)) -#define CON_STR_61(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_60(__VA_ARGS__)) -#define CON_STR_62(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_61(__VA_ARGS__)) -#define CON_STR_63(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_62(__VA_ARGS__)) -#define CON_STR_64(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_63(__VA_ARGS__)) -#define CON_STR_65(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_64(__VA_ARGS__)) -#define CON_STR_66(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_65(__VA_ARGS__)) -#define CON_STR_67(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_66(__VA_ARGS__)) -#define CON_STR_68(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_67(__VA_ARGS__)) -#define CON_STR_69(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_68(__VA_ARGS__)) -#define CON_STR_70(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_69(__VA_ARGS__)) -#define CON_STR_71(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_70(__VA_ARGS__)) -#define CON_STR_72(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_71(__VA_ARGS__)) -#define CON_STR_73(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_72(__VA_ARGS__)) -#define CON_STR_74(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_73(__VA_ARGS__)) -#define CON_STR_75(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_74(__VA_ARGS__)) -#define CON_STR_76(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_75(__VA_ARGS__)) -#define CON_STR_77(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_76(__VA_ARGS__)) -#define CON_STR_78(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_77(__VA_ARGS__)) -#define CON_STR_79(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_78(__VA_ARGS__)) -#define CON_STR_80(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_79(__VA_ARGS__)) -#define CON_STR_81(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_80(__VA_ARGS__)) -#define CON_STR_82(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_81(__VA_ARGS__)) -#define CON_STR_83(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_82(__VA_ARGS__)) -#define CON_STR_84(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_83(__VA_ARGS__)) -#define CON_STR_85(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_84(__VA_ARGS__)) -#define CON_STR_86(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_85(__VA_ARGS__)) -#define CON_STR_87(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_86(__VA_ARGS__)) -#define CON_STR_88(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_87(__VA_ARGS__)) -#define CON_STR_89(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_88(__VA_ARGS__)) -#define CON_STR_90(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_89(__VA_ARGS__)) -#define CON_STR_91(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_90(__VA_ARGS__)) -#define CON_STR_92(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_91(__VA_ARGS__)) -#define CON_STR_93(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_92(__VA_ARGS__)) -#define CON_STR_94(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_93(__VA_ARGS__)) -#define CON_STR_95(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_94(__VA_ARGS__)) -#define CON_STR_96(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_95(__VA_ARGS__)) -#define CON_STR_97(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_96(__VA_ARGS__)) -#define CON_STR_98(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_97(__VA_ARGS__)) -#define CON_STR_99(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_98(__VA_ARGS__)) -#define CON_STR_100(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_99(__VA_ARGS__)) -#define CON_STR_101(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_100(__VA_ARGS__)) -#define CON_STR_102(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_101(__VA_ARGS__)) -#define CON_STR_103(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_102(__VA_ARGS__)) -#define CON_STR_104(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_103(__VA_ARGS__)) -#define CON_STR_105(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_104(__VA_ARGS__)) -#define CON_STR_106(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_105(__VA_ARGS__)) -#define CON_STR_107(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_106(__VA_ARGS__)) -#define CON_STR_108(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_107(__VA_ARGS__)) -#define CON_STR_109(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_108(__VA_ARGS__)) -#define CON_STR_110(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_109(__VA_ARGS__)) -#define CON_STR_111(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_110(__VA_ARGS__)) -#define CON_STR_112(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_111(__VA_ARGS__)) -#define CON_STR_113(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_112(__VA_ARGS__)) -#define CON_STR_114(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_113(__VA_ARGS__)) -#define CON_STR_115(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_114(__VA_ARGS__)) -#define CON_STR_116(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_115(__VA_ARGS__)) -#define CON_STR_117(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_116(__VA_ARGS__)) -#define CON_STR_118(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_117(__VA_ARGS__)) -#define CON_STR_119(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_118(__VA_ARGS__)) -#define CON_STR_120(element, ...) \ - ADD_VIEW(element) SEPERATOR MARCO_EXPAND(CON_STR_119(__VA_ARGS__)) -#define RSEQ_N() \ - 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, \ - 104, 103, 102, 101, 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, 0 - -#define ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \ - _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, \ - _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \ - _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, \ - _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, \ - _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, \ - _80, _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, \ - _93, _94, _95, _96, _97, _98, _99, _100, _101, _102, _103, _104, \ - _105, _106, _107, _108, _109, _110, _111, _112, _113, _114, \ - _115, _116, _117, _118, _119, N, ...) \ - N - -#define MARCO_EXPAND(...) __VA_ARGS__ -#define APPLY_VARIADIC_MACRO(macro, ...) MARCO_EXPAND(macro(__VA_ARGS__)) - -#define ADD_REFERENCE(t) std::reference_wrapper(t) -#define ADD_REFERENCE_CONST(t) \ - std::reference_wrapper>(t) -#define FIELD(t) t -#define MAKE_NAMES(...) #__VA_ARGS__, - -// note use MACRO_CONCAT like A##_##B direct may cause marco expand error -#define MACRO_CONCAT(A, B) MACRO_CONCAT1(A, B) -#define MACRO_CONCAT1(A, B) A##_##B - -#define MAKE_ARG_LIST(N, op, arg, ...) \ - MACRO_CONCAT(MAKE_ARG_LIST, N)(op, arg, __VA_ARGS__) - -#define GET_ARG_COUNT_INNER(...) MARCO_EXPAND(ARG_N(__VA_ARGS__)) -#define GET_ARG_COUNT(...) GET_ARG_COUNT_INNER(__VA_ARGS__, RSEQ_N()) - -#define MAKE_STR_LIST(...) \ - MACRO_CONCAT(CON_STR, GET_ARG_COUNT(__VA_ARGS__))(__VA_ARGS__) - -template -struct identity {}; - -struct field_info { - size_t offset; - std::string_view type_name; -}; - -struct base { - virtual void to_pb(std::string &str) {} - virtual void from_pb(std::string_view str) {} - virtual void to_xml(std::string &str) {} - virtual void from_xml(std::string_view str) {} - virtual void to_json(std::string &str) {} - virtual void from_json(std::string_view str) {} - virtual void to_yaml(std::string &str) {} - virtual void from_yaml(std::string_view str) {} - virtual std::vector get_fields_name() const { return {}; } - virtual std::any get_field_any(std::string_view name) const { return {}; } - virtual iguana::detail::field_info get_field_info(std::string_view name) { - return {}; - } - - template - T &get_field_value(std::string_view name) { - auto info = get_field_info(name); - check_field(name, info); - auto ptr = (((char *)this) + info.offset); - return *((T *)ptr); - } - - template - void set_field_value(std::string_view name, T val) { - auto info = get_field_info(name); - check_field(name, info); - - auto ptr = (((char *)this) + info.offset); - - static_assert(std::is_constructible_v, "can not assign"); - - *((FiledType *)ptr) = std::move(val); - } - virtual ~base() {} - - private: - template - void check_field(std::string_view name, const field_info &info) { - if (info.offset == 0) { - throw std::invalid_argument(std::string(name) + " field not exist "); - } - -#if defined(__clang__) || defined(_MSC_VER) || \ - (defined(__GNUC__) && __GNUC__ > 8) - if (info.type_name != iguana::type_string()) { - std::string str = "type is not match: can not assign "; - str.append(iguana::type_string()); - str.append(" to ").append(info.type_name); - - throw std::invalid_argument(str); - } -#endif - } -}; - -inline std::unordered_map()>> - g_pb_map; - -template -inline bool register_type() { -#if defined(__clang__) || defined(_MSC_VER) || \ - (defined(__GNUC__) && __GNUC__ > 8) - if constexpr (std::is_base_of_v) { - auto it = g_pb_map.emplace(type_string(), [] { - return std::make_shared(); - }); - return it.second; - } - else { - return true; - } -#else - return true; -#endif -} - -#define MAKE_META_DATA_IMPL(STRUCT_NAME, ...) \ - static inline bool IGUANA_UNIQUE_VARIABLE(reg_var) = \ - iguana::detail::register_type(); \ - [[maybe_unused]] inline static auto iguana_reflect_members( \ - const iguana::detail::identity &) { \ - struct reflect_members { \ - constexpr decltype(auto) static apply_impl() { \ - return std::make_tuple(__VA_ARGS__); \ - } \ - using size_type = \ - std::integral_constant; \ - constexpr static std::string_view name() { return name_##STRUCT_NAME; } \ - constexpr static std::string_view struct_name() { \ - return std::string_view(#STRUCT_NAME, sizeof(#STRUCT_NAME) - 1); \ - } \ - constexpr static std::string_view fields() { \ - return fields_##STRUCT_NAME; \ - } \ - constexpr static size_t value() { return size_type::value; } \ - constexpr static std::array arr() { \ - return arr_##STRUCT_NAME; \ - } \ - }; \ - return reflect_members{}; \ - } - -#define MAKE_META_DATA(STRUCT_NAME, TABLE_NAME, N, ...) \ - static constexpr inline std::array arr_##STRUCT_NAME = { \ - MARCO_EXPAND(MACRO_CONCAT(CON_STR, N)(__VA_ARGS__))}; \ - static constexpr inline std::string_view fields_##STRUCT_NAME = { \ - MAKE_NAMES(__VA_ARGS__)}; \ - static constexpr inline std::string_view name_##STRUCT_NAME = TABLE_NAME; \ - MAKE_META_DATA_IMPL(STRUCT_NAME, \ - MAKE_ARG_LIST(N, &STRUCT_NAME::FIELD, __VA_ARGS__)) - -#define REFLECTION_ALIAS_IMPL(STRUCT_NAME, ALIAS, N, ...) \ - MAKE_META_DATA_IMPL_ALIAS(STRUCT_NAME, ALIAS, __VA_ARGS__) - -#define FLDALIAS(a, b) \ - std::pair { a, b } - -template -constexpr auto get_mem_ptr_tp(Args... pair) { - return std::make_tuple(std::get<0>(pair)...); -} - -template -constexpr std::array get_alias_arr(Args... pairs) { - return std::array{ - frozen::string(std::get<1>(pairs))...}; -} - -#define MAKE_META_DATA_IMPL_ALIAS(STRUCT_NAME, ALIAS, ...) \ - [[maybe_unused]] inline static auto iguana_reflect_members( \ - const iguana::detail::identity &) { \ - struct reflect_members { \ - constexpr decltype(auto) static apply_impl() { \ - return iguana::detail::get_mem_ptr_tp(__VA_ARGS__); \ - } \ - using size_type = std::integral_constant< \ - size_t, std::tuple_size_v>; \ - constexpr static std::string_view name() { return ALIAS; } \ - constexpr static std::string_view struct_name() { \ - return std::string_view(#STRUCT_NAME, sizeof(#STRUCT_NAME) - 1); \ - } \ - constexpr static size_t value() { return size_type::value; } \ - constexpr static std::array arr() { \ - return iguana::detail::get_alias_arr(__VA_ARGS__); \ - } \ - }; \ - return reflect_members{}; \ - } - -#define MAKE_META_DATA_IMPL_EMPTY(STRUCT_NAME) \ - inline auto iguana_reflect_members( \ - const iguana::detail::identity &) { \ - struct reflect_members { \ - constexpr decltype(auto) static apply_impl() { \ - return std::make_tuple(); \ - } \ - using size_type = std::integral_constant; \ - constexpr static std::string_view name() { \ - return std::string_view(#STRUCT_NAME, sizeof(#STRUCT_NAME) - 1); \ - } \ - constexpr static size_t value() { return size_type::value; } \ - constexpr static std::array arr() { \ - return arr_##STRUCT_NAME; \ - } \ - }; \ - return reflect_members{}; \ - } - -#define MAKE_META_DATA_EMPTY(STRUCT_NAME) \ - constexpr inline std::array arr_##STRUCT_NAME = {}; \ - MAKE_META_DATA_IMPL_EMPTY(STRUCT_NAME) - -template -inline auto get_value_type(std::tuple) { - return std::variant{}; -} - -inline constexpr frozen::string filter_str(const frozen::string &str) { - if (str.size() > 3 && str[0] == '_' && str[1] == '_' && str[2] == '_') { - auto ptr = str.data() + 3; - return frozen::string(ptr, str.size() - 3); - } - return str; -} - -template -inline constexpr auto get_iguana_struct_map_impl( - const std::array &arr, T &&t, - std::index_sequence) { - using ValueType = decltype(get_value_type(t)); - return frozen::unordered_map{ - {filter_str(arr[Is]), - ValueType{std::in_place_index, std::get(t)}}...}; -} -} // namespace iguana::detail - -namespace iguana { -#define REFLECTION_WITH_NAME(STRUCT_NAME, TABLE_NAME, ...) \ - MAKE_META_DATA(STRUCT_NAME, TABLE_NAME, GET_ARG_COUNT(__VA_ARGS__), \ - __VA_ARGS__) - -struct iguana_adl_t {}; - -template -inline auto iguana_reflect_type(const T &t); - -inline std::unordered_map< - std::string_view, - std::vector>> - g_iguana_custom_map; -template -inline constexpr auto get_iguana_struct_map() { - using reflect_members = decltype(iguana_reflect_type(std::declval())); - if constexpr (reflect_members::value() == 0) { - return std::array{}; - } - else { - return detail::get_iguana_struct_map_impl( - reflect_members::arr(), reflect_members::apply_impl(), - std::make_index_sequence{}); - } -} - -template ::value_type> -struct field_t { - using member_type = T; - using owner_type = typename member_traits::owner_type; - using value_type = typename member_traits::value_type; - using sub_type = ElementType; - constexpr field_t() = default; - constexpr field_t(T member, uint32_t number, frozen::string name = "") - : member_ptr(member), field_name(name), field_no(number) {} - - T member_ptr; - frozen::string field_name; - uint32_t field_no; - - auto &value(owner_type &value) const { return value.*member_ptr; } -}; - -template -struct field_type_t; - -template -struct field_type_t> { - using value_type = std::variant; -}; - -template -struct is_custom_reflection : std::false_type {}; - -template -struct is_custom_reflection< - T, std::void_t()))>> - : std::true_type {}; - -template -struct is_reflection : std::false_type {}; - -template -inline constexpr bool is_reflection_v = is_reflection::value; - -template -inline constexpr bool is_custom_reflection_v = is_custom_reflection::value; - -template -constexpr inline auto build_variant_fields(T t, S &s, uint32_t base_idx, - std::index_sequence) { - using value_type = typename member_traits::value_type; - return std::tuple(field_t>{ - t, (base_idx + uint32_t(I)), s}...); -} - -template -constexpr inline auto build_fields(T t, S &s, uint32_t &index) { - using value_type = typename member_traits::value_type; - if constexpr (is_variant::value) { - constexpr uint32_t Size = std::variant_size_v; - index += (Size - 1); - return build_variant_fields(t, s, I + 1, std::make_index_sequence{}); - } - else { - uint32_t field_no = (I == index) ? (I + 1) : (2 + index); - index++; - return std::tuple(field_t{t, field_no, s}); - } -} - -template -constexpr inline auto get_members_tuple_impl(T &&tp, U &&arr, - std::index_sequence &&) { - uint32_t index = 0; - return std::tuple_cat(build_fields(std::get(tp), arr[I], index)...); -} - -template -constexpr inline auto get_members_tuple() { - if constexpr (is_reflection::value) { - using reflect_members = decltype(iguana_reflect_type(std::declval())); - using Tuple = decltype(reflect_members::apply_impl()); - constexpr size_t Size = std::tuple_size_v; - return get_members_tuple_impl(reflect_members::apply_impl(), - reflect_members::arr(), - std::make_index_sequence{}); - } - else if constexpr (is_custom_reflection_v) { - using U = std::remove_const_t>; - return get_members_impl((U *)nullptr); - } - else { - static_assert(!sizeof(T), "expected reflection or custom reflection"); - } -} - -template -constexpr auto inline get_members_impl(Tuple &&tp, std::index_sequence) { - return frozen::unordered_map{ - {std::get(tp).field_no, - T{std::in_place_index, std::move(std::get(tp))}}...}; -} - -template -constexpr size_t count_variant_size() { - if constexpr (is_variant::value) { - return std::variant_size_v; - } - else { - return 1; - } -} - -template -constexpr size_t tuple_type_count_impl(std::index_sequence) { - return ( - (count_variant_size>>() + - ...)); -} - -template -constexpr size_t tuple_type_count() { - return tuple_type_count_impl( - std::make_index_sequence>{}); -} - -template -constexpr inline auto get_members() { - if constexpr (is_reflection_v || is_custom_reflection_v) { - constexpr auto tp = get_members_tuple(); - using Tuple = std::decay_t; - using value_type = typename field_type_t::value_type; - constexpr auto Size = tuple_type_count(); - return get_members_impl(tp, - std::make_index_sequence{}); - } - else { - static_assert(!sizeof(T), "expected reflection or custom reflection"); - } -} - -#define REFLECTION(STRUCT_NAME, ...) \ - MAKE_META_DATA(STRUCT_NAME, #STRUCT_NAME, GET_ARG_COUNT(__VA_ARGS__), \ - __VA_ARGS__) - -#define REFLECTION_EMPTY(STRUCT_NAME) MAKE_META_DATA_EMPTY(STRUCT_NAME) - -#define REFLECTION_ALIAS(STRUCT_NAME, ALIAS, ...) \ - REFLECTION_ALIAS_IMPL( \ - STRUCT_NAME, ALIAS, \ - std::tuple_size_v, __VA_ARGS__) - -#define IGUANA_UNIQUE_VARIABLE(str) MACRO_CONCAT(str, __COUNTER__) -template -struct iguana_required_struct; -#define REQUIRED_IMPL(STRUCT_NAME, N, ...) \ - template <> \ - struct iguana::iguana_required_struct { \ - inline static constexpr auto requied_arr() { \ - std::array arr_required = { \ - MARCO_EXPAND(MACRO_CONCAT(CON_STR, N)(__VA_ARGS__))}; \ - return arr_required; \ - } \ - }; - -#define REQUIRED(STRUCT_NAME, ...) \ - REQUIRED_IMPL(STRUCT_NAME, GET_ARG_COUNT(__VA_ARGS__), __VA_ARGS__) - -template -struct has_iguana_required_arr : std::false_type {}; - -template -struct has_iguana_required_arr< - T, std::void_t::requied_arr())>> - : std::true_type {}; - -template -constexpr bool has_iguana_required_arr_v = has_iguana_required_arr::value; - -inline std::string_view trim_sv(std::string_view str) { - std::string_view whitespaces(" \t\f\v\n\r"); - auto first = str.find_first_not_of(whitespaces); - auto last = str.find_last_not_of(whitespaces); - if (first == std::string_view::npos || last == std::string_view::npos) - return std::string_view(); - return str.substr(first, last - first + 1); -} - -inline int add_custom_fields(std::string_view key, - std::vector v) { - std::vector> vec; - for (auto val : v) { - std::string_view str = {val.data() + 1, val.size() - 2}; - size_t pos = str.find(','); - if (pos == std::string_view::npos || pos == str.size() - 1) { - continue; - } - - std::string_view origin = str.substr(0, pos); - std::string_view alias = str.substr(pos + 1); - - vec.push_back(std::make_pair(trim_sv(origin), trim_sv(alias))); - } - g_iguana_custom_map.emplace(key, std::move(vec)); - return 0; -} - -#define CUSTOM_FIELDS_IMPL(STRUCT_NAME, N, ...) \ - inline auto IGUANA_UNIQUE_VARIABLE(STRUCT_NAME) = iguana::add_custom_fields( \ - #STRUCT_NAME, {MARCO_EXPAND(MACRO_CONCAT(CON_STR, N)(__VA_ARGS__))}); - -#define CUSTOM_FIELDS(STRUCT_NAME, ...) \ - CUSTOM_FIELDS_IMPL(STRUCT_NAME, GET_ARG_COUNT(__VA_ARGS__), __VA_ARGS__) - -template -using Reflect_members = decltype(iguana_reflect_members( - std::declval>())); - -template -struct is_public_reflection : std::false_type {}; - -template -struct is_public_reflection>()))>> - : std::true_type {}; - -template -constexpr bool is_public_reflection_v = is_public_reflection::value; - -template -struct is_private_reflection : std::false_type {}; - -template -struct is_private_reflection< - T, std::void_t().iguana_reflect_members( - std::declval>()))>> : std::true_type {}; - -template -constexpr bool is_private_reflection_v = is_private_reflection::value; - -template -struct is_reflection>> - : std::true_type {}; - -template -struct is_reflection>> - : std::true_type {}; - -template -inline auto iguana_reflect_type(const T &t) { - if constexpr (is_public_reflection_v>) { - return iguana_reflect_members(iguana::detail::identity{}); - } - else { - return t.iguana_reflect_members(iguana::detail::identity{}); - } -} - -template typename Condition, - typename Tuple, typename Owner> -constexpr int element_index_helper() { - if constexpr (index == std::tuple_size_v) { - return index; - } - else { - using type_v = decltype(std::declval().* - std::declval>()); - using item_type = std::decay_t; - - return Condition::value - ? index - : element_index_helper(); - } -} - -template