1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-07-05 16:37:12 +02:00

35 Commits

Author SHA1 Message Date
1d85603dfb Expose DPP message embeds.
Some checks reported errors
continuous-integration/drone/push Build was killed
2021-09-23 22:13:13 +03:00
259af04d0e Disable Discord until implemented.
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-21 21:11:12 +03:00
4d1971d66b Disable the option by default. 2021-09-21 21:05:08 +03:00
b4bf96ce4b Add MariaDB Connector/C as a built-in alternative (v3.2.3). 2021-09-21 20:59:01 +03:00
f192767853 Update UTF8.cpp 2021-09-19 17:40:55 +03:00
a58b9fe267 Expose more DPP message types. 2021-09-19 14:24:15 +03:00
4a8a7172d4 Add UTF8 library. 2021-09-19 14:23:47 +03:00
cae745378d Update Utilities.hpp 2021-09-19 14:21:57 +03:00
62b9504d43 Expose DPP message component. 2021-09-19 01:08:39 +03:00
26ccfa62b9 Add std::vector proxy type. 2021-09-19 01:08:19 +03:00
83f2ab79e0 Update Guild.hpp 2021-09-18 21:35:42 +03:00
57321af0c7 Update Message.hpp 2021-09-18 21:35:38 +03:00
8d908208f0 Update Other.hpp 2021-09-18 21:35:34 +03:00
87cb6a2cba Update Role.hpp 2021-09-18 21:35:30 +03:00
0487f26865 Update User.hpp 2021-09-18 21:35:27 +03:00
e3c32e4788 DPP update fixes. 2021-09-18 21:24:49 +03:00
b978bc5046 Update DPP. 2021-09-18 21:19:56 +03:00
0f235ff6af Merge pull request #54 from theKAKAN/patch-2
Fix team kill and normal kill swapped
2021-09-12 22:38:01 +03:00
7057939854 Add more flexible string to integer and float conversion. 2021-09-12 22:28:42 +03:00
eb3100de36 Fix team kill and normal kill swapped
onPlayerKill and onPlayerTeamKill were swapped
2021-09-12 19:06:28 +00:00
f72c0f896e Merge pull request #53 from theKAKAN/patch-1
Fixes `SetSpawnCameraLookAtEx` not working as intended
2021-09-12 21:17:14 +03:00
0d323f4a26 Fixes SetSpawnCameraLookAtEx not working as intended
`SetSpawnCameraLookAtEx` was basically the same as `SetSpawnPlayerPositionEx`
2021-09-12 17:46:49 +00:00
0c4c78da6e Define discord message types. 2021-09-12 19:32:07 +03:00
2011631e78 Update Constants.cpp 2021-09-12 18:51:25 +03:00
801ccbd6cd Update Guild.hpp 2021-09-12 18:51:22 +03:00
9062121cc8 Update Other.hpp 2021-09-12 18:51:19 +03:00
596da38403 Update Role.hpp 2021-09-12 18:51:16 +03:00
aa2a8f32d1 Update User.hpp 2021-09-12 18:51:13 +03:00
13fc02e9ca Restructure discord API files. 2021-09-12 17:53:57 +03:00
17875509c0 Update CMakeLists.txt 2021-09-12 16:12:30 +03:00
5df55164ee Update Vehicle.cpp 2021-09-12 16:03:38 +03:00
45570af13b Update Player.cpp 2021-09-12 16:03:31 +03:00
949e5e61d0 Change the order of custom Pickup events to happen before performing the action. 2021-09-12 16:03:23 +03:00
e4aa96a8c3 Change the order of custom Object events to happen before performing the action. 2021-09-12 16:03:17 +03:00
e60e2958f0 Change the order of custom Checkpoint events to happen before performing the action. 2021-09-12 16:02:46 +03:00
439 changed files with 99709 additions and 3444 deletions

View File

@ -12,9 +12,11 @@ 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" ON) option(ENABLE_DISCORD "Enable built-in Discord support" OFF)
option(ENABLE_DISCORD_VOICE "Enable voice support in Discord library" 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)
# 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) #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)

View File

@ -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
@ -131,15 +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 xxHash ConcurrentQueue SAJSON CPR PUGIXML CivetWeb 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 # Enable built-in Discord support
if(ENABLE_DISCORD) if(ENABLE_DISCORD)
target_link_libraries(SqModule DPP) target_link_libraries(SqModule DPP)
target_compile_definitions(SqModule PRIVATE VCMP_ENABLE_DISCORD=1) target_compile_definitions(SqModule PRIVATE VCMP_ENABLE_DISCORD=1)
target_sources(SqModule PRIVATE Library/DPP.cpp Library/DPP.hpp Library/DPPEv.cpp Library/DPPEv.hpp Library/DPPTy.cpp Library/DPPTy.hpp) 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() 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)
@ -154,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)

View File

@ -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));
} }

View File

@ -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);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -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));
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -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));
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -169,7 +169,7 @@ void CPlayer::SetAdmin(bool toggle)
return; return;
} }
// 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);
@ -434,7 +434,7 @@ void CPlayer::SetWorld(int32_t world)
return; return;
} }
// 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);
@ -467,7 +467,7 @@ void CPlayer::SetSecondaryWorld(int32_t world)
return; return;
} }
// 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);
@ -666,7 +666,7 @@ void CPlayer::SetMoney(int32_t amount)
return; return;
} }
// 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);
@ -718,7 +718,7 @@ void CPlayer::SetScore(int32_t score)
return; return;
} }
// 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);
@ -751,7 +751,7 @@ void CPlayer::SetWantedLevel(int32_t level)
return; return;
} }
// 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);
@ -970,7 +970,7 @@ void CPlayer::SetAlphaEx(int32_t alpha, int32_t fade)
return; return;
} }
// 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);

View File

@ -225,7 +225,7 @@ void CVehicle::SetWorld(int32_t world)
return; return;
} }
// 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);
@ -917,7 +917,7 @@ void CVehicle::SetPartStatus(int32_t part, int32_t status)
return; return;
} }
// 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);
@ -950,7 +950,7 @@ void CVehicle::SetTyreStatus(int32_t tyre, int32_t status)
return; return;
} }
// 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);
@ -983,7 +983,7 @@ void CVehicle::SetDamageData(uint32_t data)
return; return;
} }
// 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);
@ -1016,7 +1016,7 @@ void CVehicle::SetRadio(int32_t radio)
return; return;
} }
// 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);

View File

@ -1,9 +1,6 @@
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include "Library/DPP.hpp" #include "Library/DPP.hpp"
#include "Core/Signal.hpp" #include "Library/DPP/Cluster.hpp"
// ------------------------------------------------------------------------------------------------
#include <cstdio>
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include <sqratConst.h> #include <sqratConst.h>
@ -11,9 +8,6 @@
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
namespace SqMod { namespace SqMod {
// ------------------------------------------------------------------------------------------------
SQMOD_DECL_TYPENAME(SqDppCluster, _SC("SqDppCluster"))
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void TerminateDPP() void TerminateDPP()
{ {
@ -35,766 +29,44 @@ void ProcessDPP()
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
extern void Register_DPPTy(HSQUIRRELVM vm, Table & ns); extern void Register_DPP_Channel(HSQUIRRELVM vm, Table & ns);
extern void Register_DPPEv(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) void Register_DPP(HSQUIRRELVM vm)
{ {
Table ns(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); Table ens(vm);
Register_DPPEv(vm, ens); Register_DPP_Events(vm, ens);
ns.Bind(_SC("Events"), ens); ns.Bind(_SC("Events"), ens);
} }
// Register base types Register_DPP_Cluster(vm, ns);
Register_DPPTy(vm, 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)
);
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
ns.Func(_SC("HasVoice"), dpp::utility::has_voice); ns.Func(_SC("HasVoice"), dpp::utility::has_voice);
// --------------------------------------------------------------------------------------------
RootTable(vm).Bind(_SC("SqDiscord"), ns); RootTable(vm).Bind(_SC("SqDiscord"), ns);
} }
// ------------------------------------------------------------------------------------------------
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 } // Namespace:: SqMod

View File

@ -1,428 +1,12 @@
#pragma once #pragma once
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include "Library/DPPEv.hpp" #include "Core/Utility.hpp"
#include "Library/DPPTy.hpp"
#include "Core/Signal.hpp"
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include <chrono>
#include <memory>
#include <functional>
// ------------------------------------------------------------------------------------------------
#include <concurrentqueue.h>
#include <dpp/dpp.h>
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
namespace SqMod { namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* WebSocket frame.
*/
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 } // Namespace:: SqMod

View File

@ -0,0 +1,16 @@
// ------------------------------------------------------------------------------------------------
#include "Library/DPP/Channel.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void Register_DPP_Channel(HSQUIRRELVM vm, Table & ns)
{
}
} // Namespace:: SqMod

View File

@ -0,0 +1,19 @@
#pragma once
// ------------------------------------------------------------------------------------------------
#include "Core/Utility.hpp"
// ------------------------------------------------------------------------------------------------
#include <chrono>
// ------------------------------------------------------------------------------------------------
#include <dpp/dpp.h>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
*
*/
} // Namespace:: SqMod

View File

@ -0,0 +1,16 @@
// ------------------------------------------------------------------------------------------------
#include "Library/DPP/Client.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void Register_DPP_Client(HSQUIRRELVM vm, Table & ns)
{
}
} // Namespace:: SqMod

View File

@ -0,0 +1,19 @@
#pragma once
// ------------------------------------------------------------------------------------------------
#include "Core/Utility.hpp"
// ------------------------------------------------------------------------------------------------
#include <chrono>
// ------------------------------------------------------------------------------------------------
#include <dpp/dpp.h>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
*
*/
} // Namespace:: SqMod

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,16 @@
// ------------------------------------------------------------------------------------------------
#include "Library/DPP/Command.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void Register_DPP_Command(HSQUIRRELVM vm, Table & ns)
{
}
} // Namespace:: SqMod

View File

@ -0,0 +1,19 @@
#pragma once
// ------------------------------------------------------------------------------------------------
#include "Core/Utility.hpp"
// ------------------------------------------------------------------------------------------------
#include <chrono>
// ------------------------------------------------------------------------------------------------
#include <dpp/dpp.h>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
*
*/
} // Namespace:: SqMod

View File

