From 53518d03daf062a40f351797e4a17f7d4f1ad11a Mon Sep 17 00:00:00 2001 From: lganzzzo Date: Mon, 27 Apr 2020 03:23:42 +0300 Subject: [PATCH] Codegen. Add the possibility to add custom codegen. --- src/CMakeLists.txt | 12 ++++++------ ...ne_ApiClient_.hpp => ApiClient_define.hpp} | 0 ...def_ApiClient_.hpp => ApiClient_undef.hpp} | 0 ...ntroller_.hpp => ApiController_define.hpp} | 0 ...ontroller_.hpp => ApiController_undef.hpp} | 0 ...codegen_define_DTO_.hpp => DTO_define.hpp} | 0 .../{codegen_undef_DTO_.hpp => DTO_undef.hpp} | 0 src/oatpp/core/macro/basic.hpp | 6 +++--- src/oatpp/core/macro/codegen.hpp | 19 +++++++++++++------ 9 files changed, 22 insertions(+), 15 deletions(-) rename src/oatpp/codegen/{codegen_define_ApiClient_.hpp => ApiClient_define.hpp} (100%) rename src/oatpp/codegen/{codegen_undef_ApiClient_.hpp => ApiClient_undef.hpp} (100%) rename src/oatpp/codegen/{codegen_define_ApiController_.hpp => ApiController_define.hpp} (100%) rename src/oatpp/codegen/{codegen_undef_ApiController_.hpp => ApiController_undef.hpp} (100%) rename src/oatpp/codegen/{codegen_define_DTO_.hpp => DTO_define.hpp} (100%) rename src/oatpp/codegen/{codegen_undef_DTO_.hpp => DTO_undef.hpp} (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index edc26f76..efac1ee8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,12 +11,12 @@ add_library(oatpp oatpp/codegen/api_controller/auth_undef.hpp oatpp/codegen/api_controller/cors_define.hpp oatpp/codegen/api_controller/cors_undef.hpp - oatpp/codegen/codegen_define_ApiClient_.hpp - oatpp/codegen/codegen_define_ApiController_.hpp - oatpp/codegen/codegen_define_DTO_.hpp - oatpp/codegen/codegen_undef_ApiClient_.hpp - oatpp/codegen/codegen_undef_ApiController_.hpp - oatpp/codegen/codegen_undef_DTO_.hpp + oatpp/codegen/ApiController_define.hpp + oatpp/codegen/ApiController_undef.hpp + oatpp/codegen/ApiClient_define.hpp + oatpp/codegen/ApiClient_undef.hpp + oatpp/codegen/DTO_define.hpp + oatpp/codegen/DTO_undef.hpp oatpp/core/Types.hpp oatpp/core/async/Coroutine.cpp oatpp/core/async/Coroutine.hpp diff --git a/src/oatpp/codegen/codegen_define_ApiClient_.hpp b/src/oatpp/codegen/ApiClient_define.hpp similarity index 100% rename from src/oatpp/codegen/codegen_define_ApiClient_.hpp rename to src/oatpp/codegen/ApiClient_define.hpp diff --git a/src/oatpp/codegen/codegen_undef_ApiClient_.hpp b/src/oatpp/codegen/ApiClient_undef.hpp similarity index 100% rename from src/oatpp/codegen/codegen_undef_ApiClient_.hpp rename to src/oatpp/codegen/ApiClient_undef.hpp diff --git a/src/oatpp/codegen/codegen_define_ApiController_.hpp b/src/oatpp/codegen/ApiController_define.hpp similarity index 100% rename from src/oatpp/codegen/codegen_define_ApiController_.hpp rename to src/oatpp/codegen/ApiController_define.hpp diff --git a/src/oatpp/codegen/codegen_undef_ApiController_.hpp b/src/oatpp/codegen/ApiController_undef.hpp similarity index 100% rename from src/oatpp/codegen/codegen_undef_ApiController_.hpp rename to src/oatpp/codegen/ApiController_undef.hpp diff --git a/src/oatpp/codegen/codegen_define_DTO_.hpp b/src/oatpp/codegen/DTO_define.hpp similarity index 100% rename from src/oatpp/codegen/codegen_define_DTO_.hpp rename to src/oatpp/codegen/DTO_define.hpp diff --git a/src/oatpp/codegen/codegen_undef_DTO_.hpp b/src/oatpp/codegen/DTO_undef.hpp similarity index 100% rename from src/oatpp/codegen/codegen_undef_DTO_.hpp rename to src/oatpp/codegen/DTO_undef.hpp diff --git a/src/oatpp/core/macro/basic.hpp b/src/oatpp/core/macro/basic.hpp index 44ddf553..3d3f9d24 100644 --- a/src/oatpp/core/macro/basic.hpp +++ b/src/oatpp/core/macro/basic.hpp @@ -26,8 +26,8 @@ * This file contains source code for basic helper macros used for code-generator. */ -#ifndef oatpp_macro_ForEach_hpp -#define oatpp_macro_ForEach_hpp +#ifndef oatpp_macro_basic_hpp +#define oatpp_macro_basic_hpp #define OATPP_MACRO_FOREACH_EXAMPLE_FUNC(INDEX, COUNT, X) \ ENV::log("macro", "param: %d/%d: '%s'", INDEX, COUNT, #X); @@ -498,4 +498,4 @@ OATPP_MACRO_EXPAND(OATPP_MACRO_FOREACH_CALL(N - 99, N, M, OATPP_MACRO_FIRSTARG_E OATPP_MACRO_FOREACH_98(N, M, OATPP_MACRO_RESTARGS(__VA_ARGS__)) -#endif /* oatpp_macro_ForEach_hpp */ +#endif /* oatpp_macro_basic_hpp */ diff --git a/src/oatpp/core/macro/codegen.hpp b/src/oatpp/core/macro/codegen.hpp index 61c1ac9a..c324314d 100644 --- a/src/oatpp/core/macro/codegen.hpp +++ b/src/oatpp/core/macro/codegen.hpp @@ -35,14 +35,21 @@ * */ -#ifndef codegen_hpp -#define codegen_hpp +#ifndef oatpp_macro_codegen_hpp +#define oatpp_macro_codegen_hpp #include "./basic.hpp" -#define OATPP_MACRO_CODEGEN_EXPAND(X) OATPP_MACRO_STR(X) +#define OATPP_CODEGEN_DEFINE_ApiController "oatpp/codegen/ApiController_define.hpp" +#define OATPP_CODEGEN_UNDEF_ApiController "oatpp/codegen/ApiController_undef.hpp" -#define OATPP_CODEGEN_BEGIN(NAME) OATPP_MACRO_CODEGEN_EXPAND(OATPP_MACRO_CONCAT2(oatpp/codegen/codegen_define_, NAME##_.hpp)) -#define OATPP_CODEGEN_END(NAME) OATPP_MACRO_CODEGEN_EXPAND(OATPP_MACRO_CONCAT2(oatpp/codegen/codegen_undef_, NAME##_.hpp)) +#define OATPP_CODEGEN_DEFINE_ApiClient "oatpp/codegen/ApiClient_define.hpp" +#define OATPP_CODEGEN_UNDEF_ApiClient "oatpp/codegen/ApiClient_undef.hpp" -#endif /* codegen_hpp */ +#define OATPP_CODEGEN_DEFINE_DTO "oatpp/codegen/DTO_define.hpp" +#define OATPP_CODEGEN_UNDEF_DTO "oatpp/codegen/DTO_undef.hpp" + +#define OATPP_CODEGEN_BEGIN(NAME) OATPP_MACRO_EXPAND(OATPP_CODEGEN_DEFINE_ ## NAME) +#define OATPP_CODEGEN_END(NAME) OATPP_MACRO_EXPAND(OATPP_CODEGEN_UNDEF_ ## NAME) + +#endif /* oatpp_macro_codegen_hpp */