mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2026-04-23 04:27:22 +02:00
Compare commits
113 Commits
4090b558ad
...
discord
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d85603dfb | |||
| 259af04d0e | |||
| 4d1971d66b | |||
| b4bf96ce4b | |||
| f192767853 | |||
| a58b9fe267 | |||
| 4a8a7172d4 | |||
| cae745378d | |||
| 62b9504d43 | |||
| 26ccfa62b9 | |||
| 83f2ab79e0 | |||
| 57321af0c7 | |||
| 8d908208f0 | |||
| 87cb6a2cba | |||
| 0487f26865 | |||
| e3c32e4788 | |||
| b978bc5046 | |||
| 0f235ff6af | |||
| 7057939854 | |||
| eb3100de36 | |||
| f72c0f896e | |||
| 0d323f4a26 | |||
| 0c4c78da6e | |||
| 2011631e78 | |||
| 801ccbd6cd | |||
| 9062121cc8 | |||
| 596da38403 | |||
| aa2a8f32d1 | |||
| 13fc02e9ca | |||
| 17875509c0 | |||
| 5df55164ee | |||
| 45570af13b | |||
| 949e5e61d0 | |||
| e4aa96a8c3 | |||
| e60e2958f0 | |||
| dfee411de5 | |||
| 37383b9383 | |||
| ba4b8524e5 | |||
| f1ef37bdf3 | |||
| 9235cb5069 | |||
| 4e27ba4a4f | |||
| 19102a9334 | |||
| 1d8d31518c | |||
| a19a171e0d | |||
| 4c3921d88a | |||
| e9f5111a33 | |||
| 08a5ba3154 | |||
| 13a7a98abe | |||
| f8ebb0e2b1 | |||
| f49452c165 | |||
| 60467782e3 | |||
| 4f70f89b78 | |||
| f6cb8ff8a1 | |||
| 4876b37f7f | |||
| b46535dedf | |||
| ba82f742e1 | |||
| 66c731bf65 | |||
| 5dcc57a130 | |||
| 1bd1b5545b | |||
| 8288c32d41 | |||
| e577a96f7e | |||
| d947bf75f5 | |||
| 9cbac142c2 | |||
| db9586bc3d | |||
| 4cefc96faf | |||
| 608c444694 | |||
| cacc6c7c62 | |||
| 11c17189b3 | |||
| 1a11dd777e | |||
| 05e644b040 | |||
| f3d4dab454 | |||
| d787803fd8 | |||
| 81893bf236 | |||
| 9f808376b9 | |||
| cbfed04bc9 | |||
| 44ed4c849c | |||
| bc2260a0f0 | |||
| d879999aeb | |||
| d1bf8f5033 | |||
| f4c2665e86 | |||
| 31029cbaf0 | |||
| 5ea7364a6d | |||
| b67a637c61 | |||
| c0fc1aea75 | |||
| 2a06a00e3e | |||
| f23a2fe389 | |||
| 69a4d305a5 | |||
| 0008869ddd | |||
| fa4644d00f | |||
| b78b3e8ede | |||
| 21c9797d1a | |||
| 94f4459d5b | |||
| 88b084422d | |||
| 954f28c2dc | |||
| 9ca62af730 | |||
| 3c6c9bc47b | |||
| acadc852c4 | |||
| 7a3d92d1d1 | |||
| 151077c799 | |||
| a99e926088 | |||
| 490f80d1e9 | |||
| 1d2a78c91e | |||
| f23a8bc8f5 | |||
| 11f3c52319 | |||
| 2b1c76a05d | |||
| a36e85d9b7 | |||
| 2fb0f851c0 | |||
| 7655c1cb98 | |||
| 9d62233cfc | |||
| 503b61c3df | |||
| 181b0f4377 | |||
| cb359ed61e | |||
| ec01a80486 |
@@ -31,6 +31,12 @@ jobs:
|
|||||||
- name: Install Postgre SQL
|
- name: Install Postgre SQL
|
||||||
run: sudo apt-get -y install libpq-dev
|
run: sudo apt-get -y install libpq-dev
|
||||||
|
|
||||||
|
- name: Install Sodium
|
||||||
|
run: sudo apt-get -y install libsodium-dev
|
||||||
|
|
||||||
|
- name: Install GNUTLS
|
||||||
|
run: sudo apt-get -y install libgnutls28-dev
|
||||||
|
|
||||||
- name: Install ZLib
|
- name: Install ZLib
|
||||||
run: sudo apt-get -y install zlib1g-dev
|
run: sudo apt-get -y install zlib1g-dev
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@
|
|||||||
/bin/*
|
/bin/*
|
||||||
|
|
||||||
# Exclude
|
# Exclude
|
||||||
!/bin/demo
|
!/vendor
|
||||||
|
|
||||||
# Hidden files and folders
|
# Hidden files and folders
|
||||||
.*
|
.*
|
||||||
|
|||||||
+13
-5
@@ -1,14 +1,23 @@
|
|||||||
cmake_minimum_required(VERSION 3.7)
|
cmake_minimum_required(VERSION 3.7)
|
||||||
project(SqMod)
|
project(SqMod)
|
||||||
|
|
||||||
|
# This plug-in only works on 64-bit
|
||||||
|
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||||
|
message(FATAL_ERROR "SqMod does not support 32-but platforms anymore.")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Tell CMake where to find our scripts
|
# Tell CMake where to find our scripts
|
||||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/vendor/POCO/cmake)
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/vendor/POCO/cmake)
|
||||||
|
|
||||||
# Several plugin options
|
# Several plugin options
|
||||||
option(ENABLE_API21 "Build for 2.1 API." OFF)
|
option(ENABLE_API21 "Build for 2.1 API." OFF)
|
||||||
|
option(ENABLE_DISCORD "Enable built-in Discord support" OFF)
|
||||||
|
option(ENABLE_DISCORD_VOICE "Enable voice support in Discord library" OFF)
|
||||||
option(ENABLE_OFFICIAL "Enable compatibility with official legacy plug-in" ON)
|
option(ENABLE_OFFICIAL "Enable compatibility with official legacy plug-in" ON)
|
||||||
option(FORCE_32BIT_BIN "Create a 32-bit executable binary if the compiler defaults to 64-bit." OFF)
|
# As a fall-back for certain situations (mainly some docker ubuntu containers)
|
||||||
|
option(ENABLE_BUILTIN_MYSQL_C "Enable built-in MySQL connector library" OFF)
|
||||||
|
#option(FORCE_32BIT_BIN "Create a 32-bit executable binary if the compiler defaults to 64-bit." OFF)
|
||||||
# This option should only be available in certain conditions
|
# This option should only be available in certain conditions
|
||||||
if(WIN32 AND MINGW)
|
if(WIN32 AND MINGW)
|
||||||
option(COPY_DEPENDENCIES "Copy deppendent DLLs into the deps folder." OFF)
|
option(COPY_DEPENDENCIES "Copy deppendent DLLs into the deps folder." OFF)
|
||||||
@@ -93,10 +102,9 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Determine if build mode
|
# Strip binary
|
||||||
if(${CMAKE_BUILD_TYPE} MATCHES "(Debug)+")
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s -g")
|
||||||
add_compile_options(-g)
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s -g")
|
||||||
endif()
|
|
||||||
|
|
||||||
# Enable position independent code
|
# Enable position independent code
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
|
|||||||
@@ -264,7 +264,12 @@ struct AABB
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD int32_t Cmp(SQFloat s) const
|
SQMOD_NODISCARD int32_t Cmp(SQFloat s) const
|
||||||
{
|
{
|
||||||
|
#ifdef SQUSEDOUBLE
|
||||||
|
auto f = static_cast< Value >(s);
|
||||||
|
return Cmp(AABB(f, f, f, f, f, f));
|
||||||
|
#else
|
||||||
return Cmp(AABB(s, s, s, s, s, s));
|
return Cmp(AABB(s, s, s, s, s, s));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -476,16 +476,16 @@ Array Circle::ToPointsArray(SQInteger num_segments) const
|
|||||||
if (i >= num_segments) return false;
|
if (i >= num_segments) return false;
|
||||||
// Get the current angle
|
// Get the current angle
|
||||||
#ifdef SQUSEDOUBLE
|
#ifdef SQUSEDOUBLE
|
||||||
SQFloat theta = 2.0d * SQMOD_PI64 * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
SQFloat theta = 2.0 * SQMOD_PI64 * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
||||||
#else
|
#else
|
||||||
SQFloat theta = 2.0f * SQMOD_PI * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
SQFloat theta = 2.0f * SQMOD_PI * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
||||||
#endif // SQUSEDOUBLE
|
#endif // SQUSEDOUBLE
|
||||||
// Calculate the x component
|
// Calculate the x component
|
||||||
SQFloat x = (rad * cosf(theta)) + pos.x;
|
SQFloat x = (rad * std::cos(theta)) + pos.x;
|
||||||
// Calculate the y component
|
// Calculate the y component
|
||||||
SQFloat y = (rad * sinf(theta)) + pos.y;
|
SQFloat y = (rad * std::sin(theta)) + pos.y;
|
||||||
// Push the Vector2 instance on the stack
|
// Push the Vector2 instance on the stack
|
||||||
Var< Vector2 >::push(vm, Vector2{x, y});
|
Var< Vector2 >::push(vm, Vector2{static_cast< Vector2::Value >(x), static_cast< Vector2::Value >(y)});
|
||||||
// Insert the element on the stack into the array
|
// Insert the element on the stack into the array
|
||||||
return true;
|
return true;
|
||||||
}, num_segments);
|
}, num_segments);
|
||||||
|
|||||||
@@ -807,7 +807,7 @@ static SQInteger SqPackARGB(SQInteger r, SQInteger g, SQInteger b, SQInteger a)
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SQInteger SqNameFilterCheck(HSQUIRRELVM vm)
|
static SQInteger SqNameFilterCheck(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
const int32_t top = sq_gettop(vm);
|
SQInteger top = sq_gettop(vm);
|
||||||
// Was the filter string specified?
|
// Was the filter string specified?
|
||||||
if (top <= 1)
|
if (top <= 1)
|
||||||
{
|
{
|
||||||
@@ -1031,7 +1031,7 @@ const String CmpGE::FSTRV("Assertion failed. Value mismatch: {0} >= {1}"); // NO
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SQInteger SqNameFilterCheckInsensitive(HSQUIRRELVM vm)
|
static SQInteger SqNameFilterCheckInsensitive(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
const int32_t top = sq_gettop(vm);
|
SQInteger top = sq_gettop(vm);
|
||||||
// Was the filter string specified?
|
// Was the filter string specified?
|
||||||
if (top <= 1)
|
if (top <= 1)
|
||||||
{
|
{
|
||||||
|
|||||||
+32
-7
@@ -76,8 +76,8 @@ add_library(SqModule MODULE SqBase.hpp Main.cpp
|
|||||||
Library/IO/Stream.cpp Library/IO/Stream.hpp
|
Library/IO/Stream.cpp Library/IO/Stream.hpp
|
||||||
Library/JSON.cpp Library/JSON.hpp
|
Library/JSON.cpp Library/JSON.hpp
|
||||||
Library/MMDB.cpp Library/MMDB.hpp
|
Library/MMDB.cpp Library/MMDB.hpp
|
||||||
|
Library/Net.cpp Library/Net.hpp
|
||||||
Library/Numeric.cpp Library/Numeric.hpp
|
Library/Numeric.cpp Library/Numeric.hpp
|
||||||
Library/Numeric/Long.cpp Library/Numeric/Long.hpp
|
|
||||||
Library/Numeric/Math.cpp Library/Numeric/Math.hpp
|
Library/Numeric/Math.cpp Library/Numeric/Math.hpp
|
||||||
Library/Numeric/Random.cpp Library/Numeric/Random.hpp
|
Library/Numeric/Random.cpp Library/Numeric/Random.hpp
|
||||||
Library/String.cpp Library/String.hpp
|
Library/String.cpp Library/String.hpp
|
||||||
@@ -85,6 +85,7 @@ add_library(SqModule MODULE SqBase.hpp Main.cpp
|
|||||||
Library/System/Dir.cpp Library/System/Dir.hpp
|
Library/System/Dir.cpp Library/System/Dir.hpp
|
||||||
Library/System/Env.cpp Library/System/Env.hpp
|
Library/System/Env.cpp Library/System/Env.hpp
|
||||||
Library/System/Path.cpp Library/System/Path.hpp
|
Library/System/Path.cpp Library/System/Path.hpp
|
||||||
|
Library/UTF8.cpp Library/UTF8.hpp
|
||||||
Library/Utils.cpp Library/Utils.hpp
|
Library/Utils.cpp Library/Utils.hpp
|
||||||
Library/Utils/Announce.cpp Library/Utils/Announce.hpp
|
Library/Utils/Announce.cpp Library/Utils/Announce.hpp
|
||||||
Library/Utils/String.cpp Library/Utils/String.hpp
|
Library/Utils/String.cpp Library/Utils/String.hpp
|
||||||
@@ -104,13 +105,11 @@ add_library(SqModule MODULE SqBase.hpp Main.cpp
|
|||||||
# POCO
|
# POCO
|
||||||
PocoLib/Crypto.cpp PocoLib/Crypto.hpp
|
PocoLib/Crypto.cpp PocoLib/Crypto.hpp
|
||||||
PocoLib/Data.cpp PocoLib/Data.hpp
|
PocoLib/Data.cpp PocoLib/Data.hpp
|
||||||
PocoLib/JSON.cpp PocoLib/JSON.hpp
|
|
||||||
PocoLib/Net.cpp PocoLib/Net.hpp
|
PocoLib/Net.cpp PocoLib/Net.hpp
|
||||||
PocoLib/RegEx.cpp PocoLib/RegEx.hpp
|
PocoLib/RegEx.cpp PocoLib/RegEx.hpp
|
||||||
PocoLib/Register.cpp PocoLib/Register.hpp
|
PocoLib/Register.cpp PocoLib/Register.hpp
|
||||||
PocoLib/Time.cpp PocoLib/Time.hpp
|
PocoLib/Time.cpp PocoLib/Time.hpp
|
||||||
PocoLib/Util.cpp PocoLib/Util.hpp
|
PocoLib/Util.cpp PocoLib/Util.hpp
|
||||||
PocoLib/XML.cpp PocoLib/XML.hpp
|
|
||||||
#
|
#
|
||||||
Core.cpp Core.hpp
|
Core.cpp Core.hpp
|
||||||
Logger.cpp Logger.hpp
|
Logger.cpp Logger.hpp
|
||||||
@@ -133,9 +132,30 @@ if(WIN32 OR MINGW)
|
|||||||
target_link_libraries(SqModule wsock32 ws2_32 shlwapi)
|
target_link_libraries(SqModule wsock32 ws2_32 shlwapi)
|
||||||
endif()
|
endif()
|
||||||
# Link to base libraries
|
# Link to base libraries
|
||||||
target_link_libraries(SqModule Squirrel fmt::fmt SimpleINI TinyDir ConcurrentQueue SAJSON CPR PUGIXML maxminddb libzmq-static)
|
target_link_libraries(SqModule Squirrel fmt::fmt SimpleINI TinyDir xxHash ConcurrentQueue SAJSON CPR UTF8Lib PUGIXML CivetWeb maxminddb libzmq-static)
|
||||||
|
# Enable built-in Discord support
|
||||||
|
if(ENABLE_DISCORD)
|
||||||
|
target_link_libraries(SqModule DPP)
|
||||||
|
target_compile_definitions(SqModule PRIVATE VCMP_ENABLE_DISCORD=1)
|
||||||
|
target_sources(SqModule PRIVATE
|
||||||
|
Library/DPP.cpp Library/DPP.hpp
|
||||||
|
Library/DPP/Channel.cpp Library/DPP/Channel.hpp
|
||||||
|
Library/DPP/Client.cpp Library/DPP/Client.hpp
|
||||||
|
Library/DPP/Cluster.cpp Library/DPP/Cluster.hpp
|
||||||
|
Library/DPP/Command.cpp Library/DPP/Command.hpp
|
||||||
|
Library/DPP/Constants.cpp Library/DPP/Constants.hpp
|
||||||
|
Library/DPP/Events.cpp Library/DPP/Events.hpp
|
||||||
|
Library/DPP/Guild.cpp Library/DPP/Guild.hpp
|
||||||
|
Library/DPP/Integration.cpp Library/DPP/Integration.hpp
|
||||||
|
Library/DPP/Message.cpp Library/DPP/Message.hpp
|
||||||
|
Library/DPP/Other.cpp Library/DPP/Other.hpp
|
||||||
|
Library/DPP/Role.cpp Library/DPP/Role.hpp
|
||||||
|
Library/DPP/User.cpp Library/DPP/User.hpp
|
||||||
|
Library/DPP/Utilities.cpp Library/DPP/Utilities.hpp
|
||||||
|
)
|
||||||
|
endif()
|
||||||
# Link to POCO libraries
|
# Link to POCO libraries
|
||||||
target_link_libraries(SqModule Poco::Foundation Poco::Crypto Poco::Data Poco::Net Poco::JSON Poco::XML)
|
target_link_libraries(SqModule Poco::Foundation Poco::Crypto Poco::Data Poco::Net)
|
||||||
# Does POCO have SQLite support?
|
# Does POCO have SQLite support?
|
||||||
if(ENABLE_DATA_SQLITE)
|
if(ENABLE_DATA_SQLITE)
|
||||||
if(NOT POCO_UNBUNDLED)
|
if(NOT POCO_UNBUNDLED)
|
||||||
@@ -150,9 +170,12 @@ if(ENABLE_DATA_SQLITE)
|
|||||||
# Include legacy implementation sources
|
# Include legacy implementation sources
|
||||||
target_sources(SqModule PRIVATE Library/SQLite.hpp Library/SQLite.cpp)
|
target_sources(SqModule PRIVATE Library/SQLite.hpp Library/SQLite.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
# Do we have built-in MYSQL enabled?
|
||||||
|
if (NOT ENABLE_BUILTIN_MYSQL_C)
|
||||||
|
find_package(MySQL)
|
||||||
|
endif()
|
||||||
# Does POCO have MySLQ support?
|
# Does POCO have MySLQ support?
|
||||||
find_package(MySQL)
|
if(ENABLE_BUILTIN_MYSQL_C OR MYSQL_FOUND)
|
||||||
if(MYSQL_FOUND)
|
|
||||||
message(STATUS "MySQL was enabled")
|
message(STATUS "MySQL was enabled")
|
||||||
# Link the libraries
|
# Link the libraries
|
||||||
target_link_libraries(SqModule Poco::DataMySQL)
|
target_link_libraries(SqModule Poco::DataMySQL)
|
||||||
@@ -175,6 +198,8 @@ if(${CMAKE_BUILD_TYPE} MATCHES "(Release)+")
|
|||||||
else()
|
else()
|
||||||
target_compile_definitions(SqModule PRIVATE _DEBUG=1 SQMOD_EXCEPTLOC=1)
|
target_compile_definitions(SqModule PRIVATE _DEBUG=1 SQMOD_EXCEPTLOC=1)
|
||||||
endif()
|
endif()
|
||||||
|
# Strip binary
|
||||||
|
set_target_properties(SqModule PROPERTIES LINK_FLAGS_RELEASE -s)
|
||||||
# Force 32-bit binaries when necessary
|
# Force 32-bit binaries when necessary
|
||||||
if(FORCE_32BIT_BIN)
|
if(FORCE_32BIT_BIN)
|
||||||
set_target_properties(SqModule PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
|
set_target_properties(SqModule PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
|
||||||
|
|||||||
@@ -48,6 +48,11 @@ extern void TerminatePrivileges();
|
|||||||
extern void TerminateRoutines();
|
extern void TerminateRoutines();
|
||||||
extern void TerminateCommands();
|
extern void TerminateCommands();
|
||||||
extern void TerminateSignals();
|
extern void TerminateSignals();
|
||||||
|
extern void TerminateNet();
|
||||||
|
#ifdef VCMP_ENABLE_DISCORD
|
||||||
|
extern void TerminateDPP();
|
||||||
|
#endif
|
||||||
|
extern void TerminatePocoNet();
|
||||||
extern void TerminatePocoData();
|
extern void TerminatePocoData();
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -547,7 +552,16 @@ void Core::Terminate(bool shutdown)
|
|||||||
// Release announcers
|
// Release announcers
|
||||||
AnnounceTerminate();
|
AnnounceTerminate();
|
||||||
cLogDbg(m_Verbosity >= 1, "Announcer terminated");
|
cLogDbg(m_Verbosity >= 1, "Announcer terminated");
|
||||||
|
// Release DPP
|
||||||
|
#ifdef VCMP_ENABLE_DISCORD
|
||||||
|
TerminateDPP();
|
||||||
|
cLogDbg(m_Verbosity >= 1, "Discord terminated");
|
||||||
|
#endif
|
||||||
|
// Release network
|
||||||
|
TerminateNet();
|
||||||
|
cLogDbg(m_Verbosity >= 1, "Network terminated");
|
||||||
// Release Poco statement results
|
// Release Poco statement results
|
||||||
|
TerminatePocoNet();
|
||||||
TerminatePocoData();
|
TerminatePocoData();
|
||||||
cLogDbg(m_Verbosity >= 1, "Poco terminated");
|
cLogDbg(m_Verbosity >= 1, "Poco terminated");
|
||||||
// Release ZMQ sockets
|
// Release ZMQ sockets
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ void Area::AddCircleEx(SQFloat cx, SQFloat cy, SQFloat cr, SQInteger num_segment
|
|||||||
CheckLock();
|
CheckLock();
|
||||||
// Get the current angle
|
// Get the current angle
|
||||||
#ifdef SQUSEDOUBLE
|
#ifdef SQUSEDOUBLE
|
||||||
SQFloat theta = 2.0d * SQMOD_PI64 * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
SQFloat theta = 2.0 * SQMOD_PI64 * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
||||||
#else
|
#else
|
||||||
SQFloat theta = 2.0f * SQMOD_PI * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
SQFloat theta = 2.0f * SQMOD_PI * static_cast< SQFloat >(i) / static_cast< SQFloat >(num_segments);
|
||||||
#endif // SQUSEDOUBLE
|
#endif // SQUSEDOUBLE
|
||||||
@@ -62,9 +62,9 @@ void Area::AddCircleEx(SQFloat cx, SQFloat cy, SQFloat cr, SQInteger num_segment
|
|||||||
// Calculate the y component
|
// Calculate the y component
|
||||||
SQFloat y = (cr * std::sin(theta)) + cy;
|
SQFloat y = (cr * std::sin(theta)) + cy;
|
||||||
// Insert the point into the list
|
// Insert the point into the list
|
||||||
mPoints.emplace_back(x, y);
|
mPoints.emplace_back(static_cast< Vector2::Value >(x), static_cast< Vector2::Value >(y));
|
||||||
// Update the bounding box
|
// Update the bounding box
|
||||||
Expand(x, y);
|
Expand(static_cast< Vector2::Value >(x), static_cast< Vector2::Value >(y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ public:
|
|||||||
: m_Ptr(o.m_Ptr), m_Cap(o.m_Cap), m_Cur(o.m_Cur)
|
: m_Ptr(o.m_Ptr), m_Cap(o.m_Cap), m_Cur(o.m_Cur)
|
||||||
{
|
{
|
||||||
o.m_Ptr = nullptr;
|
o.m_Ptr = nullptr;
|
||||||
|
o.m_Cap = o.m_Cur = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -175,6 +176,7 @@ public:
|
|||||||
m_Cap = o.m_Cap;
|
m_Cap = o.m_Cap;
|
||||||
m_Cur = o.m_Cur;
|
m_Cur = o.m_Cur;
|
||||||
o.m_Ptr = nullptr;
|
o.m_Ptr = nullptr;
|
||||||
|
o.m_Cap = o.m_Cur = 0;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -856,6 +858,17 @@ public:
|
|||||||
m_Cur += Write(m_Cur, str, size);
|
m_Cur += Write(m_Cur, str, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Steal ownership of the internal memory buffer. Whoever gets hold of the buffer must invoke delete [] on it.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Pointer Steal()
|
||||||
|
{
|
||||||
|
Pointer ptr = m_Ptr;
|
||||||
|
m_Ptr = nullptr;
|
||||||
|
m_Cap = m_Cur = 0; // Save this before calling this method
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
|||||||
+5
-75
@@ -2,7 +2,6 @@
|
|||||||
#include "Core/Common.hpp"
|
#include "Core/Common.hpp"
|
||||||
#include "Core/Buffer.hpp"
|
#include "Core/Buffer.hpp"
|
||||||
#include "Core/Utility.hpp"
|
#include "Core/Utility.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
@@ -149,7 +148,7 @@ void SqThrowLastF(const SQChar * msg, ...)
|
|||||||
// Now it's safe to throw the error
|
// Now it's safe to throw the error
|
||||||
SqThrowF(fmt::runtime("{} [{}]"), b.Data(), message);
|
SqThrowF(fmt::runtime("{} [{}]"), b.Data(), message);
|
||||||
#else
|
#else
|
||||||
SqThrowF("{} [{}]", b.Data(), std::strerror(errno));
|
SqThrowF(fmt::runtime("{} [{}]"), b.Data(), std::strerror(errno));
|
||||||
#endif // SQMOD_OS_WINDOWS
|
#endif // SQMOD_OS_WINDOWS
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,46 +312,10 @@ SQInteger PopStackInteger(HSQUIRRELVM vm, SQInteger idx)
|
|||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
case OT_CLASS:
|
case OT_CLASS:
|
||||||
case OT_USERDATA:
|
case OT_USERDATA:
|
||||||
{
|
|
||||||
return sq_getsize(vm, idx);
|
|
||||||
}
|
|
||||||
case OT_INSTANCE:
|
case OT_INSTANCE:
|
||||||
{
|
{
|
||||||
SQUserPointer tag;
|
// Attempt to get the size of the instance as a fall back
|
||||||
// Attempt to retrieve the type tag
|
return sq_getsize(vm, idx);
|
||||||
if (SQ_FAILED(sq_gettypetag(vm, -1, &tag)))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Is the instance SLongInt? (signed long)
|
|
||||||
else if (static_cast< AbstractStaticClassData * >(tag) == StaticClassTypeTag< SLongInt >::Get())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return ConvTo< SQInteger >::From(Var< const SLongInt & >(vm, idx).value.GetNum());
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
// Just ignore it...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Is the instance ULongInt? (unsigned long)
|
|
||||||
else if (static_cast< AbstractStaticClassData * >(tag) == StaticClassTypeTag< ULongInt >::Get())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return ConvTo< SQInteger >::From(Var< const ULongInt & >(vm, idx).value.GetNum());
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
// Just ignore it...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Attempt to get the size of the instance as a fall back
|
|
||||||
return sq_getsize(vm, idx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
@@ -406,41 +369,8 @@ SQFloat PopStackFloat(HSQUIRRELVM vm, SQInteger idx)
|
|||||||
}
|
}
|
||||||
case OT_INSTANCE:
|
case OT_INSTANCE:
|
||||||
{
|
{
|
||||||
SQUserPointer tag;
|
// Attempt to get the size of the instance as a fall back
|
||||||
// Attempt to retrieve the type tag
|
return ConvTo< SQFloat >::From(sq_getsize(vm, idx));
|
||||||
if (SQ_FAILED(sq_gettypetag(vm, -1, &tag)))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Is the instance SLongInt? (signed long)
|
|
||||||
else if (static_cast< AbstractStaticClassData * >(tag) == StaticClassTypeTag< SLongInt >::Get())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return ConvTo< SQFloat >::From(Var< const SLongInt & >(vm, idx).value.GetNum());
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
// Just ignore it...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Is the instance ULongInt? (unsigned long)
|
|
||||||
else if (static_cast< AbstractStaticClassData * >(tag) == StaticClassTypeTag< ULongInt >::Get())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return ConvTo< SQFloat >::From(Var< const ULongInt & >(vm, idx).value.GetNum());
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
// Just ignore it...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Attempt to get the size of the instance as a fall back
|
|
||||||
return ConvTo< SQFloat >::From(sq_getsize(vm, idx));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ void OutputMessage(const char * msg, ...);
|
|||||||
void OutputError(const char * msg, ...);
|
void OutputError(const char * msg, ...);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Generate a formatted string and throw it as a sqrat exception.
|
* Generate a formatted string and throw it as a Sqrat exception.
|
||||||
*/
|
*/
|
||||||
template < class... Args > void SqThrowF(Args &&... args)
|
template < class... Args > void SqThrowF(Args &&... args)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -444,7 +444,7 @@ void Core::EmitPlayerKilled(int32_t player_id, int32_t killer_id, int32_t reason
|
|||||||
#ifdef VCMP_ENABLE_OFFICIAL
|
#ifdef VCMP_ENABLE_OFFICIAL
|
||||||
if (IsOfficial())
|
if (IsOfficial())
|
||||||
{
|
{
|
||||||
if (!team_kill)
|
if (team_kill)
|
||||||
{
|
{
|
||||||
ExecuteLegacyEvent(m_VM, _SC("onPlayerTeamKill"), _killer.mLgObj, _player.mLgObj, reason, static_cast< int32_t >(body_part));
|
ExecuteLegacyEvent(m_VM, _SC("onPlayerTeamKill"), _killer.mLgObj, _player.mLgObj, reason, static_cast< int32_t >(body_part));
|
||||||
}
|
}
|
||||||
@@ -1743,7 +1743,7 @@ void Core::EmitEntityPool(vcmpEntityPool entity_type, int32_t entity_id, bool is
|
|||||||
break;
|
break;
|
||||||
case vcmpEntityPoolRadio:
|
case vcmpEntityPoolRadio:
|
||||||
// @TODO Implement...
|
// @TODO Implement...
|
||||||
//break;
|
break;
|
||||||
#if SQMOD_SDK_LEAST(2, 1)
|
#if SQMOD_SDK_LEAST(2, 1)
|
||||||
case vcmpEntityPoolPlayer:
|
case vcmpEntityPoolPlayer:
|
||||||
// @TODO Implement...
|
// @TODO Implement...
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ template < class Key, class T, class Pred = std::equal_to< Key > > struct VecMap
|
|||||||
using difference_type = typename storage_type::difference_type;
|
using difference_type = typename storage_type::difference_type;
|
||||||
using iterator = typename storage_type::iterator;
|
using iterator = typename storage_type::iterator;
|
||||||
using const_iterator = typename storage_type::const_iterator;
|
using const_iterator = typename storage_type::const_iterator;
|
||||||
|
using reverse_iterator = typename storage_type::reverse_iterator;
|
||||||
|
using const_reverse_iterator = typename storage_type::const_reverse_iterator;
|
||||||
using insert_return_type = std::pair< iterator, pointer >;
|
using insert_return_type = std::pair< iterator, pointer >;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -100,12 +102,12 @@ template < class Key, class T, class Pred = std::equal_to< Key > > struct VecMap
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve a reverse iterator to the beginning (const). See: std::vector::[c]rbegin()
|
* Retrieve a reverse iterator to the beginning (const). See: std::vector::[c]rbegin()
|
||||||
*/
|
*/
|
||||||
const_iterator rbegin() const noexcept { return m_Storage.rbegin(); }
|
reverse_iterator rbegin() const noexcept { return m_Storage.rbegin(); }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve a reverse iterator to the beginning (const). See: std::vector::crbegin()
|
* Retrieve a reverse iterator to the beginning (const). See: std::vector::crbegin()
|
||||||
*/
|
*/
|
||||||
const_iterator crbegin() const noexcept { return m_Storage.crbegin(); }
|
const_reverse_iterator crbegin() const noexcept { return m_Storage.crbegin(); }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve a reverse iterator to the beginning. See: std::vector::rend()
|
* Retrieve a reverse iterator to the beginning. See: std::vector::rend()
|
||||||
@@ -115,12 +117,12 @@ template < class Key, class T, class Pred = std::equal_to< Key > > struct VecMap
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve a reverse iterator to the beginning (const). See: std::vector::[c]rend()
|
* Retrieve a reverse iterator to the beginning (const). See: std::vector::[c]rend()
|
||||||
*/
|
*/
|
||||||
const_iterator rend() const noexcept { return m_Storage.rend(); }
|
reverse_iterator rend() const noexcept { return m_Storage.rend(); }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve a reverse iterator to the beginning (const). See: std::vector::crend()
|
* Retrieve a reverse iterator to the beginning (const). See: std::vector::crend()
|
||||||
*/
|
*/
|
||||||
const_iterator crend() const noexcept { return m_Storage.crend(); }
|
const_reverse_iterator crend() const noexcept { return m_Storage.crend(); }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Check if elements are stored in the container.
|
* Check if elements are stored in the container.
|
||||||
|
|||||||
@@ -157,16 +157,16 @@ void CCheckpoint::SetWorld(int32_t world)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetCheckPointWorld(m_ID, world);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & CHECKPOINTCL_EMIT_CHECKPOINT_WORLD))
|
else if (!(m_CircularLocks & CHECKPOINTCL_EMIT_CHECKPOINT_WORLD))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, CHECKPOINTCL_EMIT_CHECKPOINT_WORLD);
|
BitGuardU32 bg(m_CircularLocks, CHECKPOINTCL_EMIT_CHECKPOINT_WORLD);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitCheckpointWorld(m_ID, current, world);
|
Core::Get().EmitCheckpointWorld(m_ID, current, world);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetCheckPointWorld(m_ID, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -257,8 +257,6 @@ void CCheckpoint::SetRadius(float radius)
|
|||||||
Validate();
|
Validate();
|
||||||
// Grab the current value for this property
|
// Grab the current value for this property
|
||||||
const float current = _Func->GetCheckPointRadius(m_ID);
|
const float current = _Func->GetCheckPointRadius(m_ID);
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetCheckPointRadius(m_ID, radius);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & CHECKPOINTCL_EMIT_CHECKPOINT_RADIUS))
|
if (!(m_CircularLocks & CHECKPOINTCL_EMIT_CHECKPOINT_RADIUS))
|
||||||
{
|
{
|
||||||
@@ -267,6 +265,8 @@ void CCheckpoint::SetRadius(float radius)
|
|||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitCheckpointRadius(m_ID, current, radius);
|
Core::Get().EmitCheckpointRadius(m_ID, current, radius);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetCheckPointRadius(m_ID, radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
+12
-12
@@ -163,16 +163,16 @@ void CObject::SetWorld(int32_t world)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetObjectWorld(m_ID, world);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_WORLD))
|
else if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_WORLD))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, OBJECTCL_EMIT_OBJECT_WORLD);
|
BitGuardU32 bg(m_CircularLocks, OBJECTCL_EMIT_OBJECT_WORLD);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitObjectWorld(m_ID, current, world);
|
Core::Get().EmitObjectWorld(m_ID, current, world);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetObjectWorld(m_ID, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -202,16 +202,16 @@ void CObject::SetAlphaEx(int32_t alpha, uint32_t time)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetObjectAlpha(m_ID, alpha, time);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_ALPHA))
|
else if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_ALPHA))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, OBJECTCL_EMIT_OBJECT_ALPHA);
|
BitGuardU32 bg(m_CircularLocks, OBJECTCL_EMIT_OBJECT_ALPHA);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitObjectAlpha(m_ID, current, alpha, time);
|
Core::Get().EmitObjectAlpha(m_ID, current, alpha, time);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetObjectAlpha(m_ID, alpha, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -400,16 +400,16 @@ void CObject::SetShotReport(bool toggle)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetObjectShotReportEnabled(m_ID, static_cast< uint8_t >(toggle));
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_REPORT))
|
else if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_REPORT))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, OBJECTCL_EMIT_OBJECT_REPORT);
|
BitGuardU32 bg(m_CircularLocks, OBJECTCL_EMIT_OBJECT_REPORT);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitObjectReport(m_ID, current, toggle, false);
|
Core::Get().EmitObjectReport(m_ID, current, toggle, false);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetObjectShotReportEnabled(m_ID, static_cast< uint8_t >(toggle));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -433,16 +433,16 @@ void CObject::SetTouchedReport(bool toggle)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetObjectTouchedReportEnabled(m_ID, static_cast< uint8_t >(toggle));
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_REPORT))
|
else if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_REPORT))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, OBJECTCL_EMIT_OBJECT_REPORT);
|
BitGuardU32 bg(m_CircularLocks, OBJECTCL_EMIT_OBJECT_REPORT);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitObjectReport(m_ID, current, toggle, true);
|
Core::Get().EmitObjectReport(m_ID, current, toggle, true);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetObjectTouchedReportEnabled(m_ID, static_cast< uint8_t >(toggle));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
+28
-26
@@ -145,19 +145,20 @@ void CPickup::SetOption(int32_t option_id, bool toggle)
|
|||||||
{
|
{
|
||||||
// Attempt to obtain the current value of the specified option
|
// Attempt to obtain the current value of the specified option
|
||||||
const bool value = _Func->GetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id));
|
const bool value = _Func->GetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id));
|
||||||
// Attempt to modify the current value of the specified option
|
// Avoid infinite recursive event loops
|
||||||
if (_Func->SetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id),
|
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_OPTION))
|
||||||
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
|
|
||||||
{
|
|
||||||
STHROWF("Invalid option identifier: {}", option_id);
|
|
||||||
}
|
|
||||||
else if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_OPTION))
|
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_OPTION);
|
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_OPTION);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPickupOption(m_ID, option_id, value, 0, NullLightObj());
|
Core::Get().EmitPickupOption(m_ID, option_id, value, 0, NullLightObj());
|
||||||
}
|
}
|
||||||
|
// Attempt to modify the current value of the specified option
|
||||||
|
if (_Func->SetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id),
|
||||||
|
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
|
||||||
|
{
|
||||||
|
STHROWF("Invalid option identifier: {}", option_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -165,19 +166,20 @@ void CPickup::SetOptionEx(int32_t option_id, bool toggle, int32_t header, LightO
|
|||||||
{
|
{
|
||||||
// Attempt to obtain the current value of the specified option
|
// Attempt to obtain the current value of the specified option
|
||||||
const bool value = _Func->GetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id));
|
const bool value = _Func->GetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id));
|
||||||
// Attempt to modify the current value of the specified option
|
// Avoid infinite recursive event loops
|
||||||
if (_Func->SetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id),
|
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_OPTION))
|
||||||
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
|
|
||||||
{
|
|
||||||
STHROWF("Invalid option identifier: {}", option_id);
|
|
||||||
}
|
|
||||||
else if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_OPTION))
|
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_OPTION);
|
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_OPTION);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPickupOption(m_ID, option_id, value, header, payload);
|
Core::Get().EmitPickupOption(m_ID, option_id, value, header, payload);
|
||||||
}
|
}
|
||||||
|
// Attempt to modify the current value of the specified option
|
||||||
|
if (_Func->SetPickupOption(m_ID, static_cast< vcmpPickupOption >(option_id),
|
||||||
|
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
|
||||||
|
{
|
||||||
|
STHROWF("Invalid option identifier: {}", option_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -201,16 +203,16 @@ void CPickup::SetWorld(int32_t world)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetPickupWorld(m_ID, world);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_WORLD))
|
else if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_WORLD))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_WORLD);
|
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_WORLD);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPickupWorld(m_ID, current, world);
|
Core::Get().EmitPickupWorld(m_ID, current, world);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetPickupWorld(m_ID, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -234,16 +236,16 @@ void CPickup::SetAlpha(int32_t alpha)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetPickupAlpha(m_ID, alpha);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_ALPHA))
|
else if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_ALPHA))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_ALPHA);
|
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_ALPHA);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPickupAlpha(m_ID, current, alpha);
|
Core::Get().EmitPickupAlpha(m_ID, current, alpha);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetPickupAlpha(m_ID, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -267,16 +269,16 @@ void CPickup::SetAutomatic(bool toggle)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetPickupIsAutomatic(m_ID, static_cast< uint8_t >(toggle));
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_AUTOMATIC))
|
else if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_AUTOMATIC))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_AUTOMATIC);
|
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_AUTOMATIC);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPickupAutomatic(m_ID, current, toggle);
|
Core::Get().EmitPickupAutomatic(m_ID, current, toggle);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetPickupIsAutomatic(m_ID, static_cast< uint8_t >(toggle));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -300,16 +302,16 @@ void CPickup::SetAutoTimer(int32_t timer)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetPickupAutoTimer(m_ID, static_cast< uint32_t >(timer));
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_AUTOTIMER))
|
else if (!(m_CircularLocks & PICKUPCL_EMIT_PICKUP_AUTOTIMER))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_AUTOTIMER);
|
BitGuardU32 bg(m_CircularLocks, PICKUPCL_EMIT_PICKUP_AUTOTIMER);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPickupAutoTimer(m_ID, current, timer);
|
Core::Get().EmitPickupAutoTimer(m_ID, current, timer);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetPickupAutoTimer(m_ID, static_cast< uint32_t >(timer));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
+70
-44
@@ -168,16 +168,16 @@ void CPlayer::SetAdmin(bool toggle)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetPlayerAdmin(m_ID, static_cast< uint8_t >(toggle));
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_ADMIN))
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_ADMIN))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_ADMIN);
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_ADMIN);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPlayerAdmin(m_ID, current, toggle);
|
Core::Get().EmitPlayerAdmin(m_ID, current, toggle);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetPlayerAdmin(m_ID, static_cast< uint8_t >(toggle));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -373,13 +373,6 @@ void CPlayer::SetOptionEx(int32_t option_id, bool toggle, int32_t header, LightO
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
else if (_Func->SetPlayerOption(m_ID,
|
|
||||||
static_cast< vcmpPlayerOption >(option_id),
|
|
||||||
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
|
|
||||||
{
|
|
||||||
STHROWF("Invalid option identifier: {}", option_id);
|
|
||||||
}
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_OPTION))
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_OPTION))
|
||||||
{
|
{
|
||||||
@@ -388,6 +381,13 @@ void CPlayer::SetOptionEx(int32_t option_id, bool toggle, int32_t header, LightO
|
|||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPlayerOption(m_ID, option_id, current, header, payload);
|
Core::Get().EmitPlayerOption(m_ID, option_id, current, header, payload);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
if (_Func->SetPlayerOption(m_ID,
|
||||||
|
static_cast< vcmpPlayerOption >(option_id),
|
||||||
|
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
|
||||||
|
{
|
||||||
|
STHROWF("Invalid option identifier: {}", option_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if SQMOD_SDK_LEAST(2, 1)
|
#if SQMOD_SDK_LEAST(2, 1)
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -433,16 +433,16 @@ void CPlayer::SetWorld(int32_t world)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetPlayerWorld(m_ID, world);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_WORLD))
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_WORLD))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_WORLD);
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_WORLD);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPlayerWorld(m_ID, current, world, false);
|
Core::Get().EmitPlayerWorld(m_ID, current, world, false);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetPlayerWorld(m_ID, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -466,16 +466,16 @@ void CPlayer::SetSecondaryWorld(int32_t world)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetPlayerSecondaryWorld(m_ID, world);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_WORLD))
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_WORLD))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_WORLD);
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_WORLD);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPlayerWorld(m_ID, current, world, true);
|
Core::Get().EmitPlayerWorld(m_ID, current, world, true);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetPlayerSecondaryWorld(m_ID, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -526,11 +526,6 @@ void CPlayer::SetTeam(int32_t team)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
else if (_Func->SetPlayerTeam(m_ID, team) == vcmpErrorArgumentOutOfBounds)
|
|
||||||
{
|
|
||||||
STHROWF("Invalid team identifier: {}", team);
|
|
||||||
}
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_TEAM))
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_TEAM))
|
||||||
{
|
{
|
||||||
@@ -539,6 +534,11 @@ void CPlayer::SetTeam(int32_t team)
|
|||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPlayerTeam(m_ID, current, team);
|
Core::Get().EmitPlayerTeam(m_ID, current, team);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
if (_Func->SetPlayerTeam(m_ID, team) == vcmpErrorArgumentOutOfBounds)
|
||||||
|
{
|
||||||
|
STHROWF("Invalid team identifier: {}", team);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -562,11 +562,6 @@ void CPlayer::SetSkin(int32_t skin)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
else if (_Func->SetPlayerSkin(m_ID, skin) == vcmpErrorArgumentOutOfBounds)
|
|
||||||
{
|
|
||||||
STHROWF("Invalid skin identifier: {}", skin);
|
|
||||||
}
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_SKIN))
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_SKIN))
|
||||||
{
|
{
|
||||||
@@ -575,6 +570,11 @@ void CPlayer::SetSkin(int32_t skin)
|
|||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPlayerSkin(m_ID, current, skin);
|
Core::Get().EmitPlayerSkin(m_ID, current, skin);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
if (_Func->SetPlayerSkin(m_ID, skin) == vcmpErrorArgumentOutOfBounds)
|
||||||
|
{
|
||||||
|
STHROWF("Invalid skin identifier: {}", skin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -665,16 +665,16 @@ void CPlayer::SetMoney(int32_t amount)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetPlayerMoney(m_ID, amount);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_MONEY))
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_MONEY))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_MONEY);
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_MONEY);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPlayerMoney(m_ID, current, amount);
|
Core::Get().EmitPlayerMoney(m_ID, current, amount);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetPlayerMoney(m_ID, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -684,8 +684,6 @@ void CPlayer::GiveMoney(int32_t amount)
|
|||||||
Validate();
|
Validate();
|
||||||
// Grab the current value for this property
|
// Grab the current value for this property
|
||||||
const int32_t current = _Func->GetPlayerMoney(m_ID);
|
const int32_t current = _Func->GetPlayerMoney(m_ID);
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->GivePlayerMoney(m_ID, amount);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_MONEY))
|
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_MONEY))
|
||||||
{
|
{
|
||||||
@@ -694,6 +692,8 @@ void CPlayer::GiveMoney(int32_t amount)
|
|||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPlayerMoney(m_ID, current, current + amount);
|
Core::Get().EmitPlayerMoney(m_ID, current, current + amount);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->GivePlayerMoney(m_ID, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -717,16 +717,16 @@ void CPlayer::SetScore(int32_t score)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetPlayerScore(m_ID, score);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_SCORE))
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_SCORE))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_SCORE);
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_SCORE);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPlayerScore(m_ID, current, score);
|
Core::Get().EmitPlayerScore(m_ID, current, score);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetPlayerScore(m_ID, score);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -750,16 +750,16 @@ void CPlayer::SetWantedLevel(int32_t level)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetPlayerWantedLevel(m_ID, level);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_WANTED_LEVEL))
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_WANTED_LEVEL))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_WANTED_LEVEL);
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_WANTED_LEVEL);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPlayerWantedLevel(m_ID, current, level);
|
Core::Get().EmitPlayerWantedLevel(m_ID, current, level);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetPlayerWantedLevel(m_ID, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -832,8 +832,6 @@ void CPlayer::SetImmunity(uint32_t flags)
|
|||||||
Validate();
|
Validate();
|
||||||
// Grab the current value for this property
|
// Grab the current value for this property
|
||||||
const uint32_t current = _Func->GetPlayerImmunityFlags(m_ID);
|
const uint32_t current = _Func->GetPlayerImmunityFlags(m_ID);
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetPlayerImmunityFlags(m_ID, static_cast< uint32_t >(flags));
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_IMMUNITY))
|
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_IMMUNITY))
|
||||||
{
|
{
|
||||||
@@ -842,6 +840,8 @@ void CPlayer::SetImmunity(uint32_t flags)
|
|||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPlayerImmunity(m_ID, static_cast< int32_t >(current), static_cast< int32_t >(flags));
|
Core::Get().EmitPlayerImmunity(m_ID, static_cast< int32_t >(current), static_cast< int32_t >(flags));
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetPlayerImmunityFlags(m_ID, static_cast< uint32_t >(flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -969,16 +969,16 @@ void CPlayer::SetAlphaEx(int32_t alpha, int32_t fade)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetPlayerAlpha(m_ID, alpha, static_cast< uint32_t >(fade));
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_ALPHA))
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_ALPHA))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_ALPHA);
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_ALPHA);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitPlayerAlpha(m_ID, current, alpha, fade);
|
Core::Get().EmitPlayerAlpha(m_ID, current, alpha, fade);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetPlayerAlpha(m_ID, alpha, static_cast< uint32_t >(fade));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -1044,7 +1044,7 @@ uint32_t CPlayer::GetGameKeys() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool CPlayer::Embark(CVehicle & vehicle) const
|
bool CPlayer::Embark(CVehicle & vehicle)
|
||||||
{
|
{
|
||||||
// Is the specified vehicle even valid?
|
// Is the specified vehicle even valid?
|
||||||
if (!vehicle.IsActive())
|
if (!vehicle.IsActive())
|
||||||
@@ -1053,13 +1053,26 @@ bool CPlayer::Embark(CVehicle & vehicle) const
|
|||||||
}
|
}
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
|
// If the player embarks in the same vehicle then ignore
|
||||||
|
if (_Func->GetPlayerVehicleId(m_ID) == vehicle.GetID())
|
||||||
|
{
|
||||||
|
return true; // I guess this is somewhat successful
|
||||||
|
}
|
||||||
|
// Avoid infinite recursive event loops
|
||||||
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_EMBARK))
|
||||||
|
{
|
||||||
|
// Prevent this event from triggering while executed
|
||||||
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_EMBARK);
|
||||||
|
// Now forward the event call
|
||||||
|
Core::Get().EmitPlayerEmbarking(m_ID, vehicle.GetID(), 0);
|
||||||
|
}
|
||||||
// Perform the requested operation
|
// Perform the requested operation
|
||||||
return (_Func->PutPlayerInVehicle(m_ID, vehicle.GetID(), 0,
|
return (_Func->PutPlayerInVehicle(m_ID, vehicle.GetID(), 0,
|
||||||
static_cast< uint8_t >(true), static_cast< uint8_t >(true)) != vcmpErrorRequestDenied);
|
static_cast< uint8_t >(true), static_cast< uint8_t >(true)) != vcmpErrorRequestDenied);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool CPlayer::EmbarkEx(CVehicle & vehicle, int32_t slot, bool allocate, bool warp) const
|
bool CPlayer::EmbarkEx(CVehicle & vehicle, int32_t slot, bool allocate, bool warp)
|
||||||
{
|
{
|
||||||
// Is the specified vehicle even valid?
|
// Is the specified vehicle even valid?
|
||||||
if (!vehicle.IsActive())
|
if (!vehicle.IsActive())
|
||||||
@@ -1068,6 +1081,19 @@ bool CPlayer::EmbarkEx(CVehicle & vehicle, int32_t slot, bool allocate, bool war
|
|||||||
}
|
}
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
|
// If the player embarks in the same vehicle then ignore
|
||||||
|
if (_Func->GetPlayerVehicleId(m_ID) == vehicle.GetID())
|
||||||
|
{
|
||||||
|
return true; // I guess this is somewhat successful
|
||||||
|
}
|
||||||
|
// Avoid infinite recursive event loops
|
||||||
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_EMBARK))
|
||||||
|
{
|
||||||
|
// Prevent this event from triggering while executed
|
||||||
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_EMBARK);
|
||||||
|
// Now forward the event call
|
||||||
|
Core::Get().EmitPlayerEmbarking(m_ID, vehicle.GetID(), slot);
|
||||||
|
}
|
||||||
// Perform the requested operation
|
// Perform the requested operation
|
||||||
return (_Func->PutPlayerInVehicle(m_ID, vehicle.GetID(), slot,
|
return (_Func->PutPlayerInVehicle(m_ID, vehicle.GetID(), slot,
|
||||||
static_cast< uint8_t >(allocate), static_cast< uint8_t >(warp)) != vcmpErrorRequestDenied);
|
static_cast< uint8_t >(allocate), static_cast< uint8_t >(warp)) != vcmpErrorRequestDenied);
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ enum PlayerCircularLocks
|
|||||||
PLAYERCL_EMIT_PLAYER_SCORE = (1u << 6u),
|
PLAYERCL_EMIT_PLAYER_SCORE = (1u << 6u),
|
||||||
PLAYERCL_EMIT_PLAYER_WANTED_LEVEL = (1u << 7u),
|
PLAYERCL_EMIT_PLAYER_WANTED_LEVEL = (1u << 7u),
|
||||||
PLAYERCL_EMIT_PLAYER_IMMUNITY = (1u << 8u),
|
PLAYERCL_EMIT_PLAYER_IMMUNITY = (1u << 8u),
|
||||||
PLAYERCL_EMIT_PLAYER_ALPHA = (1u << 9u)
|
PLAYERCL_EMIT_PLAYER_ALPHA = (1u << 9u),
|
||||||
|
PLAYERCL_EMIT_PLAYER_EMBARK = (1u << 10u)
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
@@ -593,12 +594,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Embark the managed player entity into the specified vehicle entity.
|
* Embark the managed player entity into the specified vehicle entity.
|
||||||
*/
|
*/
|
||||||
bool Embark(CVehicle & vehicle) const;
|
bool Embark(CVehicle & vehicle);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Embark the managed player entity into the specified vehicle entity.
|
* Embark the managed player entity into the specified vehicle entity.
|
||||||
*/
|
*/
|
||||||
bool EmbarkEx(CVehicle & vehicle, int32_t slot, bool allocate, bool warp) const;
|
bool EmbarkEx(CVehicle & vehicle, int32_t slot, bool allocate, bool warp);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Disembark the managed player entity from the currently embarked vehicle entity.
|
* Disembark the managed player entity from the currently embarked vehicle entity.
|
||||||
|
|||||||
+65
-37
@@ -148,19 +148,20 @@ void CVehicle::SetOption(int32_t option_id, bool toggle)
|
|||||||
{
|
{
|
||||||
// Attempt to obtain the current value of the specified option
|
// Attempt to obtain the current value of the specified option
|
||||||
const bool value = _Func->GetVehicleOption(m_ID, static_cast< vcmpVehicleOption >(option_id));
|
const bool value = _Func->GetVehicleOption(m_ID, static_cast< vcmpVehicleOption >(option_id));
|
||||||
// Attempt to modify the current value of the specified option
|
// Avoid infinite recursive event loops
|
||||||
if (_Func->SetVehicleOption(m_ID, static_cast< vcmpVehicleOption >(option_id),
|
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_OPTION))
|
||||||
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
|
|
||||||
{
|
|
||||||
STHROWF("Invalid option identifier: {}", option_id);
|
|
||||||
}
|
|
||||||
else if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_OPTION))
|
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_OPTION);
|
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_OPTION);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitVehicleOption(m_ID, option_id, value, 0, NullLightObj());
|
Core::Get().EmitVehicleOption(m_ID, option_id, value, 0, NullLightObj());
|
||||||
}
|
}
|
||||||
|
// Attempt to modify the current value of the specified option
|
||||||
|
if (_Func->SetVehicleOption(m_ID, static_cast< vcmpVehicleOption >(option_id),
|
||||||
|
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
|
||||||
|
{
|
||||||
|
STHROWF("Invalid option identifier: {}", option_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -168,19 +169,20 @@ void CVehicle::SetOptionEx(int32_t option_id, bool toggle, int32_t header, Light
|
|||||||
{
|
{
|
||||||
// Attempt to obtain the current value of the specified option
|
// Attempt to obtain the current value of the specified option
|
||||||
const bool value = _Func->GetVehicleOption(m_ID, static_cast< vcmpVehicleOption >(option_id));
|
const bool value = _Func->GetVehicleOption(m_ID, static_cast< vcmpVehicleOption >(option_id));
|
||||||
// Attempt to modify the current value of the specified option
|
// Avoid infinite recursive event loops
|
||||||
if (_Func->SetVehicleOption(m_ID, static_cast< vcmpVehicleOption >(option_id),
|
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_OPTION))
|
||||||
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
|
|
||||||
{
|
|
||||||
STHROWF("Invalid option identifier: {}", option_id);
|
|
||||||
}
|
|
||||||
else if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_OPTION))
|
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_OPTION);
|
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_OPTION);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitVehicleOption(m_ID, option_id, value, header, payload);
|
Core::Get().EmitVehicleOption(m_ID, option_id, value, header, payload);
|
||||||
}
|
}
|
||||||
|
// Attempt to modify the current value of the specified option
|
||||||
|
if (_Func->SetVehicleOption(m_ID, static_cast< vcmpVehicleOption >(option_id),
|
||||||
|
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
|
||||||
|
{
|
||||||
|
STHROWF("Invalid option identifier: {}", option_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -222,16 +224,16 @@ void CVehicle::SetWorld(int32_t world)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetVehicleWorld(m_ID, world);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_WORLD))
|
else if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_WORLD))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_WORLD);
|
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_WORLD);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitVehicleWorld(m_ID, current, world);
|
Core::Get().EmitVehicleWorld(m_ID, current, world);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetVehicleWorld(m_ID, world);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -321,8 +323,6 @@ void CVehicle::SetImmunity(uint32_t flags)
|
|||||||
Validate();
|
Validate();
|
||||||
// Grab the current value for this property
|
// Grab the current value for this property
|
||||||
const uint32_t current = _Func->GetVehicleImmunityFlags(m_ID);
|
const uint32_t current = _Func->GetVehicleImmunityFlags(m_ID);
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetVehicleImmunityFlags(m_ID, static_cast< uint32_t >(flags));
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_IMMUNITY))
|
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_IMMUNITY))
|
||||||
{
|
{
|
||||||
@@ -331,6 +331,8 @@ void CVehicle::SetImmunity(uint32_t flags)
|
|||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitVehicleImmunity(m_ID, static_cast< int32_t >(current), static_cast< int32_t >(flags));
|
Core::Get().EmitVehicleImmunity(m_ID, static_cast< int32_t >(current), static_cast< int32_t >(flags));
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetVehicleImmunityFlags(m_ID, static_cast< uint32_t >(flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -914,16 +916,16 @@ void CVehicle::SetPartStatus(int32_t part, int32_t status)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetVehiclePartStatus(m_ID, part, status);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_PARTSTATUS))
|
else if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_PARTSTATUS))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_PARTSTATUS);
|
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_PARTSTATUS);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitVehiclePartStatus(m_ID, part, current, status);
|
Core::Get().EmitVehiclePartStatus(m_ID, part, current, status);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetVehiclePartStatus(m_ID, part, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -947,16 +949,16 @@ void CVehicle::SetTyreStatus(int32_t tyre, int32_t status)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetVehicleTyreStatus(m_ID, tyre, status);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_TYRESTATUS))
|
else if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_TYRESTATUS))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_TYRESTATUS);
|
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_TYRESTATUS);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitVehicleTyreStatus(m_ID, tyre, current, status);
|
Core::Get().EmitVehicleTyreStatus(m_ID, tyre, current, status);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetVehicleTyreStatus(m_ID, tyre, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -980,16 +982,16 @@ void CVehicle::SetDamageData(uint32_t data)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetVehicleDamageData(m_ID, data);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_DAMAGEDATA))
|
else if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_DAMAGEDATA))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_DAMAGEDATA);
|
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_DAMAGEDATA);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitVehicleDamageData(m_ID, current, data);
|
Core::Get().EmitVehicleDamageData(m_ID, current, data);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetVehicleDamageData(m_ID, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -1013,16 +1015,16 @@ void CVehicle::SetRadio(int32_t radio)
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetVehicleRadio(m_ID, radio);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_RADIO))
|
else if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_RADIO))
|
||||||
{
|
{
|
||||||
// Prevent this event from triggering while executed
|
// Prevent this event from triggering while executed
|
||||||
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_RADIO);
|
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_RADIO);
|
||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitVehicleRadio(m_ID, current, radio);
|
Core::Get().EmitVehicleRadio(m_ID, current, radio);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetVehicleRadio(m_ID, radio);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -1089,8 +1091,6 @@ void CVehicle::SetHandlingRule(int32_t rule, float data)
|
|||||||
Validate();
|
Validate();
|
||||||
// Grab the current value for this property
|
// Grab the current value for this property
|
||||||
const auto current = static_cast< SQFloat >(_Func->GetInstHandlingRule(m_ID, rule));
|
const auto current = static_cast< SQFloat >(_Func->GetInstHandlingRule(m_ID, rule));
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->SetInstHandlingRule(m_ID, rule, data);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_HANDLINGRULE))
|
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_HANDLINGRULE))
|
||||||
{
|
{
|
||||||
@@ -1099,6 +1099,8 @@ void CVehicle::SetHandlingRule(int32_t rule, float data)
|
|||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitVehicleHandlingRule(m_ID, rule, current, data);
|
Core::Get().EmitVehicleHandlingRule(m_ID, rule, current, data);
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->SetInstHandlingRule(m_ID, rule, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -1108,8 +1110,6 @@ void CVehicle::ResetHandlingRule(int32_t rule)
|
|||||||
Validate();
|
Validate();
|
||||||
// Grab the current value for this property
|
// Grab the current value for this property
|
||||||
const auto current = static_cast< SQFloat >(_Func->GetInstHandlingRule(m_ID, rule));
|
const auto current = static_cast< SQFloat >(_Func->GetInstHandlingRule(m_ID, rule));
|
||||||
// Avoid property unwind from a recursive call
|
|
||||||
_Func->ResetInstHandlingRule(m_ID, rule);
|
|
||||||
// Avoid infinite recursive event loops
|
// Avoid infinite recursive event loops
|
||||||
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_HANDLINGRULE))
|
if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_HANDLINGRULE))
|
||||||
{
|
{
|
||||||
@@ -1118,6 +1118,8 @@ void CVehicle::ResetHandlingRule(int32_t rule)
|
|||||||
// Now forward the event call
|
// Now forward the event call
|
||||||
Core::Get().EmitVehicleHandlingRule(m_ID, rule, current, static_cast< SQFloat >(_Func->GetInstHandlingRule(m_ID, rule)));
|
Core::Get().EmitVehicleHandlingRule(m_ID, rule, current, static_cast< SQFloat >(_Func->GetInstHandlingRule(m_ID, rule)));
|
||||||
}
|
}
|
||||||
|
// Avoid property unwind from a recursive call
|
||||||
|
_Func->ResetInstHandlingRule(m_ID, rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -1148,7 +1150,7 @@ void CVehicle::SetLightsData(int32_t data) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool CVehicle::Embark(CPlayer & player) const
|
bool CVehicle::Embark(CPlayer & player)
|
||||||
{
|
{
|
||||||
// Is the specified player even valid?
|
// Is the specified player even valid?
|
||||||
if (!player.IsActive())
|
if (!player.IsActive())
|
||||||
@@ -1157,6 +1159,19 @@ bool CVehicle::Embark(CPlayer & player) const
|
|||||||
}
|
}
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
|
// If the player embarks in the same vehicle then ignore
|
||||||
|
if (_Func->GetPlayerVehicleId(player.GetID()) == m_ID)
|
||||||
|
{
|
||||||
|
return true; // I guess this is somewhat successful
|
||||||
|
}
|
||||||
|
// Avoid infinite recursive event loops
|
||||||
|
else if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_EMBARK))
|
||||||
|
{
|
||||||
|
// Prevent this event from triggering while executed
|
||||||
|
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_EMBARK);
|
||||||
|
// Now forward the event call
|
||||||
|
Core::Get().EmitPlayerEmbarking(player.GetID(), m_ID, 0);
|
||||||
|
}
|
||||||
// Perform the requested operation
|
// Perform the requested operation
|
||||||
return (_Func->PutPlayerInVehicle(player.GetID(), m_ID, 0,
|
return (_Func->PutPlayerInVehicle(player.GetID(), m_ID, 0,
|
||||||
static_cast< uint8_t >(true), static_cast< uint8_t >(true))
|
static_cast< uint8_t >(true), static_cast< uint8_t >(true))
|
||||||
@@ -1164,7 +1179,7 @@ bool CVehicle::Embark(CPlayer & player) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool CVehicle::EmbarkEx(CPlayer & player, int32_t slot, bool allocate, bool warp) const
|
bool CVehicle::EmbarkEx(CPlayer & player, int32_t slot, bool allocate, bool warp)
|
||||||
{
|
{
|
||||||
// Is the specified player even valid?
|
// Is the specified player even valid?
|
||||||
if (!player.IsActive())
|
if (!player.IsActive())
|
||||||
@@ -1173,6 +1188,19 @@ bool CVehicle::EmbarkEx(CPlayer & player, int32_t slot, bool allocate, bool warp
|
|||||||
}
|
}
|
||||||
// Validate the managed identifier
|
// Validate the managed identifier
|
||||||
Validate();
|
Validate();
|
||||||
|
// If the player embarks in the same vehicle then ignore
|
||||||
|
if (_Func->GetPlayerVehicleId(player.GetID()) == m_ID)
|
||||||
|
{
|
||||||
|
return true; // I guess this is somewhat successful
|
||||||
|
}
|
||||||
|
// Avoid infinite recursive event loops
|
||||||
|
else if (!(m_CircularLocks & VEHICLECL_EMIT_VEHICLE_EMBARK))
|
||||||
|
{
|
||||||
|
// Prevent this event from triggering while executed
|
||||||
|
BitGuardU32 bg(m_CircularLocks, VEHICLECL_EMIT_VEHICLE_EMBARK);
|
||||||
|
// Now forward the event call
|
||||||
|
Core::Get().EmitPlayerEmbarking(player.GetID(), m_ID, 0);
|
||||||
|
}
|
||||||
// Perform the requested operation
|
// Perform the requested operation
|
||||||
return (_Func->PutPlayerInVehicle(player.GetID(), m_ID, slot,
|
return (_Func->PutPlayerInVehicle(player.GetID(), m_ID, slot,
|
||||||
static_cast< uint8_t >(allocate), static_cast< uint8_t >(warp)) != vcmpErrorRequestDenied);
|
static_cast< uint8_t >(allocate), static_cast< uint8_t >(warp)) != vcmpErrorRequestDenied);
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ enum VehicleCircularLocks
|
|||||||
VEHICLECL_EMIT_VEHICLE_TYRESTATUS = (1u << 4u),
|
VEHICLECL_EMIT_VEHICLE_TYRESTATUS = (1u << 4u),
|
||||||
VEHICLECL_EMIT_VEHICLE_DAMAGEDATA = (1u << 5u),
|
VEHICLECL_EMIT_VEHICLE_DAMAGEDATA = (1u << 5u),
|
||||||
VEHICLECL_EMIT_VEHICLE_RADIO = (1u << 6u),
|
VEHICLECL_EMIT_VEHICLE_RADIO = (1u << 6u),
|
||||||
VEHICLECL_EMIT_VEHICLE_HANDLINGRULE = (1u << 7u)
|
VEHICLECL_EMIT_VEHICLE_HANDLINGRULE = (1u << 7u),
|
||||||
|
VEHICLECL_EMIT_VEHICLE_EMBARK = (1u << 8u) // This should probably be shared with CPlayer
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
@@ -615,12 +616,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Embark the specified player entity into the managed vehicle entity.
|
* Embark the specified player entity into the managed vehicle entity.
|
||||||
*/
|
*/
|
||||||
bool Embark(CPlayer & player) const;
|
bool Embark(CPlayer & player);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Embark the specified player entity into the managed vehicle entity.
|
* Embark the specified player entity into the managed vehicle entity.
|
||||||
*/
|
*/
|
||||||
bool EmbarkEx(CPlayer & player, int32_t slot, bool allocate, bool warp) const;
|
bool EmbarkEx(CPlayer & player, int32_t slot, bool allocate, bool warp);
|
||||||
#if SQMOD_SDK_LEAST(2, 1)
|
#if SQMOD_SDK_LEAST(2, 1)
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Set whether the target player will see an objective arrow over a vehicle.
|
* Set whether the target player will see an objective arrow over a vehicle.
|
||||||
|
|||||||
+33
-3
@@ -16,6 +16,7 @@ SQMOD_DECL_TYPENAME(SqCpResponse, _SC("SqCprResponse"))
|
|||||||
SQMOD_DECL_TYPENAME(SqCpParameters, _SC("SqCprParameters"))
|
SQMOD_DECL_TYPENAME(SqCpParameters, _SC("SqCprParameters"))
|
||||||
SQMOD_DECL_TYPENAME(SqCpPayload, _SC("SqCprPayload"))
|
SQMOD_DECL_TYPENAME(SqCpPayload, _SC("SqCprPayload"))
|
||||||
SQMOD_DECL_TYPENAME(SqCpProxies, _SC("SqCprProxies"))
|
SQMOD_DECL_TYPENAME(SqCpProxies, _SC("SqCprProxies"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqCpRedirect, _SC("SqCprRedirect"))
|
||||||
SQMOD_DECL_TYPENAME(SqCpSession, _SC("SqCprSession"))
|
SQMOD_DECL_TYPENAME(SqCpSession, _SC("SqCprSession"))
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
@@ -404,10 +405,20 @@ static const EnumElement g_StatusCodes[] = {
|
|||||||
{_SC("MISC_CODE_OFFSET"), cpr::status::MISC_CODE_OFFSET}
|
{_SC("MISC_CODE_OFFSET"), cpr::status::MISC_CODE_OFFSET}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_PostRedirectFlags[] = {
|
||||||
|
{_SC("Post301"), static_cast< SQInteger >(cpr::PostRedirectFlags::POST_301)},
|
||||||
|
{_SC("Post302"), static_cast< SQInteger >(cpr::PostRedirectFlags::POST_302)},
|
||||||
|
{_SC("Post303"), static_cast< SQInteger >(cpr::PostRedirectFlags::POST_303)},
|
||||||
|
{_SC("Postall"), static_cast< SQInteger >(cpr::PostRedirectFlags::POST_ALL)},
|
||||||
|
{_SC("None"), static_cast< SQInteger >(cpr::PostRedirectFlags::NONE)},
|
||||||
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static const EnumElements g_EnumList[] = {
|
static const EnumElements g_EnumList[] = {
|
||||||
{_SC("SqCprErrorCode"), g_ErrorCodes},
|
{_SC("SqCprErrorCode"), g_ErrorCodes},
|
||||||
{_SC("SqCprStatusCode"), g_StatusCodes}
|
{_SC("SqCprStatusCode"), g_StatusCodes},
|
||||||
|
{_SC("SqCprPostRedirectFlags"), g_PostRedirectFlags}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
@@ -605,6 +616,26 @@ void Register_CURL(HSQUIRRELVM vm)
|
|||||||
.CbFunc(_SC("While"), &CpProxies::While)
|
.CbFunc(_SC("While"), &CpProxies::While)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
cpns.Bind(_SC("Redirect"),
|
||||||
|
Class< CpRedirect >(vm, SqCpRedirect::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
.Ctor< SQInteger >()
|
||||||
|
.Ctor< SQInteger, bool >()
|
||||||
|
.Ctor< SQInteger, bool, SQInteger >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqCpRedirect::Fn)
|
||||||
|
// Properties
|
||||||
|
.Prop(_SC("Maximum"), &CpRedirect::GetMaximum, &CpRedirect::SetMaximum)
|
||||||
|
.Prop(_SC("Follow"), &CpRedirect::GetFollow, &CpRedirect::SetFollow)
|
||||||
|
.Prop(_SC("Flags"), &CpRedirect::GetFlags, &CpRedirect::SetFlags)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("SetMaximum"), &CpRedirect::ApplyMaximum)
|
||||||
|
.Func(_SC("SetFollow"), &CpRedirect::ApplyFollow)
|
||||||
|
.Func(_SC("SetFlags"), &CpRedirect::ApplyFlags)
|
||||||
|
);
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
cpns.Bind(_SC("Session"),
|
cpns.Bind(_SC("Session"),
|
||||||
Class< CpSession, NoCopy< CpSession > >(vm, SqCpSession::Str)
|
Class< CpSession, NoCopy< CpSession > >(vm, SqCpSession::Str)
|
||||||
@@ -631,7 +662,6 @@ void Register_CURL(HSQUIRRELVM vm)
|
|||||||
.Func(_SC("YieldProxies"), &CpSession::YieldProxies)
|
.Func(_SC("YieldProxies"), &CpSession::YieldProxies)
|
||||||
.FmtFunc(_SC("SetNTLM"), &CpSession::SetNTLM_)
|
.FmtFunc(_SC("SetNTLM"), &CpSession::SetNTLM_)
|
||||||
.Func(_SC("SetRedirect"), &CpSession::SetRedirect_)
|
.Func(_SC("SetRedirect"), &CpSession::SetRedirect_)
|
||||||
.Func(_SC("SetMaxRedirects"), &CpSession::SetMaxRedirects_)
|
|
||||||
.Func(_SC("SetCookies"), &CpSession::SetCookies_)
|
.Func(_SC("SetCookies"), &CpSession::SetCookies_)
|
||||||
.FmtFunc(_SC("SetBody"), &CpSession::SetBody_)
|
.FmtFunc(_SC("SetBody"), &CpSession::SetBody_)
|
||||||
.Func(_SC("SetLowSpeed"), &CpSession::SetLowSpeed_)
|
.Func(_SC("SetLowSpeed"), &CpSession::SetLowSpeed_)
|
||||||
|
|||||||
+150
-14
@@ -888,7 +888,7 @@ struct CpResponse : public cpr::Response
|
|||||||
*/
|
*/
|
||||||
void SetStatusCode(SQInteger value)
|
void SetStatusCode(SQInteger value)
|
||||||
{
|
{
|
||||||
cpr::Response::status_code = value;
|
cpr::Response::status_code = static_cast< long >(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -1604,6 +1604,152 @@ struct CpProxies : public cpr::Proxies
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Wrapper for cpr::Redirect that can be bound to the script engine.
|
||||||
|
*/
|
||||||
|
struct CpRedirect : public cpr::Redirect
|
||||||
|
{
|
||||||
|
using cpr::Redirect::Redirect;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
CpRedirect() = default;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit CpRedirect(SQInteger maximum)
|
||||||
|
: cpr::Redirect(static_cast< long >(maximum), true, cpr::PostRedirectFlags::POST_ALL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
CpRedirect(SQInteger maximum, bool follow)
|
||||||
|
: cpr::Redirect(static_cast< long >(maximum), follow, cpr::PostRedirectFlags::POST_ALL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
CpRedirect(SQInteger maximum, bool follow, SQInteger post_flags)
|
||||||
|
: cpr::Redirect(static_cast< long >(maximum), follow, static_cast< cpr::PostRedirectFlags >(post_flags))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
explicit CpRedirect(const cpr::Redirect & e) : cpr::Redirect(e) { }
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit CpRedirect(cpr::Redirect && e) : cpr::Redirect(e) { }
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
CpRedirect(const CpRedirect &) = default;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
CpRedirect(CpRedirect &&) noexcept = default;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~CpRedirect() = default;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator.
|
||||||
|
*/
|
||||||
|
CpRedirect & operator = (const CpRedirect &) = default;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
CpRedirect & operator = (CpRedirect &&) noexcept = default;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the maximum number of redirects to follow. 0: Refuse any redirects. -1: Infinite number of redirects.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetMaximum() const noexcept
|
||||||
|
{
|
||||||
|
return static_cast< SQInteger >(cpr::Redirect::maximum);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the maximum number of redirects to follow. 0: Refuse any redirects. -1: Infinite number of redirects.
|
||||||
|
*/
|
||||||
|
void SetMaximum(SQInteger value) noexcept
|
||||||
|
{
|
||||||
|
cpr::Redirect::maximum = static_cast< long >(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the maximum number of redirects to follow. 0: Refuse any redirects. -1: Infinite number of redirects.
|
||||||
|
*/
|
||||||
|
CpRedirect & ApplyMaximum(SQInteger value) noexcept
|
||||||
|
{
|
||||||
|
SetMaximum(value);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve whether to follow 3xx redirects.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool GetFollow() const noexcept
|
||||||
|
{
|
||||||
|
return cpr::Redirect::follow;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify whether to follow 3xx redirects.
|
||||||
|
*/
|
||||||
|
void SetFollow(bool value) noexcept
|
||||||
|
{
|
||||||
|
cpr::Redirect::follow = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify whether to follow 3xx redirects.
|
||||||
|
*/
|
||||||
|
CpRedirect & ApplyFollow(bool value) noexcept
|
||||||
|
{
|
||||||
|
SetMaximum(value);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the flags to control how to act after a redirect for a post request.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool GetFlags() const noexcept
|
||||||
|
{
|
||||||
|
return cpr::Redirect::follow;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the flags to control how to act after a redirect for a post request.
|
||||||
|
*/
|
||||||
|
void SetFlags(bool value) noexcept
|
||||||
|
{
|
||||||
|
cpr::Redirect::follow = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the flags to control how to act after a redirect for a post request.
|
||||||
|
*/
|
||||||
|
CpRedirect & ApplyFlags(bool value) noexcept
|
||||||
|
{
|
||||||
|
SetMaximum(value);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Wrapper for cpr::Session that can be bound to the script engine.
|
* Wrapper for cpr::Session that can be bound to the script engine.
|
||||||
*/
|
*/
|
||||||
@@ -1620,7 +1766,7 @@ struct CpSession : public cpr::Session
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* URL constructor.
|
* URL constructor.
|
||||||
*/
|
*/
|
||||||
CpSession(StackStrF & url)
|
explicit CpSession(StackStrF & url)
|
||||||
: cpr::Session()
|
: cpr::Session()
|
||||||
{
|
{
|
||||||
cpr::Session::SetUrl(cpr::Url(url.mPtr, url.GetSize()));
|
cpr::Session::SetUrl(cpr::Url(url.mPtr, url.GetSize()));
|
||||||
@@ -1654,7 +1800,7 @@ struct CpSession : public cpr::Session
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Throw exception if the session is locked.
|
* Throw exception if the session is locked.
|
||||||
*/
|
*/
|
||||||
void LockCheck()
|
void LockCheck() const
|
||||||
{
|
{
|
||||||
if (mPending)
|
if (mPending)
|
||||||
{
|
{
|
||||||
@@ -1827,23 +1973,13 @@ struct CpSession : public cpr::Session
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify redirect option.
|
* Modify redirect option.
|
||||||
*/
|
*/
|
||||||
CpSession & SetRedirect_(bool redirect)
|
CpSession & SetRedirect_(CpRedirect & redirect)
|
||||||
{
|
{
|
||||||
LockCheck();
|
LockCheck();
|
||||||
cpr::Session::SetRedirect(redirect);
|
cpr::Session::SetRedirect(redirect);
|
||||||
return *this; // Allow chaining
|
return *this; // Allow chaining
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Modify max-redirects option.
|
|
||||||
*/
|
|
||||||
CpSession & SetMaxRedirects_(SQInteger max_redirects)
|
|
||||||
{
|
|
||||||
LockCheck();
|
|
||||||
cpr::Session::SetMaxRedirects(cpr::MaxRedirects(static_cast< int32_t >(max_redirects)));
|
|
||||||
return *this; // Allow chaining
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify cookies option.
|
* Modify cookies option.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+20
-16
@@ -3,7 +3,6 @@
|
|||||||
#include "Library/Chrono/Date.hpp"
|
#include "Library/Chrono/Date.hpp"
|
||||||
#include "Library/Chrono/Timer.hpp"
|
#include "Library/Chrono/Timer.hpp"
|
||||||
#include "Library/Chrono/Timestamp.hpp"
|
#include "Library/Chrono/Timestamp.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
#include "Core/Utility.hpp"
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -243,33 +242,38 @@ int64_t Chrono::DateRangeToSeconds(uint16_t _year, uint8_t _month, uint8_t _day,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SLongInt SqGetEpochTimeMicro()
|
static SQRESULT SqGetEpochTimeMicro(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
return SLongInt(Chrono::GetEpochTimeMicro());
|
sq_pushinteger(vm, Chrono::GetEpochTimeMicro());
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SLongInt SqGetEpochTimeMilli()
|
static SQRESULT SqGetEpochTimeMilli(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
return SLongInt(Chrono::GetEpochTimeMilli());
|
sq_pushinteger(vm, Chrono::GetEpochTimeMilli());
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SLongInt SqGetCurrentSysTime()
|
static SQRESULT SqGetCurrentSysTime(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
return SLongInt(Chrono::GetCurrentSysTime());
|
sq_pushinteger(vm, Chrono::GetCurrentSysTime());
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SQInteger SqGetTickCount()
|
static SQRESULT SqGetTickCount(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
return ConvTo< SQInteger >::From(GetTickCount());
|
sq_pushinteger(vm, ConvTo< SQInteger >::From(GetTickCount()));
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SLongInt SqGetTickCount64()
|
static SQRESULT SqGetTickCount64(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
return SLongInt(GetTickCount64());
|
sq_pushinteger(vm, ConvTo< SQInteger >::From(GetTickCount64()));
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
@@ -284,11 +288,11 @@ void Register_Chrono(HSQUIRRELVM vm)
|
|||||||
Register_ChronoTimestamp(vm, cns);
|
Register_ChronoTimestamp(vm, cns);
|
||||||
|
|
||||||
cns
|
cns
|
||||||
.Func(_SC("EpochMicro"), &SqGetEpochTimeMicro)
|
.SquirrelFunc(_SC("EpochMicro"), &SqGetEpochTimeMicro)
|
||||||
.Func(_SC("EpochMilli"), &SqGetEpochTimeMilli)
|
.SquirrelFunc(_SC("EpochMilli"), &SqGetEpochTimeMilli)
|
||||||
.Func(_SC("Current"), &SqGetCurrentSysTime)
|
.SquirrelFunc(_SC("Current"), &SqGetCurrentSysTime)
|
||||||
.Func(_SC("TickCount"), &SqGetTickCount)
|
.SquirrelFunc(_SC("TickCount"), &SqGetTickCount)
|
||||||
.Func(_SC("TickCount64"), &SqGetTickCount64)
|
.SquirrelFunc(_SC("TickCount64"), &SqGetTickCount64)
|
||||||
.Func(_SC("IsLeapYear"), &Chrono::IsLeapYear)
|
.Func(_SC("IsLeapYear"), &Chrono::IsLeapYear)
|
||||||
.Func(_SC("IsDateValid"), &Chrono::ValidDate)
|
.Func(_SC("IsDateValid"), &Chrono::ValidDate)
|
||||||
.Func(_SC("DaysInYear"), &Chrono::DaysInYear)
|
.Func(_SC("DaysInYear"), &Chrono::DaysInYear)
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Core/Common.hpp"
|
#include "Core/Common.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,19 @@ SQMOD_DECL_TYPENAME(Typename, _SC("SqDate"))
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQChar Date::Delimiter = '-';
|
SQChar Date::Delimiter = '-';
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Date::Date(int64_t ts)
|
||||||
|
: Date()
|
||||||
|
{
|
||||||
|
const auto y = static_cast< uint16_t >(std::lround(std::floor(ts / 3.17098e-14)));
|
||||||
|
ts -= int64_t{y} * 3.17098e-14;
|
||||||
|
const auto m = static_cast< uint8_t >(std::lround(std::floor(ts / 2.628e+12)));
|
||||||
|
ts -= int64_t{m} * 2.628e+12;
|
||||||
|
const auto d = static_cast< uint8_t >(std::lround(std::floor(ts / 8.64e+10)));
|
||||||
|
// Set the specified date
|
||||||
|
Set(y, m, d);
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t Date::Compare(const Date & o) const
|
int32_t Date::Compare(const Date & o) const
|
||||||
{
|
{
|
||||||
@@ -363,6 +376,12 @@ Timestamp Date::GetTimestamp() const
|
|||||||
return Timestamp(static_cast< int64_t >(days * 86400000000LL));
|
return Timestamp(static_cast< int64_t >(days * 86400000000LL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
std::time_t Date::ToTimeT() const
|
||||||
|
{
|
||||||
|
return GetTimestamp().ToTimeT();
|
||||||
|
}
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_ChronoDate(HSQUIRRELVM vm, Table & /*cns*/)
|
void Register_ChronoDate(HSQUIRRELVM vm, Table & /*cns*/)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -83,6 +83,11 @@ public:
|
|||||||
SetStr(str);
|
SetStr(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Time-stamp constructor.
|
||||||
|
*/
|
||||||
|
explicit Date(int64_t ts);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Copy constructor.
|
* Copy constructor.
|
||||||
*/
|
*/
|
||||||
@@ -349,6 +354,11 @@ public:
|
|||||||
* Convert this date instance to a time-stamp.
|
* Convert this date instance to a time-stamp.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Timestamp GetTimestamp() const;
|
SQMOD_NODISCARD Timestamp GetTimestamp() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
std::time_t ToTimeT() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
|||||||
@@ -16,6 +16,26 @@ SQChar Datetime::Delimiter = ' ';
|
|||||||
SQChar Datetime::DateDelim = '-';
|
SQChar Datetime::DateDelim = '-';
|
||||||
SQChar Datetime::TimeDelim = ':';
|
SQChar Datetime::TimeDelim = ':';
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Datetime::Datetime(int64_t ts)
|
||||||
|
: Datetime()
|
||||||
|
{
|
||||||
|
const auto y = static_cast< uint16_t >(std::lround(std::floor(ts / 3.17098e-14)));
|
||||||
|
ts -= int64_t{y} * 3.17098e-14;
|
||||||
|
const auto mo = static_cast< uint8_t >(std::lround(std::floor(ts / 2.628e+12)));
|
||||||
|
ts -= int64_t{mo} * 2.628e+12;
|
||||||
|
const auto d = static_cast< uint8_t >(std::lround(std::floor(ts / 8.64e+10)));
|
||||||
|
ts -= int64_t{d} * 8.64e+10;
|
||||||
|
const auto h = static_cast< uint8_t >(std::lround(std::floor(ts / 3.6e+9)));
|
||||||
|
ts -= int64_t{h} * 3.6e+9;
|
||||||
|
const auto mi = static_cast< uint8_t >(std::lround(std::floor(ts / 6e+7)));
|
||||||
|
ts -= int64_t{mi} * 6e+7;
|
||||||
|
const auto s = static_cast< uint8_t >(std::lround(std::floor(ts / 1e+6)));
|
||||||
|
ts -= int64_t{s} * 1e+6;
|
||||||
|
// Set the specified date-time
|
||||||
|
Set(y, mo, d, h, mi, s, static_cast< uint16_t >(ts / 1000LL));
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t Datetime::Compare(const Datetime & o) const
|
int32_t Datetime::Compare(const Datetime & o) const
|
||||||
{
|
{
|
||||||
@@ -745,6 +765,12 @@ Timestamp Datetime::GetTimestamp() const
|
|||||||
return Timestamp(ms);
|
return Timestamp(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
std::time_t Datetime::ToTimeT() const
|
||||||
|
{
|
||||||
|
return GetTimestamp().ToTimeT();
|
||||||
|
}
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_ChronoDatetime(HSQUIRRELVM vm, Table & /*cns*/)
|
void Register_ChronoDatetime(HSQUIRRELVM vm, Table & /*cns*/)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -140,6 +140,11 @@ public:
|
|||||||
Set(year, month, day, hour, minute, second, millisecond);
|
Set(year, month, day, hour, minute, second, millisecond);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Time-stamp constructor.
|
||||||
|
*/
|
||||||
|
explicit Datetime(int64_t ts);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Copy constructor.
|
* Copy constructor.
|
||||||
*/
|
*/
|
||||||
@@ -572,6 +577,11 @@ public:
|
|||||||
* Convert this date-time instance to a time-stamp.
|
* Convert this date-time instance to a time-stamp.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Timestamp GetTimestamp() const;
|
SQMOD_NODISCARD Timestamp GetTimestamp() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
std::time_t ToTimeT() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
|||||||
@@ -12,6 +12,20 @@ SQMOD_DECL_TYPENAME(Typename, _SC("SqTime"))
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQChar Time::Delimiter = ':';
|
SQChar Time::Delimiter = ':';
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Time::Time(int64_t ts)
|
||||||
|
: Time()
|
||||||
|
{
|
||||||
|
const auto h = static_cast< uint8_t >(std::lround(std::floor(ts / 3.6e+9)));
|
||||||
|
ts -= int64_t{h} * 3.6e+9;
|
||||||
|
const auto m = static_cast< uint8_t >(std::lround(std::floor(ts / 6e+7)));
|
||||||
|
ts -= int64_t{m} * 6e+7;
|
||||||
|
const auto s = static_cast< uint8_t >(std::lround(std::floor(ts / 1e+6)));
|
||||||
|
ts -= int64_t{s} * 1e+6;
|
||||||
|
// Set the specified time
|
||||||
|
Set(h, m, s, static_cast< uint16_t >(ts / 1000LL));
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t Time::Compare(const Time & o) const
|
int32_t Time::Compare(const Time & o) const
|
||||||
{
|
{
|
||||||
@@ -410,6 +424,12 @@ Timestamp Time::GetTimestamp() const
|
|||||||
return Timestamp(ms);
|
return Timestamp(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
std::time_t Time::ToTimeT() const
|
||||||
|
{
|
||||||
|
return GetTimestamp().ToTimeT();
|
||||||
|
}
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_ChronoTime(HSQUIRRELVM vm, Table & /*cns*/)
|
void Register_ChronoTime(HSQUIRRELVM vm, Table & /*cns*/)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
uint8_t m_Hour{}; // Hour
|
uint8_t m_Hour{0}; // Hour
|
||||||
uint8_t m_Minute{}; // Minute
|
uint8_t m_Minute{0}; // Minute
|
||||||
uint8_t m_Second{}; // Second
|
uint8_t m_Second{0}; // Second
|
||||||
uint16_t m_Millisecond{}; // Millisecond
|
uint16_t m_Millisecond{0}; // Millisecond
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQChar m_Delimiter; // Component delimiter when generating strings.
|
SQChar m_Delimiter; // Component delimiter when generating strings.
|
||||||
@@ -94,6 +94,11 @@ public:
|
|||||||
SetStr(str);
|
SetStr(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Time-stamp constructor.
|
||||||
|
*/
|
||||||
|
explicit Time(int64_t ts);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Copy constructor.
|
* Copy constructor.
|
||||||
*/
|
*/
|
||||||
@@ -354,6 +359,11 @@ public:
|
|||||||
* Convert this time instance to a time-stamp.
|
* Convert this time instance to a time-stamp.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Timestamp GetTimestamp() const;
|
SQMOD_NODISCARD Timestamp GetTimestamp() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
std::time_t ToTimeT() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/Chrono/Timestamp.hpp"
|
#include "Library/Chrono/Timestamp.hpp"
|
||||||
#include "Library/Chrono/Timer.hpp"
|
#include "Library/Chrono/Timer.hpp"
|
||||||
|
#include "Library/Chrono/Time.hpp"
|
||||||
#include "Library/Chrono/Date.hpp"
|
#include "Library/Chrono/Date.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
#include "Library/Chrono/Datetime.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
@@ -10,13 +14,6 @@ namespace SqMod {
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQMOD_DECL_TYPENAME(Typename, _SC("SqTimestamp"))
|
SQMOD_DECL_TYPENAME(Typename, _SC("SqTimestamp"))
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
Timestamp::Timestamp(const SLongInt & t)
|
|
||||||
: m_Timestamp(t.GetNum())
|
|
||||||
{
|
|
||||||
/* ... */
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t Timestamp::Cmp(const Timestamp & o) const
|
int32_t Timestamp::Cmp(const Timestamp & o) const
|
||||||
{
|
{
|
||||||
@@ -47,27 +44,152 @@ void Timestamp::SetNow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SLongInt Timestamp::GetMicroseconds() const
|
SQInteger Timestamp::GetMicroseconds() const
|
||||||
{
|
{
|
||||||
return SLongInt(m_Timestamp);
|
return m_Timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Timestamp::SetMicroseconds(const SLongInt & amount)
|
void Timestamp::SetMicroseconds(SQInteger amount)
|
||||||
{
|
{
|
||||||
m_Timestamp = amount.GetNum();
|
m_Timestamp = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SLongInt Timestamp::GetMilliseconds() const
|
Timestamp & Timestamp::AddMicroseconds(SQInteger amount) { m_Timestamp += amount; return *this; }
|
||||||
|
Timestamp & Timestamp::SubMicroseconds(SQInteger amount) { m_Timestamp -= amount; return *this; }
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQInteger Timestamp::GetMilliseconds() const
|
||||||
{
|
{
|
||||||
return SLongInt(m_Timestamp / 1000L);
|
return m_Timestamp / 1000L;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Timestamp::SetMilliseconds(const SLongInt & amount)
|
void Timestamp::SetMilliseconds(SQInteger amount)
|
||||||
{
|
{
|
||||||
m_Timestamp = (amount.GetNum() * 1000L);
|
m_Timestamp = (amount * 1000L);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Timestamp & Timestamp::AddMilliseconds(SQInteger amount) { m_Timestamp += (amount * 1000L); return *this; }
|
||||||
|
Timestamp & Timestamp::SubMilliseconds(SQInteger amount) { m_Timestamp -= (amount * 1000L); return *this; }
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Time Timestamp::GetTime() const
|
||||||
|
{
|
||||||
|
return Time(m_Timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Timestamp::SetTime(const Time & t)
|
||||||
|
{
|
||||||
|
SetHoursI(t.GetHour());
|
||||||
|
AddMinutesI(t.GetMinute());
|
||||||
|
AddSecondsI(t.GetSecond());
|
||||||
|
AddMillisecondsRaw(t.GetMillisecond());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Timestamp & Timestamp::AddTime(const Time & t)
|
||||||
|
{
|
||||||
|
AddHoursI(t.GetHour());
|
||||||
|
AddMinutesI(t.GetMinute());
|
||||||
|
AddSecondsI(t.GetSecond());
|
||||||
|
AddMillisecondsRaw(t.GetMillisecond());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Timestamp & Timestamp::SubTime(const Time & t)
|
||||||
|
{
|
||||||
|
SubMillisecondsRaw(t.GetMillisecond());
|
||||||
|
SubSecondsI(t.GetSecond());
|
||||||
|
SubMinutesI(t.GetMinute());
|
||||||
|
SubHoursI(t.GetHour());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Date Timestamp::GetDate() const
|
||||||
|
{
|
||||||
|
return Date(m_Timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Timestamp::SetDate(const Date & d)
|
||||||
|
{
|
||||||
|
SetYearsI(d.GetYear());
|
||||||
|
AddDaysF(d.GetMonth() * 30.4167);
|
||||||
|
AddDaysI(d.GetDay());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Timestamp & Timestamp::AddDate(const Date & d)
|
||||||
|
{
|
||||||
|
AddYearsI(d.GetYear());
|
||||||
|
AddDaysF(d.GetMonth() * 30.4167);
|
||||||
|
AddDaysI(d.GetDay());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Timestamp & Timestamp::SubDate(const Date & d)
|
||||||
|
{
|
||||||
|
SubDaysI(d.GetDay());
|
||||||
|
SubDaysF(d.GetMonth() * 30.4167);
|
||||||
|
SubYearsI(d.GetYear());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Datetime Timestamp::GetDatetime() const
|
||||||
|
{
|
||||||
|
return Datetime(m_Timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Timestamp::SetDatetime(const Datetime & dt)
|
||||||
|
{
|
||||||
|
SetYearsI(dt.GetYear());
|
||||||
|
AddDaysF(dt.GetMonth() * 30.4167);
|
||||||
|
AddDaysI(dt.GetDay());
|
||||||
|
AddHoursI(dt.GetHour());
|
||||||
|
AddMinutesI(dt.GetMinute());
|
||||||
|
AddSecondsI(dt.GetSecond());
|
||||||
|
AddMillisecondsRaw(dt.GetMillisecond());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Timestamp & Timestamp::AddDatetime(const Datetime & dt)
|
||||||
|
{
|
||||||
|
AddYearsI(dt.GetYear());
|
||||||
|
AddDaysF(dt.GetMonth() * 30.4167);
|
||||||
|
AddDaysI(dt.GetDay());
|
||||||
|
AddHoursI(dt.GetHour());
|
||||||
|
AddMinutesI(dt.GetMinute());
|
||||||
|
AddSecondsI(dt.GetSecond());
|
||||||
|
AddMillisecondsRaw(dt.GetMillisecond());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Timestamp & Timestamp::SubDatetime(const Datetime & dt)
|
||||||
|
{
|
||||||
|
SubMillisecondsRaw(dt.GetMillisecond());
|
||||||
|
SubSecondsI(dt.GetSecond());
|
||||||
|
SubMinutesI(dt.GetMinute());
|
||||||
|
SubHoursI(dt.GetHour());
|
||||||
|
SubDaysI(dt.GetDay());
|
||||||
|
SubDaysF(dt.GetMonth() * 30.4167);
|
||||||
|
SubYearsI(dt.GetYear());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
std::time_t Timestamp::ToTimeT() const
|
||||||
|
{
|
||||||
|
return std::chrono::system_clock::to_time_t(std::chrono::time_point< std::chrono::system_clock >{std::chrono::microseconds{m_Timestamp}});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -83,7 +205,7 @@ static Timestamp SqGetMicrosecondsRaw(int64_t amount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static Timestamp SqGetMicroseconds(const SLongInt & amount)
|
static Timestamp SqGetMicroseconds(SQInteger amount)
|
||||||
{
|
{
|
||||||
return Timestamp(amount);
|
return Timestamp(amount);
|
||||||
}
|
}
|
||||||
@@ -156,8 +278,46 @@ void Register_ChronoTimestamp(HSQUIRRELVM vm, Table & /*cns*/)
|
|||||||
.Prop(_SC("DaysI"), &Timestamp::GetDaysI, &Timestamp::SetDaysI)
|
.Prop(_SC("DaysI"), &Timestamp::GetDaysI, &Timestamp::SetDaysI)
|
||||||
.Prop(_SC("YearsF"), &Timestamp::GetYearsF, &Timestamp::SetYearsF)
|
.Prop(_SC("YearsF"), &Timestamp::GetYearsF, &Timestamp::SetYearsF)
|
||||||
.Prop(_SC("YearsI"), &Timestamp::GetYearsI, &Timestamp::SetYearsI)
|
.Prop(_SC("YearsI"), &Timestamp::GetYearsI, &Timestamp::SetYearsI)
|
||||||
|
.Prop(_SC("Time"), &Timestamp::GetTime, &Timestamp::SetTime)
|
||||||
|
.Prop(_SC("Date"), &Timestamp::GetDate, &Timestamp::SetDate)
|
||||||
|
.Prop(_SC("Datetime"), &Timestamp::GetDatetime, &Timestamp::SetDatetime)
|
||||||
// Member Methods
|
// Member Methods
|
||||||
.Func(_SC("SetNow"), &Timestamp::SetNow)
|
.Func(_SC("SetNow"), &Timestamp::SetNow)
|
||||||
|
// Properties
|
||||||
|
.Func(_SC("AddMicroseconds"), &Timestamp::AddMicroseconds)
|
||||||
|
.Func(_SC("SubMicroseconds"), &Timestamp::SubMicroseconds)
|
||||||
|
.Func(_SC("AddMicrosecondsRaw"), &Timestamp::AddMicrosecondsRaw)
|
||||||
|
.Func(_SC("SubMicrosecondsRaw"), &Timestamp::SubMicrosecondsRaw)
|
||||||
|
.Func(_SC("AddMilliseconds"), &Timestamp::AddMilliseconds)
|
||||||
|
.Func(_SC("SubMilliseconds"), &Timestamp::SubMilliseconds)
|
||||||
|
.Func(_SC("AddMillisecondsRaw"), &Timestamp::AddMillisecondsRaw)
|
||||||
|
.Func(_SC("SubMillisecondsRaw"), &Timestamp::SubMillisecondsRaw)
|
||||||
|
.Func(_SC("AddSecondsF"), &Timestamp::AddSecondsF)
|
||||||
|
.Func(_SC("SubSecondsF"), &Timestamp::SubSecondsF)
|
||||||
|
.Func(_SC("AddSecondsI"), &Timestamp::AddSecondsI)
|
||||||
|
.Func(_SC("SubSecondsI"), &Timestamp::SubSecondsI)
|
||||||
|
.Func(_SC("AddMinutesF"), &Timestamp::AddMinutesF)
|
||||||
|
.Func(_SC("SubMinutesF"), &Timestamp::SubMinutesF)
|
||||||
|
.Func(_SC("AddMinutesI"), &Timestamp::AddMinutesI)
|
||||||
|
.Func(_SC("SubMinutesI"), &Timestamp::SubMinutesI)
|
||||||
|
.Func(_SC("AddHoursF"), &Timestamp::AddHoursF)
|
||||||
|
.Func(_SC("SubHoursF"), &Timestamp::SubHoursF)
|
||||||
|
.Func(_SC("AddHoursI"), &Timestamp::AddHoursI)
|
||||||
|
.Func(_SC("SubHoursI"), &Timestamp::SubHoursI)
|
||||||
|
.Func(_SC("AddDaysF"), &Timestamp::AddDaysF)
|
||||||
|
.Func(_SC("SubDaysF"), &Timestamp::SubDaysF)
|
||||||
|
.Func(_SC("AddDaysI"), &Timestamp::AddDaysI)
|
||||||
|
.Func(_SC("SubDaysI"), &Timestamp::SubDaysI)
|
||||||
|
.Func(_SC("AddYearsF"), &Timestamp::AddYearsF)
|
||||||
|
.Func(_SC("SubYearsF"), &Timestamp::SubYearsF)
|
||||||
|
.Func(_SC("AddYearsI"), &Timestamp::AddYearsI)
|
||||||
|
.Func(_SC("SubYearsI"), &Timestamp::SubYearsI)
|
||||||
|
.Func(_SC("AddTime"), &Timestamp::AddTime)
|
||||||
|
.Func(_SC("SubTime"), &Timestamp::SubTime)
|
||||||
|
.Func(_SC("AddDate"), &Timestamp::AddDate)
|
||||||
|
.Func(_SC("SubDate"), &Timestamp::SubDate)
|
||||||
|
.Func(_SC("AddDatetime"), &Timestamp::AddDatetime)
|
||||||
|
.Func(_SC("SubDatetime"), &Timestamp::SubDatetime)
|
||||||
// Static Functions
|
// Static Functions
|
||||||
.StaticFunc(_SC("GetNow"), &SqGetEpochTimeNow)
|
.StaticFunc(_SC("GetNow"), &SqGetEpochTimeNow)
|
||||||
.StaticFunc(_SC("GetMicrosRaw"), &SqGetMicrosecondsRaw)
|
.StaticFunc(_SC("GetMicrosRaw"), &SqGetMicrosecondsRaw)
|
||||||
|
|||||||
@@ -7,7 +7,10 @@
|
|||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
class Date;
|
||||||
|
class Time;
|
||||||
class Timer;
|
class Timer;
|
||||||
|
class Datetime;
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
@@ -37,11 +40,6 @@ public:
|
|||||||
/* ... */
|
/* ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
explicit Timestamp(const SLongInt & t);
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -119,12 +117,18 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SLongInt GetMicroseconds() const;
|
SQMOD_NODISCARD SQInteger GetMicroseconds() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void SetMicroseconds(const SLongInt & amount);
|
void SetMicroseconds(SQInteger amount);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddMicroseconds(SQInteger amount);
|
||||||
|
Timestamp & SubMicroseconds(SQInteger amount);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
@@ -145,12 +149,24 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SLongInt GetMilliseconds() const;
|
Timestamp & AddMicrosecondsRaw(SQInteger amount) { m_Timestamp += amount; return *this; }
|
||||||
|
Timestamp & SubMicrosecondsRaw(SQInteger amount) { m_Timestamp -= amount; return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void SetMilliseconds(const SLongInt & amount);
|
SQMOD_NODISCARD SQInteger GetMilliseconds() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void SetMilliseconds(SQInteger amount);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddMilliseconds(SQInteger amount);
|
||||||
|
Timestamp & SubMilliseconds(SQInteger amount);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
@@ -168,6 +184,12 @@ public:
|
|||||||
m_Timestamp = int64_t(int64_t(amount) * 1000L);
|
m_Timestamp = int64_t(int64_t(amount) * 1000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddMillisecondsRaw(SQInteger amount) { m_Timestamp += int64_t(int64_t(amount) * 1000L); return *this; }
|
||||||
|
Timestamp & SubMillisecondsRaw(SQInteger amount) { m_Timestamp -= int64_t(int64_t(amount) * 1000L); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -184,6 +206,12 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 1000000L);
|
m_Timestamp = int64_t(double(amount) * 1000000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddSecondsF(SQFloat amount) { m_Timestamp += int64_t(double(amount) * 1000000L); return *this; }
|
||||||
|
Timestamp & SubSecondsF(SQFloat amount) { m_Timestamp -= int64_t(double(amount) * 1000000L); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -200,12 +228,18 @@ public:
|
|||||||
m_Timestamp = int64_t(int64_t(amount) * 1000000L);
|
m_Timestamp = int64_t(int64_t(amount) * 1000000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddSecondsI(SQInteger amount) { m_Timestamp += int64_t(int64_t(amount) * 1000000L); return *this; }
|
||||||
|
Timestamp & SubSecondsI(SQInteger amount) { m_Timestamp -= int64_t(int64_t(amount) * 1000000L); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SQFloat GetMinutesF() const
|
SQMOD_NODISCARD SQFloat GetMinutesF() const
|
||||||
{
|
{
|
||||||
return SQFloat(m_Timestamp / 60000000.0);
|
return SQFloat(m_Timestamp) / 60000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -216,6 +250,12 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 60000000L);
|
m_Timestamp = int64_t(double(amount) * 60000000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddMinutesF(SQFloat amount) { m_Timestamp += int64_t(double(amount) * 60000000L); return *this; }
|
||||||
|
Timestamp & SubMinutesF(SQFloat amount) { m_Timestamp -= int64_t(double(amount) * 60000000L); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -232,12 +272,18 @@ public:
|
|||||||
m_Timestamp = int64_t(int64_t(amount) * 60000000L);
|
m_Timestamp = int64_t(int64_t(amount) * 60000000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddMinutesI(SQInteger amount) { m_Timestamp += int64_t(int64_t(amount) * 60000000L); return *this; }
|
||||||
|
Timestamp & SubMinutesI(SQInteger amount) { m_Timestamp -= int64_t(int64_t(amount) * 60000000L); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SQFloat GetHoursF() const
|
SQMOD_NODISCARD SQFloat GetHoursF() const
|
||||||
{
|
{
|
||||||
return SQFloat(m_Timestamp / 3600000000.0);
|
return SQFloat(m_Timestamp) / 3600000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -248,6 +294,12 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 3600000000LL);
|
m_Timestamp = int64_t(double(amount) * 3600000000LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddHoursF(SQFloat amount) { m_Timestamp += int64_t(double(amount) * 3600000000LL); return *this; }
|
||||||
|
Timestamp & SubHoursF(SQFloat amount) { m_Timestamp -= int64_t(double(amount) * 3600000000LL); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -264,12 +316,18 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 3600000000LL);
|
m_Timestamp = int64_t(double(amount) * 3600000000LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddHoursI(SQInteger amount) { m_Timestamp += int64_t(double(amount) * 3600000000LL); return *this; }
|
||||||
|
Timestamp & SubHoursI(SQInteger amount) { m_Timestamp -= int64_t(double(amount) * 3600000000LL); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SQFloat GetDaysF() const
|
SQMOD_NODISCARD SQFloat GetDaysF() const
|
||||||
{
|
{
|
||||||
return SQFloat(m_Timestamp / 86400000000.0);
|
return SQFloat(m_Timestamp) / 86400000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -280,6 +338,12 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 86400000000LL);
|
m_Timestamp = int64_t(double(amount) * 86400000000LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddDaysF(SQFloat amount) { m_Timestamp += int64_t(double(amount) * 86400000000LL); return *this; }
|
||||||
|
Timestamp & SubDaysF(SQFloat amount) { m_Timestamp -= int64_t(double(amount) * 86400000000LL); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -296,12 +360,18 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 86400000000LL);
|
m_Timestamp = int64_t(double(amount) * 86400000000LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddDaysI(SQInteger amount) { m_Timestamp += int64_t(double(amount) * 86400000000LL); return *this; }
|
||||||
|
Timestamp & SubDaysI(SQInteger amount) { m_Timestamp -= int64_t(double(amount) * 86400000000LL); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SQFloat GetYearsF() const
|
SQMOD_NODISCARD SQFloat GetYearsF() const
|
||||||
{
|
{
|
||||||
return SQFloat(m_Timestamp / 31557600000000.0);
|
return SQFloat(m_Timestamp) / 31557600000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -312,6 +382,12 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 31557600000000LL);
|
m_Timestamp = int64_t(double(amount) * 31557600000000LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddYearsF(SQFloat amount) { m_Timestamp += int64_t(double(amount) * 31557600000000LL); return *this; }
|
||||||
|
Timestamp & SubYearsF(SQFloat amount) { m_Timestamp -= int64_t(double(amount) * 31557600000000LL); return *this; }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -328,6 +404,65 @@ public:
|
|||||||
m_Timestamp = int64_t(double(amount) * 31557600000000LL);
|
m_Timestamp = int64_t(double(amount) * 31557600000000LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddYearsI(SQInteger amount) { m_Timestamp += int64_t(double(amount) * 31557600000000LL); return *this; }
|
||||||
|
Timestamp & SubYearsI(SQInteger amount) { m_Timestamp -= int64_t(double(amount) * 31557600000000LL); return *this; }
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Time GetTime() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void SetTime(const Time & t);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddTime(const Time & t);
|
||||||
|
Timestamp & SubTime(const Time & t);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Date GetDate() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void SetDate(const Date & d);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddDate(const Date & d);
|
||||||
|
Timestamp & SubDate(const Date & d);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Datetime GetDatetime() const;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void SetDatetime(const Datetime & dt);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timestamp & AddDatetime(const Datetime & dt);
|
||||||
|
Timestamp & SubDatetime(const Datetime & dt);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::time_t ToTimeT() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP.hpp"
|
||||||
|
#include "Library/DPP/Cluster.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <sqratConst.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void TerminateDPP()
|
||||||
|
{
|
||||||
|
// Go over all clusters and try to terminate them
|
||||||
|
for (DpCluster * inst = DpCluster::sHead; inst && inst->mNext != DpCluster::sHead; inst = inst->mNext)
|
||||||
|
{
|
||||||
|
inst->Terminate(); // Terminate() the cluster
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ProcessDPP()
|
||||||
|
{
|
||||||
|
// Go over all clusters and allow them to process data
|
||||||
|
for (DpCluster * inst = DpCluster::sHead; inst && inst->mNext != DpCluster::sHead; inst = inst->mNext)
|
||||||
|
{
|
||||||
|
inst->Process();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
extern void Register_DPP_Channel(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Client(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Cluster(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Command(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Constants(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Events(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Guild(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Integration(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Message(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Other(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_Role(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_DPP_User(HSQUIRRELVM vm, Table & ns);
|
||||||
|
|
||||||
|
// ================================================================================================
|
||||||
|
void Register_DPP(HSQUIRRELVM vm)
|
||||||
|
{
|
||||||
|
Table ns(vm);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
Register_DPP_Constants(vm, ns);
|
||||||
|
Register_DPP_Client(vm, ns);
|
||||||
|
Register_DPP_Integration(vm, ns);
|
||||||
|
Register_DPP_Command(vm, ns);
|
||||||
|
Register_DPP_Message(vm, ns);
|
||||||
|
Register_DPP_Channel(vm, ns);
|
||||||
|
Register_DPP_Other(vm, ns);
|
||||||
|
Register_DPP_Role(vm, ns);
|
||||||
|
Register_DPP_User(vm, ns);
|
||||||
|
Register_DPP_Guild(vm, ns);
|
||||||
|
{
|
||||||
|
Table ens(vm);
|
||||||
|
Register_DPP_Events(vm, ens);
|
||||||
|
ns.Bind(_SC("Events"), ens);
|
||||||
|
}
|
||||||
|
Register_DPP_Cluster(vm, ns);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Func(_SC("HasVoice"), dpp::utility::has_voice);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
RootTable(vm).Bind(_SC("SqDiscord"), ns);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Core/Common.hpp"
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "PocoLib/XML.hpp"
|
#include "Library/DPP/Channel.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
@@ -7,12 +7,10 @@ namespace SqMod {
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
// ================================================================================================
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Register_POCO_XML(HSQUIRRELVM vm, Table &)
|
void Register_DPP_Channel(HSQUIRRELVM vm, Table & ns)
|
||||||
{
|
{
|
||||||
//Table ns(vm);
|
|
||||||
|
|
||||||
//RootTable(vm).Bind(_SC("SqXML"), ns);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "PocoLib/JSON.hpp"
|
#include "Library/DPP/Client.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
@@ -7,12 +7,10 @@ namespace SqMod {
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
// ================================================================================================
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Register_POCO_JSON(HSQUIRRELVM vm, Table &)
|
void Register_DPP_Client(HSQUIRRELVM vm, Table & ns)
|
||||||
{
|
{
|
||||||
//Table ns(vm);
|
|
||||||
|
|
||||||
//RootTable(vm).Bind(_SC("SqJSON"), ns);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,757 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Cluster.hpp"
|
||||||
|
#include "Library/DPP/Events.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppCluster, _SC("SqDppCluster"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Cluster(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Cluster"),
|
||||||
|
Class< DpCluster, NoCopy< DpCluster > >(vm, SqDppCluster::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor< StackStrF & >()
|
||||||
|
.Ctor< StackStrF &, SQInteger >()
|
||||||
|
.Ctor< StackStrF &, SQInteger, SQInteger >()
|
||||||
|
.Ctor< StackStrF &, SQInteger, SQInteger, SQInteger >()
|
||||||
|
.Ctor< StackStrF &, SQInteger, SQInteger, SQInteger, SQInteger >()
|
||||||
|
.Ctor< StackStrF &, SQInteger, SQInteger, SQInteger, SQInteger, bool >()
|
||||||
|
.Ctor< StackStrF &, SQInteger, SQInteger, SQInteger, SQInteger, bool, const DpCachePolicy & >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppCluster::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("On"), &DpCluster::GetEvents)
|
||||||
|
.Prop(_SC("UpTime"), &DpCluster::UpTime)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("Start"), &DpCluster::Start)
|
||||||
|
.Func(_SC("Log"), &DpCluster::Log)
|
||||||
|
.Func(_SC("GetDmChannel"), &DpCluster::GetDmChannel)
|
||||||
|
.Func(_SC("SetDmChannel"), &DpCluster::SetDmChannel)
|
||||||
|
.Func(_SC("SetPresence"), &DpCluster::SetPresence)
|
||||||
|
.Func(_SC("EnableEvent"), &DpCluster::EnableEvent)
|
||||||
|
.Func(_SC("DisableEvent"), &DpCluster::DisableEvent)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD LightObj EventToScriptObject(uint8_t type, uintptr_t data);
|
||||||
|
void EventInvokeCleanup(uint8_t type, uintptr_t data);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::Process(bool force)
|
||||||
|
{
|
||||||
|
// Is there a valid connection?
|
||||||
|
if (!mC && !force)
|
||||||
|
{
|
||||||
|
return; // No point in going forward
|
||||||
|
}
|
||||||
|
DpInternalEvent event;
|
||||||
|
// Retrieve each event individually and process it
|
||||||
|
for (size_t count = mQueue.size_approx(), n = 0; n <= count; ++n)
|
||||||
|
{
|
||||||
|
// Try to get an event from the queue
|
||||||
|
if (mQueue.try_dequeue(event))
|
||||||
|
{
|
||||||
|
// Fetch the type of event
|
||||||
|
const auto type = event.GetType();
|
||||||
|
// Fetch the event itself
|
||||||
|
const auto data = event.GetData();
|
||||||
|
// Is this a valid event and is anyone listening to it?
|
||||||
|
if (event.mData == 0 || mEvents[type].first == nullptr || mEvents[type].first->IsEmpty())
|
||||||
|
{
|
||||||
|
continue; // Move on
|
||||||
|
}
|
||||||
|
// Transform the event instance into a script object
|
||||||
|
LightObj obj = EventToScriptObject(type, data);
|
||||||
|
// Allow the script to take ownership of the event instance now
|
||||||
|
event.Reset();
|
||||||
|
// Forward the call to the associated signal
|
||||||
|
(*mEvents[type].first)(obj);
|
||||||
|
// Allow the event instance to clean itself
|
||||||
|
EventInvokeCleanup(type, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================================================================
|
||||||
|
* Event handlers.
|
||||||
|
*/
|
||||||
|
void DpCluster::OnVoiceStateUpdate(const dpp::voice_state_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceStateUpdate, new DpVoiceStateUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnLog(const dpp::log_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::Log, new DpLogEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildJoinRequestDelete(const dpp::guild_join_request_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildJoinRequestDelete, new DpGuildJoinRequestDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnInteractionCreate(const dpp::interaction_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::InteractionCreate, new DpInteractionCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnButtonClick(const dpp::button_click_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ButtonClick, new DpButtonClickEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnSelectClick(const dpp::select_click_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::SelectClick, new DpSelectClickEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildDelete(const dpp::guild_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildDelete, new DpGuildDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnChannelDelete(const dpp::channel_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ChannelDelete, new DpChannelDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnChannelUpdate(const dpp::channel_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ChannelUpdate, new DpChannelUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnReady(const dpp::ready_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::Ready, new DpReadyEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageDelete(const dpp::message_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageDelete, new DpMessageDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnApplicationCommandDelete(const dpp::application_command_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ApplicationCommandDelete, new DpApplicationCommandDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildMemberRemove(const dpp::guild_member_remove_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildMemberRemove, new DpGuildMemberRemoveEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnApplicationCommandCreate(const dpp::application_command_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ApplicationCommandCreate, new DpApplicationCommandCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnResumed(const dpp::resumed_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::Resumed, new DpResumedEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildRoleCreate(const dpp::guild_role_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildRoleCreate, new DpGuildRoleCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnTypingStart(const dpp::typing_start_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::TypingStart, new DpTypingStartEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageReactionAdd(const dpp::message_reaction_add_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageReactionAdd, new DpMessageReactionAddEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildMembersChunk(const dpp::guild_members_chunk_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildMembersChunk, new DpGuildMembersChunkEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageReactionRemove(const dpp::message_reaction_remove_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageReactionRemove, new DpMessageReactionRemoveEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildCreate(const dpp::guild_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildCreate, new DpGuildCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnChannelCreate(const dpp::channel_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ChannelCreate, new DpChannelCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageReactionRemoveEmoji(const dpp::message_reaction_remove_emoji_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageReactionRemoveEmoji, new DpMessageReactionRemoveEmojiEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageDeleteBulk(const dpp::message_delete_bulk_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageDeleteBulk, new DpMessageDeleteBulkEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildRoleUpdate(const dpp::guild_role_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildRoleUpdate, new DpGuildRoleUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildRoleDelete(const dpp::guild_role_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildRoleDelete, new DpGuildRoleDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnChannelPinsUpdate(const dpp::channel_pins_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ChannelPinsUpdate, new DpChannelPinsUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageReactionRemoveAll(const dpp::message_reaction_remove_all_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageReactionRemoveAll, new DpMessageReactionRemoveAllEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnVoiceServerUpdate(const dpp::voice_server_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceServerUpdate, new DpVoiceServerUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildEmojisUpdate(const dpp::guild_emojis_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildEmojisUpdate, new DpGuildEmojisUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildStickersUpdate(const dpp::guild_stickers_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildStickersUpdate, new DpGuildStickersUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnPresenceUpdate(const dpp::presence_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::PresenceUpdate, new DpPresenceUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnWebhooksUpdate(const dpp::webhooks_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::WebhooksUpdate, new DpWebhooksUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildMemberAdd(const dpp::guild_member_add_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildMemberAdd, new DpGuildMemberAddEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnInviteDelete(const dpp::invite_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::InviteDelete, new DpInviteDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildUpdate(const dpp::guild_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildUpdate, new DpGuildUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildIntegrationsUpdate(const dpp::guild_integrations_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildIntegrationsUpdate, new DpGuildIntegrationsUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildMemberUpdate(const dpp::guild_member_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildMemberUpdate, new DpGuildMemberUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnApplicationCommandUpdate(const dpp::application_command_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ApplicationCommandUpdate, new DpApplicationCommandUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnInviteCreate(const dpp::invite_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::InviteCreate, new DpInviteCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageUpdate(const dpp::message_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageUpdate, new DpMessageUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnUserUpdate(const dpp::user_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::UserUpdate, new DpUserUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnMessageCreate(const dpp::message_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::MessageCreate, new DpMessageCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildBanAdd(const dpp::guild_ban_add_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildBanAdd, new DpGuildBanAddEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnGuildBanRemove(const dpp::guild_ban_remove_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::GuildBanRemove, new DpGuildBanRemoveEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnIntegrationCreate(const dpp::integration_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::IntegrationCreate, new DpIntegrationCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnIntegrationUpdate(const dpp::integration_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::IntegrationUpdate, new DpIntegrationUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnIntegrationDelete(const dpp::integration_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::IntegrationDelete, new DpIntegrationDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnThreadCreate(const dpp::thread_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadCreate, new DpThreadCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnThreadUpdate(const dpp::thread_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadUpdate, new DpThreadUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnThreadDelete(const dpp::thread_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadDelete, new DpThreadDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnThreadListSync(const dpp::thread_list_sync_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadListSync, new DpThreadListSyncEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnThreadMemberUpdate(const dpp::thread_member_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadMemberUpdate, new DpThreadMemberUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnThreadMembersUpdate(const dpp::thread_members_update_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::ThreadMembersUpdate, new DpThreadMembersUpdateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnVoiceBufferSend(const dpp::voice_buffer_send_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceBufferSend, new DpVoiceBufferSendEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnVoiceUserTalking(const dpp::voice_user_talking_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceUserTalking, new DpVoiceUserTalkingEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnVoiceReady(const dpp::voice_ready_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceReady, new DpVoiceReadyEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnVoiceReceive(const dpp::voice_receive_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceReceive, new DpVoiceReceiveEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnVoiceTrackMarker(const dpp::voice_track_marker_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::VoiceTrackMarker, new DpVoiceTrackMarkerEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnStageInstanceCreate(const dpp::stage_instance_create_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::StageInstanceCreate, new DpStageInstanceCreateEvent(ev)));
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnStageInstanceDelete(const dpp::stage_instance_delete_t & ev)
|
||||||
|
{
|
||||||
|
mQueue.enqueue(DpInternalEvent(DpEventID::StageInstanceDelete, new DpStageInstanceDeleteEvent(ev)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
DpCluster & DpCluster::EnableEvent(SQInteger id)
|
||||||
|
{
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case DpEventID::VoiceStateUpdate: mC->on_voice_state_update([this](auto && e) { OnVoiceStateUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::Log: mC->on_log([this](auto && e) { OnLog(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildJoinRequestDelete: mC->on_guild_join_request_delete([this](auto && e) { OnGuildJoinRequestDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::InteractionCreate: mC->on_interaction_create([this](auto && e) { OnInteractionCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ButtonClick: mC->on_button_click([this](auto && e) { OnButtonClick(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::SelectClick: mC->on_select_click([this](auto && e) { OnSelectClick(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildDelete: mC->on_guild_delete([this](auto && e) { OnGuildDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ChannelDelete: mC->on_channel_delete([this](auto && e) { OnChannelDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ChannelUpdate: mC->on_channel_update([this](auto && e) { OnChannelUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::Ready: mC->on_ready([this](auto && e) { OnReady(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageDelete: mC->on_message_delete([this](auto && e) { OnMessageDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ApplicationCommandDelete: mC->on_application_command_delete([this](auto && e) { OnApplicationCommandDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildMemberRemove: mC->on_guild_member_remove([this](auto && e) { OnGuildMemberRemove(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ApplicationCommandCreate: mC->on_application_command_create([this](auto && e) { OnApplicationCommandCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::Resumed: mC->on_resumed([this](auto && e) { OnResumed(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildRoleCreate: mC->on_guild_role_create([this](auto && e) { OnGuildRoleCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::TypingStart: mC->on_typing_start([this](auto && e) { OnTypingStart(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageReactionAdd: mC->on_message_reaction_add([this](auto && e) { OnMessageReactionAdd(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildMembersChunk: mC->on_guild_members_chunk([this](auto && e) { OnGuildMembersChunk(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageReactionRemove: mC->on_message_reaction_remove([this](auto && e) { OnMessageReactionRemove(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildCreate: mC->on_guild_create([this](auto && e) { OnGuildCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ChannelCreate: mC->on_channel_create([this](auto && e) { OnChannelCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageReactionRemoveEmoji: mC->on_message_reaction_remove_emoji([this](auto && e) { OnMessageReactionRemoveEmoji(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageDeleteBulk: mC->on_message_delete_bulk([this](auto && e) { OnMessageDeleteBulk(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildRoleUpdate: mC->on_guild_role_update([this](auto && e) { OnGuildRoleUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildRoleDelete: mC->on_guild_role_delete([this](auto && e) { OnGuildRoleDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ChannelPinsUpdate: mC->on_channel_pins_update([this](auto && e) { OnChannelPinsUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageReactionRemoveAll: mC->on_message_reaction_remove_all([this](auto && e) { OnMessageReactionRemoveAll(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::VoiceServerUpdate: mC->on_voice_server_update([this](auto && e) { OnVoiceServerUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildEmojisUpdate: mC->on_guild_emojis_update([this](auto && e) { OnGuildEmojisUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildStickersUpdate: mC->on_guild_stickers_update([this](auto && e) { OnGuildStickersUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::PresenceUpdate: mC->on_presence_update([this](auto && e) { OnPresenceUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::WebhooksUpdate: mC->on_webhooks_update([this](auto && e) { OnWebhooksUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildMemberAdd: mC->on_guild_member_add([this](auto && e) { OnGuildMemberAdd(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::InviteDelete: mC->on_invite_delete([this](auto && e) { OnInviteDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildUpdate: mC->on_guild_update([this](auto && e) { OnGuildUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildIntegrationsUpdate: mC->on_guild_integrations_update([this](auto && e) { OnGuildIntegrationsUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildMemberUpdate: mC->on_guild_member_update([this](auto && e) { OnGuildMemberUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ApplicationCommandUpdate: mC->on_application_command_update([this](auto && e) { OnApplicationCommandUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::InviteCreate: mC->on_invite_create([this](auto && e) { OnInviteCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageUpdate: mC->on_message_update([this](auto && e) { OnMessageUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::UserUpdate: mC->on_user_update([this](auto && e) { OnUserUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::MessageCreate: mC->on_message_create([this](auto && e) { OnMessageCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildBanAdd: mC->on_guild_ban_add([this](auto && e) { OnGuildBanAdd(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::GuildBanRemove: mC->on_guild_ban_remove([this](auto && e) { OnGuildBanRemove(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::IntegrationCreate: mC->on_integration_create([this](auto && e) { OnIntegrationCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::IntegrationUpdate: mC->on_integration_update([this](auto && e) { OnIntegrationUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::IntegrationDelete: mC->on_integration_delete([this](auto && e) { OnIntegrationDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ThreadCreate: mC->on_thread_create([this](auto && e) { OnThreadCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ThreadUpdate: mC->on_thread_update([this](auto && e) { OnThreadUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ThreadDelete: mC->on_thread_delete([this](auto && e) { OnThreadDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ThreadListSync: mC->on_thread_list_sync([this](auto && e) { OnThreadListSync(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ThreadMemberUpdate: mC->on_thread_member_update([this](auto && e) { OnThreadMemberUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::ThreadMembersUpdate: mC->on_thread_members_update([this](auto && e) { OnThreadMembersUpdate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::VoiceBufferSend: mC->on_voice_buffer_send([this](auto && e) { OnVoiceBufferSend(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::VoiceUserTalking: mC->on_voice_user_talking([this](auto && e) { OnVoiceUserTalking(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::VoiceReady: mC->on_voice_ready([this](auto && e) { OnVoiceReady(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::VoiceReceive: mC->on_voice_receive([this](auto && e) { OnVoiceReceive(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::VoiceTrackMarker: mC->on_voice_track_marker([this](auto && e) { OnVoiceTrackMarker(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::StageInstanceCreate: mC->on_stage_instance_create([this](auto && e) { OnStageInstanceCreate(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::StageInstanceDelete: mC->on_stage_instance_delete([this](auto && e) { OnStageInstanceDelete(std::forward< decltype(e) >(e)); }); break;
|
||||||
|
case DpEventID::Max: // Fall through
|
||||||
|
default: STHROWF("Invalid discord event identifier {}", id);
|
||||||
|
}
|
||||||
|
// Allow chaining
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
DpCluster & DpCluster::DisableEvent(SQInteger id)
|
||||||
|
{
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case DpEventID::VoiceStateUpdate: mC->on_voice_state_update(std::function<void(const dpp::voice_state_update_t&)>{}); break;
|
||||||
|
case DpEventID::Log: mC->on_log(std::function<void(const dpp::log_t&)>{}); break;
|
||||||
|
case DpEventID::GuildJoinRequestDelete: mC->on_guild_join_request_delete(std::function<void(const dpp::guild_join_request_delete_t&)>{}); break;
|
||||||
|
case DpEventID::InteractionCreate: mC->on_interaction_create(std::function<void(const dpp::interaction_create_t&)>{}); break;
|
||||||
|
case DpEventID::ButtonClick: mC->on_button_click(std::function<void(const dpp::button_click_t&)>{}); break;
|
||||||
|
case DpEventID::SelectClick: mC->on_select_click(std::function<void(const dpp::select_click_t&)>{}); break;
|
||||||
|
case DpEventID::GuildDelete: mC->on_guild_delete(std::function<void(const dpp::guild_delete_t&)>{}); break;
|
||||||
|
case DpEventID::ChannelDelete: mC->on_channel_delete(std::function<void(const dpp::channel_delete_t&)>{}); break;
|
||||||
|
case DpEventID::ChannelUpdate: mC->on_channel_update(std::function<void(const dpp::channel_update_t&)>{}); break;
|
||||||
|
case DpEventID::Ready: mC->on_ready(std::function<void(const dpp::ready_t&)>{}); break;
|
||||||
|
case DpEventID::MessageDelete: mC->on_message_delete(std::function<void(const dpp::message_delete_t&)>{}); break;
|
||||||
|
case DpEventID::ApplicationCommandDelete: mC->on_application_command_delete(std::function<void(const dpp::application_command_delete_t&)>{}); break;
|
||||||
|
case DpEventID::GuildMemberRemove: mC->on_guild_member_remove(std::function<void(const dpp::guild_member_remove_t&)>{}); break;
|
||||||
|
case DpEventID::ApplicationCommandCreate: mC->on_application_command_create(std::function<void(const dpp::application_command_create_t&)>{}); break;
|
||||||
|
case DpEventID::Resumed: mC->on_resumed(std::function<void(const dpp::resumed_t&)>{}); break;
|
||||||
|
case DpEventID::GuildRoleCreate: mC->on_guild_role_create(std::function<void(const dpp::guild_role_create_t&)>{}); break;
|
||||||
|
case DpEventID::TypingStart: mC->on_typing_start(std::function<void(const dpp::typing_start_t&)>{}); break;
|
||||||
|
case DpEventID::MessageReactionAdd: mC->on_message_reaction_add(std::function<void(const dpp::message_reaction_add_t&)>{}); break;
|
||||||
|
case DpEventID::GuildMembersChunk: mC->on_guild_members_chunk(std::function<void(const dpp::guild_members_chunk_t&)>{}); break;
|
||||||
|
case DpEventID::MessageReactionRemove: mC->on_message_reaction_remove(std::function<void(const dpp::message_reaction_remove_t&)>{}); break;
|
||||||
|
case DpEventID::GuildCreate: mC->on_guild_create(std::function<void(const dpp::guild_create_t&)>{}); break;
|
||||||
|
case DpEventID::ChannelCreate: mC->on_channel_create(std::function<void(const dpp::channel_create_t&)>{}); break;
|
||||||
|
case DpEventID::MessageReactionRemoveEmoji: mC->on_message_reaction_remove_emoji(std::function<void(const dpp::message_reaction_remove_emoji_t&)>{}); break;
|
||||||
|
case DpEventID::MessageDeleteBulk: mC->on_message_delete_bulk(std::function<void(const dpp::message_delete_bulk_t&)>{}); break;
|
||||||
|
case DpEventID::GuildRoleUpdate: mC->on_guild_role_update(std::function<void(const dpp::guild_role_update_t&)>{}); break;
|
||||||
|
case DpEventID::GuildRoleDelete: mC->on_guild_role_delete(std::function<void(const dpp::guild_role_delete_t&)>{}); break;
|
||||||
|
case DpEventID::ChannelPinsUpdate: mC->on_channel_pins_update(std::function<void(const dpp::channel_pins_update_t&)>{}); break;
|
||||||
|
case DpEventID::MessageReactionRemoveAll: mC->on_message_reaction_remove_all(std::function<void(const dpp::message_reaction_remove_all_t&)>{}); break;
|
||||||
|
case DpEventID::VoiceServerUpdate: mC->on_voice_server_update(std::function<void(const dpp::voice_server_update_t&)>{}); break;
|
||||||
|
case DpEventID::GuildEmojisUpdate: mC->on_guild_emojis_update(std::function<void(const dpp::guild_emojis_update_t&)>{}); break;
|
||||||
|
case DpEventID::GuildStickersUpdate: mC->on_guild_stickers_update(std::function<void(const dpp::guild_stickers_update_t&)>{}); break;
|
||||||
|
case DpEventID::PresenceUpdate: mC->on_presence_update(std::function<void(const dpp::presence_update_t&)>{}); break;
|
||||||
|
case DpEventID::WebhooksUpdate: mC->on_webhooks_update(std::function<void(const dpp::webhooks_update_t&)>{}); break;
|
||||||
|
case DpEventID::GuildMemberAdd: mC->on_guild_member_add(std::function<void(const dpp::guild_member_add_t&)>{}); break;
|
||||||
|
case DpEventID::InviteDelete: mC->on_invite_delete(std::function<void(const dpp::invite_delete_t&)>{}); break;
|
||||||
|
case DpEventID::GuildUpdate: mC->on_guild_update(std::function<void(const dpp::guild_update_t&)>{}); break;
|
||||||
|
case DpEventID::GuildIntegrationsUpdate: mC->on_guild_integrations_update(std::function<void(const dpp::guild_integrations_update_t&)>{}); break;
|
||||||
|
case DpEventID::GuildMemberUpdate: mC->on_guild_member_update(std::function<void(const dpp::guild_member_update_t&)>{}); break;
|
||||||
|
case DpEventID::ApplicationCommandUpdate: mC->on_application_command_update(std::function<void(const dpp::application_command_update_t&)>{}); break;
|
||||||
|
case DpEventID::InviteCreate: mC->on_invite_create(std::function<void(const dpp::invite_create_t&)>{}); break;
|
||||||
|
case DpEventID::MessageUpdate: mC->on_message_update(std::function<void(const dpp::message_update_t&)>{}); break;
|
||||||
|
case DpEventID::UserUpdate: mC->on_user_update(std::function<void(const dpp::user_update_t&)>{}); break;
|
||||||
|
case DpEventID::MessageCreate: mC->on_message_create(std::function<void(const dpp::message_create_t&)>{}); break;
|
||||||
|
case DpEventID::GuildBanAdd: mC->on_guild_ban_add(std::function<void(const dpp::guild_ban_add_t&)>{}); break;
|
||||||
|
case DpEventID::GuildBanRemove: mC->on_guild_ban_remove(std::function<void(const dpp::guild_ban_remove_t&)>{}); break;
|
||||||
|
case DpEventID::IntegrationCreate: mC->on_integration_create(std::function<void(const dpp::integration_create_t&)>{}); break;
|
||||||
|
case DpEventID::IntegrationUpdate: mC->on_integration_update(std::function<void(const dpp::integration_update_t&)>{}); break;
|
||||||
|
case DpEventID::IntegrationDelete: mC->on_integration_delete(std::function<void(const dpp::integration_delete_t&)>{}); break;
|
||||||
|
case DpEventID::ThreadCreate: mC->on_thread_create(std::function<void(const dpp::thread_create_t&)>{}); break;
|
||||||
|
case DpEventID::ThreadUpdate: mC->on_thread_update(std::function<void(const dpp::thread_update_t&)>{}); break;
|
||||||
|
case DpEventID::ThreadDelete: mC->on_thread_delete(std::function<void(const dpp::thread_delete_t&)>{}); break;
|
||||||
|
case DpEventID::ThreadListSync: mC->on_thread_list_sync(std::function<void(const dpp::thread_list_sync_t&)>{}); break;
|
||||||
|
case DpEventID::ThreadMemberUpdate: mC->on_thread_member_update(std::function<void(const dpp::thread_member_update_t&)>{}); break;
|
||||||
|
case DpEventID::ThreadMembersUpdate: mC->on_thread_members_update(std::function<void(const dpp::thread_members_update_t&)>{}); break;
|
||||||
|
case DpEventID::VoiceBufferSend: mC->on_voice_buffer_send(std::function<void(const dpp::voice_buffer_send_t&)>{}); break;
|
||||||
|
case DpEventID::VoiceUserTalking: mC->on_voice_user_talking(std::function<void(const dpp::voice_user_talking_t&)>{}); break;
|
||||||
|
case DpEventID::VoiceReady: mC->on_voice_ready(std::function<void(const dpp::voice_ready_t&)>{}); break;
|
||||||
|
case DpEventID::VoiceReceive: mC->on_voice_receive(std::function<void(const dpp::voice_receive_t&)>{}); break;
|
||||||
|
case DpEventID::VoiceTrackMarker: mC->on_voice_track_marker(std::function<void(const dpp::voice_track_marker_t&)>{}); break;
|
||||||
|
case DpEventID::StageInstanceCreate: mC->on_stage_instance_create(std::function<void(const dpp::stage_instance_create_t&)>{}); break;
|
||||||
|
case DpEventID::StageInstanceDelete: mC->on_stage_instance_delete(std::function<void(const dpp::stage_instance_delete_t&)>{}); break;
|
||||||
|
case DpEventID::Max: // Fall through
|
||||||
|
default: STHROWF("Invalid discord event identifier {}", id);
|
||||||
|
}
|
||||||
|
// Allow chaining
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpInternalEvent::Release()
|
||||||
|
{
|
||||||
|
// Make sure we actually manage something
|
||||||
|
if (mData == 0) return;
|
||||||
|
// Fetch the type of data
|
||||||
|
const auto type = GetType();
|
||||||
|
// Fetch the data itself
|
||||||
|
const auto data = GetData();
|
||||||
|
// Identify data type
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case DpEventID::VoiceStateUpdate: delete reinterpret_cast< DpVoiceStateUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::Log: delete reinterpret_cast< DpLogEvent * >(data); break;
|
||||||
|
case DpEventID::GuildJoinRequestDelete: delete reinterpret_cast< DpGuildJoinRequestDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::InteractionCreate: delete reinterpret_cast< DpInteractionCreateEvent * >(data); break;
|
||||||
|
case DpEventID::ButtonClick: delete reinterpret_cast< DpButtonClickEvent * >(data); break;
|
||||||
|
case DpEventID::SelectClick: delete reinterpret_cast< DpSelectClickEvent * >(data); break;
|
||||||
|
case DpEventID::GuildDelete: delete reinterpret_cast< DpGuildDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::ChannelDelete: delete reinterpret_cast< DpChannelDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::ChannelUpdate: delete reinterpret_cast< DpChannelUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::Ready: delete reinterpret_cast< DpReadyEvent * >(data); break;
|
||||||
|
case DpEventID::MessageDelete: delete reinterpret_cast< DpMessageDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::ApplicationCommandDelete: delete reinterpret_cast< DpApplicationCommandDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::GuildMemberRemove: delete reinterpret_cast< DpGuildMemberRemoveEvent * >(data); break;
|
||||||
|
case DpEventID::ApplicationCommandCreate: delete reinterpret_cast< DpApplicationCommandCreateEvent * >(data); break;
|
||||||
|
case DpEventID::Resumed: delete reinterpret_cast< DpResumedEvent * >(data); break;
|
||||||
|
case DpEventID::GuildRoleCreate: delete reinterpret_cast< DpGuildRoleCreateEvent * >(data); break;
|
||||||
|
case DpEventID::TypingStart: delete reinterpret_cast< DpTypingStartEvent * >(data); break;
|
||||||
|
case DpEventID::MessageReactionAdd: delete reinterpret_cast< DpMessageReactionAddEvent * >(data); break;
|
||||||
|
case DpEventID::GuildMembersChunk: delete reinterpret_cast< DpGuildMembersChunkEvent * >(data); break;
|
||||||
|
case DpEventID::MessageReactionRemove: delete reinterpret_cast< DpMessageReactionRemoveEvent * >(data); break;
|
||||||
|
case DpEventID::GuildCreate: delete reinterpret_cast< DpGuildCreateEvent * >(data); break;
|
||||||
|
case DpEventID::ChannelCreate: delete reinterpret_cast< DpChannelCreateEvent * >(data); break;
|
||||||
|
case DpEventID::MessageReactionRemoveEmoji: delete reinterpret_cast< DpMessageReactionRemoveEmojiEvent * >(data); break;
|
||||||
|
case DpEventID::MessageDeleteBulk: delete reinterpret_cast< DpMessageDeleteBulkEvent * >(data); break;
|
||||||
|
case DpEventID::GuildRoleUpdate: delete reinterpret_cast< DpGuildRoleUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::GuildRoleDelete: delete reinterpret_cast< DpGuildRoleDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::ChannelPinsUpdate: delete reinterpret_cast< DpChannelPinsUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::MessageReactionRemoveAll: delete reinterpret_cast< DpMessageReactionRemoveAllEvent * >(data); break;
|
||||||
|
case DpEventID::VoiceServerUpdate: delete reinterpret_cast< DpVoiceServerUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::GuildEmojisUpdate: delete reinterpret_cast< DpGuildEmojisUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::GuildStickersUpdate: delete reinterpret_cast< DpGuildStickersUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::PresenceUpdate: delete reinterpret_cast< DpPresenceUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::WebhooksUpdate: delete reinterpret_cast< DpWebhooksUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::GuildMemberAdd: delete reinterpret_cast< DpGuildMemberAddEvent * >(data); break;
|
||||||
|
case DpEventID::InviteDelete: delete reinterpret_cast< DpInviteDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::GuildUpdate: delete reinterpret_cast< DpGuildUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::GuildIntegrationsUpdate: delete reinterpret_cast< DpGuildIntegrationsUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::GuildMemberUpdate: delete reinterpret_cast< DpGuildMemberUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::ApplicationCommandUpdate: delete reinterpret_cast< DpApplicationCommandUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::InviteCreate: delete reinterpret_cast< DpInviteCreateEvent * >(data); break;
|
||||||
|
case DpEventID::MessageUpdate: delete reinterpret_cast< DpMessageUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::UserUpdate: delete reinterpret_cast< DpUserUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::MessageCreate: delete reinterpret_cast< DpMessageCreateEvent * >(data); break;
|
||||||
|
case DpEventID::GuildBanAdd: delete reinterpret_cast< DpGuildBanAddEvent * >(data); break;
|
||||||
|
case DpEventID::GuildBanRemove: delete reinterpret_cast< DpGuildBanRemoveEvent * >(data); break;
|
||||||
|
case DpEventID::IntegrationCreate: delete reinterpret_cast< DpIntegrationCreateEvent * >(data); break;
|
||||||
|
case DpEventID::IntegrationUpdate: delete reinterpret_cast< DpIntegrationUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::IntegrationDelete: delete reinterpret_cast< DpIntegrationDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::ThreadCreate: delete reinterpret_cast< DpThreadCreateEvent * >(data); break;
|
||||||
|
case DpEventID::ThreadUpdate: delete reinterpret_cast< DpThreadUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::ThreadDelete: delete reinterpret_cast< DpThreadDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::ThreadListSync: delete reinterpret_cast< DpThreadListSyncEvent * >(data); break;
|
||||||
|
case DpEventID::ThreadMemberUpdate: delete reinterpret_cast< DpThreadMemberUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::ThreadMembersUpdate: delete reinterpret_cast< DpThreadMembersUpdateEvent * >(data); break;
|
||||||
|
case DpEventID::VoiceBufferSend: delete reinterpret_cast< DpVoiceBufferSendEvent * >(data); break;
|
||||||
|
case DpEventID::VoiceUserTalking: delete reinterpret_cast< DpVoiceUserTalkingEvent * >(data); break;
|
||||||
|
case DpEventID::VoiceReady: delete reinterpret_cast< DpVoiceReadyEvent * >(data); break;
|
||||||
|
case DpEventID::VoiceReceive: delete reinterpret_cast< DpVoiceReceiveEvent * >(data); break;
|
||||||
|
case DpEventID::VoiceTrackMarker: delete reinterpret_cast< DpVoiceTrackMarkerEvent * >(data); break;
|
||||||
|
case DpEventID::StageInstanceCreate: delete reinterpret_cast< DpStageInstanceCreateEvent * >(data); break;
|
||||||
|
case DpEventID::StageInstanceDelete: delete reinterpret_cast< DpStageInstanceDeleteEvent * >(data); break;
|
||||||
|
case DpEventID::Max: // Fall through
|
||||||
|
default: LogFtl("Unrecognized discord event instance type"); assert(0); break;
|
||||||
|
}
|
||||||
|
// Forget about it
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD LightObj EventToScriptObject(uint8_t type, uintptr_t data)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case DpEventID::VoiceStateUpdate: return LightObj(reinterpret_cast< DpVoiceStateUpdateEvent * >(data));
|
||||||
|
case DpEventID::Log: return LightObj(reinterpret_cast< DpLogEvent * >(data));
|
||||||
|
case DpEventID::GuildJoinRequestDelete: return LightObj(reinterpret_cast< DpGuildJoinRequestDeleteEvent * >(data));
|
||||||
|
case DpEventID::InteractionCreate: return LightObj(reinterpret_cast< DpInteractionCreateEvent * >(data));
|
||||||
|
case DpEventID::ButtonClick: return LightObj(reinterpret_cast< DpButtonClickEvent * >(data));
|
||||||
|
case DpEventID::SelectClick: return LightObj(reinterpret_cast< DpSelectClickEvent * >(data));
|
||||||
|
case DpEventID::GuildDelete: return LightObj(reinterpret_cast< DpGuildDeleteEvent * >(data));
|
||||||
|
case DpEventID::ChannelDelete: return LightObj(reinterpret_cast< DpChannelDeleteEvent * >(data));
|
||||||
|
case DpEventID::ChannelUpdate: return LightObj(reinterpret_cast< DpChannelUpdateEvent * >(data));
|
||||||
|
case DpEventID::Ready: return LightObj(reinterpret_cast< DpReadyEvent * >(data));
|
||||||
|
case DpEventID::MessageDelete: return LightObj(reinterpret_cast< DpMessageDeleteEvent * >(data));
|
||||||
|
case DpEventID::ApplicationCommandDelete: return LightObj(reinterpret_cast< DpApplicationCommandDeleteEvent * >(data));
|
||||||
|
case DpEventID::GuildMemberRemove: return LightObj(reinterpret_cast< DpGuildMemberRemoveEvent * >(data));
|
||||||
|
case DpEventID::ApplicationCommandCreate: return LightObj(reinterpret_cast< DpApplicationCommandCreateEvent * >(data));
|
||||||
|
case DpEventID::Resumed: return LightObj(reinterpret_cast< DpResumedEvent * >(data));
|
||||||
|
case DpEventID::GuildRoleCreate: return LightObj(reinterpret_cast< DpGuildRoleCreateEvent * >(data));
|
||||||
|
case DpEventID::TypingStart: return LightObj(reinterpret_cast< DpTypingStartEvent * >(data));
|
||||||
|
case DpEventID::MessageReactionAdd: return LightObj(reinterpret_cast< DpMessageReactionAddEvent * >(data));
|
||||||
|
case DpEventID::GuildMembersChunk: return LightObj(reinterpret_cast< DpGuildMembersChunkEvent * >(data));
|
||||||
|
case DpEventID::MessageReactionRemove: return LightObj(reinterpret_cast< DpMessageReactionRemoveEvent * >(data));
|
||||||
|
case DpEventID::GuildCreate: return LightObj(reinterpret_cast< DpGuildCreateEvent * >(data));
|
||||||
|
case DpEventID::ChannelCreate: return LightObj(reinterpret_cast< DpChannelCreateEvent * >(data));
|
||||||
|
case DpEventID::MessageReactionRemoveEmoji: return LightObj(reinterpret_cast< DpMessageReactionRemoveEmojiEvent * >(data));
|
||||||
|
case DpEventID::MessageDeleteBulk: return LightObj(reinterpret_cast< DpMessageDeleteBulkEvent * >(data));
|
||||||
|
case DpEventID::GuildRoleUpdate: return LightObj(reinterpret_cast< DpGuildRoleUpdateEvent * >(data));
|
||||||
|
case DpEventID::GuildRoleDelete: return LightObj(reinterpret_cast< DpGuildRoleDeleteEvent * >(data));
|
||||||
|
case DpEventID::ChannelPinsUpdate: return LightObj(reinterpret_cast< DpChannelPinsUpdateEvent * >(data));
|
||||||
|
case DpEventID::MessageReactionRemoveAll: return LightObj(reinterpret_cast< DpMessageReactionRemoveAllEvent * >(data));
|
||||||
|
case DpEventID::VoiceServerUpdate: return LightObj(reinterpret_cast< DpVoiceServerUpdateEvent * >(data));
|
||||||
|
case DpEventID::GuildEmojisUpdate: return LightObj(reinterpret_cast< DpGuildEmojisUpdateEvent * >(data));
|
||||||
|
case DpEventID::GuildStickersUpdate: return LightObj(reinterpret_cast< DpGuildStickersUpdateEvent * >(data));
|
||||||
|
case DpEventID::PresenceUpdate: return LightObj(reinterpret_cast< DpPresenceUpdateEvent * >(data));
|
||||||
|
case DpEventID::WebhooksUpdate: return LightObj(reinterpret_cast< DpWebhooksUpdateEvent * >(data));
|
||||||
|
case DpEventID::GuildMemberAdd: return LightObj(reinterpret_cast< DpGuildMemberAddEvent * >(data));
|
||||||
|
case DpEventID::InviteDelete: return LightObj(reinterpret_cast< DpInviteDeleteEvent * >(data));
|
||||||
|
case DpEventID::GuildUpdate: return LightObj(reinterpret_cast< DpGuildUpdateEvent * >(data));
|
||||||
|
case DpEventID::GuildIntegrationsUpdate: return LightObj(reinterpret_cast< DpGuildIntegrationsUpdateEvent * >(data));
|
||||||
|
case DpEventID::GuildMemberUpdate: return LightObj(reinterpret_cast< DpGuildMemberUpdateEvent * >(data));
|
||||||
|
case DpEventID::ApplicationCommandUpdate: return LightObj(reinterpret_cast< DpApplicationCommandUpdateEvent * >(data));
|
||||||
|
case DpEventID::InviteCreate: return LightObj(reinterpret_cast< DpInviteCreateEvent * >(data));
|
||||||
|
case DpEventID::MessageUpdate: return LightObj(reinterpret_cast< DpMessageUpdateEvent * >(data));
|
||||||
|
case DpEventID::UserUpdate: return LightObj(reinterpret_cast< DpUserUpdateEvent * >(data));
|
||||||
|
case DpEventID::MessageCreate: return LightObj(reinterpret_cast< DpMessageCreateEvent * >(data));
|
||||||
|
case DpEventID::GuildBanAdd: return LightObj(reinterpret_cast< DpGuildBanAddEvent * >(data));
|
||||||
|
case DpEventID::GuildBanRemove: return LightObj(reinterpret_cast< DpGuildBanRemoveEvent * >(data));
|
||||||
|
case DpEventID::IntegrationCreate: return LightObj(reinterpret_cast< DpIntegrationCreateEvent * >(data));
|
||||||
|
case DpEventID::IntegrationUpdate: return LightObj(reinterpret_cast< DpIntegrationUpdateEvent * >(data));
|
||||||
|
case DpEventID::IntegrationDelete: return LightObj(reinterpret_cast< DpIntegrationDeleteEvent * >(data));
|
||||||
|
case DpEventID::ThreadCreate: return LightObj(reinterpret_cast< DpThreadCreateEvent * >(data));
|
||||||
|
case DpEventID::ThreadUpdate: return LightObj(reinterpret_cast< DpThreadUpdateEvent * >(data));
|
||||||
|
case DpEventID::ThreadDelete: return LightObj(reinterpret_cast< DpThreadDeleteEvent * >(data));
|
||||||
|
case DpEventID::ThreadListSync: return LightObj(reinterpret_cast< DpThreadListSyncEvent * >(data));
|
||||||
|
case DpEventID::ThreadMemberUpdate: return LightObj(reinterpret_cast< DpThreadMemberUpdateEvent * >(data));
|
||||||
|
case DpEventID::ThreadMembersUpdate: return LightObj(reinterpret_cast< DpThreadMembersUpdateEvent * >(data));
|
||||||
|
case DpEventID::VoiceBufferSend: return LightObj(reinterpret_cast< DpVoiceBufferSendEvent * >(data));
|
||||||
|
case DpEventID::VoiceUserTalking: return LightObj(reinterpret_cast< DpVoiceUserTalkingEvent * >(data));
|
||||||
|
case DpEventID::VoiceReady: return LightObj(reinterpret_cast< DpVoiceReadyEvent * >(data));
|
||||||
|
case DpEventID::VoiceReceive: return LightObj(reinterpret_cast< DpVoiceReceiveEvent * >(data));
|
||||||
|
case DpEventID::VoiceTrackMarker: return LightObj(reinterpret_cast< DpVoiceTrackMarkerEvent * >(data));
|
||||||
|
case DpEventID::StageInstanceCreate: return LightObj(reinterpret_cast< DpStageInstanceCreateEvent * >(data));
|
||||||
|
case DpEventID::StageInstanceDelete: return LightObj(reinterpret_cast< DpStageInstanceDeleteEvent * >(data));
|
||||||
|
case DpEventID::Max: // Fall through
|
||||||
|
default: assert(0); return LightObj{};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void EventInvokeCleanup(uint8_t type, uintptr_t data)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case DpEventID::VoiceStateUpdate: reinterpret_cast< DpVoiceStateUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::Log: reinterpret_cast< DpLogEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildJoinRequestDelete: reinterpret_cast< DpGuildJoinRequestDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::InteractionCreate: reinterpret_cast< DpInteractionCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ButtonClick: reinterpret_cast< DpButtonClickEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::SelectClick: reinterpret_cast< DpSelectClickEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildDelete: reinterpret_cast< DpGuildDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ChannelDelete: reinterpret_cast< DpChannelDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ChannelUpdate: reinterpret_cast< DpChannelUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::Ready: reinterpret_cast< DpReadyEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageDelete: reinterpret_cast< DpMessageDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ApplicationCommandDelete: reinterpret_cast< DpApplicationCommandDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildMemberRemove: reinterpret_cast< DpGuildMemberRemoveEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ApplicationCommandCreate: reinterpret_cast< DpApplicationCommandCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::Resumed: reinterpret_cast< DpResumedEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildRoleCreate: reinterpret_cast< DpGuildRoleCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::TypingStart: reinterpret_cast< DpTypingStartEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageReactionAdd: reinterpret_cast< DpMessageReactionAddEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildMembersChunk: reinterpret_cast< DpGuildMembersChunkEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageReactionRemove: reinterpret_cast< DpMessageReactionRemoveEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildCreate: reinterpret_cast< DpGuildCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ChannelCreate: reinterpret_cast< DpChannelCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageReactionRemoveEmoji: reinterpret_cast< DpMessageReactionRemoveEmojiEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageDeleteBulk: reinterpret_cast< DpMessageDeleteBulkEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildRoleUpdate: reinterpret_cast< DpGuildRoleUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildRoleDelete: reinterpret_cast< DpGuildRoleDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ChannelPinsUpdate: reinterpret_cast< DpChannelPinsUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageReactionRemoveAll: reinterpret_cast< DpMessageReactionRemoveAllEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::VoiceServerUpdate: reinterpret_cast< DpVoiceServerUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildEmojisUpdate: reinterpret_cast< DpGuildEmojisUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildStickersUpdate: reinterpret_cast< DpGuildStickersUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::PresenceUpdate: reinterpret_cast< DpPresenceUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::WebhooksUpdate: reinterpret_cast< DpWebhooksUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildMemberAdd: reinterpret_cast< DpGuildMemberAddEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::InviteDelete: reinterpret_cast< DpInviteDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildUpdate: reinterpret_cast< DpGuildUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildIntegrationsUpdate: reinterpret_cast< DpGuildIntegrationsUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildMemberUpdate: reinterpret_cast< DpGuildMemberUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ApplicationCommandUpdate: reinterpret_cast< DpApplicationCommandUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::InviteCreate: reinterpret_cast< DpInviteCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageUpdate: reinterpret_cast< DpMessageUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::UserUpdate: reinterpret_cast< DpUserUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::MessageCreate: reinterpret_cast< DpMessageCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildBanAdd: reinterpret_cast< DpGuildBanAddEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::GuildBanRemove: reinterpret_cast< DpGuildBanRemoveEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::IntegrationCreate: reinterpret_cast< DpIntegrationCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::IntegrationUpdate: reinterpret_cast< DpIntegrationUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::IntegrationDelete: reinterpret_cast< DpIntegrationDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ThreadCreate: reinterpret_cast< DpThreadCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ThreadUpdate: reinterpret_cast< DpThreadUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ThreadDelete: reinterpret_cast< DpThreadDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ThreadListSync: reinterpret_cast< DpThreadListSyncEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ThreadMemberUpdate: reinterpret_cast< DpThreadMemberUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::ThreadMembersUpdate: reinterpret_cast< DpThreadMembersUpdateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::VoiceBufferSend: reinterpret_cast< DpVoiceBufferSendEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::VoiceUserTalking: reinterpret_cast< DpVoiceUserTalkingEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::VoiceReady: reinterpret_cast< DpVoiceReadyEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::VoiceReceive: reinterpret_cast< DpVoiceReceiveEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::VoiceTrackMarker: reinterpret_cast< DpVoiceTrackMarkerEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::StageInstanceCreate: reinterpret_cast< DpStageInstanceCreateEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::StageInstanceDelete: reinterpret_cast< DpStageInstanceDeleteEvent * >(data)->Cleanup(); break;
|
||||||
|
case DpEventID::Max: // Fall through
|
||||||
|
default: assert(0); return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,431 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
#include "Core/Signal.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Other.hpp"
|
||||||
|
#include "Library/DPP/Constants.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
#include <memory>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <concurrentqueue.h>
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Internal event proxy.
|
||||||
|
*/
|
||||||
|
struct DpInternalEvent
|
||||||
|
{
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Event data.
|
||||||
|
*/
|
||||||
|
uint64_t mData{0llu};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpInternalEvent() noexcept = default;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpInternalEvent(uint64_t type, void * data) noexcept
|
||||||
|
: mData((type << 56u) | reinterpret_cast< uint64_t >(data))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpInternalEvent(const DpInternalEvent & o) = delete;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpInternalEvent(DpInternalEvent && o) noexcept
|
||||||
|
: mData(o.mData)
|
||||||
|
{
|
||||||
|
o.mData = 0llu; // Take ownership
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpInternalEvent()
|
||||||
|
{
|
||||||
|
Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpInternalEvent & operator = (const DpInternalEvent & o) = delete;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpInternalEvent & operator = (DpInternalEvent && o) noexcept
|
||||||
|
{
|
||||||
|
if (mData != o.mData)
|
||||||
|
{
|
||||||
|
// Release current information
|
||||||
|
Release();
|
||||||
|
// Replicate members
|
||||||
|
mData = o.mData;
|
||||||
|
// Take ownership
|
||||||
|
o.mData = 0llu;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Forget about the managed event data.
|
||||||
|
*/
|
||||||
|
void Reset() noexcept
|
||||||
|
{
|
||||||
|
mData = 0llu;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the event type.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD uint8_t GetType() const noexcept
|
||||||
|
{
|
||||||
|
return static_cast< uint8_t >((mData >> 56u) & 0xFFllu);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the event data.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD uintptr_t GetData() const noexcept
|
||||||
|
{
|
||||||
|
return static_cast< uintptr_t >((~(0xFFllu << 56u)) & mData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release associated event data, if any.
|
||||||
|
*/
|
||||||
|
void Release();
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* The cluster class represents a group of shards and a command queue for sending and receiving
|
||||||
|
* commands from discord via HTTP.
|
||||||
|
*/
|
||||||
|
struct DpCluster : public SqChainedInstances< DpCluster >
|
||||||
|
{
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Queue of events generated from other threads.
|
||||||
|
*/
|
||||||
|
using EventQueue = moodycamel::ConcurrentQueue< DpInternalEvent >;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Managed cluster instance.
|
||||||
|
*/
|
||||||
|
std::unique_ptr< dpp::cluster > mC{nullptr};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Event queue.
|
||||||
|
*/
|
||||||
|
EventQueue mQueue{4096};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpCluster(StackStrF & token)
|
||||||
|
: mC(std::make_unique< dpp::cluster >(token.ToStr()))
|
||||||
|
, mQueue(4096)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCluster(StackStrF & token, SQInteger intents)
|
||||||
|
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents)))
|
||||||
|
, mQueue(4096)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCluster(StackStrF & token, SQInteger intents, SQInteger shards)
|
||||||
|
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents), static_cast< uint32_t >(shards)))
|
||||||
|
, mQueue(4096)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCluster(StackStrF & token, SQInteger intents, SQInteger shards, SQInteger cluster_id)
|
||||||
|
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents), static_cast< uint32_t >(shards), static_cast< uint32_t >(cluster_id)))
|
||||||
|
, mQueue(4096)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCluster(StackStrF & token, SQInteger intents, SQInteger shards, SQInteger cluster_id, SQInteger max_clusters)
|
||||||
|
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents), static_cast< uint32_t >(shards), static_cast< uint32_t >(cluster_id), static_cast< uint32_t >(max_clusters)))
|
||||||
|
, mQueue(4096)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCluster(StackStrF & token, SQInteger intents, SQInteger shards, SQInteger cluster_id, SQInteger max_clusters, bool compressed)
|
||||||
|
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents), static_cast< uint32_t >(shards), static_cast< uint32_t >(cluster_id), static_cast< uint32_t >(max_clusters), compressed))
|
||||||
|
, mQueue(4096)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCluster(StackStrF & token, SQInteger intents, SQInteger shards, SQInteger cluster_id, SQInteger max_clusters, bool compressed, const DpCachePolicy & cp)
|
||||||
|
: mC(std::make_unique< dpp::cluster >(token.ToStr(), static_cast< uint32_t >(intents), static_cast< uint32_t >(shards), static_cast< uint32_t >(cluster_id), static_cast< uint32_t >(max_clusters), compressed, cp.ToNative()))
|
||||||
|
, mQueue(4096)
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpCluster()
|
||||||
|
{
|
||||||
|
DropEvents();
|
||||||
|
// Forget about this instance
|
||||||
|
UnchainInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Start the cluster, connecting all its shards. Returns once all shards are connected.
|
||||||
|
*/
|
||||||
|
DpCluster & Start()
|
||||||
|
{
|
||||||
|
LogInf("Before start...");
|
||||||
|
mC->start(true);
|
||||||
|
LogInf("After start...");
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Log a message to whatever log the user is using.
|
||||||
|
*/
|
||||||
|
DpCluster & Log(SQInteger severity, StackStrF & message)
|
||||||
|
{
|
||||||
|
mC->log(static_cast< dpp::loglevel >(severity), message.ToStr());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Get the dm channel for a user id.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetDmChannel(dpp::snowflake user_id) const
|
||||||
|
{
|
||||||
|
return mC->get_dm_channel(static_cast< dpp::snowflake >(user_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Set the dm channel id for a user id.
|
||||||
|
*/
|
||||||
|
DpCluster & SetDmChannel(dpp::snowflake user_id, dpp::snowflake channel_id)
|
||||||
|
{
|
||||||
|
mC->set_dm_channel(user_id, channel_id);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Returns the uptime of the cluster.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::utility::uptime UpTime() const
|
||||||
|
{
|
||||||
|
return mC->uptime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Returns the uptime of the cluster.
|
||||||
|
*/
|
||||||
|
DpCluster & SetPresence(const DpPresence & p)
|
||||||
|
{
|
||||||
|
mC->set_presence(p.Valid());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
LightObj mSqEvents{}; // Table containing the emitted cluster events.
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the events table of this cluster.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj & GetEvents()
|
||||||
|
{
|
||||||
|
return mSqEvents;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Cluster signals.
|
||||||
|
*/
|
||||||
|
std::array< SignalPair, static_cast< size_t >(DpEventID::Max) > mEvents{};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Process the cluster.
|
||||||
|
*/
|
||||||
|
void Process(bool force = false);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Terminate the cluster.
|
||||||
|
*/
|
||||||
|
void Terminate()
|
||||||
|
{
|
||||||
|
// Delete the cluster instance
|
||||||
|
mC.reset();
|
||||||
|
// Release associated script objects
|
||||||
|
mSqEvents.Release();
|
||||||
|
// Release event signal objects
|
||||||
|
DropEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Enable a certain event for the cluster.
|
||||||
|
*/
|
||||||
|
DpCluster & EnableEvent(SQInteger id);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Disable a certain event for the cluster.
|
||||||
|
*/
|
||||||
|
DpCluster & DisableEvent(SQInteger id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Initialize the cluster.
|
||||||
|
*/
|
||||||
|
void Initialize()
|
||||||
|
{
|
||||||
|
InitEvents();
|
||||||
|
// Remember this instance
|
||||||
|
ChainInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Signal initialization.
|
||||||
|
*/
|
||||||
|
void InitEvents()
|
||||||
|
{
|
||||||
|
// Ignore the call if already initialized
|
||||||
|
if (!mSqEvents.IsNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Create a new table on the stack
|
||||||
|
sq_newtableex(SqVM(), 64);
|
||||||
|
// Grab the table object from the stack
|
||||||
|
mSqEvents = LightObj(-1, SqVM());
|
||||||
|
// Pop the table object from the stack
|
||||||
|
sq_pop(SqVM(), 1);
|
||||||
|
// Proceed to initializing the events
|
||||||
|
for (size_t i = 0; i < mEvents.size(); ++i)
|
||||||
|
{
|
||||||
|
InitSignalPair(mEvents[i], mSqEvents, DpEventID::NAME[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Signal termination.
|
||||||
|
*/
|
||||||
|
void DropEvents()
|
||||||
|
{
|
||||||
|
for (auto & e : mEvents)
|
||||||
|
{
|
||||||
|
ResetSignalPair(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Event handlers.
|
||||||
|
*/
|
||||||
|
void OnVoiceStateUpdate(const dpp::voice_state_update_t & ev);
|
||||||
|
void OnLog(const dpp::log_t & ev);
|
||||||
|
void OnGuildJoinRequestDelete(const dpp::guild_join_request_delete_t & ev);
|
||||||
|
void OnInteractionCreate(const dpp::interaction_create_t & ev);
|
||||||
|
void OnButtonClick(const dpp::button_click_t & ev);
|
||||||
|
void OnSelectClick(const dpp::select_click_t & ev);
|
||||||
|
void OnGuildDelete(const dpp::guild_delete_t & ev);
|
||||||
|
void OnChannelDelete(const dpp::channel_delete_t & ev);
|
||||||
|
void OnChannelUpdate(const dpp::channel_update_t & ev);
|
||||||
|
void OnReady(const dpp::ready_t & ev);
|
||||||
|
void OnMessageDelete(const dpp::message_delete_t & ev);
|
||||||
|
void OnApplicationCommandDelete(const dpp::application_command_delete_t & ev);
|
||||||
|
void OnGuildMemberRemove(const dpp::guild_member_remove_t & ev);
|
||||||
|
void OnApplicationCommandCreate(const dpp::application_command_create_t & ev);
|
||||||
|
void OnResumed(const dpp::resumed_t & ev);
|
||||||
|
void OnGuildRoleCreate(const dpp::guild_role_create_t & ev);
|
||||||
|
void OnTypingStart(const dpp::typing_start_t & ev);
|
||||||
|
void OnMessageReactionAdd(const dpp::message_reaction_add_t & ev);
|
||||||
|
void OnGuildMembersChunk(const dpp::guild_members_chunk_t & ev);
|
||||||
|
void OnMessageReactionRemove(const dpp::message_reaction_remove_t & ev);
|
||||||
|
void OnGuildCreate(const dpp::guild_create_t & ev);
|
||||||
|
void OnChannelCreate(const dpp::channel_create_t & ev);
|
||||||
|
void OnMessageReactionRemoveEmoji(const dpp::message_reaction_remove_emoji_t & ev);
|
||||||
|
void OnMessageDeleteBulk(const dpp::message_delete_bulk_t & ev);
|
||||||
|
void OnGuildRoleUpdate(const dpp::guild_role_update_t & ev);
|
||||||
|
void OnGuildRoleDelete(const dpp::guild_role_delete_t & ev);
|
||||||
|
void OnChannelPinsUpdate(const dpp::channel_pins_update_t & ev);
|
||||||
|
void OnMessageReactionRemoveAll(const dpp::message_reaction_remove_all_t & ev);
|
||||||
|
void OnVoiceServerUpdate(const dpp::voice_server_update_t & ev);
|
||||||
|
void OnGuildEmojisUpdate(const dpp::guild_emojis_update_t & ev);
|
||||||
|
void OnGuildStickersUpdate(const dpp::guild_stickers_update_t & ev);
|
||||||
|
void OnPresenceUpdate(const dpp::presence_update_t & ev);
|
||||||
|
void OnWebhooksUpdate(const dpp::webhooks_update_t & ev);
|
||||||
|
void OnGuildMemberAdd(const dpp::guild_member_add_t & ev);
|
||||||
|
void OnInviteDelete(const dpp::invite_delete_t & ev);
|
||||||
|
void OnGuildUpdate(const dpp::guild_update_t & ev);
|
||||||
|
void OnGuildIntegrationsUpdate(const dpp::guild_integrations_update_t & ev);
|
||||||
|
void OnGuildMemberUpdate(const dpp::guild_member_update_t & ev);
|
||||||
|
void OnApplicationCommandUpdate(const dpp::application_command_update_t & ev);
|
||||||
|
void OnInviteCreate(const dpp::invite_create_t & ev);
|
||||||
|
void OnMessageUpdate(const dpp::message_update_t & ev);
|
||||||
|
void OnUserUpdate(const dpp::user_update_t & ev);
|
||||||
|
void OnMessageCreate(const dpp::message_create_t & ev);
|
||||||
|
void OnGuildBanAdd(const dpp::guild_ban_add_t & ev);
|
||||||
|
void OnGuildBanRemove(const dpp::guild_ban_remove_t & ev);
|
||||||
|
void OnIntegrationCreate(const dpp::integration_create_t & ev);
|
||||||
|
void OnIntegrationUpdate(const dpp::integration_update_t & ev);
|
||||||
|
void OnIntegrationDelete(const dpp::integration_delete_t & ev);
|
||||||
|
void OnThreadCreate(const dpp::thread_create_t & ev);
|
||||||
|
void OnThreadUpdate(const dpp::thread_update_t & ev);
|
||||||
|
void OnThreadDelete(const dpp::thread_delete_t & ev);
|
||||||
|
void OnThreadListSync(const dpp::thread_list_sync_t & ev);
|
||||||
|
void OnThreadMemberUpdate(const dpp::thread_member_update_t & ev);
|
||||||
|
void OnThreadMembersUpdate(const dpp::thread_members_update_t & ev);
|
||||||
|
void OnVoiceBufferSend(const dpp::voice_buffer_send_t & ev);
|
||||||
|
void OnVoiceUserTalking(const dpp::voice_user_talking_t & ev);
|
||||||
|
void OnVoiceReady(const dpp::voice_ready_t & ev);
|
||||||
|
void OnVoiceReceive(const dpp::voice_receive_t & ev);
|
||||||
|
void OnVoiceTrackMarker(const dpp::voice_track_marker_t & ev);
|
||||||
|
void OnStageInstanceCreate(const dpp::stage_instance_create_t & ev);
|
||||||
|
void OnStageInstanceDelete(const dpp::stage_instance_delete_t & ev);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Command.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Command(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,427 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Constants.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <sqratConst.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
const std::array< const char *, static_cast< size_t >(DpEventID::Max) > DpEventID::NAME{
|
||||||
|
"VoiceStateUpdate",
|
||||||
|
"Log",
|
||||||
|
"GuildJoinRequestDelete",
|
||||||
|
"InteractionCreate",
|
||||||
|
"ButtonClick",
|
||||||
|
"SelectClick",
|
||||||
|
"GuildDelete",
|
||||||
|
"ChannelDelete",
|
||||||
|
"ChannelUpdate",
|
||||||
|
"Ready",
|
||||||
|
"MessageDelete",
|
||||||
|
"ApplicationCommandDelete",
|
||||||
|
"GuildMemberRemove",
|
||||||
|
"ApplicationCommandCreate",
|
||||||
|
"Resumed",
|
||||||
|
"GuildRoleCreate",
|
||||||
|
"TypingStart",
|
||||||
|
"MessageReactionAdd",
|
||||||
|
"GuildMembersChunk",
|
||||||
|
"MessageReactionRemove",
|
||||||
|
"GuildCreate",
|
||||||
|
"ChannelCreate",
|
||||||
|
"MessageReactionRemoveEmoji",
|
||||||
|
"MessageDeleteBulk",
|
||||||
|
"GuildRoleUpdate",
|
||||||
|
"GuildRoleDelete",
|
||||||
|
"ChannelPinsUpdate",
|
||||||
|
"MessageReactionRemoveAll",
|
||||||
|
"VoiceServerUpdate",
|
||||||
|
"GuildEmojisUpdate",
|
||||||
|
"GuildStickersUpdate",
|
||||||
|
"PresenceUpdate",
|
||||||
|
"WebhooksUpdate",
|
||||||
|
"GuildMemberAdd",
|
||||||
|
"InviteDelete",
|
||||||
|
"GuildUpdate",
|
||||||
|
"GuildIntegrationsUpdate",
|
||||||
|
"GuildMemberUpdate",
|
||||||
|
"ApplicationCommandUpdate",
|
||||||
|
"InviteCreate",
|
||||||
|
"MessageUpdate",
|
||||||
|
"UserUpdate",
|
||||||
|
"MessageCreate",
|
||||||
|
"GuildBanAdd",
|
||||||
|
"GuildBanRemove",
|
||||||
|
"IntegrationCreate",
|
||||||
|
"IntegrationUpdate",
|
||||||
|
"IntegrationDelete",
|
||||||
|
"ThreadCreate",
|
||||||
|
"ThreadUpdate",
|
||||||
|
"ThreadDelete",
|
||||||
|
"ThreadListSync",
|
||||||
|
"ThreadMemberUpdate",
|
||||||
|
"ThreadMembersUpdate",
|
||||||
|
"VoiceBufferSend",
|
||||||
|
"VoiceUserTalking",
|
||||||
|
"VoiceReady",
|
||||||
|
"VoiceReceive",
|
||||||
|
"VoiceTrackMarker",
|
||||||
|
"StageInstanceCreate",
|
||||||
|
"StageInstanceDelete"
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpLogLevelEnum[] = {
|
||||||
|
{_SC("Trace"), static_cast< SQInteger >(dpp::ll_trace)},
|
||||||
|
{_SC("Debug"), static_cast< SQInteger >(dpp::ll_debug)},
|
||||||
|
{_SC("Info"), static_cast< SQInteger >(dpp::ll_info)},
|
||||||
|
{_SC("Warning"), static_cast< SQInteger >(dpp::ll_warning)},
|
||||||
|
{_SC("Error"), static_cast< SQInteger >(dpp::ll_error)},
|
||||||
|
{_SC("Critical"), static_cast< SQInteger >(dpp::ll_critical)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpImageTypeEnum[] = {
|
||||||
|
{_SC("PNG"), static_cast< SQInteger >(dpp::i_png)},
|
||||||
|
{_SC("JPG"), static_cast< SQInteger >(dpp::i_jpg)},
|
||||||
|
{_SC("GIF"), static_cast< SQInteger >(dpp::i_gif)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpCachePolicyEnum[] = {
|
||||||
|
{_SC("Aggressive"), static_cast< SQInteger >(dpp::cp_aggressive)},
|
||||||
|
{_SC("Lazy"), static_cast< SQInteger >(dpp::cp_lazy)},
|
||||||
|
{_SC("None"), static_cast< SQInteger >(dpp::cp_none)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpClusterIntentsEnum[] = {
|
||||||
|
{_SC("Guilds"), static_cast< SQInteger >(dpp::i_guilds)},
|
||||||
|
{_SC("GuildMembers"), static_cast< SQInteger >(dpp::i_guild_members)},
|
||||||
|
{_SC("GuildBans"), static_cast< SQInteger >(dpp::i_guild_bans)},
|
||||||
|
{_SC("GuildEmojis"), static_cast< SQInteger >(dpp::i_guild_emojis)},
|
||||||
|
{_SC("GuildIntegrations"), static_cast< SQInteger >(dpp::i_guild_integrations)},
|
||||||
|
{_SC("GuildWebhooks"), static_cast< SQInteger >(dpp::i_guild_webhooks)},
|
||||||
|
{_SC("GuildInvites"), static_cast< SQInteger >(dpp::i_guild_invites)},
|
||||||
|
{_SC("GuildVoiceStates"), static_cast< SQInteger >(dpp::i_guild_voice_states)},
|
||||||
|
{_SC("GuildPresences"), static_cast< SQInteger >(dpp::i_guild_presences)},
|
||||||
|
{_SC("GuildMessages"), static_cast< SQInteger >(dpp::i_guild_messages)},
|
||||||
|
{_SC("GuildMessageReactions"), static_cast< SQInteger >(dpp::i_guild_message_reactions)},
|
||||||
|
{_SC("GuildMessageTyping"), static_cast< SQInteger >(dpp::i_guild_message_typing)},
|
||||||
|
{_SC("DirectMessages"), static_cast< SQInteger >(dpp::i_direct_messages)},
|
||||||
|
{_SC("DirectMessageReactions"), static_cast< SQInteger >(dpp::i_direct_message_reactions)},
|
||||||
|
{_SC("DirectMessageTyping"), static_cast< SQInteger >(dpp::i_direct_message_typing)},
|
||||||
|
{_SC("Default"), static_cast< SQInteger >(dpp::i_default_intents)},
|
||||||
|
{_SC("Privileged"), static_cast< SQInteger >(dpp::i_privileged_intents)},
|
||||||
|
{_SC("All"), static_cast< SQInteger >(dpp::i_all_intents)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpPresenceFlagsEnum[] = {
|
||||||
|
{_SC("DesktopOnline"), static_cast< SQInteger >(dpp::p_desktop_online)},
|
||||||
|
{_SC("DesktopDND"), static_cast< SQInteger >(dpp::p_desktop_dnd)},
|
||||||
|
{_SC("DesktopIdle"), static_cast< SQInteger >(dpp::p_desktop_idle)},
|
||||||
|
{_SC("WebWnline"), static_cast< SQInteger >(dpp::p_web_online)},
|
||||||
|
{_SC("WebDND"), static_cast< SQInteger >(dpp::p_web_dnd)},
|
||||||
|
{_SC("WebIdle"), static_cast< SQInteger >(dpp::p_web_idle)},
|
||||||
|
{_SC("MobileOnline"), static_cast< SQInteger >(dpp::p_mobile_online)},
|
||||||
|
{_SC("MobileDND"), static_cast< SQInteger >(dpp::p_mobile_dnd)},
|
||||||
|
{_SC("MobileIdle"), static_cast< SQInteger >(dpp::p_mobile_idle)},
|
||||||
|
{_SC("StatusOnline"), static_cast< SQInteger >(dpp::p_status_online)},
|
||||||
|
{_SC("StatusDND"), static_cast< SQInteger >(dpp::p_status_dnd)},
|
||||||
|
{_SC("StatusIdle"), static_cast< SQInteger >(dpp::p_status_idle)},
|
||||||
|
// Helper bit-shift flags
|
||||||
|
{_SC("BitShiftDesktop"), static_cast< SQInteger >(PF_SHIFT_DESKTOP)},
|
||||||
|
{_SC("BitShiftWeb"), static_cast< SQInteger >(PF_SHIFT_WEB)},
|
||||||
|
{_SC("BitShiftMobile"), static_cast< SQInteger >(PF_SHIFT_MOBILE)},
|
||||||
|
{_SC("BitShiftMain"), static_cast< SQInteger >(PF_SHIFT_MAIN)},
|
||||||
|
{_SC("BitStatusMask"), static_cast< SQInteger >(PF_STATUS_MASK)},
|
||||||
|
{_SC("BitClearDesktop"), static_cast< SQInteger >(PF_CLEAR_DESKTOP)},
|
||||||
|
{_SC("BitClearWeb"), static_cast< SQInteger >(PF_CLEAR_WEB)},
|
||||||
|
{_SC("BitClearMobile"), static_cast< SQInteger >(PF_CLEAR_MOBILE)},
|
||||||
|
{_SC("BitClearStatus"), static_cast< SQInteger >(PF_CLEAR_STATUS)},
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpPresenceStatusEnum[] = {
|
||||||
|
{_SC("Offline"), static_cast< SQInteger >(dpp::ps_offline)},
|
||||||
|
{_SC("Online"), static_cast< SQInteger >(dpp::ps_online)},
|
||||||
|
{_SC("DND"), static_cast< SQInteger >(dpp::ps_dnd)},
|
||||||
|
{_SC("Idle"), static_cast< SQInteger >(dpp::ps_idle)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpDesktopStatusBitsEnum[] = {
|
||||||
|
{_SC("ShiftDesktop"), static_cast< SQInteger >(PF_SHIFT_DESKTOP)},
|
||||||
|
{_SC("ShiftWeb"), static_cast< SQInteger >(PF_SHIFT_WEB)},
|
||||||
|
{_SC("ShiftMobile"), static_cast< SQInteger >(PF_SHIFT_MOBILE)},
|
||||||
|
{_SC("ShiftMain"), static_cast< SQInteger >(PF_SHIFT_MAIN)},
|
||||||
|
{_SC("StatusMask"), static_cast< SQInteger >(PF_STATUS_MASK)},
|
||||||
|
{_SC("ClearDesktop"), static_cast< SQInteger >(PF_CLEAR_DESKTOP)},
|
||||||
|
{_SC("ClearWeb"), static_cast< SQInteger >(PF_CLEAR_WEB)},
|
||||||
|
{_SC("ClearMobile"), static_cast< SQInteger >(PF_CLEAR_MOBILE)},
|
||||||
|
{_SC("ClearStatus"), static_cast< SQInteger >(PF_CLEAR_STATUS)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpActivityTypeEnum[] = {
|
||||||
|
{_SC("Game"), static_cast< SQInteger >(dpp::at_game)},
|
||||||
|
{_SC("Streaming"), static_cast< SQInteger >(dpp::at_streaming)},
|
||||||
|
{_SC("Listening"), static_cast< SQInteger >(dpp::at_listening)},
|
||||||
|
{_SC("Custom"), static_cast< SQInteger >(dpp::at_custom)},
|
||||||
|
{_SC("Competing"), static_cast< SQInteger >(dpp::at_competing)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpActivityFlagsEnum[] = {
|
||||||
|
{_SC("Instance"), static_cast< SQInteger >(dpp::af_instance)},
|
||||||
|
{_SC("Join"), static_cast< SQInteger >(dpp::af_join)},
|
||||||
|
{_SC("Spectate"), static_cast< SQInteger >(dpp::af_spectate)},
|
||||||
|
{_SC("JoinRequest"), static_cast< SQInteger >(dpp::af_join_request)},
|
||||||
|
{_SC("Sync"), static_cast< SQInteger >(dpp::af_sync)},
|
||||||
|
{_SC("Play"), static_cast< SQInteger >(dpp::af_play)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpVoiceStateFlagsEnum[] = {
|
||||||
|
{_SC("Deaf"), static_cast< SQInteger >(dpp::vs_deaf)},
|
||||||
|
{_SC("Mute"), static_cast< SQInteger >(dpp::vs_mute)},
|
||||||
|
{_SC("SelfMute"), static_cast< SQInteger >(dpp::vs_self_mute)},
|
||||||
|
{_SC("SelfDeaf"), static_cast< SQInteger >(dpp::vs_self_deaf)},
|
||||||
|
{_SC("SelfStream"), static_cast< SQInteger >(dpp::vs_self_stream)},
|
||||||
|
{_SC("SelfVideo"), static_cast< SQInteger >(dpp::vs_self_video)},
|
||||||
|
{_SC("Suppress"), static_cast< SQInteger >(dpp::vs_suppress)},
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpRoleFlagsEnum[] = {
|
||||||
|
{_SC("Hoist"), static_cast< SQInteger >(dpp::r_hoist)},
|
||||||
|
{_SC("Managed"), static_cast< SQInteger >(dpp::r_managed)},
|
||||||
|
{_SC("Mentionable"), static_cast< SQInteger >(dpp::r_mentionable)},
|
||||||
|
{_SC("PremiumSubscriber"), static_cast< SQInteger >(dpp::r_premium_subscriber)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpRolePermissionsEnum[] = {
|
||||||
|
{_SC("CreateInstantInvite"), static_cast< SQInteger >(dpp::p_create_instant_invite)},
|
||||||
|
{_SC("KickMembers"), static_cast< SQInteger >(dpp::p_kick_members)},
|
||||||
|
{_SC("BanMembers"), static_cast< SQInteger >(dpp::p_ban_members)},
|
||||||
|
{_SC("Administrator"), static_cast< SQInteger >(dpp::p_administrator)},
|
||||||
|
{_SC("ManageChannels"), static_cast< SQInteger >(dpp::p_manage_channels)},
|
||||||
|
{_SC("ManageGuild"), static_cast< SQInteger >(dpp::p_manage_guild)},
|
||||||
|
{_SC("AddReactions"), static_cast< SQInteger >(dpp::p_add_reactions)},
|
||||||
|
{_SC("ViewAuditLog"), static_cast< SQInteger >(dpp::p_view_audit_log)},
|
||||||
|
{_SC("PrioritySpeaker"), static_cast< SQInteger >(dpp::p_priority_speaker)},
|
||||||
|
{_SC("Stream"), static_cast< SQInteger >(dpp::p_stream)},
|
||||||
|
{_SC("ViewChannel"), static_cast< SQInteger >(dpp::p_view_channel)},
|
||||||
|
{_SC("SendMessages"), static_cast< SQInteger >(dpp::p_send_messages)},
|
||||||
|
{_SC("SendTtsMessages"), static_cast< SQInteger >(dpp::p_send_tts_messages)},
|
||||||
|
{_SC("ManageMessages"), static_cast< SQInteger >(dpp::p_manage_messages)},
|
||||||
|
{_SC("EmbedLinks"), static_cast< SQInteger >(dpp::p_embed_links)},
|
||||||
|
{_SC("AttachFiles"), static_cast< SQInteger >(dpp::p_attach_files)},
|
||||||
|
{_SC("ReadMessageHistory"), static_cast< SQInteger >(dpp::p_read_message_history)},
|
||||||
|
{_SC("MentionEveryone"), static_cast< SQInteger >(dpp::p_mention_everyone)},
|
||||||
|
{_SC("UseExternalEmojis"), static_cast< SQInteger >(dpp::p_use_external_emojis)},
|
||||||
|
{_SC("ViewGuildInsights"), static_cast< SQInteger >(dpp::p_view_guild_insights)},
|
||||||
|
{_SC("Connect"), static_cast< SQInteger >(dpp::p_connect)},
|
||||||
|
{_SC("Speak"), static_cast< SQInteger >(dpp::p_speak)},
|
||||||
|
{_SC("MuteMembers"), static_cast< SQInteger >(dpp::p_mute_members)},
|
||||||
|
{_SC("DeafenMembers"), static_cast< SQInteger >(dpp::p_deafen_members)},
|
||||||
|
{_SC("MoveMembers"), static_cast< SQInteger >(dpp::p_move_members)},
|
||||||
|
{_SC("UseVAD"), static_cast< SQInteger >(dpp::p_use_vad)},
|
||||||
|
{_SC("ChangeNickname"), static_cast< SQInteger >(dpp::p_change_nickname)},
|
||||||
|
{_SC("ManageNicknames"), static_cast< SQInteger >(dpp::p_manage_nicknames)},
|
||||||
|
{_SC("ManageRoles"), static_cast< SQInteger >(dpp::p_manage_roles)},
|
||||||
|
{_SC("ManageWebHooks"), static_cast< SQInteger >(dpp::p_manage_webhooks)},
|
||||||
|
{_SC("ManageEmojis"), static_cast< SQInteger >(dpp::p_manage_emojis)},
|
||||||
|
{_SC("UseSlashCommands"), static_cast< SQInteger >(dpp::p_use_slash_commands)},
|
||||||
|
{_SC("RequestToSpeak"), static_cast< SQInteger >(dpp::p_request_to_speak)},
|
||||||
|
{_SC("ManageThreads"), static_cast< SQInteger >(dpp::p_manage_threads)},
|
||||||
|
{_SC("UsePublicThreads"), static_cast< SQInteger >(dpp::p_use_public_threads)},
|
||||||
|
{_SC("UsePrivateThreads"), static_cast< SQInteger >(dpp::p_use_private_threads)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpUserFlagsEnum[] = {
|
||||||
|
{_SC("Bot"), static_cast< SQInteger >(dpp::u_bot)},
|
||||||
|
{_SC("System"), static_cast< SQInteger >(dpp::u_system)},
|
||||||
|
{_SC("MfaEnabled"), static_cast< SQInteger >(dpp::u_mfa_enabled)},
|
||||||
|
{_SC("Verified"), static_cast< SQInteger >(dpp::u_verified)},
|
||||||
|
{_SC("NitroFull"), static_cast< SQInteger >(dpp::u_nitro_full)},
|
||||||
|
{_SC("NitroClassic"), static_cast< SQInteger >(dpp::u_nitro_classic)},
|
||||||
|
{_SC("DiscordEmployee"), static_cast< SQInteger >(dpp::u_discord_employee)},
|
||||||
|
{_SC("PartneredOwner"), static_cast< SQInteger >(dpp::u_partnered_owner)},
|
||||||
|
{_SC("HypesquadEvents"), static_cast< SQInteger >(dpp::u_hypesquad_events)},
|
||||||
|
{_SC("Bughunter1"), static_cast< SQInteger >(dpp::u_bughunter_1)},
|
||||||
|
{_SC("HouseBravery"), static_cast< SQInteger >(dpp::u_house_bravery)},
|
||||||
|
{_SC("HouseBrilliance"), static_cast< SQInteger >(dpp::u_house_brilliance)},
|
||||||
|
{_SC("HouseBalanace"), static_cast< SQInteger >(dpp::u_house_balanace)},
|
||||||
|
{_SC("EarlySupporter"), static_cast< SQInteger >(dpp::u_early_supporter)},
|
||||||
|
{_SC("TeamUser"), static_cast< SQInteger >(dpp::u_team_user)},
|
||||||
|
{_SC("Bughunter2"), static_cast< SQInteger >(dpp::u_bughunter_2)},
|
||||||
|
{_SC("VerifiedBot"), static_cast< SQInteger >(dpp::u_verified_bot)},
|
||||||
|
{_SC("VerifiedBotDev"), static_cast< SQInteger >(dpp::u_verified_bot_dev)},
|
||||||
|
{_SC("AnimatedIcon"), static_cast< SQInteger >(dpp::u_animated_icon)},
|
||||||
|
{_SC("CertifiedModerator"), static_cast< SQInteger >(dpp::u_certified_moderator)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpRegionEnum[] = {
|
||||||
|
{_SC("Brazil"), static_cast< SQInteger >(dpp::r_brazil)},
|
||||||
|
{_SC("CentralEurope"), static_cast< SQInteger >(dpp::r_central_europe)},
|
||||||
|
{_SC("HongKong"), static_cast< SQInteger >(dpp::r_hong_kong)},
|
||||||
|
{_SC("India"), static_cast< SQInteger >(dpp::r_india)},
|
||||||
|
{_SC("Japan"), static_cast< SQInteger >(dpp::r_japan)},
|
||||||
|
{_SC("Russia"), static_cast< SQInteger >(dpp::r_russia)},
|
||||||
|
{_SC("Singapore"), static_cast< SQInteger >(dpp::r_singapore)},
|
||||||
|
{_SC("SouthAfrica"), static_cast< SQInteger >(dpp::r_south_africa)},
|
||||||
|
{_SC("Sydney"), static_cast< SQInteger >(dpp::r_sydney)},
|
||||||
|
{_SC("UsCentral"), static_cast< SQInteger >(dpp::r_us_central)},
|
||||||
|
{_SC("UsEast"), static_cast< SQInteger >(dpp::r_us_east)},
|
||||||
|
{_SC("UsSouth"), static_cast< SQInteger >(dpp::r_us_south)},
|
||||||
|
{_SC("UsWest"), static_cast< SQInteger >(dpp::r_us_west)},
|
||||||
|
{_SC("WesternEurope"), static_cast< SQInteger >(dpp::r_western_europe)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpGuildFlagsEnum[] = {
|
||||||
|
{_SC("Large"), static_cast< SQInteger >(dpp::g_large)},
|
||||||
|
{_SC("Unavailable"), static_cast< SQInteger >(dpp::g_unavailable)},
|
||||||
|
{_SC("WidgetEnabled"), static_cast< SQInteger >(dpp::g_widget_enabled)},
|
||||||
|
{_SC("InviteSplash"), static_cast< SQInteger >(dpp::g_invite_splash)},
|
||||||
|
{_SC("VipRegions"), static_cast< SQInteger >(dpp::g_vip_regions)},
|
||||||
|
{_SC("VanityURL"), static_cast< SQInteger >(dpp::g_vanity_url)},
|
||||||
|
{_SC("Verified"), static_cast< SQInteger >(dpp::g_verified)},
|
||||||
|
{_SC("Partnered"), static_cast< SQInteger >(dpp::g_partnered)},
|
||||||
|
{_SC("Community"), static_cast< SQInteger >(dpp::g_community)},
|
||||||
|
{_SC("Commerce"), static_cast< SQInteger >(dpp::g_commerce)},
|
||||||
|
{_SC("News"), static_cast< SQInteger >(dpp::g_news)},
|
||||||
|
{_SC("Discoverable"), static_cast< SQInteger >(dpp::g_discoverable)},
|
||||||
|
{_SC("Featureable"), static_cast< SQInteger >(dpp::g_featureable)},
|
||||||
|
{_SC("AnimatedIcon"), static_cast< SQInteger >(dpp::g_animated_icon)},
|
||||||
|
{_SC("Banner"), static_cast< SQInteger >(dpp::g_banner)},
|
||||||
|
{_SC("WelcomeScreenEnabled"), static_cast< SQInteger >(dpp::g_welcome_screen_enabled)},
|
||||||
|
{_SC("MemberVerificationGate"), static_cast< SQInteger >(dpp::g_member_verification_gate)},
|
||||||
|
{_SC("PreviewEnabled"), static_cast< SQInteger >(dpp::g_preview_enabled)},
|
||||||
|
{_SC("NoJoinNotifications"), static_cast< SQInteger >(dpp::g_no_join_notifications)},
|
||||||
|
{_SC("NoBoostNotifications"), static_cast< SQInteger >(dpp::g_no_boost_notifications)},
|
||||||
|
{_SC("HasAnimatedIcon"), static_cast< SQInteger >(dpp::g_has_animated_icon)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpGuildMemberFlagsEnum[] = {
|
||||||
|
{_SC("Deaf"), static_cast< SQInteger >(dpp::gm_deaf)},
|
||||||
|
{_SC("Mute"), static_cast< SQInteger >(dpp::gm_mute)},
|
||||||
|
{_SC("Pending"), static_cast< SQInteger >(dpp::gm_pending)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpComponentTypeEnum[] = {
|
||||||
|
{_SC("ActionRow"), static_cast< SQInteger >(dpp::cot_action_row)},
|
||||||
|
{_SC("Button"), static_cast< SQInteger >(dpp::cot_button)},
|
||||||
|
{_SC("SelectMenu"), static_cast< SQInteger >(dpp::cot_selectmenu)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpComponentStyleEnum[] = {
|
||||||
|
{_SC("Primary"), static_cast< SQInteger >(dpp::cos_primary)},
|
||||||
|
{_SC("Secondary"), static_cast< SQInteger >(dpp::cos_secondary)},
|
||||||
|
{_SC("Success"), static_cast< SQInteger >(dpp::cos_success)},
|
||||||
|
{_SC("Danger"), static_cast< SQInteger >(dpp::cos_danger)},
|
||||||
|
{_SC("Link"), static_cast< SQInteger >(dpp::cos_link)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpStickerTypeEnum[] = {
|
||||||
|
{_SC("Standard"), static_cast< SQInteger >(dpp::st_standard)},
|
||||||
|
{_SC("Guild"), static_cast< SQInteger >(dpp::st_guild)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpStickerFormatEnum[] = {
|
||||||
|
{_SC("PNG"), static_cast< SQInteger >(dpp::sf_png)},
|
||||||
|
{_SC("APNG"), static_cast< SQInteger >(dpp::sf_apng)},
|
||||||
|
{_SC("Lottie"), static_cast< SQInteger >(dpp::sf_lottie)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpMessageFlagsEnum[] = {
|
||||||
|
{_SC("Crossposted"), static_cast< SQInteger >(dpp::m_crossposted)},
|
||||||
|
{_SC("IsCrosspost"), static_cast< SQInteger >(dpp::m_is_crosspost)},
|
||||||
|
{_SC("SuppressEmbeds"), static_cast< SQInteger >(dpp::m_suppress_embeds)},
|
||||||
|
{_SC("SourceMessageDeleted"), static_cast< SQInteger >(dpp::m_source_message_deleted)},
|
||||||
|
{_SC("Urgent"), static_cast< SQInteger >(dpp::m_urgent)},
|
||||||
|
{_SC("Ephemeral"), static_cast< SQInteger >(dpp::m_ephemeral)},
|
||||||
|
{_SC("Loading"), static_cast< SQInteger >(dpp::m_loading)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpMessageTypeEnum[] = {
|
||||||
|
{_SC("Default"), static_cast< SQInteger >(dpp::mt_default)},
|
||||||
|
{_SC("RecipientAdd"), static_cast< SQInteger >(dpp::mt_recipient_add)},
|
||||||
|
{_SC("RecipientRemove"), static_cast< SQInteger >(dpp::mt_recipient_remove)},
|
||||||
|
{_SC("Call"), static_cast< SQInteger >(dpp::mt_call)},
|
||||||
|
{_SC("ChannelNameChange"), static_cast< SQInteger >(dpp::mt_channel_name_change)},
|
||||||
|
{_SC("ChannelIconChange"), static_cast< SQInteger >(dpp::mt_channel_icon_change)},
|
||||||
|
{_SC("ChannelPinnedMessage"), static_cast< SQInteger >(dpp::mt_channel_pinned_message)},
|
||||||
|
{_SC("GuildMemberJoin"), static_cast< SQInteger >(dpp::mt_guild_member_join)},
|
||||||
|
{_SC("UserPremiumGuildSubscription"), static_cast< SQInteger >(dpp::mt_user_premium_guild_subscription)},
|
||||||
|
{_SC("UserPremiumGuildSubscriptionTier1"), static_cast< SQInteger >(dpp::mt_user_premium_guild_subscription_tier_1)},
|
||||||
|
{_SC("UserPremiumGuildSubscriptionTier2"), static_cast< SQInteger >(dpp::mt_user_premium_guild_subscription_tier_2)},
|
||||||
|
{_SC("UserPremiumGuildSubscriptionTier3"), static_cast< SQInteger >(dpp::mt_user_premium_guild_subscription_tier_3)},
|
||||||
|
{_SC("ChannelFollowAdd"), static_cast< SQInteger >(dpp::mt_channel_follow_add)},
|
||||||
|
{_SC("GuildDiscoveryDisqualified"), static_cast< SQInteger >(dpp::mt_guild_discovery_disqualified)},
|
||||||
|
{_SC("GuildDiscoveryRequalified"), static_cast< SQInteger >(dpp::mt_guild_discovery_requalified)},
|
||||||
|
{_SC("GuildDiscoveryGracePeriodInitialWarning"), static_cast< SQInteger >(dpp::mt_guild_discovery_grace_period_initial_warning)},
|
||||||
|
{_SC("GuildDiscoveryGracePeriodFinalWarning"), static_cast< SQInteger >(dpp::mt_guild_discovery_grace_period_final_warning)},
|
||||||
|
{_SC("ThreadCreated"), static_cast< SQInteger >(dpp::mt_thread_created)},
|
||||||
|
{_SC("Reply"), static_cast< SQInteger >(dpp::mt_reply)},
|
||||||
|
{_SC("ApplicationCommand"), static_cast< SQInteger >(dpp::mt_application_command)},
|
||||||
|
{_SC("ThreadStarterMessage"), static_cast< SQInteger >(dpp::mt_thread_starter_message)},
|
||||||
|
{_SC("GuildInviteReminder"), static_cast< SQInteger >(dpp::mt_guild_invite_reminder)}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElements g_EnumList[] = {
|
||||||
|
{_SC("SqDiscordLogLevel"), g_DpLogLevelEnum},
|
||||||
|
{_SC("SqDiscordImageType"), g_DpImageTypeEnum},
|
||||||
|
{_SC("SqDiscordCachePolicy"), g_DpCachePolicyEnum},
|
||||||
|
{_SC("SqDiscordClusterIntents"), g_DpClusterIntentsEnum},
|
||||||
|
{_SC("SqDiscordPresenceFlags"), g_DpPresenceFlagsEnum},
|
||||||
|
{_SC("SqDiscordPresenceStatus"), g_DpPresenceStatusEnum},
|
||||||
|
{_SC("SqDiscordDesktopStatusBits"), g_DpDesktopStatusBitsEnum},
|
||||||
|
{_SC("SqDiscordActivityType"), g_DpActivityTypeEnum},
|
||||||
|
{_SC("SqDiscordActivityFlags"), g_DpActivityFlagsEnum},
|
||||||
|
{_SC("SqDiscordVoiceStateFlags"), g_DpVoiceStateFlagsEnum},
|
||||||
|
{_SC("SqDiscordRoleFlags"), g_DpRoleFlagsEnum},
|
||||||
|
{_SC("SqDiscordRolePermissions"), g_DpRolePermissionsEnum},
|
||||||
|
{_SC("SqDiscordUserFlags"), g_DpUserFlagsEnum},
|
||||||
|
{_SC("SqDiscordRegion"), g_DpRegionEnum},
|
||||||
|
{_SC("SqDiscordGuildFlags"), g_DpGuildFlagsEnum},
|
||||||
|
{_SC("SqDiscordGuildMemberFlags"), g_DpGuildMemberFlagsEnum},
|
||||||
|
{_SC("SqDiscordComponentType"), g_DpComponentTypeEnum},
|
||||||
|
{_SC("SqDiscordComponentStyle"), g_DpComponentStyleEnum},
|
||||||
|
{_SC("SqDiscordStickerType"), g_DpStickerTypeEnum},
|
||||||
|
{_SC("SqDiscordStickerFormat"), g_DpStickerFormatEnum},
|
||||||
|
{_SC("SqDiscordMessageFlags"), g_DpMessageFlagsEnum},
|
||||||
|
{_SC("SqDiscordMessageType"), g_DpMessageTypeEnum}
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Constants(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
RegisterEnumerations(vm, g_EnumList);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
Enumeration e(vm);
|
||||||
|
// Bind all events using their associated name
|
||||||
|
for (SQInteger i = 0; i < static_cast< SQInteger >(DpEventID::Max); ++i)
|
||||||
|
{
|
||||||
|
e.Const(DpEventID::NAME[i], i);
|
||||||
|
}
|
||||||
|
// Expose the constants
|
||||||
|
ConstTable(vm).Enum(_SC("SqDiscordEvent"), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Unique ID for each event.
|
||||||
|
*/
|
||||||
|
struct DpEventID
|
||||||
|
{
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* ID enumeration.
|
||||||
|
*/
|
||||||
|
enum Type
|
||||||
|
{
|
||||||
|
VoiceStateUpdate=0,
|
||||||
|
Log,
|
||||||
|
GuildJoinRequestDelete,
|
||||||
|
InteractionCreate,
|
||||||
|
ButtonClick,
|
||||||
|
SelectClick,
|
||||||
|
GuildDelete,
|
||||||
|
ChannelDelete,
|
||||||
|
ChannelUpdate,
|
||||||
|
Ready,
|
||||||
|
MessageDelete,
|
||||||
|
ApplicationCommandDelete,
|
||||||
|
GuildMemberRemove,
|
||||||
|
ApplicationCommandCreate,
|
||||||
|
Resumed,
|
||||||
|
GuildRoleCreate,
|
||||||
|
TypingStart,
|
||||||
|
MessageReactionAdd,
|
||||||
|
GuildMembersChunk,
|
||||||
|
MessageReactionRemove,
|
||||||
|
GuildCreate,
|
||||||
|
ChannelCreate,
|
||||||
|
MessageReactionRemoveEmoji,
|
||||||
|
MessageDeleteBulk,
|
||||||
|
GuildRoleUpdate,
|
||||||
|
GuildRoleDelete,
|
||||||
|
ChannelPinsUpdate,
|
||||||
|
MessageReactionRemoveAll,
|
||||||
|
VoiceServerUpdate,
|
||||||
|
GuildEmojisUpdate,
|
||||||
|
GuildStickersUpdate,
|
||||||
|
PresenceUpdate,
|
||||||
|
WebhooksUpdate,
|
||||||
|
GuildMemberAdd,
|
||||||
|
InviteDelete,
|
||||||
|
GuildUpdate,
|
||||||
|
GuildIntegrationsUpdate,
|
||||||
|
GuildMemberUpdate,
|
||||||
|
ApplicationCommandUpdate,
|
||||||
|
InviteCreate,
|
||||||
|
MessageUpdate,
|
||||||
|
UserUpdate,
|
||||||
|
MessageCreate,
|
||||||
|
GuildBanAdd,
|
||||||
|
GuildBanRemove,
|
||||||
|
IntegrationCreate,
|
||||||
|
IntegrationUpdate,
|
||||||
|
IntegrationDelete,
|
||||||
|
ThreadCreate,
|
||||||
|
ThreadUpdate,
|
||||||
|
ThreadDelete,
|
||||||
|
ThreadListSync,
|
||||||
|
ThreadMemberUpdate,
|
||||||
|
ThreadMembersUpdate,
|
||||||
|
VoiceBufferSend,
|
||||||
|
VoiceUserTalking,
|
||||||
|
VoiceReady,
|
||||||
|
VoiceReceive,
|
||||||
|
VoiceTrackMarker,
|
||||||
|
StageInstanceCreate,
|
||||||
|
StageInstanceDelete,
|
||||||
|
Max
|
||||||
|
};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* String identification for each event ID.
|
||||||
|
*/
|
||||||
|
static const std::array< const char *, static_cast< size_t >(Max) > NAME;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,630 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Events.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppVoiceStateUpdateEvent, _SC("SqDppVoiceStateUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppLogEvent, _SC("SqDppLogEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildJoinRequestDeleteEvent, _SC("SqDppGuildJoinRequestDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppInteractionCreateEvent, _SC("SqDppInteractionCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppButtonClickEvent, _SC("SqDppButtonClickEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppSelectClickEvent, _SC("SqDppSelectClickEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildDeleteEvent, _SC("SqDppGuildDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppChannelDeleteEvent, _SC("SqDppChannelDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppChannelUpdateEvent, _SC("SqDppChannelUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppReadyEvent, _SC("SqDppReadyEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppMessageDeleteEvent, _SC("SqDppMessageDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppApplicationCommandDeleteEvent, _SC("SqDppApplicationCommandDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildMemberRemoveEvent, _SC("SqDppGuildMemberRemoveEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppApplicationCommandCreateEvent, _SC("SqDppApplicationCommandCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppResumedEvent, _SC("SqDppResumedEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildRoleCreateEvent, _SC("SqDppGuildRoleCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppTypingStartEvent, _SC("SqDppTypingStartEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppMessageReactionAddEvent, _SC("SqDppMessageReactionAddEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildMembersChunkEvent, _SC("SqDppGuildMembersChunkEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppMessageReactionRemoveEvent, _SC("SqDppMessageReactionRemoveEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildCreateEvent, _SC("SqDppGuildCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppChannelCreateEvent, _SC("SqDppChannelCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppMessageReactionRemoveEmojiEvent, _SC("SqDppMessageReactionRemoveEmojiEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppMessageDeleteBulkEvent, _SC("SqDppMessageDeleteBulkEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildRoleUpdateEvent, _SC("SqDppGuildRoleUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildRoleDeleteEvent, _SC("SqDppGuildRoleDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppChannelPinsUpdateEvent, _SC("SqDppChannelPinsUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppMessageReactionRemoveAllEvent, _SC("SqDppMessageReactionRemoveAllEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppVoiceServerUpdateEvent, _SC("SqDppVoiceServerUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildEmojisUpdateEvent, _SC("SqDppGuildEmojisUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildStickersUpdateEvent, _SC("SqDppGuildStickersUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppPresenceUpdateEvent, _SC("SqDppPresenceUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppWebhooksUpdateEvent, _SC("SqDppWebhooksUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildMemberAddEvent, _SC("SqDppGuildMemberAddEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppInviteDeleteEvent, _SC("SqDppInviteDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildUpdateEvent, _SC("SqDppGuildUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildIntegrationsUpdateEvent, _SC("SqDppGuildIntegrationsUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildMemberUpdateEvent, _SC("SqDppGuildMemberUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppApplicationCommandUpdateEvent, _SC("SqDppApplicationCommandUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppInviteCreateEvent, _SC("SqDppInviteCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppMessageUpdateEvent, _SC("SqDppMessageUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppUserUpdateEvent, _SC("SqDppUserUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppMessageCreateEvent, _SC("SqDppMessageCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildBanAddEvent, _SC("SqDppGuildBanAddEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildBanRemoveEvent, _SC("SqDppGuildBanRemoveEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppIntegrationCreateEvent, _SC("SqDppIntegrationCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppIntegrationUpdateEvent, _SC("SqDppIntegrationUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppIntegrationDeleteEvent, _SC("SqDppIntegrationDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppThreadCreateEvent, _SC("SqDppThreadCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppThreadUpdateEvent, _SC("SqDppThreadUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppThreadDeleteEvent, _SC("SqDppThreadDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppThreadListSyncEvent, _SC("SqDppThreadListSyncEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppThreadMemberUpdateEvent, _SC("SqDppThreadMemberUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppThreadMembersUpdateEvent, _SC("SqDppThreadMembersUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppVoiceBufferSendEvent, _SC("SqDppVoiceBufferSendEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppVoiceUserTalkingEvent, _SC("SqDppVoiceUserTalkingEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppVoiceReadyEvent, _SC("SqDppVoiceReadyEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppVoiceReceiveEvent, _SC("SqDppVoiceReceiveEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppVoiceTrackMarkerEvent, _SC("SqDppVoiceTrackMarkerEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppStageInstanceCreateEvent, _SC("SqDppStageInstanceCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppStageInstanceDeleteEvent, _SC("SqDppStageInstanceDeleteEvent"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Events(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceStateUpdate"),
|
||||||
|
Class< DpVoiceStateUpdateEvent, NoConstructor< DpVoiceStateUpdateEvent > >(vm, SqDppVoiceStateUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppVoiceStateUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceStateUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("State"), &DpVoiceStateUpdateEvent::GetState)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Log"),
|
||||||
|
Class< DpLogEvent, NoConstructor< DpLogEvent > >(vm, SqDppLogEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppLogEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpLogEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpLogEvent::GetRawEvent)
|
||||||
|
.Prop(_SC("Severity"), &DpLogEvent::GetSeverity)
|
||||||
|
.Prop(_SC("Message"), &DpLogEvent::GetMessage)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildJoinRequestDelete"),
|
||||||
|
Class< DpGuildJoinRequestDeleteEvent, NoConstructor< DpGuildJoinRequestDeleteEvent > >(vm, SqDppGuildJoinRequestDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildJoinRequestDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildJoinRequestDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildJoinRequestDeleteEvent::GetRawEvent)
|
||||||
|
.Prop(_SC("GuildID"), &DpGuildJoinRequestDeleteEvent::GetGuildID)
|
||||||
|
.Prop(_SC("UserID"), &DpGuildJoinRequestDeleteEvent::GetUserID)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("InteractionCreate"),
|
||||||
|
Class< DpInteractionCreateEvent, NoConstructor< DpInteractionCreateEvent > >(vm, SqDppInteractionCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppInteractionCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpInteractionCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpInteractionCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ButtonClick"),
|
||||||
|
Class< DpButtonClickEvent, NoConstructor< DpButtonClickEvent > >(vm, SqDppButtonClickEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppButtonClickEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpButtonClickEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpButtonClickEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("SelectClick"),
|
||||||
|
Class< DpSelectClickEvent, NoConstructor< DpSelectClickEvent > >(vm, SqDppSelectClickEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppSelectClickEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpSelectClickEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpSelectClickEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildDelete"),
|
||||||
|
Class< DpGuildDeleteEvent, NoConstructor< DpGuildDeleteEvent > >(vm, SqDppGuildDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ChannelDelete"),
|
||||||
|
Class< DpChannelDeleteEvent, NoConstructor< DpChannelDeleteEvent > >(vm, SqDppChannelDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppChannelDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpChannelDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpChannelDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ChannelUpdate"),
|
||||||
|
Class< DpChannelUpdateEvent, NoConstructor< DpChannelUpdateEvent > >(vm, SqDppChannelUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppChannelUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpChannelUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpChannelUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Ready"),
|
||||||
|
Class< DpReadyEvent, NoConstructor< DpReadyEvent > >(vm, SqDppReadyEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppReadyEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpReadyEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpReadyEvent::GetRawEvent)
|
||||||
|
.Prop(_SC("SessionID"), &DpReadyEvent::GetSessionID)
|
||||||
|
.Prop(_SC("ShardID"), &DpReadyEvent::GetShardID)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageDelete"),
|
||||||
|
Class< DpMessageDeleteEvent, NoConstructor< DpMessageDeleteEvent > >(vm, SqDppMessageDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppMessageDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpMessageDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ApplicationCommandDelete"),
|
||||||
|
Class< DpApplicationCommandDeleteEvent, NoConstructor< DpApplicationCommandDeleteEvent > >(vm, SqDppApplicationCommandDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppApplicationCommandDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpApplicationCommandDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpApplicationCommandDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildMemberRemove"),
|
||||||
|
Class< DpGuildMemberRemoveEvent, NoConstructor< DpGuildMemberRemoveEvent > >(vm, SqDppGuildMemberRemoveEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildMemberRemoveEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildMemberRemoveEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildMemberRemoveEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ApplicationCommandCreate"),
|
||||||
|
Class< DpApplicationCommandCreateEvent, NoConstructor< DpApplicationCommandCreateEvent > >(vm, SqDppApplicationCommandCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppApplicationCommandCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpApplicationCommandCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpApplicationCommandCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Resumed"),
|
||||||
|
Class< DpResumedEvent, NoConstructor< DpResumedEvent > >(vm, SqDppResumedEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppResumedEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpResumedEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpResumedEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildRoleCreate"),
|
||||||
|
Class< DpGuildRoleCreateEvent, NoConstructor< DpGuildRoleCreateEvent > >(vm, SqDppGuildRoleCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildRoleCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildRoleCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildRoleCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("TypingStart"),
|
||||||
|
Class< DpTypingStartEvent, NoConstructor< DpTypingStartEvent > >(vm, SqDppTypingStartEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppTypingStartEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpTypingStartEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpTypingStartEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageReactionAdd"),
|
||||||
|
Class< DpMessageReactionAddEvent, NoConstructor< DpMessageReactionAddEvent > >(vm, SqDppMessageReactionAddEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppMessageReactionAddEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageReactionAddEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpMessageReactionAddEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildMembersChunk"),
|
||||||
|
Class< DpGuildMembersChunkEvent, NoConstructor< DpGuildMembersChunkEvent > >(vm, SqDppGuildMembersChunkEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildMembersChunkEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildMembersChunkEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildMembersChunkEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageReactionRemove"),
|
||||||
|
Class< DpMessageReactionRemoveEvent, NoConstructor< DpMessageReactionRemoveEvent > >(vm, SqDppMessageReactionRemoveEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppMessageReactionRemoveEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageReactionRemoveEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpMessageReactionRemoveEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildCreate"),
|
||||||
|
Class< DpGuildCreateEvent, NoConstructor< DpGuildCreateEvent > >(vm, SqDppGuildCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ChannelCreate"),
|
||||||
|
Class< DpChannelCreateEvent, NoConstructor< DpChannelCreateEvent > >(vm, SqDppChannelCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppChannelCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpChannelCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpChannelCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageReactionRemoveEmoji"),
|
||||||
|
Class< DpMessageReactionRemoveEmojiEvent, NoConstructor< DpMessageReactionRemoveEmojiEvent > >(vm, SqDppMessageReactionRemoveEmojiEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppMessageReactionRemoveEmojiEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageReactionRemoveEmojiEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpMessageReactionRemoveEmojiEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageDeleteBulk"),
|
||||||
|
Class< DpMessageDeleteBulkEvent, NoConstructor< DpMessageDeleteBulkEvent > >(vm, SqDppMessageDeleteBulkEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppMessageDeleteBulkEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageDeleteBulkEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpMessageDeleteBulkEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildRoleUpdate"),
|
||||||
|
Class< DpGuildRoleUpdateEvent, NoConstructor< DpGuildRoleUpdateEvent > >(vm, SqDppGuildRoleUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildRoleUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildRoleUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildRoleUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildRoleDelete"),
|
||||||
|
Class< DpGuildRoleDeleteEvent, NoConstructor< DpGuildRoleDeleteEvent > >(vm, SqDppGuildRoleDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildRoleDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildRoleDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildRoleDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ChannelPinsUpdate"),
|
||||||
|
Class< DpChannelPinsUpdateEvent, NoConstructor< DpChannelPinsUpdateEvent > >(vm, SqDppChannelPinsUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppChannelPinsUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpChannelPinsUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpChannelPinsUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageReactionRemoveAll"),
|
||||||
|
Class< DpMessageReactionRemoveAllEvent, NoConstructor< DpMessageReactionRemoveAllEvent > >(vm, SqDppMessageReactionRemoveAllEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppMessageReactionRemoveAllEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageReactionRemoveAllEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpMessageReactionRemoveAllEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceServerUpdate"),
|
||||||
|
Class< DpVoiceServerUpdateEvent, NoConstructor< DpVoiceServerUpdateEvent > >(vm, SqDppVoiceServerUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppVoiceServerUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceServerUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpVoiceServerUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildEmojisUpdate"),
|
||||||
|
Class< DpGuildEmojisUpdateEvent, NoConstructor< DpGuildEmojisUpdateEvent > >(vm, SqDppGuildEmojisUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildEmojisUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildEmojisUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildEmojisUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildStickersUpdate"),
|
||||||
|
Class< DpGuildStickersUpdateEvent, NoConstructor< DpGuildStickersUpdateEvent > >(vm, SqDppGuildStickersUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildStickersUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildStickersUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildStickersUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("PresenceUpdate"),
|
||||||
|
Class< DpPresenceUpdateEvent, NoConstructor< DpPresenceUpdateEvent > >(vm, SqDppPresenceUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppPresenceUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpPresenceUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpPresenceUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("WebhooksUpdate"),
|
||||||
|
Class< DpWebhooksUpdateEvent, NoConstructor< DpWebhooksUpdateEvent > >(vm, SqDppWebhooksUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppWebhooksUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpWebhooksUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpWebhooksUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildMemberAdd"),
|
||||||
|
Class< DpGuildMemberAddEvent, NoConstructor< DpGuildMemberAddEvent > >(vm, SqDppGuildMemberAddEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildMemberAddEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildMemberAddEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildMemberAddEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("InviteDelete"),
|
||||||
|
Class< DpInviteDeleteEvent, NoConstructor< DpInviteDeleteEvent > >(vm, SqDppInviteDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppInviteDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpInviteDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpInviteDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildUpdate"),
|
||||||
|
Class< DpGuildUpdateEvent, NoConstructor< DpGuildUpdateEvent > >(vm, SqDppGuildUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildIntegrationsUpdate"),
|
||||||
|
Class< DpGuildIntegrationsUpdateEvent, NoConstructor< DpGuildIntegrationsUpdateEvent > >(vm, SqDppGuildIntegrationsUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildIntegrationsUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildIntegrationsUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildIntegrationsUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildMemberUpdate"),
|
||||||
|
Class< DpGuildMemberUpdateEvent, NoConstructor< DpGuildMemberUpdateEvent > >(vm, SqDppGuildMemberUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildMemberUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildMemberUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildMemberUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ApplicationCommandUpdate"),
|
||||||
|
Class< DpApplicationCommandUpdateEvent, NoConstructor< DpApplicationCommandUpdateEvent > >(vm, SqDppApplicationCommandUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppApplicationCommandUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpApplicationCommandUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpApplicationCommandUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("InviteCreate"),
|
||||||
|
Class< DpInviteCreateEvent, NoConstructor< DpInviteCreateEvent > >(vm, SqDppInviteCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppInviteCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpInviteCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpInviteCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageUpdate"),
|
||||||
|
Class< DpMessageUpdateEvent, NoConstructor< DpMessageUpdateEvent > >(vm, SqDppMessageUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppMessageUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpMessageUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("UserUpdate"),
|
||||||
|
Class< DpUserUpdateEvent, NoConstructor< DpUserUpdateEvent > >(vm, SqDppUserUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppUserUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpUserUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpUserUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageCreate"),
|
||||||
|
Class< DpMessageCreateEvent, NoConstructor< DpMessageCreateEvent > >(vm, SqDppMessageCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppMessageCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpMessageCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildBanAdd"),
|
||||||
|
Class< DpGuildBanAddEvent, NoConstructor< DpGuildBanAddEvent > >(vm, SqDppGuildBanAddEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildBanAddEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildBanAddEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildBanAddEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildBanRemove"),
|
||||||
|
Class< DpGuildBanRemoveEvent, NoConstructor< DpGuildBanRemoveEvent > >(vm, SqDppGuildBanRemoveEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildBanRemoveEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildBanRemoveEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpGuildBanRemoveEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("IntegrationCreate"),
|
||||||
|
Class< DpIntegrationCreateEvent, NoConstructor< DpIntegrationCreateEvent > >(vm, SqDppIntegrationCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppIntegrationCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpIntegrationCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpIntegrationCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("IntegrationUpdate"),
|
||||||
|
Class< DpIntegrationUpdateEvent, NoConstructor< DpIntegrationUpdateEvent > >(vm, SqDppIntegrationUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppIntegrationUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpIntegrationUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpIntegrationUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("IntegrationDelete"),
|
||||||
|
Class< DpIntegrationDeleteEvent, NoConstructor< DpIntegrationDeleteEvent > >(vm, SqDppIntegrationDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppIntegrationDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpIntegrationDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpIntegrationDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ThreadCreate"),
|
||||||
|
Class< DpThreadCreateEvent, NoConstructor< DpThreadCreateEvent > >(vm, SqDppThreadCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppThreadCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpThreadCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpThreadCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ThreadUpdate"),
|
||||||
|
Class< DpThreadUpdateEvent, NoConstructor< DpThreadUpdateEvent > >(vm, SqDppThreadUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppThreadUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpThreadUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpThreadUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ThreadDelete"),
|
||||||
|
Class< DpThreadDeleteEvent, NoConstructor< DpThreadDeleteEvent > >(vm, SqDppThreadDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppThreadDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpThreadDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpThreadDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ThreadListSync"),
|
||||||
|
Class< DpThreadListSyncEvent, NoConstructor< DpThreadListSyncEvent > >(vm, SqDppThreadListSyncEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppThreadListSyncEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpThreadListSyncEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpThreadListSyncEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ThreadMemberUpdate"),
|
||||||
|
Class< DpThreadMemberUpdateEvent, NoConstructor< DpThreadMemberUpdateEvent > >(vm, SqDppThreadMemberUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppThreadMemberUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpThreadMemberUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpThreadMemberUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ThreadMembersUpdate"),
|
||||||
|
Class< DpThreadMembersUpdateEvent, NoConstructor< DpThreadMembersUpdateEvent > >(vm, SqDppThreadMembersUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppThreadMembersUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpThreadMembersUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpThreadMembersUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceBufferSend"),
|
||||||
|
Class< DpVoiceBufferSendEvent, NoConstructor< DpVoiceBufferSendEvent > >(vm, SqDppVoiceBufferSendEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppVoiceBufferSendEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceBufferSendEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpVoiceBufferSendEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceUserTalking"),
|
||||||
|
Class< DpVoiceUserTalkingEvent, NoConstructor< DpVoiceUserTalkingEvent > >(vm, SqDppVoiceUserTalkingEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppVoiceUserTalkingEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceUserTalkingEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpVoiceUserTalkingEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceReady"),
|
||||||
|
Class< DpVoiceReadyEvent, NoConstructor< DpVoiceReadyEvent > >(vm, SqDppVoiceReadyEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppVoiceReadyEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceReadyEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpVoiceReadyEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceReceive"),
|
||||||
|
Class< DpVoiceReceiveEvent, NoConstructor< DpVoiceReceiveEvent > >(vm, SqDppVoiceReceiveEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppVoiceReceiveEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceReceiveEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpVoiceReceiveEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceTrackMarker"),
|
||||||
|
Class< DpVoiceTrackMarkerEvent, NoConstructor< DpVoiceTrackMarkerEvent > >(vm, SqDppVoiceTrackMarkerEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppVoiceTrackMarkerEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceTrackMarkerEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpVoiceTrackMarkerEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("StageInstanceCreate"),
|
||||||
|
Class< DpStageInstanceCreateEvent, NoConstructor< DpStageInstanceCreateEvent > >(vm, SqDppStageInstanceCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppStageInstanceCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpStageInstanceCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpStageInstanceCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("StageInstanceDelete"),
|
||||||
|
Class< DpStageInstanceDeleteEvent, NoConstructor< DpStageInstanceDeleteEvent > >(vm, SqDppStageInstanceDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppStageInstanceDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpStageInstanceDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("RawEvent"), &DpStageInstanceDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,146 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Guild.hpp"
|
||||||
|
#include "Library/DPP/Other.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuildMember, _SC("SqDppGuildMember"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppGuild, _SC("SqDppGuild"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Table DpGuild::GetMembers() const
|
||||||
|
{
|
||||||
|
Table t(SqVM(), static_cast< SQInteger >(Valid().members.size()));
|
||||||
|
// Attempt to convert the [members] associative container into a script table
|
||||||
|
const auto r = t.InsertFromMapWith(mPtr->members, [](HSQUIRRELVM vm, auto id, auto & m) -> SQRESULT {
|
||||||
|
// The [id] is a dpp::snowflake which is basically a uint64_t so let's leave that as is
|
||||||
|
sq_pushinteger(vm, static_cast< SQInteger >(id));
|
||||||
|
// Wrap the dpp::guild_member type into a DpGuildMember instance
|
||||||
|
ClassType< DpGuildMember >::PushInstance(vm, new DpGuildMember(m));
|
||||||
|
// The elements are now on the stack and can be inserted in the table
|
||||||
|
return SQ_OK;
|
||||||
|
});
|
||||||
|
// Did anything fail?
|
||||||
|
if (SQ_FAILED(r))
|
||||||
|
{
|
||||||
|
STHROWF("Unable to convert [members] container");
|
||||||
|
}
|
||||||
|
// Return the resulted table
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
Table DpGuild::GetVoiceMembers() const
|
||||||
|
{
|
||||||
|
Table t(SqVM(), static_cast< SQInteger >(Valid().voice_members.size()));
|
||||||
|
// Attempt to convert the [voice_members] associative container into a script table
|
||||||
|
const auto r = t.InsertFromMapWith(mPtr->voice_members, [](HSQUIRRELVM vm, auto id, auto & m) -> SQRESULT {
|
||||||
|
// The [id] is a dpp::snowflake which is basically a uint64_t so let's leave that as is
|
||||||
|
sq_pushinteger(vm, static_cast< SQInteger >(id));
|
||||||
|
// Wrap the dpp::guild_member type into a DpGuildMember instance
|
||||||
|
ClassType< DpVoiceState >::PushInstance(vm, new DpVoiceState(m));
|
||||||
|
// The elements are now on the stack and can be inserted in the table
|
||||||
|
return SQ_OK;
|
||||||
|
});
|
||||||
|
// Did anything fail?
|
||||||
|
if (SQ_FAILED(r))
|
||||||
|
{
|
||||||
|
STHROWF("Unable to convert [voice_members] container");
|
||||||
|
}
|
||||||
|
// Return the resulted table
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Guild(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
ns.Bind(_SC("GuildMember"),
|
||||||
|
Class< DpGuildMember, NoConstructor< DpGuildMember > >(vm, SqDppGuildMember::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuildMember::Fn)
|
||||||
|
.Func(_SC("_tojson"), &DpGuildMember::BuildJSON)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpGuildMember::IsValid)
|
||||||
|
.Prop(_SC("JSON"), &DpGuildMember::BuildJSON)
|
||||||
|
.Prop(_SC("Nickname"), &DpGuildMember::GetNickname)
|
||||||
|
.Prop(_SC("GuildID"), &DpGuildMember::GetGuildID)
|
||||||
|
.Prop(_SC("UserID"), &DpGuildMember::GetUserID)
|
||||||
|
.Prop(_SC("JoinedAt"), &DpGuildMember::GetJoinedAt)
|
||||||
|
.Prop(_SC("PremiumSince"), &DpGuildMember::GetPremiumSince)
|
||||||
|
.Prop(_SC("Flags"), &DpGuildMember::GetFlags)
|
||||||
|
.Prop(_SC("IsDeaf"), &DpGuildMember::IsDeaf)
|
||||||
|
.Prop(_SC("IsMuted"), &DpGuildMember::IsMuted)
|
||||||
|
.Prop(_SC("IsPending"), &DpGuildMember::IsPending)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("GetRoles"), &DpGuildMember::GetRoles)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Guild"),
|
||||||
|
Class< DpGuild, NoConstructor< DpGuild > >(vm, SqDppGuild::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppGuild::Fn)
|
||||||
|
.Func(_SC("_tojson"), &DpGuild::BuildJSON)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpGuild::IsValid)
|
||||||
|
.Prop(_SC("JSON"), &DpGuild::BuildJSON)
|
||||||
|
.Prop(_SC("ShardID"), &DpGuild::GetShardID)
|
||||||
|
.Prop(_SC("Flags"), &DpGuild::GetFlags)
|
||||||
|
.Prop(_SC("Name"), &DpGuild::GetName)
|
||||||
|
.Prop(_SC("Description"), &DpGuild::GetDescription)
|
||||||
|
.Prop(_SC("VanityUrlCode"), &DpGuild::GetVanityUrlCode)
|
||||||
|
.Prop(_SC("Icon"), &DpGuild::GetIcon)
|
||||||
|
.Prop(_SC("Splash"), &DpGuild::GetSplash)
|
||||||
|
.Prop(_SC("DiscoverySplash"), &DpGuild::GetDiscoverySplash)
|
||||||
|
.Prop(_SC("OwnerID"), &DpGuild::GetOwnerID)
|
||||||
|
.Prop(_SC("VoiceRegion"), &DpGuild::GetVoiceRegion)
|
||||||
|
.Prop(_SC("AfkChannelID"), &DpGuild::GetAfkChannelID)
|
||||||
|
.Prop(_SC("AfkTimeout"), &DpGuild::GetAfkTimeout)
|
||||||
|
.Prop(_SC("WidgetChannelID"), &DpGuild::GetWidgetChannelID)
|
||||||
|
.Prop(_SC("VerificationLevel"), &DpGuild::GetVerificationLevel)
|
||||||
|
.Prop(_SC("DefaultMessageNotifications"), &DpGuild::GetDefaultMessageNotifications)
|
||||||
|
.Prop(_SC("ExplicitContentFilter"), &DpGuild::GetExplicitContentFilter)
|
||||||
|
.Prop(_SC("MfaLevel"), &DpGuild::GetMfaLevel)
|
||||||
|
.Prop(_SC("ApplicationID"), &DpGuild::GetApplicationID)
|
||||||
|
.Prop(_SC("SystemChannelID"), &DpGuild::GetSystemChannelID)
|
||||||
|
.Prop(_SC("RulesChannelID"), &DpGuild::GetRulesChannelID)
|
||||||
|
.Prop(_SC("MemberCount"), &DpGuild::GetMemberCount)
|
||||||
|
.Prop(_SC("Banner"), &DpGuild::GetBanner)
|
||||||
|
.Prop(_SC("PremiumTier"), &DpGuild::GetPremiumTier)
|
||||||
|
.Prop(_SC("PremiumSubscriptionCount"), &DpGuild::GetPremiumSubscriptionCount)
|
||||||
|
.Prop(_SC("PublicUpdatesChannelID"), &DpGuild::GetPublicUpdatesChannelID)
|
||||||
|
.Prop(_SC("MaxVideoChannelUsers"), &DpGuild::GetMaxVideoChannelUsers)
|
||||||
|
.Prop(_SC("IsLarge"), &DpGuild::IsLarge)
|
||||||
|
.Prop(_SC("IsUnavailable"), &DpGuild::IsUnavailable)
|
||||||
|
.Prop(_SC("WidgetEnabled"), &DpGuild::WidgetEnabled)
|
||||||
|
.Prop(_SC("HasInviteSplash"), &DpGuild::HasInviteSplash)
|
||||||
|
.Prop(_SC("HasVipRegions"), &DpGuild::HasVipRegions)
|
||||||
|
.Prop(_SC("HasVanityURL"), &DpGuild::HasVanityURL)
|
||||||
|
.Prop(_SC("IsVerified"), &DpGuild::IsVerified)
|
||||||
|
.Prop(_SC("IsPartnered"), &DpGuild::IsPartnered)
|
||||||
|
.Prop(_SC("IsCommunity"), &DpGuild::IsCommunity)
|
||||||
|
.Prop(_SC("HasCommerce"), &DpGuild::HasCommerce)
|
||||||
|
.Prop(_SC("HasNews"), &DpGuild::HasNews)
|
||||||
|
.Prop(_SC("IsDiscoverable"), &DpGuild::IsDiscoverable)
|
||||||
|
.Prop(_SC("IsFeatureable"), &DpGuild::IsFeatureable)
|
||||||
|
.Prop(_SC("HasAnimatedIcon"), &DpGuild::HasAnimatedIcon)
|
||||||
|
.Prop(_SC("BasBanner"), &DpGuild::BasBanner)
|
||||||
|
.Prop(_SC("WelcomeScreenEnabled"), &DpGuild::WelcomeScreenEnabled)
|
||||||
|
.Prop(_SC("HasMemberVerificationGate"), &DpGuild::HasMemberVerificationGate)
|
||||||
|
.Prop(_SC("IsPreviewEnabled"), &DpGuild::IsPreviewEnabled)
|
||||||
|
.Prop(_SC("HasAnimatedIconHash"), &DpGuild::HasAnimatedIconHash)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("BuildJSON"), &DpGuild::BuildJSON_)
|
||||||
|
.Func(_SC("GetRoles"), &DpGuild::GetRoles)
|
||||||
|
.Func(_SC("GetChannels"), &DpGuild::GetChannels)
|
||||||
|
.Func(_SC("GetThreads"), &DpGuild::GetThreads)
|
||||||
|
.Func(_SC("GetMembers"), &DpGuild::GetMembers)
|
||||||
|
.Func(_SC("GetVoiceMembers"), &DpGuild::GetVoiceMembers)
|
||||||
|
.Func(_SC("GetEmojis"), &DpGuild::GetEmojis)
|
||||||
|
.Func(_SC("RehashMembers"), &DpGuild::RehashMembers)
|
||||||
|
.Func(_SC("ConnectMemberVoice"), &DpGuild::ConnectMemberVoice)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,478 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Represents a guild on Discord (AKA a server).
|
||||||
|
*/
|
||||||
|
struct DpGuildMember
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::guild_member >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced guild member instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Whether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpGuildMember() noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpGuildMember(Ptr::pointer ptr, bool owned = false) noexcept
|
||||||
|
: mPtr(ptr), mOwned(owned)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
explicit DpGuildMember(const Ptr::element_type & o) noexcept
|
||||||
|
: DpGuildMember(new Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpGuildMember(Ptr::element_type && o) noexcept
|
||||||
|
: DpGuildMember(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpGuildMember(const DpGuildMember & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpGuildMember(DpGuildMember && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpGuildMember() noexcept { Cleanup(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpGuildMember & operator = (const DpGuildMember & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpGuildMember & operator = (DpGuildMember && o) noexcept
|
||||||
|
{
|
||||||
|
if (this != &o) {
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
Cleanup();
|
||||||
|
// Transfer members values
|
||||||
|
mPtr = std::move(o.mPtr);
|
||||||
|
mOwned = o.mOwned;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle.
|
||||||
|
*/
|
||||||
|
void Validate() const { if (!mPtr) STHROWF("Invalid discord voice state handle"); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle and retrieve a const reference to it.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Ptr::element_type & Valid() const { Validate(); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether a valid instance is managed.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsValid() const { return static_cast< bool >(mPtr); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the gickname, or empty string if they don't have a nickname on this guild.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetNickname() const { return Valid().nickname; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild id.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetGuildID() const { return Valid().guild_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the user id.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetUserID() const { return Valid().user_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the list of roles this user has on this guild.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Array GetRoles() const
|
||||||
|
{
|
||||||
|
return Array(SqVM()).Reserve(static_cast< SQInteger >(Valid().roles.size()))
|
||||||
|
.AppendFromVector(Valid().roles);
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the date and time since the user joined the guild.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetJoinedAt() const
|
||||||
|
{
|
||||||
|
return std::chrono::time_point_cast< std::chrono::seconds >(
|
||||||
|
std::chrono::system_clock::from_time_t(Valid().joined_at)
|
||||||
|
).time_since_epoch().count();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the date and time since the user has boosted the guild guild.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetPremiumSince() const
|
||||||
|
{
|
||||||
|
return std::chrono::time_point_cast< std::chrono::seconds >(
|
||||||
|
std::chrono::system_clock::from_time_t(Valid().premium_since)
|
||||||
|
).time_since_epoch().count();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the set of flags built from the bitmask defined by dpp::guild_member_flags.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetFlags() const { return static_cast< SQInteger >(Valid().flags); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Build JSON string for the member object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON() const { return Valid().build_json(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is deafened.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsDeaf() const { return Valid().is_deaf(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is muted.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsMuted() const { return Valid().is_muted(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is pending verification by membership screening.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsPending() const { return Valid().is_pending(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Represents a guild on Discord (AKA a server)
|
||||||
|
*/
|
||||||
|
struct DpGuild
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::guild >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced guild instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Whether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpGuild() noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpGuild(Ptr::pointer ptr, bool owned = false) noexcept
|
||||||
|
: mPtr(ptr), mOwned(owned)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
explicit DpGuild(const Ptr::element_type & o) noexcept
|
||||||
|
: DpGuild(new Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpGuild(Ptr::element_type && o) noexcept
|
||||||
|
: DpGuild(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpGuild(const DpGuild & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpGuild(DpGuild && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpGuild() noexcept { Cleanup(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpGuild & operator = (const DpGuild & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpGuild & operator = (DpGuild && o) noexcept
|
||||||
|
{
|
||||||
|
if (this != &o) {
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
Cleanup();
|
||||||
|
// Transfer members values
|
||||||
|
mPtr = std::move(o.mPtr);
|
||||||
|
mOwned = o.mOwned;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle.
|
||||||
|
*/
|
||||||
|
void Validate() const { if (!mPtr) STHROWF("Invalid discord guild handle"); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle and retrieve a const reference to it.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Ptr::element_type & Valid() const { Validate(); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether a valid instance is managed.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsValid() const { return static_cast< bool >(mPtr); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the shard ID of the guild.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetShardID() const { return static_cast< SQInteger >(Valid().shard_id); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the flags bitmask as defined by values within dpp::guild_flags.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetFlags() const { return static_cast< SQInteger >(Valid().flags); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild name.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetName() const { return Valid().name; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the server description for communities.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetDescription() const { return Valid().description; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the vanity url code for verified or partnered servers and boost level 3.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetVanityUrlCode() const { return Valid().vanity_url_code; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild icon hash.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const dpp::utility::iconhash & GetIcon() const { return Valid().icon; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild splash hash.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const dpp::utility::iconhash & GetSplash() const { return Valid().splash; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild discovery splash hash.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const dpp::utility::iconhash & GetDiscoverySplash() const { return Valid().discovery_splash; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the snowflake id of guild owner.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetOwnerID() const { return Valid().owner_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild voice region.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetVoiceRegion() const { return static_cast< SQInteger >(Valid().voice_region); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the snowflake ID of AFK voice channel or 0.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetAfkChannelID() const { return Valid().afk_channel_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the voice AFK timeout before moving users to AFK channel.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetAfkTimeout() const { return static_cast< SQInteger >(Valid().afk_timeout); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the snowflake ID of widget channel, or 0.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetWidgetChannelID() const { return Valid().widget_channel_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the verification level of server.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetVerificationLevel() const { return static_cast< SQInteger >(Valid().verification_level); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the setting for how notifications are to be delivered to users.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetDefaultMessageNotifications() const { return static_cast< SQInteger >(Valid().default_message_notifications); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether or not explicit content filtering is enable and what setting it is.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetExplicitContentFilter() const { return static_cast< SQInteger >(Valid().explicit_content_filter); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether multi factor authentication is required for moderators or not.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetMfaLevel() const { return static_cast< SQInteger >(Valid().mfa_level); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the ID of creating application, if any, or 0.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetApplicationID() const { return Valid().application_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the ID of system channel where discord update messages are sent.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetSystemChannelID() const { return Valid().system_channel_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the ID of rules channel for communities.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetRulesChannelID() const { return Valid().rules_channel_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the approximate member count. May be sent as zero.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetMemberCount() const { return static_cast< SQInteger >(Valid().member_count); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the server banner hash.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const dpp::utility::iconhash & GetBanner() const { return Valid().banner; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the boost level.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetPremiumTier() const { return static_cast< SQInteger >(Valid().premium_tier); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the number of boosters.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetPremiumSubscriptionCount() const { return static_cast< SQInteger >(Valid().premium_subscription_count); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve public updates channel ID or 0.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetPublicUpdatesChannelID() const { return Valid().public_updates_channel_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the maximum users in a video channel, or 0.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetMaxVideoChannelUsers() const { return static_cast< SQInteger >(Valid().max_video_channel_users); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve a roles defined on this server.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Array GetRoles() const { return Array(SqVM()).Reserve(static_cast< SQInteger >(Valid().roles.size())).AppendFromVector(Valid().roles); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve a list of channels on this server.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Array GetChannels() const { return Array(SqVM()).Reserve(static_cast< SQInteger >(Valid().channels.size())).AppendFromVector(Valid().channels); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve a list of threads on this server.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Array GetThreads() const { return Array(SqVM()).Reserve(static_cast< SQInteger >(Valid().threads.size())).AppendFromVector(Valid().threads); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve a list of guild members. Note that when you first receive the guild create event,
|
||||||
|
* this may be empty or near empty. This depends upon your dpp::intents and the size of your bot.
|
||||||
|
* It will be filled by guild member chunk requests.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Table GetMembers() const;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve a list of members in voice channels in the guild.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Table GetVoiceMembers() const;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve a list of emojis.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Array GetEmojis() const { return Array(SqVM()).Reserve(static_cast< SQInteger >(Valid().emojis.size())).AppendFromVector(Valid().emojis); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Build a JSON string from this object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON() const { return Valid().build_json(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Build a JSON string from this object. If [with_id] is True then ID is to be included in the JSON.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON_(bool with_id) const { return Valid().build_json(with_id); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Rehash members map.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD DpGuild & RehashMembers() { Valid().rehash_members(); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Connect to a voice channel another guild member is in.
|
||||||
|
* Returns true if the user specified is in a voice channel, false if they aren't.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool ConnectMemberVoice(SQInteger user_id) const { return Valid().connect_member_voice(user_id); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Is a large server (>250 users).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsLarge() const { return Valid().is_large(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Is unavailable due to outage (most other fields will be blank or outdated).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsUnavailable() const { return Valid().is_unavailable(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Widget is enabled for this server.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool WidgetEnabled() const { return Valid().widget_enabled(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has an invite splash.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasInviteSplash() const { return Valid().has_invite_splash(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has VIP regions.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasVipRegions() const { return Valid().has_vip_regions(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild can have a vanity URL.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasVanityURL() const { return Valid().has_vanity_url(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild is a verified server.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsVerified() const { return Valid().is_verified(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild is a discord partner server.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsPartnered() const { return Valid().is_partnered(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has enabled community.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsCommunity() const { return Valid().is_community(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has enabled commerce channels.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasCommerce() const { return Valid().has_commerce(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has news channel.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasNews() const { return Valid().has_news(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild is discoverable.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsDiscoverable() const { return Valid().is_discoverable(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild is featureable.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsFeatureable() const { return Valid().is_featureable(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild is allowed an animated icon.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasAnimatedIcon() const { return Valid().has_animated_icon(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has a banner image.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool BasBanner() const { return Valid().has_banner(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has enabled welcome screen.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool WelcomeScreenEnabled() const { return Valid().is_welcome_screen_enabled(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has enabled membership screening.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasMemberVerificationGate() const { return Valid().has_member_verification_gate(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Guild has preview enabled.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsPreviewEnabled() const { return Valid().is_preview_enabled(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Server icon is actually an animated gif.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasAnimatedIconHash() const { return Valid().has_animated_icon_hash(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Integration.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Integration(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,242 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Message.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppSelectOption, _SC("SqDppSelectOption"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppSelectOptions, _SC("SqDppSelectOptions"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppComponent, _SC("SqDppComponent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppComponents, _SC("SqDppComponents"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppEmbedFooter, _SC("SqDppEmbedFooter"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppEmbedImage, _SC("SqDppEmbedImage"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppEmbedProvider, _SC("SqDppEmbedProvider"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppEmbedAuthor, _SC("SqDppEmbedAuthor"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppEmbedField, _SC("SqDppEmbedField"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppEmbed, _SC("SqDppEmbed"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppReaction, _SC("SqDppReaction"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppAttachment, _SC("SqDppAttachment"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppSticker, _SC("SqDppSticker"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppStickerPack, _SC("SqDppStickerPack"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppMessage, _SC("SqDppMessage"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Message(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("SelectOption"),
|
||||||
|
Class< DpSelectOption, NoCopy< DpSelectOption > >(vm, SqDppSelectOption::Str)
|
||||||
|
.Ctor()
|
||||||
|
.Ctor< StackStrF &, StackStrF &, StackStrF & >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppSelectOption::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpSelectOption::IsValid)
|
||||||
|
.Prop(_SC("Label"), &DpSelectOption::GetLabel, &DpSelectOption::SetLabel)
|
||||||
|
.Prop(_SC("Value"), &DpSelectOption::GetValue, &DpSelectOption::SetValue)
|
||||||
|
.Prop(_SC("Description"), &DpSelectOption::GetDescription, &DpSelectOption::SetDescription)
|
||||||
|
.Prop(_SC("IsDefault"), &DpSelectOption::IsDefault, &DpSelectOption::SetDefault)
|
||||||
|
.Prop(_SC("IsAnimated"), &DpSelectOption::IsAnimated, &DpSelectOption::SetAnimated)
|
||||||
|
.Prop(_SC("EmojiName"), &DpSelectOption::GetEmojiName, &DpSelectOption::SetEmojiName)
|
||||||
|
.Prop(_SC("EmojiID"), &DpSelectOption::GetEmojiID, &DpSelectOption::SetEmojiID)
|
||||||
|
// Member Methods
|
||||||
|
.FmtFunc(_SC("SetLabel"), &DpSelectOption::ApplyLabel)
|
||||||
|
.FmtFunc(_SC("SetValue"), &DpSelectOption::ApplyValue)
|
||||||
|
.FmtFunc(_SC("SetDescription"), &DpSelectOption::ApplyDescription)
|
||||||
|
.FmtFunc(_SC("SetEmoji"), &DpSelectOption::SetEmoji)
|
||||||
|
.FmtFunc(_SC("SetDefault"), &DpSelectOption::SetDefault)
|
||||||
|
.FmtFunc(_SC("SetAnimated"), &DpSelectOption::SetAnimated)
|
||||||
|
.FmtFunc(_SC("SetEmojiName"), &DpSelectOption::ApplyEmojiName)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
Register_DPP_VectorProxy< dpp::select_option, DpSelectOption, SqDppSelectOptions >(vm, ns, _SC("SelectOptions"));
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Component"),
|
||||||
|
Class< DpComponent, NoConstructor< DpComponent > >(vm, SqDppComponent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppComponent::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpComponent::IsValid)
|
||||||
|
.Prop(_SC("JSON"), &DpComponent::BuildJSON)
|
||||||
|
.Prop(_SC("Type"), &DpComponent::GetType, &DpComponent::SetType)
|
||||||
|
.Prop(_SC("Label"), &DpComponent::GetLabel, &DpComponent::SetLabel)
|
||||||
|
.Prop(_SC("Style"), &DpComponent::GetStyle, &DpComponent::SetStyle)
|
||||||
|
.Prop(_SC("CustomID"), &DpComponent::GetCustomID, &DpComponent::SetCustomID)
|
||||||
|
.Prop(_SC("URL"), &DpComponent::GetURL, &DpComponent::SetURL)
|
||||||
|
.Prop(_SC("Placeholder"), &DpComponent::GetPlaceholder, &DpComponent::SetPlaceholder)
|
||||||
|
.Prop(_SC("MinValues"), &DpComponent::GetMinValues, &DpComponent::SetMinValues)
|
||||||
|
.Prop(_SC("MaxValues"), &DpComponent::GetMaxValues, &DpComponent::SetMaxValues)
|
||||||
|
.Prop(_SC("Disabled"), &DpComponent::IsDisabled, &DpComponent::SetDisabled)
|
||||||
|
.Prop(_SC("IsAnimated"), &DpComponent::IsAnimated, &DpComponent::SetAnimated)
|
||||||
|
.Prop(_SC("EmojiName"), &DpComponent::GetEmojiName, &DpComponent::SetEmojiName)
|
||||||
|
.Prop(_SC("EmojiID"), &DpComponent::GetEmojiID, &DpComponent::SetEmojiID)
|
||||||
|
// Member Methods
|
||||||
|
.FmtFunc(_SC("SetLabel"), &DpComponent::ApplyLabel)
|
||||||
|
.FmtFunc(_SC("SetCustomID"), &DpComponent::ApplyCustomID)
|
||||||
|
.FmtFunc(_SC("SetURL"), &DpComponent::ApplyURL)
|
||||||
|
.FmtFunc(_SC("SetPlaceholder"), &DpComponent::ApplyPlaceholder)
|
||||||
|
.FmtFunc(_SC("SetDisabled"), &DpComponent::SetDisabled)
|
||||||
|
.FmtFunc(_SC("SetAnimated"), &DpComponent::SetAnimated)
|
||||||
|
.FmtFunc(_SC("SetEmojiName"), &DpComponent::ApplyEmojiName)
|
||||||
|
.FmtFunc(_SC("GetComponents"), &DpComponent::GetComponents)
|
||||||
|
.FmtFunc(_SC("GetOptions"), &DpComponent::GetOptions)
|
||||||
|
.FmtFunc(_SC("AddComponent"), &DpComponent::AddComponent)
|
||||||
|
.FmtFunc(_SC("AddOption"), &DpComponent::AddSelectOption)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
Register_DPP_VectorProxy< dpp::component, DpComponent, SqDppComponent >(vm, ns, _SC("Components"));
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("EmbedFooter"),
|
||||||
|
Class< DpEmbedFooter, NoConstructor< DpEmbedFooter > >(vm, SqDppEmbedFooter::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppEmbedFooter::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpEmbedFooter::IsValid)
|
||||||
|
.Prop(_SC("Text"), &DpEmbedFooter::GetText, &DpEmbedFooter::SetText)
|
||||||
|
.Prop(_SC("Icon"), &DpEmbedFooter::GetIconURL, &DpEmbedFooter::SetIconURL)
|
||||||
|
.Prop(_SC("Proxy"), &DpEmbedFooter::GetProxyURL, &DpEmbedFooter::SetProxyURL)
|
||||||
|
// Member Methods
|
||||||
|
.FmtFunc(_SC("SetText"), &DpEmbedFooter::ApplyText)
|
||||||
|
.FmtFunc(_SC("SetIcon"), &DpEmbedFooter::ApplyIconURL)
|
||||||
|
.FmtFunc(_SC("SetProxy"), &DpEmbedFooter::ApplyProxyURL)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("EmbedImage"),
|
||||||
|
Class< DpEmbedImage, NoConstructor< DpEmbedImage > >(vm, SqDppEmbedImage::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppEmbedImage::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpEmbedImage::IsValid)
|
||||||
|
.Prop(_SC("URL"), &DpEmbedImage::GetURL, &DpEmbedImage::SetURL)
|
||||||
|
.Prop(_SC("Proxy"), &DpEmbedImage::GetProxyURL, &DpEmbedImage::SetProxyURL)
|
||||||
|
.Prop(_SC("Height"), &DpEmbedImage::GetHeight, &DpEmbedImage::SetHeight)
|
||||||
|
.Prop(_SC("Width"), &DpEmbedImage::GetWidth, &DpEmbedImage::SetWidth)
|
||||||
|
// Member Methods
|
||||||
|
.FmtFunc(_SC("SetURL"), &DpEmbedImage::ApplyURL)
|
||||||
|
.FmtFunc(_SC("SetProxy"), &DpEmbedImage::ApplyProxyURL)
|
||||||
|
.FmtFunc(_SC("SetHeight"), &DpEmbedImage::ApplyHeight)
|
||||||
|
.FmtFunc(_SC("SetWidth"), &DpEmbedImage::ApplyWidth)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("EmbedProvider"),
|
||||||
|
Class< DpEmbedProvider, NoConstructor< DpEmbedProvider > >(vm, SqDppEmbedProvider::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppEmbedProvider::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpEmbedProvider::IsValid)
|
||||||
|
.Prop(_SC("Name"), &DpEmbedProvider::GetName, &DpEmbedProvider::SetName)
|
||||||
|
.Prop(_SC("URL"), &DpEmbedProvider::GetURL, &DpEmbedProvider::SetURL)
|
||||||
|
// Member Methods
|
||||||
|
.FmtFunc(_SC("SetName"), &DpEmbedProvider::ApplyName)
|
||||||
|
.FmtFunc(_SC("SetURL"), &DpEmbedProvider::ApplyURL)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("EmbedAuthor"),
|
||||||
|
Class< DpEmbedAuthor, NoConstructor< DpEmbedAuthor > >(vm, SqDppEmbedAuthor::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppEmbedAuthor::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpEmbedAuthor::IsValid)
|
||||||
|
.Prop(_SC("Name"), &DpEmbedAuthor::GetName, &DpEmbedAuthor::SetName)
|
||||||
|
.Prop(_SC("URL"), &DpEmbedAuthor::GetURL, &DpEmbedAuthor::SetURL)
|
||||||
|
.Prop(_SC("Icon"), &DpEmbedAuthor::GetIconURL, &DpEmbedAuthor::SetIconURL)
|
||||||
|
.Prop(_SC("ProxyIcon"), &DpEmbedAuthor::GetProxyIconURL, &DpEmbedAuthor::SetProxyIconURL)
|
||||||
|
// Member Methods
|
||||||
|
.FmtFunc(_SC("SetName"), &DpEmbedAuthor::ApplyName)
|
||||||
|
.FmtFunc(_SC("SetURL"), &DpEmbedAuthor::ApplyURL)
|
||||||
|
.FmtFunc(_SC("SetIcon"), &DpEmbedAuthor::ApplyIconURL)
|
||||||
|
.FmtFunc(_SC("SetProxyIcon"), &DpEmbedAuthor::ApplyProxyIconURL)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("EmbedField"),
|
||||||
|
Class< DpEmbedField, NoConstructor< DpEmbedField > >(vm, SqDppEmbedField::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppEmbedField::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpEmbedField::IsValid)
|
||||||
|
.Prop(_SC("Name"), &DpEmbedField::GetName, &DpEmbedField::SetName)
|
||||||
|
.Prop(_SC("Value"), &DpEmbedField::GetValue, &DpEmbedField::SetValue)
|
||||||
|
.Prop(_SC("Inline"), &DpEmbedField::IsInline, &DpEmbedField::SetInline)
|
||||||
|
// Member Methods
|
||||||
|
.FmtFunc(_SC("SetName"), &DpEmbedField::ApplyName)
|
||||||
|
.FmtFunc(_SC("SetValue"), &DpEmbedField::ApplyValue)
|
||||||
|
.FmtFunc(_SC("SetInline"), &DpEmbedField::SetInline)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Embed"),
|
||||||
|
Class< DpEmbed, NoConstructor< DpEmbed > >(vm, SqDppEmbed::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppEmbed::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpEmbed::IsValid)
|
||||||
|
.Prop(_SC("Title"), &DpEmbed::GetTitle, &DpEmbed::SetTitle)
|
||||||
|
.Prop(_SC("Type"), &DpEmbed::GetType, &DpEmbed::SetType)
|
||||||
|
.Prop(_SC("Description"), &DpEmbed::GetDescription, &DpEmbed::SetDescription)
|
||||||
|
.Prop(_SC("URL"), &DpEmbed::GetURL, &DpEmbed::SetURL)
|
||||||
|
.Prop(_SC("TimeStamp"), &DpEmbed::GetTimeStamp, &DpEmbed::SetTimeStamp)
|
||||||
|
.Prop(_SC("Color"), &DpEmbed::GetColor, &DpEmbed::SetColor)
|
||||||
|
.Prop(_SC("Footer"), &DpEmbed::GetFooter, &DpEmbed::SetFooter)
|
||||||
|
.Prop(_SC("Image"), &DpEmbed::GetImage, &DpEmbed::SetImage)
|
||||||
|
.Prop(_SC("Thumbnail"), &DpEmbed::GetThumbnail, &DpEmbed::SetThumbnail)
|
||||||
|
.Prop(_SC("Video"), &DpEmbed::GetVideo, &DpEmbed::SetVideo)
|
||||||
|
.Prop(_SC("Provider"), &DpEmbed::GetProvider, &DpEmbed::SetProvider)
|
||||||
|
.Prop(_SC("Author"), &DpEmbed::GetAuthor, &DpEmbed::SetAuthor)
|
||||||
|
.Prop(_SC("Fields"), &DpEmbed::GetFields)
|
||||||
|
// Member Methods
|
||||||
|
.FmtFunc(_SC("SetTitle"), &DpEmbed::ApplyTitle)
|
||||||
|
.FmtFunc(_SC("SetType"), &DpEmbed::ApplyType)
|
||||||
|
.FmtFunc(_SC("SetDescription"), &DpEmbed::ApplyDescription)
|
||||||
|
.FmtFunc(_SC("SetURL"), &DpEmbed::ApplyURL)
|
||||||
|
.FmtFunc(_SC("SetTimeStamp"), &DpEmbed::ApplyTimeStamp)
|
||||||
|
.FmtFunc(_SC("SetFooter"), &DpEmbed::ApplyFooter)
|
||||||
|
.FmtFunc(_SC("SetImage"), &DpEmbed::ApplyImage)
|
||||||
|
.FmtFunc(_SC("SetThumbnail"), &DpEmbed::ApplyThumbnail)
|
||||||
|
.FmtFunc(_SC("SetVideo"), &DpEmbed::ApplyVideo)
|
||||||
|
.FmtFunc(_SC("SetProvider"), &DpEmbed::ApplyProvider)
|
||||||
|
.FmtFunc(_SC("SetAuthor"), &DpEmbed::ApplyAuthor)
|
||||||
|
.FmtFunc(_SC("AddField"), &DpEmbed::AddField)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Reaction"),
|
||||||
|
Class< DpReaction, NoConstructor< DpReaction > >(vm, SqDppReaction::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppReaction::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpReaction::IsValid)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Attachment"),
|
||||||
|
Class< DpAttachment, NoConstructor< DpAttachment > >(vm, SqDppAttachment::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppAttachment::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpAttachment::IsValid)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Sticker"),
|
||||||
|
Class< DpSticker, NoConstructor< DpSticker > >(vm, SqDppSticker::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppSticker::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpSticker::IsValid)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("StickerPack"),
|
||||||
|
Class< DpStickerPack, NoConstructor< DpStickerPack > >(vm, SqDppStickerPack::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppStickerPack::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpStickerPack::IsValid)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Message"),
|
||||||
|
Class< DpMessage, NoConstructor< DpMessage > >(vm, SqDppMessage::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppMessage::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpMessage::IsValid)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,141 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Other.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppCachePolicy, _SC("SqDppCachePolicy"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppIconHash, _SC("SqDppIconHash"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppUptime, _SC("SqDppUptime"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppActivity, _SC("SqDppActivity"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppPresence, _SC("SqDppPresence"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppVoiceState, _SC("SqDppVoiceState"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Other(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Uptime"),
|
||||||
|
Class< dpp::utility::uptime >(vm, SqDppUptime::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppUptime::Fn)
|
||||||
|
.Func(_SC("_tostring"), &dpp::utility::uptime::to_string)
|
||||||
|
// Member Variables
|
||||||
|
.Var(_SC("Days"), &dpp::utility::uptime::days)
|
||||||
|
.Var(_SC("Hours"), &dpp::utility::uptime::hours)
|
||||||
|
.Var(_SC("Minutes"), &dpp::utility::uptime::mins)
|
||||||
|
.Var(_SC("Seconds"), &dpp::utility::uptime::secs)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("ToSeconds"), &dpp::utility::uptime::to_secs)
|
||||||
|
.Func(_SC("ToMilliseconds"), &dpp::utility::uptime::to_msecs)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("IconHash"),
|
||||||
|
Class< dpp::utility::iconhash >(vm, SqDppIconHash::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
.Ctor< const std::string & >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppIconHash::Fn)
|
||||||
|
.Func(_SC("_tostring"), &dpp::utility::iconhash::to_string)
|
||||||
|
// Member Variables
|
||||||
|
.Var(_SC("High"), &dpp::utility::iconhash::first)
|
||||||
|
.Var(_SC("Low"), &dpp::utility::iconhash::second)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("Set"), &dpp::utility::iconhash::set)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("CachePolicy"),
|
||||||
|
Class< DpCachePolicy >(vm, SqDppCachePolicy::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
.Ctor< SQInteger >()
|
||||||
|
.Ctor< SQInteger, SQInteger >()
|
||||||
|
.Ctor< SQInteger, SQInteger, SQInteger >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppCachePolicy::Fn)
|
||||||
|
// Member Variables
|
||||||
|
.Var(_SC("UserPolicy"), &DpCachePolicy::mUserPolicy)
|
||||||
|
.Var(_SC("EmojiPolicy"), &DpCachePolicy::mEmojiPolicy)
|
||||||
|
.Var(_SC("RolePolicy"), &DpCachePolicy::mRolePolicy)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Activity"),
|
||||||
|
Class< DpActivity, NoCopy< DpActivity > >(vm, SqDppActivity::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
.Ctor< SQInteger, StackStrF &, StackStrF &, StackStrF & >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppActivity::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Name"), &DpActivity::GetName, &DpActivity::SetName)
|
||||||
|
.Prop(_SC("State"), &DpActivity::GetState, &DpActivity::SetState)
|
||||||
|
.Prop(_SC("URL"), &DpActivity::GetURL, &DpActivity::SetURL)
|
||||||
|
.Prop(_SC("Type"), &DpActivity::GetType, &DpActivity::SetType)
|
||||||
|
.Prop(_SC("CreatedAt"), &DpActivity::GetCreatedAt, &DpActivity::SetCreatedAt)
|
||||||
|
.Prop(_SC("Start"), &DpActivity::GetStart, &DpActivity::SetStart)
|
||||||
|
.Prop(_SC("End"), &DpActivity::GetEnd, &DpActivity::SetEnd)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("SetName"), &DpActivity::ApplyName)
|
||||||
|
.Func(_SC("SetState"), &DpActivity::ApplyState)
|
||||||
|
.Func(_SC("SetURL"), &DpActivity::ApplyURL)
|
||||||
|
.Func(_SC("SetType"), &DpActivity::ApplyType)
|
||||||
|
.Func(_SC("SetCreatedAt"), &DpActivity::ApplyCreatedAt)
|
||||||
|
.Func(_SC("SetStart"), &DpActivity::ApplyStart)
|
||||||
|
.Func(_SC("SetEnd"), &DpActivity::ApplyEnd)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Presence"),
|
||||||
|
Class< DpPresence, NoCopy< DpPresence > >(vm, SqDppPresence::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppPresence::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpPresence::IsValid)
|
||||||
|
.Prop(_SC("UserID"), &DpPresence::GetUserID, &DpPresence::SetUserID)
|
||||||
|
.Prop(_SC("GuildID"), &DpPresence::GetGuildID, &DpPresence::SetGuildID)
|
||||||
|
.Prop(_SC("Flags"), &DpPresence::GetFlags, &DpPresence::SetFlags)
|
||||||
|
.Prop(_SC("ActivityCount"), &DpPresence::ActivityCount)
|
||||||
|
.Prop(_SC("DesktopStatus"), &DpPresence::GetDesktopStatus)
|
||||||
|
.Prop(_SC("WebStatus"), &DpPresence::GetWebStatus)
|
||||||
|
.Prop(_SC("MobileStatus"), &DpPresence::GetMobileStatus)
|
||||||
|
.Prop(_SC("Status"), &DpPresence::GetStatus)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("SetUserID"), &DpPresence::ApplyUserID)
|
||||||
|
.Func(_SC("SetGuildID"), &DpPresence::ApplyGuildID)
|
||||||
|
.Func(_SC("SetFlags"), &DpPresence::ApplyFlags)
|
||||||
|
.Func(_SC("AddActivity"), &DpPresence::AddActivity)
|
||||||
|
.Func(_SC("EachActivity"), &DpPresence::EachActivity)
|
||||||
|
.Func(_SC("ClearActivities"), &DpPresence::ClearActivities)
|
||||||
|
.Func(_SC("FilterActivities"), &DpPresence::FilterActivities)
|
||||||
|
.Func(_SC("BuildJSON"), &DpPresence::BuildJSON)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceState"),
|
||||||
|
Class< DpVoiceState, NoConstructor< DpVoiceState > >(vm, SqDppVoiceState::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppVoiceState::Fn)
|
||||||
|
.Func(_SC("_tojson"), &DpVoiceState::BuildJSON)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpVoiceState::IsValid)
|
||||||
|
.Prop(_SC("JSON"), &DpVoiceState::BuildJSON)
|
||||||
|
.Prop(_SC("GuildID"), &DpVoiceState::GetGuildID)
|
||||||
|
.Prop(_SC("ChannelID"), &DpVoiceState::GetChannelID)
|
||||||
|
.Prop(_SC("UserID"), &DpVoiceState::GetUserID)
|
||||||
|
.Prop(_SC("SessionID"), &DpVoiceState::GetSessionID)
|
||||||
|
.Prop(_SC("Flags"), &DpVoiceState::GetFlags, &DpVoiceState::SetFlags)
|
||||||
|
.Prop(_SC("IsDeaf"), &DpVoiceState::IsDeaf)
|
||||||
|
.Prop(_SC("IsMute"), &DpVoiceState::IsMute)
|
||||||
|
.Prop(_SC("IsSelfMute"), &DpVoiceState::IsSelfMute)
|
||||||
|
.Prop(_SC("IsSelfDeaf"), &DpVoiceState::IsSelfDeaf)
|
||||||
|
.Prop(_SC("SelfStream"), &DpVoiceState::SelfStream)
|
||||||
|
.Prop(_SC("SelfVideo"), &DpVoiceState::SelfVideo)
|
||||||
|
.Prop(_SC("IsSuppressed"), &DpVoiceState::IsSuppressed)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,607 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Represents the caching policy of the cluster.
|
||||||
|
*/
|
||||||
|
struct DpCachePolicy
|
||||||
|
{
|
||||||
|
SQInteger mUserPolicy{dpp::cp_aggressive};
|
||||||
|
SQInteger mEmojiPolicy{dpp::cp_aggressive};
|
||||||
|
SQInteger mRolePolicy{dpp::cp_aggressive};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpCachePolicy() noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpCachePolicy(SQInteger user) noexcept
|
||||||
|
: mUserPolicy(user), mEmojiPolicy(dpp::cp_aggressive), mRolePolicy(dpp::cp_aggressive)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCachePolicy(SQInteger user, SQInteger emoji) noexcept
|
||||||
|
: mUserPolicy(user), mEmojiPolicy(emoji), mRolePolicy(dpp::cp_aggressive)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpCachePolicy(SQInteger user, SQInteger emoji, SQInteger role) noexcept
|
||||||
|
: mUserPolicy(user), mEmojiPolicy(emoji), mRolePolicy(role)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
DpCachePolicy(const DpCachePolicy &) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Convert to native cache policy type.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::cache_policy_t ToNative() const noexcept
|
||||||
|
{
|
||||||
|
return dpp::cache_policy_t{
|
||||||
|
static_cast< dpp::cache_policy_setting_t >(mUserPolicy),
|
||||||
|
static_cast< dpp::cache_policy_setting_t >(mEmojiPolicy),
|
||||||
|
static_cast< dpp::cache_policy_setting_t >(mRolePolicy)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* An activity is a representation of what a user is doing. It might be a game, or a website, or a movie. Whatever.
|
||||||
|
*/
|
||||||
|
struct DpActivity
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::activity >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced activity instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Whether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpActivity() noexcept
|
||||||
|
: DpActivity(new Ptr::element_type(), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpActivity(Ptr::pointer ptr, bool owned = false) noexcept
|
||||||
|
: mPtr(ptr), mOwned(owned)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
explicit DpActivity(const Ptr::element_type & o) noexcept
|
||||||
|
: DpActivity(new Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpActivity(Ptr::element_type && o) noexcept
|
||||||
|
: DpActivity(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpActivity(SQInteger type, StackStrF & name, StackStrF & state, StackStrF & url)
|
||||||
|
: DpActivity(new Ptr::element_type(static_cast< dpp::activity_type >(type), name.ToStr(), state.ToStr(), url.ToStr()), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpActivity(const DpActivity & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpActivity(DpActivity && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpActivity() noexcept { Cleanup(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpActivity & operator = (const DpActivity & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpActivity & operator = (DpActivity && o) noexcept
|
||||||
|
{
|
||||||
|
if (this != &o) {
|
||||||
|
Cleanup();
|
||||||
|
// Transfer members values
|
||||||
|
mPtr = std::move(o.mPtr);
|
||||||
|
mOwned = o.mOwned;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle.
|
||||||
|
*/
|
||||||
|
void Validate() const { if (!mPtr) STHROWF("Invalid discord activity handle"); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle and retrieve a const reference to it.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Ptr::element_type & Valid() const { Validate(); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether a valid instance is managed.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsValid() const { return static_cast< bool >(mPtr); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the name of the activity.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetName() const { return Valid().name; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the name of the activity.
|
||||||
|
*/
|
||||||
|
void SetName(StackStrF & name) const { Valid().name = name.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the name of the activity.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyName(StackStrF & name) { SetName(name); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the state of the activity.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetState() const { return Valid().state; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the state of the activity.
|
||||||
|
*/
|
||||||
|
void SetState(StackStrF & state) const { Valid().state = state.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the state of the activity.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyState(StackStrF & state) { SetState(state); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the url of the activity.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetURL() const { return Valid().url; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the url of the activity.
|
||||||
|
*/
|
||||||
|
void SetURL(StackStrF & url) const { Valid().url = url.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the url of the activity.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyURL(StackStrF & url) { SetURL(url); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the type of the activity.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetType() const { return static_cast< SQInteger >(Valid().type); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the type of the activity.
|
||||||
|
*/
|
||||||
|
void SetType(SQInteger s) const { Valid().type = static_cast< dpp::activity_type >(s); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the type of the activity.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyType(SQInteger s) { SetType(s); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve when the activity was created.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetCreatedAt() const
|
||||||
|
{
|
||||||
|
return static_cast< SQInteger >(std::chrono::duration_cast< std::chrono::seconds >(std::chrono::system_clock::from_time_t(Valid().created_at).time_since_epoch()).count());
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify when the activity was created.
|
||||||
|
*/
|
||||||
|
void SetCreatedAt(SQInteger s) const
|
||||||
|
{
|
||||||
|
Valid().created_at = std::chrono::system_clock::to_time_t(std::chrono::time_point< std::chrono::system_clock >{std::chrono::seconds{s}});
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify when the activity was created.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyCreatedAt(SQInteger s) { SetCreatedAt(s); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve when the activity was started.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetStart() const
|
||||||
|
{
|
||||||
|
return static_cast< SQInteger >(std::chrono::duration_cast< std::chrono::seconds >(std::chrono::system_clock::from_time_t(Valid().start).time_since_epoch()).count());
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify when the activity was started.
|
||||||
|
*/
|
||||||
|
void SetStart(SQInteger s) const
|
||||||
|
{
|
||||||
|
Valid().start = std::chrono::system_clock::to_time_t(std::chrono::time_point< std::chrono::system_clock >{std::chrono::seconds{s}});
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify when the activity was started.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyStart(SQInteger s) { SetStart(s); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve when the activity was stopped.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetEnd() const
|
||||||
|
{
|
||||||
|
return static_cast< SQInteger >(std::chrono::duration_cast< std::chrono::seconds >(std::chrono::system_clock::from_time_t(Valid().end).time_since_epoch()).count());
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify when the activity was stopped.
|
||||||
|
*/
|
||||||
|
void SetEnd(SQInteger s) const
|
||||||
|
{
|
||||||
|
Valid().end = std::chrono::system_clock::to_time_t(std::chrono::time_point< std::chrono::system_clock >{std::chrono::seconds{s}});
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify when the activity was stopped.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyEnd(SQInteger s) { SetEnd(s); return *this; }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Represents user presence, e.g. what game they are playing and if they are online.
|
||||||
|
*/
|
||||||
|
struct DpPresence
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::presence >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced presence instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Whether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpPresence() noexcept
|
||||||
|
: DpPresence(new Ptr::element_type(), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpPresence(Ptr::pointer ptr, bool owned = false) noexcept
|
||||||
|
: mPtr(ptr), mOwned(owned)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
explicit DpPresence(const Ptr::element_type & o) noexcept
|
||||||
|
: DpPresence(new Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpPresence(Ptr::element_type && o) noexcept
|
||||||
|
: DpPresence(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpPresence(const DpPresence & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpPresence(DpPresence && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpPresence() noexcept { Cleanup(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpPresence & operator = (const DpPresence & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpPresence & operator = (DpPresence && o) noexcept
|
||||||
|
{
|
||||||
|
if (this != &o) {
|
||||||
|
Cleanup();
|
||||||
|
// Transfer members values
|
||||||
|
mPtr = std::move(o.mPtr);
|
||||||
|
mOwned = o.mOwned;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle.
|
||||||
|
*/
|
||||||
|
void Validate() const { if (!mPtr) STHROWF("Invalid discord presence handle"); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle and retrieve a const reference to it.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Ptr::element_type & Valid() const { Validate(); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether a valid instance is managed.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsValid() const { return static_cast< bool >(mPtr); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the user that the presence applies to.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetUserID() const { return Valid().user_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the user that the presence applies to.
|
||||||
|
*/
|
||||||
|
void SetUserID(dpp::snowflake id) const { Valid().user_id = id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the user that the presence applies to.
|
||||||
|
*/
|
||||||
|
DpPresence & ApplyUserID(dpp::snowflake id) { SetUserID(id); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild that the presence applies to.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetGuildID() const { return Valid().guild_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the guild that the presence applies to.
|
||||||
|
*/
|
||||||
|
void SetGuildID(dpp::snowflake id) const { Valid().guild_id = id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the guild that the presence applies to.
|
||||||
|
*/
|
||||||
|
DpPresence & ApplyGuildID(dpp::snowflake id) { SetGuildID(id); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the presence bit-mask.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetFlags() const { return static_cast< SQInteger >(Valid().flags); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the presence bit-mask.
|
||||||
|
*/
|
||||||
|
void SetFlags(SQInteger f) const { Valid().flags = static_cast< uint8_t >(f); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the presence bit-mask.
|
||||||
|
*/
|
||||||
|
DpPresence & ApplyFlags(SQInteger f) { SetFlags(f); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the number of activities.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger ActivityCount() const { return static_cast< SQInteger >(Valid().activities.size()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Add a new activity.
|
||||||
|
*/
|
||||||
|
DpPresence & AddActivity(const DpActivity & a) { Valid().activities.push_back(a.Valid()); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Iterate all activities.
|
||||||
|
*/
|
||||||
|
DpPresence & EachActivity(Function & fn)
|
||||||
|
{
|
||||||
|
for (const auto & a : Valid().activities)
|
||||||
|
{
|
||||||
|
fn.Execute(a);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the number of activities.
|
||||||
|
*/
|
||||||
|
DpPresence & ClearActivities(const DpActivity & a) { Valid().activities.clear(); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Filter activities.
|
||||||
|
*/
|
||||||
|
DpPresence & FilterActivities(Function & fn)
|
||||||
|
{
|
||||||
|
std::vector< dpp::activity > list;
|
||||||
|
// Reserve memory in advance
|
||||||
|
list.reserve(Valid().activities.size());
|
||||||
|
// Process each activity individually
|
||||||
|
for (const auto & a : Valid().activities)
|
||||||
|
{
|
||||||
|
auto ret = fn.Eval(a);
|
||||||
|
// (null || true) == keep & false == skip
|
||||||
|
if (!ret.IsNull() || !ret.template Cast< bool >())
|
||||||
|
{
|
||||||
|
list.push_back(a); // Keep this activity
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Use filtered activities
|
||||||
|
Valid().activities.swap(list);
|
||||||
|
// Allow chaining
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Build JSON string from this object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON() const { return Valid().build_json(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the users status on desktop.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetDesktopStatus() const { return static_cast< SQInteger >(Valid().desktop_status()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the user's status on web.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetWebStatus() const { return static_cast< SQInteger >(Valid().web_status()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the user's status on mobile.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetMobileStatus() const { return static_cast< SQInteger >(Valid().mobile_status()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the user's status as shown to other users.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetStatus() const { return static_cast< SQInteger >(Valid().status()); }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Represents the voice state of a user on a guild.
|
||||||
|
* These are stored in the DpGuild object, and accessible there, or via DpChannel::GetVoiceMembers.
|
||||||
|
*/
|
||||||
|
struct DpVoiceState
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::voicestate >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced voice state instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Whether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpVoiceState() noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpVoiceState(Ptr::pointer ptr, bool owned = false) noexcept
|
||||||
|
: mPtr(ptr), mOwned(owned)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpVoiceState(const Ptr::element_type & o) noexcept
|
||||||
|
: DpVoiceState(new Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpVoiceState(Ptr::element_type && o) noexcept
|
||||||
|
: DpVoiceState(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpVoiceState(const DpVoiceState & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpVoiceState(DpVoiceState && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpVoiceState() noexcept { Cleanup(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpVoiceState & operator = (const DpVoiceState & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpVoiceState & operator = (DpVoiceState && o) noexcept
|
||||||
|
{
|
||||||
|
if (this != &o) {
|
||||||
|
Cleanup();
|
||||||
|
// Transfer members values
|
||||||
|
mPtr = std::move(o.mPtr);
|
||||||
|
mOwned = o.mOwned;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle.
|
||||||
|
*/
|
||||||
|
void Validate() const { if (!mPtr) STHROWF("Invalid discord voice state handle"); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle and retrieve a const reference to it.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Ptr::element_type & Valid() const { Validate(); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether a valid instance is managed.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsValid() const { return static_cast< bool >(mPtr); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild id this voice state is for (optional).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetGuildID() const { return Valid().guild_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild id this voice state is for (optional).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetChannelID() const { return Valid().channel_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild id this voice state is for (optional).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetUserID() const { return Valid().user_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild id this voice state is for (optional).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetSessionID() const { return Valid().session_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild id this voice state is for (optional).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetFlags() const { return Valid().flags; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild id this voice state is for (optional).
|
||||||
|
*/
|
||||||
|
void SetFlags(SQInteger flags) const { Valid().flags = flags; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild id this voice state is for (optional).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON() const { return Valid().build_json(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if user is deafened.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsDeaf() const { return Valid().is_deaf(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if user is muted.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsMute() const { return Valid().is_mute(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if user muted themselves.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsSelfMute() const { return Valid().is_self_mute(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if user deafened themselves.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsSelfDeaf() const { return Valid().is_self_deaf(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if user is streamig.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool SelfStream() const { return Valid().self_stream(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if user is in video.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool SelfVideo() const { return Valid().self_video(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if user is surpressed.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsSuppressed() const { return Valid().is_suppressed(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Role.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppRole, _SC("SqDppRole"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_Role(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
ns.Bind(_SC("Role"),
|
||||||
|
Class< DpRole, NoConstructor< DpRole > >(vm, SqDppRole::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppRole::Fn)
|
||||||
|
.Func(_SC("_tojson"), &DpRole::BuildJSON)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpRole::IsValid)
|
||||||
|
.Prop(_SC("JSON"), &DpRole::BuildJSON)
|
||||||
|
.Prop(_SC("Name"), &DpRole::GetName)
|
||||||
|
.Prop(_SC("GuildID"), &DpRole::GetGuildID)
|
||||||
|
.Prop(_SC("Color"), &DpRole::GetColour)
|
||||||
|
.Prop(_SC("Colour"), &DpRole::GetColour)
|
||||||
|
.Prop(_SC("Position"), &DpRole::GetPosition)
|
||||||
|
.Prop(_SC("Permissions"), &DpRole::GetPermissions)
|
||||||
|
.Prop(_SC("Flags"), &DpRole::GetFlags)
|
||||||
|
.Prop(_SC("IntegrationID"), &DpRole::GetIntegrationID)
|
||||||
|
.Prop(_SC("BotID"), &DpRole::GetBotID)
|
||||||
|
.Prop(_SC("IsHoisted"), &DpRole::IsHoisted)
|
||||||
|
.Prop(_SC("IsMentionable"), &DpRole::IsMentionable)
|
||||||
|
.Prop(_SC("IsManaged"), &DpRole::IsManaged)
|
||||||
|
.Prop(_SC("CanCreateInstantInvite"), &DpRole::CanCreateInstantInvite)
|
||||||
|
.Prop(_SC("CanKickMembers"), &DpRole::CanKickMembers)
|
||||||
|
.Prop(_SC("CanBanMembers"), &DpRole::CanBanMembers)
|
||||||
|
.Prop(_SC("IsAdministrator"), &DpRole::IsAdministrator)
|
||||||
|
.Prop(_SC("CanManageChannels"), &DpRole::CanManageChannels)
|
||||||
|
.Prop(_SC("CanManageGuild"), &DpRole::CanManageGuild)
|
||||||
|
.Prop(_SC("CanAddReactions"), &DpRole::CanAddReactions)
|
||||||
|
.Prop(_SC("CanViewAuditLog"), &DpRole::CanViewAuditLog)
|
||||||
|
.Prop(_SC("IsPrioritySpeaker"), &DpRole::IsPrioritySpeaker)
|
||||||
|
.Prop(_SC("CanStream"), &DpRole::CanStream)
|
||||||
|
.Prop(_SC("CanViewChannel"), &DpRole::CanViewChannel)
|
||||||
|
.Prop(_SC("CanSendMessages"), &DpRole::CanSendMessages)
|
||||||
|
.Prop(_SC("CanSendTtsMessages"), &DpRole::CanSendTtsMessages)
|
||||||
|
.Prop(_SC("CanManageMessages"), &DpRole::CanManageMessages)
|
||||||
|
.Prop(_SC("CanEmbedLinks"), &DpRole::CanEmbedLinks)
|
||||||
|
.Prop(_SC("CanAttachFiles"), &DpRole::CanAttachFiles)
|
||||||
|
.Prop(_SC("CanReadMessageHistory"), &DpRole::CanReadMessageHistory)
|
||||||
|
.Prop(_SC("CanMentionEveryone"), &DpRole::CanMentionEveryone)
|
||||||
|
.Prop(_SC("CanUseExternalEmojis"), &DpRole::CanUseExternalEmojis)
|
||||||
|
.Prop(_SC("CanViewGuildInsights"), &DpRole::CanViewGuildInsights)
|
||||||
|
.Prop(_SC("CanConnect"), &DpRole::CanConnect)
|
||||||
|
.Prop(_SC("CanSpeak"), &DpRole::CanSpeak)
|
||||||
|
.Prop(_SC("CanMuteMembers"), &DpRole::CanMuteMembers)
|
||||||
|
.Prop(_SC("CanDeafenMembers"), &DpRole::CanDeafenMembers)
|
||||||
|
.Prop(_SC("CanMoveMembers"), &DpRole::CanMoveMembers)
|
||||||
|
.Prop(_SC("CanUseVAT"), &DpRole::CanUseVAT)
|
||||||
|
.Prop(_SC("CanChangeNickname"), &DpRole::CanChangeNickname)
|
||||||
|
.Prop(_SC("CanManageNicknames"), &DpRole::CanManageNicknames)
|
||||||
|
.Prop(_SC("CanManageRoles"), &DpRole::CanManageRoles)
|
||||||
|
.Prop(_SC("CanManageWebhooks"), &DpRole::CanManageWebhooks)
|
||||||
|
.Prop(_SC("CanManageEmojis"), &DpRole::CanManageEmojis)
|
||||||
|
.Prop(_SC("CanUseSlashCommands"), &DpRole::CanUseSlashCommands)
|
||||||
|
.Prop(_SC("HasRequestToSpeak"), &DpRole::HasRequestToSpeak)
|
||||||
|
.Prop(_SC("CanManageThreads"), &DpRole::CanManageThreads)
|
||||||
|
.Prop(_SC("HasUsePublicThreads"), &DpRole::HasUsePublicThreads)
|
||||||
|
.Prop(_SC("HasUsePrivateThreads"), &DpRole::HasUsePrivateThreads)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("BuildJSON"), &DpRole::BuildJSON_)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,301 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Represents a role within a DpGuild.
|
||||||
|
*/
|
||||||
|
struct DpRole
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::role >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced role instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Whether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpRole() noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpRole(Ptr::pointer ptr, bool owned = false) noexcept
|
||||||
|
: mPtr(ptr), mOwned(owned)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpRole(const Ptr::element_type & o) noexcept
|
||||||
|
: DpRole(new Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpRole(Ptr::element_type && o) noexcept
|
||||||
|
: DpRole(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpRole(const DpRole & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpRole(DpRole && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpRole() noexcept { Cleanup(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpRole & operator = (const DpRole & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpRole & operator = (DpRole && o) noexcept
|
||||||
|
{
|
||||||
|
if (this != &o) {
|
||||||
|
Cleanup();
|
||||||
|
// Transfer members values
|
||||||
|
mPtr = std::move(o.mPtr);
|
||||||
|
mOwned = o.mOwned;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle.
|
||||||
|
*/
|
||||||
|
void Validate() const { if (!mPtr) STHROWF("Invalid discord role handle"); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle and retrieve a const reference to it.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Ptr::element_type & Valid() const { Validate(); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether a valid instance is managed.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsValid() const { return static_cast< bool >(mPtr); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve role name.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetName() const { return Valid().name; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the role guild id.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetGuildID() const { return Valid().guild_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the role colour.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetColour() const { return static_cast< SQInteger >(Valid().colour); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the role position.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetPosition() const { return static_cast< SQInteger >(Valid().position); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the role permissions bitmask values from SqDiscordRolePermissions.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetPermissions() const { return static_cast< SQInteger >(Valid().permissions); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the role flags from SqDiscordRoleFlags.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetFlags() const { return static_cast< SQInteger >(Valid().flags); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the role integration id if any (e.g. role is a bot's role created when it was invited).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetIntegrationID() const { return Valid().integration_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the role bot id if any (e.g. role is a bot's role created when it was invited).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetBotID() const { return Valid().bot_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Build a JSON string from this object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON() const { return Valid().build_json(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Build a JSON string from this object. If [with_id] is True then ID is to be included in the JSON.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON_(bool with_id) const { return Valid().build_json(with_id); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role is hoisted.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsHoisted() const { return Valid().is_hoisted(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role is mentionable.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsMentionable() const { return Valid().is_mentionable(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role is managed (belongs to a bot or application).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsManaged() const { return Valid().is_managed(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has create instant invite permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanCreateInstantInvite() const { return Valid().has_create_instant_invite(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the kick members permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanKickMembers() const { return Valid().has_kick_members(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the ban members permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanBanMembers() const { return Valid().has_ban_members(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the administrator permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsAdministrator() const { return Valid().has_administrator(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the manage channels permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageChannels() const { return Valid().has_manage_channels(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the manage guild permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageGuild() const { return Valid().has_manage_guild(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the add reactions permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanAddReactions() const { return Valid().has_add_reactions(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the view audit log permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanViewAuditLog() const { return Valid().has_view_audit_log(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the priority speaker permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsPrioritySpeaker() const { return Valid().has_priority_speaker(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the stream permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanStream() const { return Valid().has_stream(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the view channel permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanViewChannel() const { return Valid().has_view_channel(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the send messages permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanSendMessages() const { return Valid().has_send_messages(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the send TTS messages permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanSendTtsMessages() const { return Valid().has_send_tts_messages(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the manage messages permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageMessages() const { return Valid().has_manage_messages(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the embed links permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanEmbedLinks() const { return Valid().has_embed_links(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the attach files permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanAttachFiles() const { return Valid().has_attach_files(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the read message history permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanReadMessageHistory() const { return Valid().has_read_message_history(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the mention \@everyone and \@here permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanMentionEveryone() const { return Valid().has_mention_everyone(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the use external emojis permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanUseExternalEmojis() const { return Valid().has_use_external_emojis(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the view guild insights permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanViewGuildInsights() const { return Valid().has_view_guild_insights(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the connect voice permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanConnect() const { return Valid().has_connect(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the speak permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanSpeak() const { return Valid().has_speak(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the mute members permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanMuteMembers() const { return Valid().has_mute_members(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the deafen members permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanDeafenMembers() const { return Valid().has_deafen_members(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the move members permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanMoveMembers() const { return Valid().has_move_members(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has use voice activity detection permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanUseVAT() const { return Valid().has_use_vad(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the change nickname permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanChangeNickname() const { return Valid().has_change_nickname(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the manage nicknames permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageNicknames() const { return Valid().has_manage_nicknames(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the manage roles permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageRoles() const { return Valid().has_manage_roles(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the manage webhooks permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageWebhooks() const { return Valid().has_manage_webhooks(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the manage emojis permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageEmojis() const { return Valid().has_manage_emojis(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the use slash commands permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanUseSlashCommands() const { return Valid().has_use_slash_commands(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the request to speak permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasRequestToSpeak() const { return Valid().has_request_to_speak(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the manage threads permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool CanManageThreads() const { return Valid().has_manage_threads(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the use public threads permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasUsePublicThreads() const { return Valid().has_use_public_threads(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the role has the use private threads permission.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasUsePrivateThreads() const { return Valid().has_use_private_threads(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/User.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDppUser, _SC("SqDppUser"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_DPP_User(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
ns.Bind(_SC("User"),
|
||||||
|
Class< DpUser, NoConstructor< DpUser > >(vm, SqDppUser::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDppUser::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpUser::IsValid)
|
||||||
|
.Prop(_SC("Username"), &DpUser::GetUsername)
|
||||||
|
.Prop(_SC("Discriminator"), &DpUser::GetDiscriminator)
|
||||||
|
.Prop(_SC("Avatar"), &DpUser::GetAvatar)
|
||||||
|
.Prop(_SC("Flags"), &DpUser::GetFlags)
|
||||||
|
.Prop(_SC("RefCount"), &DpUser::GetRefCount)
|
||||||
|
.Prop(_SC("AvatarURL"), &DpUser::GetAvatarURL)
|
||||||
|
.Prop(_SC("IsBot"), &DpUser::IsBot)
|
||||||
|
.Prop(_SC("IsSystem"), &DpUser::IsSystem)
|
||||||
|
.Prop(_SC("IsMfaEnabled"), &DpUser::IsMfaEnabled)
|
||||||
|
.Prop(_SC("IsVerified"), &DpUser::IsVerified)
|
||||||
|
.Prop(_SC("HasNitroFull"), &DpUser::HasNitroFull)
|
||||||
|
.Prop(_SC("HasNitroClassic"), &DpUser::HasNitroClassic)
|
||||||
|
.Prop(_SC("IsDiscordEmployee"), &DpUser::IsDiscordEmployee)
|
||||||
|
.Prop(_SC("IsPartneredOwner"), &DpUser::IsPartneredOwner)
|
||||||
|
.Prop(_SC("HasHypesquadEvents"), &DpUser::HasHypesquadEvents)
|
||||||
|
.Prop(_SC("IsBughunter1"), &DpUser::IsBughunter1)
|
||||||
|
.Prop(_SC("IsHouseBravery"), &DpUser::IsHouseBravery)
|
||||||
|
.Prop(_SC("IsHouseBrilliance"), &DpUser::IsHouseBrilliance)
|
||||||
|
.Prop(_SC("IsHouseBalanace"), &DpUser::IsHouseBalanace)
|
||||||
|
.Prop(_SC("IsEarlySupporter"), &DpUser::IsEarlySupporter)
|
||||||
|
.Prop(_SC("IsTeamUser"), &DpUser::IsTeamUser)
|
||||||
|
.Prop(_SC("IsBughunter2"), &DpUser::IsBughunter2)
|
||||||
|
.Prop(_SC("IsVerifiedBot"), &DpUser::IsVerifiedBot)
|
||||||
|
.Prop(_SC("IsVerifiedBotDev"), &DpUser::IsVerifiedBotDev)
|
||||||
|
.Prop(_SC("IsCertifiedDoderator"), &DpUser::IsCertifiedDoderator)
|
||||||
|
.Prop(_SC("HasAnimatedIcon"), &DpUser::HasAnimatedIcon)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,206 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Represents a user on discord. May or may not be a member of a DpGuild.
|
||||||
|
*/
|
||||||
|
struct DpUser
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::user >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced user instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Whether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpUser() noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpUser(Ptr::pointer ptr, bool owned = false) noexcept
|
||||||
|
: mPtr(ptr), mOwned(owned)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
explicit DpUser(const Ptr::element_type & o) noexcept
|
||||||
|
: DpUser(new Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpUser(Ptr::element_type && o) noexcept
|
||||||
|
: DpUser(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpUser(const DpUser & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpUser(DpUser && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpUser() noexcept { Cleanup(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpUser & operator = (const DpUser & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpUser & operator = (DpUser && o) noexcept
|
||||||
|
{
|
||||||
|
if (this != &o) {
|
||||||
|
Cleanup();
|
||||||
|
// Transfer members values
|
||||||
|
mPtr = std::move(o.mPtr);
|
||||||
|
mOwned = o.mOwned;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle.
|
||||||
|
*/
|
||||||
|
void Validate() const { if (!mPtr) STHROWF("Invalid discord user handle"); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle and retrieve a const reference to it.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Ptr::element_type & Valid() const { Validate(); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether a valid instance is managed.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsValid() const { return static_cast< bool >(mPtr); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve user discord username.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetUsername() const { return Valid().username; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve user discriminator (aka tag), 4 digits usually displayed with leading zeroes.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetDiscriminator() const { return static_cast< SQInteger >(Valid().discriminator); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve user avatar hash.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const dpp::utility::iconhash & GetAvatar() const { return Valid().avatar; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve user flags built from a bitmask of values in dpp::user_flags.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetFlags() const { return static_cast< SQInteger >(Valid().flags); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve user feference count of how many guilds this user is in.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetRefCount() const { return static_cast< SQInteger >(Valid().refcount); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the avatar url of the user object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string GetAvatarURL() const { return Valid().get_avatar_url(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is a bot.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsBot() const { return Valid().is_bot(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is a system user (Clyde).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsSystem() const { return Valid().is_system(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user has multi-factor authentication enabled.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsMfaEnabled() const { return Valid().is_mfa_enabled(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user has verified account.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsVerified() const { return Valid().is_verified(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user has full nitro.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasNitroFull() const { return Valid().has_nitro_full(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user has nitro classic.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasNitroClassic() const { return Valid().has_nitro_classic(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is a discord employee.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsDiscordEmployee() const { return Valid().is_discord_employee(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user owns a partnered server.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsPartneredOwner() const { return Valid().is_partnered_owner(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user has hype-squad events.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasHypesquadEvents() const { return Valid().has_hypesquad_events(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user has the bug-hunter level 1 badge.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsBughunter1() const { return Valid().is_bughunter_1(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is in house bravery.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsHouseBravery() const { return Valid().is_house_bravery(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is in house brilliance.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsHouseBrilliance() const { return Valid().is_house_brilliance(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is in house balance.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsHouseBalanace() const { return Valid().is_house_balanace(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is an early supporter.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsEarlySupporter() const { return Valid().is_early_supporter(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is a team user.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsTeamUser() const { return Valid().is_team_user(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user has the bug-hunter level 2 badge.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsBughunter2() const { return Valid().is_bughunter_2(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user has the verified bot badge.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsVerifiedBot() const { return Valid().is_verified_bot(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is an early verified bot developer.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsVerifiedBotDev() const { return Valid().is_verified_bot_dev(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is a certified moderator.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsCertifiedDoderator() const { return Valid().is_certified_moderator(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user has an animated icon.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasAnimatedIcon() const { return Valid().has_animated_icon(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/DPP/Utilities.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,429 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Wrapper around a std::vector of DPP values.
|
||||||
|
*/
|
||||||
|
template < class T, class W > struct DpVectorProxy
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< std::vector< T > >;
|
||||||
|
using Vec = std::vector< std::pair< LightObj, W * > >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced vector instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Cached script objects vector.
|
||||||
|
*/
|
||||||
|
Vec mVec{};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Whether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpVectorProxy() noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpVectorProxy(typename Ptr::pointer ptr, bool owned = false)
|
||||||
|
: mPtr(ptr), mVec(), mOwned(owned)
|
||||||
|
{ if (mPtr) mVec.resize(mPtr->size()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpVectorProxy(const typename Ptr::element_type & o) noexcept
|
||||||
|
: DpVectorProxy(new typename Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpVectorProxy(typename Ptr::element_type && o) noexcept
|
||||||
|
: DpVectorProxy(new typename Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpVectorProxy(const DpVectorProxy & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpVectorProxy(DpVectorProxy && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpVectorProxy() noexcept { Cleanup(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpVectorProxy & operator = (const DpVectorProxy & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpVectorProxy & operator = (DpVectorProxy && o) noexcept
|
||||||
|
{
|
||||||
|
if (this != &o) {
|
||||||
|
Cleanup();
|
||||||
|
// Transfer members values
|
||||||
|
mPtr = std::move(o.mPtr);
|
||||||
|
mVec = std::move(o.mVec);
|
||||||
|
mOwned = o.mOwned;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Release any referenced resources and default to an empty/invalid state.
|
||||||
|
*/
|
||||||
|
void Cleanup()
|
||||||
|
{
|
||||||
|
// Invalidate cached instances
|
||||||
|
ClearCache();
|
||||||
|
// Do we own this to try delete it?
|
||||||
|
if (!mOwned && mPtr) {
|
||||||
|
// Not our job, simply forget about it
|
||||||
|
[[maybe_unused]] auto p = mPtr.release();
|
||||||
|
} else mPtr.reset(); // We own this so delete the instance
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle.
|
||||||
|
*/
|
||||||
|
void Validate() const { if (!mPtr) STHROWF("Invalid discord vector handle"); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed handle and retrieve a const reference to it.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD typename Ptr::element_type & Valid() const { Validate(); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether a valid instance is managed.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsValid() const { return static_cast< bool >(mPtr); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Make sure an index is within range and return the container. Container must exist.
|
||||||
|
*/
|
||||||
|
void ValidIdx_(SQInteger i)
|
||||||
|
{
|
||||||
|
if (static_cast< size_t >(i) >= Valid().size())
|
||||||
|
{
|
||||||
|
STHROWF("Invalid vector container index({})", i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
typename Ptr::element_type & ValidIdx(SQInteger i) { ValidIdx_(i); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Make sure an index is within range and return the container. Container must exist.
|
||||||
|
*/
|
||||||
|
void ValidIdx_(SQInteger i) const
|
||||||
|
{
|
||||||
|
if (static_cast< size_t >(i) >= Valid().size())
|
||||||
|
{
|
||||||
|
STHROWF("Invalid vector container index({})", i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const typename Ptr::element_type & ValidIdx(SQInteger i) const { ValidIdx_(i); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Make sure a container instance is referenced and is populated, then return it.
|
||||||
|
*/
|
||||||
|
void ValidPop_()
|
||||||
|
{
|
||||||
|
if (Valid().empty())
|
||||||
|
{
|
||||||
|
STHROWF("Vector container is empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
typename Ptr::element_type & ValidPop() { ValidPop_(); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Make sure a container instance is referenced and is populated, then return it.
|
||||||
|
*/
|
||||||
|
void ValidPop_() const
|
||||||
|
{
|
||||||
|
if (Valid().empty())
|
||||||
|
{
|
||||||
|
STHROWF("Vector container is empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const typename Ptr::element_type & ValidPop() const { ValidPop_(); return *mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if a container instance is referenced.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsNull() const { return !mPtr; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve a value from the container.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj & Get_(SQInteger i)
|
||||||
|
{
|
||||||
|
// Is the element cached?
|
||||||
|
if (mVec[static_cast< size_t >(i)].first.IsNull())
|
||||||
|
{
|
||||||
|
mVec[static_cast< size_t >(i)] = Obj(&mPtr->at(static_cast< size_t >(i)));
|
||||||
|
}
|
||||||
|
// Return the object from the cache
|
||||||
|
return mVec[static_cast< size_t >(i)].first;
|
||||||
|
}
|
||||||
|
SQMOD_NODISCARD LightObj & Get(SQInteger i)
|
||||||
|
{
|
||||||
|
// Was the referenced vector modified?
|
||||||
|
if (mVec.size() < Valid().size())
|
||||||
|
{
|
||||||
|
// Synchronize the size
|
||||||
|
mVec.resize(mPtr->size());
|
||||||
|
// Synchronize the cache
|
||||||
|
CacheSync();
|
||||||
|
}
|
||||||
|
// Validate index
|
||||||
|
ValidIdx_(i);
|
||||||
|
// Perform the request
|
||||||
|
return Get_(i);
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify a value from the container.
|
||||||
|
*/
|
||||||
|
void Set(SQInteger i, const W & v) { ValidIdx(i)[static_cast< size_t >(i)] = v.Valid(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if the container has no elements.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool Empty() const { return Valid().empty(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the number of elements in the container.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger Size() const { return static_cast< SQInteger >(Valid().size()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the number of elements that the container has currently allocated space for.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger Capacity() const { return static_cast< SQInteger >(Valid().capacity()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Synchronize cache container instances.
|
||||||
|
*/
|
||||||
|
void CacheSync()
|
||||||
|
{
|
||||||
|
// Invalidate cached instances, if any
|
||||||
|
for (size_t i = 0; i < mVec.size(); ++i)
|
||||||
|
{
|
||||||
|
// Is this element cached?
|
||||||
|
if (mVec[i].second != nullptr)
|
||||||
|
{
|
||||||
|
// Discard previous instance, if any
|
||||||
|
[[maybe_unused]] auto _ = mVec[i].second->mPtr.release();
|
||||||
|
// Sync to new instance
|
||||||
|
mVec[i].second->mPtr.reset(&mPtr->at(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Increase the capacity of the container to a value that's greater or equal to the one specified.
|
||||||
|
*/
|
||||||
|
DpVectorProxy & Reserve(SQInteger n)
|
||||||
|
{
|
||||||
|
Valid().reserve(ClampL< SQInteger, size_t >(n));
|
||||||
|
mVec.reserve(mPtr->size());
|
||||||
|
CacheSync();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Request the removal of unused capacity.
|
||||||
|
*/
|
||||||
|
void Compact() { Valid().shrink_to_fit(); CacheSync(); mVec.shrink_to_fit(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Erase all elements from the cache container.
|
||||||
|
*/
|
||||||
|
void ClearCache()
|
||||||
|
{
|
||||||
|
// Invalidate cached instances, if any
|
||||||
|
for (auto & e : mVec)
|
||||||
|
{
|
||||||
|
// Is this element cached?
|
||||||
|
if (e.second != nullptr)
|
||||||
|
{
|
||||||
|
// Invalidate the instance
|
||||||
|
e.second->Cleanup();
|
||||||
|
// Forget about it
|
||||||
|
e.second = nullptr;
|
||||||
|
// Release script object
|
||||||
|
e.first.Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Clear the cache vector
|
||||||
|
mVec.clear();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Erase all elements from the container.
|
||||||
|
*/
|
||||||
|
void Clear() { Validate(); ClearCache(); mPtr->clear(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Push a value at the back of the container.
|
||||||
|
*/
|
||||||
|
void Push(const W & v)
|
||||||
|
{
|
||||||
|
Valid().push_back(v.Valid());
|
||||||
|
mVec.emplace_back();
|
||||||
|
CacheSync();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Extends the Container by appending all the items in the given container.
|
||||||
|
*/
|
||||||
|
void Extend(DpVectorProxy & v)
|
||||||
|
{
|
||||||
|
Valid().insert(Valid().end(), v.Valid().begin(), v.Valid().end());
|
||||||
|
mVec.resize(mPtr->size());
|
||||||
|
CacheSync();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Pop the last element in the container.
|
||||||
|
*/
|
||||||
|
void Pop()
|
||||||
|
{
|
||||||
|
Validate();
|
||||||
|
// Is this element cached?
|
||||||
|
if (mVec.back().second != nullptr)
|
||||||
|
{
|
||||||
|
// Invalidate the instance
|
||||||
|
mVec.back().second->Cleanup();
|
||||||
|
mVec.back().first.Release();
|
||||||
|
}
|
||||||
|
// Safe to remove
|
||||||
|
mPtr->pop_back();
|
||||||
|
mVec.pop_back();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Erase the element at a certain position.
|
||||||
|
*/
|
||||||
|
void EraseAt(SQInteger i)
|
||||||
|
{
|
||||||
|
ValidIdx_(i);
|
||||||
|
// Is this element cached?
|
||||||
|
if (mVec[static_cast< size_t >(i)].second != nullptr)
|
||||||
|
{
|
||||||
|
// Invalidate the instance
|
||||||
|
mVec[static_cast< size_t >(i)].second->Cleanup();
|
||||||
|
mVec[static_cast< size_t >(i)].first.Release();
|
||||||
|
}
|
||||||
|
// Safe to remove
|
||||||
|
mPtr->erase(mPtr->begin() + static_cast< size_t >(i));
|
||||||
|
mVec.erase(mVec.begin() + static_cast< size_t >(i));
|
||||||
|
// Synchronize cache
|
||||||
|
CacheSync();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Iterate all values through a functor.
|
||||||
|
*/
|
||||||
|
void Each(Function & fn)
|
||||||
|
{
|
||||||
|
Validate();
|
||||||
|
// Iterate referenced vector elements
|
||||||
|
for (size_t i = 0; i < mVec.size(); ++i)
|
||||||
|
{
|
||||||
|
fn.Execute(Get(static_cast< SQInteger >(i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Iterate values in range through a functor.
|
||||||
|
*/
|
||||||
|
void EachRange(SQInteger p, SQInteger n, Function & fn)
|
||||||
|
{
|
||||||
|
ValidIdx_(p);
|
||||||
|
ValidIdx_(p + n);
|
||||||
|
// Iterate specified range
|
||||||
|
for (n += p; p < n; ++p)
|
||||||
|
{
|
||||||
|
fn.Execute(Get(static_cast< SQInteger >(p)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Iterate all values through a functor until stopped (i.e false is returned).
|
||||||
|
*/
|
||||||
|
void While(Function & fn)
|
||||||
|
{
|
||||||
|
Validate();
|
||||||
|
// Iterate referenced vector elements
|
||||||
|
for (size_t i = 0; i < mVec.size(); ++i)
|
||||||
|
{
|
||||||
|
auto ret = fn.Eval(Get(static_cast< SQInteger >(i)));
|
||||||
|
// (null || true) == continue & false == break
|
||||||
|
if (!ret.IsNull() || !ret.template Cast< bool >())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Iterate values in range through a functor until stopped (i.e false is returned).
|
||||||
|
*/
|
||||||
|
void WhileRange(SQInteger p, SQInteger n, Function & fn)
|
||||||
|
{
|
||||||
|
ValidIdx_(p);
|
||||||
|
ValidIdx_(p + n);
|
||||||
|
// Iterate specified range
|
||||||
|
for (n += p; p < n; ++p)
|
||||||
|
{
|
||||||
|
auto ret = fn.Eval(Get(static_cast< SQInteger >(p)));
|
||||||
|
// (null || true) == continue & false == break
|
||||||
|
if (!ret.IsNull() || !ret.template Cast< bool >())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve a wrapped instance as a script object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD static std::pair< LightObj, W * > Obj(T * ptr, bool owned = false)
|
||||||
|
{
|
||||||
|
// Create the wrapper instance for given pointer
|
||||||
|
auto wp = std::make_unique< W >(ptr, false);
|
||||||
|
// Create script object for wrapper instance
|
||||||
|
std::pair< LightObj, W * > p{LightObj{wp.get()}, wp.get()};
|
||||||
|
// Release ownership of the wrapper instance
|
||||||
|
[[maybe_unused]] auto _ = wp.release();
|
||||||
|
// Return the script object and wrapper instance
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve a wrapped instance as a script object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD static std::pair< LightObj, W * > Obj(const T * ptr, bool owned = false)
|
||||||
|
{
|
||||||
|
return Obj(const_cast< T * >(ptr), owned);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template < class T, class W, class U > inline void Register_DPP_VectorProxy(HSQUIRRELVM vm, Table & ns, const SQChar * name)
|
||||||
|
{
|
||||||
|
using Container = DpVectorProxy< T, W >;
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(name,
|
||||||
|
Class< Container, NoConstructor< Container > >(vm, U::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &U::Fn)
|
||||||
|
// Properties
|
||||||
|
.Prop(_SC("Null"), &Container::IsNull)
|
||||||
|
.Prop(_SC("Empty"), &Container::Empty)
|
||||||
|
.Prop(_SC("Size"), &Container::Size)
|
||||||
|
.Prop(_SC("Capacity"), &Container::Capacity, &Container::Reserve)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("Get"), &Container::Get)
|
||||||
|
.Func(_SC("Set"), &Container::Set)
|
||||||
|
.Func(_SC("Reserve"), &Container::Reserve)
|
||||||
|
.Func(_SC("Compact"), &Container::Compact)
|
||||||
|
.Func(_SC("Clear"), &Container::Clear)
|
||||||
|
.Func(_SC("Push"), &Container::Push)
|
||||||
|
.Func(_SC("Append"), &Container::Push)
|
||||||
|
.Func(_SC("Extend"), &Container::Extend)
|
||||||
|
.Func(_SC("Pop"), &Container::Pop)
|
||||||
|
.Func(_SC("EraseAt"), &Container::EraseAt)
|
||||||
|
.Func(_SC("Each"), &Container::Each)
|
||||||
|
.Func(_SC("EachRange"), &Container::EachRange)
|
||||||
|
.Func(_SC("While"), &Container::While)
|
||||||
|
.Func(_SC("WhileRange"), &Container::WhileRange)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/IO/Buffer.hpp"
|
#include "Library/IO/Buffer.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
#include "Base/AABB.hpp"
|
#include "Base/AABB.hpp"
|
||||||
#include "Base/Circle.hpp"
|
#include "Base/Circle.hpp"
|
||||||
#include "Base/Color3.hpp"
|
#include "Base/Color3.hpp"
|
||||||
@@ -20,25 +19,7 @@ namespace SqMod {
|
|||||||
SQMOD_DECL_TYPENAME(Typename, _SC("SqBuffer"))
|
SQMOD_DECL_TYPENAME(Typename, _SC("SqBuffer"))
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteInt64(const SLongInt & val)
|
SQInteger SqBuffer::WriteRawString(StackStrF & val) const
|
||||||
{
|
|
||||||
// Validate the managed buffer reference
|
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< int64_t >(val.GetNum());
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void SqBuffer::WriteUint64(const ULongInt & val)
|
|
||||||
{
|
|
||||||
// Validate the managed buffer reference
|
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< uint64_t >(val.GetNum());
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
SQInteger SqBuffer::WriteRawString(StackStrF & val)
|
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
Validate();
|
Validate();
|
||||||
@@ -56,7 +37,7 @@ SQInteger SqBuffer::WriteRawString(StackStrF & val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger SqBuffer::WriteClientString(StackStrF & val)
|
SQInteger SqBuffer::WriteClientString(StackStrF & val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
Validate();
|
Validate();
|
||||||
@@ -81,97 +62,67 @@ SQInteger SqBuffer::WriteClientString(StackStrF & val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteAABB(const AABB & val)
|
void SqBuffer::WriteAABB(const AABB & val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< AABB >(val);
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< AABB >(val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteCircle(const Circle & val)
|
void SqBuffer::WriteCircle(const Circle & val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< Circle >(val);
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< Circle >(val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteColor3(const Color3 & val)
|
void SqBuffer::WriteColor3(const Color3 & val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< Color3 >(val);
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< Color3 >(val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteColor4(const Color4 & val)
|
void SqBuffer::WriteColor4(const Color4 & val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< Color4 >(val);
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< Color4 >(val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteQuaternion(const Quaternion & val)
|
void SqBuffer::WriteQuaternion(const Quaternion & val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< Quaternion >(val);
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< Quaternion >(val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteSphere(const Sphere &val)
|
void SqBuffer::WriteSphere(const Sphere &val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< Sphere >(val);
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< Sphere >(val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteVector2(const Vector2 & val)
|
void SqBuffer::WriteVector2(const Vector2 & val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< Vector2 >(val);
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< Vector2 >(val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteVector2i(const Vector2i & val)
|
void SqBuffer::WriteVector2i(const Vector2i & val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< Vector2i >(val);
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< Vector2i >(val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteVector3(const Vector3 & val)
|
void SqBuffer::WriteVector3(const Vector3 & val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< Vector3 >(val);
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< Vector3 >(val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteVector4(const Vector4 & val)
|
void SqBuffer::WriteVector4(const Vector4 & val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< Vector4 >(val);
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< Vector4 >(val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SLongInt SqBuffer::ReadInt64()
|
SQInteger SqBuffer::ReadInt64() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -180,11 +131,11 @@ SLongInt SqBuffer::ReadInt64()
|
|||||||
// Advance the buffer cursor
|
// Advance the buffer cursor
|
||||||
m_Buffer->Advance< int64_t >(1);
|
m_Buffer->Advance< int64_t >(1);
|
||||||
// Return the requested information
|
// Return the requested information
|
||||||
return SLongInt(value);
|
return static_cast< SQInteger >(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
ULongInt SqBuffer::ReadUint64()
|
SQInteger SqBuffer::ReadUint64() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -193,11 +144,11 @@ ULongInt SqBuffer::ReadUint64()
|
|||||||
// Advance the buffer cursor
|
// Advance the buffer cursor
|
||||||
m_Buffer->Advance< uint64_t >(1);
|
m_Buffer->Advance< uint64_t >(1);
|
||||||
// Return the requested information
|
// Return the requested information
|
||||||
return ULongInt(value);
|
return static_cast< SQInteger >(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj SqBuffer::ReadRawString(SQInteger length)
|
LightObj SqBuffer::ReadRawString(SQInteger length) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -237,7 +188,7 @@ LightObj SqBuffer::ReadRawString(SQInteger length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj SqBuffer::ReadClientString()
|
LightObj SqBuffer::ReadClientString() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -264,7 +215,7 @@ LightObj SqBuffer::ReadClientString()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
AABB SqBuffer::ReadAABB()
|
AABB SqBuffer::ReadAABB() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -277,7 +228,7 @@ AABB SqBuffer::ReadAABB()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Circle SqBuffer::ReadCircle()
|
Circle SqBuffer::ReadCircle() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -290,7 +241,7 @@ Circle SqBuffer::ReadCircle()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Color3 SqBuffer::ReadColor3()
|
Color3 SqBuffer::ReadColor3() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -303,7 +254,7 @@ Color3 SqBuffer::ReadColor3()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Color4 SqBuffer::ReadColor4()
|
Color4 SqBuffer::ReadColor4() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -316,7 +267,7 @@ Color4 SqBuffer::ReadColor4()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Quaternion SqBuffer::ReadQuaternion()
|
Quaternion SqBuffer::ReadQuaternion() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -329,7 +280,7 @@ Quaternion SqBuffer::ReadQuaternion()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Sphere SqBuffer::ReadSphere()
|
Sphere SqBuffer::ReadSphere() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -342,7 +293,7 @@ Sphere SqBuffer::ReadSphere()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Vector2 SqBuffer::ReadVector2()
|
Vector2 SqBuffer::ReadVector2() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -355,7 +306,7 @@ Vector2 SqBuffer::ReadVector2()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Vector2i SqBuffer::ReadVector2i()
|
Vector2i SqBuffer::ReadVector2i() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -368,7 +319,7 @@ Vector2i SqBuffer::ReadVector2i()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Vector3 SqBuffer::ReadVector3()
|
Vector3 SqBuffer::ReadVector3() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -381,7 +332,7 @@ Vector3 SqBuffer::ReadVector3()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Vector4 SqBuffer::ReadVector4()
|
Vector4 SqBuffer::ReadVector4() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -394,7 +345,7 @@ Vector4 SqBuffer::ReadVector4()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger SqBuffer::GetCRC32(SQInteger n)
|
SQInteger SqBuffer::GetCRC32(SQInteger n) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -407,7 +358,7 @@ SQInteger SqBuffer::GetCRC32(SQInteger n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger SqBuffer::GetADLER32(SQInteger n)
|
SQInteger SqBuffer::GetADLER32(SQInteger n) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
|
|||||||
+118
-199
@@ -45,7 +45,6 @@ public:
|
|||||||
SqBuffer()
|
SqBuffer()
|
||||||
: m_Buffer(new Buffer())
|
: m_Buffer(new Buffer())
|
||||||
{
|
{
|
||||||
/* ... */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -54,7 +53,6 @@ public:
|
|||||||
explicit SqBuffer(SQInteger n)
|
explicit SqBuffer(SQInteger n)
|
||||||
: m_Buffer(new Buffer(ConvTo< SzType >::From(n)))
|
: m_Buffer(new Buffer(ConvTo< SzType >::From(n)))
|
||||||
{
|
{
|
||||||
/* ... */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -63,7 +61,6 @@ public:
|
|||||||
SqBuffer(SQInteger n, SQInteger c)
|
SqBuffer(SQInteger n, SQInteger c)
|
||||||
: m_Buffer(new Buffer(ConvTo< SzType >::From(n), ConvTo< SzType >::From(c)))
|
: m_Buffer(new Buffer(ConvTo< SzType >::From(n), ConvTo< SzType >::From(c)))
|
||||||
{
|
{
|
||||||
/* ... */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -72,7 +69,6 @@ public:
|
|||||||
SqBuffer(ConstPtr p, SQInteger n)
|
SqBuffer(ConstPtr p, SQInteger n)
|
||||||
: m_Buffer(new Buffer(p, ConvTo< SzType >::From(n)))
|
: m_Buffer(new Buffer(p, ConvTo< SzType >::From(n)))
|
||||||
{
|
{
|
||||||
/* ... */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -81,7 +77,6 @@ public:
|
|||||||
SqBuffer(ConstPtr p, SQInteger n, SQInteger c)
|
SqBuffer(ConstPtr p, SQInteger n, SQInteger c)
|
||||||
: m_Buffer(new Buffer(p, ConvTo< SzType >::From(n), ConvTo< SzType >::From(c)))
|
: m_Buffer(new Buffer(p, ConvTo< SzType >::From(n), ConvTo< SzType >::From(c)))
|
||||||
{
|
{
|
||||||
/* ... */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -90,7 +85,6 @@ public:
|
|||||||
explicit SqBuffer(const SRef & ref) // NOLINT(modernize-pass-by-value)
|
explicit SqBuffer(const SRef & ref) // NOLINT(modernize-pass-by-value)
|
||||||
: m_Buffer(ref)
|
: m_Buffer(ref)
|
||||||
{
|
{
|
||||||
/* ... */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -99,7 +93,6 @@ public:
|
|||||||
explicit SqBuffer(const Buffer & b)
|
explicit SqBuffer(const Buffer & b)
|
||||||
: m_Buffer(new Buffer(b))
|
: m_Buffer(new Buffer(b))
|
||||||
{
|
{
|
||||||
/* ... */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -108,7 +101,6 @@ public:
|
|||||||
explicit SqBuffer(Buffer && b)
|
explicit SqBuffer(Buffer && b)
|
||||||
: m_Buffer(new Buffer(std::move(b)))
|
: m_Buffer(new Buffer(std::move(b)))
|
||||||
{
|
{
|
||||||
/* ... */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -181,26 +173,40 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed memory buffer reference.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Buffer & Valid() const
|
||||||
|
{
|
||||||
|
Validate();
|
||||||
|
// Return the buffer
|
||||||
|
return *m_Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Validate the managed memory buffer reference and the buffer itself.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Buffer & ValidDeeper() const
|
||||||
|
{
|
||||||
|
ValidateDeeper();
|
||||||
|
// Return the buffer
|
||||||
|
return *m_Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve a certain element type at the specified position.
|
* Retrieve a certain element type at the specified position.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Value Get(SQInteger n) const
|
SQMOD_NODISCARD Value Get(SQInteger n) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
return Valid().At(ConvTo< SzType >::From(n));
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
return m_Buffer->At(ConvTo< SzType >::From(n));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify a certain element type at the specified position.
|
* Modify a certain element type at the specified position.
|
||||||
*/
|
*/
|
||||||
void Set(SQInteger n, SQInteger v)
|
void Set(SQInteger n, SQInteger v) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().At(ConvTo< SzType >::From(n)) = ConvTo< Value >::From(v);
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
m_Buffer->At(ConvTo< SzType >::From(n)) = ConvTo< Value >::From(v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -208,21 +214,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Value GetFront() const
|
SQMOD_NODISCARD Value GetFront() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
return Valid().Front();
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
return m_Buffer->Front();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the element at the front of the buffer.
|
* Modify the element at the front of the buffer.
|
||||||
*/
|
*/
|
||||||
void SetFront(SQInteger v)
|
void SetFront(SQInteger v) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Front() = ConvTo< Value >::From(v);
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
m_Buffer->Front() = ConvTo< Value >::From(v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -230,21 +230,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Value GetNext() const
|
SQMOD_NODISCARD Value GetNext() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
return Valid().Next();
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
return m_Buffer->Next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the element after the first element in the buffer.
|
* Modify the element after the first element in the buffer.
|
||||||
*/
|
*/
|
||||||
void SetNext(SQInteger v)
|
void SetNext(SQInteger v) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Next() = ConvTo< Value >::From(v);
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
m_Buffer->Next() = ConvTo< Value >::From(v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -252,21 +246,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Value GetBack() const
|
SQMOD_NODISCARD Value GetBack() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
return Valid().Back();
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
return m_Buffer->Back();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the element at the back of the buffer.
|
* Modify the element at the back of the buffer.
|
||||||
*/
|
*/
|
||||||
void SetBack(SQInteger v)
|
void SetBack(SQInteger v) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Back() = ConvTo< Value >::From(v);
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
m_Buffer->Back() = ConvTo< Value >::From(v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -274,65 +262,47 @@ public:
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Value GetPrev() const
|
SQMOD_NODISCARD Value GetPrev() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
return Valid().Prev();
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
return m_Buffer->Prev();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the element before the last element in the buffer.
|
* Modify the element before the last element in the buffer.
|
||||||
*/
|
*/
|
||||||
void SetPrev(SQInteger v)
|
void SetPrev(SQInteger v) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Prev() = ConvTo< Value >::From(v);
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
m_Buffer->Prev() = ConvTo< Value >::From(v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Reposition the edit cursor to the specified number of elements ahead.
|
* Reposition the edit cursor to the specified number of elements ahead.
|
||||||
*/
|
*/
|
||||||
void Advance(SQInteger n)
|
void Advance(SQInteger n) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Advance(ConvTo< SzType >::From(n));
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Advance(ConvTo< SzType >::From(n));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Reposition the edit cursor to the specified number of elements behind.
|
* Reposition the edit cursor to the specified number of elements behind.
|
||||||
*/
|
*/
|
||||||
void Retreat(SQInteger n)
|
void Retreat(SQInteger n) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Retreat(ConvTo< SzType >::From(n));
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Retreat(ConvTo< SzType >::From(n));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Reposition the edit cursor to a fixed position within the buffer.
|
* Reposition the edit cursor to a fixed position within the buffer.
|
||||||
*/
|
*/
|
||||||
void Move(SQInteger n)
|
void Move(SQInteger n) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Move(ConvTo< SzType >::From(n));
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Move(ConvTo< SzType >::From(n));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Append a value to the current cursor location and advance the cursor.
|
* Append a value to the current cursor location and advance the cursor.
|
||||||
*/
|
*/
|
||||||
void Push(SQInteger v)
|
void Push(SQInteger v) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push(ConvTo< Value >::From(v));
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push(ConvTo< Value >::From(v));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -340,21 +310,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Value GetCursor() const
|
SQMOD_NODISCARD Value GetCursor() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
return Valid().Cursor();
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
return m_Buffer->Cursor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the element at the cursor position.
|
* Modify the element at the cursor position.
|
||||||
*/
|
*/
|
||||||
void SetCursor(SQInteger v)
|
void SetCursor(SQInteger v) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Cursor() = ConvTo< Value >::From(v);
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
m_Buffer->Cursor() = ConvTo< Value >::From(v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -362,21 +326,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Value GetBefore() const
|
SQMOD_NODISCARD Value GetBefore() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
return Valid().Before();
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
return m_Buffer->Before();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the element before the cursor position.
|
* Modify the element before the cursor position.
|
||||||
*/
|
*/
|
||||||
void SetBefore(SQInteger v)
|
void SetBefore(SQInteger v) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Before() = ConvTo< Value >::From(v);
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
m_Buffer->Before() = ConvTo< Value >::From(v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -384,21 +342,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Value GetAfter() const
|
SQMOD_NODISCARD Value GetAfter() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
return Valid().After();
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
return m_Buffer->After();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the element after the cursor position.
|
* Modify the element after the cursor position.
|
||||||
*/
|
*/
|
||||||
void SetAfter(SQInteger v)
|
void SetAfter(SQInteger v) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().After() = ConvTo< Value >::From(v);
|
||||||
Validate();
|
|
||||||
// Return the requested element
|
|
||||||
m_Buffer->After() = ConvTo< Value >::From(v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -414,10 +366,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SzType GetSize() const
|
SQMOD_NODISCARD SzType GetSize() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
return Valid().CapacityAs< Value >();
|
||||||
Validate();
|
|
||||||
// Return the requested information
|
|
||||||
return m_Buffer->CapacityAs< Value >();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -425,10 +374,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SzType GetCapacity() const
|
SQMOD_NODISCARD SzType GetCapacity() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
return Valid().Capacity();
|
||||||
Validate();
|
|
||||||
// Return the requested information
|
|
||||||
return m_Buffer->Capacity();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -436,10 +382,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SzType GetPosition() const
|
SQMOD_NODISCARD SzType GetPosition() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
return Valid().Position();
|
||||||
Validate();
|
|
||||||
// Return the requested information
|
|
||||||
return m_Buffer->Position();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -447,21 +390,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SzType GetRemaining() const
|
SQMOD_NODISCARD SzType GetRemaining() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
return Valid().Remaining();
|
||||||
Validate();
|
|
||||||
// Return the requested information
|
|
||||||
return m_Buffer->Remaining();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Grow the size of the internal buffer by the specified amount of bytes.
|
* Grow the size of the internal buffer by the specified amount of bytes.
|
||||||
*/
|
*/
|
||||||
void Grow(SQInteger n)
|
void Grow(SQInteger n) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
return Valid().Grow(ConvTo< SzType >::From(n) * sizeof(Value));
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
return m_Buffer->Grow(ConvTo< SzType >::From(n) * sizeof(Value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -488,165 +425,147 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a signed 8 bit integer to the buffer.
|
* Write a signed 8 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteInt8(SQInteger val)
|
void WriteInt8(SQInteger val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< int8_t >(static_cast< int8_t >(val));
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< int8_t >(ConvTo< int8_t >::From(val));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write an unsigned 8 bit integer to the buffer.
|
* Write an unsigned 8 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteUint8(SQInteger val)
|
void WriteUint8(SQInteger val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< uint8_t >(static_cast< uint8_t >(val));
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< uint8_t >(ConvTo< uint8_t >::From(val));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a signed 16 bit integer to the buffer.
|
* Write a signed 16 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteInt16(SQInteger val)
|
void WriteInt16(SQInteger val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< int16_t >(static_cast< int16_t >(val));
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< int16_t >(ConvTo< int16_t >::From(val));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write an unsigned 16 bit integer to the buffer.
|
* Write an unsigned 16 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteUint16(SQInteger val)
|
void WriteUint16(SQInteger val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< uint16_t >(static_cast< uint16_t >(val));
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< uint16_t >(ConvTo< uint16_t >::From(val));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a signed 32 bit integer to the buffer.
|
* Write a signed 32 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteInt32(SQInteger val)
|
void WriteInt32(SQInteger val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< int32_t >(static_cast< int32_t >(val));
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< int32_t >(ConvTo< int32_t >::From(val));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write an unsigned 32 bit integer to the buffer.
|
* Write an unsigned 32 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteUint32(SQInteger val)
|
void WriteUint32(SQInteger val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< uint32_t >(static_cast< uint32_t >(val));
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< uint32_t >(ConvTo< uint32_t >::From(val));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a signed 64 bit integer to the buffer.
|
* Write a signed 64 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteInt64(const SLongInt & val);
|
void WriteInt64(SQInteger val) const
|
||||||
|
{
|
||||||
|
Valid().Push< int64_t >(static_cast< int64_t >(val));
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write an unsigned 64 bit integer to the buffer.
|
* Write an unsigned 64 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteUint64(const ULongInt & val);
|
void WriteUint64(SQInteger val) const
|
||||||
|
{
|
||||||
|
Valid().Push< uint64_t >(static_cast< uint64_t >(val));
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a 32 bit float to the buffer.
|
* Write a 32 bit float to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteFloat32(SQFloat val)
|
void WriteFloat32(SQFloat val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< float >(ConvTo< float >::From(val));
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< float >(ConvTo< float >::From(val));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a 64 bit float to the buffer.
|
* Write a 64 bit float to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteFloat64(SQFloat val)
|
void WriteFloat64(SQFloat val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
Valid().Push< double >(ConvTo< double >::From(val));
|
||||||
Validate();
|
|
||||||
// Perform the requested operation
|
|
||||||
m_Buffer->Push< double >(ConvTo< double >::From(val));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a raw string to the buffer.
|
* Write a raw string to the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger WriteRawString(StackStrF & val);
|
SQInteger WriteRawString(StackStrF & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a client encoded string to the buffer.
|
* Write a client encoded string to the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger WriteClientString(StackStrF & val);
|
SQInteger WriteClientString(StackStrF & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a AABB to the buffer.
|
* Write a AABB to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteAABB(const AABB & val);
|
void WriteAABB(const AABB & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Circle to the buffer.
|
* Write a Circle to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteCircle(const Circle & val);
|
void WriteCircle(const Circle & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Color3 to the buffer.
|
* Write a Color3 to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteColor3(const Color3 & val);
|
void WriteColor3(const Color3 & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Color4 to the buffer.
|
* Write a Color4 to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteColor4(const Color4 & val);
|
void WriteColor4(const Color4 & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Quaternion to the buffer.
|
* Write a Quaternion to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteQuaternion(const Quaternion & val);
|
void WriteQuaternion(const Quaternion & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Sphere to the buffer.
|
* Write a Sphere to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteSphere(const Sphere &val);
|
void WriteSphere(const Sphere &val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Vector2 to the buffer.
|
* Write a Vector2 to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteVector2(const Vector2 & val);
|
void WriteVector2(const Vector2 & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Vector2i to the buffer.
|
* Write a Vector2i to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteVector2i(const Vector2i & val);
|
void WriteVector2i(const Vector2i & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Vector3 to the buffer.
|
* Write a Vector3 to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteVector3(const Vector3 & val);
|
void WriteVector3(const Vector3 & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Vector4 to the buffer.
|
* Write a Vector4 to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteVector4(const Vector4 & val);
|
void WriteVector4(const Vector4 & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a signed 8 bit integer from the buffer.
|
* Write a signed 8 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger ReadInt8()
|
SQMOD_NODISCARD SQInteger ReadInt8() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -661,7 +580,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read an unsigned 8 bit integer from the buffer.
|
* Read an unsigned 8 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger ReadUint8()
|
SQMOD_NODISCARD SQInteger ReadUint8() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -676,7 +595,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a signed 16 bit integer from the buffer.
|
* Read a signed 16 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger ReadInt16()
|
SQMOD_NODISCARD SQInteger ReadInt16() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -691,7 +610,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read an unsigned 16 bit integer from the buffer.
|
* Read an unsigned 16 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger ReadUint16()
|
SQMOD_NODISCARD SQInteger ReadUint16() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -706,7 +625,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a signed 32 bit integer from the buffer.
|
* Read a signed 32 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger ReadInt32()
|
SQMOD_NODISCARD SQInteger ReadInt32() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -721,7 +640,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read an unsigned 32 bit integer from the buffer.
|
* Read an unsigned 32 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger ReadUint32()
|
SQMOD_NODISCARD SQInteger ReadUint32() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -736,17 +655,17 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a signed 64 bit integer from the buffer.
|
* Read a signed 64 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
SLongInt ReadInt64();
|
SQMOD_NODISCARD SQInteger ReadInt64() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read an unsigned 64 bit integer from the buffer.
|
* Read an unsigned 64 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
ULongInt ReadUint64();
|
SQMOD_NODISCARD SQInteger ReadUint64() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a 32 bit float from the buffer.
|
* Read a 32 bit float from the buffer.
|
||||||
*/
|
*/
|
||||||
SQFloat ReadFloat32()
|
SQMOD_NODISCARD SQFloat ReadFloat32() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -761,7 +680,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a 64 bit float from the buffer.
|
* Read a 64 bit float from the buffer.
|
||||||
*/
|
*/
|
||||||
SQFloat ReadFloat64()
|
SQMOD_NODISCARD SQFloat ReadFloat64() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@@ -776,72 +695,72 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a raw string from the buffer.
|
* Read a raw string from the buffer.
|
||||||
*/
|
*/
|
||||||
LightObj ReadRawString(SQInteger length);
|
SQMOD_NODISCARD LightObj ReadRawString(SQInteger length) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a string from the buffer.
|
* Read a string from the buffer.
|
||||||
*/
|
*/
|
||||||
LightObj ReadClientString();
|
SQMOD_NODISCARD LightObj ReadClientString() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a AABB from the buffer.
|
* Read a AABB from the buffer.
|
||||||
*/
|
*/
|
||||||
AABB ReadAABB();
|
SQMOD_NODISCARD AABB ReadAABB() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Circle from the buffer.
|
* Read a Circle from the buffer.
|
||||||
*/
|
*/
|
||||||
Circle ReadCircle();
|
SQMOD_NODISCARD Circle ReadCircle() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Color3 from the buffer.
|
* Read a Color3 from the buffer.
|
||||||
*/
|
*/
|
||||||
Color3 ReadColor3();
|
SQMOD_NODISCARD Color3 ReadColor3() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Color4 from the buffer.
|
* Read a Color4 from the buffer.
|
||||||
*/
|
*/
|
||||||
Color4 ReadColor4();
|
SQMOD_NODISCARD Color4 ReadColor4() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Quaternion from the buffer.
|
* Read a Quaternion from the buffer.
|
||||||
*/
|
*/
|
||||||
Quaternion ReadQuaternion();
|
SQMOD_NODISCARD Quaternion ReadQuaternion() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Sphere from the buffer.
|
* Read a Sphere from the buffer.
|
||||||
*/
|
*/
|
||||||
Sphere ReadSphere();
|
SQMOD_NODISCARD Sphere ReadSphere() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Vector2 from the buffer.
|
* Read a Vector2 from the buffer.
|
||||||
*/
|
*/
|
||||||
Vector2 ReadVector2();
|
SQMOD_NODISCARD Vector2 ReadVector2() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Vector2i from the buffer.
|
* Read a Vector2i from the buffer.
|
||||||
*/
|
*/
|
||||||
Vector2i ReadVector2i();
|
SQMOD_NODISCARD Vector2i ReadVector2i() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Vector3 from the buffer.
|
* Read a Vector3 from the buffer.
|
||||||
*/
|
*/
|
||||||
Vector3 ReadVector3();
|
SQMOD_NODISCARD Vector3 ReadVector3() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Vector4 from the buffer.
|
* Read a Vector4 from the buffer.
|
||||||
*/
|
*/
|
||||||
Vector4 ReadVector4();
|
SQMOD_NODISCARD Vector4 ReadVector4() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Compute the CRC-32 checksums on the data in the buffer.
|
* Compute the CRC-32 checksums on the data in the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger GetCRC32(SQInteger n);
|
SQMOD_NODISCARD SQInteger GetCRC32(SQInteger n) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Compute the Adler-32 checksums on the data in the buffer.
|
* Compute the Adler-32 checksums on the data in the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger GetADLER32(SQInteger n);
|
SQMOD_NODISCARD SQInteger GetADLER32(SQInteger n) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
|||||||
+19
-19
@@ -36,7 +36,7 @@ static SQChar * Bin128ToDec(const uint32_t N[4])
|
|||||||
// Add s[] to itself in decimal, doubling it
|
// Add s[] to itself in decimal, doubling it
|
||||||
for (j = sizeof(s) - 2; j >= 0; j--)
|
for (j = sizeof(s) - 2; j >= 0; j--)
|
||||||
{
|
{
|
||||||
s[j] += s[j] - '0' + carry;
|
s[j] += s[j] - '0' + carry; // NOLINT(cppcoreguidelines-narrowing-conversions)
|
||||||
|
|
||||||
carry = (s[j] > '9');
|
carry = (s[j] > '9');
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ SQFloat GetEntryAsFloat(const MMDB_entry_data_s & ed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj GetEntryAsLong(const MMDB_entry_data_s & ed)
|
SQInteger GetEntryAsLong(const MMDB_entry_data_s & ed)
|
||||||
{
|
{
|
||||||
uint64_t value = 0;
|
uint64_t value = 0;
|
||||||
// Identify the type of entry data
|
// Identify the type of entry data
|
||||||
@@ -315,7 +315,7 @@ LightObj GetEntryAsLong(const MMDB_entry_data_s & ed)
|
|||||||
STHROWF("Unsupported conversion from ({}) to (long)", AsTypeStr(ed.type));
|
STHROWF("Unsupported conversion from ({}) to (long)", AsTypeStr(ed.type));
|
||||||
}
|
}
|
||||||
// Return a long integer instance with the requested value
|
// Return a long integer instance with the requested value
|
||||||
return LightObj(SqTypeIdentity< ULongInt >{}, SqVM(), value);
|
return static_cast< SQInteger >(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -338,7 +338,7 @@ LightObj GetEntryAsString(const MMDB_entry_data_s & ed)
|
|||||||
sq_pushstring(vm, fmt::format("{}", ed.double_value).c_str(), -1);
|
sq_pushstring(vm, fmt::format("{}", ed.double_value).c_str(), -1);
|
||||||
} break;
|
} break;
|
||||||
case MMDB_DATA_TYPE_BYTES: {
|
case MMDB_DATA_TYPE_BYTES: {
|
||||||
sq_pushstring(vm, reinterpret_cast< const SQChar * >(ed.bytes), ed.data_size / sizeof(SQChar));
|
sq_pushstring(vm, reinterpret_cast< const SQChar * >(ed.bytes), static_cast< SQInteger >(ed.data_size) / sizeof(SQChar));
|
||||||
} break;
|
} break;
|
||||||
case MMDB_DATA_TYPE_UINT16: {
|
case MMDB_DATA_TYPE_UINT16: {
|
||||||
sq_pushstring(vm, fmt::format("{}", ed.uint16).c_str(), -1);
|
sq_pushstring(vm, fmt::format("{}", ed.uint16).c_str(), -1);
|
||||||
@@ -444,7 +444,7 @@ void SockAddr::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid sockaddr structure handle =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid sockaddr structure handle =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -551,7 +551,7 @@ void Database::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind database reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind database reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -687,7 +687,7 @@ void Description::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind database reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind database reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -708,7 +708,7 @@ Description::Pointer Description::GetValid(const SQChar * file, int32_t line) co
|
|||||||
// Validate the referenced description
|
// Validate the referenced description
|
||||||
if (!m_Description)
|
if (!m_Description)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind meta-data description reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind meta-data description reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Return the description pointer
|
// Return the description pointer
|
||||||
return m_Description;
|
return m_Description;
|
||||||
@@ -747,7 +747,7 @@ void EntryData::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind database reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind database reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -768,7 +768,7 @@ EntryData::ConstRef EntryData::GetValid(const SQChar * file, int32_t line) const
|
|||||||
// See if the entry has any data
|
// See if the entry has any data
|
||||||
if (!m_Entry.has_data)
|
if (!m_Entry.has_data)
|
||||||
{
|
{
|
||||||
SqThrowF("The referenced entry has no data =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("The referenced entry has no data =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Return the entry
|
// Return the entry
|
||||||
return m_Entry;
|
return m_Entry;
|
||||||
@@ -821,7 +821,7 @@ void EntryDataList::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind database reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind database reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -842,7 +842,7 @@ EntryDataList::Pointer EntryDataList::GetValid(const SQChar * file, int32_t line
|
|||||||
// Validate the managed list
|
// Validate the managed list
|
||||||
if (!m_List)
|
if (!m_List)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind entry data list reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind entry data list reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// return the list
|
// return the list
|
||||||
return m_List;
|
return m_List;
|
||||||
@@ -869,7 +869,7 @@ EntryDataList::Pointer EntryDataList::GetValidElem(const SQChar * file, int32_t
|
|||||||
// Validate the current element
|
// Validate the current element
|
||||||
if (!m_List)
|
if (!m_List)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind entry data element reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind entry data element reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// return the element
|
// return the element
|
||||||
return m_Elem;
|
return m_Elem;
|
||||||
@@ -979,7 +979,7 @@ void LookupResult::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind database reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind database reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1051,7 +1051,7 @@ Object LookupResult::GetEntryDataList()
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger LookupResult::GetValue(HSQUIRRELVM vm)
|
SQInteger LookupResult::GetValue(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
const int32_t top = sq_gettop(vm);
|
const auto top = sq_gettop(vm);
|
||||||
// The lookup result instance
|
// The lookup result instance
|
||||||
LookupResult * lookup;
|
LookupResult * lookup;
|
||||||
// Attempt to extract the lookup result instance
|
// Attempt to extract the lookup result instance
|
||||||
@@ -1139,7 +1139,7 @@ void Metadata::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind database reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind database reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1160,7 +1160,7 @@ Metadata::Pointer Metadata::GetValid(const SQChar * file, int32_t line) const
|
|||||||
// Validate the referenced meta-data
|
// Validate the referenced meta-data
|
||||||
if (!m_Metadata)
|
if (!m_Metadata)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind meta-data reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind meta-data reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Return the meta-data pointer
|
// Return the meta-data pointer
|
||||||
return m_Metadata;
|
return m_Metadata;
|
||||||
@@ -1211,7 +1211,7 @@ void SearchNode::Validate(const SQChar * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid Maxmind database reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid Maxmind database reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1294,7 +1294,7 @@ Object SearchNode::GetRightRecordEntryDataList()
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger SearchNode::GetRecordEntryData(HSQUIRRELVM vm, bool right)
|
SQInteger SearchNode::GetRecordEntryData(HSQUIRRELVM vm, bool right)
|
||||||
{
|
{
|
||||||
const int32_t top = sq_gettop(vm);
|
const auto top = sq_gettop(vm);
|
||||||
// The search node result instance
|
// The search node result instance
|
||||||
SearchNode * node;
|
SearchNode * node;
|
||||||
// Attempt to extract the search node result instance
|
// Attempt to extract the search node result instance
|
||||||
|
|||||||
+9
-10
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/IO/Buffer.hpp"
|
#include "Library/IO/Buffer.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -76,7 +75,7 @@ SQFloat GetEntryAsFloat(const MMDB_entry_data_s & ed);
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value from the specified entry data as a long integer.
|
* Retrieve the value from the specified entry data as a long integer.
|
||||||
*/
|
*/
|
||||||
LightObj GetEntryAsLong(const MMDB_entry_data_s & ed);
|
SQInteger GetEntryAsLong(const MMDB_entry_data_s & ed);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value from the specified entry data as a string.
|
* Retrieve the value from the specified entry data as a string.
|
||||||
@@ -811,7 +810,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value from the current element as a long integer.
|
* Retrieve the value from the current element as a long integer.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj GetLong() const
|
SQMOD_NODISCARD SQInteger GetLong() const
|
||||||
{
|
{
|
||||||
return GetEntryAsLong(SQMOD_GET_VALID(*this));
|
return GetEntryAsLong(SQMOD_GET_VALID(*this));
|
||||||
}
|
}
|
||||||
@@ -1105,7 +1104,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value from the current element as a long integer.
|
* Retrieve the value from the current element as a long integer.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj GetLong() const
|
SQMOD_NODISCARD SQInteger GetLong() const
|
||||||
{
|
{
|
||||||
return GetEntryAsLong(SQMOD_GET_VALID_ELEM(*this)->entry_data);
|
return GetEntryAsLong(SQMOD_GET_VALID_ELEM(*this)->entry_data);
|
||||||
}
|
}
|
||||||
@@ -1492,9 +1491,9 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the build epoch.
|
* Retrieve the build epoch.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Object GetBuildEpoch() const
|
SQMOD_NODISCARD SQInteger GetBuildEpoch() const
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), ConvTo< uint64_t >::From(SQMOD_GET_VALID(*this)->build_epoch));
|
return ConvTo< SQInteger >::From(SQMOD_GET_VALID(*this)->build_epoch);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -1662,17 +1661,17 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the left record value.
|
* Retrieve the left record value.
|
||||||
*/
|
*/
|
||||||
Object GetLeftRecord()
|
SQInteger GetLeftRecord()
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), ConvTo< uint64_t >::From(SQMOD_GET_VALID(*this).left_record));
|
return ConvTo< SQInteger >::From(SQMOD_GET_VALID(*this).left_record);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the right record value.
|
* Retrieve the right record value.
|
||||||
*/
|
*/
|
||||||
Object GetRightRecord()
|
SQInteger GetRightRecord()
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), ConvTo< uint64_t >::From(SQMOD_GET_VALID(*this).right_record));
|
return ConvTo< SQInteger >::From(SQMOD_GET_VALID(*this).right_record);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
|||||||
+40
-46
@@ -534,7 +534,7 @@ bool DbConvTo< bool >::From(const SQChar * value, unsigned long length, enum_fie
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool DbConvTo< char >::From(const SQChar * value, unsigned long length, enum_field_types type, const SQChar * tn)
|
char DbConvTo< char >::From(const SQChar * value, unsigned long length, enum_field_types type, const SQChar * tn)
|
||||||
{
|
{
|
||||||
return ConvertToSInt< char >(value, length, type, tn);
|
return ConvertToSInt< char >(value, length, type, tn);
|
||||||
}
|
}
|
||||||
@@ -636,7 +636,7 @@ void ConnHnd::Create(const Account & acc)
|
|||||||
SQMOD_THROW_CURRENT(*this, "Cannot connect to database");
|
SQMOD_THROW_CURRENT(*this, "Cannot connect to database");
|
||||||
}
|
}
|
||||||
// Attempt configure the auto-commit option
|
// Attempt configure the auto-commit option
|
||||||
else if (mysql_autocommit(mPtr, mAutoCommit) != 0)
|
else if (mysql_autocommit(mPtr, static_cast< StmtBind::BoolType >(mAutoCommit)) != 0)
|
||||||
{
|
{
|
||||||
SQMOD_THROW_CURRENT(*this, "Cannot configure auto-commit");
|
SQMOD_THROW_CURRENT(*this, "Cannot configure auto-commit");
|
||||||
}
|
}
|
||||||
@@ -1555,7 +1555,7 @@ void Account::SetSSL(const SQChar * key, const SQChar * cert, const SQChar * ca,
|
|||||||
Table Account::GetOptionsTable() const
|
Table Account::GetOptionsTable() const
|
||||||
{
|
{
|
||||||
// Allocate an empty table
|
// Allocate an empty table
|
||||||
Table tbl(SqVM(), m_Options.size());
|
Table tbl(SqVM(), static_cast< SQInteger >(m_Options.size()));
|
||||||
// Insert every option into the table
|
// Insert every option into the table
|
||||||
for (const auto & opt : m_Options)
|
for (const auto & opt : m_Options)
|
||||||
{
|
{
|
||||||
@@ -1623,7 +1623,7 @@ void Connection::Validate(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL connection reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL connection reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1642,11 +1642,11 @@ void Connection::ValidateCreated(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL connection reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL connection reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
else if (m_Handle->mPtr == nullptr)
|
else if (m_Handle->mPtr == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL connection =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL connection =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1694,7 +1694,7 @@ const ConnRef & Connection::GetCreated() const
|
|||||||
#endif // _DEBUG
|
#endif // _DEBUG
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Object Connection::Insert(const SQChar * query)
|
SQInteger Connection::Insert(const SQChar * query)
|
||||||
{
|
{
|
||||||
// Make sure the specified query is valid
|
// Make sure the specified query is valid
|
||||||
if (!query || *query == '\0')
|
if (!query || *query == '\0')
|
||||||
@@ -1707,7 +1707,7 @@ Object Connection::Insert(const SQChar * query)
|
|||||||
SQMOD_THROW_CURRENT(*m_Handle, "Unable to execute MySQL query");
|
SQMOD_THROW_CURRENT(*m_Handle, "Unable to execute MySQL query");
|
||||||
}
|
}
|
||||||
// Return the identifier of the inserted row
|
// Return the identifier of the inserted row
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), mysql_insert_id(m_Handle->mPtr));
|
return static_cast< SQInteger >(mysql_insert_id(m_Handle->mPtr));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -1784,12 +1784,11 @@ SQInteger Connection::ExecuteF(HSQUIRRELVM vm)
|
|||||||
// Attempt to execute the specified query
|
// Attempt to execute the specified query
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Var< ULongInt >::push(vm, ULongInt(conn->m_Handle->Execute(val.mPtr, static_cast<unsigned long>(val.mLen))));
|
sq_pushinteger(vm, static_cast< SQInteger >(conn->m_Handle->Execute(val.mPtr, static_cast< unsigned long >(val.mLen))));
|
||||||
}
|
}
|
||||||
catch (const Sqrat::Exception & e)
|
catch (const std::exception & e)
|
||||||
{
|
{
|
||||||
// Propagate the error
|
return sq_throwerror(vm, e.what()); // Propagate the error
|
||||||
return sq_throwerror(vm, e.what());
|
|
||||||
}
|
}
|
||||||
// This function returned a value
|
// This function returned a value
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1851,12 +1850,11 @@ SQInteger Connection::InsertF(HSQUIRRELVM vm)
|
|||||||
SQMOD_THROW_CURRENT(*(conn->m_Handle), "Unable to execute MySQL query");
|
SQMOD_THROW_CURRENT(*(conn->m_Handle), "Unable to execute MySQL query");
|
||||||
}
|
}
|
||||||
// Return the identifier of the inserted row
|
// Return the identifier of the inserted row
|
||||||
Var< ULongInt >::push(vm, ULongInt(mysql_insert_id(conn->m_Handle->mPtr)));
|
sq_pushinteger(vm, static_cast< SQInteger >(mysql_insert_id(conn->m_Handle->mPtr)));
|
||||||
}
|
}
|
||||||
catch (const Sqrat::Exception & e)
|
catch (const std::exception & e)
|
||||||
{
|
{
|
||||||
// Propagate the error
|
return sq_throwerror(vm, e.what()); // Propagate the error
|
||||||
return sq_throwerror(vm, e.what());
|
|
||||||
}
|
}
|
||||||
// This function returned a value
|
// This function returned a value
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1962,12 +1960,12 @@ void Field::Validate(const char * file, int32_t line) const
|
|||||||
// Do we have a valid result-set handle?
|
// Do we have a valid result-set handle?
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Are we pointing to a valid index?
|
// Are we pointing to a valid index?
|
||||||
else if (m_Index >= m_Handle->mFieldCount)
|
else if (m_Index >= m_Handle->mFieldCount)
|
||||||
{
|
{
|
||||||
SqThrowF("Field index is out of range: {} >= {} =>[{}:{}]", m_Index, m_Handle->mFieldCount, file, line);
|
SqThrowF(SQMOD_RTFMT("Field index is out of range: {} >= {} =>[{}:{}]"), m_Index, m_Handle->mFieldCount, file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1993,7 +1991,7 @@ void Field::ValidateCreated(const char * file, int32_t line) const
|
|||||||
// Do we have a valid result-set handle?
|
// Do we have a valid result-set handle?
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Are we pointing to a valid index?
|
// Are we pointing to a valid index?
|
||||||
m_Handle->ValidateField(m_Index, file, line);
|
m_Handle->ValidateField(m_Index, file, line);
|
||||||
@@ -2018,12 +2016,12 @@ void Field::ValidateStepped(const char * file, int32_t line) const
|
|||||||
// Do we have a valid result-set handle?
|
// Do we have a valid result-set handle?
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Do we have a valid row available?
|
// Do we have a valid row available?
|
||||||
else if (m_Handle->mRow == nullptr)
|
else if (m_Handle->mRow == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("No row available in MySQL result-set =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("No row available in MySQL result-set =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Are we pointing to a valid index?
|
// Are we pointing to a valid index?
|
||||||
m_Handle->ValidateField(m_Index, file, line);
|
m_Handle->ValidateField(m_Index, file, line);
|
||||||
@@ -2098,7 +2096,7 @@ void Field::ValidateField(uint32_t idx, const char * file, int32_t line) const
|
|||||||
// Do we have a valid result-set handle?
|
// Do we have a valid result-set handle?
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Validate the specified field index
|
// Validate the specified field index
|
||||||
m_Handle->ValidateField(idx, file, line);
|
m_Handle->ValidateField(idx, file, line);
|
||||||
@@ -2361,7 +2359,7 @@ SQInteger Field::GetUint32() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Object Field::GetInt64() const
|
SQInteger Field::GetInt64() const
|
||||||
{
|
{
|
||||||
SQMOD_VALIDATE_STEPPED(*this);
|
SQMOD_VALIDATE_STEPPED(*this);
|
||||||
// Obtain the initial stack size
|
// Obtain the initial stack size
|
||||||
@@ -2369,18 +2367,16 @@ Object Field::GetInt64() const
|
|||||||
// Should we retrieve the value from the bind wrapper?
|
// Should we retrieve the value from the bind wrapper?
|
||||||
if (m_Handle->mStatement)
|
if (m_Handle->mStatement)
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< SLongInt >{}, SqVM(),
|
return ConvTo< SQInteger >::From(m_Handle->mBinds[m_Index].mInt64);
|
||||||
ConvTo< int64_t >::From(m_Handle->mBinds[m_Index].mInt64));
|
|
||||||
}
|
}
|
||||||
// Retrieve the value directly from the row
|
// Retrieve the value directly from the row
|
||||||
return Object(SqTypeIdentity< SLongInt >{}, SqVM(),
|
return DbConvTo< SQInteger >::From(m_Handle->mRow[m_Index],
|
||||||
DbConvTo< int64_t >::From(m_Handle->mRow[m_Index],
|
|
||||||
m_Handle->mLengths[m_Index],
|
m_Handle->mLengths[m_Index],
|
||||||
m_Handle->mFields[m_Index].type));
|
m_Handle->mFields[m_Index].type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Object Field::GetUint64() const
|
SQInteger Field::GetUint64() const
|
||||||
{
|
{
|
||||||
SQMOD_VALIDATE_STEPPED(*this);
|
SQMOD_VALIDATE_STEPPED(*this);
|
||||||
// Obtain the initial stack size
|
// Obtain the initial stack size
|
||||||
@@ -2388,14 +2384,12 @@ Object Field::GetUint64() const
|
|||||||
// Should we retrieve the value from the bind wrapper?
|
// Should we retrieve the value from the bind wrapper?
|
||||||
if (m_Handle->mStatement)
|
if (m_Handle->mStatement)
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(),
|
return ConvTo< SQInteger >::From(m_Handle->mBinds[m_Index].mUint64);
|
||||||
ConvTo< uint64_t >::From(m_Handle->mBinds[m_Index].mUint64));
|
|
||||||
}
|
}
|
||||||
// Retrieve the value directly from the row
|
// Retrieve the value directly from the row
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(),
|
return DbConvTo< SQInteger >::From(m_Handle->mRow[m_Index],
|
||||||
DbConvTo< uint64_t >::From(m_Handle->mRow[m_Index],
|
|
||||||
m_Handle->mLengths[m_Index],
|
m_Handle->mLengths[m_Index],
|
||||||
m_Handle->mFields[m_Index].type));
|
m_Handle->mFields[m_Index].type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -2471,7 +2465,7 @@ void ResultSet::Validate(const char * file, int32_t line) const
|
|||||||
// Do we have a valid result-set handle?
|
// Do we have a valid result-set handle?
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -2492,11 +2486,11 @@ void ResultSet::ValidateCreated(const char * file, int32_t line) const
|
|||||||
// Do we have a valid result-set handle?
|
// Do we have a valid result-set handle?
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
else if (m_Handle->mPtr == nullptr)
|
else if (m_Handle->mPtr == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -2521,12 +2515,12 @@ void ResultSet::ValidateStepped(const char * file, int32_t line) const
|
|||||||
// Do we have a valid result-set handle?
|
// Do we have a valid result-set handle?
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL result-set reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL result-set reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
// Do we have a valid row available?
|
// Do we have a valid row available?
|
||||||
else if (m_Handle->mRow == nullptr)
|
else if (m_Handle->mRow == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("No row available in MySQL result-set =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("No row available in MySQL result-set =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -2753,7 +2747,7 @@ void Statement::Validate(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -2772,11 +2766,11 @@ void Statement::ValidateCreated(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
else if (m_Handle->mPtr == nullptr)
|
else if (m_Handle->mPtr == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid MySQL statement =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid MySQL statement =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -2997,23 +2991,23 @@ void Statement::SetUint64(uint32_t idx, SQInteger val) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Statement::SetSLongInt(uint32_t idx, const SLongInt & val) const
|
void Statement::SetSLongInt(uint32_t idx, SQInteger val) const
|
||||||
{
|
{
|
||||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||||
// Attempt to set the input value
|
// Attempt to set the input value
|
||||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_LONGLONG, &(m_Handle->mMyBinds[idx]));
|
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_LONGLONG, &(m_Handle->mMyBinds[idx]));
|
||||||
// Attempt to assign the numeric value inside the specified object
|
// Attempt to assign the numeric value inside the specified object
|
||||||
m_Handle->mBinds[idx].mInt64 = val.GetNum();
|
m_Handle->mBinds[idx].mInt64 = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Statement::SetULongInt(uint32_t idx, const ULongInt & val) const
|
void Statement::SetULongInt(uint32_t idx, SQInteger val) const
|
||||||
{
|
{
|
||||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||||
// Attempt to set the input value
|
// Attempt to set the input value
|
||||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_LONGLONG, &(m_Handle->mMyBinds[idx]));
|
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_LONGLONG, &(m_Handle->mMyBinds[idx]));
|
||||||
// Attempt to assign the numeric value inside the specified object
|
// Attempt to assign the numeric value inside the specified object
|
||||||
m_Handle->mBinds[idx].mUint64 = val.GetNum();
|
m_Handle->mBinds[idx].mUint64 = static_cast< uint64_t >(val);
|
||||||
// Specify that this value is unsigned
|
// Specify that this value is unsigned
|
||||||
m_Handle->mMyBinds[idx].is_unsigned = true;
|
m_Handle->mMyBinds[idx].is_unsigned = true;
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-20
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/IO/Buffer.hpp"
|
#include "Library/IO/Buffer.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
#include "Library/Chrono.hpp"
|
#include "Library/Chrono.hpp"
|
||||||
#include "Library/Chrono/Date.hpp"
|
#include "Library/Chrono/Date.hpp"
|
||||||
#include "Library/Chrono/Datetime.hpp"
|
#include "Library/Chrono/Datetime.hpp"
|
||||||
@@ -18,7 +17,7 @@
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#ifdef SQMOD_POCO_HAS_MYSQL
|
#ifdef SQMOD_POCO_HAS_MYSQL
|
||||||
#include <mysql.h>
|
#include <mysql/mysql.h>
|
||||||
#else
|
#else
|
||||||
#error Enable MySQL support in order to compile this library.
|
#error Enable MySQL support in order to compile this library.
|
||||||
#endif
|
#endif
|
||||||
@@ -196,7 +195,7 @@ template < > struct DbConvTo< bool >
|
|||||||
*/
|
*/
|
||||||
template < > struct DbConvTo< char >
|
template < > struct DbConvTo< char >
|
||||||
{
|
{
|
||||||
SQMOD_NODISCARD static bool From(const SQChar * value, unsigned long length, enum_field_types type, const SQChar * tn = _SC("char"));
|
SQMOD_NODISCARD static char From(const SQChar * value, unsigned long length, enum_field_types type, const SQChar * tn = _SC("char"));
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
@@ -560,7 +559,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the used buffer.
|
* Retrieve the used buffer.
|
||||||
*/
|
*/
|
||||||
char * GetBuffer()
|
SQMOD_NODISCARD char * GetBuffer()
|
||||||
{
|
{
|
||||||
return mData ? mData.Data() : reinterpret_cast< char * >(&mUint64);
|
return mData ? mData.Data() : reinterpret_cast< char * >(&mUint64);
|
||||||
}
|
}
|
||||||
@@ -650,7 +649,7 @@ public:
|
|||||||
* Grab the current error in the associated statement or connection handle and throw it.
|
* Grab the current error in the associated statement or connection handle and throw it.
|
||||||
*/
|
*/
|
||||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||||
void ThrowCurrent(const char * act, const char * file, int32_t line);
|
void ThrowCurrent(const char * act, const char * file, int32_t line) const;
|
||||||
#else
|
#else
|
||||||
void ThrowCurrent(const char * act) const;
|
void ThrowCurrent(const char * act) const;
|
||||||
#endif // _DEBUG
|
#endif // _DEBUG
|
||||||
@@ -1457,7 +1456,7 @@ public:
|
|||||||
{
|
{
|
||||||
// Attempt to toggle auto-commit if necessary
|
// Attempt to toggle auto-commit if necessary
|
||||||
if (SQMOD_GET_CREATED(*this)->mAutoCommit != toggle &&
|
if (SQMOD_GET_CREATED(*this)->mAutoCommit != toggle &&
|
||||||
mysql_autocommit(m_Handle->mPtr, toggle) != 0)
|
mysql_autocommit(m_Handle->mPtr, static_cast< StmtBind::BoolType >(toggle)) != 0)
|
||||||
{
|
{
|
||||||
SQMOD_THROW_CURRENT(*m_Handle, "Cannot toggle auto-commit");
|
SQMOD_THROW_CURRENT(*m_Handle, "Cannot toggle auto-commit");
|
||||||
}
|
}
|
||||||
@@ -1486,15 +1485,15 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Execute a query on the server.
|
* Execute a query on the server.
|
||||||
*/
|
*/
|
||||||
Object Execute(const SQChar * query)
|
SQInteger Execute(const SQChar * query)
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), SQMOD_GET_CREATED(*this)->Execute(query));
|
return static_cast< SQInteger >(SQMOD_GET_CREATED(*this)->Execute(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Execute a query on the server.
|
* Execute a query on the server.
|
||||||
*/
|
*/
|
||||||
Object Insert(const SQChar * query);
|
SQInteger Insert(const SQChar * query);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Execute a query on the server.
|
* Execute a query on the server.
|
||||||
@@ -1866,12 +1865,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value inside the referenced field as a signed 64 bit integer value.
|
* Retrieve the value inside the referenced field as a signed 64 bit integer value.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Object GetInt64() const;
|
SQMOD_NODISCARD SQInteger GetInt64() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value inside the referenced field as an unsigned 64 bit integer value.
|
* Retrieve the value inside the referenced field as an unsigned 64 bit integer value.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Object GetUint64() const;
|
SQMOD_NODISCARD SQInteger GetUint64() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value inside the referenced field as a 32 bit floating point value.
|
* Retrieve the value inside the referenced field as a 32 bit floating point value.
|
||||||
@@ -2111,17 +2110,17 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Returns the current position of the row cursor for the last Next().
|
* Returns the current position of the row cursor for the last Next().
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Object RowIndex() const
|
SQMOD_NODISCARD SQInteger RowIndex() const
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), SQMOD_GET_CREATED(*this)->RowIndex());
|
return static_cast< SQInteger >(SQMOD_GET_CREATED(*this)->RowIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Returns the number of rows in the result set.
|
* Returns the number of rows in the result set.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Object RowCount() const
|
SQMOD_NODISCARD SQInteger RowCount() const
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), SQMOD_GET_CREATED(*this)->RowCount());
|
return static_cast< SQInteger >(SQMOD_GET_CREATED(*this)->RowCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -2143,9 +2142,9 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Seeks to an arbitrary row in a query result set.
|
* Seeks to an arbitrary row in a query result set.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD bool SetLongRowIndex(const ULongInt & index) const
|
SQMOD_NODISCARD bool SetLongRowIndex(SQInteger index) const
|
||||||
{
|
{
|
||||||
return SQMOD_GET_CREATED(*this)->SetRowIndex(index.GetNum());
|
return SQMOD_GET_CREATED(*this)->SetRowIndex(static_cast< uint64_t >(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -2422,7 +2421,7 @@ public:
|
|||||||
// Do we have a valid handle?
|
// Do we have a valid handle?
|
||||||
if (m_Handle)
|
if (m_Handle)
|
||||||
{
|
{
|
||||||
m_Handle->mQuery;
|
return m_Handle->mQuery;
|
||||||
}
|
}
|
||||||
// Default to an empty string
|
// Default to an empty string
|
||||||
return NullString();
|
return NullString();
|
||||||
@@ -2517,12 +2516,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Assign a signed long integer to a parameter.
|
* Assign a signed long integer to a parameter.
|
||||||
*/
|
*/
|
||||||
void SetSLongInt(uint32_t idx, const SLongInt & val) const;
|
void SetSLongInt(uint32_t idx, SQInteger val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Assign an unsigned long integer to a parameter.
|
* Assign an unsigned long integer to a parameter.
|
||||||
*/
|
*/
|
||||||
void SetULongInt(uint32_t idx, const ULongInt & val) const;
|
void SetULongInt(uint32_t idx, SQInteger val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Assign a native integer to a parameter.
|
* Assign a native integer to a parameter.
|
||||||
|
|||||||
@@ -0,0 +1,203 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Net.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <sqratConst.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqWebSocketClient, _SC("SqWebSocketClient"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static std::thread::id sMainThreadID{}; // Main thread ID
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void InitializeNet()
|
||||||
|
{
|
||||||
|
int f = MG_FEATURES_DEFAULT;
|
||||||
|
#ifndef NO_FILES
|
||||||
|
f |= MG_FEATURES_FILES;
|
||||||
|
#endif
|
||||||
|
#ifndef NO_SSL
|
||||||
|
f |= MG_FEATURES_SSL;
|
||||||
|
#endif
|
||||||
|
#ifndef NO_CGI
|
||||||
|
f |= MG_FEATURES_CGI;
|
||||||
|
#endif
|
||||||
|
#ifndef NO_CACHING
|
||||||
|
f |= MG_FEATURES_CACHE;
|
||||||
|
#endif
|
||||||
|
#ifdef USE_IPV6
|
||||||
|
f |= MG_FEATURES_CGI;
|
||||||
|
#endif
|
||||||
|
#ifdef USE_WEBSOCKET
|
||||||
|
f |= MG_FEATURES_WEBSOCKET;
|
||||||
|
#endif
|
||||||
|
#ifdef USE_SERVER_STATS
|
||||||
|
f |= MG_FEATURES_STATS;
|
||||||
|
#endif
|
||||||
|
#ifdef USE_ZLIB
|
||||||
|
f |= MG_FEATURES_COMPRESSION;
|
||||||
|
#endif
|
||||||
|
#ifdef USE_HTTP2
|
||||||
|
f |= MG_FEATURES_HTTP2;
|
||||||
|
#endif
|
||||||
|
#ifdef USE_X_DOM_SOCKET
|
||||||
|
f |= MG_FEATURES_X_DOMAIN_SOCKET;
|
||||||
|
#endif
|
||||||
|
mg_init_library(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void TerminateNet()
|
||||||
|
{
|
||||||
|
// Go over all connections and try to terminate them
|
||||||
|
for (WebSocketClient * inst = WebSocketClient::sHead; inst && inst->mNext != WebSocketClient::sHead; inst = inst->mNext)
|
||||||
|
{
|
||||||
|
inst->Terminate(); // Terminate() the connection
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ProcessNet()
|
||||||
|
{
|
||||||
|
// Go over all connections and allow them to process data
|
||||||
|
for (WebSocketClient * inst = WebSocketClient::sHead; inst && inst->mNext != WebSocketClient::sHead; inst = inst->mNext)
|
||||||
|
{
|
||||||
|
inst->Process();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
WebSocketClient & WebSocketClient::Connect()
|
||||||
|
{
|
||||||
|
// Make sure another connection does not exist
|
||||||
|
Invalid();
|
||||||
|
// Error buffer
|
||||||
|
char err_buf[128] = {0};
|
||||||
|
// Connect to the given WS or WSS (WS secure) server
|
||||||
|
mHandle = mg_connect_websocket_client(mHost.c_str(), mPort, mSecure?1:0,
|
||||||
|
err_buf, sizeof(err_buf), mPath.c_str(),
|
||||||
|
mOrigin.empty() ? nullptr : mOrigin.c_str(),
|
||||||
|
&WebSocketClient::DataHandler_,
|
||||||
|
&WebSocketClient::CloseHandler_,
|
||||||
|
this);
|
||||||
|
// Check if connection was possible
|
||||||
|
if (!mHandle)
|
||||||
|
{
|
||||||
|
STHROWF("Connection failed: {}", err_buf);
|
||||||
|
}
|
||||||
|
// Allow chaining
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
WebSocketClient & WebSocketClient::ConnectExt()
|
||||||
|
{
|
||||||
|
// Make sure another connection does not exist
|
||||||
|
Invalid();
|
||||||
|
// Error buffer
|
||||||
|
char err_buf[128] = {0};
|
||||||
|
// Connect to the given WS or WSS (WS secure) server
|
||||||
|
mHandle = mg_connect_websocket_client_extensions(mHost.c_str(), mPort, mSecure?1:0,
|
||||||
|
err_buf, sizeof(err_buf), mPath.c_str(),
|
||||||
|
mOrigin.empty() ? nullptr : mOrigin.c_str(),
|
||||||
|
mExtensions.empty() ? nullptr : mExtensions.c_str(),
|
||||||
|
&WebSocketClient::DataHandler_,
|
||||||
|
&WebSocketClient::CloseHandler_,
|
||||||
|
this);
|
||||||
|
// Check if connection was possible
|
||||||
|
if (!mHandle)
|
||||||
|
{
|
||||||
|
STHROWF("Connection failed: {}", err_buf);
|
||||||
|
}
|
||||||
|
// Allow chaining
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
int WebSocketClient::DataHandler(int flags, char * data, size_t data_len) noexcept
|
||||||
|
{
|
||||||
|
// Create a frame instance to store information and queue it
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mQueue.enqueue(std::make_unique< Frame >(data, data_len, flags));
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
LogFtl("Failed to queue web-socket data");
|
||||||
|
}
|
||||||
|
// Return 1 to keep the connection open
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void WebSocketClient::CloseHandler() noexcept
|
||||||
|
{
|
||||||
|
mClosing.store(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================================================================================================
|
||||||
|
void Register_Net(HSQUIRRELVM vm)
|
||||||
|
{
|
||||||
|
Table ns(vm);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("WebSocketClient"),
|
||||||
|
Class< WebSocketClient, NoCopy< WebSocketClient > >(ns.GetVM(), SqWebSocketClient::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
.Ctor< StackStrF &, uint16_t, StackStrF & >()
|
||||||
|
.Ctor< StackStrF &, uint16_t, StackStrF &, bool >()
|
||||||
|
.Ctor< StackStrF &, uint16_t, StackStrF &, bool, StackStrF & >()
|
||||||
|
.Ctor< StackStrF &, uint16_t, StackStrF &, bool, StackStrF &, StackStrF & >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqWebSocketClient::Fn)
|
||||||
|
// Properties
|
||||||
|
.Prop(_SC("Tag"), &WebSocketClient::GetTag, &WebSocketClient::SetTag)
|
||||||
|
.Prop(_SC("Data"), &WebSocketClient::GetData, &WebSocketClient::SetData)
|
||||||
|
.Prop(_SC("Host"), &WebSocketClient::GetHost, &WebSocketClient::SetHost)
|
||||||
|
.Prop(_SC("Port"), &WebSocketClient::GetPort, &WebSocketClient::SetPort)
|
||||||
|
.Prop(_SC("Path"), &WebSocketClient::GetPath, &WebSocketClient::SetPath)
|
||||||
|
.Prop(_SC("Secure"), &WebSocketClient::GetSecure, &WebSocketClient::SetSecure)
|
||||||
|
.Prop(_SC("Origin"), &WebSocketClient::GetOrigin, &WebSocketClient::SetOrigin)
|
||||||
|
.Prop(_SC("Extensions"), &WebSocketClient::GetExtensions, &WebSocketClient::SetExtensions)
|
||||||
|
.Prop(_SC("OnData"), &WebSocketClient::GetOnData, &WebSocketClient::SetOnData)
|
||||||
|
.Prop(_SC("OnClose"), &WebSocketClient::GetOnClose, &WebSocketClient::SetOnClose)
|
||||||
|
.Prop(_SC("Valid"), &WebSocketClient::IsValid)
|
||||||
|
.Prop(_SC("Closing"), &WebSocketClient::IsClosing)
|
||||||
|
// Member Methods
|
||||||
|
.FmtFunc(_SC("SetTag"), &WebSocketClient::ApplyTag)
|
||||||
|
.FmtFunc(_SC("SetData"), &WebSocketClient::ApplyData)
|
||||||
|
.FmtFunc(_SC("SetHost"), &WebSocketClient::ApplyHost)
|
||||||
|
.Func(_SC("SetPort"), &WebSocketClient::ApplyPort)
|
||||||
|
.FmtFunc(_SC("SetPath"), &WebSocketClient::ApplyPath)
|
||||||
|
.Func(_SC("SetSecure"), &WebSocketClient::ApplySecure)
|
||||||
|
.FmtFunc(_SC("SetOrigin"), &WebSocketClient::ApplyOrigin)
|
||||||
|
.FmtFunc(_SC("SetExtensions"), &WebSocketClient::ApplyExtensions)
|
||||||
|
.CbFunc(_SC("BindOnData"), &WebSocketClient::BindOnData)
|
||||||
|
.CbFunc(_SC("BindOnClose"), &WebSocketClient::BindOnClose)
|
||||||
|
.Func(_SC("Connect"), &WebSocketClient::Connect)
|
||||||
|
.Func(_SC("ConnectExt"), &WebSocketClient::ConnectExt)
|
||||||
|
.Func(_SC("SendOpCode"), &WebSocketClient::SendOpCode)
|
||||||
|
.Func(_SC("SendBuffer"), &WebSocketClient::SendBuffer)
|
||||||
|
.FmtFunc(_SC("SendString"), &WebSocketClient::SendString)
|
||||||
|
.Func(_SC("Close"), &WebSocketClient::Close)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
RootTable(vm).Bind(_SC("SqNet"), ns);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ConstTable(vm).Enum(_SC("SqWsOpCode"), Enumeration(vm)
|
||||||
|
.Const(_SC("Continuation"), static_cast< SQInteger >(MG_WEBSOCKET_OPCODE_CONTINUATION))
|
||||||
|
.Const(_SC("Text"), static_cast< SQInteger >(MG_WEBSOCKET_OPCODE_TEXT))
|
||||||
|
.Const(_SC("Binary"), static_cast< SQInteger >(MG_WEBSOCKET_OPCODE_BINARY))
|
||||||
|
.Const(_SC("ConnectionClose"), static_cast< SQInteger >(MG_WEBSOCKET_OPCODE_CONNECTION_CLOSE))
|
||||||
|
.Const(_SC("Ping"), static_cast< SQInteger >(MG_WEBSOCKET_OPCODE_PING))
|
||||||
|
.Const(_SC("Pong"), static_cast< SQInteger >(MG_WEBSOCKET_OPCODE_PONG))
|
||||||
|
);
|
||||||
|
// Main thread ID
|
||||||
|
sMainThreadID = std::this_thread::get_id();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -0,0 +1,760 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/IO/Buffer.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <sqratFunction.h>
|
||||||
|
#include <concurrentqueue.h>
|
||||||
|
#include <civetweb.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* WebSocket client implementation.
|
||||||
|
*/
|
||||||
|
struct WebSocketClient : public SqChainedInstances< WebSocketClient >
|
||||||
|
{
|
||||||
|
using Base = SqChainedInstances< WebSocketClient >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* WebSocket frame.
|
||||||
|
*/
|
||||||
|
struct Frame
|
||||||
|
{
|
||||||
|
/* ----------------------------------------------------------------------------------------
|
||||||
|
* Frame data.
|
||||||
|
*/
|
||||||
|
char * mData{nullptr};
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------------------
|
||||||
|
* Frame data capacity.
|
||||||
|
*/
|
||||||
|
uint32_t mSize{0};
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------------------
|
||||||
|
* Frame flags.
|
||||||
|
*/
|
||||||
|
int mFlags{0};
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
Frame() = default;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
Frame(char * data, size_t size, int flags)
|
||||||
|
: mData(nullptr), mSize(static_cast< uint32_t >(size)), mFlags(flags)
|
||||||
|
{
|
||||||
|
// Do we need to allocate a buffer?
|
||||||
|
if (mSize != 0)
|
||||||
|
{
|
||||||
|
// Allocate the memory buffer.
|
||||||
|
mData = new char[mSize];
|
||||||
|
// Copy the data into the buffer we own
|
||||||
|
std::memcpy(mData, data, mSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
Frame(const Frame & o) = delete;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------------------
|
||||||
|
* Move constructor (disabled).
|
||||||
|
*/
|
||||||
|
Frame(Frame && o) noexcept = delete;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~Frame()
|
||||||
|
{
|
||||||
|
delete[] mData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
Frame & operator = (const Frame & o) = delete;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
Frame & operator = (Frame && o) noexcept = delete;
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------------------------
|
||||||
|
* Forget about the associated memory buffer.
|
||||||
|
*/
|
||||||
|
void ForgetBuffer() noexcept
|
||||||
|
{
|
||||||
|
mData = nullptr;
|
||||||
|
mSize = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Smart frame pointer.
|
||||||
|
*/
|
||||||
|
using FramePtr = std::unique_ptr< Frame >;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Queue of frames written from other threads.
|
||||||
|
*/
|
||||||
|
using FrameQueue = moodycamel::ConcurrentQueue< FramePtr >;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Connection handle.
|
||||||
|
*/
|
||||||
|
struct mg_connection * mHandle{nullptr};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Queue of frames that must be processed.
|
||||||
|
*/
|
||||||
|
FrameQueue mQueue{1024};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Callback to invoke when receiving data.
|
||||||
|
*/
|
||||||
|
Function mOnData{};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Callback to invoke when the socket is shutting down.
|
||||||
|
*/
|
||||||
|
Function mOnClose{};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* User tag associated with this instance.
|
||||||
|
*/
|
||||||
|
String mTag{};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* User data associated with this instance.
|
||||||
|
*/
|
||||||
|
LightObj mData{};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Server port.
|
||||||
|
*/
|
||||||
|
int mPort{0};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Make a secure connection to server.
|
||||||
|
*/
|
||||||
|
bool mSecure{false};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Whether the connection is currently closing.
|
||||||
|
*/
|
||||||
|
std::atomic< bool > mClosing{false};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Server host to connect to, i.e. "echo.websocket.org" or "192.168.1.1" or "localhost".
|
||||||
|
*/
|
||||||
|
String mHost{};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Server path you are trying to connect to, i.e. if connection to localhost/app, path should be "/app".
|
||||||
|
*/
|
||||||
|
String mPath{};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Value of the Origin HTTP header.
|
||||||
|
*/
|
||||||
|
String mOrigin{};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Extensions to include in the connection.
|
||||||
|
*/
|
||||||
|
String mExtensions{};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
WebSocketClient()
|
||||||
|
: Base(), mHandle(nullptr), mQueue(1024), mOnData(), mOnClose(), mTag(), mData()
|
||||||
|
, mPort(0), mSecure(false), mClosing(false), mHost(), mPath(), mOrigin(), mExtensions()
|
||||||
|
{
|
||||||
|
ChainInstance(); // Remember this instance
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
WebSocketClient(StackStrF & host, uint16_t port, StackStrF & path)
|
||||||
|
: Base(), mHandle(nullptr), mQueue(1024), mOnData(), mOnClose(), mTag(), mData()
|
||||||
|
, mPort(port), mSecure(false), mClosing(false)
|
||||||
|
, mHost(host.mPtr, host.GetSize())
|
||||||
|
, mPath(path.mPtr, path.GetSize())
|
||||||
|
, mOrigin(), mExtensions()
|
||||||
|
{
|
||||||
|
ChainInstance(); // Remember this instance
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
WebSocketClient(StackStrF & host, uint16_t port, StackStrF & path, bool secure)
|
||||||
|
: Base(), mHandle(nullptr), mQueue(1024), mOnData(), mOnClose(), mTag(), mData()
|
||||||
|
, mPort(port), mSecure(secure), mClosing(false)
|
||||||
|
, mHost(host.mPtr, host.GetSize())
|
||||||
|
, mPath(path.mPtr, path.GetSize())
|
||||||
|
, mOrigin(), mExtensions()
|
||||||
|
{
|
||||||
|
ChainInstance(); // Remember this instance
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
WebSocketClient(StackStrF & host, uint16_t port, StackStrF & path, bool secure, StackStrF & origin)
|
||||||
|
: Base(), mHandle(nullptr), mQueue(1024), mOnData(), mOnClose(), mTag(), mData()
|
||||||
|
, mPort(port), mSecure(secure), mClosing(false)
|
||||||
|
, mHost(host.mPtr, host.GetSize())
|
||||||
|
, mPath(path.mPtr, path.GetSize())
|
||||||
|
, mOrigin(origin.mPtr, origin.GetSize())
|
||||||
|
, mExtensions()
|
||||||
|
{
|
||||||
|
ChainInstance(); // Remember this instance
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
WebSocketClient(StackStrF & host, uint16_t port, StackStrF & path, bool secure, StackStrF & origin, StackStrF & ext)
|
||||||
|
: Base(), mHandle(nullptr), mQueue(1024), mOnData(), mOnClose(), mTag(), mData()
|
||||||
|
, mPort(port), mSecure(secure), mClosing(false)
|
||||||
|
, mHost(host.mPtr, host.GetSize())
|
||||||
|
, mPath(path.mPtr, path.GetSize())
|
||||||
|
, mOrigin(origin.mPtr, origin.GetSize())
|
||||||
|
, mExtensions(ext.mPtr, ext.GetSize())
|
||||||
|
{
|
||||||
|
ChainInstance(); // Remember this instance
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
WebSocketClient(const WebSocketClient &) = delete;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
WebSocketClient(WebSocketClient &&) = delete;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor. Closes the connection.
|
||||||
|
*/
|
||||||
|
~WebSocketClient()
|
||||||
|
{
|
||||||
|
// Is there a connection left to close?
|
||||||
|
if (mHandle != nullptr)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
// Forget about this instance
|
||||||
|
UnchainInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator.
|
||||||
|
*/
|
||||||
|
WebSocketClient & operator = (const WebSocketClient &) = delete;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
WebSocketClient & operator = (WebSocketClient &&) = delete;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Return whether the associated connection handle is valid.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsValid() const
|
||||||
|
{
|
||||||
|
return mHandle != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Return whether the associated connection is closing.
|
||||||
|
* This is only valid inside the OnClose callback.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsClosing() const
|
||||||
|
{
|
||||||
|
return mClosing.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated user tag.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const String & GetTag() const
|
||||||
|
{
|
||||||
|
return mTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated user tag.
|
||||||
|
*/
|
||||||
|
void SetTag(StackStrF & tag)
|
||||||
|
{
|
||||||
|
if (tag.mLen > 0)
|
||||||
|
{
|
||||||
|
mTag.assign(tag.mPtr, static_cast< size_t >(tag.mLen));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mTag.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated user tag.
|
||||||
|
*/
|
||||||
|
WebSocketClient & ApplyTag(StackStrF & tag)
|
||||||
|
{
|
||||||
|
SetTag(tag);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated user data.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj & GetData()
|
||||||
|
{
|
||||||
|
return mData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated user data.
|
||||||
|
*/
|
||||||
|
void SetData(LightObj & data)
|
||||||
|
{
|
||||||
|
mData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated user data.
|
||||||
|
*/
|
||||||
|
WebSocketClient & ApplyData(LightObj & data)
|
||||||
|
{
|
||||||
|
mData = data;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Make sure a connection exists.
|
||||||
|
*/
|
||||||
|
void Validate() const
|
||||||
|
{
|
||||||
|
if (mHandle == nullptr)
|
||||||
|
{
|
||||||
|
STHROWF("No connection was made to server ({}:{}{})", mHost, mPort, mPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Return a valid connection.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD struct mg_connection * Valid() const
|
||||||
|
{
|
||||||
|
Validate();
|
||||||
|
return mHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Make sure a connection does not exist.
|
||||||
|
*/
|
||||||
|
void Invalid() const
|
||||||
|
{
|
||||||
|
if (mHandle != nullptr)
|
||||||
|
{
|
||||||
|
STHROWF("Connection already made to server ({}:{}{})", mHost, mPort, mPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated server host.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const String & GetHost() const
|
||||||
|
{
|
||||||
|
return mHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated server host.
|
||||||
|
*/
|
||||||
|
void SetHost(StackStrF & host)
|
||||||
|
{
|
||||||
|
Invalid();
|
||||||
|
// Is there a valid host?
|
||||||
|
if (host.mLen > 0)
|
||||||
|
{
|
||||||
|
mHost.assign(host.mPtr, static_cast< size_t >(host.mLen));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mHost.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated server host.
|
||||||
|
*/
|
||||||
|
WebSocketClient & ApplyHost(StackStrF & host)
|
||||||
|
{
|
||||||
|
SetHost(host);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated server path.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const String & GetPath() const
|
||||||
|
{
|
||||||
|
return mPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated server path.
|
||||||
|
*/
|
||||||
|
void SetPath(StackStrF & path)
|
||||||
|
{
|
||||||
|
Invalid();
|
||||||
|
// Is there a valid path?
|
||||||
|
if (path.mLen > 0)
|
||||||
|
{
|
||||||
|
mPath.assign(path.mPtr, static_cast< size_t >(path.mLen));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mPath.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated server path.
|
||||||
|
*/
|
||||||
|
WebSocketClient & ApplyPath(StackStrF & path)
|
||||||
|
{
|
||||||
|
SetPath(path);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated origin value.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const String & GetOrigin() const
|
||||||
|
{
|
||||||
|
return mOrigin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated origin value.
|
||||||
|
*/
|
||||||
|
void SetOrigin(StackStrF & origin)
|
||||||
|
{
|
||||||
|
Invalid();
|
||||||
|
// Is there a valid origin?
|
||||||
|
if (origin.mLen > 0)
|
||||||
|
{
|
||||||
|
mOrigin.assign(origin.mPtr, static_cast< size_t >(origin.mLen));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mOrigin.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated origin value.
|
||||||
|
*/
|
||||||
|
WebSocketClient & ApplyOrigin(StackStrF & origin)
|
||||||
|
{
|
||||||
|
SetOrigin(origin);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated connection extensions.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const String & GetExtensions() const
|
||||||
|
{
|
||||||
|
return mExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated connection extensions.
|
||||||
|
*/
|
||||||
|
void SetExtensions(StackStrF & ext)
|
||||||
|
{
|
||||||
|
Invalid();
|
||||||
|
// Is there a valid extension?
|
||||||
|
if (ext.mLen > 0)
|
||||||
|
{
|
||||||
|
mExtensions.assign(ext.mPtr, static_cast< size_t >(ext.mLen));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mExtensions.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated connection extensions.
|
||||||
|
*/
|
||||||
|
WebSocketClient & ApplyExtensions(StackStrF & ext)
|
||||||
|
{
|
||||||
|
SetExtensions(ext);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated server port number.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD int GetPort() const
|
||||||
|
{
|
||||||
|
return mPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated server port number.
|
||||||
|
*/
|
||||||
|
void SetPort(int port)
|
||||||
|
{
|
||||||
|
Invalid();
|
||||||
|
// Is there a valid port?
|
||||||
|
if (port < 0 || port > 65535)
|
||||||
|
{
|
||||||
|
STHROWF("Invalid port number: {0} < 0 || {0} > 65535", port);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mPort = port;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated server port number.
|
||||||
|
*/
|
||||||
|
WebSocketClient & ApplyPort(int port)
|
||||||
|
{
|
||||||
|
SetPort(port);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated SSL status.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool GetSecure() const
|
||||||
|
{
|
||||||
|
return mSecure;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated SSL status.
|
||||||
|
*/
|
||||||
|
void SetSecure(bool secure)
|
||||||
|
{
|
||||||
|
Invalid();
|
||||||
|
mSecure = secure;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated SSL status.
|
||||||
|
*/
|
||||||
|
WebSocketClient & ApplySecure(bool secure)
|
||||||
|
{
|
||||||
|
SetSecure(secure);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated data callback.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Function & GetOnData()
|
||||||
|
{
|
||||||
|
return mOnData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated data callback.
|
||||||
|
*/
|
||||||
|
void SetOnData(Function & cb)
|
||||||
|
{
|
||||||
|
mOnData = cb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated data callback.
|
||||||
|
*/
|
||||||
|
WebSocketClient & BindOnData(Function & cb)
|
||||||
|
{
|
||||||
|
mOnData = cb;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated close callback.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD Function & GetOnClose()
|
||||||
|
{
|
||||||
|
return mOnClose;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated close callback.
|
||||||
|
*/
|
||||||
|
void SetOnClose(Function & cb)
|
||||||
|
{
|
||||||
|
mOnClose = cb;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated close callback.
|
||||||
|
*/
|
||||||
|
WebSocketClient & BindOnClose(Function & cb)
|
||||||
|
{
|
||||||
|
mOnClose = cb;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Connect to a web-socket as a client.
|
||||||
|
*/
|
||||||
|
WebSocketClient & Connect();
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Connect to a web-socket as a client with specific extensions.
|
||||||
|
*/
|
||||||
|
WebSocketClient & ConnectExt();
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Close client connection.
|
||||||
|
*/
|
||||||
|
void Close()
|
||||||
|
{
|
||||||
|
mg_close_connection(Valid());
|
||||||
|
// Prevent further use
|
||||||
|
mHandle = nullptr;
|
||||||
|
// Process pending events
|
||||||
|
Process(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Sends the contents of the given buffer through the socket as a single frame.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger SendOpCode(SqBuffer & buf, SQInteger opcode)
|
||||||
|
{
|
||||||
|
return mg_websocket_client_write(Valid(), static_cast< int >(opcode), nullptr, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Sends the contents of the given buffer through the socket as a single frame.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger SendBuffer(SqBuffer & buf, SQInteger opcode)
|
||||||
|
{
|
||||||
|
return mg_websocket_client_write(Valid(), static_cast< int >(opcode), buf.Valid().Data(), buf.Valid().Position());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Sends the contents of the given string through the socket as a single frame.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger SendString(SQInteger opcode, StackStrF & str)
|
||||||
|
{
|
||||||
|
return mg_websocket_client_write(Valid(), static_cast< int >(opcode), str.mPtr, static_cast< size_t >(str.mLen));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Process received data.
|
||||||
|
*/
|
||||||
|
void Process(bool force = false)
|
||||||
|
{
|
||||||
|
// Is there a valid connection?
|
||||||
|
if (mHandle == nullptr && !force)
|
||||||
|
{
|
||||||
|
return; // No point in going forward
|
||||||
|
}
|
||||||
|
FramePtr frame;
|
||||||
|
// See if connection is closing
|
||||||
|
const bool closing = mClosing.load();
|
||||||
|
// Is the connection closing?
|
||||||
|
if (closing)
|
||||||
|
{
|
||||||
|
mHandle = nullptr; // Prevent further use
|
||||||
|
}
|
||||||
|
// Retrieve each frame individually and process it
|
||||||
|
for (size_t count = mQueue.size_approx(), n = 0; n <= count; ++n)
|
||||||
|
{
|
||||||
|
// Try to get a frame from the queue
|
||||||
|
if (mQueue.try_dequeue(frame) && !mOnData.IsNull())
|
||||||
|
{
|
||||||
|
// Obtain a buffer from the frame
|
||||||
|
Buffer b(frame->mData, frame->mSize, frame->mSize, Buffer::OwnIt{});
|
||||||
|
// Backup the frame size before forgetting about it
|
||||||
|
const SQInteger size = static_cast< SQInteger >(frame->mSize);
|
||||||
|
// Take ownership of the memory
|
||||||
|
frame->ForgetBuffer();
|
||||||
|
// Transform the buffer into a script object
|
||||||
|
LightObj obj(SqTypeIdentity< SqBuffer >{}, SqVM(), std::move(b));
|
||||||
|
// Forward the event to the callback
|
||||||
|
mOnData.Execute(obj, size, frame->mFlags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Is the server closing the connection?
|
||||||
|
if (closing && !mOnClose.IsNull())
|
||||||
|
{
|
||||||
|
mOnClose.Execute(); // Let the user know
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Used internally to release script resources, if any. The VM is about to be closed.
|
||||||
|
* If you don't close the connection yourself don't care about what is received after this.
|
||||||
|
*/
|
||||||
|
void Terminate()
|
||||||
|
{
|
||||||
|
// Process pending data
|
||||||
|
Process(true);
|
||||||
|
// Release callbacks
|
||||||
|
mOnData.Release();
|
||||||
|
mOnClose.Release();
|
||||||
|
// Release user data
|
||||||
|
mData.Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Callback for handling data received from the server
|
||||||
|
*/
|
||||||
|
int DataHandler(int flags, char * data, size_t data_len) noexcept;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Callback for handling a close message received from the server.
|
||||||
|
*/
|
||||||
|
void CloseHandler() noexcept;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Proxy for DataHandler()
|
||||||
|
*/
|
||||||
|
static int DataHandler_(struct mg_connection * SQ_UNUSED_ARG(c), int f, char * d, size_t n, void * u) noexcept
|
||||||
|
{
|
||||||
|
return reinterpret_cast< WebSocketClient * >(u)->DataHandler(f, d, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Proxy for CloseHandler();
|
||||||
|
*/
|
||||||
|
static void CloseHandler_(const struct mg_connection * SQ_UNUSED_ARG(c), void * u) noexcept
|
||||||
|
{
|
||||||
|
reinterpret_cast< WebSocketClient * >(u)->CloseHandler();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -5,14 +5,12 @@
|
|||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
extern void Register_LongInt(HSQUIRRELVM vm);
|
|
||||||
extern void Register_Math(HSQUIRRELVM vm);
|
extern void Register_Math(HSQUIRRELVM vm);
|
||||||
extern void Register_Random(HSQUIRRELVM vm);
|
extern void Register_Random(HSQUIRRELVM vm);
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_Numeric(HSQUIRRELVM vm)
|
void Register_Numeric(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
Register_LongInt(vm);
|
|
||||||
Register_Math(vm);
|
Register_Math(vm);
|
||||||
Register_Random(vm);
|
Register_Random(vm);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,376 +0,0 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
#include "Library/Numeric/Random.hpp"
|
|
||||||
#include "Base/DynArg.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
namespace SqMod {
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
SQMOD_DECL_TYPENAME(TypenameS, _SC("SLongInt"))
|
|
||||||
SQMOD_DECL_TYPENAME(TypenameU, _SC("ULongInt"))
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
LongInt< signed long long >::LongInt(const SQChar * text)
|
|
||||||
: m_Data(0), m_Text()
|
|
||||||
{
|
|
||||||
m_Data = std::strtoll(text, nullptr, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
LongInt< signed long long >::LongInt(const SQChar * text, uint32_t base)
|
|
||||||
: m_Data(0), m_Text()
|
|
||||||
{
|
|
||||||
m_Data = std::strtoll(text, nullptr, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
LongInt< signed long long > & LongInt< signed long long >::operator = (const SQChar * text)
|
|
||||||
{
|
|
||||||
m_Data = std::strtoll(text, nullptr, 10);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
const SQChar * LongInt< signed long long >::ToString()
|
|
||||||
{
|
|
||||||
if (std::snprintf(m_Text, sizeof(m_Text), "%llu", m_Data) < 0)
|
|
||||||
{
|
|
||||||
m_Text[0] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_Text;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void LongInt< signed long long >::Random()
|
|
||||||
{
|
|
||||||
m_Data = GetRandomInt64();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void LongInt< signed long long >::Random(Type n)
|
|
||||||
{
|
|
||||||
m_Data = GetRandomInt64(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void LongInt< signed long long >::Random(Type m, Type n)
|
|
||||||
{
|
|
||||||
m_Data = GetRandomInt64(m, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
LongInt< unsigned long long >::LongInt(const SQChar * text)
|
|
||||||
: m_Data(0), m_Text()
|
|
||||||
{
|
|
||||||
m_Data = std::strtoull(text, nullptr, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
LongInt< unsigned long long >::LongInt(const SQChar * text, uint32_t base)
|
|
||||||
: m_Data(0), m_Text()
|
|
||||||
{
|
|
||||||
m_Data = std::strtoull(text, nullptr, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
LongInt< unsigned long long > & LongInt< unsigned long long >::operator = (const SQChar * text)
|
|
||||||
{
|
|
||||||
m_Data = std::strtoull(text, nullptr, 10);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
const SQChar * LongInt< unsigned long long >::ToString()
|
|
||||||
{
|
|
||||||
if (std::snprintf(m_Text, sizeof(m_Text), "%llu", m_Data) < 0)
|
|
||||||
{
|
|
||||||
m_Text[0] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_Text;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void LongInt< unsigned long long >::Random()
|
|
||||||
{
|
|
||||||
m_Data = GetRandomUint64();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void LongInt< unsigned long long >::Random(Type n)
|
|
||||||
{
|
|
||||||
m_Data = GetRandomUint64(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void LongInt< unsigned long long >::Random(Type m, Type n)
|
|
||||||
{
|
|
||||||
m_Data = GetRandomUint64(m, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
signed long long PopStackSLong(HSQUIRRELVM vm, SQInteger idx)
|
|
||||||
{
|
|
||||||
// Identify which type must be extracted
|
|
||||||
switch (sq_gettype(vm, idx))
|
|
||||||
{
|
|
||||||
case OT_INTEGER:
|
|
||||||
{
|
|
||||||
SQInteger val;
|
|
||||||
sq_getinteger(vm, idx, &val);
|
|
||||||
return static_cast< signed long long >(val);
|
|
||||||
}
|
|
||||||
case OT_FLOAT:
|
|
||||||
{
|
|
||||||
SQFloat val;
|
|
||||||
sq_getfloat(vm, idx, &val);
|
|
||||||
return ConvTo< signed long long >::From(val);
|
|
||||||
}
|
|
||||||
case OT_BOOL:
|
|
||||||
{
|
|
||||||
SQBool val;
|
|
||||||
sq_getbool(vm, idx, &val);
|
|
||||||
return static_cast< signed long long >(val);
|
|
||||||
}
|
|
||||||
case OT_STRING:
|
|
||||||
{
|
|
||||||
const SQChar * val = nullptr;
|
|
||||||
// Attempt to retrieve and convert the string
|
|
||||||
if (SQ_SUCCEEDED(sq_getstring(vm, idx, &val)) && val != nullptr && *val != '\0')
|
|
||||||
{
|
|
||||||
return std::strtoll(val, nullptr, 10);
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
case OT_ARRAY:
|
|
||||||
case OT_TABLE:
|
|
||||||
case OT_CLASS:
|
|
||||||
case OT_USERDATA:
|
|
||||||
{
|
|
||||||
return static_cast< signed long long >(sq_getsize(vm, idx));
|
|
||||||
}
|
|
||||||
case OT_INSTANCE:
|
|
||||||
{
|
|
||||||
// Attempt to treat the value as a signed long instance
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return Var< const SLongInt & >(vm, idx).value.GetNum();
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
// Just ignore it...
|
|
||||||
}
|
|
||||||
// Attempt to treat the value as a unsigned long instance
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return ConvTo< signed long long >::From(Var< const ULongInt & >(vm, idx).value.GetNum());
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
// Just ignore it...
|
|
||||||
}
|
|
||||||
// Attempt to get the size of the instance as a fall back
|
|
||||||
return static_cast< signed long long >(sq_getsize(vm, idx));
|
|
||||||
}
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
// Default to 0
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
unsigned long long PopStackULong(HSQUIRRELVM vm, SQInteger idx)
|
|
||||||
{
|
|
||||||
// Identify which type must be extracted
|
|
||||||
switch (sq_gettype(vm, idx))
|
|
||||||
{
|
|
||||||
case OT_INTEGER:
|
|
||||||
{
|
|
||||||
SQInteger val;
|
|
||||||
sq_getinteger(vm, idx, &val);
|
|
||||||
return ConvTo< unsigned long long >::From(val);
|
|
||||||
}
|
|
||||||
case OT_FLOAT:
|
|
||||||
{
|
|
||||||
SQFloat val;
|
|
||||||
sq_getfloat(vm, idx, &val);
|
|
||||||
return ConvTo< unsigned long long >::From(val);
|
|
||||||
}
|
|
||||||
case OT_BOOL:
|
|
||||||
{
|
|
||||||
SQBool val;
|
|
||||||
sq_getbool(vm, idx, &val);
|
|
||||||
return ConvTo< unsigned long long >::From(val);
|
|
||||||
}
|
|
||||||
case OT_STRING:
|
|
||||||
{
|
|
||||||
const SQChar * val = nullptr;
|
|
||||||
// Attempt to retrieve and convert the string
|
|
||||||
if (SQ_SUCCEEDED(sq_getstring(vm, idx, &val)) && val != nullptr && *val != '\0')
|
|
||||||
{
|
|
||||||
return std::strtoull(val, nullptr, 10);
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
case OT_ARRAY:
|
|
||||||
case OT_TABLE:
|
|
||||||
case OT_CLASS:
|
|
||||||
case OT_USERDATA:
|
|
||||||
{
|
|
||||||
return ConvTo< unsigned long long >::From(sq_getsize(vm, idx));
|
|
||||||
}
|
|
||||||
case OT_INSTANCE:
|
|
||||||
{
|
|
||||||
// Attempt to treat the value as a signed long instance
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return ConvTo< unsigned long long >::From(Var< const SLongInt & >(vm, idx).value.GetNum());
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
// Just ignore it...
|
|
||||||
}
|
|
||||||
// Attempt to treat the value as a unsigned long instance
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return Var< const ULongInt & >(vm, idx).value.GetNum();
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
// Just ignore it...
|
|
||||||
}
|
|
||||||
// Attempt to get the size of the instance as a fall back
|
|
||||||
return ConvTo< unsigned long long >::From(sq_getsize(vm, idx));
|
|
||||||
}
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
// Default to 0
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
const SLongInt & GetSLongInt()
|
|
||||||
{
|
|
||||||
static SLongInt l;
|
|
||||||
l.SetNum(0);
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
const SLongInt & GetSLongInt(signed long long n)
|
|
||||||
{
|
|
||||||
static SLongInt l;
|
|
||||||
l.SetNum(n);
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
const SLongInt & GetSLongInt(const SQChar * s)
|
|
||||||
{
|
|
||||||
static SLongInt l;
|
|
||||||
l = s;
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ULongInt & GetULongInt()
|
|
||||||
{
|
|
||||||
static ULongInt l;
|
|
||||||
l.SetNum(0);
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ULongInt & GetULongInt(unsigned long long n)
|
|
||||||
{
|
|
||||||
static ULongInt l;
|
|
||||||
l.SetNum(n);
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ULongInt & GetULongInt(const SQChar * s)
|
|
||||||
{
|
|
||||||
static ULongInt l;
|
|
||||||
l = s;
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================================================
|
|
||||||
void Register_LongInt(HSQUIRRELVM vm)
|
|
||||||
{
|
|
||||||
RootTable(vm).Bind(TypenameS::Str,
|
|
||||||
Class< SLongInt >(vm, TypenameS::Str)
|
|
||||||
// Constructors
|
|
||||||
.Ctor()
|
|
||||||
.Ctor< SLongInt::Type >()
|
|
||||||
.template Ctor< const char *, SQInteger >()
|
|
||||||
// Properties
|
|
||||||
.Prop(_SC("Str"), &SLongInt::GetCStr, &SLongInt::SetStr)
|
|
||||||
.Prop(_SC("Num"), &SLongInt::GetSNum, &SLongInt::SetNum)
|
|
||||||
// Core Meta-methods
|
|
||||||
.SquirrelFunc(_SC("cmp"), &SqDynArgFwd< SqDynArgCmpFn< SLongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, SLongInt, ULongInt >)
|
|
||||||
.SquirrelFunc(_SC("_typename"), &TypenameS::Fn)
|
|
||||||
.Func(_SC("_tostring"), &SLongInt::ToString)
|
|
||||||
// Core Functions
|
|
||||||
.Func(_SC("tointeger"), &SLongInt::ToSqInteger)
|
|
||||||
.Func(_SC("tofloat"), &SLongInt::ToSqFloat)
|
|
||||||
.Func(_SC("tostring"), &SLongInt::ToSqString)
|
|
||||||
.Func(_SC("tobool"), &SLongInt::ToSqBool)
|
|
||||||
.Func(_SC("tochar"), &SLongInt::ToSqChar)
|
|
||||||
// Meta-methods
|
|
||||||
.SquirrelFunc(_SC("_add"), &SqDynArgFwd< SqDynArgAddFn< SLongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, SLongInt, ULongInt >)
|
|
||||||
.SquirrelFunc(_SC("_sub"), &SqDynArgFwd< SqDynArgSubFn< SLongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, SLongInt, ULongInt >)
|
|
||||||
.SquirrelFunc(_SC("_mul"), &SqDynArgFwd< SqDynArgMulFn< SLongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, SLongInt, ULongInt >)
|
|
||||||
.SquirrelFunc(_SC("_div"), &SqDynArgFwd< SqDynArgDivFn< SLongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, SLongInt, ULongInt >)
|
|
||||||
.SquirrelFunc(_SC("_modulo"), &SqDynArgFwd< SqDynArgModFn< SLongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, SLongInt, ULongInt >)
|
|
||||||
.Func< SLongInt (SLongInt::*)(void) const >(_SC("_unm"), &SLongInt::operator -)
|
|
||||||
// Functions
|
|
||||||
.Func(_SC("GetStr"), &SLongInt::GetCStr)
|
|
||||||
.Func(_SC("SetStr"), &SLongInt::SetStr)
|
|
||||||
.Func(_SC("GetNum"), &SLongInt::GetSNum)
|
|
||||||
.Func(_SC("SetNum"), &SLongInt::SetNum)
|
|
||||||
// Overloads
|
|
||||||
.Overload< void (SLongInt::*)(void) >(_SC("Random"), &SLongInt::Random)
|
|
||||||
.Overload< void (SLongInt::*)(SLongInt::Type) >(_SC("Random"), &SLongInt::Random)
|
|
||||||
.Overload< void (SLongInt::*)(SLongInt::Type, SLongInt::Type) >(_SC("Random"), &SLongInt::Random)
|
|
||||||
);
|
|
||||||
|
|
||||||
RootTable(vm).Bind(TypenameU::Str,
|
|
||||||
Class< ULongInt >(vm, TypenameU::Str)
|
|
||||||
// Constructors
|
|
||||||
.Ctor()
|
|
||||||
.Ctor< ULongInt::Type >()
|
|
||||||
.Ctor< const char *, SQInteger >()
|
|
||||||
// Properties
|
|
||||||
.Prop(_SC("Str"), &ULongInt::GetCStr, &ULongInt::SetStr)
|
|
||||||
.Prop(_SC("Num"), &ULongInt::GetSNum, &ULongInt::SetNum)
|
|
||||||
// Core Meta-methods
|
|
||||||
.SquirrelFunc(_SC("cmp"), &SqDynArgFwd< SqDynArgCmpFn< ULongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, ULongInt, SLongInt >)
|
|
||||||
.SquirrelFunc(_SC("_typename"), &TypenameU::Fn)
|
|
||||||
.Func(_SC("_tostring"), &ULongInt::ToString)
|
|
||||||
// Core Functions
|
|
||||||
.Func(_SC("tointeger"), &ULongInt::ToSqInteger)
|
|
||||||
.Func(_SC("tofloat"), &ULongInt::ToSqFloat)
|
|
||||||
.Func(_SC("tostring"), &ULongInt::ToSqString)
|
|
||||||
.Func(_SC("tobool"), &ULongInt::ToSqBool)
|
|
||||||
.Func(_SC("tochar"), &ULongInt::ToSqChar)
|
|
||||||
// Meta-methods
|
|
||||||
.SquirrelFunc(_SC("_add"), &SqDynArgFwd< SqDynArgAddFn< ULongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, ULongInt, SLongInt >)
|
|
||||||
.SquirrelFunc(_SC("_sub"), &SqDynArgFwd< SqDynArgSubFn< ULongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, ULongInt, SLongInt >)
|
|
||||||
.SquirrelFunc(_SC("_mul"), &SqDynArgFwd< SqDynArgMulFn< ULongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, ULongInt, SLongInt >)
|
|
||||||
.SquirrelFunc(_SC("_div"), &SqDynArgFwd< SqDynArgDivFn< ULongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, ULongInt, SLongInt >)
|
|
||||||
.SquirrelFunc(_SC("_modulo"), &SqDynArgFwd< SqDynArgModFn< ULongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, ULongInt, SLongInt >)
|
|
||||||
.Func< ULongInt (ULongInt::*)(void) const >(_SC("_unm"), &ULongInt::operator -)
|
|
||||||
// Functions
|
|
||||||
.Func(_SC("GetStr"), &ULongInt::GetCStr)
|
|
||||||
.Func(_SC("SetStr"), &ULongInt::SetStr)
|
|
||||||
.Func(_SC("GetNum"), &ULongInt::GetSNum)
|
|
||||||
.Func(_SC("SetNum"), &ULongInt::SetNum)
|
|
||||||
// Overloads
|
|
||||||
.Overload< void (ULongInt::*)(void) >(_SC("Random"), &ULongInt::Random)
|
|
||||||
.Overload< void (ULongInt::*)(ULongInt::Type) >(_SC("Random"), &ULongInt::Random)
|
|
||||||
.Overload< void (ULongInt::*)(ULongInt::Type, ULongInt::Type) >(_SC("Random"), &ULongInt::Random)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,5 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/Numeric/Math.hpp"
|
#include "Library/Numeric/Math.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@@ -66,7 +65,7 @@ static SQInteger SqRemainder(HSQUIRRELVM vm)
|
|||||||
// Are we both arguments integers?
|
// Are we both arguments integers?
|
||||||
else if ((sq_gettype(vm, 2) == OT_INTEGER) && sq_gettype(vm, 3) == OT_INTEGER)
|
else if ((sq_gettype(vm, 2) == OT_INTEGER) && sq_gettype(vm, 3) == OT_INTEGER)
|
||||||
{ // NOLINT(bugprone-branch-clone)
|
{ // NOLINT(bugprone-branch-clone)
|
||||||
sq_pushinteger(vm, std::remainder(PopStackInteger(vm, 2), PopStackInteger(vm, 3)));
|
sq_pushinteger(vm, static_cast< SQInteger >(std::remainder(PopStackInteger(vm, 2), PopStackInteger(vm, 3))));
|
||||||
}
|
}
|
||||||
// Is the first argument float?
|
// Is the first argument float?
|
||||||
else if ((sq_gettype(vm, 2) == OT_FLOAT))
|
else if ((sq_gettype(vm, 2) == OT_FLOAT))
|
||||||
@@ -76,7 +75,7 @@ static SQInteger SqRemainder(HSQUIRRELVM vm)
|
|||||||
// Is the first argument integer?
|
// Is the first argument integer?
|
||||||
else if ((sq_gettype(vm, 2) == OT_INTEGER))
|
else if ((sq_gettype(vm, 2) == OT_INTEGER))
|
||||||
{
|
{
|
||||||
sq_pushinteger(vm, std::remainder(PopStackInteger(vm, 2), PopStackInteger(vm, 3)));
|
sq_pushinteger(vm, static_cast< SQInteger >(std::remainder(PopStackInteger(vm, 2), PopStackInteger(vm, 3))));
|
||||||
}
|
}
|
||||||
// Default to both arguments as float so we don't loos precision from the float one
|
// Default to both arguments as float so we don't loos precision from the float one
|
||||||
else
|
else
|
||||||
@@ -184,18 +183,7 @@ static SQInteger SqNanL(HSQUIRRELVM vm)
|
|||||||
return val.mRes; // Propagate the error!
|
return val.mRes; // Propagate the error!
|
||||||
}
|
}
|
||||||
// Fetch the arguments from the stack and perform the requested operation
|
// Fetch the arguments from the stack and perform the requested operation
|
||||||
try
|
sq_pushinteger(vm, static_cast< SQInteger >(std::nanl(val.mPtr)));
|
||||||
{
|
|
||||||
Var< SLongInt * >::push(vm, new SLongInt(std::nanl(val.mPtr)));
|
|
||||||
}
|
|
||||||
catch (const std::exception & e)
|
|
||||||
{
|
|
||||||
return sq_throwerror(vm, e.what());
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
return sq_throwerror(vm, _SC("Failed to create a long integer instance"));
|
|
||||||
}
|
|
||||||
// Specify that we have a value on the stack
|
// Specify that we have a value on the stack
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -659,11 +647,11 @@ static SQInteger SqRoundI(HSQUIRRELVM vm)
|
|||||||
// Fetch the arguments from the stack and perform the requested operation
|
// Fetch the arguments from the stack and perform the requested operation
|
||||||
if (sq_gettype(vm, 2) == OT_FLOAT)
|
if (sq_gettype(vm, 2) == OT_FLOAT)
|
||||||
{
|
{
|
||||||
sq_pushinteger(vm, ConvTo< SQInteger >::From(std::llround(PopStackFloat(vm, 2))));
|
sq_pushinteger(vm, static_cast< SQInteger >(std::llround(PopStackFloat(vm, 2))));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sq_pushinteger(vm, ConvTo< SQInteger >::From(std::llround(PopStackInteger(vm, 2))));
|
sq_pushinteger(vm, static_cast< SQInteger >(std::llround(PopStackInteger(vm, 2))));
|
||||||
}
|
}
|
||||||
// Specify that we have a value on the stack
|
// Specify that we have a value on the stack
|
||||||
return 1;
|
return 1;
|
||||||
@@ -678,24 +666,13 @@ static SQInteger SqRoundL(HSQUIRRELVM vm)
|
|||||||
return sq_throwerror(vm, "Wrong number of arguments");
|
return sq_throwerror(vm, "Wrong number of arguments");
|
||||||
}
|
}
|
||||||
// Fetch the arguments from the stack and perform the requested operation
|
// Fetch the arguments from the stack and perform the requested operation
|
||||||
try
|
if (sq_gettype(vm, 2) == OT_FLOAT)
|
||||||
{
|
{
|
||||||
if (sq_gettype(vm, 2) == OT_FLOAT)
|
sq_pushinteger(vm, static_cast< SQInteger >(std::llround(PopStackFloat(vm, 2))));
|
||||||
{
|
|
||||||
Var< SLongInt * >::push(vm, new SLongInt(std::llround(PopStackFloat(vm, 2))));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Var< SLongInt * >::push(vm, new SLongInt(std::llround(PopStackInteger(vm, 2))));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (const std::exception & e)
|
else
|
||||||
{
|
{
|
||||||
return sq_throwerror(vm, e.what());
|
sq_pushinteger(vm, static_cast< SQInteger >(std::llround(PopStackInteger(vm, 2))));
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
return sq_throwerror(vm, _SC("Failed to create a long integer instance"));
|
|
||||||
}
|
}
|
||||||
// Specify that we have a value on the stack
|
// Specify that we have a value on the stack
|
||||||
return 1;
|
return 1;
|
||||||
@@ -760,7 +737,7 @@ static SQInteger SqLdexp(HSQUIRRELVM vm)
|
|||||||
return sq_throwerror(vm, "Wrong number of arguments");
|
return sq_throwerror(vm, "Wrong number of arguments");
|
||||||
}
|
}
|
||||||
// Fetch the arguments from the stack and perform the requested operation
|
// Fetch the arguments from the stack and perform the requested operation
|
||||||
sq_pushfloat(vm, std::ldexp(PopStackFloat(vm, 2), PopStackInteger(vm, 3)));
|
sq_pushfloat(vm, std::ldexp(PopStackFloat(vm, 2), static_cast< int >(PopStackInteger(vm, 3))));
|
||||||
// Specify that we have a value on the stack
|
// Specify that we have a value on the stack
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -811,9 +788,9 @@ static SQInteger SqScalbn(HSQUIRRELVM vm)
|
|||||||
}
|
}
|
||||||
// Fetch the arguments from the stack and perform the requested operation
|
// Fetch the arguments from the stack and perform the requested operation
|
||||||
#ifdef _SQ64
|
#ifdef _SQ64
|
||||||
sq_pushfloat(vm, std::scalbln(PopStackFloat(vm, 2), PopStackInteger(vm, 3)));
|
sq_pushfloat(vm, std::scalbln(PopStackFloat(vm, 2), static_cast< int >(PopStackInteger(vm, 3))));
|
||||||
#else
|
#else
|
||||||
sq_pushfloat(vm, std::scalbn(PopStackFloat(vm, 2), PopStackInteger(vm, 3)));
|
sq_pushfloat(vm, std::scalbn(PopStackFloat(vm, 2), static_cast< int >(PopStackInteger(vm, 3))));
|
||||||
#endif // _SQ64
|
#endif // _SQ64
|
||||||
// Specify that we have a value on the stack
|
// Specify that we have a value on the stack
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1066,7 +1043,7 @@ static SQInteger SqDigits1(HSQUIRRELVM vm)
|
|||||||
return sq_throwerror(vm, "Wrong number of arguments");
|
return sq_throwerror(vm, "Wrong number of arguments");
|
||||||
}
|
}
|
||||||
// Fetch the integer value from the stack
|
// Fetch the integer value from the stack
|
||||||
int64_t n = std::llabs(PopStackSLong(vm, 2));
|
int64_t n = std::llabs(PopStackInteger(vm, 2));
|
||||||
// Start with 0 digits
|
// Start with 0 digits
|
||||||
uint8_t d = 0;
|
uint8_t d = 0;
|
||||||
// Identify the number of digits
|
// Identify the number of digits
|
||||||
@@ -1090,7 +1067,7 @@ static SQInteger SqDigits0(HSQUIRRELVM vm)
|
|||||||
return sq_throwerror(vm, "Wrong number of arguments");
|
return sq_throwerror(vm, "Wrong number of arguments");
|
||||||
}
|
}
|
||||||
// Fetch the integer value from the stack
|
// Fetch the integer value from the stack
|
||||||
int64_t n = std::llabs(PopStackSLong(vm, 2));
|
int64_t n = std::llabs(PopStackInteger(vm, 2));
|
||||||
// Start with 0 digits
|
// Start with 0 digits
|
||||||
uint8_t d = 0;
|
uint8_t d = 0;
|
||||||
// Identify the number of digits
|
// Identify the number of digits
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Core/Common.hpp"
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|||||||
+40
-35
@@ -424,21 +424,21 @@ int32_t ReleaseMemory(int32_t bytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Object GetMemoryUsage()
|
SQInteger GetMemoryUsage()
|
||||||
{
|
{
|
||||||
// Obtain the initial stack size
|
// Obtain the initial stack size
|
||||||
const StackGuard sg;
|
const StackGuard sg;
|
||||||
// Push a long integer instance with the requested value on the stack
|
// Push a long integer instance with the requested value on the stack
|
||||||
return Object(new SLongInt(sqlite3_memory_used()));
|
return sqlite3_memory_used();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Object GetMemoryHighwaterMark(bool reset)
|
SQInteger GetMemoryHighwaterMark(bool reset)
|
||||||
{
|
{
|
||||||
// Obtain the initial stack size
|
// Obtain the initial stack size
|
||||||
const StackGuard sg;
|
const StackGuard sg;
|
||||||
// Push a long integer instance with the requested value on the stack
|
// Push a long integer instance with the requested value on the stack
|
||||||
return Object(new SLongInt(sqlite3_memory_highwater(reset)));
|
return sqlite3_memory_highwater(reset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -451,11 +451,15 @@ LightObj EscapeString(StackStrF & str)
|
|||||||
}
|
}
|
||||||
// Allocate a memory buffer
|
// Allocate a memory buffer
|
||||||
std::vector< SQChar > b;
|
std::vector< SQChar > b;
|
||||||
b.reserve(static_cast< size_t >(str.mLen));
|
// Allocate extra space to make sure there's room for a null terminator since we need it
|
||||||
|
// This is a f* up from SQLite devs not returning the number of written characters from snprintf
|
||||||
|
// So we can figure out if we actually had room for the null terminator or not
|
||||||
|
b.reserve(static_cast< size_t >(str.mLen * 2 + 1));
|
||||||
// Attempt to escape the specified string
|
// Attempt to escape the specified string
|
||||||
sqlite3_snprintf(static_cast<int>(b.capacity()), b.data(), "%q", str.mPtr);
|
sqlite3_snprintf(static_cast<int>(b.capacity()), b.data(), "%q", str.mPtr);
|
||||||
// Return the resulted string
|
// Return the resulted string
|
||||||
return LightObj(b.data());
|
LightObj o(b.data(), -1);
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -477,7 +481,8 @@ LightObj EscapeStringEx(SQChar spec, StackStrF & str)
|
|||||||
fs[1] = spec;
|
fs[1] = spec;
|
||||||
// Allocate a memory buffer
|
// Allocate a memory buffer
|
||||||
std::vector< SQChar > b;
|
std::vector< SQChar > b;
|
||||||
b.reserve(static_cast< size_t >(str.mLen));
|
// Allocate extra space to make sure there's room for a null terminator since we need it (see above)
|
||||||
|
b.reserve(static_cast< size_t >(str.mLen * 2 + 1));
|
||||||
// Attempt to escape the specified string
|
// Attempt to escape the specified string
|
||||||
sqlite3_snprintf(static_cast<int>(b.capacity()), b.data(), fs, str.mPtr);
|
sqlite3_snprintf(static_cast<int>(b.capacity()), b.data(), fs, str.mPtr);
|
||||||
// Return the resulted string
|
// Return the resulted string
|
||||||
@@ -886,7 +891,7 @@ void SQLiteConnection::TraceOutput(void * /*ptr*/, const char * sql)
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SQLiteConnection::ProfileOutput(void * /*ptr*/, const char * sql, sqlite3_uint64 time)
|
void SQLiteConnection::ProfileOutput(void * /*ptr*/, const char * sql, sqlite3_uint64 time)
|
||||||
{
|
{
|
||||||
LogInf("SQLite profile (time: %" PRINT_UINT_FMT "): %s", time, sql);
|
LogInf("SQLite profile (time: %llu): %s", time, sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -895,7 +900,7 @@ void SQLiteConnection::Validate(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite connection reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite connection reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -914,11 +919,11 @@ void SQLiteConnection::ValidateCreated(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite connection reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite connection reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
else if (m_Handle->mPtr == nullptr)
|
else if (m_Handle->mPtr == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite connection =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite connection =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1227,12 +1232,12 @@ void SQLiteParameter::Validate(const char * file, int32_t line) const
|
|||||||
// Are we pointing to a valid index?
|
// Are we pointing to a valid index?
|
||||||
if (m_Index < 0)
|
if (m_Index < 0)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid column index: {} < 0 =>[{}:{}]", m_Index, file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid column index: {} < 0 =>[{}:{}]"), m_Index, file, line);
|
||||||
}
|
}
|
||||||
// Do we have a valid statement handle?
|
// Do we have a valid statement handle?
|
||||||
else if (!m_Handle)
|
else if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1258,15 +1263,15 @@ void SQLiteParameter::ValidateCreated(const char * file, int32_t line) const
|
|||||||
// Are we pointing to a valid index?
|
// Are we pointing to a valid index?
|
||||||
if (m_Index < 0)
|
if (m_Index < 0)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid column index: {} < 0 =>[{}:{}]", m_Index, file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid column index: {} < 0 =>[{}:{}]"), m_Index, file, line);
|
||||||
}
|
}
|
||||||
else if (!m_Handle)
|
else if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
else if (m_Handle->mPtr == nullptr)
|
else if (m_Handle->mPtr == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1326,7 +1331,7 @@ void SQLiteParameter::ValidateParam(int32_t idx, const char * file, int32_t line
|
|||||||
// Is the specified index in range?
|
// Is the specified index in range?
|
||||||
if (!m_Handle->CheckParameter(idx))
|
if (!m_Handle->CheckParameter(idx))
|
||||||
{
|
{
|
||||||
SqThrowF("Parameter index is out of range ({}:{}) =>[{}:{}]", idx, m_Handle->mParameters,
|
SqThrowF(SQMOD_RTFMT("Parameter index is out of range ({}:{}) =>[{}:{}]"), idx, m_Handle->mParameters,
|
||||||
file, line);
|
file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1585,11 +1590,11 @@ void SQLiteParameter::SetUint32(SQInteger value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SQLiteParameter::SetInt64(const Object & value)
|
void SQLiteParameter::SetInt64(SQInteger value)
|
||||||
{
|
{
|
||||||
SQMOD_VALIDATE_CREATED(*this);
|
SQMOD_VALIDATE_CREATED(*this);
|
||||||
// Attempt to bind the specified value
|
// Attempt to bind the specified value
|
||||||
m_Handle->mStatus = sqlite3_bind_int64(m_Handle->mPtr, m_Index, value.Cast< const SLongInt & >().GetNum());
|
m_Handle->mStatus = sqlite3_bind_int64(m_Handle->mPtr, m_Index, value);
|
||||||
// Validate the result
|
// Validate the result
|
||||||
if (m_Handle->mStatus != SQLITE_OK)
|
if (m_Handle->mStatus != SQLITE_OK)
|
||||||
{
|
{
|
||||||
@@ -1598,11 +1603,11 @@ void SQLiteParameter::SetInt64(const Object & value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SQLiteParameter::SetUint64(const Object & value)
|
void SQLiteParameter::SetUint64(SQInteger value)
|
||||||
{
|
{
|
||||||
SQMOD_VALIDATE_CREATED(*this);
|
SQMOD_VALIDATE_CREATED(*this);
|
||||||
// Attempt to bind the specified value
|
// Attempt to bind the specified value
|
||||||
m_Handle->mStatus = sqlite3_bind_int64(m_Handle->mPtr, m_Index, value.Cast< const ULongInt & >().GetNum());
|
m_Handle->mStatus = sqlite3_bind_int64(m_Handle->mPtr, m_Index, value);
|
||||||
// Validate the result
|
// Validate the result
|
||||||
if (m_Handle->mStatus != SQLITE_OK)
|
if (m_Handle->mStatus != SQLITE_OK)
|
||||||
{
|
{
|
||||||
@@ -1933,12 +1938,12 @@ void SQLiteColumn::Validate(const char * file, int32_t line) const
|
|||||||
// Are we pointing to a valid index?
|
// Are we pointing to a valid index?
|
||||||
if (m_Index < 0)
|
if (m_Index < 0)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid column index: {} < 0 =>[{}:{}]", m_Index, file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid column index: {} < 0 =>[{}:{}]"), m_Index, file, line);
|
||||||
}
|
}
|
||||||
// Do we have a valid statement handle?
|
// Do we have a valid statement handle?
|
||||||
else if (!m_Handle)
|
else if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -1964,15 +1969,15 @@ void SQLiteColumn::ValidateCreated(const char * file, int32_t line) const
|
|||||||
// Are we pointing to a valid index?
|
// Are we pointing to a valid index?
|
||||||
if (m_Index < 0)
|
if (m_Index < 0)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid column index: {} < 0 =>[{}:{}]", m_Index, file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid column index: {} < 0 =>[{}:{}]"), m_Index, file, line);
|
||||||
}
|
}
|
||||||
else if (!m_Handle)
|
else if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
else if (m_Handle->mPtr == nullptr)
|
else if (m_Handle->mPtr == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -2032,7 +2037,7 @@ void SQLiteColumn::ValidateColumn(int32_t idx, const char * file, int32_t line)
|
|||||||
// Is the specified index in range?
|
// Is the specified index in range?
|
||||||
if (!m_Handle->CheckColumn(idx))
|
if (!m_Handle->CheckColumn(idx))
|
||||||
{
|
{
|
||||||
SqThrowF("Column index is out of range: {}:{} =>[{}:{}]", idx, m_Handle->mColumns,
|
SqThrowF(SQMOD_RTFMT("Column index is out of range: {}:{} =>[{}:{}]"), idx, m_Handle->mColumns,
|
||||||
file, line);
|
file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2315,11 +2320,11 @@ SQFloat SQLiteColumn::GetFloat() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Object SQLiteColumn::GetLong() const
|
SQInteger SQLiteColumn::GetLong() const
|
||||||
{
|
{
|
||||||
SQMOD_VALIDATE_ROW(*this);
|
SQMOD_VALIDATE_ROW(*this);
|
||||||
// Return the requested information
|
// Return the requested information
|
||||||
return Object(new SLongInt(sqlite3_column_int64(m_Handle->mPtr, m_Index)));
|
return sqlite3_column_int64(m_Handle->mPtr, m_Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -2407,7 +2412,7 @@ void SQLiteStatement::Validate(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -2426,11 +2431,11 @@ void SQLiteStatement::ValidateCreated(const char * file, int32_t line) const
|
|||||||
{
|
{
|
||||||
if (!m_Handle)
|
if (!m_Handle)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement reference =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement reference =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
else if (m_Handle->mPtr == nullptr)
|
else if (m_Handle->mPtr == nullptr)
|
||||||
{
|
{
|
||||||
SqThrowF("Invalid SQLite statement =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("Invalid SQLite statement =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -2485,7 +2490,7 @@ void SQLiteStatement::ValidateColumn(int32_t idx, const char * file, int32_t lin
|
|||||||
// Is the specified index in range?
|
// Is the specified index in range?
|
||||||
if (!m_Handle->CheckColumn(idx))
|
if (!m_Handle->CheckColumn(idx))
|
||||||
{
|
{
|
||||||
SqThrowF("Column index is out of range: {}:{} =>[{}:{}]", idx, m_Handle->mColumns, file, line);
|
SqThrowF(SQMOD_RTFMT("Column index is out of range: {}:{} =>[{}:{}]"), idx, m_Handle->mColumns, file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -2508,7 +2513,7 @@ void SQLiteStatement::ValidateParam(int32_t idx, const char * file, int32_t line
|
|||||||
// Is the specified index in range?
|
// Is the specified index in range?
|
||||||
if (!m_Handle->CheckParameter(idx))
|
if (!m_Handle->CheckParameter(idx))
|
||||||
{
|
{
|
||||||
SqThrowF("Parameter index is out of range: {}:{} =>[{}:{}]", idx, m_Handle->mParameters, file, line);
|
SqThrowF(SQMOD_RTFMT("Parameter index is out of range: {}:{} =>[{}:{}]"), idx, m_Handle->mParameters, file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -2531,7 +2536,7 @@ void SQLiteStatement::ValidateRow(const char * file, int32_t line) const
|
|||||||
// Do we have any rows available?
|
// Do we have any rows available?
|
||||||
if (!m_Handle->mGood)
|
if (!m_Handle->mGood)
|
||||||
{
|
{
|
||||||
SqThrowF("No row available =>[{}:{}]", file, line);
|
SqThrowF(SQMOD_RTFMT("No row available =>[{}:{}]"), file, line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|||||||
+15
-16
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/IO/Buffer.hpp"
|
#include "Library/IO/Buffer.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
#include "Library/Chrono/Date.hpp"
|
#include "Library/Chrono/Date.hpp"
|
||||||
#include "Library/Chrono/Datetime.hpp"
|
#include "Library/Chrono/Datetime.hpp"
|
||||||
#include "Library/Chrono/Time.hpp"
|
#include "Library/Chrono/Time.hpp"
|
||||||
@@ -95,12 +94,12 @@ Object GetStatementObj(const StmtRef & stmt);
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Tests if a certain query string is empty.
|
* Tests if a certain query string is empty.
|
||||||
*/
|
*/
|
||||||
bool IsQueryEmpty(const SQChar * str);
|
SQMOD_NODISCARD bool IsQueryEmpty(const SQChar * str);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the string representation of a certain status code.
|
* Retrieve the string representation of a certain status code.
|
||||||
*/
|
*/
|
||||||
const SQChar * GetErrStr(int32_t status);
|
SQMOD_NODISCARD const SQChar * GetErrStr(int32_t status);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Set a specific heap limit.
|
* Set a specific heap limit.
|
||||||
@@ -115,32 +114,32 @@ int32_t ReleaseMemory(int32_t bytes);
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the current memory usage.
|
* Retrieve the current memory usage.
|
||||||
*/
|
*/
|
||||||
Object GetMemoryUsage();
|
SQMOD_NODISCARD SQInteger GetMemoryUsage();
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the memory high watermark.
|
* Retrieve the memory high watermark.
|
||||||
*/
|
*/
|
||||||
Object GetMemoryHighwaterMark(bool reset);
|
SQMOD_NODISCARD SQInteger GetMemoryHighwaterMark(bool reset);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the escaped version of the specified string.
|
* Retrieve the escaped version of the specified string.
|
||||||
*/
|
*/
|
||||||
LightObj EscapeString(StackStrF & str);
|
SQMOD_NODISCARD LightObj EscapeString(StackStrF & str);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the escaped version of the specified string using the supplied format specifier.
|
* Retrieve the escaped version of the specified string using the supplied format specifier.
|
||||||
*/
|
*/
|
||||||
LightObj EscapeStringEx(SQChar spec, StackStrF & str);
|
SQMOD_NODISCARD LightObj EscapeStringEx(SQChar spec, StackStrF & str);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Convert the values from the specified array to a list of column names string.
|
* Convert the values from the specified array to a list of column names string.
|
||||||
*/
|
*/
|
||||||
LightObj ArrayToQueryColumns(Array & arr);
|
SQMOD_NODISCARD LightObj ArrayToQueryColumns(Array & arr);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Convert the keys from the specified array to a list of column names string.
|
* Convert the keys from the specified array to a list of column names string.
|
||||||
*/
|
*/
|
||||||
LightObj TableToQueryColumns(Table & tbl);
|
SQMOD_NODISCARD LightObj TableToQueryColumns(Table & tbl);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* The structure that holds the data associated with a certain connection.
|
* The structure that holds the data associated with a certain connection.
|
||||||
@@ -701,9 +700,9 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Get the row-id of the most recent successful INSERT into the database from the current connection.
|
* Get the row-id of the most recent successful INSERT into the database from the current connection.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Object GetLastInsertRowID() const
|
SQMOD_NODISCARD SQInteger GetLastInsertRowID() const
|
||||||
{
|
{
|
||||||
return Object(new SLongInt(sqlite3_last_insert_rowid(SQMOD_GET_CREATED(*this)->mPtr)));
|
return sqlite3_last_insert_rowid(SQMOD_GET_CREATED(*this)->mPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@@ -1148,12 +1147,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Attempt to bind a signed 64 bit integer value at the referenced parameter index.
|
* Attempt to bind a signed 64 bit integer value at the referenced parameter index.
|
||||||
*/
|
*/
|
||||||
void SetInt64(const Object & value);
|
void SetInt64(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Attempt to bind an unsigned 64 bit integer value at the referenced parameter index.
|
* Attempt to bind an unsigned 64 bit integer value at the referenced parameter index.
|
||||||
*/
|
*/
|
||||||
void SetUint64(const Object & value);
|
void SetUint64(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Attempt to bind a native floating point value at the referenced parameter index.
|
* Attempt to bind a native floating point value at the referenced parameter index.
|
||||||
@@ -1538,7 +1537,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value inside the referenced column as a long integer.
|
* Retrieve the value inside the referenced column as a long integer.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Object GetLong() const;
|
SQMOD_NODISCARD SQInteger GetLong() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value inside the referenced column as a string.
|
* Retrieve the value inside the referenced column as a string.
|
||||||
@@ -2101,7 +2100,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Attempt to bind a signed 64 bit integer value at the specified parameter index.
|
* Attempt to bind a signed 64 bit integer value at the specified parameter index.
|
||||||
*/
|
*/
|
||||||
SQLiteStatement & SetInt64(const Object & param, const Object & value)
|
SQLiteStatement & SetInt64(const Object & param, SQInteger value)
|
||||||
{
|
{
|
||||||
SQLiteParameter(SQMOD_GET_CREATED(*this), param).SetInt64(value);
|
SQLiteParameter(SQMOD_GET_CREATED(*this), param).SetInt64(value);
|
||||||
// Allow chaining of operations
|
// Allow chaining of operations
|
||||||
@@ -2111,7 +2110,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Attempt to bind an unsigned 64 bit integer value at the specified parameter index.
|
* Attempt to bind an unsigned 64 bit integer value at the specified parameter index.
|
||||||
*/
|
*/
|
||||||
SQLiteStatement & SetUint64(const Object & param, const Object & value)
|
SQLiteStatement & SetUint64(const Object & param, SQInteger value)
|
||||||
{
|
{
|
||||||
SQLiteParameter(SQMOD_GET_CREATED(*this), param).SetUint64(value);
|
SQLiteParameter(SQMOD_GET_CREATED(*this), param).SetUint64(value);
|
||||||
// Allow chaining of operations
|
// Allow chaining of operations
|
||||||
|
|||||||
+175
-10
@@ -189,7 +189,7 @@ static LightObj SqCenterStr(SQChar f, uint32_t w, StackStrF & s)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Calculate the insert position
|
// Calculate the insert position
|
||||||
const int32_t p = ((w/2) - (s.mLen/2));
|
const auto p = ((w/2) - (s.mLen/2));
|
||||||
// Insert only the fill character first
|
// Insert only the fill character first
|
||||||
std::memset(b.Data(), f, w);
|
std::memset(b.Data(), f, w);
|
||||||
// Overwrite with the specified string
|
// Overwrite with the specified string
|
||||||
@@ -287,7 +287,7 @@ static Buffer StrToLowercaseImpl(const SQChar * str, uint32_t len)
|
|||||||
while (*str != '\0')
|
while (*str != '\0')
|
||||||
{
|
{
|
||||||
// Convert it and move to the next one
|
// Convert it and move to the next one
|
||||||
b.At(n++) = std::tolower(*(str++));
|
b.At(n++) = static_cast< char >(std::tolower(*(str++)));
|
||||||
}
|
}
|
||||||
// End the resulted string
|
// End the resulted string
|
||||||
b.At(n) = '\0';
|
b.At(n) = '\0';
|
||||||
@@ -349,7 +349,7 @@ static Buffer StrToUppercaseImpl(const SQChar * str, uint32_t len)
|
|||||||
while (*str != '\0')
|
while (*str != '\0')
|
||||||
{
|
{
|
||||||
// Convert it and move to the next one
|
// Convert it and move to the next one
|
||||||
b.At(n++) = std::toupper(*(str++));
|
b.At(n++) = static_cast< char >(std::toupper(*(str++)));
|
||||||
}
|
}
|
||||||
// End the resulted string
|
// End the resulted string
|
||||||
b.At(n) = '\0';
|
b.At(n) = '\0';
|
||||||
@@ -594,7 +594,7 @@ static bool OnlyDelimiter(const SQChar * str, SQChar chr)
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SQInteger SqStrExplode(HSQUIRRELVM vm)
|
static SQInteger SqStrExplode(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
const int32_t top = sq_gettop(vm);
|
const auto top = sq_gettop(vm);
|
||||||
// Was the delimiter character specified?
|
// Was the delimiter character specified?
|
||||||
if (top <= 1)
|
if (top <= 1)
|
||||||
{
|
{
|
||||||
@@ -899,17 +899,79 @@ static String StrCharacterSwap(SQInteger a, SQInteger b, StackStrF & val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SQInteger SqStrToI(SQInteger base, StackStrF & s)
|
// Returns a size_t, depicting the difference between `a` and `b`. See: https://github.com/wooorm/levenshtein.c
|
||||||
|
// See <https://en.wikipedia.org/wiki/Levenshtein_distance> for more information.
|
||||||
|
SQMOD_NODISCARD static size_t Levenshtein_n(const char * a, const size_t a_length, const char * b, const size_t b_length) noexcept
|
||||||
|
{
|
||||||
|
// Shortcut optimizations / degenerate cases.
|
||||||
|
if (a == b)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (a_length == 0)
|
||||||
|
{
|
||||||
|
return b_length;
|
||||||
|
}
|
||||||
|
else if (b_length == 0)
|
||||||
|
{
|
||||||
|
return a_length;
|
||||||
|
}
|
||||||
|
auto cache = reinterpret_cast< size_t * >(calloc(a_length, sizeof(size_t)));
|
||||||
|
size_t index = 0;
|
||||||
|
size_t b_index = 0;
|
||||||
|
size_t distance;
|
||||||
|
size_t b_distance;
|
||||||
|
size_t result;
|
||||||
|
char code;
|
||||||
|
// initialize the vector.
|
||||||
|
while (index < a_length)
|
||||||
|
{
|
||||||
|
cache[index] = index + 1;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
// Loop
|
||||||
|
while (b_index < b_length)
|
||||||
|
{
|
||||||
|
code = b[b_index];
|
||||||
|
result = distance = b_index++;
|
||||||
|
index = SIZE_MAX;
|
||||||
|
|
||||||
|
while (++index < a_length)
|
||||||
|
{
|
||||||
|
b_distance = code == a[index] ? distance : distance + 1;
|
||||||
|
distance = cache[index];
|
||||||
|
|
||||||
|
cache[index] = result = distance > result
|
||||||
|
? b_distance > result
|
||||||
|
? result + 1
|
||||||
|
: b_distance
|
||||||
|
: b_distance > distance
|
||||||
|
? distance + 1
|
||||||
|
: b_distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(cache);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static SQInteger SqLevenshtein(StackStrF & a, StackStrF & b)
|
||||||
|
{
|
||||||
|
return static_cast< SQInteger >(Levenshtein_n(a.mPtr, static_cast< size_t >(a.mLen), b.mPtr, static_cast< size_t >(b.mLen)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static SQInteger SqStringToInt(SQInteger base, StackStrF & s)
|
||||||
{
|
{
|
||||||
#ifdef _SQ64
|
#ifdef _SQ64
|
||||||
return std::stoll(s.mPtr, nullptr, ConvTo< int >::From((base)));
|
return std::stoll(s.ToStr(), nullptr, ConvTo< int >::From((base)));
|
||||||
#else
|
#else
|
||||||
return std::stoi(s.mPtr, nullptr, ConvTo< int >::From((base)));
|
return std::stoi(s.ToStr(), nullptr, ConvTo< int >::From((base)));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SQFloat SqStrToF(StackStrF & s)
|
static SQFloat SqStringToFloat(StackStrF & s)
|
||||||
{
|
{
|
||||||
#ifdef SQUSEDOUBLE
|
#ifdef SQUSEDOUBLE
|
||||||
return std::strtod(s.mPtr, nullptr);
|
return std::strtod(s.mPtr, nullptr);
|
||||||
@@ -918,6 +980,102 @@ static SQFloat SqStrToF(StackStrF & s)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD static Table SqStringToL(SQInteger base, StackStrF & s)
|
||||||
|
{
|
||||||
|
SQChar * end = nullptr;
|
||||||
|
// Attempt to process the specified string
|
||||||
|
const auto r = std::strtol(s.mPtr, &end, ConvTo< int >::From((base)));
|
||||||
|
// Allocate a table for the result
|
||||||
|
Table t(SqVM(), 2);
|
||||||
|
// Insert the resulted value
|
||||||
|
t.SetValue(_SC("value"), r);
|
||||||
|
// Insert the end of the value
|
||||||
|
t.SetValue(_SC("end"), static_cast< intptr_t >(end - s.mPtr));
|
||||||
|
// Return the table containing the results
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD static Table SqStringToLL(SQInteger base, StackStrF & s)
|
||||||
|
{
|
||||||
|
SQChar * end = nullptr;
|
||||||
|
// Attempt to process the specified string
|
||||||
|
const auto r = std::strtoll(s.mPtr, &end, ConvTo< int >::From((base)));
|
||||||
|
// Allocate a table for the result
|
||||||
|
Table t(SqVM(), 2);
|
||||||
|
// Insert the resulted value
|
||||||
|
t.SetValue(_SC("value"), r);
|
||||||
|
// Insert the end of the value
|
||||||
|
t.SetValue(_SC("end"), static_cast< intptr_t >(end - s.mPtr));
|
||||||
|
// Return the table containing the results
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD static Table SqStringToUL(SQInteger base, StackStrF & s)
|
||||||
|
{
|
||||||
|
SQChar * end = nullptr;
|
||||||
|
// Attempt to process the specified string
|
||||||
|
const auto r = std::strtoul(s.mPtr, &end, ConvTo< int >::From((base)));
|
||||||
|
// Allocate a table for the result
|
||||||
|
Table t(SqVM(), 2);
|
||||||
|
// Insert the resulted value
|
||||||
|
t.SetValue(_SC("value"), r);
|
||||||
|
// Insert the end of the value
|
||||||
|
t.SetValue(_SC("end"), static_cast< intptr_t >(end - s.mPtr));
|
||||||
|
// Return the table containing the results
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD static Table SqStringToULL(SQInteger base, StackStrF & s)
|
||||||
|
{
|
||||||
|
SQChar * end = nullptr;
|
||||||
|
// Attempt to process the specified string
|
||||||
|
const auto r = std::strtoull(s.mPtr, &end, ConvTo< int >::From((base)));
|
||||||
|
// Allocate a table for the result
|
||||||
|
Table t(SqVM(), 2);
|
||||||
|
// Insert the resulted value
|
||||||
|
t.SetValue(_SC("value"), r);
|
||||||
|
// Insert the end of the value
|
||||||
|
t.SetValue(_SC("end"), static_cast< intptr_t >(end - s.mPtr));
|
||||||
|
// Return the table containing the results
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD static Table SqStringToF(StackStrF & s)
|
||||||
|
{
|
||||||
|
SQChar * end = nullptr;
|
||||||
|
// Attempt to process the specified string
|
||||||
|
const auto r = std::strtof(s.mPtr, &end);
|
||||||
|
// Allocate a table for the result
|
||||||
|
Table t(SqVM(), 2);
|
||||||
|
// Insert the resulted value
|
||||||
|
t.SetValue(_SC("value"), r);
|
||||||
|
// Insert the end of the value
|
||||||
|
t.SetValue(_SC("end"), static_cast< intptr_t >(end - s.mPtr));
|
||||||
|
// Return the table containing the results
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD static Table SqStringToD(StackStrF & s)
|
||||||
|
{
|
||||||
|
SQChar * end = nullptr;
|
||||||
|
// Attempt to process the specified string
|
||||||
|
const auto r = std::strtod(s.mPtr, &end);
|
||||||
|
// Allocate a table for the result
|
||||||
|
Table t(SqVM(), 2);
|
||||||
|
// Insert the resulted value
|
||||||
|
t.SetValue(_SC("value"), r);
|
||||||
|
// Insert the end of the value
|
||||||
|
t.SetValue(_SC("end"), static_cast< intptr_t >(end - s.mPtr));
|
||||||
|
// Return the table containing the results
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_String(HSQUIRRELVM vm)
|
void Register_String(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
@@ -938,8 +1096,15 @@ void Register_String(HSQUIRRELVM vm)
|
|||||||
.FmtFunc(_SC("Lowercase"), &SqToLowercase)
|
.FmtFunc(_SC("Lowercase"), &SqToLowercase)
|
||||||
.FmtFunc(_SC("Uppercase"), &SqToUppercase)
|
.FmtFunc(_SC("Uppercase"), &SqToUppercase)
|
||||||
.FmtFunc(_SC("JustAlnum"), &SqJustAlphaNum)
|
.FmtFunc(_SC("JustAlnum"), &SqJustAlphaNum)
|
||||||
.FmtFunc(_SC("ToInt"), &SqStrToI)
|
.FmtFunc(_SC("ToInt"), &SqStringToInt)
|
||||||
.FmtFunc(_SC("ToFloat"), &SqStrToF)
|
.FmtFunc(_SC("ToFloat"), &SqStringToFloat)
|
||||||
|
.FmtFunc(_SC("ToL"), &SqStringToL)
|
||||||
|
.FmtFunc(_SC("ToLL"), &SqStringToLL)
|
||||||
|
.FmtFunc(_SC("ToUL"), &SqStringToUL)
|
||||||
|
.FmtFunc(_SC("ToULL"), &SqStringToULL)
|
||||||
|
.FmtFunc(_SC("ToF"), &SqStringToF)
|
||||||
|
.FmtFunc(_SC("ToD"), &SqStringToD)
|
||||||
|
.FmtFunc(_SC("Levenshtein"), &SqLevenshtein)
|
||||||
.FmtFunc(_SC("AreAllSpace"), &SqAllChars< std::isspace >)
|
.FmtFunc(_SC("AreAllSpace"), &SqAllChars< std::isspace >)
|
||||||
.FmtFunc(_SC("AreAllPrint"), &SqAllChars< std::isprint >)
|
.FmtFunc(_SC("AreAllPrint"), &SqAllChars< std::isprint >)
|
||||||
.FmtFunc(_SC("AreAllCntrl"), &SqAllChars< std::iscntrl >)
|
.FmtFunc(_SC("AreAllCntrl"), &SqAllChars< std::iscntrl >)
|
||||||
|
|||||||
@@ -0,0 +1,135 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/UTF8.hpp"
|
||||||
|
#include "Core/Buffer.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD static SQInteger SqStrLenUTF8(StackStrF & str)
|
||||||
|
{
|
||||||
|
// Is the string empty or invalid?
|
||||||
|
if (str.mLen <= 0)
|
||||||
|
{
|
||||||
|
return str.mLen; // Return same value
|
||||||
|
}
|
||||||
|
// Perform the request and return the result
|
||||||
|
return static_cast< SQInteger >(utf8len(str.mPtr));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD static SQInteger SqStrNLenUTF8(SQInteger len, StackStrF & str)
|
||||||
|
{
|
||||||
|
// Is the string empty or invalid?
|
||||||
|
if (str.mLen <= 0)
|
||||||
|
{
|
||||||
|
return str.mLen; // Return same value
|
||||||
|
}
|
||||||
|
// Is the specified length within bounds?
|
||||||
|
else if (std::abs(len) > str.mLen)
|
||||||
|
{
|
||||||
|
STHROWF("Specified range {} is out of bounds {}", len, str.mLen);
|
||||||
|
}
|
||||||
|
// Should we compute the length backwards?
|
||||||
|
else if (len < 0)
|
||||||
|
{
|
||||||
|
len = str.mLen - std::abs(len); // Subtract from actual length
|
||||||
|
}
|
||||||
|
// Did we trim all of it?
|
||||||
|
else if (len == 0)
|
||||||
|
{
|
||||||
|
return 0; // Nothing to search for
|
||||||
|
}
|
||||||
|
// Perform the request and return the result
|
||||||
|
return static_cast< SQInteger >(utf8nlen(str.mPtr, static_cast< size_t >(len)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD static SQInteger SqStrChrUTF8(SQInteger chr, StackStrF & str)
|
||||||
|
{
|
||||||
|
// Is the string empty or invalid?
|
||||||
|
if (str.mLen <= 0)
|
||||||
|
{
|
||||||
|
return -1; // Let the user know that we could not search for this
|
||||||
|
}
|
||||||
|
// Look for the specified character in the string
|
||||||
|
auto * p = reinterpret_cast< const SQChar * >(utf8chr(str.mPtr, static_cast< utf8_int32_t >(chr)));
|
||||||
|
// Return the distance in bytes where the character was found
|
||||||
|
return static_cast< SQInteger >(p - str.mPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD static SQInteger SqCaseCmpUTF8(StackStrF & a, StackStrF & b)
|
||||||
|
{
|
||||||
|
// Is the left string invalid?
|
||||||
|
if (a.mLen < 0)
|
||||||
|
{
|
||||||
|
STHROWF("Invalid string on the left {}", a.mLen);
|
||||||
|
}
|
||||||
|
// Is the right string invalid?
|
||||||
|
else if (b.mLen < 0)
|
||||||
|
{
|
||||||
|
STHROWF("Invalid string on the right {}", b.mLen);
|
||||||
|
}
|
||||||
|
// Perform the request and return the result
|
||||||
|
return utf8casecmp(a.mPtr, b.mPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD static SQInteger SqNCaseCmpUTF8(StackStrF & a, StackStrF & b)
|
||||||
|
{
|
||||||
|
// Is the left string invalid?
|
||||||
|
if (a.mLen < 0)
|
||||||
|
{
|
||||||
|
STHROWF("Invalid string on the left {}", a.mLen);
|
||||||
|
}
|
||||||
|
// Is the right string invalid?
|
||||||
|
else if (b.mLen < 0)
|
||||||
|
{
|
||||||
|
STHROWF("Invalid string on the right {}", b.mLen);
|
||||||
|
}
|
||||||
|
// See if we can decide this based on length differences
|
||||||
|
else if (a.mLen < b.mLen)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if (a.mLen > b.mLen)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
// Perform the request and return the result
|
||||||
|
return utf8ncasecmp(a.mPtr, b.mPtr, static_cast< size_t >(a.mLen));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_NODISCARD static SQInteger SqCaseStrUTF8(StackStrF & hs, StackStrF & nd)
|
||||||
|
{
|
||||||
|
// Is the haystack or needle string empty or invalid?
|
||||||
|
if (hs.mLen <= 0 || nd.mLen <= 0)
|
||||||
|
{
|
||||||
|
return -1; // Let the user know that we could not search for this
|
||||||
|
}
|
||||||
|
// Look for the specified needle string in the haystack string
|
||||||
|
auto * p = reinterpret_cast< const SQChar * >(utf8casestr(hs.mPtr, nd.mPtr));
|
||||||
|
// Return the distance in bytes where the string was found
|
||||||
|
return static_cast< SQInteger >(p - hs.mPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================================================================================================
|
||||||
|
void Register_UTF8(HSQUIRRELVM vm)
|
||||||
|
{
|
||||||
|
Table ns(vm);
|
||||||
|
|
||||||
|
ns
|
||||||
|
.FmtFunc(_SC("StrLen"), &SqStrLenUTF8)
|
||||||
|
.FmtFunc(_SC("StrNLen"), &SqStrNLenUTF8)
|
||||||
|
.FmtFunc(_SC("StrChr"), &SqStrChrUTF8)
|
||||||
|
.FmtFunc(_SC("CaseCmp"), &SqCaseCmpUTF8)
|
||||||
|
.FmtFunc(_SC("NCaseCmp"), &SqNCaseCmpUTF8)
|
||||||
|
.FmtFunc(_SC("CaseStr"), &SqCaseStrUTF8)
|
||||||
|
;
|
||||||
|
|
||||||
|
RootTable(vm).Bind(_SC("SqUTF8"), ns);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Core/Common.hpp"
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <utf8.h>
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
@@ -40,8 +40,9 @@ using Poco::StreamCopier;
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Helper utility that can be used to announce the server to a master-list.
|
* Helper utility that can be used to announce the server to a master-list.
|
||||||
*/
|
*/
|
||||||
struct SqAnnouncer : SqChainedInstances< SqAnnouncer >
|
struct SqAnnouncer : public SqChainedInstances< SqAnnouncer >
|
||||||
{
|
{
|
||||||
|
using Base = SqChainedInstances< SqAnnouncer >;
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Announcer status.
|
* Announcer status.
|
||||||
*/
|
*/
|
||||||
@@ -114,7 +115,7 @@ struct SqAnnouncer : SqChainedInstances< SqAnnouncer >
|
|||||||
* Explicit constructor.
|
* Explicit constructor.
|
||||||
*/
|
*/
|
||||||
SqAnnouncer(SQInteger interval, StackStrF & uri)
|
SqAnnouncer(SQInteger interval, StackStrF & uri)
|
||||||
: mRun(false), mLog(true)
|
: Base(), mRun(false), mLog(true)
|
||||||
, mCount(0)
|
, mCount(0)
|
||||||
, mSuccess(0)
|
, mSuccess(0)
|
||||||
, mFailures(0)
|
, mFailures(0)
|
||||||
@@ -125,8 +126,7 @@ struct SqAnnouncer : SqChainedInstances< SqAnnouncer >
|
|||||||
, mURI(uri.mPtr)
|
, mURI(uri.mPtr)
|
||||||
, mMtx(), mThread()
|
, mMtx(), mThread()
|
||||||
{
|
{
|
||||||
// Remember this instance
|
ChainInstance(); // Remember this instance
|
||||||
ChainInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -164,6 +164,22 @@ template < class T > struct SqVector
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor from container.
|
||||||
|
*/
|
||||||
|
explicit SqVector(const Container & v)
|
||||||
|
: mC(Poco::makeShared< Container >(v))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor from container.
|
||||||
|
*/
|
||||||
|
explicit SqVector(Container && v) noexcept
|
||||||
|
: mC(Poco::makeShared< Container >(std::move(v)))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Move constructor.
|
* Move constructor.
|
||||||
*/
|
*/
|
||||||
|
|||||||
+32
-32
@@ -108,99 +108,99 @@ bool XmlNode::RemoveAttrInst(const XmlAttribute & attr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlAttribute::AsLong(const SLongInt & def) const
|
SQInteger XmlAttribute::AsLong(SQInteger def) const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< SLongInt >{}, SqVM(), m_Attr.as_llong(def.GetNum()));
|
return m_Attr.as_llong(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlAttribute::AsUlong(const ULongInt & def) const
|
SQInteger XmlAttribute::AsUlong(SQInteger def) const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< ULongInt >{}, SqVM(), m_Attr.as_ullong(def.GetNum()));
|
return static_cast< SQInteger >(m_Attr.as_ullong(static_cast< uint64_t >(def)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool XmlAttribute::ApplyLong(const SLongInt & value)
|
bool XmlAttribute::ApplyLong(SQInteger value)
|
||||||
{
|
{
|
||||||
return m_Attr.set_value(value.GetNum());
|
return m_Attr.set_value(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool XmlAttribute::ApplyUlong(const ULongInt & value)
|
bool XmlAttribute::ApplyUlong(SQInteger value)
|
||||||
{
|
{
|
||||||
return m_Attr.set_value(value.GetNum());
|
return m_Attr.set_value(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlAttribute::GetLong() const
|
SQInteger XmlAttribute::GetLong() const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< SLongInt >{}, SqVM(), m_Attr.as_llong());
|
return m_Attr.as_llong();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void XmlAttribute::SetLong(const SLongInt & value)
|
void XmlAttribute::SetLong(SQInteger value)
|
||||||
{
|
{
|
||||||
m_Attr = value.GetNum();
|
m_Attr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlAttribute::GetUlong() const
|
SQInteger XmlAttribute::GetUlong() const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< ULongInt >{}, SqVM(), m_Attr.as_ullong());
|
return static_cast< SQInteger >(m_Attr.as_ullong());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void XmlAttribute::SetUlong(const ULongInt & value)
|
void XmlAttribute::SetUlong(SQInteger value)
|
||||||
{
|
{
|
||||||
m_Attr = value.GetNum();
|
m_Attr = static_cast< uint64_t >(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlText::AsLong(const SLongInt & def) const
|
SQInteger XmlText::AsLong(SQInteger def) const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< SLongInt >{}, SqVM(), m_Text.as_llong(def.GetNum()));
|
return m_Text.as_llong(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlText::AsUlong(const ULongInt & def) const
|
SQInteger XmlText::AsUlong(SQInteger def) const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< ULongInt >{}, SqVM(), m_Text.as_ullong(def.GetNum()));
|
return static_cast< SQInteger >(m_Text.as_ullong(static_cast< uint64_t >(def)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool XmlText::ApplyLong(const SLongInt & value)
|
bool XmlText::ApplyLong(SQInteger value)
|
||||||
{
|
{
|
||||||
return m_Text.set(value.GetNum());
|
return m_Text.set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool XmlText::ApplyUlong(const ULongInt & value)
|
bool XmlText::ApplyUlong(SQInteger value)
|
||||||
{
|
{
|
||||||
return m_Text.set(value.GetNum());
|
return m_Text.set(static_cast< uint64_t >(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlText::GetLong() const
|
SQInteger XmlText::GetLong() const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< SLongInt >{}, SqVM(), m_Text.as_llong());
|
return m_Text.as_llong();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void XmlText::SetLong(const SLongInt & value)
|
void XmlText::SetLong(SQInteger value)
|
||||||
{
|
{
|
||||||
m_Text = value.GetNum();
|
m_Text = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlText::GetUlong() const
|
SQInteger XmlText::GetUlong() const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< SLongInt >{}, SqVM(), m_Text.as_ullong());
|
return static_cast< SQInteger >(m_Text.as_ullong());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void XmlText::SetUlong(const ULongInt & value)
|
void XmlText::SetUlong(SQInteger value)
|
||||||
{
|
{
|
||||||
m_Text = value.GetNum();
|
m_Text = static_cast< uint64_t >(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
+16
-19
@@ -3,9 +3,6 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Core/Utility.hpp"
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -1420,12 +1417,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a long integer or the specified default value if empty.
|
* Retrieve the value as a long integer or the specified default value if empty.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj AsLong(const SLongInt & def) const;
|
SQMOD_NODISCARD SQInteger AsLong(SQInteger def) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a unsigned long integer or the specified default value if empty.
|
* Retrieve the value as a unsigned long integer or the specified default value if empty.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj AsUlong(const ULongInt & def) const;
|
SQMOD_NODISCARD SQInteger AsUlong(SQInteger def) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a boolean or the specified default value if empty.
|
* Retrieve the value as a boolean or the specified default value if empty.
|
||||||
@@ -1478,12 +1475,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a long integer.
|
* Modify the value as a long integer.
|
||||||
*/
|
*/
|
||||||
bool ApplyLong(const SLongInt & value);
|
bool ApplyLong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a unsigned long integer.
|
* Modify the value as a unsigned long integer.
|
||||||
*/
|
*/
|
||||||
bool ApplyUlong(const ULongInt & value);
|
bool ApplyUlong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a boolean.
|
* Modify the value as a boolean.
|
||||||
@@ -1576,22 +1573,22 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a long integer.
|
* Retrieve the value as a long integer.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj GetLong() const;
|
SQMOD_NODISCARD SQInteger GetLong() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a long integer.
|
* Modify the value as a long integer.
|
||||||
*/
|
*/
|
||||||
void SetLong(const SLongInt & value);
|
void SetLong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a unsigned long integer.
|
* Retrieve the value as a unsigned long integer.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj GetUlong() const;
|
SQMOD_NODISCARD SQInteger GetUlong() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a unsigned long integer.
|
* Modify the value as a unsigned long integer.
|
||||||
*/
|
*/
|
||||||
void SetUlong(const ULongInt & value);
|
void SetUlong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a boolean.
|
* Retrieve the value as a boolean.
|
||||||
@@ -1772,12 +1769,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a long integer or the specified default value if empty.
|
* Retrieve the value as a long integer or the specified default value if empty.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj AsLong(const SLongInt & def) const;
|
SQMOD_NODISCARD SQInteger AsLong(SQInteger def) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a unsigned long integer or the specified default value if empty.
|
* Retrieve the value as a unsigned long integer or the specified default value if empty.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj AsUlong(const ULongInt & def) const;
|
SQMOD_NODISCARD SQInteger AsUlong(SQInteger def) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a boolean or the specified default value if empty.
|
* Retrieve the value as a boolean or the specified default value if empty.
|
||||||
@@ -1830,12 +1827,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a long integer.
|
* Modify the value as a long integer.
|
||||||
*/
|
*/
|
||||||
bool ApplyLong(const SLongInt & value);
|
bool ApplyLong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a unsigned long integer.
|
* Modify the value as a unsigned long integer.
|
||||||
*/
|
*/
|
||||||
bool ApplyUlong(const ULongInt & value);
|
bool ApplyUlong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a boolean.
|
* Modify the value as a boolean.
|
||||||
@@ -1928,22 +1925,22 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a long integer.
|
* Retrieve the value as a long integer.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj GetLong() const;
|
SQMOD_NODISCARD SQInteger GetLong() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a long integer.
|
* Modify the value as a long integer.
|
||||||
*/
|
*/
|
||||||
void SetLong(const SLongInt & value);
|
void SetLong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a unsigned long integer.
|
* Retrieve the value as a unsigned long integer.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj GetUlong() const;
|
SQMOD_NODISCARD SQInteger GetUlong() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a unsigned long integer.
|
* Modify the value as a unsigned long integer.
|
||||||
*/
|
*/
|
||||||
void SetUlong(const ULongInt & value);
|
void SetUlong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a boolean.
|
* Retrieve the value as a boolean.
|
||||||
|
|||||||
@@ -18,10 +18,15 @@ static bool g_Reload = false;
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
//extern void InitExports();
|
//extern void InitExports();
|
||||||
|
extern void InitializeNet();
|
||||||
extern void InitializePocoDataConnectors();
|
extern void InitializePocoDataConnectors();
|
||||||
extern void ProcessRoutines();
|
extern void ProcessRoutines();
|
||||||
extern void ProcessTasks();
|
extern void ProcessTasks();
|
||||||
extern void ProcessThreads();
|
extern void ProcessThreads();
|
||||||
|
extern void ProcessNet();
|
||||||
|
#ifdef VCMP_ENABLE_DISCORD
|
||||||
|
extern void ProcessDPP();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Will the scripts be reloaded at the end of the current event?
|
* Will the scripts be reloaded at the end of the current event?
|
||||||
@@ -168,6 +173,12 @@ static void OnServerFrame(float elapsed_time)
|
|||||||
ProcessTasks();
|
ProcessTasks();
|
||||||
// Process threads
|
// Process threads
|
||||||
ProcessThreads();
|
ProcessThreads();
|
||||||
|
// Process network
|
||||||
|
ProcessNet();
|
||||||
|
// Process DPP
|
||||||
|
#ifdef VCMP_ENABLE_DISCORD
|
||||||
|
ProcessDPP();
|
||||||
|
#endif
|
||||||
// Process log messages from other threads
|
// Process log messages from other threads
|
||||||
Logger::Get().ProcessQueue();
|
Logger::Get().ProcessQueue();
|
||||||
// See if a reload was requested
|
// See if a reload was requested
|
||||||
@@ -991,6 +1002,7 @@ SQMOD_API_EXPORT unsigned int VcmpPluginInit(PluginFuncs * funcs, PluginCallback
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// External plugs that need to happen (once) before initialization
|
// External plugs that need to happen (once) before initialization
|
||||||
|
InitializeNet();
|
||||||
InitializePocoDataConnectors();
|
InitializePocoDataConnectors();
|
||||||
// Proceed with plug-in initialization
|
// Proceed with plug-in initialization
|
||||||
if (!Core::Get().Initialize())
|
if (!Core::Get().Initialize())
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "Base/Color3.hpp"
|
#include "Base/Color3.hpp"
|
||||||
#include "Base/Vector2.hpp"
|
#include "Base/Vector2.hpp"
|
||||||
#include "Entity/Player.hpp"
|
#include "Entity/Player.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
@@ -173,9 +172,9 @@ void SendPluginCommand(uint32_t identifier, StackStrF & payload)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
const ULongInt & GetTime()
|
SQInteger GetTime()
|
||||||
{
|
{
|
||||||
return GetULongInt(_Func->GetTime());
|
return static_cast< SQInteger >(_Func->GetTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@@ -218,7 +217,7 @@ const SQChar * GetPluginAuthor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t GetPluginID()
|
uint32_t GetPluginID()
|
||||||
{
|
{
|
||||||
return _Info->pluginId;
|
return _Info->pluginId;
|
||||||
}
|
}
|
||||||
@@ -242,7 +241,7 @@ uint32_t GetServerFlags()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t GetMaxPlayers()
|
uint32_t GetMaxPlayers()
|
||||||
{
|
{
|
||||||
return _Func->GetMaxPlayers();
|
return _Func->GetMaxPlayers();
|
||||||
}
|
}
|
||||||
@@ -468,7 +467,7 @@ int32_t GetTimeRate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SetTimeRate(uint32_t rate)
|
void SetTimeRate(int32_t rate)
|
||||||
{
|
{
|
||||||
_Func->SetTimeRate(rate);
|
_Func->SetTimeRate(rate);
|
||||||
}
|
}
|
||||||
@@ -763,7 +762,7 @@ void SetSpawnCameraPositionEx(float x, float y, float z)
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SetSpawnCameraLookAtEx(float x, float y, float z)
|
void SetSpawnCameraLookAtEx(float x, float y, float z)
|
||||||
{
|
{
|
||||||
_Func->SetSpawnPlayerPosition(x, y, z);
|
_Func->SetSpawnCameraLookAt(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ void SendPluginCommand(uint32_t identifier, StackStrF & payload);
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the server time.
|
* Retrieve the server time.
|
||||||
*/
|
*/
|
||||||
const ULongInt & GetTime();
|
SQInteger GetTime();
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Send a log message to the server.
|
* Send a log message to the server.
|
||||||
@@ -84,7 +84,7 @@ SQMOD_NODISCARD const SQChar * GetPluginAuthor();
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the id of the host Squirrel plug-in.
|
* Retrieve the id of the host Squirrel plug-in.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD int32_t GetPluginID();
|
SQMOD_NODISCARD uint32_t GetPluginID();
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the port onto which the server was binded.
|
* Retrieve the port onto which the server was binded.
|
||||||
@@ -99,7 +99,7 @@ SQMOD_NODISCARD uint32_t GetServerFlags();
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the maximum number of clients allowed on the server.
|
* Retrieve the maximum number of clients allowed on the server.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD int32_t GetMaxPlayers();
|
SQMOD_NODISCARD uint32_t GetMaxPlayers();
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Modify the maximum number of clients allowed on the server.
|
* Modify the maximum number of clients allowed on the server.
|
||||||
@@ -205,7 +205,7 @@ SQMOD_NODISCARD int32_t GetTimeRate();
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Modify the current time-rate.
|
* Modify the current time-rate.
|
||||||
*/
|
*/
|
||||||
void SetTimeRate(uint32_t rate);
|
void SetTimeRate(int32_t rate);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the game hour.
|
* Retrieve the game hour.
|
||||||
|
|||||||
@@ -673,7 +673,7 @@ struct LgPlayer
|
|||||||
void SetCanAttack(bool toggle) const { _Func->SetPlayerOption(GetIdentifier(), vcmpPlayerOptionCanAttack, static_cast< uint8_t >(toggle)); }
|
void SetCanAttack(bool toggle) const { _Func->SetPlayerOption(GetIdentifier(), vcmpPlayerOptionCanAttack, static_cast< uint8_t >(toggle)); }
|
||||||
void SetWeaponSlot(int slot) const { Get().SetWeaponSlot(slot); }
|
void SetWeaponSlot(int slot) const { Get().SetWeaponSlot(slot); }
|
||||||
void ShowMarkers(bool toggle) const { _Func->SetPlayerOption(GetIdentifier(), vcmpPlayerOptionShowMarkers, static_cast< uint8_t >(toggle)); }
|
void ShowMarkers(bool toggle) const { _Func->SetPlayerOption(GetIdentifier(), vcmpPlayerOptionShowMarkers, static_cast< uint8_t >(toggle)); }
|
||||||
void SetSpectateTarget(LgPlayer & player) const { Get().SetSpectator(player.Get()); }
|
void SetSpectateTarget(LightObj & player) const { player.IsNull() ? Get().SetSpectatorID(-1) : Get().SetSpectator(player.CastI< LgPlayer >()->Get()); }
|
||||||
void SetMarkerVisible(bool toggle) const { _Func->SetPlayerOption(GetIdentifier(), vcmpPlayerOptionHasMarker, static_cast< uint8_t >(toggle)); }
|
void SetMarkerVisible(bool toggle) const { _Func->SetPlayerOption(GetIdentifier(), vcmpPlayerOptionHasMarker, static_cast< uint8_t >(toggle)); }
|
||||||
void SetCanUseColors(bool toggle) const { _Func->SetPlayerOption(GetIdentifier(), vcmpPlayerOptionChatTagsEnabled, static_cast< uint8_t >(toggle)); }
|
void SetCanUseColors(bool toggle) const { _Func->SetPlayerOption(GetIdentifier(), vcmpPlayerOptionChatTagsEnabled, static_cast< uint8_t >(toggle)); }
|
||||||
void SetDrunkStatus(bool toggle) const { _Func->SetPlayerOption(GetIdentifier(), vcmpPlayerOptionDrunkEffects, static_cast< uint8_t >(toggle)); }
|
void SetDrunkStatus(bool toggle) const { _Func->SetPlayerOption(GetIdentifier(), vcmpPlayerOptionDrunkEffects, static_cast< uint8_t >(toggle)); }
|
||||||
@@ -1380,7 +1380,7 @@ static bool LgUsingClasses()
|
|||||||
{ return _Func->GetServerOption(vcmpServerOptionUseClasses) >= 1; }
|
{ return _Func->GetServerOption(vcmpServerOptionUseClasses) >= 1; }
|
||||||
static void LgAddClass(int team, const Color3 & col, int skin, const Vector3 & pos, float angle,
|
static void LgAddClass(int team, const Color3 & col, int skin, const Vector3 & pos, float angle,
|
||||||
int wep1, int ammo1, int wep2, int ammo2, int wep3, int ammo3)
|
int wep1, int ammo1, int wep2, int ammo2, int wep3, int ammo3)
|
||||||
{ _Func->AddPlayerClass(team, col.GetRGBA(), skin, pos.x, pos.y, pos.z, angle, wep1, ammo1, wep2, ammo2, wep3, ammo3); }
|
{ _Func->AddPlayerClass(team, col.GetRGB(), skin, pos.x, pos.y, pos.z, angle, wep1, ammo1, wep2, ammo2, wep3, ammo3); }
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static void LgSetSpawnPlayerPos(const Vector3 & pos) { _Func->SetSpawnPlayerPosition(pos.x, pos.y, pos.z); }
|
static void LgSetSpawnPlayerPos(const Vector3 & pos) { _Func->SetSpawnPlayerPosition(pos.x, pos.y, pos.z); }
|
||||||
static void LgSetSpawnCameraPos(const Vector3 & pos) { _Func->SetSpawnCameraPosition(pos.x, pos.y, pos.z); }
|
static void LgSetSpawnCameraPos(const Vector3 & pos) { _Func->SetSpawnCameraPosition(pos.x, pos.y, pos.z); }
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include "Base/Color3.hpp"
|
#include "Base/Color3.hpp"
|
||||||
#include "Base/Vector2.hpp"
|
#include "Base/Vector2.hpp"
|
||||||
#include "Entity/Player.hpp"
|
#include "Entity/Player.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Misc/Functions.hpp"
|
#include "Misc/Functions.hpp"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#ifdef SQMOD_POCO_HAS_MYSQL
|
#ifdef SQMOD_POCO_HAS_MYSQL
|
||||||
#include <Poco/Data/MySQL/Connector.h>
|
#include <Poco/Data/MySQL/Connector.h>
|
||||||
// Used for string escape functionality
|
// Used for string escape functionality
|
||||||
#include <mysql.h>
|
#include <mysql/mysql.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef SQMOD_POCO_HAS_POSTGRESQL
|
#ifdef SQMOD_POCO_HAS_POSTGRESQL
|
||||||
#include <Poco/Data/PostgreSQL/Connector.h>
|
#include <Poco/Data/PostgreSQL/Connector.h>
|
||||||
|
|||||||
+86
-4
@@ -1,18 +1,100 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "PocoLib/Net.hpp"
|
#include "PocoLib/Net.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <sqratConst.h>
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqWsClient, _SC("SqWsClient"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void TerminatePocoNet()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_POCO_Net(HSQUIRRELVM vm, Table &)
|
void Register_POCO_Net(HSQUIRRELVM vm, Table & ns)
|
||||||
{
|
{
|
||||||
//Table ns(vm);
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("WsClient"),
|
||||||
//RootTable(vm).Bind(_SC("SqNet"), ns);
|
Class< WsClient, NoCopy< WsClient > >(ns.GetVM(), SqWsClient::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor< StackStrF &, uint16_t, StackStrF & >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqWsClient::Fn)
|
||||||
|
// Member Variables
|
||||||
|
.Var(_SC("Flags"), &WsClient::mFlags)
|
||||||
|
.Var(_SC("State"), &WsClient::mState)
|
||||||
|
// Properties
|
||||||
|
.Prop(_SC("Tag"), &WsClient::GetTag, &WsClient::SetTag)
|
||||||
|
.Prop(_SC("Data"), &WsClient::GetData, &WsClient::SetData)
|
||||||
|
.Prop(_SC("MaxPayloadSize"), &WsClient::GetMaxPayloadSize, &WsClient::SetMaxPayloadSize)
|
||||||
|
// Member Methods
|
||||||
|
.FmtFunc(_SC("SetTag"), &WsClient::ApplyTag)
|
||||||
|
.FmtFunc(_SC("SetData"), &WsClient::ApplyData)
|
||||||
|
.Func(_SC("Shutdown"), &WsClient::Shutdown)
|
||||||
|
.FmtFunc(_SC("ShutdownWith"), &WsClient::ShutdownWith)
|
||||||
|
.Func(_SC("SendFrame"), &WsClient::SendFrame)
|
||||||
|
.FmtFunc(_SC("SendStringFrame"), &WsClient::SendStringFrame)
|
||||||
|
.Func(_SC("RecvFrame"), &WsClient::RecvFrame)
|
||||||
|
.Func(_SC("RecvStringFrame"), &WsClient::RecvStringFrame)
|
||||||
|
.CbFunc(_SC("RecvFrameIn"), &WsClient::RecvFrameIn)
|
||||||
|
.CbFunc(_SC("RecvStringFrameIn"), &WsClient::RecvStringFrameIn)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ConstTable(vm).Enum(_SC("SqWsFrameFlags"), Enumeration(vm)
|
||||||
|
.Const(_SC("FIN"), static_cast< SQInteger >(Poco::Net::WebSocket::FRAME_FLAG_FIN))
|
||||||
|
.Const(_SC("RSV1"), static_cast< SQInteger >(Poco::Net::WebSocket::FRAME_FLAG_RSV1))
|
||||||
|
.Const(_SC("RSV2"), static_cast< SQInteger >(Poco::Net::WebSocket::FRAME_FLAG_RSV2))
|
||||||
|
.Const(_SC("RSV3"), static_cast< SQInteger >(Poco::Net::WebSocket::FRAME_FLAG_RSV3))
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ConstTable(vm).Enum(_SC("SqWsFrameOpcodes"), Enumeration(vm)
|
||||||
|
.Const(_SC("CONT"), static_cast< SQInteger >(Poco::Net::WebSocket::FRAME_OP_CONT))
|
||||||
|
.Const(_SC("TEXT"), static_cast< SQInteger >(Poco::Net::WebSocket::FRAME_OP_TEXT))
|
||||||
|
.Const(_SC("BINARY"), static_cast< SQInteger >(Poco::Net::WebSocket::FRAME_OP_BINARY))
|
||||||
|
.Const(_SC("CLOSE"), static_cast< SQInteger >(Poco::Net::WebSocket::FRAME_OP_CLOSE))
|
||||||
|
.Const(_SC("PING"), static_cast< SQInteger >(Poco::Net::WebSocket::FRAME_OP_PING))
|
||||||
|
.Const(_SC("PONG"), static_cast< SQInteger >(Poco::Net::WebSocket::FRAME_OP_PONG))
|
||||||
|
.Const(_SC("BITMASK"), static_cast< SQInteger >(Poco::Net::WebSocket::FRAME_OP_BITMASK))
|
||||||
|
.Const(_SC("SETRAW"), static_cast< SQInteger >(Poco::Net::WebSocket::FRAME_OP_SETRAW))
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ConstTable(vm).Enum(_SC("SqWsSendFlags"), Enumeration(vm)
|
||||||
|
.Const(_SC("Text"), static_cast< SQInteger >(Poco::Net::WebSocket::FRAME_TEXT))
|
||||||
|
.Const(_SC("Binary"), static_cast< SQInteger >(Poco::Net::WebSocket::FRAME_BINARY))
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ConstTable(vm).Enum(_SC("SqWsStatusCodes"), Enumeration(vm)
|
||||||
|
.Const(_SC("NormalClose"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_NORMAL_CLOSE))
|
||||||
|
.Const(_SC("EndpointGoingAway"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_ENDPOINT_GOING_AWAY))
|
||||||
|
.Const(_SC("ProtocolError"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_PROTOCOL_ERROR))
|
||||||
|
.Const(_SC("PayloadNotAcceptable"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_PAYLOAD_NOT_ACCEPTABLE))
|
||||||
|
.Const(_SC("Reserved"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_RESERVED))
|
||||||
|
.Const(_SC("ReservedNoStatusCode"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_RESERVED_NO_STATUS_CODE))
|
||||||
|
.Const(_SC("ReservedAbnormalClose"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_RESERVED_ABNORMAL_CLOSE))
|
||||||
|
.Const(_SC("MalformedPayload"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_MALFORMED_PAYLOAD))
|
||||||
|
.Const(_SC("PolicyViolation"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_POLICY_VIOLATION))
|
||||||
|
.Const(_SC("PayloadTooBig"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_PAYLOAD_TOO_BIG))
|
||||||
|
.Const(_SC("ExtensionRequired"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_EXTENSION_REQUIRED))
|
||||||
|
.Const(_SC("UnexpectedCondition"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_UNEXPECTED_CONDITION))
|
||||||
|
.Const(_SC("ReservedTlsFailure"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_RESERVED_TLS_FAILURE))
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ConstTable(vm).Enum(_SC("SqWsErrorCodes"), Enumeration(vm)
|
||||||
|
.Const(_SC("NoHandshake"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_ERR_NO_HANDSHAKE))
|
||||||
|
.Const(_SC("HandshakeNoVersion"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_ERR_HANDSHAKE_NO_VERSION))
|
||||||
|
.Const(_SC("HandshakeUnsupportedVersion"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_ERR_HANDSHAKE_UNSUPPORTED_VERSION))
|
||||||
|
.Const(_SC("HandshakeNoKey"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_ERR_HANDSHAKE_NO_KEY))
|
||||||
|
.Const(_SC("HandshakeAccept"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_ERR_HANDSHAKE_ACCEPT))
|
||||||
|
.Const(_SC("Unauthorized"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_ERR_UNAUTHORIZED))
|
||||||
|
.Const(_SC("PayloadTooBig"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_ERR_PAYLOAD_TOO_BIG))
|
||||||
|
.Const(_SC("IncompleteFrame"), static_cast< SQInteger >(Poco::Net::WebSocket::WS_ERR_INCOMPLETE_FRAME))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
|||||||
@@ -2,10 +2,291 @@
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Core/Common.hpp"
|
#include "Core/Common.hpp"
|
||||||
|
#include "Library/IO/Buffer.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <vector>
|
||||||
|
#include <utility>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <Poco/Thread.h>
|
||||||
|
#include <Poco/AutoPtr.h>
|
||||||
|
#include <Poco/Runnable.h>
|
||||||
|
#include <Poco/Observer.h>
|
||||||
|
#include <Poco/NObserver.h>
|
||||||
|
#include <Poco/Net/HTTPRequest.h>
|
||||||
|
#include <Poco/Net/HTTPResponse.h>
|
||||||
|
#include <Poco/Net/HTTPMessage.h>
|
||||||
|
#include <Poco/Net/HTTPClientSession.h>
|
||||||
|
#include <Poco/Net/SocketAcceptor.h>
|
||||||
|
#include <Poco/Net/SocketReactor.h>
|
||||||
|
#include <Poco/Net/WebSocket.h>
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Implements a WebSocket according to the WebSocket protocol specification in RFC 6455.
|
||||||
|
*/
|
||||||
|
struct WsClient
|
||||||
|
{
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Flags received in the last call to Recv[String]Frame() (will be overwritten on next call).
|
||||||
|
*/
|
||||||
|
int mFlags{0};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Return value from the last call to Recv[String]Frame() (will be overwritten on next call).
|
||||||
|
* A return value of 0, with flags also 0, means that the peer has shut down or closed the connection.
|
||||||
|
* A return value of 0, with non-zero flags, indicates an reception of an empty frame (e.g., in case of a PING).
|
||||||
|
*/
|
||||||
|
int mState{0};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Receiving buffer instance.
|
||||||
|
*/
|
||||||
|
Poco::Buffer< char > mBuffer{0};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* User tag associated with this instance.
|
||||||
|
*/
|
||||||
|
String mTag{};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* User data associated with this instance.
|
||||||
|
*/
|
||||||
|
LightObj mData{};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* HTTP client session instance.
|
||||||
|
*/
|
||||||
|
Poco::Net::HTTPClientSession mClient;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* HTTP request instance.
|
||||||
|
*/
|
||||||
|
Poco::Net::HTTPRequest mRequest;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* HTTP response instance.
|
||||||
|
*/
|
||||||
|
Poco::Net::HTTPResponse mResponse;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* WebSocket instance.
|
||||||
|
*/
|
||||||
|
Poco::Net::WebSocket mSocket;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Base constructor.
|
||||||
|
*/
|
||||||
|
WsClient(StackStrF & host, uint16_t port, StackStrF & uri)
|
||||||
|
: mFlags(0), mState(0), mBuffer(0), mTag(), mData()
|
||||||
|
, mClient(host.ToStr(), port)
|
||||||
|
, mRequest(Poco::Net::HTTPRequest::HTTP_GET, uri.ToStr(), Poco::Net::HTTPRequest::HTTP_1_1)
|
||||||
|
, mResponse()
|
||||||
|
, mSocket(mClient, mRequest, mResponse)
|
||||||
|
{
|
||||||
|
mSocket.setBlocking(false); // Disable blocking
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated user tag.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const String & GetTag() const
|
||||||
|
{
|
||||||
|
return mTag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated user tag.
|
||||||
|
*/
|
||||||
|
void SetTag(StackStrF & tag)
|
||||||
|
{
|
||||||
|
if (tag.mLen > 0)
|
||||||
|
{
|
||||||
|
mTag.assign(tag.mPtr, static_cast< size_t >(tag.mLen));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mTag.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated user tag.
|
||||||
|
*/
|
||||||
|
WsClient & ApplyTag(StackStrF & tag)
|
||||||
|
{
|
||||||
|
SetTag(tag);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the associated user data.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj & GetData()
|
||||||
|
{
|
||||||
|
return mData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated user data.
|
||||||
|
*/
|
||||||
|
void SetData(LightObj & data)
|
||||||
|
{
|
||||||
|
mData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the associated user data.
|
||||||
|
*/
|
||||||
|
WsClient & ApplyData(LightObj & data)
|
||||||
|
{
|
||||||
|
mData = data;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Sends a Close control frame to the server end of the connection to initiate an orderly shutdown of the connection.
|
||||||
|
*/
|
||||||
|
void Shutdown()
|
||||||
|
{
|
||||||
|
mSocket.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Sends a Close control frame to the server end of the connection to initiate an orderly shutdown of the connection.
|
||||||
|
*/
|
||||||
|
void ShutdownWith(SQInteger code, StackStrF & msg)
|
||||||
|
{
|
||||||
|
mSocket.shutdown(static_cast< uint16_t >(code), msg.ToStr());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Sends the contents of the given buffer through the socket as a single frame.
|
||||||
|
* Returns the number of bytes sent, which may be less than the number of bytes specified.
|
||||||
|
*/
|
||||||
|
SQInteger SendFrame(SqBuffer & buf, SQInteger flags)
|
||||||
|
{
|
||||||
|
return mSocket.sendFrame(buf.Valid().Data(), static_cast< int >(buf.Valid().Position()), static_cast< int >(flags));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Sends the contents of the given string through the socket as a single frame.
|
||||||
|
* Returns the number of bytes sent, which may be less than the number of bytes specified.
|
||||||
|
*/
|
||||||
|
SQInteger SendStringFrame(SQInteger flags, StackStrF & str)
|
||||||
|
{
|
||||||
|
return mSocket.sendFrame(str.mPtr, static_cast< int >(str.mLen), static_cast< int >(flags));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Receives a frame from the socket and return it as a buffer.
|
||||||
|
* The frame's payload size must not exceed the maximum payload size set with SetMaxPayloadSize().
|
||||||
|
*/
|
||||||
|
LightObj RecvFrame()
|
||||||
|
{
|
||||||
|
// Attempt to receive data
|
||||||
|
try {
|
||||||
|
mState = mSocket.receiveFrame(mBuffer, mFlags);
|
||||||
|
} catch (const Poco::TimeoutException &) {
|
||||||
|
mState = mFlags = 0; // Make sure these don't indicate otherwise
|
||||||
|
return LightObj{}; // We handle timeout so we can be non blocking
|
||||||
|
}
|
||||||
|
// If something was returned
|
||||||
|
if (mState != 0)
|
||||||
|
{
|
||||||
|
// Fetch buffer information
|
||||||
|
const auto cap = static_cast< Buffer::SzType >(mBuffer.capacityBytes());
|
||||||
|
const auto len = static_cast< Buffer::SzType >(mBuffer.sizeBytes());
|
||||||
|
// Steal buffer memory
|
||||||
|
Buffer::Pointer ptr = mBuffer.steal();
|
||||||
|
// Construct our buffer
|
||||||
|
Buffer b(ptr, cap, len, Buffer::OwnIt{});
|
||||||
|
// Transform it into a script object and return it
|
||||||
|
return LightObj(SqTypeIdentity< SqBuffer >{}, SqVM(), std::move(b));
|
||||||
|
}
|
||||||
|
// Default to null
|
||||||
|
return LightObj{};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Receives a frame from the socket and return it as a string.
|
||||||
|
* The frame's payload size must not exceed the maximum payload size set with SetMaxPayloadSize().
|
||||||
|
*/
|
||||||
|
LightObj RecvStringFrame()
|
||||||
|
{
|
||||||
|
// Attempt to receive data
|
||||||
|
try {
|
||||||
|
mState = mSocket.receiveFrame(mBuffer, mFlags);
|
||||||
|
} catch (const Poco::TimeoutException &) {
|
||||||
|
mState = mFlags = 0; // Make sure these don't indicate otherwise
|
||||||
|
return LightObj{}; // We handle timeout so we can be non blocking
|
||||||
|
}
|
||||||
|
// If something was returned
|
||||||
|
if (mState != 0)
|
||||||
|
{
|
||||||
|
// Create a string with buffer contents
|
||||||
|
LightObj obj(const_cast< const SQChar * >(mBuffer.begin()), static_cast< SQInteger >(mBuffer.sizeBytes()), SqVM());
|
||||||
|
// Discard buffer contents for next request
|
||||||
|
mBuffer.resize(0);
|
||||||
|
// Return the string object
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
// Default to null
|
||||||
|
return LightObj{};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Receives a frame from the socket and return it as a buffer. Only invokes callback if response is valid.
|
||||||
|
* The frame's payload size must not exceed the maximum payload size set with SetMaxPayloadSize().
|
||||||
|
*/
|
||||||
|
SQInteger RecvFrameIn(Function & cb)
|
||||||
|
{
|
||||||
|
auto obj = RecvFrame();
|
||||||
|
// Only invoke the callback if we have a valid response
|
||||||
|
if (mState != 0 || mFlags != 0)
|
||||||
|
{
|
||||||
|
cb(obj, mState, mFlags);
|
||||||
|
}
|
||||||
|
// Return result
|
||||||
|
return mState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Receives a frame from the socket and return it as a string. Only invokes callback if response is valid.
|
||||||
|
* The frame's payload size must not exceed the maximum payload size set with SetMaxPayloadSize().
|
||||||
|
*/
|
||||||
|
SQInteger RecvStringFrameIn(Function & cb)
|
||||||
|
{
|
||||||
|
auto obj = RecvStringFrame();
|
||||||
|
// Only invoke the callback if we have data response
|
||||||
|
if (mState != 0 || mFlags != 0)
|
||||||
|
{
|
||||||
|
cb(obj, mState, mFlags);
|
||||||
|
}
|
||||||
|
// Return result
|
||||||
|
return mState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Sets the maximum payload size for RecvFrame(). The default is std::numeric_limits<int>::max().
|
||||||
|
*/
|
||||||
|
WsClient & SetMaxPayloadSize(SQInteger size)
|
||||||
|
{
|
||||||
|
mSocket.setMaxPayloadSize(static_cast< int >(size));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Returns the maximum payload size for RecvFrame(). The default is std::numeric_limits<int>::max().
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetMaxPayloadSize() const
|
||||||
|
{
|
||||||
|
return mSocket.getMaxPayloadSize();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
|||||||
@@ -7,12 +7,10 @@ namespace SqMod {
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
extern void Register_POCO_Crypto(HSQUIRRELVM vm, Table & ns);
|
extern void Register_POCO_Crypto(HSQUIRRELVM vm, Table & ns);
|
||||||
extern void Register_POCO_Data(HSQUIRRELVM vm, Table & ns);
|
extern void Register_POCO_Data(HSQUIRRELVM vm, Table & ns);
|
||||||
extern void Register_POCO_JSON(HSQUIRRELVM vm, Table & ns);
|
|
||||||
extern void Register_POCO_Net(HSQUIRRELVM vm, Table & ns);
|
extern void Register_POCO_Net(HSQUIRRELVM vm, Table & ns);
|
||||||
extern void Register_POCO_RegEx(HSQUIRRELVM vm, Table & ns);
|
extern void Register_POCO_RegEx(HSQUIRRELVM vm, Table & ns);
|
||||||
extern void Register_POCO_Time(HSQUIRRELVM vm, Table & ns);
|
extern void Register_POCO_Time(HSQUIRRELVM vm, Table & ns);
|
||||||
extern void Register_POCO_Util(HSQUIRRELVM vm, Table & ns);
|
extern void Register_POCO_Util(HSQUIRRELVM vm, Table & ns);
|
||||||
extern void Register_POCO_XML(HSQUIRRELVM vm, Table & ns);
|
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_POCO(HSQUIRRELVM vm)
|
void Register_POCO(HSQUIRRELVM vm)
|
||||||
@@ -21,12 +19,10 @@ void Register_POCO(HSQUIRRELVM vm)
|
|||||||
|
|
||||||
Register_POCO_Crypto(vm, ns);
|
Register_POCO_Crypto(vm, ns);
|
||||||
Register_POCO_Data(vm, ns);
|
Register_POCO_Data(vm, ns);
|
||||||
Register_POCO_JSON(vm, ns);
|
|
||||||
Register_POCO_Net(vm, ns);
|
Register_POCO_Net(vm, ns);
|
||||||
Register_POCO_RegEx(vm, ns);
|
Register_POCO_RegEx(vm, ns);
|
||||||
Register_POCO_Time(vm, ns);
|
Register_POCO_Time(vm, ns);
|
||||||
Register_POCO_Util(vm, ns);
|
Register_POCO_Util(vm, ns);
|
||||||
Register_POCO_XML(vm, ns);
|
|
||||||
|
|
||||||
RootTable(vm).Bind(_SC("Sq"), ns);
|
RootTable(vm).Bind(_SC("Sq"), ns);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,12 +37,17 @@ extern void Register_Format(HSQUIRRELVM vm);
|
|||||||
extern void Register_IO(HSQUIRRELVM vm);
|
extern void Register_IO(HSQUIRRELVM vm);
|
||||||
extern void Register_JSON(HSQUIRRELVM vm);
|
extern void Register_JSON(HSQUIRRELVM vm);
|
||||||
extern void Register_MMDB(HSQUIRRELVM vm);
|
extern void Register_MMDB(HSQUIRRELVM vm);
|
||||||
|
extern void Register_Net(HSQUIRRELVM vm);
|
||||||
extern void Register_Numeric(HSQUIRRELVM vm);
|
extern void Register_Numeric(HSQUIRRELVM vm);
|
||||||
extern void Register_String(HSQUIRRELVM vm);
|
extern void Register_String(HSQUIRRELVM vm);
|
||||||
extern void Register_System(HSQUIRRELVM vm);
|
extern void Register_System(HSQUIRRELVM vm);
|
||||||
|
extern void Register_UTF8(HSQUIRRELVM vm);
|
||||||
extern void Register_Utils(HSQUIRRELVM vm);
|
extern void Register_Utils(HSQUIRRELVM vm);
|
||||||
extern void Register_XML(HSQUIRRELVM vm);
|
extern void Register_XML(HSQUIRRELVM vm);
|
||||||
extern void Register_ZMQ(HSQUIRRELVM vm);
|
extern void Register_ZMQ(HSQUIRRELVM vm);
|
||||||
|
#ifdef VCMP_ENABLE_DISCORD
|
||||||
|
extern void Register_DPP(HSQUIRRELVM vm);
|
||||||
|
#endif
|
||||||
#ifdef SQMOD_POCO_HAS_SQLITE
|
#ifdef SQMOD_POCO_HAS_SQLITE
|
||||||
extern void Register_SQLite(HSQUIRRELVM vm);
|
extern void Register_SQLite(HSQUIRRELVM vm);
|
||||||
#endif
|
#endif
|
||||||
@@ -102,12 +107,17 @@ bool RegisterAPI(HSQUIRRELVM vm)
|
|||||||
Register_IO(vm);
|
Register_IO(vm);
|
||||||
Register_JSON(vm);
|
Register_JSON(vm);
|
||||||
Register_MMDB(vm);
|
Register_MMDB(vm);
|
||||||
|
Register_Net(vm);
|
||||||
Register_Numeric(vm);
|
Register_Numeric(vm);
|
||||||
Register_String(vm);
|
Register_String(vm);
|
||||||
Register_System(vm);
|
Register_System(vm);
|
||||||
|
Register_UTF8(vm);
|
||||||
Register_Utils(vm);
|
Register_Utils(vm);
|
||||||
Register_XML(vm);
|
Register_XML(vm);
|
||||||
Register_ZMQ(vm);
|
Register_ZMQ(vm);
|
||||||
|
#ifdef VCMP_ENABLE_DISCORD
|
||||||
|
Register_DPP(vm);
|
||||||
|
#endif
|
||||||
#ifdef SQMOD_POCO_HAS_SQLITE
|
#ifdef SQMOD_POCO_HAS_SQLITE
|
||||||
Register_SQLite(vm);
|
Register_SQLite(vm);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+56
-16
@@ -32,20 +32,21 @@
|
|||||||
* OS IDENTIFICATION
|
* OS IDENTIFICATION
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__WIN32__) || defined(_WIN) || defined(__WIN__)
|
#if defined(_WIN64) || defined(__WIN64__)
|
||||||
// Windows x32
|
|
||||||
#define SQMOD_OS_WINDOWS
|
|
||||||
#define SQMOD_OS_32
|
|
||||||
#define SQMOD_OS_WINDOWS32
|
|
||||||
#define SQMOD_ARCHITECTURE 1
|
|
||||||
#define SQMOD_PLATFORM 1
|
|
||||||
#elif defined(_WIN64) || defined(__WIN64__)
|
|
||||||
// Windows x64
|
// Windows x64
|
||||||
#define SQMOD_OS_WINDOWS
|
#define SQMOD_OS_WINDOWS
|
||||||
#define SQMOD_OS_64
|
#define SQMOD_OS_64
|
||||||
#define SQMOD_OS_WINDOWS64
|
#define SQMOD_OS_WINDOWS64
|
||||||
#define SQMOD_ARCHITECTURE 2
|
#define SQMOD_ARCHITECTURE 2
|
||||||
#define SQMOD_PLATFORM 1
|
#define SQMOD_PLATFORM 1
|
||||||
|
#elif defined(_WIN32) || defined(__WIN32__) || defined(_WIN) || defined(__WIN__)
|
||||||
|
#error Squirrel Module does not support 32-bit Windows anymore
|
||||||
|
// Windows x32
|
||||||
|
//#define SQMOD_OS_WINDOWS
|
||||||
|
//#define SQMOD_OS_32
|
||||||
|
//#define SQMOD_OS_WINDOWS32
|
||||||
|
//#define SQMOD_ARCHITECTURE 1
|
||||||
|
//#define SQMOD_PLATFORM 1
|
||||||
#elif defined(linux) || defined(__linux) || defined(__linux__)
|
#elif defined(linux) || defined(__linux) || defined(__linux__)
|
||||||
// Linux
|
// Linux
|
||||||
#define SQMOD_OS_LINUX
|
#define SQMOD_OS_LINUX
|
||||||
@@ -53,13 +54,14 @@
|
|||||||
#if __x86_64__ || __ppc64__
|
#if __x86_64__ || __ppc64__
|
||||||
#define SQMOD_OS_64
|
#define SQMOD_OS_64
|
||||||
#define SQMOD_OS_LINUX64
|
#define SQMOD_OS_LINUX64
|
||||||
#define SQMOD_ARCHITECTURE 2
|
#define SQMOD_ARCHITECTURE 2
|
||||||
#define SQMOD_PLATFORM 2
|
#define SQMOD_PLATFORM 2
|
||||||
#else
|
#else
|
||||||
#define SQMOD_OS_32
|
#error Squirrel Module does not support 32-bit Linux anymore
|
||||||
#define SQMOD_OS_LINUX32
|
//#define SQMOD_OS_32
|
||||||
#define SQMOD_ARCHITECTURE 1
|
//#define SQMOD_OS_LINUX32
|
||||||
#define SQMOD_PLATFORM 2
|
//#define SQMOD_ARCHITECTURE 1
|
||||||
|
//#define SQMOD_PLATFORM 2
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
@@ -106,7 +108,7 @@
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* API EXPORT.
|
* API EXPORT.
|
||||||
*/
|
*/
|
||||||
#if defined(_MSC_VER)
|
#if defined(SQMOD_OS_WINDOWS)
|
||||||
#define SQMOD_API_EXPORT extern "C" __declspec(dllexport)
|
#define SQMOD_API_EXPORT extern "C" __declspec(dllexport)
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#define SQMOD_API_EXPORT extern "C"
|
#define SQMOD_API_EXPORT extern "C"
|
||||||
@@ -423,7 +425,7 @@ enum EntityType
|
|||||||
#define SQMOD_CONCAT(a,b) SQMOD_CONCAT_(a,b)
|
#define SQMOD_CONCAT(a,b) SQMOD_CONCAT_(a,b)
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#ifdef _WIN32
|
#ifdef SQMOD_OS_WINDOWS
|
||||||
#define sqmod_stricmp(a,b) stricmp(a,b)
|
#define sqmod_stricmp(a,b) stricmp(a,b)
|
||||||
#define sqmod_strnicmp(a,b,n) strnicmp(a,b,n)
|
#define sqmod_strnicmp(a,b,n) strnicmp(a,b,n)
|
||||||
#else
|
#else
|
||||||
@@ -506,6 +508,44 @@ enum EntityType
|
|||||||
#define SQMOD_NODISCARD
|
#define SQMOD_NODISCARD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* FLOAT SELECTION
|
||||||
|
*/
|
||||||
|
#ifdef SQUSEDOUBLE
|
||||||
|
#define SQMOD_DOUBLE_ONLY(X) X
|
||||||
|
#define SQMOD_EXCEPT_DOUBLE(X)
|
||||||
|
#define SQMOD_FLOAT_ONLY(X)
|
||||||
|
#define SQMOD_EXCEPT_FLOAT(X) X
|
||||||
|
#else
|
||||||
|
#define SQMOD_DOUBLE_ONLY(X) X
|
||||||
|
#define SQMOD_EXCEPT_DOUBLE(X)
|
||||||
|
#define SQMOD_FLOAT_ONLY(X)
|
||||||
|
#define SQMOD_EXCEPT_FLOAT(X) X
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SQMOD_DOUBLE_OR(D, F) SQMOD_DOUBLE_ONLY(D) SQMOD_EXCEPT_DOUBLE(F)
|
||||||
|
#define SQMOD_FLOAT_OR(F, D) SQMOD_FLOAT_ONLY(F) SQMOD_EXCEPT_FLOAT(D)
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* DEBUG SELECTION
|
||||||
|
*/
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#define SQMOD_DEBUG_ONLY(X) X
|
||||||
|
#define SQMOD_EXCEPT_DEBUG(X)
|
||||||
|
#define SQMOD_RELEASE_ONLY(X)
|
||||||
|
#define SQMOD_EXCEPT_RELEASE(X) X
|
||||||
|
#define SQMOD_RTFMT(X) fmt::runtime(X)
|
||||||
|
#else
|
||||||
|
#define SQMOD_DEBUG_ONLY(X)
|
||||||
|
#define SQMOD_EXCEPT_DEBUG(X) X
|
||||||
|
#define SQMOD_RELEASE_ONLY(X) X
|
||||||
|
#define SQMOD_EXCEPT_RELEASE(X)
|
||||||
|
#define SQMOD_RTFMT(X) X
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SQMOD_DEBUG_OR(D, R) SQMOD_DEBUG_ONLY(D) SQMOD_EXCEPT_DEBUG(R)
|
||||||
|
#define SQMOD_RELEASE_OR(R, D) SQMOD_RELEASE_ONLY(R) SQMOD_EXCEPT_RELEASE(D)
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* LOGGING LOCATION
|
* LOGGING LOCATION
|
||||||
*/
|
*/
|
||||||
@@ -525,7 +565,7 @@ enum EntityType
|
|||||||
|
|
||||||
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
#if defined(_DEBUG) || defined(SQMOD_EXCEPTLOC)
|
||||||
#define STHROW(e, m, ...) throw e(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ", ##__VA_ARGS__)
|
#define STHROW(e, m, ...) throw e(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ", ##__VA_ARGS__)
|
||||||
#define STHROWF(m, ...) SqThrowF(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ", ##__VA_ARGS__)
|
#define STHROWF(m, ...) SqThrowF(fmt::runtime(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] "), ##__VA_ARGS__)
|
||||||
#define STHROWLASTF(m, ...) SqThrowLastF(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ", ##__VA_ARGS__)
|
#define STHROWLASTF(m, ...) SqThrowLastF(m " =>[" __FILE__ ":" SQMOD_STRINGIZEWRAP(__LINE__) "] ", ##__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define STHROW(e, m, ...) throw e(m, ##__VA_ARGS__)
|
#define STHROW(e, m, ...) throw e(m, ##__VA_ARGS__)
|
||||||
|
|||||||
@@ -612,6 +612,30 @@ public:
|
|||||||
//sq_pop(vm,1); // pop array
|
//sq_pop(vm,1); // pop array
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Appends values to the end of the Array
|
||||||
|
///
|
||||||
|
/// \param vec Vector to be appended to the array
|
||||||
|
///
|
||||||
|
/// \tparam T Type of value (usually doesnt need to be defined explicitly)
|
||||||
|
///
|
||||||
|
/// \return The Array itself so the call can be chained
|
||||||
|
///
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template<class T>
|
||||||
|
ArrayBase& AppendFromVector(const std::vector< T > & vec) {
|
||||||
|
HSQUIRRELVM vm = SqVM();
|
||||||
|
const StackGuard sg(vm);
|
||||||
|
sq_pushobject(vm, GetObj());
|
||||||
|
for (const auto & v : vec)
|
||||||
|
{
|
||||||
|
Var< const T & >::push(vm, v);
|
||||||
|
sq_arrayappend(vm, -2);
|
||||||
|
}
|
||||||
|
//sq_pop(vm,1); // pop array
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -750,7 +750,7 @@ protected:
|
|||||||
// add the set table (static)
|
// add the set table (static)
|
||||||
HSQOBJECT& setTable = cd->setTable;
|
HSQOBJECT& setTable = cd->setTable;
|
||||||
sq_resetobject(&setTable);
|
sq_resetobject(&setTable);
|
||||||
sq_pushstring(vm, _SC("__setTable"), -1);
|
sq_pushstring(vm, _SC("@set"), -1);
|
||||||
sq_newtable(vm);
|
sq_newtable(vm);
|
||||||
sq_getstackobj(vm, -1, &setTable);
|
sq_getstackobj(vm, -1, &setTable);
|
||||||
sq_addref(vm, &setTable);
|
sq_addref(vm, &setTable);
|
||||||
@@ -759,7 +759,7 @@ protected:
|
|||||||
// add the get table (static)
|
// add the get table (static)
|
||||||
HSQOBJECT& getTable = cd->getTable;
|
HSQOBJECT& getTable = cd->getTable;
|
||||||
sq_resetobject(&getTable);
|
sq_resetobject(&getTable);
|
||||||
sq_pushstring(vm, _SC("__getTable"), -1);
|
sq_pushstring(vm, _SC("@get"), -1);
|
||||||
sq_newtable(vm);
|
sq_newtable(vm);
|
||||||
sq_getstackobj(vm, -1, &getTable);
|
sq_getstackobj(vm, -1, &getTable);
|
||||||
sq_addref(vm, &getTable);
|
sq_addref(vm, &getTable);
|
||||||
@@ -1033,7 +1033,7 @@ protected:
|
|||||||
HSQOBJECT& setTable = cd->setTable;
|
HSQOBJECT& setTable = cd->setTable;
|
||||||
sq_resetobject(&setTable);
|
sq_resetobject(&setTable);
|
||||||
sq_pushobject(vm, bd->setTable);
|
sq_pushobject(vm, bd->setTable);
|
||||||
sq_pushstring(vm, _SC("__setTable"), -1);
|
sq_pushstring(vm, _SC("@set"), -1);
|
||||||
sq_clone(vm, -2);
|
sq_clone(vm, -2);
|
||||||
sq_remove(vm, -3);
|
sq_remove(vm, -3);
|
||||||
sq_getstackobj(vm, -1, &setTable);
|
sq_getstackobj(vm, -1, &setTable);
|
||||||
@@ -1044,7 +1044,7 @@ protected:
|
|||||||
HSQOBJECT& getTable = cd->getTable;
|
HSQOBJECT& getTable = cd->getTable;
|
||||||
sq_resetobject(&getTable);
|
sq_resetobject(&getTable);
|
||||||
sq_pushobject(vm, bd->getTable);
|
sq_pushobject(vm, bd->getTable);
|
||||||
sq_pushstring(vm, _SC("__getTable"), -1);
|
sq_pushstring(vm, _SC("@get"), -1);
|
||||||
sq_clone(vm, -2);
|
sq_clone(vm, -2);
|
||||||
sq_remove(vm, -3);
|
sq_remove(vm, -3);
|
||||||
sq_getstackobj(vm, -1, &getTable);
|
sq_getstackobj(vm, -1, &getTable);
|
||||||
|
|||||||
@@ -31,6 +31,9 @@
|
|||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include "sqratAllocator.h"
|
#include "sqratAllocator.h"
|
||||||
#include "sqratTypes.h"
|
#include "sqratTypes.h"
|
||||||
#include "sqratOverloadMethods.h"
|
#include "sqratOverloadMethods.h"
|
||||||
@@ -669,6 +672,128 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Inserts associative container values into the managed object.
|
||||||
|
///
|
||||||
|
/// \param map Associative container to be inserted to the table
|
||||||
|
///
|
||||||
|
/// \tparam K Type of key (usually doesnt need to be defined explicitly)
|
||||||
|
///
|
||||||
|
/// \tparam V Type of value (usually doesnt need to be defined explicitly)
|
||||||
|
///
|
||||||
|
/// \return Result value returned by squirrel.
|
||||||
|
///
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template<class K, class V>
|
||||||
|
SQRESULT InsertFromMap(const std::unordered_map< K, V > & map, bool staticVar = false) {
|
||||||
|
HSQUIRRELVM vm = SqVM();
|
||||||
|
const StackGuard sg(vm);
|
||||||
|
sq_pushobject(vm, GetObj());
|
||||||
|
for (const auto & p : map)
|
||||||
|
{
|
||||||
|
Var< const K & >::push(vm, p.first);
|
||||||
|
Var< const V & >::push(vm, p.second);
|
||||||
|
const auto r = sq_newslot(vm, -3, staticVar);
|
||||||
|
if (SQ_FAILED(r)) return r;
|
||||||
|
}
|
||||||
|
//sq_pop(vm, 1); // pop object
|
||||||
|
return SQ_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Inserts associative container values into the managed object.
|
||||||
|
///
|
||||||
|
/// \param map Associative container to be inserted to the table
|
||||||
|
///
|
||||||
|
/// \tparam K Type of key (usually doesnt need to be defined explicitly)
|
||||||
|
///
|
||||||
|
/// \tparam V Type of value (usually doesnt need to be defined explicitly)
|
||||||
|
///
|
||||||
|
/// \return Result value returned by squirrel.
|
||||||
|
///
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template<class K, class V>
|
||||||
|
SQRESULT InsertFromMap(const std::map< K, V > & map, bool staticVar = false) {
|
||||||
|
HSQUIRRELVM vm = SqVM();
|
||||||
|
const StackGuard sg(vm);
|
||||||
|
sq_pushobject(vm, GetObj());
|
||||||
|
for (const auto & p : map)
|
||||||
|
{
|
||||||
|
Var< const K & >::push(vm, p.first);
|
||||||
|
Var< const V & >::push(vm, p.second);
|
||||||
|
const auto r = sq_newslot(vm, -3, staticVar);
|
||||||
|
if (SQ_FAILED(r)) return r;
|
||||||
|
}
|
||||||
|
//sq_pop(vm, 1); // pop object
|
||||||
|
return SQ_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Inserts associative container values into the managed object.
|
||||||
|
///
|
||||||
|
/// \param map Associative container to be inserted to the table
|
||||||
|
///
|
||||||
|
/// \param func Functor that is continuously called to push values on the stack
|
||||||
|
///
|
||||||
|
/// \tparam K Type of key (usually doesnt need to be defined explicitly)
|
||||||
|
///
|
||||||
|
/// \tparam V Type of value (usually doesnt need to be defined explicitly)
|
||||||
|
///
|
||||||
|
/// \tparam F Type of functor (usually doesnt need to be defined explicitly)
|
||||||
|
///
|
||||||
|
/// \return Result value returned by squirrel.
|
||||||
|
///
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template<class K, class V, class F>
|
||||||
|
SQRESULT InsertFromMapWith(const std::unordered_map< K, V > & map, F func, bool staticVar = false) {
|
||||||
|
HSQUIRRELVM vm = SqVM();
|
||||||
|
const StackGuard sg(vm);
|
||||||
|
sq_pushobject(vm, GetObj());
|
||||||
|
SQRESULT r = SQ_OK;
|
||||||
|
for (const auto & p : map)
|
||||||
|
{
|
||||||
|
r = func(vm, p.first, p.second);
|
||||||
|
if (SQ_FAILED(r)) break;
|
||||||
|
r = sq_newslot(vm, -3, staticVar);
|
||||||
|
if (SQ_FAILED(r)) return r;
|
||||||
|
}
|
||||||
|
//sq_pop(vm, 1); // pop object
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Inserts associative container values into the managed object.
|
||||||
|
///
|
||||||
|
/// \param map Associative container to be inserted to the table
|
||||||
|
///
|
||||||
|
/// \param func Functor that is continuously called to push values on the stack
|
||||||
|
///
|
||||||
|
/// \tparam K Type of key (usually doesnt need to be defined explicitly)
|
||||||
|
///
|
||||||
|
/// \tparam V Type of value (usually doesnt need to be defined explicitly)
|
||||||
|
///
|
||||||
|
/// \tparam F Type of functor (usually doesnt need to be defined explicitly)
|
||||||
|
///
|
||||||
|
/// \return Result value returned by squirrel.
|
||||||
|
///
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template<class K, class V, class F>
|
||||||
|
SQRESULT InsertFromMapWith(const std::map< K, V > & map, F func, bool staticVar = false) {
|
||||||
|
HSQUIRRELVM vm = SqVM();
|
||||||
|
const StackGuard sg(vm);
|
||||||
|
sq_pushobject(vm, GetObj());
|
||||||
|
SQRESULT r = SQ_OK;
|
||||||
|
for (const auto & p : map)
|
||||||
|
{
|
||||||
|
r = func(vm, p.first, p.second);
|
||||||
|
if (SQ_FAILED(r)) break;
|
||||||
|
r = sq_newslot(vm, -3, staticVar);
|
||||||
|
if (SQ_FAILED(r)) return r;
|
||||||
|
}
|
||||||
|
//sq_pop(vm, 1); // pop object
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// @cond DEV
|
/// @cond DEV
|
||||||
|
|
||||||
|
|||||||
+36
-36
@@ -181,7 +181,7 @@ private:
|
|||||||
|
|
||||||
template <class T2, bool b>
|
template <class T2, bool b>
|
||||||
struct pushAsInt {
|
struct pushAsInt {
|
||||||
void push(HSQUIRRELVM vm, const T2& /*value*/) {
|
inline void push(HSQUIRRELVM vm, const T2& /*value*/) noexcept {
|
||||||
assert(false); // fails because called before a Sqrat::Class for T exists and T is not convertible to SQInteger
|
assert(false); // fails because called before a Sqrat::Class for T exists and T is not convertible to SQInteger
|
||||||
sq_pushnull(vm);
|
sq_pushnull(vm);
|
||||||
}
|
}
|
||||||
@@ -189,8 +189,8 @@ private:
|
|||||||
|
|
||||||
template <class T2>
|
template <class T2>
|
||||||
struct pushAsInt<T2, true> {
|
struct pushAsInt<T2, true> {
|
||||||
void push(HSQUIRRELVM vm, const T2& value) {
|
inline void push(HSQUIRRELVM vm, const T2& val) noexcept {
|
||||||
sq_pushinteger(vm, static_cast<SQInteger>(value));
|
sq_pushinteger(vm, static_cast<SQInteger>(val));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -237,7 +237,7 @@ private:
|
|||||||
|
|
||||||
template <class T2, bool b>
|
template <class T2, bool b>
|
||||||
struct pushAsInt {
|
struct pushAsInt {
|
||||||
void push(HSQUIRRELVM vm, const T2& /*value*/) {
|
inline void push(HSQUIRRELVM vm, const T2& /*value*/) noexcept {
|
||||||
assert(false); // fails because called before a Sqrat::Class for T exists and T is not convertible to SQInteger
|
assert(false); // fails because called before a Sqrat::Class for T exists and T is not convertible to SQInteger
|
||||||
sq_pushnull(vm);
|
sq_pushnull(vm);
|
||||||
}
|
}
|
||||||
@@ -245,8 +245,8 @@ private:
|
|||||||
|
|
||||||
template <class T2>
|
template <class T2>
|
||||||
struct pushAsInt<T2, true> {
|
struct pushAsInt<T2, true> {
|
||||||
void push(HSQUIRRELVM vm, const T2& value) {
|
inline void push(HSQUIRRELVM vm, const T2& val) noexcept {
|
||||||
sq_pushinteger(vm, static_cast<SQInteger>(value));
|
sq_pushinteger(vm, static_cast<SQInteger>(val));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -483,7 +483,7 @@ struct Var<SharedPtr<T> > {
|
|||||||
Var(HSQUIRRELVM vm, SQInteger idx) { \
|
Var(HSQUIRRELVM vm, SQInteger idx) { \
|
||||||
value = popAsInt<type, true>(vm, idx).value; \
|
value = popAsInt<type, true>(vm, idx).value; \
|
||||||
} \
|
} \
|
||||||
static void push(HSQUIRRELVM vm, const type& value) { \
|
inline static void push(HSQUIRRELVM vm, const type& value) noexcept { \
|
||||||
sq_pushinteger(vm, static_cast<SQInteger>(value)); \
|
sq_pushinteger(vm, static_cast<SQInteger>(value)); \
|
||||||
} \
|
} \
|
||||||
};\
|
};\
|
||||||
@@ -494,7 +494,7 @@ struct Var<SharedPtr<T> > {
|
|||||||
Var(HSQUIRRELVM vm, SQInteger idx) { \
|
Var(HSQUIRRELVM vm, SQInteger idx) { \
|
||||||
value = popAsInt<type, true>(vm, idx).value; \
|
value = popAsInt<type, true>(vm, idx).value; \
|
||||||
} \
|
} \
|
||||||
static void push(HSQUIRRELVM vm, const type& value) { \
|
inline static void push(HSQUIRRELVM vm, const type& value) noexcept { \
|
||||||
sq_pushinteger(vm, static_cast<SQInteger>(value)); \
|
sq_pushinteger(vm, static_cast<SQInteger>(value)); \
|
||||||
} \
|
} \
|
||||||
};
|
};
|
||||||
@@ -525,7 +525,7 @@ SCRAT_INTEGER(signed __int64)
|
|||||||
Var(HSQUIRRELVM vm, SQInteger idx) { \
|
Var(HSQUIRRELVM vm, SQInteger idx) { \
|
||||||
value = popAsFloat<type>(vm, idx).value; \
|
value = popAsFloat<type>(vm, idx).value; \
|
||||||
} \
|
} \
|
||||||
static void push(HSQUIRRELVM vm, const type& value) { \
|
inline static void push(HSQUIRRELVM vm, const type& value) noexcept { \
|
||||||
sq_pushfloat(vm, static_cast<SQFloat>(value)); \
|
sq_pushfloat(vm, static_cast<SQFloat>(value)); \
|
||||||
} \
|
} \
|
||||||
}; \
|
}; \
|
||||||
@@ -536,7 +536,7 @@ SCRAT_INTEGER(signed __int64)
|
|||||||
Var(HSQUIRRELVM vm, SQInteger idx) { \
|
Var(HSQUIRRELVM vm, SQInteger idx) { \
|
||||||
value = popAsFloat<type>(vm, idx).value; \
|
value = popAsFloat<type>(vm, idx).value; \
|
||||||
} \
|
} \
|
||||||
static void push(HSQUIRRELVM vm, const type& value) { \
|
inline static void push(HSQUIRRELVM vm, const type& value) noexcept { \
|
||||||
sq_pushfloat(vm, static_cast<SQFloat>(value)); \
|
sq_pushfloat(vm, static_cast<SQFloat>(value)); \
|
||||||
} \
|
} \
|
||||||
};
|
};
|
||||||
@@ -572,7 +572,7 @@ struct Var<bool> {
|
|||||||
/// \param value Value to push on to the VM's stack
|
/// \param value Value to push on to the VM's stack
|
||||||
///
|
///
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
static void push(HSQUIRRELVM vm, const bool& value) {
|
inline static void push(HSQUIRRELVM vm, const bool& value) noexcept {
|
||||||
sq_pushbool(vm, static_cast<SQBool>(value));
|
sq_pushbool(vm, static_cast<SQBool>(value));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -605,7 +605,7 @@ struct Var<const bool&> {
|
|||||||
/// \param value Value to push on to the VM's stack
|
/// \param value Value to push on to the VM's stack
|
||||||
///
|
///
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
static void push(HSQUIRRELVM vm, const bool& value) {
|
inline static void push(HSQUIRRELVM vm, const bool& value) noexcept {
|
||||||
sq_pushbool(vm, static_cast<SQBool>(value));
|
sq_pushbool(vm, static_cast<SQBool>(value));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -615,7 +615,7 @@ struct Var<const bool&> {
|
|||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
template<>
|
template<>
|
||||||
struct Var<std::nullptr_t> {
|
struct Var<std::nullptr_t> {
|
||||||
std::nullptr_t value; ///< The actual value of get operations
|
std::nullptr_t value{}; ///< The actual value of get operations
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// Attempts to get the value off the stack at idx as a nullptr_t
|
/// Attempts to get the value off the stack at idx as a nullptr_t
|
||||||
@@ -632,7 +632,7 @@ struct Var<std::nullptr_t> {
|
|||||||
/// \param vm Target VM
|
/// \param vm Target VM
|
||||||
///
|
///
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
static void push(HSQUIRRELVM vm) {
|
inline static void push(HSQUIRRELVM vm) noexcept {
|
||||||
sq_pushnull(vm);
|
sq_pushnull(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -643,7 +643,7 @@ struct Var<std::nullptr_t> {
|
|||||||
/// \param value Value to push on to the VM's stack
|
/// \param value Value to push on to the VM's stack
|
||||||
///
|
///
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
static void push(HSQUIRRELVM vm, std::nullptr_t SQ_UNUSED_ARG(value)) {
|
inline static void push(HSQUIRRELVM vm, std::nullptr_t SQ_UNUSED_ARG(value)) noexcept {
|
||||||
sq_pushnull(vm);
|
sq_pushnull(vm);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -655,13 +655,13 @@ template<>
|
|||||||
struct Var<SQChar*> {
|
struct Var<SQChar*> {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
HSQOBJECT obj; /* hold a reference to the object holding value during the Var struct lifetime*/
|
HSQOBJECT obj{}; /* hold a reference to the object holding value during the Var struct lifetime*/
|
||||||
HSQUIRRELVM v;
|
HSQUIRRELVM v{nullptr};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SQChar* value; ///< The actual value of get operations
|
SQChar* value{nullptr}; ///< The actual value of get operations
|
||||||
SQInteger size; ///< The size of the obtained string
|
SQInteger size{0}; ///< The size of the obtained string
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// Attempts to get the value off the stack at idx as a character array
|
/// Attempts to get the value off the stack at idx as a character array
|
||||||
@@ -698,7 +698,7 @@ public:
|
|||||||
/// \param len Length of the string (defaults to finding the length by searching for a terminating null-character)
|
/// \param len Length of the string (defaults to finding the length by searching for a terminating null-character)
|
||||||
///
|
///
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
static void push(HSQUIRRELVM vm, const SQChar* value, SQInteger len = -1) {
|
inline static void push(HSQUIRRELVM vm, const SQChar* value, SQInteger len = -1) noexcept {
|
||||||
sq_pushstring(vm, value, len);
|
sq_pushstring(vm, value, len);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -710,13 +710,13 @@ template<>
|
|||||||
struct Var<const SQChar*> {
|
struct Var<const SQChar*> {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
HSQOBJECT obj; /* hold a reference to the object holding value during the Var struct lifetime*/
|
HSQOBJECT obj{}; /* hold a reference to the object holding value during the Var struct lifetime*/
|
||||||
HSQUIRRELVM v;
|
HSQUIRRELVM v{nullptr};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
const SQChar* value; ///< The actual value of get operations
|
const SQChar* value{nullptr}; ///< The actual value of get operations
|
||||||
SQInteger size; ///< The size of the obtained string
|
SQInteger size{0}; ///< The size of the obtained string
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// Attempts to get the value off the stack at idx as a character array
|
/// Attempts to get the value off the stack at idx as a character array
|
||||||
@@ -753,7 +753,7 @@ public:
|
|||||||
/// \param len Length of the string (defaults to finding the length by searching for a terminating null-character)
|
/// \param len Length of the string (defaults to finding the length by searching for a terminating null-character)
|
||||||
///
|
///
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
static void push(HSQUIRRELVM vm, const SQChar* value, SQInteger len = -1) {
|
inline static void push(HSQUIRRELVM vm, const SQChar* value, SQInteger len = -1) noexcept {
|
||||||
sq_pushstring(vm, value, len);
|
sq_pushstring(vm, value, len);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -789,8 +789,8 @@ struct Var<string> {
|
|||||||
/// \param value Value to push on to the VM's stack
|
/// \param value Value to push on to the VM's stack
|
||||||
///
|
///
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
static void push(HSQUIRRELVM vm, const string& value) {
|
inline static void push(HSQUIRRELVM vm, const string& value) noexcept {
|
||||||
sq_pushstring(vm, value.c_str(), value.size());
|
sq_pushstring(vm, value.c_str(), static_cast< SQInteger >(value.size()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -825,8 +825,8 @@ struct Var<const string&> {
|
|||||||
/// \param value Value to push on to the VM's stack
|
/// \param value Value to push on to the VM's stack
|
||||||
///
|
///
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
static void push(HSQUIRRELVM vm, const string& value) {
|
inline static void push(HSQUIRRELVM vm, const string& value) noexcept {
|
||||||
sq_pushstring(vm, value.c_str(), value.size());
|
sq_pushstring(vm, value.c_str(), static_cast< SQInteger >(value.size()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -863,7 +863,7 @@ struct Var<std::wstring> {
|
|||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
static void push(HSQUIRRELVM vm, const std::wstring& value) {
|
static void push(HSQUIRRELVM vm, const std::wstring& value) {
|
||||||
std::string s(value.begin(), value.end());
|
std::string s(value.begin(), value.end());
|
||||||
sq_pushstring(vm, s.c_str(), s.size());
|
sq_pushstring(vm, s.c_str(), static_cast< SQInteger >(s.size()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -900,7 +900,7 @@ struct Var<const std::wstring&> {
|
|||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
static void push(HSQUIRRELVM vm, const std::wstring& value) {
|
static void push(HSQUIRRELVM vm, const std::wstring& value) {
|
||||||
std::string s(value.begin(), value.end());
|
std::string s(value.begin(), value.end());
|
||||||
sq_pushstring(vm, s.c_str(), s.size());
|
sq_pushstring(vm, s.c_str(), static_cast< SQInteger >(s.size()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1173,7 +1173,7 @@ struct Var<StackStrF> {
|
|||||||
/// \param value Value to push on to the VM's stack
|
/// \param value Value to push on to the VM's stack
|
||||||
///
|
///
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
static void push(HSQUIRRELVM vm, const StackStrF& value) {
|
static void push(HSQUIRRELVM vm, const StackStrF& value) noexcept {
|
||||||
if (sq_isstring(value.mObj)) {
|
if (sq_isstring(value.mObj)) {
|
||||||
sq_pushobject(vm, value.mObj);
|
sq_pushobject(vm, value.mObj);
|
||||||
} else {
|
} else {
|
||||||
@@ -1284,7 +1284,7 @@ inline void PushVars(HSQUIRRELVM /*vm*/) { }
|
|||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void PushVars(HSQUIRRELVM vm, T value) {
|
inline void PushVars(HSQUIRRELVM vm, T value) {
|
||||||
PushVar(vm, value);
|
PushVar(vm, std::forward< T >(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -1292,15 +1292,15 @@ inline void PushVars(HSQUIRRELVM vm, T value) {
|
|||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
template<class T, class... Ts>
|
template<class T, class... Ts>
|
||||||
inline void PushVars(HSQUIRRELVM vm, T value, Ts &&... tail) {
|
inline void PushVars(HSQUIRRELVM vm, T value, Ts &&... tail) {
|
||||||
PushVar(vm, value);
|
PushVar(vm, std::forward< T >(value));
|
||||||
PushVars(vm, std::forward<Ts>(tail)...);
|
PushVars(vm, std::forward< Ts >(tail)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @cond DEV
|
/// @cond DEV
|
||||||
template<class T, bool b>
|
template<class T, bool b>
|
||||||
struct PushVarR_helper {
|
struct PushVarR_helper {
|
||||||
inline static void push(HSQUIRRELVM vm, T value) {
|
inline static void push(HSQUIRRELVM vm, T value) {
|
||||||
PushVar<T>(vm, value);
|
PushVar<T>(vm, std::forward< T >(value));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|||||||
Vendored
+30
-4
@@ -1,11 +1,22 @@
|
|||||||
add_subdirectory(ConcurrentQueue)
|
add_subdirectory(ConcurrentQueue)
|
||||||
add_subdirectory(Fmt)
|
add_subdirectory(Fmt)
|
||||||
|
add_subdirectory(xxHash)
|
||||||
add_subdirectory(Squirrel)
|
add_subdirectory(Squirrel)
|
||||||
add_subdirectory(SimpleIni)
|
add_subdirectory(SimpleIni)
|
||||||
add_subdirectory(TinyDir)
|
add_subdirectory(TinyDir)
|
||||||
add_subdirectory(SAJSON)
|
add_subdirectory(SAJSON)
|
||||||
add_subdirectory(CPR)
|
add_subdirectory(CPR)
|
||||||
|
add_subdirectory(UTF8)
|
||||||
add_subdirectory(PUGIXML)
|
add_subdirectory(PUGIXML)
|
||||||
|
add_subdirectory(CivetWeb)
|
||||||
|
if (ENABLE_BUILTIN_MYSQL_C)
|
||||||
|
set(WITH_MSI OFF CACHE INTERNAL "" FORCE)
|
||||||
|
set(WITH_UNIT_TESTS OFF CACHE INTERNAL "" FORCE)
|
||||||
|
set(WITH_EXTERNAL_ZLIB ON CACHE INTERNAL "" FORCE)
|
||||||
|
set(WITH_CURL ON CACHE INTERNAL "" FORCE)
|
||||||
|
set(WITH_SSL ON CACHE INTERNAL "" FORCE)
|
||||||
|
add_subdirectory(MDBC)
|
||||||
|
endif()
|
||||||
set(BUILD_TESTING OFF CACHE INTERNAL "" FORCE)
|
set(BUILD_TESTING OFF CACHE INTERNAL "" FORCE)
|
||||||
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE)
|
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE)
|
||||||
add_subdirectory(MaxmindDB)
|
add_subdirectory(MaxmindDB)
|
||||||
@@ -31,20 +42,35 @@ set(ENABLE_POCODOC OFF CACHE INTERNAL "" FORCE)
|
|||||||
set(ENABLE_PAGECOMPILER OFF CACHE INTERNAL "" FORCE)
|
set(ENABLE_PAGECOMPILER OFF CACHE INTERNAL "" FORCE)
|
||||||
set(ENABLE_PAGECOMPILER_FILE2PAGE OFF CACHE INTERNAL "" FORCE)
|
set(ENABLE_PAGECOMPILER_FILE2PAGE OFF CACHE INTERNAL "" FORCE)
|
||||||
set(ENABLE_TESTS OFF CACHE INTERNAL "" FORCE)
|
set(ENABLE_TESTS OFF CACHE INTERNAL "" FORCE)
|
||||||
|
set(ENABLE_ACTIVERECORD OFF CACHE INTERNAL "" FORCE)
|
||||||
|
set(ENABLE_ACTIVERECORD_COMPILER OFF CACHE INTERNAL "" FORCE)
|
||||||
set(POCO_UNBUNDLED OFF CACHE INTERNAL "" FORCE)
|
set(POCO_UNBUNDLED OFF CACHE INTERNAL "" FORCE)
|
||||||
|
# Manualy enable some options if available
|
||||||
|
find_package(MySQL)
|
||||||
|
if(MYSQL_FOUND)
|
||||||
|
set(ENABLE_DATA_MYSQL ON CACHE INTERNAL "" FORCE)
|
||||||
|
endif()
|
||||||
|
find_package(PostgreSQL)
|
||||||
|
if(PostgreSQL_FOUND)
|
||||||
|
set(ENABLE_DATA_POSTGRESQL ON CACHE INTERNAL "" FORCE)
|
||||||
|
endif()
|
||||||
add_subdirectory(POCO)
|
add_subdirectory(POCO)
|
||||||
# Windows gets stupid sometimes
|
# Windows gets stupid sometimes
|
||||||
if (WIN32 AND MINGW)
|
if (WIN32 AND MINGW)
|
||||||
target_compile_definitions(Foundation PUBLIC POCO_NO_FPENVIRONMENT=1)
|
target_compile_definitions(Foundation PUBLIC POCO_NO_FPENVIRONMENT=1)
|
||||||
endif()
|
endif()
|
||||||
# We have these on GCC
|
# We have these on GCC
|
||||||
if(MINGW OR GCC)
|
if(MINGW OR GCC)
|
||||||
set(ENABLE_INTRINSICS ON CACHE INTERNAL "" FORCE)
|
set(ENABLE_INTRINSICS ON CACHE INTERNAL "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
set(BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
|
set(BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
|
||||||
set(BUILD_SHARED OFF CACHE INTERNAL "" FORCE)
|
set(BUILD_SHARED OFF CACHE INTERNAL "" FORCE)
|
||||||
set(BUILD_STATIC ON CACHE INTERNAL "" FORCE)
|
set(BUILD_STATIC ON CACHE INTERNAL "" FORCE)
|
||||||
if (WIN32 OR MINGW)
|
if (WIN32 OR MINGW)
|
||||||
set(ZMQ_HAVE_IPC OFF CACHE INTERNAL "" FORCE)
|
set(ZMQ_HAVE_IPC OFF CACHE INTERNAL "" FORCE)
|
||||||
|
endif()
|
||||||
|
add_subdirectory(ZMQ)
|
||||||
|
# Should we include DPP?
|
||||||
|
if (ENABLE_DISCORD)
|
||||||
|
add_subdirectory(DPP)
|
||||||
endif()
|
endif()
|
||||||
add_subdirectory(ZMQ)
|
|
||||||
Vendored
+3
-1
@@ -13,6 +13,7 @@ add_library(CPR STATIC
|
|||||||
cpr/payload.cpp
|
cpr/payload.cpp
|
||||||
cpr/proxies.cpp
|
cpr/proxies.cpp
|
||||||
cpr/proxyauth.cpp
|
cpr/proxyauth.cpp
|
||||||
|
cpr/redirect.cpp
|
||||||
cpr/session.cpp
|
cpr/session.cpp
|
||||||
cpr/timeout.cpp
|
cpr/timeout.cpp
|
||||||
cpr/unix_socket.cpp
|
cpr/unix_socket.cpp
|
||||||
@@ -30,14 +31,15 @@ add_library(CPR STATIC
|
|||||||
include/cpr/curlholder.h
|
include/cpr/curlholder.h
|
||||||
include/cpr/digest.h
|
include/cpr/digest.h
|
||||||
include/cpr/error.h
|
include/cpr/error.h
|
||||||
|
include/cpr/interface.h
|
||||||
include/cpr/limit_rate.h
|
include/cpr/limit_rate.h
|
||||||
include/cpr/max_redirects.h
|
|
||||||
include/cpr/multipart.h
|
include/cpr/multipart.h
|
||||||
include/cpr/ntlm.h
|
include/cpr/ntlm.h
|
||||||
include/cpr/parameters.h
|
include/cpr/parameters.h
|
||||||
include/cpr/payload.h
|
include/cpr/payload.h
|
||||||
include/cpr/proxies.h
|
include/cpr/proxies.h
|
||||||
include/cpr/proxyauth.h
|
include/cpr/proxyauth.h
|
||||||
|
include/cpr/redirect.h
|
||||||
include/cpr/response.h
|
include/cpr/response.h
|
||||||
include/cpr/session.h
|
include/cpr/session.h
|
||||||
include/cpr/ssl_options.h
|
include/cpr/ssl_options.h
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user