From 4e31fc478cbda3244d2ffd0bd50ebd82ab886e8c Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Mon, 30 Jul 2018 01:51:02 +0300 Subject: [PATCH] Multiple fixes for last refactoring. --- include/sqrat/sqratClass.h | 2 +- include/sqrat/sqratGlobalMethods.h | 6 ++-- include/sqrat/sqratMemberMethods.h | 44 +++++++++++++++--------------- include/sqrat/sqratTypes.h | 5 +++- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/include/sqrat/sqratClass.h b/include/sqrat/sqratClass.h index 5737154a..53327300 100644 --- a/include/sqrat/sqratClass.h +++ b/include/sqrat/sqratClass.h @@ -462,7 +462,7 @@ public: ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template Class& GlobalFmtFunc(const SQChar* name, F method) { - BindFunc(name, &method, sizeof(method), SqMemberGlobalFmtFunc(method)); + BindFunc(name, &method, sizeof(method), SqMemberGlobalFunc(method)); return *this; } diff --git a/include/sqrat/sqratGlobalMethods.h b/include/sqrat/sqratGlobalMethods.h index d2849013..ce4adf37 100644 --- a/include/sqrat/sqratGlobalMethods.h +++ b/include/sqrat/sqratGlobalMethods.h @@ -127,7 +127,7 @@ template struct SqGlobal { } #endif try { - return SqGlobalProxy::Run(vm, startIdx); + return SqGlobalProxy::template Run(vm, startIdx); } catch (const Exception& e) { return sq_throwerror(vm, e.what()); } @@ -151,7 +151,7 @@ template struct SqGlobal { } #endif try { - return SqGlobalProxy::Run(vm, startIdx); + return SqGlobalProxy::template Run(vm, startIdx); } catch (const Exception& e) { return sq_throwerror(vm, e.what()); } @@ -175,7 +175,7 @@ template <> struct SqGlobal { } #endif try { - return SqGlobalProxy::Run(vm, startIdx); + return SqGlobalProxy::Run(vm, startIdx); } catch (const Exception& e) { return sq_throwerror(vm, e.what()); } diff --git a/include/sqrat/sqratMemberMethods.h b/include/sqrat/sqratMemberMethods.h index a842ca0d..ec675a8b 100644 --- a/include/sqrat/sqratMemberMethods.h +++ b/include/sqrat/sqratMemberMethods.h @@ -54,7 +54,7 @@ template struct SqMemberProxy { typedef R(C::*M)(A...); C* inst = Var(vm, 1).value; M* methodPtr; - sq_getuserdata(vm, -1, reinterpret_cast(&methodPtr), NULL); + sq_getuserdata(vm, -1, reinterpret_cast(&methodPtr), nullptr); M method = *methodPtr; R ret = (inst->*method)(a...); PushVar(vm, ret); @@ -70,7 +70,7 @@ template struct SqMemberProxy { typedef R(C::*M)(A...) const; C* inst = Var(vm, 1).value; M* methodPtr; - sq_getuserdata(vm, -1, reinterpret_cast(&methodPtr), NULL); + sq_getuserdata(vm, -1, reinterpret_cast(&methodPtr), nullptr); M method = *methodPtr; R ret = (inst->*method)(a...); PushVar(vm, ret); @@ -83,7 +83,7 @@ template struct SqMemberProxy { // reference return specialization // -template struct SqMemberProxy { +template struct SqMemberProxy { template static SQInteger Run(HSQUIRRELVM vm) noexcept { ArgPop a(vm, 2); if (SQ_FAILED(a.Proc(sizeof...(A) == 0 && sq_gettop(vm) == 2))) { @@ -93,7 +93,7 @@ template struct SqMemberProxy { typedef R&(C::*M)(A...); C* inst = Var(vm, 1).value; M* methodPtr; - sq_getuserdata(vm, -1, reinterpret_cast(&methodPtr), NULL); + sq_getuserdata(vm, -1, reinterpret_cast(&methodPtr), nullptr); M method = *methodPtr; R& ret = (inst->*method)(a...); PushVarR(vm, ret); @@ -109,7 +109,7 @@ template struct SqMemberProxy { typedef R&(C::*M)(A...) const; C* inst = Var(vm, 1).value; M* methodPtr; - sq_getuserdata(vm, -1, reinterpret_cast(&methodPtr), NULL); + sq_getuserdata(vm, -1, reinterpret_cast(&methodPtr), nullptr); M method = *methodPtr; R& ret = (inst->*method)(a...); PushVarR(vm, ret); @@ -132,7 +132,7 @@ template struct SqMemberProxy { typedef void(C::*M)(A...); C* inst = Var(vm, 1).value; M* methodPtr; - sq_getuserdata(vm, -1, reinterpret_cast(&methodPtr), NULL); + sq_getuserdata(vm, -1, reinterpret_cast(&methodPtr), nullptr); M method = *methodPtr; (inst->*method)(a...); }); @@ -147,7 +147,7 @@ template struct SqMemberProxy { typedef void(C::*M)(A...) const; C* inst = Var(vm, 1).value; M* methodPtr; - sq_getuserdata(vm, -1, reinterpret_cast(&methodPtr), NULL); + sq_getuserdata(vm, -1, reinterpret_cast(&methodPtr), nullptr); M method = *methodPtr; (inst->*method)(a...); }); @@ -180,7 +180,7 @@ template struct SqMember { } #endif try { - return SqMemberProxy::Run(vm); + return SqMemberProxy:: template Run(vm); } catch (const Exception& e) { return sq_throwerror(vm, e.what()); } @@ -197,7 +197,7 @@ template struct SqMember { } #endif try { - return SqMemberProxy::RunC(vm); + return SqMemberProxy::template RunC(vm); } catch (const Exception& e) { return sq_throwerror(vm, e.what()); } @@ -210,7 +210,7 @@ template struct SqMember { // reference return specialization // -template struct SqMember { +template struct SqMember { // Function proxy template static SQFUNCTION GetProxy() noexcept { return +[](HSQUIRRELVM vm) noexcept -> SQInteger { @@ -221,7 +221,7 @@ template struct SqMember { } #endif try { - return SqMemberProxy::Run(vm); + return SqMemberProxy::template Run(vm); } catch (const Exception& e) { return sq_throwerror(vm, e.what()); } @@ -238,7 +238,7 @@ template struct SqMember { } #endif try { - return SqMemberProxy::RunC(vm); + return SqMemberProxy::template RunC(vm); } catch (const Exception& e) { return sq_throwerror(vm, e.what()); } @@ -263,7 +263,7 @@ template struct SqMember { } #endif try { - return SqMemberProxy::Run(vm); + return SqMemberProxy::template Run(vm); } catch (const Exception& e) { return sq_throwerror(vm, e.what()); } @@ -280,7 +280,7 @@ template struct SqMember { } #endif try { - return SqMemberProxy::RunC(vm); + return SqMemberProxy::template RunC(vm); } catch (const Exception& e) { return sq_throwerror(vm, e.what()); } @@ -327,8 +327,8 @@ inline SQInteger sqDefaultGet(HSQUIRRELVM vm) { } typedef V C::*M; - M* memberPtr = NULL; - sq_getuserdata(vm, -1, (SQUserPointer*)&memberPtr, NULL); // Get Member... + M* memberPtr = nullptr; + sq_getuserdata(vm, -1, (SQUserPointer*)&memberPtr, nullptr); // Get Member... M member = *memberPtr; PushVarR(vm, ptr->*member); @@ -339,8 +339,8 @@ inline SQInteger sqDefaultGet(HSQUIRRELVM vm) { template inline SQInteger sqStaticGet(HSQUIRRELVM vm) { typedef V *M; - M* memberPtr = NULL; - sq_getuserdata(vm, -1, (SQUserPointer*)&memberPtr, NULL); // Get Member... + M* memberPtr = nullptr; + sq_getuserdata(vm, -1, (SQUserPointer*)&memberPtr, nullptr); // Get Member... M member = *memberPtr; PushVarR(vm, *member); @@ -399,8 +399,8 @@ inline SQInteger sqDefaultSet(HSQUIRRELVM vm) { } typedef V C::*M; - M* memberPtr = NULL; - sq_getuserdata(vm, -1, (SQUserPointer*)&memberPtr, NULL); // Get Member... + M* memberPtr = nullptr; + sq_getuserdata(vm, -1, (SQUserPointer*)&memberPtr, nullptr); // Get Member... M member = *memberPtr; SQTRY() @@ -422,8 +422,8 @@ inline SQInteger sqDefaultSet(HSQUIRRELVM vm) { template inline SQInteger sqStaticSet(HSQUIRRELVM vm) { typedef V *M; - M* memberPtr = NULL; - sq_getuserdata(vm, -1, (SQUserPointer*)&memberPtr, NULL); // Get Member... + M* memberPtr = nullptr; + sq_getuserdata(vm, -1, (SQUserPointer*)&memberPtr, nullptr); // Get Member... M member = *memberPtr; SQTRY() diff --git a/include/sqrat/sqratTypes.h b/include/sqrat/sqratTypes.h index d0918659..0b62a6e7 100644 --- a/include/sqrat/sqratTypes.h +++ b/include/sqrat/sqratTypes.h @@ -1187,7 +1187,10 @@ template<> struct ArgPopHasFmt { static constexpr bool value = /// Helper used to process formatted arguments when necessary. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template struct ArgPopFmt { - static inline SQInteger Proc(StackStrF &, bool) { + template static inline SQInteger Proc(T &, bool) { + return SQ_OK; + } + template static inline SQInteger Get(T &) { return SQ_OK; } };