@ -1,5 +1,5 @@
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include "Library/DPPTy.hpp" #include "Library/DPP/Constants.hpp"
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include <sqratConst.h> #include <sqratConst.h>
@ -8,326 +8,69 @@
namespace SqMod { namespace SqMod {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
SQMOD_DECL_TYPENAME(SqDppCachePolicy, _SC("SqDppCachePolicy")) const std::array< const char *, static_cast< size_t >(DpEventID::Max) > DpEventID::NAME{
SQMOD_DECL_TYPENAME(SqDppIconHash, _SC("SqDppIconHash")) "VoiceStateUpdate",
SQMOD_DECL_TYPENAME(SqDppUptime, _SC("SqDppUptime")) "Log",
SQMOD_DECL_TYPENAME(SqDppActivity, _SC("SqDppActivity")) "GuildJoinRequestDelete",
SQMOD_DECL_TYPENAME(SqDppPresence, _SC("SqDppPresence")) "InteractionCreate",
SQMOD_DECL_TYPENAME(SqDppVoiceState, _SC("SqDppVoiceState")) "ButtonClick",
SQMOD_DECL_TYPENAME(SqDppRole, _SC("SqDppRole")) "SelectClick",
SQMOD_DECL_TYPENAME(SqDppUser, _SC("SqDppUser")) "GuildDelete",
SQMOD_DECL_TYPENAME(SqDppGuildMember, _SC("SqDppGuildMember")) "ChannelDelete",
SQMOD_DECL_TYPENAME(SqDppGuild, _SC("SqDppGuild")) "ChannelUpdate",
"Ready",
// ------------------------------------------------------------------------------------------------ "MessageDelete",
void Register_DPPConst(HSQUIRRELVM vm, Table & ns); "ApplicationCommandDelete",
"GuildMemberRemove",
// ------------------------------------------------------------------------------------------------ "ApplicationCommandCreate",
void Register_DPPTy(HSQUIRRELVM vm, Table & ns) "Resumed",
{ "GuildRoleCreate",
Register_DPPConst(vm, ns); "TypingStart",
// -------------------------------------------------------------------------------------------- "MessageReactionAdd",
ns.Bind(_SC("Uptime"), "GuildMembersChunk",
Class< dpp::utility::uptime >(vm, SqDppUptime::Str) "MessageReactionRemove",
// Constructors "GuildCreate",
.Ctor() "ChannelCreate",
// Meta-methods "MessageReactionRemoveEmoji",
.SquirrelFunc(_SC("_typename"), &SqDppUptime::Fn) "MessageDeleteBulk",
.Func(_SC("_tostring"), &dpp::utility::uptime::to_string) "GuildRoleUpdate",
// Member Variables "GuildRoleDelete",
.Var(_SC("Days"), &dpp::utility::uptime::days) "ChannelPinsUpdate",
.Var(_SC("Hours"), &dpp::utility::uptime::hours) "MessageReactionRemoveAll",
.Var(_SC("Minutes"), &dpp::utility::uptime::mins) "VoiceServerUpdate",
.Var(_SC("Seconds"), &dpp::utility::uptime::secs) "GuildEmojisUpdate",
// Member Methods "GuildStickersUpdate",
.Func(_SC("ToSeconds"), &dpp::utility::uptime::to_secs) "PresenceUpdate",
.Func(_SC("ToMilliseconds"), &dpp::utility::uptime::to_msecs) "WebhooksUpdate",
); "GuildMemberAdd",
// -------------------------------------------------------------------------------------------- "InviteDelete",
ns.Bind(_SC("IconHash"), "GuildUpdate",
Class< dpp::utility::iconhash >(vm, SqDppIconHash::Str) "GuildIntegrationsUpdate",
// Constructors "GuildMemberUpdate",
.Ctor() "ApplicationCommandUpdate",
.Ctor< const std::string & >() "InviteCreate",
// Meta-methods "MessageUpdate",
.SquirrelFunc(_SC("_typename"), &SqDppIconHash::Fn) "UserUpdate",
.Func(_SC("_tostring"), &dpp::utility::iconhash::to_string) "MessageCreate",
// Member Variables "GuildBanAdd",
.Var(_SC("High"), &dpp::utility::iconhash::first) "GuildBanRemove",
.Var(_SC("Low"), &dpp::utility::iconhash::second) "IntegrationCreate",
// Member Methods "IntegrationUpdate",
.Func(_SC("Set"), &dpp::utility::iconhash::set) "IntegrationDelete",
); "ThreadCreate",
// -------------------------------------------------------------------------------------------- "ThreadUpdate",
ns.Bind(_SC("CachePolicy"), "ThreadDelete",
Class< DpCachePolicy >(vm, SqDppCachePolicy::Str) "ThreadListSync",
// Constructors "ThreadMemberUpdate",
.Ctor() "ThreadMembersUpdate",
.Ctor< SQInteger >() "VoiceBufferSend",
.Ctor< SQInteger, SQInteger >() "VoiceUserTalking",
.Ctor< SQInteger, SQInteger, SQInteger >() "VoiceReady",
// Meta-methods "VoiceReceive",
.SquirrelFunc(_SC("_typename"), &SqDppCachePolicy::Fn) "VoiceTrackMarker",
// Member Variables "StageInstanceCreate",
.Var(_SC("UserPolicy"), &DpCachePolicy::mUserPolicy) "StageInstanceDelete"
.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("IsSupressed"), &DpVoiceState::IsSupressed)
);
// --------------------------------------------------------------------------------------------
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_)
);
// --------------------------------------------------------------------------------------------
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)
);
// --------------------------------------------------------------------------------------------
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)
);
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
static const EnumElement g_DpLogLevelEnum[] = { static const EnumElement g_DpLogLevelEnum[] = {
@ -449,7 +192,7 @@ static const EnumElement g_DpVoiceStateFlagsEnum[] = {
{_SC("SelfDeaf"), static_cast< SQInteger >(dpp::vs_self_deaf)}, {_SC("SelfDeaf"), static_cast< SQInteger >(dpp::vs_self_deaf)},
{_SC("SelfStream"), static_cast< SQInteger >(dpp::vs_self_stream)}, {_SC("SelfStream"), static_cast< SQInteger >(dpp::vs_self_stream)},
{_SC("SelfVideo"), static_cast< SQInteger >(dpp::vs_self_video)}, {_SC("SelfVideo"), static_cast< SQInteger >(dpp::vs_self_video)},
{_SC("Supress"), static_cast< SQInteger >(dpp::vs_supress)}, {_SC("Suppress"), static_cast< SQInteger >(dpp::vs_suppress)},
}; };
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -574,6 +317,72 @@ static const EnumElement g_DpGuildMemberFlagsEnum[] = {
{_SC("Pending"), static_cast< SQInteger >(dpp::gm_pending)} {_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[] = { static const EnumElements g_EnumList[] = {
{_SC("SqDiscordLogLevel"), g_DpLogLevelEnum}, {_SC("SqDiscordLogLevel"), g_DpLogLevelEnum},
@ -591,13 +400,28 @@ static const EnumElements g_EnumList[] = {
{_SC("SqDiscordUserFlags"), g_DpUserFlagsEnum}, {_SC("SqDiscordUserFlags"), g_DpUserFlagsEnum},
{_SC("SqDiscordRegion"), g_DpRegionEnum}, {_SC("SqDiscordRegion"), g_DpRegionEnum},
{_SC("SqDiscordGuildFlags"), g_DpGuildFlagsEnum}, {_SC("SqDiscordGuildFlags"), g_DpGuildFlagsEnum},
{_SC("SqDiscordGuildMemberFlags"), g_DpGuildMemberFlagsEnum} {_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_DPPConst(HSQUIRRELVM vm, Table &) void Register_DPP_Constants(HSQUIRRELVM vm, Table & ns)
{ {
RegisterEnumerations(vm, g_EnumList); 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 } // Namespace:: SqMod

View File

@ -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

View File

@ -1,11 +1,5 @@
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include "Library/DPPEv.hpp" #include "Library/DPP/Events.hpp"
// ------------------------------------------------------------------------------------------------
#include <cstdio>
// ------------------------------------------------------------------------------------------------
#include <sqratConst.h>
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
namespace SqMod { namespace SqMod {
@ -74,72 +68,7 @@ SQMOD_DECL_TYPENAME(SqDppStageInstanceCreateEvent, _SC("SqDppStageInstanceCreate
SQMOD_DECL_TYPENAME(SqDppStageInstanceDeleteEvent, _SC("SqDppStageInstanceDeleteEvent")) SQMOD_DECL_TYPENAME(SqDppStageInstanceDeleteEvent, _SC("SqDppStageInstanceDeleteEvent"))
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
const std::array< const char *, static_cast< size_t >(DpEventID::Max) > DpEventID::NAME{ void Register_DPP_Events(HSQUIRRELVM vm, Table & ns)
"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"
};
// ------------------------------------------------------------------------------------------------
void Register_DPPEv(HSQUIRRELVM vm, Table & ns)
{ {
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
ns.Bind(_SC("VoiceStateUpdate"), ns.Bind(_SC("VoiceStateUpdate"),
@ -696,71 +625,6 @@ void Register_DPPEv(HSQUIRRELVM vm, Table & ns)
// Member Properties // Member Properties
.Prop(_SC("RawEvent"), &DpStageInstanceDeleteEvent::GetRawEvent) .Prop(_SC("RawEvent"), &DpStageInstanceDeleteEvent::GetRawEvent)
); );
// --------------------------------------------------------------------------------------------
ConstTable(vm).Enum(_SC("SqDiscordEvent"), Enumeration(vm)
.Const(_SC("VoiceStateUpdate"), static_cast< SQInteger >(DpEventID::VoiceStateUpdate))
.Const(_SC("Log"), static_cast< SQInteger >(DpEventID::Log))
.Const(_SC("GuildJoinRequestDelete"), static_cast< SQInteger >(DpEventID::GuildJoinRequestDelete))
.Const(_SC("InteractionCreate"), static_cast< SQInteger >(DpEventID::InteractionCreate))
.Const(_SC("ButtonClick"), static_cast< SQInteger >(DpEventID::ButtonClick))
.Const(_SC("SelectClick"), static_cast< SQInteger >(DpEventID::SelectClick))
.Const(_SC("GuildDelete"), static_cast< SQInteger >(DpEventID::GuildDelete))
.Const(_SC("ChannelDelete"), static_cast< SQInteger >(DpEventID::ChannelDelete))
.Const(_SC("ChannelUpdate"), static_cast< SQInteger >(DpEventID::ChannelUpdate))
.Const(_SC("Ready"), static_cast< SQInteger >(DpEventID::Ready))
.Const(_SC("MessageDelete"), static_cast< SQInteger >(DpEventID::MessageDelete))
.Const(_SC("ApplicationCommandDelete"), static_cast< SQInteger >(DpEventID::ApplicationCommandDelete))
.Const(_SC("GuildMemberRemove"), static_cast< SQInteger >(DpEventID::GuildMemberRemove))
.Const(_SC("ApplicationCommandCreate"), static_cast< SQInteger >(DpEventID::ApplicationCommandCreate))
.Const(_SC("Resumed"), static_cast< SQInteger >(DpEventID::Resumed))
.Const(_SC("GuildRoleCreate"), static_cast< SQInteger >(DpEventID::GuildRoleCreate))
.Const(_SC("TypingStart"), static_cast< SQInteger >(DpEventID::TypingStart))
.Const(_SC("MessageReactionAdd"), static_cast< SQInteger >(DpEventID::MessageReactionAdd))
.Const(_SC("GuildMembersChunk"), static_cast< SQInteger >(DpEventID::GuildMembersChunk))
.Const(_SC("MessageReactionRemove"), static_cast< SQInteger >(DpEventID::MessageReactionRemove))
.Const(_SC("GuildCreate"), static_cast< SQInteger >(DpEventID::GuildCreate))
.Const(_SC("ChannelCreate"), static_cast< SQInteger >(DpEventID::ChannelCreate))
.Const(_SC("MessageReactionRemoveEmoji"), static_cast< SQInteger >(DpEventID::MessageReactionRemoveEmoji))
.Const(_SC("MessageDeleteBulk"), static_cast< SQInteger >(DpEventID::MessageDeleteBulk))
.Const(_SC("GuildRoleUpdate"), static_cast< SQInteger >(DpEventID::GuildRoleUpdate))
.Const(_SC("GuildRoleDelete"), static_cast< SQInteger >(DpEventID::GuildRoleDelete))
.Const(_SC("ChannelPinsUpdate"), static_cast< SQInteger >(DpEventID::ChannelPinsUpdate))
.Const(_SC("MessageReactionRemoveAll"), static_cast< SQInteger >(DpEventID::MessageReactionRemoveAll))
.Const(_SC("VoiceServerUpdate"), static_cast< SQInteger >(DpEventID::VoiceServerUpdate))
.Const(_SC("GuildEmojisUpdate"), static_cast< SQInteger >(DpEventID::GuildEmojisUpdate))
.Const(_SC("GuildStickersUpdate"), static_cast< SQInteger >(DpEventID::GuildStickersUpdate))
.Const(_SC("PresenceUpdate"), static_cast< SQInteger >(DpEventID::PresenceUpdate))
.Const(_SC("WebhooksUpdate"), static_cast< SQInteger >(DpEventID::WebhooksUpdate))
.Const(_SC("GuildMemberAdd"), static_cast< SQInteger >(DpEventID::GuildMemberAdd))
.Const(_SC("InviteDelete"), static_cast< SQInteger >(DpEventID::InviteDelete))
.Const(_SC("GuildUpdate"), static_cast< SQInteger >(DpEventID::GuildUpdate))
.Const(_SC("GuildIntegrationsUpdate"), static_cast< SQInteger >(DpEventID::GuildIntegrationsUpdate))
.Const(_SC("GuildMemberUpdate"), static_cast< SQInteger >(DpEventID::GuildMemberUpdate))
.Const(_SC("ApplicationCommandUpdate"), static_cast< SQInteger >(DpEventID::ApplicationCommandUpdate))
.Const(_SC("InviteCreate"), static_cast< SQInteger >(DpEventID::InviteCreate))
.Const(_SC("MessageUpdate"), static_cast< SQInteger >(DpEventID::MessageUpdate))
.Const(_SC("UserUpdate"), static_cast< SQInteger >(DpEventID::UserUpdate))
.Const(_SC("MessageCreate"), static_cast< SQInteger >(DpEventID::MessageCreate))
.Const(_SC("GuildBanAdd"), static_cast< SQInteger >(DpEventID::GuildBanAdd))
.Const(_SC("GuildBanRemove"), static_cast< SQInteger >(DpEventID::GuildBanRemove))
.Const(_SC("IntegrationCreate"), static_cast< SQInteger >(DpEventID::IntegrationCreate))
.Const(_SC("IntegrationUpdate"), static_cast< SQInteger >(DpEventID::IntegrationUpdate))
.Const(_SC("IntegrationDelete"), static_cast< SQInteger >(DpEventID::IntegrationDelete))
.Const(_SC("ThreadCreate"), static_cast< SQInteger >(DpEventID::ThreadCreate))
.Const(_SC("ThreadUpdate"), static_cast< SQInteger >(DpEventID::ThreadUpdate))
.Const(_SC("ThreadDelete"), static_cast< SQInteger >(DpEventID::ThreadDelete))
.Const(_SC("ThreadListSync"), static_cast< SQInteger >(DpEventID::ThreadListSync))
.Const(_SC("ThreadMemberUpdate"), static_cast< SQInteger >(DpEventID::ThreadMemberUpdate))
.Const(_SC("ThreadMembersUpdate"), static_cast< SQInteger >(DpEventID::ThreadMembersUpdate))
.Const(_SC("VoiceBufferSend"), static_cast< SQInteger >(DpEventID::VoiceBufferSend))
.Const(_SC("VoiceUserTalking"), static_cast< SQInteger >(DpEventID::VoiceUserTalking))
.Const(_SC("VoiceReady"), static_cast< SQInteger >(DpEventID::VoiceReady))
.Const(_SC("VoiceReceive"), static_cast< SQInteger >(DpEventID::VoiceReceive))
.Const(_SC("VoiceTrackMarker"), static_cast< SQInteger >(DpEventID::VoiceTrackMarker))
.Const(_SC("StageInstanceCreate"), static_cast< SQInteger >(DpEventID::StageInstanceCreate))
.Const(_SC("StageInstanceDelete"), static_cast< SQInteger >(DpEventID::StageInstanceDelete))
.Const(_SC("Max"), static_cast< SQInteger >(DpEventID::Max))
);
} }
} // Namespace:: SqMod } // Namespace:: SqMod

View File

@ -1,7 +1,15 @@
#pragma once #pragma once
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include "Library/DPPTy.hpp" #include "Library/DPP/Channel.hpp"
#include "Library/DPP/Client.hpp"
#include "Library/DPP/Command.hpp"
#include "Library/DPP/Guild.hpp"
#include "Library/DPP/Integration.hpp"
#include "Library/DPP/Message.hpp"
#include "Library/DPP/Other.hpp"
#include "Library/DPP/Role.hpp"
#include "Library/DPP/User.hpp"
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
#include <chrono> #include <chrono>
@ -13,85 +21,6 @@
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
namespace SqMod { 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.
*/
static const std::array< const char *, static_cast< size_t >(Max) > NAME;
};
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Base class of an event handler. * Base class of an event handler.
*/ */

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,16 @@
// ------------------------------------------------------------------------------------------------
#include "Library/DPP/Integration.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
void Register_DPP_Integration(HSQUIRRELVM vm, Table & ns)
{
}
} // Namespace:: SqMod

View File

@ -0,0 +1,19 @@
#pragma once
// ------------------------------------------------------------------------------------------------
#include "Core/Utility.hpp"
// ------------------------------------------------------------------------------------------------
#include <chrono>
// ------------------------------------------------------------------------------------------------
#include <dpp/dpp.h>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
*
*/
} // Namespace:: SqMod

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

301
module/Library/DPP/Role.hpp Normal file
View File

@ -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

View File

@ -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

206
module/Library/DPP/User.hpp Normal file
View File

@ -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

View File

@ -0,0 +1,12 @@
// ------------------------------------------------------------------------------------------------
#include "Library/DPP/Utilities.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------------
} // Namespace:: SqMod

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -961,17 +961,17 @@ static SQInteger SqLevenshtein(StackStrF & a, StackStrF & b)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
static SQInteger SqStrToI(SQInteger base, StackStrF & s) 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);
@ -980,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)
{ {
@ -1000,8 +1096,14 @@ 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("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 >)

135
module/Library/UTF8.cpp Normal file
View File

@ -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

14
module/Library/UTF8.hpp Normal file
View File

@ -0,0 +1,14 @@
#pragma once
// ------------------------------------------------------------------------------------------------
#include "Core/Utility.hpp"
// ------------------------------------------------------------------------------------------------
#include <utf8.h>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
} // Namespace:: SqMod

View File

@ -762,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);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -41,6 +41,7 @@ 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);
@ -110,6 +111,7 @@ bool RegisterAPI(HSQUIRRELVM 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);

18
vendor/CMakeLists.txt vendored
View File

@ -6,8 +6,17 @@ 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) 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)
@ -36,6 +45,15 @@ set(ENABLE_TESTS OFF CACHE INTERNAL "" FORCE)
set(ENABLE_ACTIVERECORD OFF CACHE INTERNAL "" FORCE) set(ENABLE_ACTIVERECORD OFF CACHE INTERNAL "" FORCE)
set(ENABLE_ACTIVERECORD_COMPILER 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)

View File

@ -88,7 +88,7 @@ namespace dpp {
* @brief Get the container map * @brief Get the container map
* @warning Be sure to use cache::get_mutex() correctly if you * @warning Be sure to use cache::get_mutex() correctly if you
* manipulate or iterate the map returned by this method! If you do * manipulate or iterate the map returned by this method! If you do
* not, this is not thread safe and will casue crashes! * not, this is not thread safe and will cause crashes!
* @see cache::get_mutex * @see cache::get_mutex
* *
* @return cache_container& A reference to the cache's container map * @return cache_container& A reference to the cache's container map

View File

@ -290,8 +290,8 @@ public:
* @param shards The total number of shards on this bot. If there are multiple clusters, then (shards / clusters) actual shards will run on this cluster. * @param shards The total number of shards on this bot. If there are multiple clusters, then (shards / clusters) actual shards will run on this cluster.
* If you omit this value, the library will attempt to query the Discord API for the correct number of shards to start. * If you omit this value, the library will attempt to query the Discord API for the correct number of shards to start.
* @param cluster_id The ID of this cluster, should be between 0 and MAXCLUSTERS-1 * @param cluster_id The ID of this cluster, should be between 0 and MAXCLUSTERS-1
* @param maxclusters The total number of clusters that are active, which may be on seperate processes or even separate machines. * @param maxclusters The total number of clusters that are active, which may be on separate processes or even separate machines.
* @param compressed Wether or not to use compression for shards on this cluster. Saves a ton of bandwidth at the cost of some CPU * @param compressed Whether or not to use compression for shards on this cluster. Saves a ton of bandwidth at the cost of some CPU
* @param policy Set the user caching policy for the cluster, either lazy (only cache users/members when they message the bot) or aggressive (request whole member lists on seeing new guilds too) * @param policy Set the user caching policy for the cluster, either lazy (only cache users/members when they message the bot) or aggressive (request whole member lists on seeing new guilds too)
*/ */
cluster(const std::string &token, uint32_t intents = i_default_intents, uint32_t shards = 0, uint32_t cluster_id = 0, uint32_t maxclusters = 1, bool compressed = true, cache_policy_t policy = {cp_aggressive, cp_aggressive, cp_aggressive}); cluster(const std::string &token, uint32_t intents = i_default_intents, uint32_t shards = 0, uint32_t cluster_id = 0, uint32_t maxclusters = 1, bool compressed = true, cache_policy_t policy = {cp_aggressive, cp_aggressive, cp_aggressive});
@ -1968,7 +1968,7 @@ public:
void thread_create(const std::string& thread_name, snowflake channel_id, uint16_t auto_archive_duration, channel_type thread_type, command_completion_event_t callback = {}); void thread_create(const std::string& thread_name, snowflake channel_id, uint16_t auto_archive_duration, channel_type thread_type, command_completion_event_t callback = {});
/** /**
* @brief Create a thread with a message (Discord: ID of a thread is same as mesage ID) * @brief Create a thread with a message (Discord: ID of a thread is same as message ID)
* *
* @param thread_name Name of the thread * @param thread_name Name of the thread
* @param channel_id Channel in which thread to create * @param channel_id Channel in which thread to create

View File

@ -30,11 +30,29 @@
namespace dpp { namespace dpp {
/**
* @brief dpp::resolved_user contains both a dpp::guild_member and a dpp::user.
* The user can be used to obtain in-depth user details such as if they are nitro,
* and the guild member information to check their roles on a guild etc.
* The Discord API provides both if a parameter is a user ping,
* so we offer both in a combined structure.
*/
struct CoreExport resolved_user {
/**
* @brief Holds user information
*/
dpp::user user;
/**
* @brief Holds member information
*/
dpp::guild_member member;
};
/** /**
* @brief Represents a received parameter. * @brief Represents a received parameter.
* We use variant so that multiple non-related types can be contained within. * We use variant so that multiple non-related types can be contained within.
*/ */
typedef std::variant<std::string, dpp::role, dpp::channel, dpp::user, int32_t, bool> command_parameter; typedef std::variant<std::monostate, std::string, dpp::role, dpp::channel, dpp::resolved_user, int32_t, bool> command_parameter;
/** /**
* @brief Parameter types when registering a command. * @brief Parameter types when registering a command.
@ -102,7 +120,7 @@ typedef std::vector<std::pair<std::string, param_info>> parameter_registration_t
/** /**
* @brief Parameter list for a called command. * @brief Parameter list for a called command.
* See dpp::parameter_registration_t for an explaination as to why vector is used. * See dpp::parameter_registration_t for an explanation as to why vector is used.
*/ */
typedef std::vector<std::pair<std::string, command_parameter>> parameter_list_t; typedef std::vector<std::pair<std::string, command_parameter>> parameter_list_t;
@ -277,9 +295,25 @@ public:
* to the user if you do not emit some form of reply within 3 seconds. * to the user if you do not emit some form of reply within 3 seconds.
* *
* @param m message to reply with. * @param m message to reply with.
* @param interaction true if the reply is generated by an interaction * @param source source of the command
*/ */
void reply(const dpp::message &m, command_source source); void reply(const dpp::message &m, command_source source);
/**
* @brief Reply to a command without a message, causing the discord client
* to display "Bot name is thinking...".
* The "thinking" message will persist for a maximum of 15 minutes.
* This counts as a reply for a slash command. Slash commands will emit an
* ugly error to the user if you do not emit some form of reply within 3
* seconds.
*
* @param source source of the command
*/
void thinking(command_source source);
/* Easter egg */
void thonk(command_source source);
}; };
}; };

View File

@ -186,7 +186,7 @@ namespace dpp {
* @brief Convert a byte count to display value * @brief Convert a byte count to display value
* *
* @param c number of bytes * @param c number of bytes
* @return std::string display value suffixed with M, G, T where neccessary * @return std::string display value suffixed with M, G, T where necessary
*/ */
std::string CoreExport bytes(uint64_t c); std::string CoreExport bytes(uint64_t c);
@ -257,7 +257,7 @@ namespace dpp {
* @param str string to return substring from * @param str string to return substring from
* @param start start codepoint offset * @param start start codepoint offset
* @param length length in codepoints * @param length length in codepoints
* @return std::string Substring in UTF-8 or emtpy string if invalid UTF-8 passed in * @return std::string Substring in UTF-8 or empty string if invalid UTF-8 passed in
*/ */
std::string CoreExport utf8substr(const std::string& str, std::string::size_type start, std::string::size_type length); std::string CoreExport utf8substr(const std::string& str, std::string::size_type start, std::string::size_type length);
}; };

View File

@ -201,7 +201,7 @@ class CoreExport discord_voice_client : public websocket_client
int UDPSend(const char* data, size_t length); int UDPSend(const char* data, size_t length);
/** /**
* @brief Receieve data from UDP socket immediately. * @brief Receive data from UDP socket immediately.
* *
* @param data data to receive * @param data data to receive
* @param max_length size of data receiving buffer * @param max_length size of data receiving buffer

View File

@ -1095,7 +1095,7 @@ public:
* @param event Event parameters * @param event Event parameters
*/ */
std::function<void(const voice_ready_t& event)> voice_ready; std::function<void(const voice_ready_t& event)> voice_ready;
/** @brief Event handler function pointer for voice receieve event /** @brief Event handler function pointer for voice receive event
* @param event Event parameters * @param event Event parameters
*/ */
std::function<void(const voice_receive_t& event)> voice_receive; std::function<void(const voice_receive_t& event)> voice_receive;

View File

@ -207,7 +207,7 @@ public:
/** Setting for how notifications are to be delivered to users */ /** Setting for how notifications are to be delivered to users */
uint8_t default_message_notifications; uint8_t default_message_notifications;
/** Wether or not explicit content filtering is enable and what setting it is */ /** Whether or not explicit content filtering is enable and what setting it is */
uint8_t explicit_content_filter; uint8_t explicit_content_filter;
/** If multi factor authentication is required for moderators or not */ /** If multi factor authentication is required for moderators or not */

View File

@ -474,7 +474,7 @@ struct CoreExport embed {
/** Add an embed field. Returns the embed itself so these method calls may be "chained" /** Add an embed field. Returns the embed itself so these method calls may be "chained"
* @param name The name of the field * @param name The name of the field
* @param value The value of the field (max length 1000) * @param value The value of the field (max length 1000)
* @param is_inline Wether or not to display the field 'inline' or on its own line * @param is_inline Whether or not to display the field 'inline' or on its own line
* @return A reference to self * @return A reference to self
*/ */
embed& add_field(const std::string& name, const std::string &value, bool is_inline = false); embed& add_field(const std::string& name, const std::string &value, bool is_inline = false);
@ -569,6 +569,8 @@ struct CoreExport attachment {
uint32_t height; uint32_t height;
/** MIME type of the attachment, if applicable */ /** MIME type of the attachment, if applicable */
std::string content_type; std::string content_type;
/** Whether this attachment is ephemeral, if applicable */
bool ephemeral;
/** /**
* @brief Constructs a new attachment object. * @brief Constructs a new attachment object.
@ -724,7 +726,7 @@ enum message_flags {
/// this message originated from a message in another channel (via Channel Following) /// this message originated from a message in another channel (via Channel Following)
m_is_crosspost = 1 << 1, m_is_crosspost = 1 << 1,
/// do not include any embeds when serializing this message /// do not include any embeds when serializing this message
m_supress_embeds = 1 << 2, m_suppress_embeds = 1 << 2,
/// the source message for this crosspost has been deleted (via Channel Following) /// the source message for this crosspost has been deleted (via Channel Following)
m_source_message_deleted = 1 << 3, m_source_message_deleted = 1 << 3,
/// this message came from the urgent message system /// this message came from the urgent message system
@ -736,7 +738,7 @@ enum message_flags {
}; };
/** /**
* @brief Mesage types for dpp::message::type * @brief Message types for dpp::message::type
*/ */
enum message_type { enum message_type {
/// Default /// Default
@ -970,9 +972,9 @@ struct CoreExport message {
/** /**
* @brief Set the allowed mentions object for pings on the message * @brief Set the allowed mentions object for pings on the message
* *
* @param _parse_users wether or not to parse users in the message content or embeds * @param _parse_users whether or not to parse users in the message content or embeds
* @param _parse_roles wether or not to parse roles in the message content or embeds * @param _parse_roles whether or not to parse roles in the message content or embeds
* @param _parse_everyone wether or not to parse everyone/here in the message content or embeds * @param _parse_everyone whether or not to parse everyone/here in the message content or embeds
* @param _replied_user if set to true and this is a reply, then ping the user we reply to * @param _replied_user if set to true and this is a reply, then ping the user we reply to
* @param users list of user ids to allow pings for * @param users list of user ids to allow pings for
* @param roles list of role ids to allow pings for * @param roles list of role ids to allow pings for
@ -982,7 +984,7 @@ struct CoreExport message {
/** Fill this object from json. /** Fill this object from json.
* @param j JSON object to fill from * @param j JSON object to fill from
* @param cp Cache policy for user records, wether or not we cache users when a message is received * @param cp Cache policy for user records, whether or not we cache users when a message is received
* @return A reference to self * @return A reference to self
*/ */
message& fill_from_json(nlohmann::json* j, cache_policy_t cp = {cp_aggressive, cp_aggressive, cp_aggressive}); message& fill_from_json(nlohmann::json* j, cache_policy_t cp = {cp_aggressive, cp_aggressive, cp_aggressive});
@ -1012,7 +1014,7 @@ struct CoreExport message {
* *
* @return true if embeds removed * @return true if embeds removed
*/ */
bool supress_embeds() const; bool suppress_embeds() const;
/** /**
* @brief True if source message was deleted * @brief True if source message was deleted

View File

@ -54,8 +54,10 @@ enum command_option_type : uint8_t {
* @brief This type is a variant that can hold any of the potential * @brief This type is a variant that can hold any of the potential
* native data types represented by the enum above. * native data types represented by the enum above.
* It is used in interactions. * It is used in interactions.
*
* std::monostate indicates an invalid parameter value, e.g. an unfilled optional parameter.
*/ */
typedef std::variant<std::string, int32_t, bool, snowflake> command_value; typedef std::variant<std::monostate, std::string, int32_t, bool, snowflake> command_value;
/** /**
* @brief This struct represents choices in a multiple choice option * @brief This struct represents choices in a multiple choice option
@ -157,8 +159,6 @@ void to_json(nlohmann::json& j, const command_option& opt);
*/ */
enum interaction_response_type { enum interaction_response_type {
ir_pong = 1, //!< ACK a Ping ir_pong = 1, //!< ACK a Ping
ir_acknowledge = 2, //!< DEPRECATED ACK a command without sending a message, eating the user's input
ir_channel_message = 3, //!< DEPRECATED respond with a message, eating the user's input
ir_channel_message_with_source = 4, //!< respond to an interaction with a message ir_channel_message_with_source = 4, //!< respond to an interaction with a message
ir_deferred_channel_message_with_source = 5, //!< ACK an interaction and edit a response later, the user sees a loading state ir_deferred_channel_message_with_source = 5, //!< ACK an interaction and edit a response later, the user sees a loading state
ir_deferred_update_message = 6, //!< for components, ACK an interaction and edit the original message later; the user does not see a loading state ir_deferred_update_message = 6, //!< for components, ACK an interaction and edit the original message later; the user does not see a loading state
@ -226,11 +226,25 @@ struct CoreExport interaction_response {
}; };
/** /**
* @brief Resolved snowflake ids to usernames. * @brief Resolved snowflake ids to users, guild members, roles and channels.
* TODO: Needs implementation. Not needed something that
* functions as we have cache.
*/ */
struct CoreExport command_resolved { struct CoreExport command_resolved {
/**
* @brief Resolved users
*/
std::map<dpp::snowflake, dpp::user> users;
/**
* @brief Resolved guild members
*/
std::map<dpp::snowflake, dpp::guild_member> members;
/**
* @brief Resolved roles
*/
std::map<dpp::snowflake, dpp::role> roles;
/**
* @brief Resolved channels
*/
std::map<dpp::snowflake, dpp::channel> channels;
}; };
/** /**
@ -272,7 +286,6 @@ enum interaction_type {
struct CoreExport command_interaction { struct CoreExport command_interaction {
snowflake id; //!< the ID of the invoked command snowflake id; //!< the ID of the invoked command
std::string name; //!< the name of the invoked command std::string name; //!< the name of the invoked command
command_resolved resolved; //!< Optional: converted users + roles + channels
std::vector<command_data_option> options; //!< Optional: the params + values from the user std::vector<command_data_option> options; //!< Optional: the params + values from the user
}; };
@ -326,6 +339,7 @@ public:
user usr; //!< Optional: user object for the invoking user, if invoked in a DM user usr; //!< Optional: user object for the invoking user, if invoked in a DM
std::string token; //!< a continuation token for responding to the interaction std::string token; //!< a continuation token for responding to the interaction
uint8_t version; //!< read-only property, always 1 uint8_t version; //!< read-only property, always 1
command_resolved resolved; //!< Resolved user/role etc
/** /**
* @brief Fill object properties from JSON * @brief Fill object properties from JSON
@ -513,7 +527,7 @@ public:
/** /**
* @brief Disable default permissions, command will be unusable unless * @brief Disable default permissions, command will be unusable unless
* permissions are overriden with add_permission and * permissions are overridden with add_permission and
* dpp::guild_command_edit_permissions * dpp::guild_command_edit_permissions
* *
* @return slashcommand& reference to self for chaining of calls * @return slashcommand& reference to self for chaining of calls

View File

@ -21,9 +21,9 @@
#pragma once #pragma once
#if !defined(DPP_VERSION_LONG) #if !defined(DPP_VERSION_LONG)
#define DPP_VERSION_LONG 0x00090003 #define DPP_VERSION_LONG 0x00090004
#define DPP_VERSION_SHORT 090003 #define DPP_VERSION_SHORT 090004
#define DPP_VERSION_TEXT "D++ 9.0.3 (05-Sep-2021)" #define DPP_VERSION_TEXT "D++ 9.0.5 (14-Sep-2021)"
#define DPP_VERSION_MAJOR ((DPP_VERSION_LONG & 0x00ff0000) >> 16) #define DPP_VERSION_MAJOR ((DPP_VERSION_LONG & 0x00ff0000) >> 16)
#define DPP_VERSION_MINOR ((DPP_VERSION_LONG & 0x0000ff00) >> 8) #define DPP_VERSION_MINOR ((DPP_VERSION_LONG & 0x0000ff00) >> 8)

View File

@ -34,7 +34,7 @@ enum voicestate_flags {
vs_self_deaf = 0b00001000, //!< Self Deafened vs_self_deaf = 0b00001000, //!< Self Deafened
vs_self_stream = 0b00010000, //!< Self Streaming vs_self_stream = 0b00010000, //!< Self Streaming
vs_self_video = 0b00100000, //!< Self Video vs_self_video = 0b00100000, //!< Self Video
vs_supress = 0b01000000 //!< Supression vs_suppress = 0b01000000 //!< Suppression
}; };
/** /**
@ -94,9 +94,9 @@ public:
/// Return true if the user is in video /// Return true if the user is in video
bool self_video() const; bool self_video() const;
/// Return true if user is surpressed. /// Return true if user is suppressed.
/// "HELP HELP I'M BEING SUPRESSED!" /// "HELP HELP I'M BEING SUPPRESSED!"
bool is_supressed() const; bool is_suppressed() const;
}; };
/** A container of voicestates */ /** A container of voicestates */

View File

@ -327,7 +327,7 @@ void cluster::interaction_response_edit(const std::string &token, const message
void cluster::global_command_create(slashcommand &s, command_completion_event_t callback) { void cluster::global_command_create(slashcommand &s, command_completion_event_t callback) {
this->post_rest(API_PATH "/applications", std::to_string(me.id), "commands", m_post, s.build_json(false), [s, callback] (json &j, const http_request_completion_t& http) mutable { this->post_rest(API_PATH "/applications", std::to_string(s.application_id ? s.application_id : me.id), "commands", m_post, s.build_json(false), [s, callback] (json &j, const http_request_completion_t& http) mutable {
if (j.contains("id")) { if (j.contains("id")) {
s.id = SnowflakeNotNull(&j, "id"); s.id = SnowflakeNotNull(&j, "id");
} }
@ -339,7 +339,7 @@ void cluster::global_command_create(slashcommand &s, command_completion_event_t
} }
void cluster::guild_command_create(slashcommand &s, snowflake guild_id, command_completion_event_t callback) { void cluster::guild_command_create(slashcommand &s, snowflake guild_id, command_completion_event_t callback) {
this->post_rest(API_PATH "/applications", std::to_string(me.id), "guilds/" + std::to_string(guild_id) + "/commands", m_post, s.build_json(false), [s, this, guild_id, callback] (json &j, const http_request_completion_t& http) mutable { this->post_rest(API_PATH "/applications", std::to_string(s.application_id ? s.application_id : me.id), "guilds/" + std::to_string(guild_id) + "/commands", m_post, s.build_json(false), [s, this, guild_id, callback] (json &j, const http_request_completion_t& http) mutable {
if (j.contains("id")) { if (j.contains("id")) {
s.id = SnowflakeNotNull(&j, "id"); s.id = SnowflakeNotNull(&j, "id");
} }
@ -355,11 +355,14 @@ void cluster::guild_command_create(slashcommand &s, snowflake guild_id, command_
} }
void cluster::guild_bulk_command_create(const std::vector<slashcommand> &commands, snowflake guild_id, command_completion_event_t callback) { void cluster::guild_bulk_command_create(const std::vector<slashcommand> &commands, snowflake guild_id, command_completion_event_t callback) {
if (commands.empty()) {
return;
}
json j = json::array(); json j = json::array();
for (auto & s : commands) { for (auto & s : commands) {
j.push_back(json::parse(s.build_json(false))); j.push_back(json::parse(s.build_json(false)));
} }
this->post_rest(API_PATH "/applications", std::to_string(me.id), "guilds/" + std::to_string(guild_id) + "/commands", m_put, j.dump(), [this, callback] (json &j, const http_request_completion_t& http) mutable { this->post_rest(API_PATH "/applications", std::to_string(commands[0].application_id ? commands[0].application_id : me.id), "guilds/" + std::to_string(guild_id) + "/commands", m_put, j.dump(), [this, callback] (json &j, const http_request_completion_t& http) mutable {
slashcommand_map slashcommands; slashcommand_map slashcommands;
for (auto & curr_slashcommand : j) { for (auto & curr_slashcommand : j) {
slashcommands[SnowflakeNotNull(&curr_slashcommand, "id")] = slashcommand().fill_from_json(&curr_slashcommand); slashcommands[SnowflakeNotNull(&curr_slashcommand, "id")] = slashcommand().fill_from_json(&curr_slashcommand);
@ -371,11 +374,14 @@ void cluster::guild_bulk_command_create(const std::vector<slashcommand> &command
} }
void cluster::global_bulk_command_create(const std::vector<slashcommand> &commands, command_completion_event_t callback) { void cluster::global_bulk_command_create(const std::vector<slashcommand> &commands, command_completion_event_t callback) {
if (commands.empty()) {
return;
}
json j = json::array(); json j = json::array();
for (auto & s : commands) { for (auto & s : commands) {
j.push_back(json::parse(s.build_json(false))); j.push_back(json::parse(s.build_json(false)));
} }
this->post_rest(API_PATH "/applications", std::to_string(me.id), "commands", m_put, j.dump(), [this, callback] (json &j, const http_request_completion_t& http) mutable { this->post_rest(API_PATH "/applications", std::to_string(commands[0].application_id ? commands[0].application_id : me.id), "commands", m_put, j.dump(), [this, callback] (json &j, const http_request_completion_t& http) mutable {
slashcommand_map slashcommands; slashcommand_map slashcommands;
for (auto & curr_slashcommand : j) { for (auto & curr_slashcommand : j) {
slashcommands[SnowflakeNotNull(&curr_slashcommand, "id")] = slashcommand().fill_from_json(&curr_slashcommand); slashcommands[SnowflakeNotNull(&curr_slashcommand, "id")] = slashcommand().fill_from_json(&curr_slashcommand);
@ -387,7 +393,7 @@ void cluster::global_bulk_command_create(const std::vector<slashcommand> &comman
} }
void cluster::global_command_edit(const slashcommand &s, command_completion_event_t callback) { void cluster::global_command_edit(const slashcommand &s, command_completion_event_t callback) {
this->post_rest(API_PATH "/applications", std::to_string(me.id), "commands/" + std::to_string(s.id), m_patch, s.build_json(true), [callback](json &j, const http_request_completion_t& http) { this->post_rest(API_PATH "/applications", std::to_string(s.application_id ? s.application_id : me.id), "commands/" + std::to_string(s.id), m_patch, s.build_json(true), [callback](json &j, const http_request_completion_t& http) {
if (callback) { if (callback) {
callback(confirmation_callback_t("confirmation", confirmation(), http)); callback(confirmation_callback_t("confirmation", confirmation(), http));
} }
@ -395,7 +401,7 @@ void cluster::global_command_edit(const slashcommand &s, command_completion_even
} }
void cluster::guild_command_edit(const slashcommand &s, snowflake guild_id, command_completion_event_t callback) { void cluster::guild_command_edit(const slashcommand &s, snowflake guild_id, command_completion_event_t callback) {
this->post_rest(API_PATH "/applications", std::to_string(me.id), "guilds/" + std::to_string(guild_id) + "/commands/" + std::to_string(s.id), m_patch, s.build_json(true), [callback](json &j, const http_request_completion_t& http) { this->post_rest(API_PATH "/applications", std::to_string(s.application_id ? s.application_id : me.id), "guilds/" + std::to_string(guild_id) + "/commands/" + std::to_string(s.id), m_patch, s.build_json(true), [callback](json &j, const http_request_completion_t& http) {
if (callback) { if (callback) {
callback(confirmation_callback_t("confirmation", confirmation(), http)); callback(confirmation_callback_t("confirmation", confirmation(), http));
} }
@ -414,7 +420,7 @@ void cluster::guild_command_edit_permissions(const slashcommand &s, snowflake gu
} }
} }
this->post_rest(API_PATH "/applications", std::to_string(me.id), "guilds/" + std::to_string(guild_id) + "/commands/" + std::to_string(s.id) + "/permissions", m_put, j.dump(), [callback](json &j, const http_request_completion_t& http) { this->post_rest(API_PATH "/applications", std::to_string(s.application_id ? s.application_id : me.id), "guilds/" + std::to_string(guild_id) + "/commands/" + std::to_string(s.id) + "/permissions", m_put, j.dump(), [callback](json &j, const http_request_completion_t& http) {
if (callback) { if (callback) {
callback(confirmation_callback_t("confirmation", confirmation(), http)); callback(confirmation_callback_t("confirmation", confirmation(), http));
} }
@ -1040,7 +1046,7 @@ void cluster::guild_ban_add(snowflake guild_id, snowflake user_id, uint32_t dele
j["reason"] = reason; j["reason"] = reason;
if (delete_message_days) if (delete_message_days)
j["delete_message_days"] = delete_message_days; j["delete_message_days"] = delete_message_days;
this->post_rest(API_PATH "/guilds", std::to_string(guild_id), "bans/" + std::to_string(user_id), m_put, "", [callback](json &j, const http_request_completion_t& http) { this->post_rest(API_PATH "/guilds", std::to_string(guild_id), "bans/" + std::to_string(user_id), m_put, j.dump(), [callback](json &j, const http_request_completion_t& http) {
if (callback) { if (callback) {
callback(confirmation_callback_t("confirmation", confirmation(), http)); callback(confirmation_callback_t("confirmation", confirmation(), http));
} }
@ -1656,7 +1662,7 @@ void cluster::execute_webhook(const class webhook &wh, const struct message& m,
if (thread_id) { if (thread_id) {
parameters.append("&thread_id=" + std::to_string(thread_id)); parameters.append("&thread_id=" + std::to_string(thread_id));
} }
this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(token), m_post, m.build_json(false), [callback](json &j, const http_request_completion_t& http) { this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(!wh.token.empty() ? wh.token: token), m_post, m.build_json(false), [callback](json &j, const http_request_completion_t& http) {
if (callback) { if (callback) {
callback(confirmation_callback_t("message", message().fill_from_json(&j), http)); callback(confirmation_callback_t("message", message().fill_from_json(&j), http));
} }
@ -1665,7 +1671,7 @@ void cluster::execute_webhook(const class webhook &wh, const struct message& m,
void cluster::get_webhook_message(const class webhook &wh, command_completion_event_t callback) void cluster::get_webhook_message(const class webhook &wh, command_completion_event_t callback)
{ {
this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(token) + "/messages/@original", m_get, "", [callback](json &j, const http_request_completion_t &http){ this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(!wh.token.empty() ? wh.token: token) + "/messages/@original", m_get, "", [callback](json &j, const http_request_completion_t &http){
if (callback){ if (callback){
callback(confirmation_callback_t("message", message().fill_from_json(&j), http)); callback(confirmation_callback_t("message", message().fill_from_json(&j), http));
} }
@ -1673,7 +1679,7 @@ void cluster::get_webhook_message(const class webhook &wh, command_completion_ev
} }
void cluster::edit_webhook_message(const class webhook &wh, const struct message& m, command_completion_event_t callback) { void cluster::edit_webhook_message(const class webhook &wh, const struct message& m, command_completion_event_t callback) {
this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(token) + "/messages/" + std::to_string(m.id), m_patch, m.build_json(false), [callback](json &j, const http_request_completion_t& http) { this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(!wh.token.empty() ? wh.token: token) + "/messages/" + std::to_string(m.id), m_patch, m.build_json(false), [callback](json &j, const http_request_completion_t& http) {
if (callback) { if (callback) {
callback(confirmation_callback_t("message", message().fill_from_json(&j), http)); callback(confirmation_callback_t("message", message().fill_from_json(&j), http));
} }
@ -1681,7 +1687,7 @@ void cluster::edit_webhook_message(const class webhook &wh, const struct message
} }
void cluster::delete_webhook_message(const class webhook &wh, snowflake message_id, command_completion_event_t callback) { void cluster::delete_webhook_message(const class webhook &wh, snowflake message_id, command_completion_event_t callback) {
this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(token) + "/messages/" + std::to_string(message_id), m_delete, "", [callback](json &j, const http_request_completion_t& http) { this->post_rest(API_PATH "/webhooks", std::to_string(wh.id), dpp::url_encode(!wh.token.empty() ? wh.token: token) + "/messages/" + std::to_string(message_id), m_delete, "", [callback](json &j, const http_request_completion_t& http) {
if (callback) { if (callback) {
callback(confirmation_callback_t("confirmation", confirmation(), http)); callback(confirmation_callback_t("confirmation", confirmation(), http));
} }

View File

@ -155,6 +155,10 @@ bool commandhandler::string_has_prefix(std::string &str)
return false; return false;
} }
/* Note that message based command routing relies on cache to resolve ping types (e.g. user, channel ping).
* There isn't really a way around this for many things because there is no 'resolved' member for it.
* We only get resolved information for the user issuing the command.
*/
void commandhandler::route(const dpp::message& msg) void commandhandler::route(const dpp::message& msg)
{ {
std::string msg_content = msg.content; std::string msg_content = msg.content;
@ -226,8 +230,15 @@ void commandhandler::route(const dpp::message& msg)
snowflake uid = from_string<uint64_t>(x.substr(2, x.length() - 1), std::dec); snowflake uid = from_string<uint64_t>(x.substr(2, x.length() - 1), std::dec);
user* u = dpp::find_user(uid); user* u = dpp::find_user(uid);
if (u) { if (u) {
param = *u; dpp::resolved_user m;
m.user = *u;
dpp::guild* g = dpp::find_guild(msg.guild_id);
if (g->members.find(uid) != g->members.end()) {
m.member = g->members[uid];
}
param = m;
} }
} }
} }
break; break;
@ -270,6 +281,7 @@ void commandhandler::route(const interaction_create_t & event)
* dont have prefixes at all. * dont have prefixes at all.
*/ */
command_interaction cmd = std::get<command_interaction>(event.command.data); command_interaction cmd = std::get<command_interaction>(event.command.data);
auto found_cmd = commands.find(lowercase(cmd.name)); auto found_cmd = commands.find(lowercase(cmd.name));
if (found_cmd != commands.end()) { if (found_cmd != commands.end()) {
/* Command found; parse parameters */ /* Command found; parse parameters */
@ -277,57 +289,86 @@ void commandhandler::route(const interaction_create_t & event)
for (auto& p : found_cmd->second.parameters) { for (auto& p : found_cmd->second.parameters) {
command_parameter param; command_parameter param;
const command_value& slash_parameter = event.get_parameter(p.first); const command_value& slash_parameter = event.get_parameter(p.first);
dpp::command_resolved res = event.command.resolved;
if (p.second.optional && slash_parameter.valueless_by_exception()) { if (p.second.optional && slash_parameter.index() == 0 /* std::monostate */) {
/* Missing optional parameter, skip this */ /* Missing optional parameter, skip this */
continue; continue;
} }
try { switch (p.second.type) {
switch (p.second.type) { case pt_string: {
case pt_string: { std::string s = std::get<std::string>(slash_parameter);
std::string s = std::get<std::string>(slash_parameter); param = s;
param = s;
}
break;
case pt_role: {
snowflake rid = std::get<snowflake>(slash_parameter);
role* r = dpp::find_role(rid);
if (r) {
param = *r;
}
}
break;
case pt_channel: {
snowflake cid = std::get<snowflake>(slash_parameter);
channel* c = dpp::find_channel(cid);
if (c) {
param = *c;
}
}
break;
case pt_user: {
snowflake uid = std::get<snowflake>(slash_parameter);
user* u = dpp::find_user(uid);
if (u) {
param = *u;
}
}
break;
case pt_integer: {
int32_t i = std::get<int32_t>(slash_parameter);
param = i;
}
case pt_boolean: {
bool b = std::get<bool>(slash_parameter);
param = b;
}
break;
} }
} break;
catch (const std::bad_variant_access& e) { case pt_role: {
/* Missing optional parameter, skip this */ snowflake rid = std::get<snowflake>(slash_parameter);
continue; role* r = dpp::find_role(rid);
if (r) {
/* Use cache if the role is in the cache */
param = *r;
} else {
/* Otherwise use interaction resolved fields */
if (res.roles.find(rid) != res.roles.end()) {
param = res.roles[rid];
}
}
}
break;
case pt_channel: {
snowflake cid = std::get<snowflake>(slash_parameter);
channel* c = dpp::find_channel(cid);
if (c) {
/* Use cache if the channel is in the cache */
param = *c;
} else {
/* Otherwise use interaction resolved fields */
if (res.channels.find(cid) != res.channels.end()) {
param = res.channels[cid];
}
}
}
break;
case pt_user: {
snowflake uid = std::get<snowflake>(slash_parameter);
/* TODO: Make this used resolved, not cache */
user* u = dpp::find_user(uid);
if (u) {
/* Use the cache if the user is in the cache */
dpp::resolved_user m;
m.user = *u;
dpp::guild* g = dpp::find_guild(event.command.guild_id);
if (g->members.find(uid) != g->members.end()) {
m.member = g->members[uid];
}
param = m;
} else {
/* Otherwise use interaction resolved fields */
if (
event.command.resolved.users.find(uid) != event.command.resolved.users.end()
&&
event.command.resolved.members.find(uid) != event.command.resolved.members.end()
) {
/* Fill in both member and user info */
dpp::resolved_user m;
m.member = res.members[uid];
m.user = res.users[uid];
param = m;
}
}
}
break;
case pt_integer: {
int32_t i = std::get<int32_t>(slash_parameter);
param = i;
}
break;
case pt_boolean: {
bool b = std::get<bool>(slash_parameter);
param = b;
}
break;
} }
/* Add parameter to the list */ /* Add parameter to the list */
@ -357,4 +398,20 @@ void commandhandler::reply(const dpp::message &m, command_source source)
} }
} }
void commandhandler::thinking(command_source source)
{
dpp::message msg;
msg.content = "*";
msg.guild_id = source.guild_id;
msg.channel_id = source.channel_id;
if (!source.command_token.empty() && source.command_id) {
owner->interaction_response_create(source.command_id, source.command_token, dpp::interaction_response(ir_deferred_channel_message_with_source, msg));
}
}
void commandhandler::thonk(command_source source)
{
thinking(source);
}
}; };

View File

@ -329,7 +329,7 @@ void discord_client::Error(uint32_t errorcode)
{ 1003, "Endpoint received an unsupported frame" }, { 1003, "Endpoint received an unsupported frame" },
{ 1004, "Reserved code" }, { 1004, "Reserved code" },
{ 1005, "Expected close status, received none" }, { 1005, "Expected close status, received none" },
{ 1006, "No close code frame has been receieved" }, { 1006, "No close code frame has been received" },
{ 1007, "Endpoint received inconsistent message (e.g. malformed UTF-8)" }, { 1007, "Endpoint received inconsistent message (e.g. malformed UTF-8)" },
{ 1008, "Generic error" }, { 1008, "Generic error" },
{ 1009, "Endpoint won't process large frame" }, { 1009, "Endpoint won't process large frame" },

View File

@ -42,7 +42,7 @@ char* strptime(const char* s, const char* f, struct tm* tm) {
input.imbue(std::locale(setlocale(LC_ALL, nullptr))); input.imbue(std::locale(setlocale(LC_ALL, nullptr)));
input >> std::get_time(tm, f); input >> std::get_time(tm, f);
if (input.fail()) { if (input.fail()) {
return const_cast< char* >(""); return const_cast<char*>("");
} }
return (char*)(s + input.tellg()); return (char*)(s + input.tellg());
} }
@ -79,7 +79,7 @@ std::string StringNotNull(const json* j, const char *keyname) {
if (k != j->end()) { if (k != j->end()) {
return !k->is_null() && k->is_string() ? k->get<std::string>() : ""; return !k->is_null() && k->is_string() ? k->get<std::string>() : "";
} else { } else {
return ""; return const_cast< char* >("");
} }
} }
@ -311,7 +311,7 @@ void discord_client::HandleEvent(const std::string &event, json &j, const std::s
auto ev_iter = eventmap.find(event); auto ev_iter = eventmap.find(event);
if (ev_iter != eventmap.end()) { if (ev_iter != eventmap.end()) {
/* A handler with nullptr is silently ignored. We don't plan to make a handler for it /* A handler with nullptr is silently ignored. We don't plan to make a handler for it
* so this usually some user-only thing thats crept into the API and shown to bots * so this usually some user-only thing that's crept into the API and shown to bots
* that we dont care about. * that we dont care about.
*/ */
if (ev_iter->second != nullptr) { if (ev_iter->second != nullptr) {

View File

@ -450,7 +450,7 @@ void discord_voice_client::Error(uint32_t errorcode)
{ 1003, "Endpoint received an unsupported frame" }, { 1003, "Endpoint received an unsupported frame" },
{ 1004, "Reserved code" }, { 1004, "Reserved code" },
{ 1005, "Expected close status, received none" }, { 1005, "Expected close status, received none" },
{ 1006, "No close code frame has been receieved" }, { 1006, "No close code frame has been received" },
{ 1007, "Endpoint received inconsistent message (e.g. malformed UTF-8)" }, { 1007, "Endpoint received inconsistent message (e.g. malformed UTF-8)" },
{ 1008, "Generic error" }, { 1008, "Generic error" },
{ 1009, "Endpoint won't process large frame" }, { 1009, "Endpoint won't process large frame" },

View File

@ -386,6 +386,8 @@ int close_socket(socket_t sock) {
if (sock >= 0 && sock < FD_SETSIZE) { if (sock >= 0 && sock < FD_SETSIZE) {
return closesocket(sock); return closesocket(sock);
} }
assert(0);
return -1;
#else #else
return close(sock); return close(sock);
#endif #endif

View File

@ -517,11 +517,13 @@ reaction::reaction(json* j) {
emoji_name = StringNotNull(&emoji, "name"); emoji_name = StringNotNull(&emoji, "name");
} }
attachment::attachment() { attachment::attachment()
id = 0; : id(0)
size = 0; , size(0)
width = 0; , width(0)
height = 0; , height(0)
, ephemeral(false)
{
} }
attachment::attachment(json *j) : attachment() { attachment::attachment(json *j) : attachment() {
@ -533,6 +535,7 @@ attachment::attachment(json *j) : attachment() {
this->width = Int32NotNull(j, "width"); this->width = Int32NotNull(j, "width");
this->height = Int32NotNull(j, "height"); this->height = Int32NotNull(j, "height");
this->content_type = StringNotNull(j, "content_type"); this->content_type = StringNotNull(j, "content_type");
this->ephemeral = BoolNotNull(j, "ephemeral");
} }
std::string message::build_json(bool with_id, bool is_interaction_response) const { std::string message::build_json(bool with_id, bool is_interaction_response) const {
@ -553,6 +556,11 @@ std::string message::build_json(bool with_id, bool is_interaction_response) cons
j["content"] = content; j["content"] = content;
} }
if(author != nullptr) {
/* Used for webhooks */
j["username"] = author->username;
}
/* Populate message reference */ /* Populate message reference */
if (message_reference.channel_id || message_reference.guild_id || message_reference.message_id) { if (message_reference.channel_id || message_reference.guild_id || message_reference.message_id) {
j["message_reference"] = json::object(); j["message_reference"] = json::object();
@ -740,8 +748,8 @@ bool message::is_crosspost() const {
} }
bool message::supress_embeds() const { bool message::suppress_embeds() const {
return flags & m_supress_embeds; return flags & m_suppress_embeds;
} }
bool message::is_source_message_deleted() const { bool message::is_source_message_deleted() const {

View File

@ -285,7 +285,7 @@ void request_queue::in_loop()
auto currbucket = buckets.find(bucket.first); auto currbucket = buckets.find(bucket.first);
if (currbucket != buckets.end()) { if (currbucket != buckets.end()) {
/* Theres a bucket for this request. Check its status. If the bucket says to wait, /* There's a bucket for this request. Check its status. If the bucket says to wait,
* skip all requests in this bucket till its ok. * skip all requests in this bucket till its ok.
*/ */
if (currbucket->second.remaining < 1) { if (currbucket->second.remaining < 1) {

View File

@ -125,6 +125,7 @@ void to_json(json& j, const slashcommand& p) {
} }
j["default_permission"] = p.default_permission; j["default_permission"] = p.default_permission;
j["application_id"] = std::to_string(p.application_id);
} }
std::string slashcommand::build_json(bool with_id) const { std::string slashcommand::build_json(bool with_id) const {
@ -271,7 +272,6 @@ void from_json(const nlohmann::json& j, interaction& i) {
SetSnowflakeNotNull(&m, "id", i.message_id); SetSnowflakeNotNull(&m, "id", i.message_id);
} }
i.type = Int8NotNull(&j, "type"); i.type = Int8NotNull(&j, "type");
i.token = StringNotNull(&j, "token"); i.token = StringNotNull(&j, "token");
i.version = Int8NotNull(&j, "version"); i.version = Int8NotNull(&j, "version");
@ -284,6 +284,47 @@ void from_json(const nlohmann::json& j, interaction& i) {
} }
if (j.contains("data") && !j.at("data").is_null()) { if (j.contains("data") && !j.at("data").is_null()) {
const json& data = j["data"];
/* Deal with 'resolved' data, e.g. users, members, roles, channels */
if (data.find("resolved") != data.end()) {
const json& d_resolved = data["resolved"];
/* Users */
if (d_resolved.find("users") != d_resolved.end()) {
for (auto v = d_resolved["users"].begin(); v != d_resolved["users"].end(); ++v) {
json f = *v;
dpp::snowflake id = strtoull(v.key().c_str(), nullptr, 10);
i.resolved.users[id] = dpp::user().fill_from_json(&f);
}
}
/* Roles */
if (d_resolved.find("roles") != d_resolved.end()) {
for (auto v = d_resolved["roles"].begin(); v != d_resolved["roles"].end(); ++v) {
json f = *v;
dpp::snowflake id = strtoull(v.key().c_str(), nullptr, 10);
i.resolved.roles[id] = dpp::role().fill_from_json(i.guild_id, &f);
}
}
/* Channels */
if (d_resolved.find("channels") != d_resolved.end()) {
for (auto v = d_resolved["channels"].begin(); v != d_resolved["channels"].end(); ++v) {
json f = *v;
dpp::snowflake id = strtoull(v.key().c_str(), nullptr, 10);
i.resolved.channels[id] = dpp::channel().fill_from_json(&f);
}
}
/* Members */
if (d_resolved.find("members") != d_resolved.end()) {
for (auto v = d_resolved["members"].begin(); v != d_resolved["members"].end(); ++v) {
json f = *v;
dpp::snowflake id = strtoull(v.key().c_str(), nullptr, 10);
i.resolved.members[id] = dpp::guild_member().fill_from_json(&f, i.guild_id, id);
}
}
}
if (i.type == it_application_command) { if (i.type == it_application_command) {
command_interaction ci; command_interaction ci;
j.at("data").get_to(ci); j.at("data").get_to(ci);

View File

@ -25,7 +25,7 @@
using json = nlohmann::json; using json = nlohmann::json;
/* A mapping of discord's flag values to our bitmap (theyre different bit positions to fit other stuff in) */ /* A mapping of discord's flag values to our bitmap (they're different bit positions to fit other stuff in) */
std::map<uint32_t, dpp::user_flags> usermap = { std::map<uint32_t, dpp::user_flags> usermap = {
{ 1 << 0, dpp::u_discord_employee }, { 1 << 0, dpp::u_discord_employee },
{ 1 << 1, dpp::u_partnered_owner }, { 1 << 1, dpp::u_partnered_owner },
@ -57,7 +57,7 @@ user::~user()
} }
std::string user::get_avatar_url() const { std::string user::get_avatar_url() const {
/* XXX: Discord were supposed to change their CDN over to discord.com, they havent. /* XXX: Discord were supposed to change their CDN over to discord.com, they haven't.
* At some point in the future this URL *will* change! * At some point in the future this URL *will* change!
*/ */
return fmt::format("https://cdn.discordapp.com/avatars/{}/{}{}.{}", return fmt::format("https://cdn.discordapp.com/avatars/{}/{}{}.{}",

View File

@ -51,8 +51,8 @@ voicestate& voicestate::fill_from_json(nlohmann::json* j) {
flags |= vs_self_stream; flags |= vs_self_stream;
if (BoolNotNull(j, "self_video")) if (BoolNotNull(j, "self_video"))
flags |= vs_self_video; flags |= vs_self_video;
if (BoolNotNull(j, "supress")) if (BoolNotNull(j, "suppress"))
flags |= vs_supress; flags |= vs_suppress;
return *this; return *this;
} }
@ -80,8 +80,8 @@ bool voicestate::self_video() const {
return flags & vs_self_video; return flags & vs_self_video;
} }
bool voicestate::is_supressed() const { bool voicestate::is_suppressed() const {
return flags & vs_supress; return flags & vs_suppress;
} }
std::string voicestate::build_json() const { std::string voicestate::build_json() const {

View File

@ -304,7 +304,7 @@ void websocket_client::HandlePingPong(bool ping, const std::string &payload)
{ {
unsigned char out[MAXHEADERSIZE]; unsigned char out[MAXHEADERSIZE];
if (ping) { if (ping) {
/* For receving pings we echo back their payload with the type OP_PONG */ /* For receiving pings we echo back their payload with the type OP_PONG */
size_t s = this->FillHeader(out, payload.length(), OP_PONG); size_t s = this->FillHeader(out, payload.length(), OP_PONG);
std::string header((const char*)out, s); std::string header((const char*)out, s);
ssl_client::write(header); ssl_client::write(header);

517
vendor/MDBC/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,517 @@
# CMakeLists.txt
# This is the LGPL libmariadb project.
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
INCLUDE(CheckFunctionExists)
IF(COMMAND CMAKE_POLICY)
SET(NEW_POLICIES CMP0003 CMP0022 CMP0023 CMP0077 CMP0069 CMP0075)
FOREACH(TYPE OLD NEW)
FOREACH(P ${${TYPE}_POLICIES})
IF(POLICY ${P})
CMAKE_POLICY(SET ${P} ${TYPE})
ENDIF()
ENDFOREACH()
ENDFOREACH()
ENDIF()
PROJECT(mariadb-connector-c C)
# Is C/C built as subproject?
get_directory_property(IS_SUBPROJECT PARENT_DIRECTORY)
# do not inherit include directories from the parent project
SET_PROPERTY(DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
FOREACH(V WITH_MYSQLCOMPAT WITH_MSI WITH_SIGNCODE WITH_RTC WITH_UNIT_TESTS
WITH_DYNCOL WITH_EXTERNAL_ZLIB WITH_CURL WITH_SQLITE WITH_SSL WITH_ICONV
DEFAULT_CHARSET INSTALL_LAYOUT WITH_TEST_SRCPKG)
SET(${V} ${${OPT}${V}})
ENDFOREACH()
#SET(PACKAGE_STATUS_SUFFIX "rc")
SET(CC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
SET(CC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
SET(CPACK_PACKAGE_VERSION_MAJOR 3)
SET(CPACK_PACKAGE_VERSION_MINOR 2)
SET(CPACK_PACKAGE_VERSION_PATCH 3)
SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
MATH(EXPR MARIADB_PACKAGE_VERSION_ID "${CPACK_PACKAGE_VERSION_MAJOR} * 10000 +
${CPACK_PACKAGE_VERSION_MINOR} * 100 +
${CPACK_PACKAGE_VERSION_PATCH}")
MACRO(ADD_OPTION _name _text _default)
IF(NOT DEFINED ${_name})
OPTION(${OPT}${_name} "${_text}" "${_default}")
ELSE()
OPTION(${OPT}${_name} "${_text}" "${${_name}}")
ENDIF()
ENDMACRO()
### Options ###
IF(NOT WIN32)
ADD_OPTION(WITH_MYSQLCOMPAT "creates libmysql* symbolic links" OFF)
ELSE()
ADD_OPTION(WITH_MSI "Build MSI installation package" OFF)
ADD_OPTION(WITH_SIGNCODE "digitally sign files" OFF)
ADD_OPTION(WITH_RTC "enables run time checks for debug builds" OFF)
ADD_OPTION(WITH_ICONV "enables character set conversion" OFF)
ENDIF()
ADD_OPTION(WITH_UNIT_TESTS "build test suite" ON)
ADD_OPTION(WITH_DYNCOL "Enables support of dynamic columns" ON)
ADD_OPTION(WITH_EXTERNAL_ZLIB "Enables use of external zlib" OFF)
ADD_OPTION(WITH_CURL "Enables use of curl" ON)
ADD_OPTION(WITH_SSL "Enables use of TLS/SSL library" ON)
###############
INCLUDE(${CC_SOURCE_DIR}/cmake/misc.cmake)
INCLUDE(FindCURL)
IF(WITH_SIGNCODE)
IF(WIN32 AND NOT SIGN_OPTIONS)
SET(SIGN_OPTIONS /a /t http://timestamp.verisign.com/scripts/timstamp.dll)
ELSE()
SEPARATE_ARGUMENTS(SIGN_OPTIONS)
ENDIF()
MARK_AS_ADVANCED(SIGN_OPTIONS)
ENDIF()
SET(MARIADB_CONNECTOR_C_COPYRIGHT "2013-2017 MariaDB Corporation Ab")
IF(WITH_RTC)
SET(RTC_OPTIONS "/RTC1 /RTCc")
ENDIF()
INCLUDE(${CC_SOURCE_DIR}/cmake/plugins.cmake)
IF(WIN32)
FILE(REMOVE ${CC_BINARY_DIR}/win/packaging/plugin.conf)
INCLUDE(${CC_SOURCE_DIR}/cmake/version_info.cmake)
ENDIF()
IF(NOT IS_SUBPROJECT)
IF(MSVC)
# Speedup system tests
INCLUDE(${CC_SOURCE_DIR}/cmake/WindowsCache.cmake)
ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN)
IF (MSVC)
SET(CONFIG_TYPES "DEBUG" "RELEASE" "RELWITHDEBINFO")
FOREACH(BUILD_TYPE ${CONFIG_TYPES})
FOREACH(COMPILER CXX C)
SET(COMPILER_FLAGS "${CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}}")
IF (NOT COMPILER_FLAGS STREQUAL "")
IF(NOT WITH_ASAN)
STRING(REPLACE "/MD" "/MT" COMPILER_FLAGS ${COMPILER_FLAGS})
IF (BUILD_TYPE STREQUAL "DEBUG")
SET(COMPILER_FLAGS "${COMPILER_FLAGS} ${RTC_OPTIONS}")
ENDIF()
ENDIF()
STRING(REPLACE "/Zi" "/Z7" COMPILER_FLAGS ${COMPILER_FLAGS})
MESSAGE (STATUS "CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}= ${COMPILER_FLAGS}")
SET(CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE} ${COMPILER_FLAGS})
ENDIF()
ENDFOREACH()
ENDFOREACH()
ENDIF()
ENDIF()
ENDIF(NOT IS_SUBPROJECT)
# Disable dbug information for release builds
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDBUG_OFF")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
IF(CMAKE_COMPILER_IS_GNUCC)
INCLUDE(CheckCCompilerFlag)
#SET(GCC_FLAGS -Wunused -Wlogical-op -Wno-uninitialized -Wall -Wextra -Wformat-security -Wno-init-self -Wwrite-strings -Wshift-count-overflow -Wdeclaration-after-statement -Wno-undef -Wno-unknown-pragmas)
FOREACH(GCC_FLAG ${GCC_FLAGS})
CHECK_C_COMPILER_FLAG("${GCC_FLAG}" HAS_${GCC_FLAG}_FLAG)
IF(${HAS_${GCC_FLAG}_FLAG})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCC_FLAG}")
ENDIF()
ENDFOREACH()
ENDIF()
# If the build type isn't specified, set to Relwithdebinfo as default.
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "RelWithDebInfo")
ENDIF()
# various defines for generating include/mysql_version.h
INCLUDE(FindGit)
IF(GIT_EXECUTABLE AND EXISTS ${CC_SOURCE_DIR}/.git)
EXECUTE_PROCESS(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY ${CC_SOURCE_DIR}
OUTPUT_VARIABLE OUT RESULT_VARIABLE RES)
IF(RES EQUAL 0)
STRING(REGEX REPLACE "\n$" "" CC_SOURCE_REVISION "${OUT}")
ENDIF()
ENDIF()
SET(PROTOCOL_VERSION 10) # we adapted new password option from PHP's mysqlnd !
# if C/C is build as subproject inside MariaDB server tree we will
# use the version defined by server
IF(MAJOR_VERSION)
SET(MARIADB_CLIENT_VERSION_MAJOR ${MAJOR_VERSION})
SET(MARIADB_CLIENT_VERSION_MINOR ${MINOR_VERSION})
SET(MARIADB_CLIENT_VERSION_PATCH ${PATCH_VERSION})
SET(MARIADB_CLIENT_VERSION_EXTRA ${EXTRA_VERSION})
ELSE()
SET(MARIADB_CLIENT_VERSION_MAJOR "10")
SET(MARIADB_CLIENT_VERSION_MINOR "5")
SET(MARIADB_CLIENT_VERSION_PATCH "5")
SET(MARIADB_CLIENT_VERSION_EXTRA "")
ENDIF()
SET(MARIADB_CLIENT_VERSION "${MARIADB_CLIENT_VERSION_MAJOR}.${MARIADB_CLIENT_VERSION_MINOR}.${MARIADB_CLIENT_VERSION_PATCH}${MARIADB_CLIENT_VERSION_EXTRA}")
SET(MARIADB_BASE_VERSION "mariadb-${MARIADB_CLIENT_VERSION_MAJOR}.${MARIADB_CLIENT_VERSION_MINOR}")
MATH(EXPR MARIADB_VERSION_ID "${MARIADB_CLIENT_VERSION_MAJOR} * 10000 +
${MARIADB_CLIENT_VERSION_MINOR} * 100 +
${MARIADB_CLIENT_VERSION_PATCH}")
IF (NOT MARIADB_PORT)
SET(MARIADB_PORT 3306)
ENDIF ()
IF(NOT MARIADB_UNIX_ADDR)
SET(MARIADB_UNIX_ADDR "/tmp/mysql.sock")
ENDIF()
INCLUDE("${CC_SOURCE_DIR}/cmake/install.cmake")
IF(NOT PLUGINDIR)
SET(PLUGINDIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_PLUGINDIR}")
ENDIF()
# todo: we don't character sets in share - all is compiled in
SET(SHAREDIR "share")
SET(DEFAULT_CHARSET_HOME "${CMAKE_INSTALL_PREFIX}")
INCLUDE(${CC_SOURCE_DIR}/cmake/SearchLibrary.cmake)
IF(WITH_EXTERNAL_ZLIB)
IF(NOT ZLIB_FOUND)
FIND_PACKAGE(ZLIB REQUIRED)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
SET(LIBZ ${ZLIB_LIBRARY})
ELSE()
# ZLIB was already specified by another (parent) project
SET(INTERNAL_ZLIB_LIBRARY ${ZLIB_LIBRARY})
ENDIF()
ENDIF()
IF(NOT WIN32)
INCLUDE(TestBigEndian)
TEST_BIG_ENDIAN(HAVE_BIGENDIAN)
ENDIF()
# check for various include files
INCLUDE(${CC_SOURCE_DIR}/cmake/CheckIncludeFiles.cmake)
# check for various functions
INCLUDE(${CC_SOURCE_DIR}/cmake/CheckFunctions.cmake)
# check for various types
INCLUDE(${CC_SOURCE_DIR}/cmake/CheckTypes.cmake)
IF(UNIX)
SEARCH_LIBRARY(LIBM floor m)
SEARCH_LIBRARY(LIBPTHREAD pthread_getspecific "pthread;pthreads")
SEARCH_LIBRARY(LIBNSL gethostbyname_r "nsl_r;nsl")
SEARCH_LIBRARY(LIBSOCKET setsockopt socket)
FIND_PACKAGE(Threads)
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${LIBNSL} ${LIBBIND} ${LIBICONV} ${LIBZ}
${LIBSOCKET} ${CMAKE_DL_LIBS} ${LIBM} ${LIBPTHREAD})
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${LIBNSL} ${LIBBIND} ${LIBICONV} ${LIBZ}
${LIBSOCKET} ${CMAKE_DL_LIBS} ${LIBM} ${LIBPTHREAD})
#remove possible dups from required libraries
LIST(LENGTH CMAKE_REQUIRED_LIBRARIES rllength)
IF(${rllength} GREATER 0)
LIST(REMOVE_DUPLICATES CMAKE_REQUIRED_LIBRARIES)
ENDIF()
ENDIF()
IF(CMAKE_HAVE_PTHREAD_H)
SET(CMAKE_REQUIRED_INCLUDES pthread.h)
ENDIF()
IF(DBUG_OFF)
ADD_DEFINITIONS(-DDBUG_OFF=1)
ENDIF()
ADD_DEFINITIONS(-DMARIADB_SYSTEM_TYPE="${CMAKE_SYSTEM_NAME}")
ADD_DEFINITIONS(-DMARIADB_MACHINE_TYPE="${CMAKE_SYSTEM_PROCESSOR}")
IF(WIN32)
SET(HAVE_THREADS 1)
ADD_DEFINITIONS(-DHAVE_DLOPEN)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
IF(MSVC)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996" )
ENDIF()
ELSEIF()
SET(HAVE_THREADS ${CMAKE_USE_PTHREADS})
ENDIF()
IF(NOT DEFAULT_CHARSET)
SET(DEFAULT_CHARSET "utf8mb4")
ENDIF()
# convert SSL options to uppercase
IF(WITH_SSL)
STRING(TOUPPER ${WITH_SSL} WITH_SSL)
ENDIF()
IF(WITH_SSL STREQUAL "ON")
IF(WIN32)
SET(WITH_SSL "SCHANNEL")
ELSE()
SET(WITH_SSL "OPENSSL")
ENDIF()
ENDIF()
IF(NOT WITH_SSL STREQUAL "OFF")
IF(WITH_SSL STREQUAL "OPENSSL")
IF (NOT OPENSSL_FOUND)
FIND_PACKAGE(OpenSSL)
ENDIF()
IF(OPENSSL_FOUND)
ADD_DEFINITIONS(-DHAVE_OPENSSL -DHAVE_TLS)
SET(SSL_SOURCES "${CC_SOURCE_DIR}/libmariadb/secure/openssl.c")
SET(SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
IF(WIN32)
CHECK_INCLUDE_FILES (${OPENSSL_INCLUDE_DIR}/openssl/applink.c HAVE_OPENSSL_APPLINK_C)
ENDIF()
INCLUDE_DIRECTORIES(BEFORE ${OPENSSL_INCLUDE_DIR})
TRY_RUN(LIBRESSL_RESULT HAVE_LIBRESSL
${CMAKE_BINARY_DIR}
${CC_SOURCE_DIR}/cmake/libressl_version.c
COMPILE_DEFINITIONS "-I${OPENSSL_INCLUDE_DIR}"
RUN_OUTPUT_VARIABLE LIBRESSL_VERSION)
IF(HAVE_LIBRESSL)
ADD_DEFINITIONS(-DHAVE_LIBRESSL)
SET(TLS_LIBRARY_VERSION ${LIBRESSL_VERSION})
ELSE()
SET(TLS_LIBRARY_VERSION "OpenSSL ${OPENSSL_VERSION}")
ENDIF()
ELSE()
MESSAGE1(TLS_LIBRARY_VERSION "OpenSSL/LibreSSL not found")
ENDIF()
ENDIF()
IF(WITH_SSL STREQUAL "GNUTLS")
FIND_PACKAGE(GnuTLS "3.3.24" REQUIRED)
IF(GNUTLS_FOUND)
ADD_DEFINITIONS(-DHAVE_GNUTLS -DHAVE_TLS)
SET(SSL_SOURCES "${CC_SOURCE_DIR}/libmariadb/secure/gnutls.c")
SET(SSL_LIBRARIES ${GNUTLS_LIBRARY})
SET(TLS_LIBRARY_VERSION "GnuTLS ${GNUTLS_VERSION_STRING}")
INCLUDE_DIRECTORIES(${GNUTLS_INCLUDE_DIR})
ELSE()
MESSAGE(FATAL_ERROR "GnuTLS not found")
ENDIF()
ENDIF()
IF(WIN32)
IF(WITH_SSL STREQUAL "SCHANNEL")
ADD_DEFINITIONS(-DHAVE_SCHANNEL -DHAVE_TLS)
SET(SSL_SOURCES "${CC_SOURCE_DIR}/libmariadb/secure/schannel.c"
"${CC_SOURCE_DIR}/libmariadb/secure/ma_schannel.c"
"${CC_SOURCE_DIR}/libmariadb/secure/schannel_certs.c")
INCLUDE_DIRECTORIES("${CC_SOURCE_DIR}/plugins/pvio/")
SET(SSL_LIBRARIES secur32)
SET(TLS_LIBRARY_VERSION "Schannel ${CMAKE_SYSTEM_VERSION}")
ENDIF()
ENDIF()
MESSAGE1(TLS_LIBRARY_VERSION "TLS library/version: ${TLS_LIBRARY_VERSION}")
MARK_AS_ADVANCED(SSL_SOURCES)
ENDIF()
SET(ENABLED_LOCAL_INFILE "AUTO" CACHE STRING "If we should should enable LOAD DATA LOCAL by default (OFF/ON/AUTO)")
MARK_AS_ADVANCED(ENABLED_LOCAL_INFILE)
IF (ENABLED_LOCAL_INFILE MATCHES "^(0|FALSE)$")
SET(ENABLED_LOCAL_INFILE OFF)
ELSEIF(ENABLED_LOCAL_INFILE MATCHES "^(1|TRUE)$")
SET(ENABLED_LOCAL_INFILE ON)
ELSEIF (NOT ENABLED_LOCAL_INFILE MATCHES "^(ON|OFF|AUTO)$")
MESSAGE(FATAL_ERROR "ENABLED_LOCAL_INFILE must be one of OFF, ON, AUTO")
ENDIF()
IF(WITH_ICONV)
IF(NOT WIN32)
INCLUDE(${CC_SOURCE_DIR}/cmake/FindIconv.cmake)
ENDIF()
ENDIF()
CONFIGURE_FILE(${CC_SOURCE_DIR}/include/ma_config.h.in
${CC_BINARY_DIR}/include/ma_config.h)
CONFIGURE_FILE(${CC_SOURCE_DIR}/include/ma_config.h.in
${CC_BINARY_DIR}/include/config.h)
CONFIGURE_FILE(${CC_SOURCE_DIR}/include/mariadb_version.h.in
${CC_BINARY_DIR}/include/mariadb_version.h)
INCLUDE_DIRECTORIES(${CC_BINARY_DIR}/include)
IF(WIN32)
SET(SYSTEM_LIBS ws2_32 advapi32 kernel32 shlwapi crypt32 ${LIBZ})
ELSE()
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${LIBPTHREAD} ${CMAKE_DL_LIBS} ${LIBM})
IF(ICONV_EXTERNAL)
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${ICONV_LIBRARIES})
ENDIF()
ENDIF()
IF(WITH_SSL)
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${SSL_LIBRARIES})
ENDIF()
MESSAGE1(SYSTEM_LIBS "SYSTEM_LIBS ${SYSTEM_LIBS}")
MARK_AS_ADVANCED(SYSTEM_LIBS)
IF(NOT REMOTEIO_PLUGIN_TYPE MATCHES "OFF")
IF(CURL_FOUND)
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS})
IF(REMOTEIO_PLUGIN_TYPE MATCHES "STATIC")
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${CURL_LIBRARIES})
ENDIF()
ADD_DEFINITIONS("-DHAVE_REMOTEIO=1")
ENDIF()
ENDIF()
IF(NOT WIN32)
IF(NOT AUTH_GSSAPI_PLUGIN_TYPE MATCHES "OFF")
INCLUDE(${CC_SOURCE_DIR}/cmake/FindGSSAPI.cmake)
IF(GSSAPI_FOUND)
INCLUDE_DIRECTORIES(${GSSAPI_INCS})
IF(AUTH_GSSAPI_PLUGIN_TYPE MATCHES "STATIC")
SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${GSSAPI_LIBS})
ENDIF()
ENDIF()
ENDIF()
ENDIF()
INCLUDE(${CC_SOURCE_DIR}/plugins/CMakeLists.txt)
ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(libmariadb)
IF(NOT WIN32)
ADD_SUBDIRECTORY(mariadb_config)
ENDIF()
IF(IS_DIRECTORY ${CC_SOURCE_DIR}/unittest)
IF(WITH_UNIT_TESTS)
ADD_SUBDIRECTORY(unittest/mytap)
ADD_SUBDIRECTORY(unittest/libmariadb)
ENDIF()
ENDIF()
IF(CLIENT_DOCS)
INSTALL(DIRECTORY ${CLIENT_DOCS}
DESTINATION ${DOCS_INSTALL_DIR_${INSTALL_LAYOUT}}
COMPONENT SharedLibraries)
ENDIF()
IF(UNIX)
ADD_SUBDIRECTORY(man)
ENDIF()
IF(WIN32 AND WITH_MSI AND CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
ADD_SUBDIRECTORY(win/packaging)
ENDIF()
MESSAGE1(SYSTEM_PROCESSOR "SYSTEM processor: ${CMAKE_SYSTEM_PROCESSOR}")
SET(CPACK_PACKAGE_VENDOR "MariaDB Corporation Ab")
SET(CPACK_PACKAGE_DESCRIPTION "MariaDB Connector/C. A library for connecting to MariaDB and MySQL servers")
SET(CPACK_PACKAGE_NAME "mariadb_connector_c")
STRING(TOLOWER ${CMAKE_SYSTEM_NAME} system_name)
SET(CPACK_RESOURCE_FILE_LICENSE "${CC_SOURCE_DIR}/COPYING.LIB")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CC_SOURCE_DIR}/README")
INCLUDE(cmake/ConnectorName.cmake)
IF(NOT PACKAGE_STATUS_SUFFIX)
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mariadb-connector-c-${CPACK_PACKAGE_VERSION}-src")
IF(PACKAGE_PLATFORM_SUFFIX)
SET(CPACK_PACKAGE_FILE_NAME "mariadb-connector-c-${CPACK_PACKAGE_VERSION}-${PACKAGE_PLATFORM_SUFFIX}")
ELSE()
SET(CPACK_PACKAGE_FILE_NAME "mariadb-connector-c-${CPACK_PACKAGE_VERSION}-${system_name}-${CMAKE_SYSTEM_PROCESSOR}")
ENDIF()
ELSE()
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mariadb-connector-c-${CPACK_PACKAGE_VERSION}-${PACKAGE_STATUS_SUFFIX}-src")
IF(PACKAGE_PLATFORM_SUFFIX)
SET(CPACK_PACKAGE_FILE_NAME "mariadb-connector-c-${CPACK_PACKAGE_VERSION}-${PACKAGE_STATUS_SUFFIX}-${PACKAGE_PLATFORM_SUFFIX}")
ELSE()
SET(CPACK_PACKAGE_FILE_NAME "mariadb-connector-c-${CPACK_PACKAGE_VERSION}-${PACKAGE_STATUS_SUFFIX}-${system_name}-${CMAKE_SYSTEM_PROCESSOR}")
ENDIF()
ENDIF()
# Build source packages
IF(GIT_BUILD_SRCPKG)
# get branch name
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} show-branch OUTPUT_VARIABLE git_branch)
STRING(REGEX MATCH "\\[([^]]+)\\]" git_branch ${git_branch})
STRING(REGEX REPLACE "\\[|\\]" "" GIT_BRANCH ${git_branch})
MESSAGE1(GIT_BRANCH "${GIT_BRANCH}")
IF(WIN32)
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} archive ${GIT_BRANCH} --format=zip --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.zip)
ELSE()
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} archive ${GIT_BRANCH} --format=zip --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.zip)
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} archive ${GIT_BRANCH} --format=tar --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar)
EXECUTE_PROCESS(COMMAND gzip -9 -f ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar)
ENDIF()
ENDIF()
SET(CPACK_SOURCE_IGNORE_FILES
\\\\.git/
\\\\.gitignore
\\\\.gitattributes
CMakeCache\\\\.txt
cmake_dist\\\\.cmake
CPackConfig\\\\.cmake
mariadb_config\\\\.c$
\\\\.build/
html/
unittest
/cmake_install.cmake
/CTestTestfile.cmake
/CPackSourceConfig.cmake
/CMakeFiles/
/version_resources/
/_CPack_Packages/
\\\\.gz$
\\\\.zip$
mariadb_config/mariadb_config$
/CMakeFiles/
/version_resources/
/_CPack_Packages/
Makefile$
include/my_config\\\\.h$
)
IF(WITH_TEST_SRCPKG)
SET(PACKAGE_FILE ${CC_SOURCE_DIR}/package.name)
FILE(REMOVE ${PACKAGE_FILE})
FILE(WRITE ${PACKAGE_FILE} ${CPACK_SOURCE_PACKAGE_FILE_NAME})
ENDIF()
IF(WIN32)
SET(CPACK_GENERATOR "ZIP")
SET(CPACK_SOURCE_GENERATOR "ZIP")
ELSE()
SET(CPACK_GENERATOR "TGZ")
SET(CPACK_SOURCE_GENERATOR "TGZ")
ENDIF()
INCLUDE(CPack)
IF(WITH_EXTERNAL_ZLIB)
SET(zlib_status ${WITH_EXTERNAL_ZLIB})
ELSE()
SET(zlib_status "yes (using bundled zlib)")
ENDIF()
MESSAGE1(STATUS "MariaDB Connector/c configuration:
-- Static PLUGINS ${PLUGINS_STATIC}
-- Dynamic PLUGINS ${PLUGINS_DYNAMIC}
-- CPack generation: ${CPACK_GENERATOR}
-- SSL support: ${WITH_SSL} Libs: ${SSL_LIBRARIES}
-- Zlib support: ${zlib_status}
-- Installation layout: ${INSTALL_LAYOUT}
-- Include files will be installed in ${INSTALL_INCLUDEDIR}
-- Libraries will be installed in ${INSTALL_LIBDIR}
-- Binaries will be installed in ${INSTALL_BINDIR}
-- Documentation included from ${CLIENT_DOCS}
-- Required: ${CMAKE_REQUIRED_LIBRARIES}")

502
vendor/MDBC/COPYING.LIB vendored Normal file
View File

@ -0,0 +1,502 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

15
vendor/MDBC/README vendored Normal file
View File

@ -0,0 +1,15 @@
This is LGPL MariaDB client library that can be used to connect to MySQL
or MariaDB.
This code is based on the LGPL libmysql client library from MySQL 3.23
and PHP's mysqlnd extension.
This product includes PHP software, freely available from
<http://www.php.net/software/>
If you want to be part of this development effort, you can discuss this at
maria-developers@lists.launchpad.org.
To report a bug you'll need to signup for an account at https://jira.mariadb.org
The MariaDB team

16
vendor/MDBC/appveyor-download.bat vendored Normal file
View File

@ -0,0 +1,16 @@
@echo off
set archive=http://ftp.hosteurope.de/mirror/archive.mariadb.org//mariadb-%DB%/winx64-packages/mariadb-%DB%-winx64.msi
set last=http://mirror.i3d.net/pub/mariadb//mariadb-%DB%/winx64-packages/mariadb-%DB%-winx64.msi
curl -fLsS -o server.msi %archive%
if %ERRORLEVEL% == 0 goto end
curl -fLsS -o server.msi %last%
if %ERRORLEVEL% == 0 goto end
echo Failure Reason Given is %errorlevel%
exit /b %errorlevel%
:end
echo "File found".

41
vendor/MDBC/appveyor.yml vendored Normal file
View File

@ -0,0 +1,41 @@
version: 3.0.8;{build}
branches:
only:
- 3.1
environment:
matrix:
- DB: '10.2.38'
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
- DB: '10.3.29'
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
- DB: '10.4.19'
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
- DB: '10.5.10'
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
configuration: RelWithDebInfo
clone_folder: c:\projects\mariadb-connector-c
before_build:
- cmd: appveyor-download.bat
- cmd: msiexec /i server.msi INSTALLDIR=c:\projects\server SERVICENAME=mariadb ALLOWREMOTEROOTACCESS=true /qn
- cmd: "\"c:\\projects\\server\\bin\\mysql.exe\" -e \"create database testc\" --user=root"
- cmd: set MARIADB_CC_TEST=1
- cmd: set MYSQL_TEST_USER=root
- cmd: set MYSQL_TEST_HOST=127.0.0.1
- cmd: set MYSQL_TEST_PASSWD=
- cmd: set MYSQL_TEST_PORT=3306
- cmd: set MYSQL_TEST_DB=testc
- cmd: cmake -G "%CMAKE_PARAM%" -DCMAKE_BUILD_TYPE=RelWithDebInfo
build:
project: mariadb-connector-c.sln
parallel: true
verbosity: minimal
test_script:
- cmd: cd c:\projects\mariadb-connector-c\unittest\libmariadb
- cmd: set MARIADB_PLUGIN_DIR=cd c:\projects\mariadb-connector-c\plugins\lib\RelWithDebInfo
- cmd: ctest -V

17
vendor/MDBC/client/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,17 @@
INCLUDE_DIRECTORIES(${CC_SOURCE_DIR}/include)
IF(WIN32)
SET_VERSION_INFO("TARGET:mariadb_client_plugin_info"
"FILE_TYPE:VFT_APP"
"SOURCE_FILE:client/ma_plugin_info.c"
"ORIGINAL_FILE_NAME:mariadb_client_plugin_info.exe"
"FILE_DESCRIPTION:Client plugin viewer")
ENDIF()
ADD_EXECUTABLE(mariadb_client_plugin_info ${mariadb_client_plugin_info_RC} ma_plugin_info.c)
TARGET_LINK_LIBRARIES(mariadb_client_plugin_info mariadbclient)
INSTALL(TARGETS mariadb_client_plugin_info
DESTINATION ${INSTALL_BINDIR}
COMPONENT SharedLibraries)
SIGN_TARGET(mariadb_client_plugin_info)

211
vendor/MDBC/client/ma_plugin_info.c vendored Normal file
View File

@ -0,0 +1,211 @@
#include <my_global.h>
#include <my_sys.h>
#include <mysql.h>
#include <mysql/client_plugin.h>
#include <getopt.h>
#include <stdio.h>
#include <my_dir.h>
#include <ma_string.h>
#define CLIENT_PLUGIN_INFO_VERSION "1.0.0"
static struct option long_options[]=
{
{"all", no_argument, 0, 'a'},
{"builtin", no_argument, 0, 'b'},
{"dynamic", no_argument, 0, 'd'},
{"directory", 1, 0, 'p'},
{"plugin_name", 1, 0, 'n'},
{"version", no_argument, 0, 'v'},
{"help", no_argument, 0, '?'},
{NULL, 0, 0, 0}
};
static char *values[] =
{
"show information for all plugins",
"show information for builtin plugins",
"show information for dynamic plugins",
"show information for dynamic plugins in specified directory",
"show information for specified plugin",
"show version information",
"display this help and exit",
NULL
};
struct st_plugin_type
{
int type;
char *typename;
};
#ifndef _WIN32
int my_errno=0;
#endif
static struct st_plugin_type plugin_types[]=
{
{MYSQL_CLIENT_AUTHENTICATION_PLUGIN, "authentication"},
{MARIADB_CLIENT_PVIO_PLUGIN, "virtual IO"},
{MARIADB_CLIENT_TRACE_PLUGIN, "trace"},
{MARIADB_CLIENT_REMOTEIO_PLUGIN, "remote file access"},
{MARIADB_CLIENT_CONNECTION_PLUGIN, "connection handler"},
{0, "unknown"}
};
static void version()
{
printf("%s Version %s\n", ma_progname, CLIENT_PLUGIN_INFO_VERSION);
}
static void usage(void)
{
int i=0;
printf("%s Version %s\n", ma_progname, CLIENT_PLUGIN_INFO_VERSION);
puts("Copyright 2015 MariaDB Corporation AB");
puts("Show client plugin information for MariaDB Connector/C.");
printf("Usage: %s [OPTIONS] [plugin_name]\n", ma_progname);
while (long_options[i].name)
{
printf(" --%-12s -%s\n", long_options[i].name, values[i]);
i++;
}
}
static char *ma_get_type_name(int type)
{
int i=0;
while (plugin_types[i].type)
{
if (type== plugin_types[i].type)
return plugin_types[i].typename;
i++;
}
return plugin_types[i].typename;
}
static void show_plugin_info(struct st_mysql_client_plugin *plugin, my_bool builtin)
{
printf("Name: %s\n", plugin->name);
printf("Type: %s\n", ma_get_type_name(plugin->type));
printf("Desc: %s\n", plugin->desc);
printf("Author: %s\n", plugin->author);
printf("License: %s\n", plugin->license);
printf("Version: %d.%d.%d\n", plugin->version[0], plugin->version[1], plugin->version[2]);
printf("API Version: 0x%04X\n", plugin->interface_version);
printf("Build type: %s\n", builtin ? "builtin" : "dynamic");
printf("\n");
}
static void show_builtin()
{
struct st_mysql_client_plugin **builtin;
for (builtin= mysql_client_builtins; *builtin; builtin++)
show_plugin_info(*builtin, TRUE);
}
static void show_file(char *filename)
{
char dlpath[FN_REFLEN+1];
void *sym, *dlhandle;
struct st_mysql_client_plugin *plugin;
char *env_plugin_dir= getenv("MARIADB_PLUGIN_DIR");
char *has_so_ext= strstr(filename, SO_EXT);
if (!strchr(filename, FN_LIBCHAR))
snprintf(dlpath, sizeof(dlpath) - 1, "%s/%s%s",
(env_plugin_dir) ? env_plugin_dir : PLUGINDIR,
filename,
has_so_ext ? "" : SO_EXT);
else
strcpy(dlpath, filename);
if ((dlhandle= dlopen((const char *)dlpath, RTLD_NOW)))
{
if (sym= dlsym(dlhandle, plugin_declarations_sym))
{
plugin= (struct st_mysql_client_plugin *)sym;
show_plugin_info(plugin, 0);
}
dlclose(dlhandle);
}
}
static void show_dynamic(const char *directory)
{
MY_DIR *dir= NULL;
unsigned int i;
char *plugin_dir= directory ? (char *)directory : getenv("MARIADB_PLUGIN_DIR");
if (!plugin_dir)
plugin_dir= PLUGINDIR;
printf("plugin_dir %s\n", plugin_dir);
dir= my_dir(plugin_dir, 0);
if (!dir || !dir->number_off_files)
{
printf("No plugins found in %s\n", plugin_dir);
goto end;
}
for (i=0; i < dir->number_off_files; i++)
{
char *p= strstr(dir->dir_entry[i].name, SO_EXT);
if (p)
show_file(dir->dir_entry[i].name);
}
end:
if (dir)
my_dirend(dir);
}
int main(int argc, char *argv[])
{
int option_index= 0;
int c;
ma_progname= argv[0];
mysql_server_init(0, NULL, NULL);
if (argc <= 1)
{
usage();
exit(1);
}
c= getopt_long(argc, argv, "bdapnvh?", long_options, &option_index);
switch(c) {
case 'a': /* all */
show_builtin();
show_dynamic(NULL);
break;
case 'b': /* builtin */
show_builtin();
break;
case 'd': /* dynamic */
show_dynamic(NULL);
break;
case 'v':
version();
break;
case 'n':
if (argc > 2)
show_file(argv[2]);
break;
case 'p':
if (argc > 2)
show_dynamic(argv[2]);
break;
case '?':
usage();
break;
default:
printf("unrecocognized option: %s", argv[1]);
exit(1);
}
exit(0);
}

22
vendor/MDBC/cmake/COPYING-CMAKE-SCRIPTS vendored Normal file
View File

@ -0,0 +1,22 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

30
vendor/MDBC/cmake/CheckFunctions.cmake vendored Normal file
View File

@ -0,0 +1,30 @@
#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
# This file is included by CMakeLists.txt and
# checks for various functions.
# You will find the appropriate defines in
# include/my_config.h.in
INCLUDE(CheckFunctionExists)
CHECK_FUNCTION_EXISTS (alloca HAVE_ALLOCA)
CHECK_FUNCTION_EXISTS (dlerror HAVE_DLERROR)
CHECK_FUNCTION_EXISTS (dlopen HAVE_DLOPEN)
CHECK_FUNCTION_EXISTS (fcntl HAVE_FCNTL)
CHECK_FUNCTION_EXISTS (memcpy HAVE_MEMCPY)
CHECK_FUNCTION_EXISTS (nl_langinfo HAVE_NL_LANGINFO)
CHECK_FUNCTION_EXISTS (setlocale HAVE_SETLOCALE)
CHECK_FUNCTION_EXISTS (poll HAVE_POLL)
CHECK_FUNCTION_EXISTS (getpwuid HAVE_GETPWUID)
IF(HAVE_FILE_UCONTEXT_H)
CHECK_FUNCTION_EXISTS (makecontext HAVE_UCONTEXT_H)
ENDIF()
CHECK_FUNCTION_EXISTS (cuserid HAVE_CUSERID)

View File

@ -0,0 +1,58 @@
#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
# This file is included by CMakeLists.txt and
# checks for various header files.
# You will find the appropriate defines in
# include/my_config.h.in
INCLUDE(CheckIncludeFiles)
CHECK_INCLUDE_FILES (alloca.h HAVE_ALLOCA_H)
CHECK_INCLUDE_FILES (arpa/inet.h HAVE_ARPA_INET_H)
CHECK_INCLUDE_FILES (dlfcn.h HAVE_DLFCN_H)
CHECK_INCLUDE_FILES (fcntl.h HAVE_FCNTL_H)
CHECK_INCLUDE_FILES (float.h HAVE_FLOAT_H)
CHECK_INCLUDE_FILES (limits.h HAVE_LIMITS_H)
CHECK_INCLUDE_FILES (linux/limits.h HAVE_LINUX_LIMITS_H)
CHECK_INCLUDE_FILES (pwd.h HAVE_PWD_H)
CHECK_INCLUDE_FILES (sched.h HAVE_SCHED_H)
CHECK_INCLUDE_FILES (select.h HAVE_SELECT_H)
CHECK_INCLUDE_FILES (signal.h INCLUDE_SIGNAL)
IF(INCLUDE_SIGNAL)
SET(HAVE_SIGNAL 1)
SET(CMAKE_EXTRA_INCLUDE_FILES signal.h)
ENDIF(INCLUDE_SIGNAL)
CHECK_INCLUDE_FILES (stddef.h HAVE_STDDEF_H)
CHECK_INCLUDE_FILES (stdint.h HAVE_STDINT_H)
IF(HAVE_STDINT_H)
SET(CMAKE_EXTRA_INCLUDE_FILES stdint.h)
ENDIF(HAVE_STDINT_H)
CHECK_INCLUDE_FILES (stdlib.h HAVE_STDLIB_H)
CHECK_INCLUDE_FILES (string.h HAVE_STRING_H)
CHECK_INCLUDE_FILES (strings.h HAVE_STRINGS_H)
CHECK_INCLUDE_FILES (sys/ioctl.h HAVE_SYS_IOCTL_H)
CHECK_INCLUDE_FILES (sys/select.h HAVE_SYS_SELECT_H)
CHECK_INCLUDE_FILES (sys/socket.h HAVE_SYS_SOCKET_H)
CHECK_INCLUDE_FILES (sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES (sys/stat.h HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILES (sys/un.h HAVE_SYS_UN_H)
CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H)
CHECK_INCLUDE_FILES (utime.h HAVE_UTIME_H)
IF(APPLE)
SET(CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE=600)
ENDIF()
CHECK_INCLUDE_FILES (ucontext.h HAVE_FILE_UCONTEXT_H)
IF(NOT HAVE_FILE_UCONTEXT_H)
CHECK_INCLUDE_FILES (sys/ucontext.h HAVE_FILE_UCONTEXT_H)
ENDIF()

62
vendor/MDBC/cmake/CheckTypes.cmake vendored Normal file
View File

@ -0,0 +1,62 @@
#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
# This file is included by CMakeLists.txt and
# checks for type sizes.
# You will find the appropriate defines in
# include/my_config.h.in
INCLUDE (CheckTypeSize)
SET(CMAKE_EXTRA_INCLUDE_FILES signal.h)
CHECK_TYPE_SIZE("char *" SIZEOF_CHARP)
CHECK_TYPE_SIZE(int SIZEOF_INT)
CHECK_TYPE_SIZE(long SIZEOF_LONG)
CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
SET(CMAKE_EXTRA_INCLUDE_FILES stdio.h)
CHECK_TYPE_SIZE(size_t SIZEOF_SIZE_T)
SET(CMAKE_EXTRA_INCLUDE_FILES sys/types.h)
CHECK_TYPE_SIZE(uchar SIZEOF_UCHAR)
CHECK_TYPE_SIZE(uint SIZEOF_UINT)
CHECK_TYPE_SIZE(ulong SIZEOF_ULONG)
CHECK_TYPE_SIZE(int8 SIZEOF_INT8)
CHECK_TYPE_SIZE(uint8 SIZEOF_UINT8)
CHECK_TYPE_SIZE(int16 SIZEOF_INT16)
CHECK_TYPE_SIZE(uint16 SIZEOF_UINT16)
CHECK_TYPE_SIZE(int32 SIZEOF_INT32)
CHECK_TYPE_SIZE(uint32 SIZEOF_UINT32)
CHECK_TYPE_SIZE(int64 SIZEOF_INT64)
CHECK_TYPE_SIZE(uint64 SIZEOF_UINT64)
CHECK_TYPE_SIZE(socklen_t SIZEOF_SOCKLEN_T)
#
# Compile testing
#
INCLUDE (CheckCSourceCompiles)
#
# SOCKET_SIZE
#
IF(WIN32)
SET(SOCKET_SIZE_TYPE int)
ELSE(WIN32)
FOREACH(CHECK_TYPE "socklen_t" "size_t" "int")
IF (NOT SOCKET_SIZE_TYPE)
CHECK_C_SOURCE_COMPILES("
#include <sys/socket.h>
int main(int argc, char **argv)
{
getsockname(0, 0, (${CHECK_TYPE} *)0);
return 0;
}"
SOCKET_SIZE_FOUND_${CHECK_TYPE})
IF(SOCKET_SIZE_FOUND_${CHECK_TYPE})
SET(SOCKET_SIZE_TYPE ${CHECK_TYPE})
ENDIF(SOCKET_SIZE_FOUND_${CHECK_TYPE})
ENDIF (NOT SOCKET_SIZE_TYPE)
ENDFOREACH()
ENDIF(WIN32)

34
vendor/MDBC/cmake/ConnectorName.cmake vendored Normal file
View File

@ -0,0 +1,34 @@
#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
MACRO(GET_CONNECTOR_PACKAGE_NAME name)
# check if we have 64bit
IF(SIZEOF_VOIDP EQUAL 8)
SET(IS64 1)
ENDIF()
SET (PLAFORM_NAME CMAKE_SYSTEM_NAME)
SET (MACHINE_NAME CMAKE_SYSTEM_PROCESSOR)
SET (CONCAT_SIGN "-")
IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
SET(PLATFORM_NAME "win")
SET(CONCAT_SIGN "")
IF(IS64)
IF(CMAKE_C_COMPILER_ARCHITECTURE_ID)
STRING(TOLOWER "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MACHINE_NAME)
ELSE()
SET(MACHINE_NAME x64)
ENDIF()
ELSE()
SET(MACHINE_NAME "32")
ENDIF()
ENDIF()
SET(product_name "mysql-connector-c-${CPACK_PACKAGE_VERSION}-${PLATFORM_NAME}${CONCAT_SIGN}${MACHINE_NAME}")
STRING(TOLOWER ${product_name} ${name})
ENDMACRO()

110
vendor/MDBC/cmake/FindGSSAPI.cmake vendored Normal file
View File

@ -0,0 +1,110 @@
#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
# - Try to detect the GSSAPI support
# Once done this will define
#
# GSSAPI_FOUND - system supports GSSAPI
# GSSAPI_INCS - the GSSAPI include directory
# GSSAPI_LIBS - the libraries needed to use GSSAPI
# GSSAPI_FLAVOR - the type of API - MIT or HEIMDAL
# Copyright (c) 2006, Pino Toscano, <toscano.pino@tiscali.it>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if(GSSAPI_LIBS AND GSSAPI_FLAVOR)
# in cache already
set(GSSAPI_FOUND TRUE)
else(GSSAPI_LIBS AND GSSAPI_FLAVOR)
find_program(KRB5_CONFIG NAMES krb5-config PATHS
/opt/local/bin
/usr/lib/mit/bin/
ONLY_CMAKE_FIND_ROOT_PATH # this is required when cross compiling with cmake 2.6 and ignored with cmake 2.4, Alex
)
mark_as_advanced(KRB5_CONFIG)
#reset vars
set(GSSAPI_INCS)
set(GSSAPI_LIBS)
set(GSSAPI_FLAVOR)
if(KRB5_CONFIG)
set(HAVE_KRB5_GSSAPI TRUE)
exec_program(${KRB5_CONFIG} ARGS --libs gssapi RETURN_VALUE _return_VALUE OUTPUT_VARIABLE GSSAPI_LIBS)
if(_return_VALUE)
message(STATUS "GSSAPI configure check failed.")
set(HAVE_KRB5_GSSAPI FALSE)
endif(_return_VALUE)
IF(CMAKE_SYSTEM_NAME MATCHES AIX)
string(REGEX REPLACE "-Wl[A-Za-z0-9_/,:-]*[ $]?" "" GSSAPI_LIBS "${GSSAPI_LIBS}")
string(REGEX REPLACE "-L[A-Za-z0-9_/,:-]*[ $]?" "" GSSAPI_LIBS "${GSSAPI_LIBS}")
ENDIF()
exec_program(${KRB5_CONFIG} ARGS --cflags gssapi RETURN_VALUE _return_VALUE OUTPUT_VARIABLE GSSAPI_INCS)
string(REGEX REPLACE "(\r?\n)+$" "" GSSAPI_INCS "${GSSAPI_INCS}")
string(REGEX REPLACE " *-I" ";" GSSAPI_INCS "${GSSAPI_INCS}")
exec_program(${KRB5_CONFIG} ARGS --vendor RETURN_VALUE _return_VALUE OUTPUT_VARIABLE gssapi_flavor_tmp)
set(GSSAPI_FLAVOR_MIT)
if(gssapi_flavor_tmp MATCHES ".*Massachusetts.*")
set(GSSAPI_FLAVOR "MIT")
else(gssapi_flavor_tmp MATCHES ".*Massachusetts.*")
set(GSSAPI_FLAVOR "HEIMDAL")
endif(gssapi_flavor_tmp MATCHES ".*Massachusetts.*")
if(NOT HAVE_KRB5_GSSAPI)
if (gssapi_flavor_tmp MATCHES "Sun Microsystems.*")
message(STATUS "Solaris Kerberos does not have GSSAPI; this is normal.")
set(GSSAPI_LIBS)
set(GSSAPI_INCS)
else(gssapi_flavor_tmp MATCHES "Sun Microsystems.*")
message(WARNING "${KRB5_CONFIG} failed unexpectedly.")
endif(gssapi_flavor_tmp MATCHES "Sun Microsystems.*")
endif(NOT HAVE_KRB5_GSSAPI)
if(GSSAPI_LIBS) # GSSAPI_INCS can be also empty, so don't rely on that
set(GSSAPI_FOUND TRUE CACHE STRING "")
message(STATUS "Found GSSAPI: ${GSSAPI_LIBS}")
set(GSSAPI_INCS ${GSSAPI_INCS} CACHE STRING "")
set(GSSAPI_LIBS ${GSSAPI_LIBS} CACHE STRING "")
set(GSSAPI_FLAVOR ${GSSAPI_FLAVOR} CACHE STRING "")
mark_as_advanced(GSSAPI_INCS GSSAPI_LIBS GSSAPI_FLAVOR)
endif(GSSAPI_LIBS)
endif(KRB5_CONFIG)
endif(GSSAPI_LIBS AND GSSAPI_FLAVOR)

82
vendor/MDBC/cmake/FindIconv.cmake vendored Normal file
View File

@ -0,0 +1,82 @@
#
# Copyright (C) 2010 Michael Bell <michael.bell@web.de>
# 2015-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
# ICONV_EXTERNAL - Iconv is an external library (not libc)
# ICONV_FOUND - system has Iconv
# ICONV_INCLUDE_DIR - the Iconv include directory
# ICONV_LIBRARIES - Link these to use Iconv
# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const
# ICONV_VERSION - Iconv version string
if (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
# Already in cache, be silent
set(ICONV_FIND_QUIETLY TRUE)
endif (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
find_path(ICONV_INCLUDE_DIR iconv.h)
IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
# There is some libiconv.so in /usr/local that must
# be avoided, iconv routines are in libc
ELSEIF(APPLE)
find_library(ICONV_LIBRARIES NAMES iconv libiconv PATHS
/usr/lib/
NO_CMAKE_SYSTEM_PATH)
SET(ICONV_EXTERNAL TRUE)
ELSE()
find_library(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2)
IF(ICONV_LIBRARIES)
SET(ICONV_EXTERNAL TRUE)
ENDIF()
ENDIF()
if (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
set (ICONV_FOUND TRUE)
endif (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR})
IF(ICONV_EXTERNAL)
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
ENDIF()
if (ICONV_FOUND)
include(CheckCSourceCompiles)
CHECK_C_SOURCE_COMPILES("
#include <iconv.h>
int main(){
iconv_t conv = 0;
const char* in = 0;
size_t ilen = 0;
char* out = 0;
size_t olen = 0;
iconv(conv, &in, &ilen, &out, &olen);
return 0;
}
" ICONV_SECOND_ARGUMENT_IS_CONST )
ADD_DEFINITIONS(-DHAVE_ICONV)
endif (ICONV_FOUND)
set (CMAKE_REQUIRED_INCLUDES)
set (CMAKE_REQUIRED_LIBRARIES)
if (ICONV_FOUND)
if (NOT ICONV_FIND_QUIETLY)
message (STATUS "Found Iconv: ${ICONV_LIBRARIES}")
endif (NOT ICONV_FIND_QUIETLY)
else (ICONV_FOUND)
if (Iconv_FIND_REQUIRED)
message (FATAL_ERROR "Could not find Iconv")
endif (Iconv_FIND_REQUIRED)
endif (ICONV_FOUND)
MARK_AS_ADVANCED(
ICONV_INCLUDE_DIR
ICONV_LIBRARIES
ICONV_EXTERNAL
ICONV_SECOND_ARGUMENT_IS_CONST
)

29
vendor/MDBC/cmake/SearchLibrary.cmake vendored Normal file
View File

@ -0,0 +1,29 @@
#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
INCLUDE(CheckFunctionExists)
INCLUDE(CheckLibraryExists)
FUNCTION(SEARCH_LIBRARY library_name function liblist)
IF(${${library_name}})
RETURN()
ENDIF()
CHECK_FUNCTION_EXISTS(${function} IS_${function}_LIBC_FUNC)
IF(IS_${function}_LIBC_FUNC)
SET(${library_name} "" PARENT_SCOPE)
RETURN()
ENDIF()
FOREACH(lib ${liblist})
CHECK_LIBRARY_EXISTS(${lib} ${function} "" HAVE_${function}_IN_${lib})
IF(HAVE_${function}_IN_${lib})
SET(${library_name} ${lib} PARENT_SCOPE)
SET(HAVE_${library_name} 1 PARENT_SCOPE)
RETURN()
ENDIF()
ENDFOREACH()
ENDFUNCTION()

392
vendor/MDBC/cmake/WindowsCache.cmake vendored Normal file
View File

@ -0,0 +1,392 @@
#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
IF(MSVC)
SET(BFD_H_EXISTS 0 CACHE INTERNAL "")
SET(HAVE_ACCESS 1 CACHE INTERNAL "")
SET(HAVE_AIO_H CACHE INTERNAL "")
SET(HAVE_AIO_READ CACHE INTERNAL "")
SET(HAVE_ALARM CACHE INTERNAL "")
SET(HAVE_ALLOCA_H CACHE INTERNAL "")
SET(HAVE_ARPA_INET_H CACHE INTERNAL "")
SET(HAVE_ASM_MSR_H CACHE INTERNAL "")
SET(HAVE_BACKTRACE CACHE INTERNAL "")
SET(HAVE_BACKTRACE_SYMBOLS CACHE INTERNAL "")
SET(HAVE_BACKTRACE_SYMBOLS_FD CACHE INTERNAL "")
SET(HAVE_BFILL CACHE INTERNAL "")
SET(HAVE_BMOVE CACHE INTERNAL "")
SET(HAVE_BSD_SIGNALS CACHE INTERNAL "")
SET(HAVE_BSEARCH 1 CACHE INTERNAL "")
SET(HAVE_BSS_START CACHE INTERNAL "")
SET(HAVE_BZERO CACHE INTERNAL "")
SET(HAVE_CHOWN CACHE INTERNAL "")
SET(HAVE_CLOCK_GETTIME CACHE INTERNAL "")
SET(HAVE_COMPRESS CACHE INTERNAL "")
SET(HAVE_CRYPT CACHE INTERNAL "")
SET(HAVE_CRYPT_H CACHE INTERNAL "")
SET(HAVE_CUSERID CACHE INTERNAL "")
SET(HAVE_CXX_NEW 1 CACHE INTERNAL "")
SET(HAVE_DECL_MADVISE CACHE INTERNAL "")
SET(HAVE_DIRECTIO CACHE INTERNAL "")
SET(HAVE_DIRENT_H CACHE INTERNAL "")
SET(HAVE_DLERROR CACHE INTERNAL "")
SET(HAVE_DLFCN_H CACHE INTERNAL "")
SET(HAVE_DLOPEN CACHE INTERNAL "")
SET(HAVE_DOPRNT CACHE INTERNAL "")
SET(HAVE_EXECINFO_H CACHE INTERNAL "")
SET(HAVE_FCHMOD CACHE INTERNAL "")
SET(HAVE_FCNTL CACHE INTERNAL "")
SET(HAVE_FCNTL_H 1 CACHE INTERNAL "")
SET(HAVE_FCNTL_NONBLOCK CACHE INTERNAL "")
SET(HAVE_FCONVERT CACHE INTERNAL "")
SET(HAVE_FDATASYNC CACHE INTERNAL "")
SET(HAVE_DECL_FDATASYNC CACHE INTERNAL "")
SET(HAVE_FEDISABLEEXCEPT CACHE INTERNAL "")
SET(HAVE_FENV_H CACHE INTERNAL "")
SET(HAVE_FESETROUND CACHE INTERNAL "")
SET(HAVE_FGETLN CACHE INTERNAL "")
SET(HAVE_FINITE CACHE INTERNAL "")
SET(HAVE_FINITE_IN_MATH_H CACHE INTERNAL "")
SET(HAVE_FLOATINGPOINT_H CACHE INTERNAL "")
SET(HAVE_FLOAT_H 1 CACHE INTERNAL "")
SET(HAVE_FLOCKFILE CACHE INTERNAL "")
SET(HAVE_FNMATCH_H CACHE INTERNAL "")
SET(HAVE_FPSETMASK CACHE INTERNAL "")
SET(HAVE_FPU_CONTROL_H CACHE INTERNAL "")
SET(HAVE_FSEEKO CACHE INTERNAL "")
SET(HAVE_FSYNC CACHE INTERNAL "")
SET(HAVE_FTIME 1 CACHE INTERNAL "")
SET(HAVE_FTRUNCATE CACHE INTERNAL "")
SET(HAVE_GETADDRINFO 1 CACHE INTERNAL "")
SET(HAVE_GETCWD 1 CACHE INTERNAL "")
SET(HAVE_GETHOSTBYADDR_R CACHE INTERNAL "")
SET(HAVE_GETHRTIME CACHE INTERNAL "")
SET(HAVE_GETLINE CACHE INTERNAL "")
SET(HAVE_GETNAMEINFO CACHE INTERNAL "")
SET(HAVE_GETPAGESIZE CACHE INTERNAL "")
SET(HAVE_GETPASS CACHE INTERNAL "")
SET(HAVE_GETPASSPHRASE CACHE INTERNAL "")
SET(HAVE_GETPWNAM CACHE INTERNAL "")
SET(HAVE_GETPWUID CACHE INTERNAL "")
SET(HAVE_GETRLIMIT CACHE INTERNAL "")
SET(HAVE_GETRUSAGE CACHE INTERNAL "")
SET(HAVE_GETTIMEOFDAY CACHE INTERNAL "")
SET(HAVE_GETWD CACHE INTERNAL "")
SET(HAVE_GRP_H CACHE INTERNAL "")
SET(HAVE_IA64INTRIN_H CACHE INTERNAL "")
SET(HAVE_IEEEFP_H CACHE INTERNAL "")
SET(HAVE_INDEX CACHE INTERNAL "")
SET(HAVE_INITGROUPS CACHE INTERNAL "")
SET(HAVE_INTTYPES_H CACHE INTERNAL "")
SET(HAVE_IPPROTO_IPV6 CACHE INTERNAL "")
SET(HAVE_IPV6 TRUE CACHE INTERNAL "")
SET(HAVE_IPV6_V6ONLY 1 CACHE INTERNAL "")
SET(HAVE_ISINF CACHE INTERNAL "")
SET(HAVE_ISSETUGID CACHE INTERNAL "")
SET(HAVE_GETUID CACHE INTERNAL "")
SET(HAVE_GETEUID CACHE INTERNAL "")
SET(HAVE_GETGID CACHE INTERNAL "")
SET(HAVE_GETEGID CACHE INTERNAL "")
SET(HAVE_LANGINFO_H CACHE INTERNAL "")
SET(HAVE_LDIV 1 CACHE INTERNAL "")
SET(HAVE_LIMITS_H 1 CACHE INTERNAL "")
SET(HAVE_LOCALE_H 1 CACHE INTERNAL "")
SET(HAVE_LOG2 CACHE INTERNAL "")
SET(HAVE_LONGJMP 1 CACHE INTERNAL "")
SET(HAVE_LRAND48 CACHE INTERNAL "")
SET(HAVE_LSTAT CACHE INTERNAL "")
SET(HAVE_MADVISE CACHE INTERNAL "")
SET(HAVE_MALLINFO CACHE INTERNAL "")
SET(HAVE_MALLOC_H 1 CACHE INTERNAL "")
SET(HAVE_MEMALIGN CACHE INTERNAL "")
SET(HAVE_MEMCPY 1 CACHE INTERNAL "")
SET(HAVE_MEMMOVE 1 CACHE INTERNAL "")
SET(HAVE_MEMORY_H 1 CACHE INTERNAL "")
SET(HAVE_MKSTEMP CACHE INTERNAL "")
SET(HAVE_MLOCK CACHE INTERNAL "")
SET(HAVE_MLOCKALL CACHE INTERNAL "")
SET(HAVE_MMAP CACHE INTERNAL "")
SET(HAVE_MMAP64 CACHE INTERNAL "")
SET(HAVE_NETDB_H CACHE INTERNAL "")
SET(HAVE_NETINET_IN6_H CACHE INTERNAL "")
SET(HAVE_NETINET_IN_H CACHE INTERNAL "")
SET(HAVE_NL_LANGINFO CACHE INTERNAL "")
SET(HAVE_PASE_ENVIRONMENT CACHE INTERNAL "")
SET(HAVE_PATHS_H CACHE INTERNAL "")
SET(HAVE_PCLOSE CACHE INTERNAL "")
SET(HAVE_PERROR 1 CACHE INTERNAL "")
SET(HAVE_PEERCRED CACHE INTERNAL "")
SET(HAVE_PAM_APPL_H CACHE INTERNAL "")
SET(HAVE_POLL_H CACHE INTERNAL "")
SET(HAVE_POPEN CACHE INTERNAL "")
SET(HAVE_POLL CACHE INTERNAL "")
SET(HAVE_PORT_CREATE CACHE INTERNAL "")
SET(HAVE_PORT_H CACHE INTERNAL "")
SET(HAVE_POSIX_FALLOCATE CACHE INTERNAL "")
SET(HAVE_POSIX_SIGNALS CACHE INTERNAL "")
SET(HAVE_PREAD CACHE INTERNAL "")
SET(HAVE_PRINTSTACK CACHE INTERNAL "")
SET(HAVE_PTHREAD_ATTR_CREATE CACHE INTERNAL "")
SET(HAVE_PTHREAD_ATTR_GETSTACKSIZE CACHE INTERNAL "")
SET(HAVE_PTHREAD_ATTR_SETSCOPE CACHE INTERNAL "")
SET(HAVE_PTHREAD_ATTR_SETSTACKSIZE CACHE INTERNAL "")
SET(HAVE_PTHREAD_CONDATTR_CREATE CACHE INTERNAL "")
SET(HAVE_PTHREAD_CONDATTR_SETCLOCK CACHE INTERNAL "")
SET(HAVE_PTHREAD_INIT CACHE INTERNAL "")
SET(HAVE_PTHREAD_KEY_DELETE CACHE INTERNAL "")
SET(HAVE_PTHREAD_RWLOCK_RDLOCK CACHE INTERNAL "")
SET(HAVE_PTHREAD_SIGMASK CACHE INTERNAL "")
SET(HAVE_PTHREAD_THREADMASK CACHE INTERNAL "")
SET(HAVE_PTHREAD_YIELD_NP CACHE INTERNAL "")
SET(HAVE_PTHREAD_YIELD_ZERO_ARG CACHE INTERNAL "")
SET(HAVE_PUTENV 1 CACHE INTERNAL "")
SET(HAVE_PWD_H CACHE INTERNAL "")
SET(HAVE_RDTSCLL CACHE INTERNAL "")
SET(HAVE_READDIR_R CACHE INTERNAL "")
SET(HAVE_READLINK CACHE INTERNAL "")
SET(HAVE_READ_REAL_TIME CACHE INTERNAL "")
SET(HAVE_REALPATH CACHE INTERNAL "")
SET(HAVE_REGCOMP CACHE INTERNAL "")
SET(HAVE_RENAME 1 CACHE INTERNAL "")
SET(HAVE_RE_COMP CACHE INTERNAL "")
SET(HAVE_RINT CACHE INTERNAL "")
SET(HAVE_RWLOCK_INIT CACHE INTERNAL "")
SET(HAVE_SCHED_H CACHE INTERNAL "")
SET(HAVE_SCHED_YIELD CACHE INTERNAL "")
SET(HAVE_SELECT 1 CACHE INTERNAL "")
SET(HAVE_SELECT_H CACHE INTERNAL "")
SET(HAVE_SEMAPHORE_H CACHE INTERNAL "")
SET(HAVE_SETENV CACHE INTERNAL "")
SET(HAVE_SETFD CACHE INTERNAL "")
SET(HAVE_SETLOCALE 1 CACHE INTERNAL "")
SET(HAVE_SHMAT CACHE INTERNAL "")
SET(HAVE_SHMCTL CACHE INTERNAL "")
SET(HAVE_SHMDT CACHE INTERNAL "")
SET(HAVE_SHMGET CACHE INTERNAL "")
SET(HAVE_SIGACTION CACHE INTERNAL "")
SET(HAVE_SIGADDSET CACHE INTERNAL "")
SET(HAVE_SIGEMPTYSET CACHE INTERNAL "")
SET(HAVE_SIGHOLD CACHE INTERNAL "")
SET(HAVE_SIGINT 1 CACHE INTERNAL "")
SET(HAVE_SIGPIPE CACHE INTERNAL "")
SET(HAVE_SIGQUIT CACHE INTERNAL "")
SET(HAVE_SIGSET CACHE INTERNAL "")
SET(HAVE_SIGTERM 1 CACHE INTERNAL "")
SET(HAVE_SIGTHREADMASK CACHE INTERNAL "")
SET(HAVE_SIGWAIT CACHE INTERNAL "")
SET(HAVE_SIZEOF_BOOL FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_CHAR TRUE CACHE INTERNAL "")
SET(SIZEOF_CHAR 1 CACHE INTERNAL "")
SET(HAVE_SIZEOF_CHARP TRUE CACHE INTERNAL "")
SET(SIZEOF_CHARP ${CMAKE_SIZEOF_VOID_P} CACHE INTERNAL "")
SET(HAVE_SIZEOF_IN6_ADDR TRUE CACHE INTERNAL "")
SET(HAVE_SIZEOF_INT TRUE CACHE INTERNAL "")
SET(SIZEOF_INT 4 CACHE INTERNAL "")
SET(HAVE_SIZEOF_INT16 FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_INT32 FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_INT64 FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_INT8 FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_LONG TRUE CACHE INTERNAL "")
SET(SIZEOF_LONG 4 CACHE INTERNAL "")
SET(HAVE_SIZEOF_LONG_LONG TRUE CACHE INTERNAL "")
SET(SIZEOF_LONG_LONG 8 CACHE INTERNAL "")
SET(HAVE_SIZEOF_MODE_T FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_OFF_T TRUE CACHE INTERNAL "")
SET(SIZEOF_OFF_T 4 CACHE INTERNAL "")
SET(HAVE_SIZEOF_SHORT TRUE CACHE INTERNAL "")
SET(SIZEOF_SHORT 2 CACHE INTERNAL "")
SET(HAVE_SIZEOF_SIGSET_T FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_SIZE_T TRUE CACHE INTERNAL "")
SET(SIZEOF_SIZE_T ${CMAKE_SIZEOF_VOID_P} CACHE INTERNAL "")
SET(HAVE_SIZEOF_SOCKADDR_IN6 TRUE CACHE INTERNAL "")
SET(HAVE_SIZEOF_SOCKLEN_T FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_UCHAR FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_UINT FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_UINT16 FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_UINT32 FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_UINT64 FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_UINT8 FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_ULONG FALSE CACHE INTERNAL "")
SET(HAVE_SIZEOF_U_INT32_T FALSE CACHE INTERNAL "")
SET(HAVE_SIZE_OF_SSIZE_T FALSE CACHE INTERNAL "")
SET(HAVE_SLEEP CACHE INTERNAL "")
SET(HAVE_SOCKADDR_STORAGE_SS_FAMILY 1 CACHE INTERNAL "")
SET(HAVE_SOLARIS_STYLE_GETHOST CACHE INTERNAL "")
SET(STACK_DIRECTION -1 CACHE INTERNAL "")
SET(HAVE_STDARG_H 1 CACHE INTERNAL "")
SET(HAVE_STDDEF_H 1 CACHE INTERNAL "")
SET(HAVE_STDINT_H CACHE INTERNAL "")
SET(HAVE_STDLIB_H 1 CACHE INTERNAL "")
SET(HAVE_STPCPY CACHE INTERNAL "")
SET(HAVE_STRCASECMP CACHE INTERNAL "")
SET(HAVE_STRCOLL 1 CACHE INTERNAL "")
SET(HAVE_STRDUP 1 CACHE INTERNAL "")
SET(HAVE_STRERROR 1 CACHE INTERNAL "")
SET(HAVE_STRINGS_H CACHE INTERNAL "")
SET(HAVE_STRING_H 1 CACHE INTERNAL "")
SET(HAVE_STRLCAT CACHE INTERNAL "")
SET(HAVE_STRLCPY CACHE INTERNAL "")
SET(HAVE_STRNCASECMP CACHE INTERNAL "")
SET(HAVE_STRNDUP CACHE INTERNAL "")
IF(MSVC_VERSION GREATER 1310)
SET(HAVE_STRNLEN 1 CACHE INTERNAL "")
ENDIF()
SET(HAVE_STRPBRK 1 CACHE INTERNAL "")
SET(HAVE_STRSEP CACHE INTERNAL "")
SET(HAVE_STRSIGNAL CACHE INTERNAL "")
SET(HAVE_STRSTR 1 CACHE INTERNAL "")
SET(HAVE_STRTOK_R CACHE INTERNAL "")
SET(HAVE_STRTOL 1 CACHE INTERNAL "")
SET(HAVE_STRTOLL CACHE INTERNAL "")
SET(HAVE_STRTOUL 1 CACHE INTERNAL "")
SET(HAVE_STRTOULL CACHE INTERNAL "")
SET(HAVE_SVR3_SIGNALS CACHE INTERNAL "")
SET(HAVE_SYNCH_H CACHE INTERNAL "")
SET(HAVE_SYSENT_H CACHE INTERNAL "")
SET(HAVE_SYS_CDEFS_H CACHE INTERNAL "")
SET(HAVE_SYS_DIR_H CACHE INTERNAL "")
SET(HAVE_SYS_ERRLIST CACHE INTERNAL "")
SET(HAVE_SYS_FILE_H CACHE INTERNAL "")
SET(HAVE_SYS_FPU_H CACHE INTERNAL "")
SET(HAVE_SYS_IOCTL_H CACHE INTERNAL "")
SET(HAVE_SYS_IPC_H CACHE INTERNAL "")
SET(HAVE_SYS_MALLOC_H CACHE INTERNAL "")
SET(HAVE_SYS_MMAN_H CACHE INTERNAL "")
SET(HAVE_SYS_PARAM_H CACHE INTERNAL "")
SET(HAVE_SYS_PRCTL_H CACHE INTERNAL "")
SET(HAVE_SYS_PTEM_H CACHE INTERNAL "")
SET(HAVE_SYS_PTE_H CACHE INTERNAL "")
SET(HAVE_SYS_RESOURCE_H CACHE INTERNAL "")
SET(HAVE_SYS_SELECT_H CACHE INTERNAL "")
SET(HAVE_SYS_SHM_H CACHE INTERNAL "")
SET(HAVE_SYS_SOCKIO_H CACHE INTERNAL "")
SET(HAVE_SYS_SOCKET_H CACHE INTERNAL "")
SET(HAVE_SYS_STAT_H 1 CACHE INTERNAL "")
SET(HAVE_SYS_STREAM_H CACHE INTERNAL "")
SET(HAVE_SYS_TERMCAP_H CACHE INTERNAL "")
SET(HAVE_SYS_TIMEB_H 1 CACHE INTERNAL "")
SET(HAVE_SYS_TIMES_H CACHE INTERNAL "")
SET(HAVE_SYS_TIME_H CACHE INTERNAL "")
SET(HAVE_SYS_TYPES_H 1 CACHE INTERNAL "")
SET(HAVE_SYS_UN_H CACHE INTERNAL "")
SET(HAVE_SYS_UTIME_H 1 CACHE INTERNAL "")
SET(HAVE_SYS_VADVISE_H CACHE INTERNAL "")
SET(HAVE_SYS_WAIT_H CACHE INTERNAL "")
SET(HAVE_TCGETATTR CACHE INTERNAL "")
SET(HAVE_TELL 1 CACHE INTERNAL "")
SET(HAVE_TEMPNAM 1 CACHE INTERNAL "")
SET(HAVE_TERMCAP_H CACHE INTERNAL "")
SET(HAVE_TERMIOS_H CACHE INTERNAL "")
SET(HAVE_TERMIO_H CACHE INTERNAL "")
SET(HAVE_TERM_H CACHE INTERNAL "")
SET(HAVE_THR_SETCONCURRENCY CACHE INTERNAL "")
SET(HAVE_THR_YIELD CACHE INTERNAL "")
SET(HAVE_TIME 1 CACHE INTERNAL "")
SET(HAVE_TIMES CACHE INTERNAL "")
SET(HAVE_TIMESPEC_TS_SEC CACHE INTERNAL "")
SET(HAVE_TIME_H 1 CACHE INTERNAL "")
SET(HAVE_TZNAME 1 CACHE INTERNAL "")
SET(HAVE_UNISTD_H CACHE INTERNAL "")
SET(HAVE_UTIME_H CACHE INTERNAL "")
SET(HAVE_VALLOC CACHE INTERNAL "")
SET(HAVE_VARARGS_H 1 CACHE INTERNAL "")
SET(HAVE_VASPRINTF CACHE INTERNAL "")
SET(HAVE_VPRINTF 1 CACHE INTERNAL "")
IF(MSVC_VERSION GREATER 1310)
SET(HAVE_VSNPRINTF 1 CACHE INTERNAL "")
ENDIF()
SET(HAVE_WEAK_SYMBOL CACHE INTERNAL "")
SET(HAVE_WORDS_BIGENDIAN TRUE CACHE INTERNAL "")
SET(WORDS_BIGENDIAN CACHE INTERNAL "")
SET(HAVE__S_IFIFO 1 CACHE INTERNAL "")
SET(HAVE__S_IREAD 1 CACHE INTERNAL "")
SET(HAVE__finite 1 CACHE INTERNAL "")
SET(HAVE__pclose 1 CACHE INTERNAL "")
SET(HAVE__popen 1 CACHE INTERNAL "")
SET(HAVE__stricmp 1 CACHE INTERNAL "")
SET(HAVE__strnicmp 1 CACHE INTERNAL "")
SET(HAVE__strtoi64 1 CACHE INTERNAL "")
SET(HAVE__strtoui64 1 CACHE INTERNAL "")
IF(MSVC_VERSION GREATER 1310)
SET(HAVE_strtok_s 1 CACHE INTERNAL "")
ENDIF()
SET(STDC_HEADERS CACHE 1 INTERNAL "")
SET(STRUCT_DIRENT_HAS_D_INO CACHE INTERNAL "")
SET(STRUCT_DIRENT_HAS_D_INO CACHE INTERNAL "")
SET(STRUCT_DIRENT_HAS_D_NAMLEN CACHE INTERNAL "")
SET(TIME_WITH_SYS_TIME CACHE INTERNAL "")
SET(TIME_T_UNSIGNED 1 CACHE INTERNAL "")
SET(TIOCSTAT_IN_SYS_IOCTL CACHE INTERNAL "")
SET(HAVE_S_IROTH CACHE INTERNAL "")
SET(HAVE_S_IFIFO CACHE INTERNAL "")
SET(QSORT_TYPE_IS_VOID 1 CACHE INTERNAL "")
SET(SIGNAL_RETURN_TYPE_IS_VOID 1 CACHE INTERNAL "")
SET(C_HAS_inline CACHE INTERNAL "")
SET(C_HAS___inline 1 CACHE INTERNAL "")
SET(FIONREAD_IN_SYS_IOCTL CACHE INTERNAL "")
SET(FIONREAD_IN_SYS_FILIO CACHE INTERNAL "")
SET(GWINSZ_IN_SYS_IOCTL CACHE INTERNAL "")
SET(HAVE_CXXABI_H CACHE INTERNAL "")
SET(HAVE_NDIR_H CACHE INTERNAL "")
SET(HAVE_SYS_NDIR_H CACHE INTERNAL "")
SET(HAVE_SYS_NDIR_H CACHE INTERNAL "")
SET(HAVE_ASM_TERMBITS_H CACHE INTERNAL "")
SET(HAVE_TERMBITS_H CACHE INTERNAL "")
SET(HAVE_VIS_H CACHE INTERNAL "")
SET(HAVE_WCHAR_H 1 CACHE INTERNAL "")
SET(HAVE_WCTYPE_H 1 CACHE INTERNAL "")
SET(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP CACHE INTERNAL "")
SET(HAVE_SOCKADDR_IN_SIN_LEN CACHE INTERNAL "")
SET(HAVE_SOCKADDR_IN6_SIN6_LEN CACHE INTERNAL "")
SET(HAVE_VALGRIND CACHE INTERNAL "")
SET(HAVE_EVENT_H CACHE INTERNAL "")
SET(HAVE_LINUX_UNISTD_H CACHE INTERNAL "")
SET(HAVE_SYS_UTSNAME_H CACHE INTERNAL "")
SET(HAVE_PTHREAD_ATTR_GETGUARDSIZE CACHE INTERNAL "")
SET(FIONREAD_IN_SYS_FILIO CACHE INTERNAL "")
SET(FIONREAD_IN_SYS_IOCTL CACHE INTERNAL "")
SET(GWINSZ_IN_SYS_IOCTL CACHE INTERNAL "")
SET(HAVE_ACCESS 1 CACHE INTERNAL "")
SET(HAVE_AIOWAIT CACHE INTERNAL "")
SET(HAVE_AIO_H CACHE INTERNAL "")
SET(HAVE_AIO_READ CACHE INTERNAL "")
SET(HAVE_ALARM CACHE INTERNAL "")
SET(HAVE_ALLOCA CACHE INTERNAL "")
SET(HAVE_ALLOCA_H CACHE INTERNAL "")
SET(HAVE_ARPA_INET_H CACHE INTERNAL "")
SET(HAVE_ASM_MSR_H CACHE INTERNAL "")
SET(HAVE_ASM_TERMBITS_H CACHE INTERNAL "")
SET(HAVE_BACKTRACE CACHE INTERNAL "")
SET(HAVE_BACKTRACE_SYMBOLS CACHE INTERNAL "")
SET(HAVE_BACKTRACE_SYMBOLS_FD CACHE INTERNAL "")
SET(HAVE_BCMP CACHE INTERNAL "")
SET(HAVE_BFILL CACHE INTERNAL "")
SET(HAVE_BMOVE CACHE INTERNAL "")
SET(HAVE_BSD_SIGNALS CACHE INTERNAL "")
SET(HAVE_BSEARCH CACHE INTERNAL "")
SET(HAVE_BSS_START CACHE INTERNAL "")
SET(HAVE_BZERO CACHE INTERNAL "")
SET(HAVE_CHOWN CACHE INTERNAL "")
SET(HAVE_CLOCK_GETTIME CACHE INTERNAL "")
SET(HAVE_COMPRESS CACHE INTERNAL "")
SET(HAVE_CRYPT CACHE INTERNAL "")
SET(HAVE_CRYPT_H CACHE INTERNAL "")
SET(HAVE_CUSERID CACHE INTERNAL "")
SET(HAVE_CXXABI_H CACHE INTERNAL "")
SET(HAVE_DECL_FDATASYNC CACHE INTERNAL "")
SET(HAVE_SIGNAL_H 1 CACHE INTERNAL "")
SET(HAVE_GETHOSTBYNAME_R CACHE INTERNAL "")
SET(HAVE_PTHREAD_ATTR_SETPRIO CACHE INTERNAL "")
SET(HAVE_PTHREAD_ATTR_SETSCHEDPARAM CACHE INTERNAL "")
SET(HAVE_PTHREAD_KILL CACHE INTERNAL "")
SET(HAVE_PTHREAD_SETPRIO_NP CACHE INTERNAL "")
SET(HAVE_PTHREAD_SETSCHEDPARAM CACHE INTERNAL "")
SET(HAVE_SETFILEPOINTER CACHE INTERNAL "")
SET(SIZEOF_U_INT32_T CACHE INTERNAL "")
SET(IS_VOID_SIGNAL 1 CACHE INTERNAL "")
SET(IS_VOID_QSORT 1 CACHE INTERNAL "")
ENDIF()

30
vendor/MDBC/cmake/export.cmake vendored Normal file
View File

@ -0,0 +1,30 @@
#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
MACRO(CREATE_EXPORT_FILE op outfile version symbols alias_version)
IF(WIN32)
SET(EXPORT_CONTENT "EXPORTS\n")
FOREACH(exp_symbol ${symbols})
SET(EXPORT_CONTENT ${EXPORT_CONTENT} "${exp_symbol}\n")
ENDFOREACH()
ELSE()
SET(EXPORT_CONTENT "VERSION {\n${version} {\nglobal:\n")
FOREACH(exp_symbol ${symbols})
SET(EXPORT_CONTENT "${EXPORT_CONTENT} ${exp_symbol}\\;\n")
ENDFOREACH()
SET(EXPORT_CONTENT "${EXPORT_CONTENT}local:\n *\\;\n}\\;\n")
IF ("${alias_version}" STRGREATER "")
SET(EXPORT_CONTENT "${EXPORT_CONTENT}${alias_version} {\n}\\;\n}\\;\n")
FOREACH(exp_symbol ${symbols})
SET(EXPORT_CONTENT "${EXPORT_CONTENT}\"${exp_symbol}@${alias_version}\" = ${exp_symbol}\\;\n")
ENDFOREACH()
ELSE()
SET(EXPORT_CONTENT "${EXPORT_CONTENT}}\\;\n")
ENDIF()
ENDIF()
FILE(${op} ${CMAKE_CURRENT_BINARY_DIR}/${outfile} ${EXPORT_CONTENT})
ENDMACRO()

160
vendor/MDBC/cmake/install.cmake vendored Normal file
View File

@ -0,0 +1,160 @@
#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
#
# This file contains settings for the following layouts:
#
# - RPM
# Built with default prefix=/usr
#
#
# The following va+riables are used and can be overwritten
#
# INSTALL_LAYOUT installation layout (DEFAULT = standard for tar.gz and zip packages
# RPM packages
#
# INSTALL_BINDIR location of binaries (mariadb_config)
# INSTALL_LIBDIR location of libraries
# INSTALL_PLUGINDIR location of plugins
# INSTALL_MANDIR location of manpages
IF(NOT INSTALL_LAYOUT)
SET(INSTALL_LAYOUT "DEFAULT")
ENDIF()
SET(INSTALL_LAYOUT ${INSTALL_LAYOUT} CACHE
STRING "Installation layout. Currently supported options are DEFAULT (tar.gz and zip), RPM and DEB")
# On Windows we only provide zip and .msi. Latter one uses a different packager.
IF(UNIX)
IF(INSTALL_LAYOUT MATCHES "RPM")
SET(libmariadb_prefix "/usr")
ELSEIF(INSTALL_LAYOUT MATCHES "DEFAULT|DEB")
SET(libmariadb_prefix ${CMAKE_INSTALL_PREFIX})
ENDIF()
ENDIF()
IF(CMAKE_DEFAULT_PREFIX_INITIALIZED_BY_DEFAULT)
SET(CMAKE_DEFAULT_PREFIX ${libmariadb_prefix} CACHE PATH "Installation prefix" FORCE)
ENDIF()
# check if the specified installation layout is valid
SET(VALID_INSTALL_LAYOUTS "DEFAULT" "RPM" "DEB")
LIST(FIND VALID_INSTALL_LAYOUTS "${INSTALL_LAYOUT}" layout_no)
IF(layout_no EQUAL -1)
MESSAGE(FATAL_ERROR "Invalid installation layout ${INSTALL_LAYOUT}. Please specify one of the following layouts: ${VALID_INSTALL_LAYOUTS}")
ENDIF()
#
# Todo: We don't generate man pages yet, will fix it
# later (webhelp to man transformation)
#
#
# DEFAULT layout
#
SET(INSTALL_BINDIR_DEFAULT "bin")
SET(INSTALL_LIBDIR_DEFAULT "lib/mariadb")
SET(INSTALL_PCDIR_DEFAULT "lib/pkgconfig")
SET(INSTALL_INCLUDEDIR_DEFAULT "include/mariadb")
SET(INSTALL_DOCDIR_DEFAULT "docs")
SET(INSTALL_MANDIR_DEFAULT "man")
IF(NOT IS_SUBPROJECT)
SET(INSTALL_PLUGINDIR_DEFAULT "lib/mariadb/plugin")
ELSE()
ENDIF()
SET(LIBMARIADB_STATIC_DEFAULT "mariadbclient")
#
# RPM layout
#
SET(INSTALL_BINDIR_RPM "bin")
IF((CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le" OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "s390x") AND CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(INSTALL_LIBDIR_RPM "lib64/mariadb")
SET(INSTALL_PCDIR_RPM "lib64/pkgconfig")
SET(INSTALL_PLUGINDIR_RPM "lib64/mariadb/plugin")
ELSE()
SET(INSTALL_LIBDIR_RPM "lib/mariadb")
SET(INSTALL_PCDIR_RPM "lib/pkgconfig")
SET(INSTALL_PLUGINDIR_RPM "lib/mariadb/plugin")
ENDIF()
SET(INSTALL_INCLUDEDIR_RPM "include")
SET(INSTALL_DOCDIR_RPM "docs")
SET(INSTALL_MANDIR_RPM "share/man")
SET(LIBMARIADB_STATIC_RPM "mariadbclient")
#
# DEB layout
#
SET(INSTALL_BINDIR_DEB "bin")
SET(INSTALL_LIBDIR_DEB "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
SET(INSTALL_PCDIR_DEB "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig")
SET(INSTALL_PLUGINDIR_DEB "${INSTALL_LIBDIR_DEB}/libmariadb${CPACK_PACKAGE_VERSION_MAJOR}/plugin")
SET(INSTALL_INCLUDEDIR_DEB "include/mariadb")
SET(INSTALL_MANDIR_DEB "share/man")
SET(LIBMARIADB_STATIC_DEB "mariadb")
IF(INSTALL_LAYOUT MATCHES "DEB")
SET(INSTALL_PLUGINDIR_CLIENT ${INSTALL_PLUGINDIR_DEB})
ENDIF()
#
# Overwrite defaults
#
IF(INSTALL_LIBDIR)
SET(INSTALL_LIBDIR_${INSTALL_LAYOUT} ${INSTALL_LIBDIR})
ENDIF()
IF(INSTALL_PCDIR)
SET(INSTALL_PCDIR_${INSTALL_LAYOUT} ${INSTALL_PCDIR})
ENDIF()
IF(INSTALL_PLUGINDIR)
SET(INSTALL_PLUGINDIR_${INSTALL_LAYOUT} ${INSTALL_PLUGINDIR})
ENDIF()
# Extra INSTALL_PLUGINDIR_CLIENT that overrides any INSTALL_PLUGINDIR override
IF(INSTALL_PLUGINDIR_CLIENT)
SET(INSTALL_PLUGINDIR_${INSTALL_LAYOUT} ${INSTALL_PLUGINDIR_CLIENT})
ENDIF()
IF(INSTALL_INCLUDEDIR)
SET(INSTALL_INCLUDEDIR_${INSTALL_LAYOUT} ${INSTALL_INCLUDEDIR})
ENDIF()
IF(INSTALL_BINDIR)
SET(INSTALL_BINDIR_${INSTALL_LAYOUT} ${INSTALL_BINDIR})
ENDIF()
IF(INSTALL_MANDIR)
SET(INSTALL_MANDIR_${INSTALL_LAYOUT} ${INSTALL_MANDIR})
ENDIF()
IF(NOT INSTALL_PREFIXDIR)
SET(INSTALL_PREFIXDIR_${INSTALL_LAYOUT} ${libmariadb_prefix})
ELSE()
SET(INSTALL_PREFIXDIR_${INSTALL_LAYOUT} ${INSTALL_PREFIXDIR})
ENDIF()
IF(DEFINED INSTALL_SUFFIXDIR)
SET(INSTALL_SUFFIXDIR_${INSTALL_LAYOUT} ${INSTALL_SUFFIXDIR})
ENDIF()
FOREACH(dir "BIN" "LIB" "PC" "INCLUDE" "DOCS" "PLUGIN" "MAN")
SET(INSTALL_${dir}DIR ${INSTALL_${dir}DIR_${INSTALL_LAYOUT}})
MARK_AS_ADVANCED(INSTALL_${dir}DIR)
MESSAGE1(INSTALL_${dir}DIR "MariaDB Connector C: INSTALL_${dir}DIR=${INSTALL_${dir}DIR}")
ENDFOREACH()
SET(LIBMARIADB_STATIC_NAME ${LIBMARIADB_STATIC_${INSTALL_LAYOUT}})
MARK_AS_ADVANCED(LIBMARIADB_STATIC_NAME)
MESSAGE1(LIBMARIADB_STATIC_NAME "MariaDB Connector C: LIBMARIADB_STATIC_NAME ${LIBMARIADB_STATIC_NAME}")

20
vendor/MDBC/cmake/install_plugins.cmake vendored Normal file
View File

@ -0,0 +1,20 @@
#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
# plugin installation
MACRO(INSTALL_PLUGIN name binary_dir)
#INSTALL(TARGETS ${name} COMPONENT ClientPlugins DESTINATION ${INSTALL_PLUGINDIR})
IF(MSVC)
INSTALL(FILES $<TARGET_PDB_FILE:${name}> COMPONENT Debuginfo
DESTINATION symbols CONFIGURATIONS Debug RelWithDebInfo)
ENDIF()
IF(WIN32)
FILE(APPEND ${CC_BINARY_DIR}/win/packaging/plugin.conf "<File Id=\"${name}.dll\" Name=\"${name}.dll\" DiskId=\"1\" Source=\"${binary_dir}/${CMAKE_BUILD_TYPE}/${name}.dll\"/>\n")
FILE(APPEND ${CC_BINARY_DIR}/win/packaging/plugin.conf "<File Id=\"${name}.pdb\" Name=\"${name}.pdb\" DiskId=\"1\" Source=\"${binary_dir}/${CMAKE_BUILD_TYPE}/${name}.pdb\"/>\n")
ENDIF()
ENDMACRO()

7
vendor/MDBC/cmake/libressl_version.c vendored Normal file
View File

@ -0,0 +1,7 @@
#include <openssl/opensslv.h>
#include <stdio.h>
int main()
{
printf("%s", LIBRESSL_VERSION_TEXT);
}

View File

@ -0,0 +1,18 @@
#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
# toolchain file for building a 32bit version on a 64bit host
# Usage:
# cmake -DCMAKE_TOOLCHAIN_FILE=linux_86.toolchain.cmake
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR "i686")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")

13
vendor/MDBC/cmake/misc.cmake vendored Normal file
View File

@ -0,0 +1,13 @@
IF ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_LESS "2.8.7")
FUNCTION(MESSAGE1 id out)
MESSAGE(STATUS "${out}")
ENDFUNCTION()
ELSE()
FUNCTION(MESSAGE1 id out)
STRING(MD5 hash "${out}")
IF(NOT __msg1_${id} STREQUAL "${hash}")
MESSAGE(STATUS "${out}")
ENDIF()
SET(__msg1_${id} ${hash} CACHE INTERNAL "")
ENDFUNCTION()
ENDIF()

94
vendor/MDBC/cmake/plugins.cmake vendored Normal file
View File

@ -0,0 +1,94 @@
#
# Copyright (C) 2013-2018 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
# plugin configuration
include(${CC_SOURCE_DIR}/cmake/install_plugins.cmake)
include(${CC_SOURCE_DIR}/cmake/sign.cmake)
FUNCTION(REGISTER_PLUGIN)
SET(one_value_keywords TARGET DEFAULT TYPE)
SET(multi_value_keywords CONFIGURATIONS SOURCES LIBRARIES INCLUDES COMPILE_OPTIONS)
cmake_parse_arguments(CC_PLUGIN
"${options}"
"${one_value_keywords}"
"${multi_value_keywords}"
${ARGN})
# overwrite default if it was specified with cmake option
string(TOUPPER ${CC_PLUGIN_TARGET} cc_plugin)
if(NOT "${CLIENT_PLUGIN_${cc_plugin}}" STREQUAL "")
SET(CC_PLUGIN_DEFAULT ${CLIENT_PLUGIN_${cc_plugin}})
endif()
# use uppercase
string(TOUPPER ${CC_PLUGIN_TARGET} target_name)
string(TOUPPER "${CC_PLUGIN_CONFIGURATIONS}" CC_PLUGIN_CONFIGURATIONS)
if(NOT ${PLUGIN_${target_name}} STREQUAL "")
string(TOUPPER ${PLUGIN_${target_name}} PLUGIN_${target_name})
set(CC_PLUGIN_DEFAULT ${PLUGIN_${target_name}})
endif()
# check if default value is valid
string(TOUPPER ${CC_PLUGIN_DEFAULT} CC_PLUGIN_DEFAULT)
list(FIND CC_PLUGIN_CONFIGURATIONS ${CC_PLUGIN_DEFAULT} configuration_found)
if(${configuration_found} EQUAL -1)
message(FATAL_ERROR "Invalid plugin type ${CC_PLUGIN_DEFAULT}. Allowed plugin types are ${CC_PLUGIN_CONFIGURATIONS}")
endif()
if(NOT ${CC_PLUGIN_DEFAULT} STREQUAL "OFF")
set(PLUGIN_${CC_PLUGIN_TARGET}_TYPE ${CC_PLUGIN_TYPE})
if(${CC_PLUGIN_DEFAULT} STREQUAL "DYNAMIC")
set(PLUGINS_DYNAMIC ${PLUGINS_DYNAMIC} ${CC_PLUGIN_TARGET} PARENT_SCOPE)
if(WIN32)
set(target ${CC_PLUGIN_TARGET})
set(FILE_TYPE "VFT_DLL")
set(FILE_DESCRIPTION "MariaDB client plugin")
set(FILE_VERSION ${CPACK_PACKAGE_VERSION})
set(ORIGINAL_FILE_NAME "${target}.dll")
configure_file(${CC_SOURCE_DIR}/win/resource.rc.in
${CC_BINARY_DIR}/win/${target}.rc
@ONLY)
set(CC_PLUGIN_SOURCES ${CC_PLUGIN_SOURCES} ${CC_BINARY_DIR}/win/${target}.rc ${CC_SOURCE_DIR}/plugins/plugin.def)
endif()
add_library(${CC_PLUGIN_TARGET} MODULE ${CC_PLUGIN_SOURCES})
target_link_libraries(${CC_PLUGIN_TARGET} ${CC_PLUGIN_LIBRARIES})
set_target_properties(${CC_PLUGIN_TARGET} PROPERTIES PREFIX "")
set_target_properties(${CC_PLUGIN_TARGET}
PROPERTIES COMPILE_FLAGS
"-DPLUGIN_DYNAMIC=1 ${CC_PLUGIN_COMPILE_OPTIONS}")
if (NOT "${CC_PLUGIN_INCLUDES}" STREQUAL "")
if(CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories(${CC_PLUGIN_INCLUDES})
else()
target_include_directories(${CC_PLUGIN_TARGET} PRIVATE ${CC_PLUGIN_INCLUDES})
endif()
endif()
if (${CC_TARGET_COMPILE_OPTIONS})
target_compile_options(${CC_PLUGIN_TARGET} ${CC_TARGET_COMPILE_OPTIONS})
endif()
if(WIN32)
SIGN_TARGET(${target})
endif()
INSTALL_PLUGIN(${CC_PLUGIN_TARGET} ${CMAKE_CURRENT_BINARY_DIR})
elseif(${CC_PLUGIN_DEFAULT} STREQUAL "STATIC")
set(PLUGINS_STATIC ${PLUGINS_STATIC} ${CC_PLUGIN_TARGET} PARENT_SCOPE)
set(LIBMARIADB_PLUGIN_CFLAGS ${LIBMARIADB_PLUGIN_CFLAGS} ${CC_PLUGIN_COMPILE_OPTIONS} PARENT_SCOPE)
set(LIBMARIADB_PLUGIN_INCLUDES ${LIBMARIADB_PLUGIN_INCLUDES} ${CC_PLUGIN_INCLUDES} PARENT_SCOPE)
set(LIBMARIADB_PLUGIN_SOURCES ${LIBMARIADB_PLUGIN_SOURCES} ${CC_PLUGIN_SOURCES} PARENT_SCOPE)
set(LIBMARIADB_PLUGIN_LIBS ${LIBMARIADB_PLUGIN_LIBS} ${CC_PLUGIN_LIBRARIES} PARENT_SCOPE)
endif()
else()
set(PLUGINS_OFF ${PLUGINS_OFF} ${CC_PLUGIN_TARGET})
endif()
endfunction()

20
vendor/MDBC/cmake/sign.cmake vendored Normal file
View File

@ -0,0 +1,20 @@
#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
IF(COMMAND SIGN_TARGET)
# Do not override server's SIGN_TARGET macro
RETURN()
ENDIF()
MACRO(SIGN_TARGET target)
IF(WITH_SIGNCODE)
IF(WIN32)
SET(target_file $<TARGET_FILE:${target}>)
ADD_CUSTOM_COMMAND(TARGET ${target} COMMAND signtool ARGS sign ${SIGN_OPTIONS} ${target_file})
ENDIF()
ENDIF()
ENDMACRO()

35
vendor/MDBC/cmake/symlink.cmake vendored Normal file
View File

@ -0,0 +1,35 @@
#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
MACRO(create_symlink symlink_name target install_path)
# According to cmake documentation symlinks work on unix systems only
IF(UNIX)
# Get target components
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${symlink_name}
COMMAND ${CMAKE_COMMAND} ARGS -E remove -f ${symlink_name}
COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink $<TARGET_FILE_NAME:${target}> ${symlink_name}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${target}
)
ADD_CUSTOM_TARGET(SYM_${symlink_name}
ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${symlink_name})
SET_TARGET_PROPERTIES(SYM_${symlink_name} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
IF(CMAKE_GENERATOR MATCHES "Xcode")
# For Xcode, replace project config with install config
STRING(REPLACE "${CMAKE_CFG_INTDIR}"
"\${CMAKE_INSTALL_CONFIG_NAME}" output ${CMAKE_CURRENT_BINARY_DIR}/${symlink_name})
ENDIF()
# presumably this will be used for libmysql*.so symlinks
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${symlink_name} DESTINATION ${install_path}
COMPONENT Development)
ENDIF()
ENDMACRO()

44
vendor/MDBC/cmake/version_info.cmake vendored Normal file
View File

@ -0,0 +1,44 @@
#
# Copyright (C) 2013-2016 MariaDB Corporation AB
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the COPYING-CMAKE-SCRIPTS file.
#
FUNCTION(GET_FILE_VERSION FILE_NAME FILE_VERSION)
# if we build from a git repository, we calculate the file version:
# Patch number is number of commits for given file
IF(GIT_EXECUTABLE AND EXISTS ${CC_SOURCE_DIR}/.git)
EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} --git-dir=${CC_SOURCE_DIR}/.git --work-tree=${CC_SOURCE_DIR} rev-list HEAD --count -- ${FILE_NAME}
OUTPUT_VARIABLE FV)
STRING(REPLACE "\n" "" FV ${FV})
SET(${FILE_VERSION} ${FV} PARENT_SCOPE)
ELSE()
SET(${FILE_VERSION} 0)
ENDIF()
ENDFUNCTION()
MACRO(SET_VERSION_INFO)
SET(FILE_VERSION "0")
FOREACH(PROPERTY ${ARGN})
IF(${PROPERTY} MATCHES "TARGET:")
STRING(REGEX REPLACE "^[TARGET:\\s]" "" TARGET ${PROPERTY})
ELSEIF(${PROPERTY} MATCHES "FILE_TYPE:")
STRING(REGEX REPLACE "^[FILE_TYPE:\\s]" "" FILE_TYPE ${PROPERTY})
ELSEIF(${PROPERTY} MATCHES "ORIGINAL_FILE_NAME:")
STRING(REGEX REPLACE "^[ORIGINAL_FILE_NAME:\\s]" "" ORIGINAL_FILE_NAME ${PROPERTY})
ELSEIF(${PROPERTY} MATCHES "SOURCE_FILE:")
STRING(REGEX REPLACE "^[SOURCE_FILE:\\s]" "" SOURCE ${PROPERTY})
GET_FILE_VERSION(${SOURCE} FILE_VERSION)
ELSEIF(${PROPERTY} MATCHES "FILE_DESCRIPTION:")
STRING(REPLACE "FILE_DESCRIPTION:" "" FILE_DESCRIPTION ${PROPERTY})
ENDIF()
ENDFOREACH()
CONFIGURE_FILE(${CC_SOURCE_DIR}/win/resource.rc.in
${CC_BINARY_DIR}/win/${TARGET}.rc)
SET(${TARGET}_RC ${CC_BINARY_DIR}/win/${TARGET}.rc)
ENDMACRO()

41
vendor/MDBC/include/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,41 @@
SET(MARIADB_CLIENT_INCLUDES ${CC_SOURCE_DIR}/include/mariadb_com.h
${CC_SOURCE_DIR}/include/mysql.h
${CC_SOURCE_DIR}/include/mariadb_stmt.h
${CC_SOURCE_DIR}/include/ma_pvio.h
${CC_SOURCE_DIR}/include/ma_tls.h
${CC_BINARY_DIR}/include/mariadb_version.h
${CC_SOURCE_DIR}/include/ma_list.h
${CC_SOURCE_DIR}/include/errmsg.h
${CC_SOURCE_DIR}/include/mariadb_dyncol.h
${CC_SOURCE_DIR}/include/mariadb_ctype.h
${CC_SOURCE_DIR}/include/mariadb_rpl.h
)
IF(NOT IS_SUBPROJECT)
SET(MARIADB_CLIENT_INCLUDES ${MARIADB_CLIENT_INCLUDES}
${CC_SOURCE_DIR}/include/mysqld_error.h
)
ENDIF()
SET(MYSQL_ADDITIONAL_INCLUDES
${CC_SOURCE_DIR}/include/mysql/client_plugin.h
${CC_SOURCE_DIR}/include/mysql/plugin_auth_common.h
${CC_SOURCE_DIR}/include/mysql/plugin_auth.h
)
SET(MARIADB_ADDITIONAL_INCLUDES
${CC_SOURCE_DIR}/include/mariadb/ma_io.h
)
IF(WIN32)
SET(WIX_INCLUDES ${MARIADB_CLIENT_INCLUDES} ${MARIADB_ADDITIONAL_INCLUDES} ${MYSQL_ADDITIONAL_INCLUDES} PARENT_SCOPE)
ENDIF()
INSTALL(FILES
${MARIADB_CLIENT_INCLUDES}
DESTINATION ${INSTALL_INCLUDEDIR}
COMPONENT Development)
INSTALL(FILES
${MYSQL_ADDITIONAL_INCLUDES}
DESTINATION ${INSTALL_INCLUDEDIR}/mysql
COMPONENT Development)
INSTALL(FILES
${MARIADB_ADDITIONAL_INCLUDES}
DESTINATION ${INSTALL_INCLUDEDIR}/mariadb
COMPONENT Development)

107
vendor/MDBC/include/errmsg.h vendored Normal file
View File

@ -0,0 +1,107 @@
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
2012-2016 SkySQL AB, MariaDB Corporation AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02111-1301, USA */
/* Error messages for mysql clients */
/* error messages for the demon is in share/language/errmsg.sys */
#ifndef _errmsg_h_
#define _errmsg_h_
#ifdef __cplusplus
extern "C" {
#endif
void init_client_errs(void);
extern const char *client_errors[]; /* Error messages */
extern const char *mariadb_client_errors[]; /* Error messages */
#ifdef __cplusplus
}
#endif
#define CR_MIN_ERROR 2000 /* For easier client code */
#define CR_MAX_ERROR 2999
#define CER_MIN_ERROR 5000
#define CER_MAX_ERROR 5999
#define CER(X) mariadb_client_errors[(X)-CER_MIN_ERROR]
#define ER(X) client_errors[(X)-CR_MIN_ERROR]
#define CLIENT_ERRMAP 2 /* Errormap used by ma_error() */
#define CR_UNKNOWN_ERROR 2000
#define CR_SOCKET_CREATE_ERROR 2001
#define CR_CONNECTION_ERROR 2002
#define CR_CONN_HOST_ERROR 2003 /* never sent to a client, message only */
#define CR_IPSOCK_ERROR 2004
#define CR_UNKNOWN_HOST 2005
#define CR_SERVER_GONE_ERROR 2006 /* disappeared _between_ queries */
#define CR_VERSION_ERROR 2007
#define CR_OUT_OF_MEMORY 2008
#define CR_WRONG_HOST_INFO 2009
#define CR_LOCALHOST_CONNECTION 2010
#define CR_TCP_CONNECTION 2011
#define CR_SERVER_HANDSHAKE_ERR 2012
#define CR_SERVER_LOST 2013 /* disappeared _during_ a query */
#define CR_COMMANDS_OUT_OF_SYNC 2014
#define CR_NAMEDPIPE_CONNECTION 2015
#define CR_NAMEDPIPEWAIT_ERROR 2016
#define CR_NAMEDPIPEOPEN_ERROR 2017
#define CR_NAMEDPIPESETSTATE_ERROR 2018
#define CR_CANT_READ_CHARSET 2019
#define CR_NET_PACKET_TOO_LARGE 2020
#define CR_SSL_CONNECTION_ERROR 2026
#define CR_MALFORMED_PACKET 2027
#define CR_NO_PREPARE_STMT 2030
#define CR_PARAMS_NOT_BOUND 2031
#define CR_INVALID_PARAMETER_NO 2034
#define CR_INVALID_BUFFER_USE 2035
#define CR_UNSUPPORTED_PARAM_TYPE 2036
#define CR_SHARED_MEMORY_CONNECTION 2037
#define CR_SHARED_MEMORY_CONNECT_ERROR 2038
#define CR_CONN_UNKNOWN_PROTOCOL 2047
#define CR_SECURE_AUTH 2049
#define CR_NO_DATA 2051
#define CR_NO_STMT_METADATA 2052
#define CR_NOT_IMPLEMENTED 2054
#define CR_SERVER_LOST_EXTENDED 2055 /* never sent to a client, message only */
#define CR_STMT_CLOSED 2056
#define CR_NEW_STMT_METADATA 2057
#define CR_ALREADY_CONNECTED 2058
#define CR_AUTH_PLUGIN_CANNOT_LOAD 2059
#define CR_DUPLICATE_CONNECTION_ATTR 2060
#define CR_AUTH_PLUGIN_ERR 2061
/* Always last, if you add new error codes please update the
value for CR_MYSQL_LAST_ERROR */
#define CR_MYSQL_LAST_ERROR CR_AUTH_PLUGIN_ERR
/*
* MariaDB Connector/C errors:
*/
#define CR_EVENT_CREATE_FAILED 5000
#define CR_BIND_ADDR_FAILED 5001
#define CR_ASYNC_NOT_SUPPORTED 5002
#define CR_FUNCTION_NOT_SUPPORTED 5003
#define CR_FILE_NOT_FOUND 5004
#define CR_FILE_READ 5005
#define CR_BULK_WITHOUT_PARAMETERS 5006
#define CR_INVALID_STMT 5007
#define CR_VERSION_MISMATCH 5008
/* Always last, if you add new error codes please update the
value for CR_MARIADB_LAST_ERROR */
#define CR_MARIADB_LAST_ERROR CR_VERSION_MISMATCH
#endif

122
vendor/MDBC/include/ma_common.h vendored Normal file
View File

@ -0,0 +1,122 @@
/* Copyright (C) 2013 by MontyProgram AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02111-1301, USA */
/* defines for the libmariadb library */
#ifndef _ma_common_h
#define _ma_common_h
#include <mysql.h>
#include <ma_hashtbl.h>
enum enum_multi_status {
COM_MULTI_OFF= 0,
COM_MULTI_CANCEL,
COM_MULTI_ENABLED,
COM_MULTI_DISABLED,
COM_MULTI_END
};
typedef enum {
ALWAYS_ACCEPT, /* heuristics is disabled, use CLIENT_LOCAL_FILES */
WAIT_FOR_QUERY, /* heuristics is enabled, not sending files */
ACCEPT_FILE_REQUEST /* heuristics is enabled, ready to send a file */
} auto_local_infile_state;
typedef struct st_mariadb_db_driver
{
struct st_mariadb_client_plugin_DB *plugin;
char *name;
void *buffer;
} MARIADB_DB_DRIVER;
struct mysql_async_context;
struct st_mysql_options_extension {
char *plugin_dir;
char *default_auth;
char *ssl_crl;
char *ssl_crlpath;
char *server_public_key_path;
struct mysql_async_context *async_context;
MA_HASHTBL connect_attrs;
size_t connect_attrs_len;
void (*report_progress)(const MYSQL *mysql,
unsigned int stage,
unsigned int max_stage,
double progress,
const char *proc_info,
unsigned int proc_info_length);
MARIADB_DB_DRIVER *db_driver;
char *tls_fp; /* finger print of server certificate */
char *tls_fp_list; /* white list of finger prints */
char *tls_pw; /* password for encrypted certificates */
my_bool multi_command; /* indicates if client wants to send multiple
commands in one packet */
char *url; /* for connection handler we need to save URL for reconnect */
unsigned int tls_cipher_strength;
char *tls_version;
my_bool read_only;
char *connection_handler;
my_bool (*set_option)(MYSQL *mysql, const char *config_option, const char *config_value);
MA_HASHTBL userdata;
char *server_public_key;
char *proxy_header;
size_t proxy_header_len;
int (*io_wait)(my_socket handle, my_bool is_read, int timeout);
my_bool skip_read_response;
};
typedef struct st_connection_handler
{
struct st_ma_connection_plugin *plugin;
void *data;
my_bool active;
my_bool free_data;
} MA_CONNECTION_HANDLER;
struct st_mariadb_net_extension {
enum enum_multi_status multi_status;
int extended_errno;
};
struct st_mariadb_session_state
{
LIST *list,
*current;
};
struct st_mariadb_extension {
MA_CONNECTION_HANDLER *conn_hdlr;
struct st_mariadb_session_state session_state[SESSION_TRACK_TYPES];
unsigned long mariadb_client_flag; /* MariaDB specific client flags */
unsigned long mariadb_server_capabilities; /* MariaDB specific server capabilities */
my_bool auto_local_infile;
};
#define OPT_EXT_VAL(a,key) \
(((a)->options.extension && (a)->options.extension->key) ?\
(a)->options.extension->key : 0)
#endif
typedef struct st_mariadb_field_extension
{
MARIADB_CONST_STRING metadata[MARIADB_FIELD_ATTR_LAST+1]; /* 10.5 */
} MA_FIELD_EXTENSION;

145
vendor/MDBC/include/ma_config.h.in vendored Normal file
View File

@ -0,0 +1,145 @@
/*
* Include file constants (processed in LibmysqlIncludeFiles.txt 1
*/
#cmakedefine HAVE_OPENSSL_APPLINK_C 1
#cmakedefine HAVE_ALLOCA_H 1
#cmakedefine HAVE_BIGENDIAN 1
#cmakedefine HAVE_SETLOCALE 1
#cmakedefine HAVE_NL_LANGINFO 1
#cmakedefine HAVE_DLFCN_H 1
#cmakedefine HAVE_FCNTL_H 1
#cmakedefine HAVE_FLOAT_H 1
#cmakedefine HAVE_LIMITS_H 1
#cmakedefine HAVE_LINUX_LIMITS_H 1
#cmakedefine HAVE_PWD_H 1
#cmakedefine HAVE_SELECT_H 1
#cmakedefine HAVE_STDDEF_H 1
#cmakedefine HAVE_STDINT_H 1
#cmakedefine HAVE_STDLIB_H 1
#cmakedefine HAVE_STRING_H 1
#cmakedefine HAVE_SYS_IOCTL_H 1
#cmakedefine HAVE_SYS_SELECT_H 1
#cmakedefine HAVE_SYS_SOCKET_H 1
#cmakedefine HAVE_SYS_STREAM_H 1
#cmakedefine HAVE_SYS_STAT_H 1
#cmakedefine HAVE_SYS_SYSCTL_H 1
#cmakedefine HAVE_SYS_TYPES_H 1
#cmakedefine HAVE_SYS_UN_H 1
#cmakedefine HAVE_UNISTD_H 1
#cmakedefine HAVE_UCONTEXT_H 1
/*
* function definitions - processed in LibmysqlFunctions.txt
*/
#cmakedefine HAVE_DLERROR 1
#cmakedefine HAVE_DLOPEN 1
#cmakedefine HAVE_GETPWUID 1
#cmakedefine HAVE_MEMCPY 1
#cmakedefine HAVE_POLL 1
#cmakedefine HAVE_STRTOK_R 1
#cmakedefine HAVE_STRTOL 1
#cmakedefine HAVE_STRTOLL 1
#cmakedefine HAVE_STRTOUL 1
#cmakedefine HAVE_STRTOULL 1
#cmakedefine HAVE_TELL 1
#cmakedefine HAVE_THR_SETCONCURRENCY 1
#cmakedefine HAVE_THR_YIELD 1
#cmakedefine HAVE_VASPRINTF 1
#cmakedefine HAVE_VSNPRINTF 1
#cmakedefine HAVE_CUSERID 1
/*
* types and sizes
*/
#cmakedefine SIZEOF_CHARP @SIZEOF_CHARP@
#if defined(SIZEOF_CHARP)
# define HAVE_CHARP 1
#endif
#cmakedefine SIZEOF_INT @SIZEOF_INT@
#if defined(SIZEOF_INT)
# define HAVE_INT 1
#endif
#cmakedefine SIZEOF_LONG @SIZEOF_LONG@
#if defined(SIZEOF_LONG)
# define HAVE_LONG 1
#endif
#cmakedefine SIZEOF_LONG_LONG @SIZEOF_LONG_LONG@
#if defined(SIZEOF_LONG_LONG)
# define HAVE_LONG_LONG 1
#endif
#cmakedefine SIZEOF_SIZE_T @SIZEOF_SIZE_T@
#if defined(SIZEOF_SIZE_T)
# define HAVE_SIZE_T 1
#endif
#cmakedefine SIZEOF_UINT @SIZEOF_UINT@
#if defined(SIZEOF_UINT)
# define HAVE_UINT 1
#endif
#cmakedefine SIZEOF_ULONG @SIZEOF_ULONG@
#if defined(SIZEOF_ULONG)
# define HAVE_ULONG 1
#endif
#cmakedefine SIZEOF_INT8 @SIZEOF_INT8@
#if defined(SIZEOF_INT8)
# define HAVE_INT8 1
#endif
#cmakedefine SIZEOF_UINT8 @SIZEOF_UINT8@
#if defined(SIZEOF_UINT8)
# define HAVE_UINT8 1
#endif
#cmakedefine SIZEOF_INT16 @SIZEOF_INT16@
#if defined(SIZEOF_INT16)
# define HAVE_INT16 1
#endif
#cmakedefine SIZEOF_UINT16 @SIZEOF_UINT16@
#if defined(SIZEOF_UINT16)
# define HAVE_UINT16 1
#endif
#cmakedefine SIZEOF_INT32 @SIZEOF_INT32@
#if defined(SIZEOF_INT32)
# define HAVE_INT32 1
#endif
#cmakedefine SIZEOF_UINT32 @SIZEOF_UINT32@
#if defined(SIZEOF_UINT32)
# define HAVE_UINT32 1
#endif
#cmakedefine SIZEOF_INT64 @SIZEOF_INT64@
#if defined(SIZEOF_INT64)
# define HAVE_INT64 1
#endif
#cmakedefine SIZEOF_UINT64 @SIZEOF_UINT64@
#if defined(SIZEOF_UINT64)
# define HAVE_UINT64 1
#endif
#cmakedefine SIZEOF_SOCKLEN_T @SIZEOF_SOCKLEN_T@
#if defined(SIZEOF_SOCKLEN_T)
# define HAVE_SOCKLEN_T 1
#endif
#cmakedefine SOCKET_SIZE_TYPE @SOCKET_SIZE_TYPE@
#define LOCAL_INFILE_MODE_OFF 0
#define LOCAL_INFILE_MODE_ON 1
#define LOCAL_INFILE_MODE_AUTO 2
#define ENABLED_LOCAL_INFILE LOCAL_INFILE_MODE_@ENABLED_LOCAL_INFILE@
#define MARIADB_DEFAULT_CHARSET "@DEFAULT_CHARSET@"

236
vendor/MDBC/include/ma_context.h vendored Normal file
View File

@ -0,0 +1,236 @@
/*
Copyright 2011 Kristian Nielsen and Monty Program Ab
This file is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU General Public License
along with this. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Simple API for spawning a co-routine, to be used for async libmysqlclient.
Idea is that by implementing this interface using whatever facilities are
available for given platform, we can use the same code for the generic
libmysqlclient-async code.
(This particular implementation uses Posix ucontext swapcontext().)
*/
#ifdef _WIN32
#define MY_CONTEXT_USE_WIN32_FIBERS 1
#elif defined(__GNUC__) && __GNUC__ >= 3 && defined(__x86_64__) && !defined(__ILP32__)
#define MY_CONTEXT_USE_X86_64_GCC_ASM
#elif defined(__GNUC__) && __GNUC__ >= 3 && defined(__i386__)
#define MY_CONTEXT_USE_I386_GCC_ASM
#elif defined(HAVE_UCONTEXT_H)
#define MY_CONTEXT_USE_UCONTEXT
#else
#define MY_CONTEXT_DISABLE
#endif
#ifdef MY_CONTEXT_USE_WIN32_FIBERS
struct my_context {
void (*user_func)(void *);
void *user_arg;
void *app_fiber;
void *lib_fiber;
int return_value;
#ifndef DBUG_OFF
void *dbug_state;
#endif
};
#endif
#ifdef MY_CONTEXT_USE_UCONTEXT
#if defined(__APPLE__) && !defined(_XOPEN_SOURCE)
#define _XOPEN_SOURCE 600
#endif
#include <ucontext.h>
struct my_context {
void (*user_func)(void *);
void *user_data;
void *stack;
size_t stack_size;
ucontext_t base_context;
ucontext_t spawned_context;
int active;
#ifdef HAVE_VALGRIND
unsigned int valgrind_stack_id;
#endif
#ifndef DBUG_OFF
void *dbug_state;
#endif
};
#endif
#ifdef MY_CONTEXT_USE_X86_64_GCC_ASM
#include <stdint.h>
struct my_context {
uint64_t save[9];
void *stack_top;
void *stack_bot;
#ifdef HAVE_VALGRIND
unsigned int valgrind_stack_id;
#endif
#ifndef DBUG_OFF
void *dbug_state;
#endif
};
#endif
#ifdef MY_CONTEXT_USE_I386_GCC_ASM
#include <stdint.h>
struct my_context {
uint64_t save[7];
void *stack_top;
void *stack_bot;
#ifdef HAVE_VALGRIND
unsigned int valgrind_stack_id;
#endif
#ifndef DBUG_OFF
void *dbug_state;
#endif
};
#endif
#ifdef MY_CONTEXT_DISABLE
struct my_context {
int dummy;
};
#endif
/*
Initialize an asynchroneous context object.
Returns 0 on success, non-zero on failure.
*/
extern int my_context_init(struct my_context *c, size_t stack_size);
/* Free an asynchroneous context object, deallocating any resources used. */
extern void my_context_destroy(struct my_context *c);
/*
Spawn an asynchroneous context. The context will run the supplied user
function, passing the supplied user data pointer.
The context must have been initialised with my_context_init() prior to
this call.
The user function may call my_context_yield(), which will cause this
function to return 1. Then later my_context_continue() may be called, which
will resume the asynchroneous context by returning from the previous
my_context_yield() call.
When the user function returns, this function returns 0.
In case of error, -1 is returned.
*/
extern int my_context_spawn(struct my_context *c, void (*f)(void *), void *d);
/*
Suspend an asynchroneous context started with my_context_spawn.
When my_context_yield() is called, execution immediately returns from the
last my_context_spawn() or my_context_continue() call. Then when later
my_context_continue() is called, execution resumes by returning from this
my_context_yield() call.
Returns 0 if ok, -1 in case of error.
*/
extern int my_context_yield(struct my_context *c);
/*
Resume an asynchroneous context. The context was spawned by
my_context_spawn(), and later suspended inside my_context_yield().
The asynchroneous context may be repeatedly suspended with
my_context_yield() and resumed with my_context_continue().
Each time it is suspended, this function returns 1. When the originally
spawned user function returns, this function returns 0.
In case of error, -1 is returned.
*/
extern int my_context_continue(struct my_context *c);
struct st_ma_pvio;
struct mysql_async_context {
/*
This is set to the value that should be returned from foo_start() or
foo_cont() when a call is suspended.
*/
unsigned int events_to_wait_for;
/*
It is also set to the event(s) that triggered when a suspended call is
resumed, eg. whether we woke up due to connection completed or timeout
in mysql_real_connect_cont().
*/
unsigned int events_occured;
/*
This is set to the result of the whole asynchronous operation when it
completes. It uses a union, as different calls have different return
types.
*/
union {
void *r_ptr;
const void *r_const_ptr;
int r_int;
my_bool r_my_bool;
} ret_result;
/*
The timeout value (in millisecods), for suspended calls that need to wake
up on a timeout (eg. mysql_real_connect_start().
*/
unsigned int timeout_value;
/*
This flag is set when we are executing inside some asynchronous call
foo_start() or foo_cont(). It is used to decide whether to use the
synchronous or asynchronous version of calls that may block such as
recv().
Note that this flag is not set when a call is suspended, eg. after
returning from foo_start() and before re-entering foo_cont().
*/
my_bool active;
/*
This flag is set when an asynchronous operation is in progress, but
suspended. Ie. it is set when foo_start() or foo_cont() returns because
the operation needs to block, suspending the operation.
It is used to give an error (rather than crash) if the application
attempts to call some foo_cont() method when no suspended operation foo is
in progress.
*/
my_bool suspended;
/*
If non-NULL, this is a pointer to a callback hook that will be invoked with
the user data argument just before the context is suspended, and just after
it is resumed.
*/
struct st_ma_pvio *pvio;
void (*suspend_resume_hook)(my_bool suspend, void *user_data);
void *suspend_resume_hook_user_data;
/*
This is used to save the execution contexts so that we can suspend an
operation and switch back to the application context, to resume the
suspended context later when the application re-invokes us with
foo_cont().
*/
struct my_context async_context;
};

166
vendor/MDBC/include/ma_crypt.h vendored Normal file
View File

@ -0,0 +1,166 @@
/*
Copyright (C) 2018 MariaDB Corporation AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not see <http://www.gnu.org/licenses>
or write to the Free Software Foundation, Inc.,
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
*/
#ifndef _ma_hash_h_
#define _ma_hash_h_
#include <stddef.h>
#include <stdarg.h>
/*! Hash algorithms */
#define MA_HASH_MD5 1
#define MA_HASH_SHA1 2
#define MA_HASH_SHA224 3
#define MA_HASH_SHA256 4
#define MA_HASH_SHA384 5
#define MA_HASH_SHA512 6
#define MA_HASH_RIPEMD160 7
/*! Hash digest sizes */
#define MA_MD5_HASH_SIZE 16
#define MA_SHA1_HASH_SIZE 20
#define MA_SHA224_HASH_SIZE 28
#define MA_SHA256_HASH_SIZE 32
#define MA_SHA384_HASH_SIZE 48
#define MA_SHA512_HASH_SIZE 64
#define MA_RIPEMD160_HASH_SIZE 20
#define MA_MAX_HASH_SIZE 64
/** \typedef MRL hash context */
#if defined(_WIN32)
#include <windows.h>
#include <bcrypt.h>
typedef struct {
char free_me;
BCRYPT_ALG_HANDLE hAlg;
BCRYPT_HASH_HANDLE hHash;
PBYTE hashObject;
DWORD digest_len;
} MA_HASH_CTX;
#elif defined(HAVE_OPENSSL)
typedef void MA_HASH_CTX;
#elif defined(HAVE_GNUTLS)
typedef struct {
void *ctx;
const struct nettle_hash *hash;
} MA_HASH_CTX;
#endif
/**
@brief acquire and initialize new hash context
@param[in] algorithm hash algorithm
@param[in] ctx pointer to a crypto context
@return hash context on success, NULL on error
*/
MA_HASH_CTX *ma_hash_new(unsigned int algorithm, MA_HASH_CTX *ctx);
/**
@brief release and deinitializes a hash context
@param[in] hash context
@return void
*/
void ma_hash_free(MA_HASH_CTX *ctx);
/**
@brief hashes len bytes of data into the hash context.
This function can be called several times on same context to
hash additional data.
@param[in] ctx hash context
@param[in] buffer data buffer
@param[in] len size of buffer
@return void
*/
void ma_hash_input(MA_HASH_CTX *ctx,
const unsigned char *buffer,
size_t len);
/**
@brief retrieves the hash value from hash context
@param[in] ctx hash context
@param[out] digest digest containing hash value
@return void
*/
void ma_hash_result(MA_HASH_CTX *ctx, unsigned char *digest);
/**
@brief returns digest size for a given hash algorithm
@param[in] hash algorithm
@returns digest size or 0 on error
*/
static inline size_t ma_hash_digest_size(unsigned int hash_alg)
{
switch(hash_alg) {
case MA_HASH_MD5:
return MA_MD5_HASH_SIZE;
case MA_HASH_SHA1:
return MA_SHA1_HASH_SIZE;
case MA_HASH_SHA224:
return MA_SHA224_HASH_SIZE;
case MA_HASH_SHA256:
return MA_SHA256_HASH_SIZE;
case MA_HASH_SHA384:
return MA_SHA384_HASH_SIZE;
case MA_HASH_SHA512:
return MA_SHA512_HASH_SIZE;
case MA_HASH_RIPEMD160:
return MA_RIPEMD160_HASH_SIZE;
default:
return 0;
}
}
/**
@brief function to compute hash from buffer.
@param[in] hash_alg hash algorithm
@param[in] buffer buffer
@param[in] buffer_leng length of buffer
@param[out] digest computed hash digest
@return void
*/
static inline void ma_hash(unsigned int algorithm,
const unsigned char *buffer,
size_t buffer_length,
unsigned char *digest)
{
MA_HASH_CTX *ctx= NULL;
#ifdef _WIN32
MA_HASH_CTX dctx;
ctx= &dctx;
#endif
ctx= ma_hash_new(algorithm, ctx);
ma_hash_input(ctx, buffer, buffer_length);
ma_hash_result(ctx, digest);
ma_hash_free(ctx);
}
#endif /* _ma_hash_h_ */

1094
vendor/MDBC/include/ma_global.h vendored Normal file

File diff suppressed because it is too large Load Diff

70
vendor/MDBC/include/ma_hashtbl.h vendored Normal file
View File

@ -0,0 +1,70 @@
/************************************************************************************
Copyright (C) 2000, 2012 MySQL AB & MySQL Finland AB & TCX DataKonsult AB,
Monty Program AB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not see <http://www.gnu.org/licenses>
or write to the Free Software Foundation, Inc.,
51 Franklin St., Fifth Floor, Boston, MA 02110, USA
Part of this code includes code from the PHP project which
is freely available from http://www.php.net
*************************************************************************************/
#ifndef _ma_hashtbl_h
#define _ma_hashtbl_h
#ifdef __cplusplus
extern "C" {
#endif
typedef uchar *(*hash_get_key)(const uchar *,uint*,my_bool);
typedef void (*hash_free_key)(void *);
/* flags for hash_init */
#define MA_HASHTBL_CASE_INSENSITIVE 1
typedef struct st_hash_info {
uint next; /* index to next key */
uchar *data; /* data for current entry */
} MA_HASHTBL_LINK;
typedef struct st_hash {
uint key_offset,key_length; /* Length of key if const length */
uint records,blength,current_record;
uint flags;
DYNAMIC_ARRAY array; /* Place for hash_keys */
hash_get_key get_key;
void (*free)(void *);
uint (*calc_hashnr)(const uchar *key,uint length);
} MA_HASHTBL;
#define ma_hashtbl_init(A,B,C,D,E,F,G) _ma_hashtbl_init(A,B,C,D,E,F,G CALLER_INFO)
my_bool _ma_hashtbl_init(MA_HASHTBL *hash,uint default_array_elements, uint key_offset,
uint key_length, hash_get_key get_key,
void (*free_element)(void*), uint flags CALLER_INFO_PROTO);
void ma_hashtbl_free(MA_HASHTBL *tree);
uchar *ma_hashtbl_element(MA_HASHTBL *hash,uint idx);
void * ma_hashtbl_search(MA_HASHTBL *info,const uchar *key,uint length);
void * ma_hashtbl_next(MA_HASHTBL *info,const uchar *key,uint length);
my_bool ma_hashtbl_insert(MA_HASHTBL *info,const uchar *data);
my_bool ma_hashtbl_delete(MA_HASHTBL *hash,uchar *record);
my_bool ma_hashtbl_update(MA_HASHTBL *hash,uchar *record,uchar *old_key,uint old_key_length);
my_bool ma_hashtbl_check(MA_HASHTBL *hash); /* Only in debug library */
#define ma_hashtbl_clear(H) memset((char*) (H), 0,sizeof(*(H)))
#define ma_hashtbl_inited(H) ((H)->array.buffer != 0)
#ifdef __cplusplus
}
#endif
#endif

Some files were not shown because too many files have changed in this diff Show More