diff --git a/dependencies/sqrat/include/sqrat.h b/dependencies/sqrat/include/sqrat.h index ee797ef..81efc50 100644 --- a/dependencies/sqrat/include/sqrat.h +++ b/dependencies/sqrat/include/sqrat.h @@ -65,6 +65,5 @@ #include "sqrat/sqratUtil.h" #include "sqrat/sqratScript.h" #include "sqrat/sqratArray.h" -#include "sqrat/sqratNull.h" #endif diff --git a/dependencies/sqrat/include/sqrat/sqratNull.h b/dependencies/sqrat/include/sqrat/sqratNull.h deleted file mode 100644 index e3c4dd9..0000000 --- a/dependencies/sqrat/include/sqrat/sqratNull.h +++ /dev/null @@ -1,72 +0,0 @@ -// -// sqratNull: nullptr support -// - -// -// Copyright (c) 2009 Brandon Jones -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#if !defined(_SCRAT_NULL_H_) -#define _SCRAT_NULL_H_ - -#include // std::nullptr_t -#include "sqratTypes.h" - -namespace Sqrat { - template<> - struct Var { - - std::nullptr_t value; ///< The actual value of get operations - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Attempts to get the value off the stack at idx as an nullptr - /// - /// \param vm Target VM - /// \param idx Index trying to be read - /// - /// \remarks - /// This function MUST have its Error handled if it occurred. - /// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Var(HSQUIRRELVM vm, SQInteger idx) { -#if !defined (SCRAT_NO_ERROR_CHECKING) - SQObjectType value_type = sq_gettype(vm, idx); - if (value_type != OT_NULL) { - SQTHROW(vm, FormatTypeError(vm, idx, _SC("null"))); - } -#endif - value = nullptr; - } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - /// Called by Sqrat::PushVar to put an nullptr on the stack - /// - /// \param vm Target VM - /// \param value Value to push on to the VM's stack - /// - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - static void push(HSQUIRRELVM vm, const std::nullptr_t value) { - sq_pushnull(vm); - } - }; -} -#endif \ No newline at end of file diff --git a/dependencies/sqrat/include/sqrat/sqratTypes.h b/dependencies/sqrat/include/sqrat/sqratTypes.h index fbb0d57..e2fb54e 100644 --- a/dependencies/sqrat/include/sqrat/sqratTypes.h +++ b/dependencies/sqrat/include/sqrat/sqratTypes.h @@ -35,6 +35,7 @@ #include #include +#include // std::nullptr_t #include "sqratClassType.h" #include "sqratUtil.h" @@ -567,6 +568,46 @@ SCRAT_INTEGER(signed __int64) SCRAT_FLOAT(float) SCRAT_FLOAT(double) +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// Used to get and push nullptr to and from the stack +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +template<> +struct Var { + + std::nullptr_t value; ///< The actual value of get operations + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Attempts to get the value off the stack at idx as an nullptr + /// + /// \param vm Target VM + /// \param idx Index trying to be read + /// + /// \remarks + /// This function MUST have its Error handled if it occurred. + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + Var(HSQUIRRELVM vm, SQInteger idx) { +#if !defined (SCRAT_NO_ERROR_CHECKING) + SQObjectType value_type = sq_gettype(vm, idx); + if (value_type != OT_NULL) { + SQTHROW(vm, FormatTypeError(vm, idx, _SC("null"))); + } +#endif + value = nullptr; + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Called by Sqrat::PushVar to put an nullptr on the stack + /// + /// \param vm Target VM + /// \param value Value to push on to the VM's stack + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + static void push(HSQUIRRELVM vm, const std::nullptr_t value) { + sq_pushnull(vm); + } +}; + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Used to get and push bools to and from the stack ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -811,6 +852,48 @@ struct Var { } }; +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// Used to get and push SQUserPointer to and from the stack +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +template<> +struct Var { + + SQUserPointer value; ///< The actual value of get operations + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Attempts to get the value off the stack at idx as a SQUserPointer + /// + /// \param vm Target VM + /// \param idx Index trying to be read + /// + /// \remarks + /// This function MUST have its Error handled if it occurred. + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + Var(HSQUIRRELVM vm, SQInteger idx) { + SQUserPointer sqValue; +#if !defined (SCRAT_NO_ERROR_CHECKING) + if (SQ_FAILED(sq_getuserpointer(vm, idx, &sqValue))) { + SQTHROW(vm, FormatTypeError(vm, idx, _SC("userpointer"))); + } +#else + sq_getuserpointer(vm, idx, &sqValue); +#endif + value = sqValue; + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Called by Sqrat::PushVar to put a SQUserPointer on the stack + /// + /// \param vm Target VM + /// \param value Value to push on to the VM's stack + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + static void push(HSQUIRRELVM vm, const SQUserPointer value) { + sq_pushuserpointer(vm, value); + } +}; + #ifdef SQUNICODE ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Used to get and push std::string to and from the stack when SQChar is not char (must define SQUNICODE)