Skip to content

Commit 9fc43cf

Browse files
committed
Make const method wrappers possible
Reverts ae3052f Ref DFHack#935
1 parent 113325f commit 9fc43cf

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

library/include/DataFuncs.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ namespace df {
8383
typedef RT type; \
8484
typedef CT class_type; \
8585
static const bool is_method = true; \
86+
}; \
87+
template<FW_TARGSC class RT, class CT> struct return_type<RT (CT::*) FArgs const> { \
88+
typedef RT type; \
89+
typedef CT class_type; \
90+
static const bool is_method = true; \
8691
};
8792

8893
#define INSTANTIATE_WRAPPERS2(Count, FArgs, Args, Loads) \
@@ -99,10 +104,20 @@ namespace df {
99104
static void execute(lua_State *state, int base, void (CT::*cb) FArgs) { \
100105
LOAD_CLASS() Loads; INVOKE_VOID((self->*cb) Args); } \
101106
}; \
107+
template<FW_TARGSC class CT> struct function_wrapper<void (CT::*) FArgs const, true> { \
108+
static const int num_args = Count+1; \
109+
static void execute(lua_State *state, int base, void (CT::*cb) FArgs const) { \
110+
LOAD_CLASS() Loads; INVOKE_VOID((self->*cb) Args); } \
111+
}; \
102112
template<FW_TARGSC class RT, class CT> struct function_wrapper<RT (CT::*) FArgs, false> { \
103113
static const int num_args = Count+1; \
104114
static void execute(lua_State *state, int base, RT (CT::*cb) FArgs) { \
105115
LOAD_CLASS(); Loads; INVOKE_RV((self->*cb) Args); } \
116+
}; \
117+
template<FW_TARGSC class RT, class CT> struct function_wrapper<RT (CT::*) FArgs const, false> { \
118+
static const int num_args = Count+1; \
119+
static void execute(lua_State *state, int base, RT (CT::*cb) FArgs const) { \
120+
LOAD_CLASS(); Loads; INVOKE_RV((self->*cb) Args); } \
106121
};
107122

108123
#define INSTANTIATE_WRAPPERS(Count, FArgs, OFArgs, Args, OArgs, Loads) \

library/include/df/custom/knowledge_scholar_category_flag.methods.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
df::enums::dfhack_knowledge_scholar_flag::dfhack_knowledge_scholar_flag value()
1+
df::enums::dfhack_knowledge_scholar_flag::dfhack_knowledge_scholar_flag value() const
22
{
33
int32_t value = category * 32;
44
for (int32_t i = 0; i < 32; i++)

0 commit comments

Comments
 (0)