From 9fc43cff4d27b32577d4943878f8d0fde3e219d6 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 28 May 2016 20:11:42 -0400 Subject: [PATCH] Make const method wrappers possible Reverts ae3052f Ref #935 --- library/include/DataFuncs.h | 15 +++++++++++++++ .../knowledge_scholar_category_flag.methods.inc | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/library/include/DataFuncs.h b/library/include/DataFuncs.h index cd178263c..bf8e6b244 100644 --- a/library/include/DataFuncs.h +++ b/library/include/DataFuncs.h @@ -83,6 +83,11 @@ namespace df { typedef RT type; \ typedef CT class_type; \ static const bool is_method = true; \ + }; \ + template struct return_type { \ + typedef RT type; \ + typedef CT class_type; \ + static const bool is_method = true; \ }; #define INSTANTIATE_WRAPPERS2(Count, FArgs, Args, Loads) \ @@ -99,10 +104,20 @@ namespace df { static void execute(lua_State *state, int base, void (CT::*cb) FArgs) { \ LOAD_CLASS() Loads; INVOKE_VOID((self->*cb) Args); } \ }; \ + template struct function_wrapper { \ + static const int num_args = Count+1; \ + static void execute(lua_State *state, int base, void (CT::*cb) FArgs const) { \ + LOAD_CLASS() Loads; INVOKE_VOID((self->*cb) Args); } \ + }; \ template struct function_wrapper { \ static const int num_args = Count+1; \ static void execute(lua_State *state, int base, RT (CT::*cb) FArgs) { \ LOAD_CLASS(); Loads; INVOKE_RV((self->*cb) Args); } \ + }; \ + template struct function_wrapper { \ + static const int num_args = Count+1; \ + static void execute(lua_State *state, int base, RT (CT::*cb) FArgs const) { \ + LOAD_CLASS(); Loads; INVOKE_RV((self->*cb) Args); } \ }; #define INSTANTIATE_WRAPPERS(Count, FArgs, OFArgs, Args, OArgs, Loads) \ diff --git a/library/include/df/custom/knowledge_scholar_category_flag.methods.inc b/library/include/df/custom/knowledge_scholar_category_flag.methods.inc index 6fe896804..f5c4e9a76 100644 --- a/library/include/df/custom/knowledge_scholar_category_flag.methods.inc +++ b/library/include/df/custom/knowledge_scholar_category_flag.methods.inc @@ -1,4 +1,4 @@ -df::enums::dfhack_knowledge_scholar_flag::dfhack_knowledge_scholar_flag value() +df::enums::dfhack_knowledge_scholar_flag::dfhack_knowledge_scholar_flag value() const { int32_t value = category * 32; for (int32_t i = 0; i < 32; i++)