diff --git a/library/include/DataFuncs.h b/library/include/DataFuncs.h index a3769af55..822dcd45d 100644 --- a/library/include/DataFuncs.h +++ b/library/include/DataFuncs.h @@ -33,7 +33,18 @@ distribution. #include "LuaWrapper.h" namespace df { - template struct function_wrapper {}; + // A very simple and stupid implementation of some stuff from boost + template struct is_same_type { static const bool value = false; }; + template struct is_same_type { static const bool value = true; }; + template struct return_type {}; + + /* + * Workaround for a msvc bug suggested by: + * + * http://stackoverflow.com/questions/5110529/class-template-partial-specialization-parametrized-on-member-function-return-typ + */ + template::type,void>::value> + struct function_wrapper {}; /* * Since templates can't match variable arg count, @@ -54,23 +65,25 @@ namespace df { type v##type; df::identity_traits::get()->lua_write(state, UPVAL_METHOD_NAME, &v##type, base++); #define INSTANTIATE_WRAPPERS(Count, FArgs, Args, Loads) \ - template struct function_wrapper { \ + template struct return_type { typedef RT type; }; \ + template struct return_type { typedef RT type; }; \ + template struct function_wrapper { \ static const bool is_method = false; \ static const int num_args = Count; \ static void execute(lua_State *state, int base, void (*cb) FArgs) { Loads; INVOKE_VOID(cb Args); } \ }; \ - template struct function_wrapper { \ + template struct function_wrapper { \ static const bool is_method = false; \ static const int num_args = Count; \ static void execute(lua_State *state, int base, RT (*cb) FArgs) { Loads; INVOKE_RV(cb Args); } \ }; \ - template struct function_wrapper { \ + template struct function_wrapper { \ static const bool is_method = true; \ static const int num_args = Count+1; \ static void execute(lua_State *state, int base, void (CT::*cb) FArgs) { \ LOAD_CLASS() Loads; INVOKE_VOID((self->*cb) Args); } \ }; \ - template struct function_wrapper { \ + template struct function_wrapper { \ static const bool is_method = true; \ static const int num_args = Count+1; \ static void execute(lua_State *state, int base, RT (CT::*cb) FArgs) { \