mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Compare commits
14 Commits
8d15f4b6e9
...
8d93ab482c
Author | SHA1 | Date | |
---|---|---|---|
|
8d93ab482c | ||
|
e0761bf3b9 | ||
|
a589fbede0 | ||
|
6422c1aad4 | ||
|
aa8953dd8e | ||
|
fa79a51c46 | ||
|
2431f69391 | ||
|
3cd3320e02 | ||
|
aca50cab7c | ||
|
5d5d5b7920 | ||
|
cbd8f8b028 | ||
|
b08a024298 | ||
|
0ef37e977c | ||
|
233fc103f9 |
@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required(VERSION 3.7)
|
cmake_minimum_required(VERSION 3.21)
|
||||||
project(SqMod)
|
project(SqMod)
|
||||||
|
|
||||||
# This plug-in only works on 64-bit
|
# This plug-in only works on 64-bit
|
||||||
@ -7,8 +7,7 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Tell CMake where to find our scripts
|
# Tell CMake where to find our scripts
|
||||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${PROJECT_SOURCE_DIR}/vendor/POCO/cmake)
|
||||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/vendor/POCO/cmake)
|
|
||||||
|
|
||||||
# Several plugin options
|
# Several plugin options
|
||||||
option(ENABLE_API21 "Build for 2.1 API." OFF)
|
option(ENABLE_API21 "Build for 2.1 API." OFF)
|
||||||
@ -20,85 +19,12 @@ option(ENABLE_BUILTIN_MYSQL_C "Enable built-in MySQL connector library" OFF)
|
|||||||
if(WIN32 AND MINGW)
|
if(WIN32 AND MINGW)
|
||||||
option(COPY_DEPENDENCIES "Copy dependent DLLs into the deps folder." OFF)
|
option(COPY_DEPENDENCIES "Copy dependent DLLs into the deps folder." OFF)
|
||||||
endif()
|
endif()
|
||||||
|
# Discord suppport
|
||||||
|
option(ENABLE_DISCORD "Enable built-in Discord support." ON)
|
||||||
|
|
||||||
# C++14 is mandatory
|
# C++17 is mandatory (globally)
|
||||||
set(CPP_STD_NUMBER 14)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
include(CheckCXXCompilerFlag)
|
|
||||||
# C++ standard availability check
|
|
||||||
if(${CMAKE_CXX_COMPILER_ID} MATCHES "(GNU)+")
|
|
||||||
# Specific flags
|
|
||||||
set(CPP_STD_COMPILER_FLAG "-std=c++14")
|
|
||||||
# Don't even bother with previous version
|
|
||||||
if(CPP_STD_NUMBER LESS 20 AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
|
|
||||||
check_cxx_compiler_flag(-std=c++20 HAVE_FLAG_STD_CXX20)
|
|
||||||
check_cxx_compiler_flag(-std=c++2a HAVE_FLAG_STD_CXX2A)
|
|
||||||
if(HAVE_FLAG_STD_CXX20 OR HAVE_FLAG_STD_CXX2A)
|
|
||||||
# We can use C++20
|
|
||||||
set(CPP_STD_NUMBER 20)
|
|
||||||
# Specific flags
|
|
||||||
if (HAVE_FLAG_STD_CXX2A AND NOT HAVE_FLAG_STD_CXX20)
|
|
||||||
set(CPP_STD_COMPILER_FLAG "-std=c++2a")
|
|
||||||
else()
|
|
||||||
set(CPP_STD_COMPILER_FLAG "-std=c++20")
|
|
||||||
endif()
|
|
||||||
# Need these workarounds for older CMake
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
|
|
||||||
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0)
|
|
||||||
set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++20")
|
|
||||||
set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++20")
|
|
||||||
elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
|
|
||||||
set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a")
|
|
||||||
set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
# Don't even bother with previous version
|
|
||||||
if(CPP_STD_NUMBER LESS 17 AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
|
|
||||||
check_cxx_compiler_flag(-std=c++17 HAVE_FLAG_STD_CXX17)
|
|
||||||
check_cxx_compiler_flag(-std=c++1z HAVE_FLAG_STD_CXX1Z)
|
|
||||||
if(HAVE_FLAG_STD_CXX17 OR HAVE_FLAG_STD_CXX1Z)
|
|
||||||
# We can use C++17
|
|
||||||
set(CPP_STD_NUMBER 17)
|
|
||||||
# Specific flags
|
|
||||||
if (HAVE_FLAG_STD_CXX1Z AND NOT HAVE_FLAG_STD_CXX17)
|
|
||||||
set(CPP_STD_COMPILER_FLAG "-std=c++1z")
|
|
||||||
else()
|
|
||||||
set(CPP_STD_COMPILER_FLAG "-std=c++17")
|
|
||||||
endif()
|
|
||||||
# Need these workarounds for older CMake
|
|
||||||
if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
|
|
||||||
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
|
|
||||||
set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17")
|
|
||||||
set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17")
|
|
||||||
elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
|
|
||||||
set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++1z")
|
|
||||||
set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
# C++14 is mandatory
|
|
||||||
set(CPP_STD_NUMBER 14)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
message(STATUS "SqMod: Using C++${CPP_STD_NUMBER} standard.")
|
|
||||||
|
|
||||||
# Default to the identified standard
|
|
||||||
if(CMAKE_VERSION VERSION_LESS "3.1")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPP_STD_COMPILER_FLAG}")
|
|
||||||
else()
|
|
||||||
# Apparently the above does not work with cmake from on debian 8
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPP_STD_COMPILER_FLAG}")
|
|
||||||
# F* you too Debian. What can I say.
|
|
||||||
if(CMAKE_VERSION VERSION_LESS "3.8.0" AND CPP_STD_NUMBER LESS 17)
|
|
||||||
# Try the standard method as well
|
|
||||||
set(CMAKE_CXX_STANDARD ${CPP_STD_NUMBER})
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Strip binary
|
# Strip binary
|
||||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s -g")
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s -g")
|
||||||
|
152
cmake/FindFFmpeg.cmake
Normal file
152
cmake/FindFFmpeg.cmake
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
# vim: ts=2 sw=2
|
||||||
|
# - Try to find the required ffmpeg components(default: AVFORMAT, AVUTIL, AVCODEC)
|
||||||
|
#
|
||||||
|
# Once done this will define
|
||||||
|
# FFMPEG_FOUND - System has the all required components.
|
||||||
|
# FFMPEG_INCLUDE_DIRS - Include directory necessary for using the required components headers.
|
||||||
|
# FFMPEG_LIBRARIES - Link these to use the required ffmpeg components.
|
||||||
|
# FFMPEG_DEFINITIONS - Compiler switches required for using the required ffmpeg components.
|
||||||
|
#
|
||||||
|
# For each of the components it will additionally set.
|
||||||
|
# - AVCODEC
|
||||||
|
# - AVDEVICE
|
||||||
|
# - AVFORMAT
|
||||||
|
# - AVFILTER
|
||||||
|
# - AVUTIL
|
||||||
|
# - POSTPROC
|
||||||
|
# - SWSCALE
|
||||||
|
# - SWRESAMPLE
|
||||||
|
# the following variables will be defined
|
||||||
|
# <component>_FOUND - System has <component>
|
||||||
|
# <component>_INCLUDE_DIRS - Include directory necessary for using the <component> headers
|
||||||
|
# <component>_LIBRARIES - Link these to use <component>
|
||||||
|
# <component>_DEFINITIONS - Compiler switches required for using <component>
|
||||||
|
# <component>_VERSION - The components version
|
||||||
|
#
|
||||||
|
# Copyright (c) 2006, Matthias Kretz, <kretz@kde.org>
|
||||||
|
# Copyright (c) 2008, Alexander Neundorf, <neundorf@kde.org>
|
||||||
|
# Copyright (c) 2011, Michael Jansen, <kde@michael-jansen.biz>
|
||||||
|
#
|
||||||
|
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||||
|
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
# The default components were taken from a survey over other FindFFMPEG.cmake files
|
||||||
|
if (NOT FFmpeg_FIND_COMPONENTS)
|
||||||
|
set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
#
|
||||||
|
### Macro: set_component_found
|
||||||
|
#
|
||||||
|
# Marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIRS is present.
|
||||||
|
#
|
||||||
|
macro(set_component_found _component )
|
||||||
|
if (${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS)
|
||||||
|
# message(STATUS " - ${_component} found.")
|
||||||
|
set(${_component}_FOUND TRUE)
|
||||||
|
else ()
|
||||||
|
# message(STATUS " - ${_component} not found.")
|
||||||
|
endif ()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
#
|
||||||
|
### Macro: find_component
|
||||||
|
#
|
||||||
|
# Checks for the given component by invoking pkgconfig and then looking up the libraries and
|
||||||
|
# include directories.
|
||||||
|
#
|
||||||
|
macro(find_component _component _pkgconfig _library _header)
|
||||||
|
|
||||||
|
if (NOT WIN32)
|
||||||
|
# use pkg-config to get the directories and then use these values
|
||||||
|
# in the FIND_PATH() and FIND_LIBRARY() calls
|
||||||
|
find_package(PkgConfig)
|
||||||
|
if (PKG_CONFIG_FOUND)
|
||||||
|
pkg_check_modules(PC_${_component} ${_pkgconfig})
|
||||||
|
endif ()
|
||||||
|
endif (NOT WIN32)
|
||||||
|
|
||||||
|
find_path(${_component}_INCLUDE_DIRS ${_header}
|
||||||
|
HINTS
|
||||||
|
${PC_${_component}_INCLUDEDIR}
|
||||||
|
${PC_${_component}_INCLUDE_DIRS}
|
||||||
|
PATH_SUFFIXES
|
||||||
|
ffmpeg
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(${_component}_LIBRARIES NAMES ${_library}
|
||||||
|
HINTS
|
||||||
|
${PC_${_component}_LIBDIR}
|
||||||
|
${PC_${_component}_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER} CACHE STRING "The ${_component} CFLAGS.")
|
||||||
|
set(${_component}_VERSION ${PC_${_component}_VERSION} CACHE STRING "The ${_component} version number.")
|
||||||
|
|
||||||
|
set_component_found(${_component})
|
||||||
|
|
||||||
|
mark_as_advanced(
|
||||||
|
${_component}_INCLUDE_DIRS
|
||||||
|
${_component}_LIBRARIES
|
||||||
|
${_component}_DEFINITIONS
|
||||||
|
${_component}_VERSION)
|
||||||
|
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
|
# Check for cached results. If there are skip the costly part.
|
||||||
|
if (NOT FFMPEG_LIBRARIES)
|
||||||
|
|
||||||
|
# Check for all possible component.
|
||||||
|
find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h)
|
||||||
|
find_component(AVFORMAT libavformat avformat libavformat/avformat.h)
|
||||||
|
find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h)
|
||||||
|
find_component(AVUTIL libavutil avutil libavutil/avutil.h)
|
||||||
|
find_component(AVFILTER libavfilter avfilter libavfilter/avfilter.h)
|
||||||
|
find_component(SWSCALE libswscale swscale libswscale/swscale.h)
|
||||||
|
find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h)
|
||||||
|
find_component(SWRESAMPLE libswresample swresample libswresample/swresample.h)
|
||||||
|
|
||||||
|
# Check if the required components were found and add their stuff to the FFMPEG_* vars.
|
||||||
|
foreach (_component ${FFmpeg_FIND_COMPONENTS})
|
||||||
|
if (${_component}_FOUND)
|
||||||
|
# message(STATUS "Required component ${_component} present.")
|
||||||
|
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${_component}_LIBRARIES})
|
||||||
|
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${_component}_DEFINITIONS})
|
||||||
|
list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS})
|
||||||
|
else ()
|
||||||
|
# message(STATUS "Required component ${_component} missing.")
|
||||||
|
endif ()
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
# Build the include path with duplicates removed.
|
||||||
|
if (FFMPEG_INCLUDE_DIRS)
|
||||||
|
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# cache the vars.
|
||||||
|
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE)
|
||||||
|
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE)
|
||||||
|
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} CACHE STRING "The FFmpeg cflags." FORCE)
|
||||||
|
|
||||||
|
mark_as_advanced(FFMPEG_INCLUDE_DIRS
|
||||||
|
FFMPEG_LIBRARIES
|
||||||
|
FFMPEG_DEFINITIONS)
|
||||||
|
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Now set the noncached _FOUND vars for the components.
|
||||||
|
foreach (_component AVCODEC AVDEVICE AVFORMAT AVUTIL POSTPROCESS SWSCALE)
|
||||||
|
set_component_found(${_component})
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
# Compile the list of required vars
|
||||||
|
set(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS)
|
||||||
|
foreach (_component ${FFmpeg_FIND_COMPONENTS})
|
||||||
|
list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS)
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
# Give a nice error message if some of the required vars are missing.
|
||||||
|
find_package_handle_standard_args(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS})
|
36
cmake/FindOpus.cmake
Normal file
36
cmake/FindOpus.cmake
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# OPUS_FOUND - system has opus
|
||||||
|
# OPUS_INCLUDE_DIRS - the opus include directory
|
||||||
|
# OPUS_LIBRARIES - The libraries needed to use opus
|
||||||
|
|
||||||
|
find_path(OPUS_INCLUDE_DIRS
|
||||||
|
NAMES opus/opus.h
|
||||||
|
PATH_SUFFIXES include
|
||||||
|
)
|
||||||
|
if(OPUS_INCLUDE_DIRS)
|
||||||
|
set(HAVE_OPUS_OPUS_H 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(OPUS_USE_STATIC_LIBS)
|
||||||
|
find_library(OPUS_LIBRARIES NAMES "libopus.a")
|
||||||
|
else()
|
||||||
|
find_library(OPUS_LIBRARIES NAMES opus)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(OPUS_LIBRARIES)
|
||||||
|
if(OPUS_USE_STATIC_LIBS)
|
||||||
|
find_library(LIBM NAMES "libm.a" "libm.tbd")
|
||||||
|
else()
|
||||||
|
find_library(LIBM NAMES m)
|
||||||
|
endif()
|
||||||
|
if(LIBM)
|
||||||
|
list(APPEND OPUS_LIBRARIES ${LIBM})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(Opus
|
||||||
|
DEFAULT_MSG
|
||||||
|
OPUS_INCLUDE_DIRS OPUS_LIBRARIES HAVE_OPUS_OPUS_H
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(OPUS_INCLUDE_DIRS OPUS_LIBRARIES HAVE_OPUS_OPUS_H)
|
293
cmake/FindSodium.cmake
Normal file
293
cmake/FindSodium.cmake
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
# Written in 2016 by Henrik Steffen Gaßmann <henrik@gassmann.onl>
|
||||||
|
#
|
||||||
|
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||||
|
# and related and neighboring rights to this software to the public domain
|
||||||
|
# worldwide. This software is distributed without any warranty.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||||
|
# this software. If not, see
|
||||||
|
#
|
||||||
|
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
#
|
||||||
|
# ##############################################################################
|
||||||
|
# Tries to find the local libsodium installation.
|
||||||
|
#
|
||||||
|
# On Windows the sodium_DIR environment variable is used as a default hint which
|
||||||
|
# can be overridden by setting the corresponding cmake variable.
|
||||||
|
#
|
||||||
|
# Once done the following variables will be defined:
|
||||||
|
#
|
||||||
|
# sodium_FOUND sodium_INCLUDE_DIR sodium_LIBRARY_DEBUG sodium_LIBRARY_RELEASE
|
||||||
|
# sodium_VERSION_STRING
|
||||||
|
#
|
||||||
|
# Furthermore an imported "sodium" target is created.
|
||||||
|
#
|
||||||
|
|
||||||
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||||
|
set(_GCC_COMPATIBLE 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# static library option
|
||||||
|
if(NOT DEFINED sodium_USE_STATIC_LIBS)
|
||||||
|
option(sodium_USE_STATIC_LIBS "enable to statically link against sodium" OFF)
|
||||||
|
endif()
|
||||||
|
if(NOT (sodium_USE_STATIC_LIBS EQUAL sodium_USE_STATIC_LIBS_LAST))
|
||||||
|
unset(sodium_LIBRARY CACHE)
|
||||||
|
unset(sodium_LIBRARY_DEBUG CACHE)
|
||||||
|
unset(sodium_LIBRARY_RELEASE CACHE)
|
||||||
|
unset(sodium_DLL_DEBUG CACHE)
|
||||||
|
unset(sodium_DLL_RELEASE CACHE)
|
||||||
|
set(sodium_USE_STATIC_LIBS_LAST
|
||||||
|
${sodium_USE_STATIC_LIBS}
|
||||||
|
CACHE INTERNAL "internal change tracking variable")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ##############################################################################
|
||||||
|
# UNIX
|
||||||
|
if(UNIX)
|
||||||
|
# import pkg-config
|
||||||
|
find_package(PkgConfig)
|
||||||
|
if(PKG_CONFIG_FOUND)
|
||||||
|
pkg_check_modules(sodium_PKG QUIET libsodium)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(sodium_USE_STATIC_LIBS)
|
||||||
|
if(sodium_PKG_STATIC_LIBRARIES)
|
||||||
|
foreach(_libname ${sodium_PKG_STATIC_LIBRARIES})
|
||||||
|
if(NOT _libname MATCHES "^lib.*\\.a$") # ignore strings already ending
|
||||||
|
# with .a
|
||||||
|
list(INSERT sodium_PKG_STATIC_LIBRARIES 0 "lib${_libname}.a")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
list(REMOVE_DUPLICATES sodium_PKG_STATIC_LIBRARIES)
|
||||||
|
else()
|
||||||
|
# if pkgconfig for libsodium doesn't provide static lib info, then
|
||||||
|
# override PKG_STATIC here..
|
||||||
|
set(sodium_PKG_STATIC_LIBRARIES libsodium.a)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(XPREFIX sodium_PKG_STATIC)
|
||||||
|
else()
|
||||||
|
if(sodium_PKG_LIBRARIES STREQUAL "")
|
||||||
|
set(sodium_PKG_LIBRARIES sodium)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(XPREFIX sodium_PKG)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_path(sodium_INCLUDE_DIR sodium.h HINTS ${${XPREFIX}_INCLUDE_DIRS})
|
||||||
|
find_library(sodium_LIBRARY_DEBUG
|
||||||
|
NAMES ${${XPREFIX}_LIBRARIES}
|
||||||
|
HINTS ${${XPREFIX}_LIBRARY_DIRS})
|
||||||
|
find_library(sodium_LIBRARY_RELEASE
|
||||||
|
NAMES ${${XPREFIX}_LIBRARIES}
|
||||||
|
HINTS ${${XPREFIX}_LIBRARY_DIRS})
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# Windows
|
||||||
|
elseif(WIN32)
|
||||||
|
set(sodium_DIR "$ENV{sodium_DIR}" CACHE FILEPATH "sodium install directory")
|
||||||
|
mark_as_advanced(sodium_DIR)
|
||||||
|
|
||||||
|
find_path(sodium_INCLUDE_DIR sodium.h
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES include)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# detect target architecture
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp" [=[
|
||||||
|
#if defined _M_IX86
|
||||||
|
#error ARCH_VALUE x86_32
|
||||||
|
#elif defined _M_X64
|
||||||
|
#error ARCH_VALUE x86_64
|
||||||
|
#endif
|
||||||
|
#error ARCH_VALUE unknown
|
||||||
|
]=])
|
||||||
|
try_compile(_UNUSED_VAR "${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/arch.cpp"
|
||||||
|
OUTPUT_VARIABLE _COMPILATION_LOG)
|
||||||
|
string(REGEX
|
||||||
|
REPLACE ".*ARCH_VALUE ([a-zA-Z0-9_]+).*"
|
||||||
|
"\\1"
|
||||||
|
_TARGET_ARCH
|
||||||
|
"${_COMPILATION_LOG}")
|
||||||
|
|
||||||
|
# construct library path
|
||||||
|
if(_TARGET_ARCH STREQUAL "x86_32")
|
||||||
|
string(APPEND _PLATFORM_PATH "Win32")
|
||||||
|
elseif(_TARGET_ARCH STREQUAL "x86_64")
|
||||||
|
string(APPEND _PLATFORM_PATH "x64")
|
||||||
|
else()
|
||||||
|
message(
|
||||||
|
FATAL_ERROR
|
||||||
|
"the ${_TARGET_ARCH} architecture is not supported by Findsodium.cmake."
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
string(APPEND _PLATFORM_PATH "/$$CONFIG$$")
|
||||||
|
|
||||||
|
if(MSVC_VERSION LESS 1900)
|
||||||
|
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 60")
|
||||||
|
else()
|
||||||
|
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 50")
|
||||||
|
endif()
|
||||||
|
string(APPEND _PLATFORM_PATH "/v${_VS_VERSION}")
|
||||||
|
|
||||||
|
if(sodium_USE_STATIC_LIBS)
|
||||||
|
string(APPEND _PLATFORM_PATH "/static")
|
||||||
|
else()
|
||||||
|
string(APPEND _PLATFORM_PATH "/dynamic")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
string(REPLACE "$$CONFIG$$"
|
||||||
|
"Debug"
|
||||||
|
_DEBUG_PATH_SUFFIX
|
||||||
|
"${_PLATFORM_PATH}")
|
||||||
|
string(REPLACE "$$CONFIG$$"
|
||||||
|
"Release"
|
||||||
|
_RELEASE_PATH_SUFFIX
|
||||||
|
"${_PLATFORM_PATH}")
|
||||||
|
|
||||||
|
find_library(sodium_LIBRARY_DEBUG libsodium.lib
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX})
|
||||||
|
find_library(sodium_LIBRARY_RELEASE libsodium.lib
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX})
|
||||||
|
if(NOT sodium_USE_STATIC_LIBS)
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES_BCK ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
|
||||||
|
find_library(sodium_DLL_DEBUG libsodium
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX})
|
||||||
|
find_library(sodium_DLL_RELEASE libsodium
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX})
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_BCK})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
elseif(_GCC_COMPATIBLE)
|
||||||
|
if(sodium_USE_STATIC_LIBS)
|
||||||
|
find_library(sodium_LIBRARY_DEBUG libsodium.a
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES lib)
|
||||||
|
find_library(sodium_LIBRARY_RELEASE libsodium.a
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES lib)
|
||||||
|
else()
|
||||||
|
find_library(sodium_LIBRARY_DEBUG libsodium.dll.a
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES lib)
|
||||||
|
find_library(sodium_LIBRARY_RELEASE libsodium.dll.a
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES lib)
|
||||||
|
|
||||||
|
file(GLOB _DLL
|
||||||
|
LIST_DIRECTORIES false
|
||||||
|
RELATIVE "${sodium_DIR}/bin"
|
||||||
|
"${sodium_DIR}/bin/libsodium*.dll")
|
||||||
|
find_library(sodium_DLL_DEBUG ${_DLL} libsodium
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES bin)
|
||||||
|
find_library(sodium_DLL_RELEASE ${_DLL} libsodium
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES bin)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "this platform is not supported by FindSodium.cmake")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# unsupported
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "this platform is not supported by FindSodium.cmake")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ##############################################################################
|
||||||
|
# common stuff
|
||||||
|
|
||||||
|
# extract sodium version
|
||||||
|
if(sodium_INCLUDE_DIR)
|
||||||
|
set(_VERSION_HEADER "${sodium_INCLUDE_DIR}/sodium/version.h")
|
||||||
|
if(EXISTS "${_VERSION_HEADER}")
|
||||||
|
file(READ "${_VERSION_HEADER}" _VERSION_HEADER_CONTENT)
|
||||||
|
string(
|
||||||
|
REGEX
|
||||||
|
REPLACE
|
||||||
|
".*#define[ \t]*SODIUM_VERSION_STRING[ \t]*\"([^\n]*)\".*"
|
||||||
|
"\\1"
|
||||||
|
sodium_VERSION_STRING
|
||||||
|
"${_VERSION_HEADER_CONTENT}")
|
||||||
|
set(sodium_VERSION_STRING "${sodium_VERSION_STRING}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# communicate results
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(sodium
|
||||||
|
REQUIRED_VARS
|
||||||
|
sodium_LIBRARY_RELEASE
|
||||||
|
sodium_LIBRARY_DEBUG
|
||||||
|
sodium_INCLUDE_DIR
|
||||||
|
VERSION_VAR
|
||||||
|
sodium_VERSION_STRING)
|
||||||
|
|
||||||
|
# mark file paths as advanced
|
||||||
|
mark_as_advanced(sodium_INCLUDE_DIR)
|
||||||
|
mark_as_advanced(sodium_LIBRARY_DEBUG)
|
||||||
|
mark_as_advanced(sodium_LIBRARY_RELEASE)
|
||||||
|
if(WIN32)
|
||||||
|
mark_as_advanced(sodium_DLL_DEBUG)
|
||||||
|
mark_as_advanced(sodium_DLL_RELEASE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# create imported target
|
||||||
|
if(sodium_USE_STATIC_LIBS)
|
||||||
|
set(_LIB_TYPE STATIC)
|
||||||
|
else()
|
||||||
|
set(_LIB_TYPE SHARED)
|
||||||
|
endif()
|
||||||
|
add_library(sodium ${_LIB_TYPE} IMPORTED)
|
||||||
|
|
||||||
|
set_target_properties(sodium
|
||||||
|
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||||
|
"${sodium_INCLUDE_DIR}"
|
||||||
|
IMPORTED_LINK_INTERFACE_LANGUAGES
|
||||||
|
"C")
|
||||||
|
|
||||||
|
if(sodium_USE_STATIC_LIBS)
|
||||||
|
set_target_properties(sodium
|
||||||
|
PROPERTIES INTERFACE_COMPILE_DEFINITIONS
|
||||||
|
"SODIUM_STATIC"
|
||||||
|
IMPORTED_LOCATION
|
||||||
|
"${sodium_LIBRARY_RELEASE}"
|
||||||
|
IMPORTED_LOCATION_DEBUG
|
||||||
|
"${sodium_LIBRARY_DEBUG}")
|
||||||
|
else()
|
||||||
|
if(UNIX)
|
||||||
|
set_target_properties(sodium
|
||||||
|
PROPERTIES IMPORTED_LOCATION
|
||||||
|
"${sodium_LIBRARY_RELEASE}"
|
||||||
|
IMPORTED_LOCATION_DEBUG
|
||||||
|
"${sodium_LIBRARY_DEBUG}")
|
||||||
|
elseif(WIN32)
|
||||||
|
set_target_properties(sodium
|
||||||
|
PROPERTIES IMPORTED_IMPLIB
|
||||||
|
"${sodium_LIBRARY_RELEASE}"
|
||||||
|
IMPORTED_IMPLIB_DEBUG
|
||||||
|
"${sodium_LIBRARY_DEBUG}")
|
||||||
|
if(NOT (sodium_DLL_DEBUG MATCHES ".*-NOTFOUND"))
|
||||||
|
set_target_properties(sodium
|
||||||
|
PROPERTIES IMPORTED_LOCATION_DEBUG
|
||||||
|
"${sodium_DLL_DEBUG}")
|
||||||
|
endif()
|
||||||
|
if(NOT (sodium_DLL_RELEASE MATCHES ".*-NOTFOUND"))
|
||||||
|
set_target_properties(sodium
|
||||||
|
PROPERTIES IMPORTED_LOCATION_RELWITHDEBINFO
|
||||||
|
"${sodium_DLL_RELEASE}"
|
||||||
|
IMPORTED_LOCATION_MINSIZEREL
|
||||||
|
"${sodium_DLL_RELEASE}"
|
||||||
|
IMPORTED_LOCATION_RELEASE
|
||||||
|
"${sodium_DLL_RELEASE}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
@ -92,6 +92,7 @@ add_library(SqModule MODULE SqBase.hpp Main.cpp
|
|||||||
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
|
||||||
|
Library/Utils/Template.cpp Library/Utils/Template.hpp
|
||||||
Library/Utils/Vector.cpp Library/Utils/Vector.hpp
|
Library/Utils/Vector.cpp Library/Utils/Vector.hpp
|
||||||
Library/XML.cpp Library/XML.hpp
|
Library/XML.cpp Library/XML.hpp
|
||||||
Library/ZMQ.cpp Library/ZMQ.hpp
|
Library/ZMQ.cpp Library/ZMQ.hpp
|
||||||
@ -118,6 +119,8 @@ add_library(SqModule MODULE SqBase.hpp Main.cpp
|
|||||||
Register.cpp
|
Register.cpp
|
||||||
Exports.cpp
|
Exports.cpp
|
||||||
)
|
)
|
||||||
|
# The module requires C++ 17
|
||||||
|
set_property(TARGET SqModule PROPERTY CXX_STANDARD 17)
|
||||||
# Various definitions required by the plug-in
|
# Various definitions required by the plug-in
|
||||||
target_compile_definitions(SqModule PRIVATE SCRAT_USE_EXCEPTIONS=1)
|
target_compile_definitions(SqModule PRIVATE SCRAT_USE_EXCEPTIONS=1)
|
||||||
# SDK targeting
|
# SDK targeting
|
||||||
@ -135,7 +138,7 @@ 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 RPMalloc Squirrel fmt::fmt SimpleINI TinyDir xxHash ConcurrentQueue SAJSON CPR UTF8Lib PUGIXML CivetWeb maxminddb libzmq-static)
|
target_link_libraries(SqModule RPMalloc Squirrel fmt::fmt SimpleINI TinyDir xxHash ConcurrentQueue SAJSON CPR UTF8Lib PUGIXML CivetWeb inja maxminddb libzmq-static)
|
||||||
# Link to POCO libraries
|
# Link to POCO libraries
|
||||||
target_link_libraries(SqModule Poco::Foundation Poco::Crypto Poco::Data Poco::Net)
|
target_link_libraries(SqModule Poco::Foundation Poco::Crypto Poco::Data Poco::Net)
|
||||||
# Does POCO have SQLite support?
|
# Does POCO have SQLite support?
|
||||||
@ -174,6 +177,31 @@ if(POSTGRESQL_FOUND)
|
|||||||
# Inform the plug-in that it can make use of this library
|
# Inform the plug-in that it can make use of this library
|
||||||
target_compile_definitions(SqModule PRIVATE SQMOD_POCO_HAS_POSTGRESQL=1)
|
target_compile_definitions(SqModule PRIVATE SQMOD_POCO_HAS_POSTGRESQL=1)
|
||||||
endif()
|
endif()
|
||||||
|
# Is Discord support enabled?
|
||||||
|
if(ENABLE_DISCORD)
|
||||||
|
target_link_libraries(SqModule dpp)
|
||||||
|
target_sources(SqModule PRIVATE
|
||||||
|
Library/Discord.cpp Library/Discord.hpp
|
||||||
|
Library/Discord/Application.hpp Library/Discord/Application.cpp
|
||||||
|
Library/Discord/Automod.hpp Library/Discord/Automod.cpp
|
||||||
|
Library/Discord/Channel.hpp Library/Discord/Channel.cpp
|
||||||
|
Library/Discord/Client.hpp Library/Discord/Client.cpp
|
||||||
|
Library/Discord/Cluster.hpp Library/Discord/Cluster.cpp
|
||||||
|
Library/Discord/Command.hpp Library/Discord/Command.cpp
|
||||||
|
Library/Discord/Constants.hpp Library/Discord/Constants.cpp
|
||||||
|
Library/Discord/Events.hpp Library/Discord/Events.cpp
|
||||||
|
Library/Discord/Guild.hpp Library/Discord/Guild.cpp
|
||||||
|
Library/Discord/Integration.hpp Library/Discord/Integration.cpp
|
||||||
|
Library/Discord/Message.hpp Library/Discord/Message.cpp
|
||||||
|
Library/Discord/Misc.hpp Library/Discord/Misc.cpp
|
||||||
|
Library/Discord/Presence.hpp Library/Discord/Presence.cpp
|
||||||
|
Library/Discord/Role.hpp Library/Discord/Role.cpp
|
||||||
|
Library/Discord/User.hpp Library/Discord/User.cpp
|
||||||
|
Library/Discord/Utilities.hpp Library/Discord/Utilities.cpp
|
||||||
|
)
|
||||||
|
# Inform the plug-in that discord is enabled
|
||||||
|
target_compile_definitions(SqModule PRIVATE SQMOD_DISCORD=1)
|
||||||
|
endif()
|
||||||
# Determine if build mode
|
# Determine if build mode
|
||||||
if(${CMAKE_BUILD_TYPE} MATCHES "(Release)+")
|
if(${CMAKE_BUILD_TYPE} MATCHES "(Release)+")
|
||||||
target_compile_definitions(SqModule PRIVATE NDEBUG=1)
|
target_compile_definitions(SqModule PRIVATE NDEBUG=1)
|
||||||
@ -218,6 +246,12 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
# Copy module into the plug-ins folder
|
# Copy module into the plug-ins folder
|
||||||
add_custom_command(TARGET SqModule POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:SqModule> "${PROJECT_SOURCE_DIR}/bin/plugins")
|
add_custom_command(TARGET SqModule POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:SqModule> "${PROJECT_SOURCE_DIR}/bin/plugins")
|
||||||
|
# Copy DPP into the bin folder
|
||||||
|
if (ENABLE_DISCORD)
|
||||||
|
if (WIN32 OR MINGW)
|
||||||
|
add_custom_command(TARGET SqModule POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:dpp> "${PROJECT_SOURCE_DIR}/bin")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
# Copy several dependent DLLs on windows to make distribution easier (used mainly by people that distribute builds)
|
# Copy several dependent DLLs on windows to make distribution easier (used mainly by people that distribute builds)
|
||||||
if(WIN32 AND MINGW AND COPY_DEPENDENCIES)
|
if(WIN32 AND MINGW AND COPY_DEPENDENCIES)
|
||||||
get_filename_component(MINGW_BIN_PATH ${CMAKE_C_COMPILER} DIRECTORY REALPATH)
|
get_filename_component(MINGW_BIN_PATH ${CMAKE_C_COMPILER} DIRECTORY REALPATH)
|
||||||
|
@ -49,6 +49,9 @@ extern void TerminateRoutines();
|
|||||||
extern void TerminateCommands();
|
extern void TerminateCommands();
|
||||||
extern void TerminateSignals();
|
extern void TerminateSignals();
|
||||||
extern void TerminateNet();
|
extern void TerminateNet();
|
||||||
|
#ifdef SQMOD_DISCORD
|
||||||
|
extern void TerminateDiscord();
|
||||||
|
#endif
|
||||||
extern void TerminatePocoNet();
|
extern void TerminatePocoNet();
|
||||||
extern void TerminatePocoData();
|
extern void TerminatePocoData();
|
||||||
|
|
||||||
@ -553,6 +556,11 @@ void Core::Terminate(bool shutdown)
|
|||||||
// Release network
|
// Release network
|
||||||
TerminateNet();
|
TerminateNet();
|
||||||
cLogDbg(m_Verbosity >= 1, "Network terminated");
|
cLogDbg(m_Verbosity >= 1, "Network terminated");
|
||||||
|
// Release DPP
|
||||||
|
#ifdef SQMOD_DISCORD
|
||||||
|
TerminateDiscord();
|
||||||
|
cLogDbg(m_Verbosity >= 1, "Discord terminated");
|
||||||
|
#endif
|
||||||
// Release Poco statement results
|
// Release Poco statement results
|
||||||
TerminatePocoNet();
|
TerminatePocoNet();
|
||||||
TerminatePocoData();
|
TerminatePocoData();
|
||||||
|
51
module/Library/Discord.cpp
Normal file
51
module/Library/Discord.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord.hpp"
|
||||||
|
#include "Library/Discord/Cluster.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void TerminateDiscord()
|
||||||
|
{
|
||||||
|
// Go over all clusters and try to terminate them
|
||||||
|
for (DpCluster * inst = DpCluster::sHead; inst && inst->mNext != DpCluster::sHead; inst = inst->mNext)
|
||||||
|
{
|
||||||
|
inst->Terminate(); // Terminate the cluster
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void ProcessDiscord()
|
||||||
|
{
|
||||||
|
// Go over all clusters and allow them to process data
|
||||||
|
for (DpCluster * inst = DpCluster::sHead; inst && inst->mNext != DpCluster::sHead; inst = inst->mNext)
|
||||||
|
{
|
||||||
|
inst->Process();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
extern void Register_Discord_Constants(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_Discord_Events(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_Discord_Misc(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_Discord_Cluster(HSQUIRRELVM vm, Table & ns);
|
||||||
|
|
||||||
|
// ================================================================================================
|
||||||
|
void Register_Discord(HSQUIRRELVM vm)
|
||||||
|
{
|
||||||
|
Table ns(vm);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
Register_Discord_Constants(vm, ns);
|
||||||
|
{
|
||||||
|
Table ens(vm);
|
||||||
|
Register_Discord_Events(vm, ens);
|
||||||
|
ns.Bind(_SC("Event"), ens);
|
||||||
|
}
|
||||||
|
Register_Discord_Misc(vm, ns);
|
||||||
|
Register_Discord_Cluster(vm, ns);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
RootTable(vm).Bind(_SC("SqDiscord"), ns);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
17
module/Library/Discord.hpp
Normal file
17
module/Library/Discord.hpp
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/IO/Buffer.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <sqratFunction.h>
|
||||||
|
#include <concurrentqueue.h>
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
9
module/Library/Discord/Application.cpp
Normal file
9
module/Library/Discord/Application.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Application.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
@ -4,8 +4,7 @@
|
|||||||
#include "Core/Utility.hpp"
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#define JSMN_HEADER
|
#include <dpp/dpp.h>
|
||||||
#include <jsmn.h>
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
9
module/Library/Discord/Automod.cpp
Normal file
9
module/Library/Discord/Automod.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Automod.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
13
module/Library/Discord/Automod.hpp
Normal file
13
module/Library/Discord/Automod.hpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
9
module/Library/Discord/Channel.cpp
Normal file
9
module/Library/Discord/Channel.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Channel.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
13
module/Library/Discord/Channel.hpp
Normal file
13
module/Library/Discord/Channel.hpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
9
module/Library/Discord/Client.cpp
Normal file
9
module/Library/Discord/Client.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Client.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
13
module/Library/Discord/Client.hpp
Normal file
13
module/Library/Discord/Client.hpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
492
module/Library/Discord/Cluster.cpp
Normal file
492
module/Library/Discord/Cluster.cpp
Normal file
@ -0,0 +1,492 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Cluster.hpp"
|
||||||
|
#include "Library/Discord/Events.hpp"
|
||||||
|
#include "Logger.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpClusterTypename, _SC("SqDiscordCluster"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpClusterOptionsTypename, _SC("SqDiscordClusterOptions"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
DpCluster::DpCluster(DpClusterOptions & o)
|
||||||
|
: Base(), mQueue(4096)
|
||||||
|
, mC(std::make_unique< dpp::cluster >(o.mToken, o.mIntents, o.mShards, o.mClusterID, o.mMaxClusters, o.mCompressed, o.mPolicy, o.mRequestThreads, o.mRequestThreadsRaw))
|
||||||
|
, mSqEvents(), mEvents(), mEventsHandle()
|
||||||
|
{
|
||||||
|
// Make sure all event handles are not valid
|
||||||
|
mEventsHandle.fill(0);
|
||||||
|
// Initialize event signals
|
||||||
|
InitEvents();
|
||||||
|
// Proxy library logging to our logger
|
||||||
|
if (!o.mCustomLogging)
|
||||||
|
{
|
||||||
|
mC->on_log([](const dpp::log_t& event) {
|
||||||
|
switch (event.severity)
|
||||||
|
{
|
||||||
|
case dpp::ll_trace: Logger::Get().Send(LOGL_DBG, true, event.message.c_str(), event.message.size()); break;
|
||||||
|
case dpp::ll_debug: Logger::Get().Send(LOGL_DBG, true, event.message.c_str(), event.message.size()); break;
|
||||||
|
case dpp::ll_info: Logger::Get().Send(LOGL_INF, true, event.message.c_str(), event.message.size()); break;
|
||||||
|
case dpp::ll_warning: Logger::Get().Send(LOGL_WRN, true, event.message.c_str(), event.message.size()); break;
|
||||||
|
case dpp::ll_error: Logger::Get().Send(LOGL_ERR, true, event.message.c_str(), event.message.size()); break;
|
||||||
|
case dpp::ll_critical: Logger::Get().Send(LOGL_FTL, true, event.message.c_str(), event.message.size()); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Remember this instance
|
||||||
|
ChainInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
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
|
||||||
|
}
|
||||||
|
EventItem 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 id = static_cast< size_t >(event->GetEventID());
|
||||||
|
// Is this a valid event and is anyone listening to it?
|
||||||
|
if (!(event->mFrom) || !(mEvents[id].first) || mEvents[id].first->IsEmpty())
|
||||||
|
{
|
||||||
|
continue; // Move on
|
||||||
|
}
|
||||||
|
// Transform the event instance into a script object
|
||||||
|
LightObj obj = event->ToScriptObject();
|
||||||
|
// Allow the script to take ownership of the event instance now
|
||||||
|
[[maybe_unused]] auto p = event.release();
|
||||||
|
// Don't abort everything down the line for an error caused by a discord event handler
|
||||||
|
try {
|
||||||
|
(*mEvents[id].first)(obj); // Forward the call to the associated signal
|
||||||
|
} catch (const std::exception & e) {
|
||||||
|
LogErr("Squirrel exception caught in (%s) discord event", p->GetEventName().data());
|
||||||
|
LogSInf("Message: %s", e.what());
|
||||||
|
}
|
||||||
|
// Allow the event instance to clean itself (i.e. invalidate itself)
|
||||||
|
// User should not keep this event object for later use!
|
||||||
|
// Event data is accessible only during the event signal
|
||||||
|
p->Cleanup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::Terminate()
|
||||||
|
{
|
||||||
|
// Stop the cluster connection
|
||||||
|
if (mC) mC->shutdown();
|
||||||
|
// Release associated script objects
|
||||||
|
mSqEvents.Release();
|
||||||
|
// Release event signal objects
|
||||||
|
DropEvents();
|
||||||
|
// Delete the cluster instance
|
||||||
|
mC.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================================================================================================
|
||||||
|
void Register_Discord_Cluster(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
ns.Bind(_SC("ClusterOptions"),
|
||||||
|
Class< DpClusterOptions >(vm, SqDpClusterOptionsTypename::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor< StackStrF & >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpClusterOptionsTypename::Fn)
|
||||||
|
);
|
||||||
|
|
||||||
|
ns.Bind(_SC("Cluster"),
|
||||||
|
Class< DpCluster, NoCopy< DpCluster > >(vm, SqDpClusterTypename::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor< DpClusterOptions & >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpClusterTypename::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("On"), &DpCluster::GetEvents)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("Start"), &DpCluster::Start)
|
||||||
|
.Func(_SC("Stop"), &DpCluster::Stop)
|
||||||
|
.Func(_SC("EnableEvent"), &DpCluster::EnableEvent)
|
||||||
|
.Func(_SC("DisableEvent"), &DpCluster::DisableEvent)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
DpCluster & DpCluster::EnableEvent(SQInteger id)
|
||||||
|
{
|
||||||
|
// Retrieve managed cluster instance
|
||||||
|
auto & c = Valid("enable event on a");
|
||||||
|
// Assigned event handle
|
||||||
|
dpp::event_handle eh = 0;
|
||||||
|
// Make sure the specified event handle is valid
|
||||||
|
if (id >= 0 && id < static_cast< SQInteger >(DpEventID::Max))
|
||||||
|
{
|
||||||
|
eh = mEventsHandle[static_cast< size_t >(id)]; // Get the real handle
|
||||||
|
}
|
||||||
|
// Is this event already enabled?
|
||||||
|
if (eh != 0)
|
||||||
|
{
|
||||||
|
return *this; // Job already done
|
||||||
|
}
|
||||||
|
// Identify event type
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case DpEventID::VoiceStateUpdate: eh = c.on_voice_state_update.attach([this](const dpp::voice_state_update_t & e) { OnVoiceStateUpdate(e); }); break;
|
||||||
|
case DpEventID::VoiceClientDisconnect: eh = c.on_voice_client_disconnect.attach([this](const dpp::voice_client_disconnect_t & e) { OnVoiceClientDisconnect(e); }); break;
|
||||||
|
case DpEventID::VoiceClientSpeaking: eh = c.on_voice_client_speaking.attach([this](const dpp::voice_client_speaking_t & e) { OnVoiceClientSpeaking(e); }); break;
|
||||||
|
case DpEventID::Log: eh = c.on_log.attach([this](const dpp::log_t & e) { OnLog(e); }); break;
|
||||||
|
case DpEventID::GuildJoinRequestDelete: eh = c.on_guild_join_request_delete.attach([this](const dpp::guild_join_request_delete_t & e) { OnGuildJoinRequestDelete(e); }); break;
|
||||||
|
case DpEventID::InteractionCreate: eh = c.on_interaction_create.attach([this](const dpp::interaction_create_t & e) { OnInteractionCreate(e); }); break;
|
||||||
|
case DpEventID::SlashCommand: eh = c.on_slashcommand.attach([this](const dpp::slashcommand_t & e) { OnSlashCommand(e); }); break;
|
||||||
|
case DpEventID::ButtonClick: eh = c.on_button_click.attach([this](const dpp::button_click_t & e) { OnButtonClick(e); }); break;
|
||||||
|
case DpEventID::AutoComplete: eh = c.on_autocomplete.attach([this](const dpp::autocomplete_t & e) { OnAutoComplete(e); }); break;
|
||||||
|
case DpEventID::SelectClick: eh = c.on_select_click.attach([this](const dpp::select_click_t & e) { OnSelectClick(e); }); break;
|
||||||
|
case DpEventID::MessageContextMenu: eh = c.on_message_context_menu.attach([this](const dpp::message_context_menu_t & e) { OnMessageContextMenu(e); }); break;
|
||||||
|
case DpEventID::UserContextMenu: eh = c.on_user_context_menu.attach([this](const dpp::user_context_menu_t & e) { OnUserContextMenu(e); }); break;
|
||||||
|
case DpEventID::FormSubmit: eh = c.on_form_submit.attach([this](const dpp::form_submit_t & e) { OnFormSubmit(e); }); break;
|
||||||
|
case DpEventID::GuildDelete: eh = c.on_guild_delete.attach([this](const dpp::guild_delete_t & e) { OnGuildDelete(e); }); break;
|
||||||
|
case DpEventID::ChannelDelete: eh = c.on_channel_delete.attach([this](const dpp::channel_delete_t & e) { OnChannelDelete(e); }); break;
|
||||||
|
case DpEventID::ChannelUpdate: eh = c.on_channel_update.attach([this](const dpp::channel_update_t & e) { OnChannelUpdate(e); }); break;
|
||||||
|
case DpEventID::Ready: eh = c.on_ready.attach([this](const dpp::ready_t & e) { OnReady(e); }); break;
|
||||||
|
case DpEventID::MessageDelete: eh = c.on_message_delete.attach([this](const dpp::message_delete_t & e) { OnMessageDelete(e); }); break;
|
||||||
|
case DpEventID::GuildMemberRemove: eh = c.on_guild_member_remove.attach([this](const dpp::guild_member_remove_t & e) { OnGuildMemberRemove(e); }); break;
|
||||||
|
case DpEventID::Resumed: eh = c.on_resumed.attach([this](const dpp::resumed_t & e) { OnResumed(e); }); break;
|
||||||
|
case DpEventID::GuildRoleCreate: eh = c.on_guild_role_create.attach([this](const dpp::guild_role_create_t & e) { OnGuildRoleCreate(e); }); break;
|
||||||
|
case DpEventID::TypingStart: eh = c.on_typing_start.attach([this](const dpp::typing_start_t & e) { OnTypingStart(e); }); break;
|
||||||
|
case DpEventID::MessageReactionAdd: eh = c.on_message_reaction_add.attach([this](const dpp::message_reaction_add_t & e) { OnMessageReactionAdd(e); }); break;
|
||||||
|
case DpEventID::GuildMembersChunk: eh = c.on_guild_members_chunk.attach([this](const dpp::guild_members_chunk_t & e) { OnGuildMembersChunk(e); }); break;
|
||||||
|
case DpEventID::MessageReactionRemove: eh = c.on_message_reaction_remove.attach([this](const dpp::message_reaction_remove_t & e) { OnMessageReactionRemove(e); }); break;
|
||||||
|
case DpEventID::GuildCreate: eh = c.on_guild_create.attach([this](const dpp::guild_create_t & e) { OnGuildCreate(e); }); break;
|
||||||
|
case DpEventID::ChannelCreate: eh = c.on_channel_create.attach([this](const dpp::channel_create_t & e) { OnChannelCreate(e); }); break;
|
||||||
|
case DpEventID::MessageReactionRemoveEmoji: eh = c.on_message_reaction_remove_emoji.attach([this](const dpp::message_reaction_remove_emoji_t & e) { OnMessageReactionRemoveEmoji(e); }); break;
|
||||||
|
case DpEventID::MessageDeleteDulk: eh = c.on_message_delete_bulk.attach([this](const dpp::message_delete_bulk_t & e) { OnMessageDeleteDulk(e); }); break;
|
||||||
|
case DpEventID::GuildRoleUpdate: eh = c.on_guild_role_update.attach([this](const dpp::guild_role_update_t & e) { OnGuildRoleUpdate(e); }); break;
|
||||||
|
case DpEventID::GuildRoleDelete: eh = c.on_guild_role_delete.attach([this](const dpp::guild_role_delete_t & e) { OnGuildRoleDelete(e); }); break;
|
||||||
|
case DpEventID::ChannelPinsUpdate: eh = c.on_channel_pins_update.attach([this](const dpp::channel_pins_update_t & e) { OnChannelPinsUpdate(e); }); break;
|
||||||
|
case DpEventID::MessageReactionRemoveAll: eh = c.on_message_reaction_remove_all.attach([this](const dpp::message_reaction_remove_all_t & e) { OnMessageReactionRemoveAll(e); }); break;
|
||||||
|
case DpEventID::VoiceServerUpdate: eh = c.on_voice_server_update.attach([this](const dpp::voice_server_update_t & e) { OnVoiceServerUpdate(e); }); break;
|
||||||
|
case DpEventID::GuildEmojisUpdate: eh = c.on_guild_emojis_update.attach([this](const dpp::guild_emojis_update_t & e) { OnGuildEmojisUpdate(e); }); break;
|
||||||
|
case DpEventID::GuildStickersUpdate: eh = c.on_guild_stickers_update.attach([this](const dpp::guild_stickers_update_t & e) { OnGuildStickersUpdate(e); }); break;
|
||||||
|
case DpEventID::PresenceUpdate: eh = c.on_presence_update.attach([this](const dpp::presence_update_t & e) { OnPresenceUpdate(e); }); break;
|
||||||
|
case DpEventID::WebhooksUpdate: eh = c.on_webhooks_update.attach([this](const dpp::webhooks_update_t & e) { OnWebhooksUpdate(e); }); break;
|
||||||
|
case DpEventID::AutomodRuleCreate: eh = c.on_automod_rule_create.attach([this](const dpp::automod_rule_create_t & e) { OnAutomodRuleCreate(e); }); break;
|
||||||
|
case DpEventID::AutomodRuleUpdate: eh = c.on_automod_rule_update.attach([this](const dpp::automod_rule_update_t & e) { OnAutomodRuleUpdate(e); }); break;
|
||||||
|
case DpEventID::AutomodRuleDelete: eh = c.on_automod_rule_delete.attach([this](const dpp::automod_rule_delete_t & e) { OnAutomodRuleDelete(e); }); break;
|
||||||
|
case DpEventID::AutomodRuleExecute: eh = c.on_automod_rule_execute.attach([this](const dpp::automod_rule_execute_t & e) { OnAutomodRuleExecute(e); }); break;
|
||||||
|
case DpEventID::GuildMemberAdd: eh = c.on_guild_member_add.attach([this](const dpp::guild_member_add_t & e) { OnGuildMemberAdd(e); }); break;
|
||||||
|
case DpEventID::InviteDelete: eh = c.on_invite_delete.attach([this](const dpp::invite_delete_t & e) { OnInviteDelete(e); }); break;
|
||||||
|
case DpEventID::GuildUpdate: eh = c.on_guild_update.attach([this](const dpp::guild_update_t & e) { OnGuildUpdate(e); }); break;
|
||||||
|
case DpEventID::GuildIntegrationsUpdate: eh = c.on_guild_integrations_update.attach([this](const dpp::guild_integrations_update_t & e) { OnGuildIntegrationsUpdate(e); }); break;
|
||||||
|
case DpEventID::GuildMemberUpdate: eh = c.on_guild_member_update.attach([this](const dpp::guild_member_update_t & e) { OnGuildMemberUpdate(e); }); break;
|
||||||
|
case DpEventID::InviteCreate: eh = c.on_invite_create.attach([this](const dpp::invite_create_t & e) { OnInviteCreate(e); }); break;
|
||||||
|
case DpEventID::MessageUpdate: eh = c.on_message_update.attach([this](const dpp::message_update_t & e) { OnMessageUpdate(e); }); break;
|
||||||
|
case DpEventID::UserUpdate: eh = c.on_user_update.attach([this](const dpp::user_update_t & e) { OnUserUpdate(e); }); break;
|
||||||
|
case DpEventID::MessageCreate: eh = c.on_message_create.attach([this](const dpp::message_create_t & e) { OnMessageCreate(e); }); break;
|
||||||
|
case DpEventID::GuildBanAdd: eh = c.on_guild_ban_add.attach([this](const dpp::guild_ban_add_t & e) { OnGuildBanAdd(e); }); break;
|
||||||
|
case DpEventID::GuildBanRemove: eh = c.on_guild_ban_remove.attach([this](const dpp::guild_ban_remove_t & e) { OnGuildBanRemove(e); }); break;
|
||||||
|
case DpEventID::IntegrationCreate: eh = c.on_integration_create.attach([this](const dpp::integration_create_t & e) { OnIntegrationCreate(e); }); break;
|
||||||
|
case DpEventID::IntegrationUpdate: eh = c.on_integration_update.attach([this](const dpp::integration_update_t & e) { OnIntegrationUpdate(e); }); break;
|
||||||
|
case DpEventID::IntegrationDelete: eh = c.on_integration_delete.attach([this](const dpp::integration_delete_t & e) { OnIntegrationDelete(e); }); break;
|
||||||
|
case DpEventID::ThreadCreate: eh = c.on_thread_create.attach([this](const dpp::thread_create_t & e) { OnThreadCreate(e); }); break;
|
||||||
|
case DpEventID::ThreadUpdate: eh = c.on_thread_update.attach([this](const dpp::thread_update_t & e) { OnThreadUpdate(e); }); break;
|
||||||
|
case DpEventID::ThreadDelete: eh = c.on_thread_delete.attach([this](const dpp::thread_delete_t & e) { OnThreadDelete(e); }); break;
|
||||||
|
case DpEventID::ThreadListSync: eh = c.on_thread_list_sync.attach([this](const dpp::thread_list_sync_t & e) { OnThreadListSync(e); }); break;
|
||||||
|
case DpEventID::ThreadMemberUpdate: eh = c.on_thread_member_update.attach([this](const dpp::thread_member_update_t & e) { OnThreadMemberUpdate(e); }); break;
|
||||||
|
case DpEventID::ThreadMembersUpdate: eh = c.on_thread_members_update.attach([this](const dpp::thread_members_update_t & e) { OnThreadMembersUpdate(e); }); break;
|
||||||
|
case DpEventID::GuildScheduledEventCreate: eh = c.on_guild_scheduled_event_create.attach([this](const dpp::guild_scheduled_event_create_t & e) { OnGuildScheduledEventCreate(e); }); break;
|
||||||
|
case DpEventID::GuildScheduledEventUpdate: eh = c.on_guild_scheduled_event_update.attach([this](const dpp::guild_scheduled_event_update_t & e) { OnGuildScheduledEventUpdate(e); }); break;
|
||||||
|
case DpEventID::GuildScheduledEventDelete: eh = c.on_guild_scheduled_event_delete.attach([this](const dpp::guild_scheduled_event_delete_t & e) { OnGuildScheduledEventDelete(e); }); break;
|
||||||
|
case DpEventID::GuildScheduledEventUserAdd: eh = c.on_guild_scheduled_event_user_add.attach([this](const dpp::guild_scheduled_event_user_add_t & e) { OnGuildScheduledEventUserAdd(e); }); break;
|
||||||
|
case DpEventID::GuildScheduledEventUserRemove: eh = c.on_guild_scheduled_event_user_remove.attach([this](const dpp::guild_scheduled_event_user_remove_t & e) { OnGuildScheduledEventUserRemove(e); }); break;
|
||||||
|
case DpEventID::VoiceBufferSend: eh = c.on_voice_buffer_send.attach([this](const dpp::voice_buffer_send_t & e) { OnVoiceBufferSend(e); }); break;
|
||||||
|
case DpEventID::VoiceUserTalking: eh = c.on_voice_user_talking.attach([this](const dpp::voice_user_talking_t & e) { OnVoiceUserTalking(e); }); break;
|
||||||
|
case DpEventID::VoiceReady: eh = c.on_voice_ready.attach([this](const dpp::voice_ready_t & e) { OnVoiceReady(e); }); break;
|
||||||
|
case DpEventID::VoiceReceive: eh = c.on_voice_receive.attach([this](const dpp::voice_receive_t & e) { OnVoiceReceive(e); }); break;
|
||||||
|
case DpEventID::VoiceReceiveCombined: eh = c.on_voice_receive_combined.attach([this](const dpp::voice_receive_t & e) { OnVoiceReceiveCombined(e); }); break;
|
||||||
|
case DpEventID::VoiceTrackMarker: eh = c.on_voice_track_marker.attach([this](const dpp::voice_track_marker_t & e) { OnVoiceTrackMarker(e); }); break;
|
||||||
|
case DpEventID::StageInstanceCreate: eh = c.on_stage_instance_create.attach([this](const dpp::stage_instance_create_t & e) { OnStageInstanceCreate(e); }); break;
|
||||||
|
case DpEventID::StageInstanceUpdate: eh = c.on_stage_instance_update.attach([this](const dpp::stage_instance_update_t & e) { OnStageInstanceUpdate(e); }); break;
|
||||||
|
case DpEventID::StageInstanceDelete: eh = c.on_stage_instance_delete.attach([this](const dpp::stage_instance_delete_t & e) { OnStageInstanceDelete(e); }); break;
|
||||||
|
case DpEventID::Max: // Fall through
|
||||||
|
default: STHROWF("Invalid discord event identifier {}", id);
|
||||||
|
}
|
||||||
|
// Remember the designated event handle
|
||||||
|
mEventsHandle[static_cast< size_t >(id)] = eh;
|
||||||
|
// Allow chaining
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
DpCluster & DpCluster::DisableEvent(SQInteger id)
|
||||||
|
{
|
||||||
|
// Retrieve managed cluster instance
|
||||||
|
auto & c = Valid("disable event on a");
|
||||||
|
// Assigned event handle
|
||||||
|
dpp::event_handle eh = 0;
|
||||||
|
// Make sure the specified event handle is valid
|
||||||
|
if (id >= 0 && id < static_cast< SQInteger >(DpEventID::Max))
|
||||||
|
{
|
||||||
|
eh = mEventsHandle[static_cast< size_t >(id)]; // Get the real handle
|
||||||
|
}
|
||||||
|
// Is there anything attached to event dispatched?
|
||||||
|
if (eh == 0)
|
||||||
|
{
|
||||||
|
return *this; // Nothing to detach
|
||||||
|
}
|
||||||
|
// Identify event type
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case DpEventID::VoiceStateUpdate: c.on_voice_state_update.detach(eh); break;
|
||||||
|
case DpEventID::VoiceClientDisconnect: c.on_voice_client_disconnect.detach(eh); break;
|
||||||
|
case DpEventID::VoiceClientSpeaking: c.on_voice_client_speaking.detach(eh); break;
|
||||||
|
case DpEventID::Log: c.on_log.detach(eh); break;
|
||||||
|
case DpEventID::GuildJoinRequestDelete: c.on_guild_join_request_delete.detach(eh); break;
|
||||||
|
case DpEventID::InteractionCreate: c.on_interaction_create.detach(eh); break;
|
||||||
|
case DpEventID::SlashCommand: c.on_slashcommand.detach(eh); break;
|
||||||
|
case DpEventID::ButtonClick: c.on_button_click.detach(eh); break;
|
||||||
|
case DpEventID::AutoComplete: c.on_autocomplete.detach(eh); break;
|
||||||
|
case DpEventID::SelectClick: c.on_select_click.detach(eh); break;
|
||||||
|
case DpEventID::MessageContextMenu: c.on_message_context_menu.detach(eh); break;
|
||||||
|
case DpEventID::UserContextMenu: c.on_user_context_menu.detach(eh); break;
|
||||||
|
case DpEventID::FormSubmit: c.on_form_submit.detach(eh); break;
|
||||||
|
case DpEventID::GuildDelete: c.on_guild_delete.detach(eh); break;
|
||||||
|
case DpEventID::ChannelDelete: c.on_channel_delete.detach(eh); break;
|
||||||
|
case DpEventID::ChannelUpdate: c.on_channel_update.detach(eh); break;
|
||||||
|
case DpEventID::Ready: c.on_ready.detach(eh); break;
|
||||||
|
case DpEventID::MessageDelete: c.on_message_delete.detach(eh); break;
|
||||||
|
case DpEventID::GuildMemberRemove: c.on_guild_member_remove.detach(eh); break;
|
||||||
|
case DpEventID::Resumed: c.on_resumed.detach(eh); break;
|
||||||
|
case DpEventID::GuildRoleCreate: c.on_guild_role_create.detach(eh); break;
|
||||||
|
case DpEventID::TypingStart: c.on_typing_start.detach(eh); break;
|
||||||
|
case DpEventID::MessageReactionAdd: c.on_message_reaction_add.detach(eh); break;
|
||||||
|
case DpEventID::GuildMembersChunk: c.on_guild_members_chunk.detach(eh); break;
|
||||||
|
case DpEventID::MessageReactionRemove: c.on_message_reaction_remove.detach(eh); break;
|
||||||
|
case DpEventID::GuildCreate: c.on_guild_create.detach(eh); break;
|
||||||
|
case DpEventID::ChannelCreate: c.on_channel_create.detach(eh); break;
|
||||||
|
case DpEventID::MessageReactionRemoveEmoji: c.on_message_reaction_remove_emoji.detach(eh); break;
|
||||||
|
case DpEventID::MessageDeleteDulk: c.on_message_delete_bulk.detach(eh); break;
|
||||||
|
case DpEventID::GuildRoleUpdate: c.on_guild_role_update.detach(eh); break;
|
||||||
|
case DpEventID::GuildRoleDelete: c.on_guild_role_delete.detach(eh); break;
|
||||||
|
case DpEventID::ChannelPinsUpdate: c.on_channel_pins_update.detach(eh); break;
|
||||||
|
case DpEventID::MessageReactionRemoveAll: c.on_message_reaction_remove_all.detach(eh); break;
|
||||||
|
case DpEventID::VoiceServerUpdate: c.on_voice_server_update.detach(eh); break;
|
||||||
|
case DpEventID::GuildEmojisUpdate: c.on_guild_emojis_update.detach(eh); break;
|
||||||
|
case DpEventID::GuildStickersUpdate: c.on_guild_stickers_update.detach(eh); break;
|
||||||
|
case DpEventID::PresenceUpdate: c.on_presence_update.detach(eh); break;
|
||||||
|
case DpEventID::WebhooksUpdate: c.on_webhooks_update.detach(eh); break;
|
||||||
|
case DpEventID::AutomodRuleCreate: c.on_automod_rule_create.detach(eh); break;
|
||||||
|
case DpEventID::AutomodRuleUpdate: c.on_automod_rule_update.detach(eh); break;
|
||||||
|
case DpEventID::AutomodRuleDelete: c.on_automod_rule_delete.detach(eh); break;
|
||||||
|
case DpEventID::AutomodRuleExecute: c.on_automod_rule_execute.detach(eh); break;
|
||||||
|
case DpEventID::GuildMemberAdd: c.on_guild_member_add.detach(eh); break;
|
||||||
|
case DpEventID::InviteDelete: c.on_invite_delete.detach(eh); break;
|
||||||
|
case DpEventID::GuildUpdate: c.on_guild_update.detach(eh); break;
|
||||||
|
case DpEventID::GuildIntegrationsUpdate: c.on_guild_integrations_update.detach(eh); break;
|
||||||
|
case DpEventID::GuildMemberUpdate: c.on_guild_member_update.detach(eh); break;
|
||||||
|
case DpEventID::InviteCreate: c.on_invite_create.detach(eh); break;
|
||||||
|
case DpEventID::MessageUpdate: c.on_message_update.detach(eh); break;
|
||||||
|
case DpEventID::UserUpdate: c.on_user_update.detach(eh); break;
|
||||||
|
case DpEventID::MessageCreate: c.on_message_create.detach(eh); break;
|
||||||
|
case DpEventID::GuildBanAdd: c.on_guild_ban_add.detach(eh); break;
|
||||||
|
case DpEventID::GuildBanRemove: c.on_guild_ban_remove.detach(eh); break;
|
||||||
|
case DpEventID::IntegrationCreate: c.on_integration_create.detach(eh); break;
|
||||||
|
case DpEventID::IntegrationUpdate: c.on_integration_update.detach(eh); break;
|
||||||
|
case DpEventID::IntegrationDelete: c.on_integration_delete.detach(eh); break;
|
||||||
|
case DpEventID::ThreadCreate: c.on_thread_create.detach(eh); break;
|
||||||
|
case DpEventID::ThreadUpdate: c.on_thread_update.detach(eh); break;
|
||||||
|
case DpEventID::ThreadDelete: c.on_thread_delete.detach(eh); break;
|
||||||
|
case DpEventID::ThreadListSync: c.on_thread_list_sync.detach(eh); break;
|
||||||
|
case DpEventID::ThreadMemberUpdate: c.on_thread_member_update.detach(eh); break;
|
||||||
|
case DpEventID::ThreadMembersUpdate: c.on_thread_members_update.detach(eh); break;
|
||||||
|
case DpEventID::GuildScheduledEventCreate: c.on_guild_scheduled_event_create.detach(eh); break;
|
||||||
|
case DpEventID::GuildScheduledEventUpdate: c.on_guild_scheduled_event_update.detach(eh); break;
|
||||||
|
case DpEventID::GuildScheduledEventDelete: c.on_guild_scheduled_event_delete.detach(eh); break;
|
||||||
|
case DpEventID::GuildScheduledEventUserAdd: c.on_guild_scheduled_event_user_add.detach(eh); break;
|
||||||
|
case DpEventID::GuildScheduledEventUserRemove: c.on_guild_scheduled_event_user_remove.detach(eh); break;
|
||||||
|
case DpEventID::VoiceBufferSend: c.on_voice_buffer_send.detach(eh); break;
|
||||||
|
case DpEventID::VoiceUserTalking: c.on_voice_user_talking.detach(eh); break;
|
||||||
|
case DpEventID::VoiceReady: c.on_voice_ready.detach(eh); break;
|
||||||
|
case DpEventID::VoiceReceive: c.on_voice_receive.detach(eh); break;
|
||||||
|
case DpEventID::VoiceReceiveCombined: c.on_voice_receive_combined.detach(eh); break;
|
||||||
|
case DpEventID::VoiceTrackMarker: c.on_voice_track_marker.detach(eh); break;
|
||||||
|
case DpEventID::StageInstanceCreate: c.on_stage_instance_create.detach(eh); break;
|
||||||
|
case DpEventID::StageInstanceUpdate: c.on_stage_instance_update.detach(eh); break;
|
||||||
|
case DpEventID::StageInstanceDelete: c.on_stage_instance_delete.detach(eh); break;
|
||||||
|
case DpEventID::Max: // Fall through
|
||||||
|
default: STHROWF("Invalid discord event identifier {}", id);
|
||||||
|
}
|
||||||
|
// Forget about this event handler
|
||||||
|
mEventsHandle[static_cast< size_t >(id)] = 0;
|
||||||
|
// Allow chaining
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void DpCluster::OnVoiceStateUpdate(const dpp::voice_state_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpVoiceStateUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnVoiceClientDisconnect(const dpp::voice_client_disconnect_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpVoiceClientDisconnectEvent(ev))); }
|
||||||
|
void DpCluster::OnVoiceClientSpeaking(const dpp::voice_client_speaking_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpVoiceClientSpeakingEvent(ev))); }
|
||||||
|
void DpCluster::OnLog(const dpp::log_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpLogEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildJoinRequestDelete(const dpp::guild_join_request_delete_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildJoinRequestDeleteEvent(ev))); }
|
||||||
|
void DpCluster::OnInteractionCreate(const dpp::interaction_create_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpInteractionCreateEvent(ev))); }
|
||||||
|
void DpCluster::OnSlashCommand(const dpp::slashcommand_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpSlashCommandEvent(ev))); }
|
||||||
|
void DpCluster::OnButtonClick(const dpp::button_click_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpButtonClickEvent(ev))); }
|
||||||
|
void DpCluster::OnAutoComplete(const dpp::autocomplete_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpAutoCompleteEvent(ev))); }
|
||||||
|
void DpCluster::OnSelectClick(const dpp::select_click_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpSelectClickEvent(ev))); }
|
||||||
|
void DpCluster::OnMessageContextMenu(const dpp::message_context_menu_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpMessageContextMenuEvent(ev))); }
|
||||||
|
void DpCluster::OnUserContextMenu(const dpp::user_context_menu_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpUserContextMenuEvent(ev))); }
|
||||||
|
void DpCluster::OnFormSubmit(const dpp::form_submit_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpFormSubmitEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildDelete(const dpp::guild_delete_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildDeleteEvent(ev))); }
|
||||||
|
void DpCluster::OnChannelDelete(const dpp::channel_delete_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpChannelDeleteEvent(ev))); }
|
||||||
|
void DpCluster::OnChannelUpdate(const dpp::channel_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpChannelUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnReady(const dpp::ready_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpReadyEvent(ev))); }
|
||||||
|
void DpCluster::OnMessageDelete(const dpp::message_delete_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpMessageDeleteEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildMemberRemove(const dpp::guild_member_remove_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildMemberRemoveEvent(ev))); }
|
||||||
|
void DpCluster::OnResumed(const dpp::resumed_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpResumedEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildRoleCreate(const dpp::guild_role_create_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildRoleCreateEvent(ev))); }
|
||||||
|
void DpCluster::OnTypingStart(const dpp::typing_start_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpTypingStartEvent(ev))); }
|
||||||
|
void DpCluster::OnMessageReactionAdd(const dpp::message_reaction_add_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpMessageReactionAddEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildMembersChunk(const dpp::guild_members_chunk_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildMembersChunkEvent(ev))); }
|
||||||
|
void DpCluster::OnMessageReactionRemove(const dpp::message_reaction_remove_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpMessageReactionRemoveEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildCreate(const dpp::guild_create_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildCreateEvent(ev))); }
|
||||||
|
void DpCluster::OnChannelCreate(const dpp::channel_create_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpChannelCreateEvent(ev))); }
|
||||||
|
void DpCluster::OnMessageReactionRemoveEmoji(const dpp::message_reaction_remove_emoji_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpMessageReactionRemoveEmojiEvent(ev))); }
|
||||||
|
void DpCluster::OnMessageDeleteDulk(const dpp::message_delete_bulk_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpMessageDeleteDulkEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildRoleUpdate(const dpp::guild_role_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildRoleUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildRoleDelete(const dpp::guild_role_delete_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildRoleDeleteEvent(ev))); }
|
||||||
|
void DpCluster::OnChannelPinsUpdate(const dpp::channel_pins_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpChannelPinsUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnMessageReactionRemoveAll(const dpp::message_reaction_remove_all_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpMessageReactionRemoveAllEvent(ev))); }
|
||||||
|
void DpCluster::OnVoiceServerUpdate(const dpp::voice_server_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpVoiceServerUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildEmojisUpdate(const dpp::guild_emojis_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildEmojisUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildStickersUpdate(const dpp::guild_stickers_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildStickersUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnPresenceUpdate(const dpp::presence_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpPresenceUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnWebhooksUpdate(const dpp::webhooks_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpWebhooksUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnAutomodRuleCreate(const dpp::automod_rule_create_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpAutomodRuleCreateEvent(ev))); }
|
||||||
|
void DpCluster::OnAutomodRuleUpdate(const dpp::automod_rule_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpAutomodRuleUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnAutomodRuleDelete(const dpp::automod_rule_delete_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpAutomodRuleDeleteEvent(ev))); }
|
||||||
|
void DpCluster::OnAutomodRuleExecute(const dpp::automod_rule_execute_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpAutomodRuleExecuteEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildMemberAdd(const dpp::guild_member_add_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildMemberAddEvent(ev))); }
|
||||||
|
void DpCluster::OnInviteDelete(const dpp::invite_delete_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpInviteDeleteEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildUpdate(const dpp::guild_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildIntegrationsUpdate(const dpp::guild_integrations_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildIntegrationsUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildMemberUpdate(const dpp::guild_member_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildMemberUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnInviteCreate(const dpp::invite_create_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpInviteCreateEvent(ev))); }
|
||||||
|
void DpCluster::OnMessageUpdate(const dpp::message_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpMessageUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnUserUpdate(const dpp::user_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpUserUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnMessageCreate(const dpp::message_create_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpMessageCreateEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildBanAdd(const dpp::guild_ban_add_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildBanAddEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildBanRemove(const dpp::guild_ban_remove_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildBanRemoveEvent(ev))); }
|
||||||
|
void DpCluster::OnIntegrationCreate(const dpp::integration_create_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpIntegrationCreateEvent(ev))); }
|
||||||
|
void DpCluster::OnIntegrationUpdate(const dpp::integration_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpIntegrationUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnIntegrationDelete(const dpp::integration_delete_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpIntegrationDeleteEvent(ev))); }
|
||||||
|
void DpCluster::OnThreadCreate(const dpp::thread_create_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpThreadCreateEvent(ev))); }
|
||||||
|
void DpCluster::OnThreadUpdate(const dpp::thread_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpThreadUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnThreadDelete(const dpp::thread_delete_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpThreadDeleteEvent(ev))); }
|
||||||
|
void DpCluster::OnThreadListSync(const dpp::thread_list_sync_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpThreadListSyncEvent(ev))); }
|
||||||
|
void DpCluster::OnThreadMemberUpdate(const dpp::thread_member_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpThreadMemberUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnThreadMembersUpdate(const dpp::thread_members_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpThreadMembersUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildScheduledEventCreate(const dpp::guild_scheduled_event_create_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildScheduledEventCreateEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildScheduledEventUpdate(const dpp::guild_scheduled_event_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildScheduledEventUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildScheduledEventDelete(const dpp::guild_scheduled_event_delete_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildScheduledEventDeleteEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildScheduledEventUserAdd(const dpp::guild_scheduled_event_user_add_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildScheduledEventUserAddEvent(ev))); }
|
||||||
|
void DpCluster::OnGuildScheduledEventUserRemove(const dpp::guild_scheduled_event_user_remove_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpGuildScheduledEventUserRemoveEvent(ev))); }
|
||||||
|
void DpCluster::OnVoiceBufferSend(const dpp::voice_buffer_send_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpVoiceBufferSendEvent(ev))); }
|
||||||
|
void DpCluster::OnVoiceUserTalking(const dpp::voice_user_talking_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpVoiceUserTalkingEvent(ev))); }
|
||||||
|
void DpCluster::OnVoiceReady(const dpp::voice_ready_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpVoiceReadyEvent(ev))); }
|
||||||
|
void DpCluster::OnVoiceReceive(const dpp::voice_receive_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpVoiceReceiveEvent(ev))); }
|
||||||
|
void DpCluster::OnVoiceReceiveCombined(const dpp::voice_receive_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpVoiceReceiveCombinedEvent(ev))); }
|
||||||
|
void DpCluster::OnVoiceTrackMarker(const dpp::voice_track_marker_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpVoiceTrackMarkerEvent(ev))); }
|
||||||
|
void DpCluster::OnStageInstanceCreate(const dpp::stage_instance_create_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpStageInstanceCreateEvent(ev))); }
|
||||||
|
void DpCluster::OnStageInstanceUpdate(const dpp::stage_instance_update_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpStageInstanceUpdateEvent(ev))); }
|
||||||
|
void DpCluster::OnStageInstanceDelete(const dpp::stage_instance_delete_t & ev)
|
||||||
|
{ mQueue.enqueue(EventItem(new DpStageInstanceDeleteEvent(ev))); }
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
337
module/Library/Discord/Cluster.hpp
Normal file
337
module/Library/Discord/Cluster.hpp
Normal file
@ -0,0 +1,337 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
#include "Core/Signal.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Constants.hpp"
|
||||||
|
#include "Library/Discord/Misc.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
#include <memory>
|
||||||
|
#include <functional>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <concurrentqueue.h>
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
struct DpEventBase;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct DpClusterOptions
|
||||||
|
{
|
||||||
|
// The bot token to use for all HTTP commands and websocket connections.
|
||||||
|
std::string mToken{};
|
||||||
|
// A bitmask of dpd::intents values for all shards on this cluster. This is required to be sent for all bots with over 100 servers.
|
||||||
|
uint32_t mIntents{dpp::i_default_intents};
|
||||||
|
// 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.
|
||||||
|
uint32_t mShards{0};
|
||||||
|
// The ID of this cluster, should be between 0 and MAXCLUSTERS-1
|
||||||
|
uint32_t mClusterID{0};
|
||||||
|
// The total number of clusters that are active, which may be on separate processes or even separate machines.
|
||||||
|
uint32_t mMaxClusters{1};
|
||||||
|
// Whether or not to use compression for shards on this cluster. Saves a ton of bandwidth at the cost of some CPU
|
||||||
|
bool mCompressed{true};
|
||||||
|
// 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)
|
||||||
|
dpp::cache_policy_t mPolicy{dpp::cp_aggressive, dpp::cp_aggressive, dpp::cp_aggressive};
|
||||||
|
// The number of threads to allocate for making HTTP requests to Discord. This defaults to 12. You can increase this at runtime via the object returned from get_rest().
|
||||||
|
uint32_t mRequestThreads{12};
|
||||||
|
// The number of threads to allocate for making HTTP requests to sites outside of Discord. This defaults to 1. You can increase this at runtime via the object returned from get_raw_rest().
|
||||||
|
uint32_t mRequestThreadsRaw{1};
|
||||||
|
// Disable automatic forwarding of logged messages to internal logging. Allows to handle logging manually without risking duplicate output (at the cost of some performance, ofc).
|
||||||
|
bool mCustomLogging{false};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Base constructors.
|
||||||
|
*/
|
||||||
|
DpClusterOptions(StackStrF & token)
|
||||||
|
: mToken(token.ToStr())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy/Move constructors.
|
||||||
|
*/
|
||||||
|
DpClusterOptions(const DpClusterOptions &) noexcept = default;
|
||||||
|
DpClusterOptions(DpClusterOptions &&) noexcept = default;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy/Move assignment operators.
|
||||||
|
*/
|
||||||
|
DpClusterOptions & operator = (const DpClusterOptions &) noexcept = default;
|
||||||
|
DpClusterOptions & operator = (DpClusterOptions &&) noexcept = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Primitive implementation of a discord client with basic functionality.
|
||||||
|
*/
|
||||||
|
struct DpCluster : public SqChainedInstances< DpCluster >
|
||||||
|
{
|
||||||
|
using Base = SqChainedInstances< DpCluster >;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Queue of events generated from other threads.
|
||||||
|
*/
|
||||||
|
using EventItem = std::unique_ptr< DpEventBase >;
|
||||||
|
using EventQueue = moodycamel::ConcurrentQueue< EventItem >;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Type of container for cluster signals.
|
||||||
|
*/
|
||||||
|
using Signals = std::array< SignalPair, static_cast< size_t >(DpEventID::Max) >;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Type of container for event handles.
|
||||||
|
*/
|
||||||
|
using EventHandle = std::array< dpp::event_handle, static_cast< size_t >(DpEventID::Max) >;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Event queue.
|
||||||
|
*/
|
||||||
|
EventQueue mQueue{4096};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Managed cluster instance.
|
||||||
|
*/
|
||||||
|
std::unique_ptr< dpp::cluster > mC;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Table containing the emitted cluster events.
|
||||||
|
*/
|
||||||
|
LightObj mSqEvents{};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Cluster signals.
|
||||||
|
*/
|
||||||
|
Signals mEvents{};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Event handles for bound event event handlers so they can be stopped at any time.
|
||||||
|
*/
|
||||||
|
EventHandle mEventsHandle{};
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Base constructors.
|
||||||
|
*/
|
||||||
|
DpCluster(DpClusterOptions & o);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy/Move constructors (disabled).
|
||||||
|
*/
|
||||||
|
DpCluster(const DpCluster &) noexcept = delete;
|
||||||
|
DpCluster(DpCluster &&) noexcept = delete;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpCluster()
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
// Forget about this instance
|
||||||
|
UnchainInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy/Move assignment operators (disabled).
|
||||||
|
*/
|
||||||
|
DpCluster & operator = (const DpCluster &) noexcept = delete;
|
||||||
|
DpCluster & operator = (DpCluster &&) noexcept = delete;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if the managed cluster instance is valid and throw an exception otherwise.
|
||||||
|
*/
|
||||||
|
void Validate() const
|
||||||
|
{
|
||||||
|
if (!mC)
|
||||||
|
{
|
||||||
|
STHROWF("Discord cluster instance is not valid anymore.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if the managed cluster instance is valid and throw an exception otherwise.
|
||||||
|
*/
|
||||||
|
void Validate(const char * m) const
|
||||||
|
{
|
||||||
|
if (!mC)
|
||||||
|
{
|
||||||
|
STHROWF("Cannot {} a cluster instance that is not valid anymore.", fmt::to_string_view(m));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if the managed cluster instance is valid and throw an exception otherwise.
|
||||||
|
*/
|
||||||
|
dpp::cluster & Valid() const { Validate(); return *mC; }
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if the managed cluster instance is valid and throw an exception otherwise.
|
||||||
|
*/
|
||||||
|
dpp::cluster & Valid(const char * m) const { Validate(m); return *mC; }
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Process the cluster. This is used internally on each server frame.
|
||||||
|
*/
|
||||||
|
void Process(bool force = false);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Terminate the cluster. This is used internally when the VM is shutting down.
|
||||||
|
*/
|
||||||
|
void Terminate();
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Start the cluster.
|
||||||
|
*/
|
||||||
|
DpCluster & Start() { Valid("start").start(dpp::st_return); return *this; }
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Stop the cluster.
|
||||||
|
*/
|
||||||
|
void Stop() { Valid("stop").shutdown(); }
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the events table of this cluster.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj & GetEvents()
|
||||||
|
{
|
||||||
|
return mSqEvents;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Enable a certain event for the cluster.
|
||||||
|
*/
|
||||||
|
DpCluster & EnableEvent(SQInteger id);
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Disable a certain event for the cluster.
|
||||||
|
*/
|
||||||
|
DpCluster & DisableEvent(SQInteger id);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Signal initialization.
|
||||||
|
*/
|
||||||
|
void InitEvents()
|
||||||
|
{
|
||||||
|
// Ignore the call if already initialized
|
||||||
|
if (!mSqEvents.IsNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Create a new table on the stack with enough space pre-allocated
|
||||||
|
sq_newtableex(SqVM(), static_cast< SQInteger >(DpEventID::Max + 1));
|
||||||
|
// 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 OnVoiceClientDisconnect(const dpp::voice_client_disconnect_t & ev);
|
||||||
|
void OnVoiceClientSpeaking(const dpp::voice_client_speaking_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 OnSlashCommand(const dpp::slashcommand_t & ev);
|
||||||
|
void OnButtonClick(const dpp::button_click_t & ev);
|
||||||
|
void OnAutoComplete(const dpp::autocomplete_t & ev);
|
||||||
|
void OnSelectClick(const dpp::select_click_t & ev);
|
||||||
|
void OnMessageContextMenu(const dpp::message_context_menu_t & ev);
|
||||||
|
void OnUserContextMenu(const dpp::user_context_menu_t & ev);
|
||||||
|
void OnFormSubmit(const dpp::form_submit_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 OnGuildMemberRemove(const dpp::guild_member_remove_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 OnMessageDeleteDulk(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 OnAutomodRuleCreate(const dpp::automod_rule_create_t & ev);
|
||||||
|
void OnAutomodRuleUpdate(const dpp::automod_rule_update_t & ev);
|
||||||
|
void OnAutomodRuleDelete(const dpp::automod_rule_delete_t & ev);
|
||||||
|
void OnAutomodRuleExecute(const dpp::automod_rule_execute_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 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 OnGuildScheduledEventCreate(const dpp::guild_scheduled_event_create_t & ev);
|
||||||
|
void OnGuildScheduledEventUpdate(const dpp::guild_scheduled_event_update_t & ev);
|
||||||
|
void OnGuildScheduledEventDelete(const dpp::guild_scheduled_event_delete_t & ev);
|
||||||
|
void OnGuildScheduledEventUserAdd(const dpp::guild_scheduled_event_user_add_t & ev);
|
||||||
|
void OnGuildScheduledEventUserRemove(const dpp::guild_scheduled_event_user_remove_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 OnVoiceReceiveCombined(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 OnStageInstanceUpdate(const dpp::stage_instance_update_t & ev);
|
||||||
|
void OnStageInstanceDelete(const dpp::stage_instance_delete_t & ev);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
9
module/Library/Discord/Command.cpp
Normal file
9
module/Library/Discord/Command.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Command.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
13
module/Library/Discord/Command.hpp
Normal file
13
module/Library/Discord/Command.hpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
282
module/Library/Discord/Constants.cpp
Normal file
282
module/Library/Discord/Constants.cpp
Normal file
@ -0,0 +1,282 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Constants.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <sqratConst.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
const std::array< const char *, static_cast< size_t >(DpEventID::Max) > DpEventID::NAME{
|
||||||
|
"VoiceStateUpdate",
|
||||||
|
"VoiceClientDisconnect",
|
||||||
|
"VoiceClientSpeaking",
|
||||||
|
"Log",
|
||||||
|
"GuildJoinRequestDelete",
|
||||||
|
"InteractionCreate",
|
||||||
|
"SlashCommand",
|
||||||
|
"ButtonClick",
|
||||||
|
"AutoComplete",
|
||||||
|
"SelectClick",
|
||||||
|
"MessageContextMenu",
|
||||||
|
"UserContextMenu",
|
||||||
|
"FormSubmit",
|
||||||
|
"GuildDelete",
|
||||||
|
"ChannelDelete",
|
||||||
|
"ChannelUpdate",
|
||||||
|
"Ready",
|
||||||
|
"MessageDelete",
|
||||||
|
"GuildMemberRemove",
|
||||||
|
"Resumed",
|
||||||
|
"GuildRoleCreate",
|
||||||
|
"TypingStart",
|
||||||
|
"MessageReactionAdd",
|
||||||
|
"GuildMembersChunk",
|
||||||
|
"MessageReactionRemove",
|
||||||
|
"GuildCreate",
|
||||||
|
"ChannelCreate",
|
||||||
|
"MessageReactionRemoveEmoji",
|
||||||
|
"MessageDeleteDulk",
|
||||||
|
"GuildRoleUpdate",
|
||||||
|
"GuildRoleDelete",
|
||||||
|
"ChannelPinsUpdate",
|
||||||
|
"MessageReactionRemoveAll",
|
||||||
|
"VoiceServerUpdate",
|
||||||
|
"GuildEmojisUpdate",
|
||||||
|
"GuildStickersUpdate",
|
||||||
|
"PresenceUpdate",
|
||||||
|
"WebhooksUpdate",
|
||||||
|
"AutomodRuleCreate",
|
||||||
|
"AutomodRuleUpdate",
|
||||||
|
"AutomodRuleDelete",
|
||||||
|
"AutomodRuleExecute",
|
||||||
|
"GuildMemberAdd",
|
||||||
|
"InviteDelete",
|
||||||
|
"GuildUpdate",
|
||||||
|
"GuildIntegrationsUpdate",
|
||||||
|
"GuildMemberUpdate",
|
||||||
|
"InviteCreate",
|
||||||
|
"MessageUpdate",
|
||||||
|
"UserUpdate",
|
||||||
|
"MessageCreate",
|
||||||
|
"GuildBanAdd",
|
||||||
|
"GuildBanRemove",
|
||||||
|
"IntegrationCreate",
|
||||||
|
"IntegrationUpdate",
|
||||||
|
"IntegrationDelete",
|
||||||
|
"ThreadCreate",
|
||||||
|
"ThreadUpdate",
|
||||||
|
"ThreadDelete",
|
||||||
|
"ThreadListSync",
|
||||||
|
"ThreadMemberUpdate",
|
||||||
|
"ThreadMembersUpdate",
|
||||||
|
"GuildScheduledEventCreate",
|
||||||
|
"GuildScheduledEventUpdate",
|
||||||
|
"GuildScheduledEventDelete",
|
||||||
|
"GuildScheduledEventUserAdd",
|
||||||
|
"GuildScheduledEventUserRemove",
|
||||||
|
"VoiceBufferSend",
|
||||||
|
"VoiceUserTalking",
|
||||||
|
"VoiceReady",
|
||||||
|
"VoiceReceive",
|
||||||
|
"VoiceReceiveCombined",
|
||||||
|
"VoiceTrackMarker",
|
||||||
|
"StageInstanceCreate",
|
||||||
|
"StageInstanceUpdate",
|
||||||
|
"StageInstanceDelete",
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpLogLevelEnum[] = {
|
||||||
|
{_SC("Trace"), static_cast< SQInteger >(dpp::ll_trace)},
|
||||||
|
{_SC("Debug"), static_cast< SQInteger >(dpp::ll_debug)},
|
||||||
|
{_SC("Info"), static_cast< SQInteger >(dpp::ll_info)},
|
||||||
|
{_SC("Warning"), static_cast< SQInteger >(dpp::ll_warning)},
|
||||||
|
{_SC("Error"), static_cast< SQInteger >(dpp::ll_error)},
|
||||||
|
{_SC("Critical"), static_cast< SQInteger >(dpp::ll_critical)},
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpVoiceStateFlagsEnum[] = {
|
||||||
|
{_SC("Deaf"), static_cast< SQInteger >(dpp::vs_deaf)},
|
||||||
|
{_SC("Mute"), static_cast< SQInteger >(dpp::vs_mute)},
|
||||||
|
{_SC("SelfMute"), static_cast< SQInteger >(dpp::vs_self_mute)},
|
||||||
|
{_SC("SelfDeaf"), static_cast< SQInteger >(dpp::vs_self_deaf)},
|
||||||
|
{_SC("SelfStream"), static_cast< SQInteger >(dpp::vs_self_stream)},
|
||||||
|
{_SC("SelfVideo"), static_cast< SQInteger >(dpp::vs_self_video)},
|
||||||
|
{_SC("Suppress"), static_cast< SQInteger >(dpp::vs_suppress)},
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpEmojiFlagsEnum[] = {
|
||||||
|
{_SC("RequireColons"), static_cast< SQInteger >(dpp::e_require_colons)},
|
||||||
|
{_SC("Managed"), static_cast< SQInteger >(dpp::e_managed)},
|
||||||
|
{_SC("Animated"), static_cast< SQInteger >(dpp::e_animated)},
|
||||||
|
{_SC("Available"), static_cast< SQInteger >(dpp::e_available)},
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpPresenceFlagsEnum[] = {
|
||||||
|
{_SC("DesktopOnline"), static_cast< SQInteger >(dpp::p_desktop_online)},
|
||||||
|
{_SC("DesktopDND"), static_cast< SQInteger >(dpp::p_desktop_dnd)},
|
||||||
|
{_SC("DesktopIdle"), static_cast< SQInteger >(dpp::p_desktop_idle)},
|
||||||
|
{_SC("WebOnline"), static_cast< SQInteger >(dpp::p_web_online)},
|
||||||
|
{_SC("WebDND"), static_cast< SQInteger >(dpp::p_web_dnd)},
|
||||||
|
{_SC("WebIdle"), static_cast< SQInteger >(dpp::p_web_idle)},
|
||||||
|
{_SC("MobileOnline"), static_cast< SQInteger >(dpp::p_mobile_online)},
|
||||||
|
{_SC("MobileDND"), static_cast< SQInteger >(dpp::p_mobile_dnd)},
|
||||||
|
{_SC("MobileIdle"), static_cast< SQInteger >(dpp::p_mobile_idle)},
|
||||||
|
{_SC("StatusOnline"), static_cast< SQInteger >(dpp::p_status_online)},
|
||||||
|
{_SC("StatusDND"), static_cast< SQInteger >(dpp::p_status_dnd)},
|
||||||
|
{_SC("StatusIdle"), static_cast< SQInteger >(dpp::p_status_idle)},
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpPresenceStatusEnum[] = {
|
||||||
|
{_SC("Offline"), static_cast< SQInteger >(dpp::ps_offline)},
|
||||||
|
{_SC("Online"), static_cast< SQInteger >(dpp::ps_online)},
|
||||||
|
{_SC("DND"), static_cast< SQInteger >(dpp::ps_dnd)},
|
||||||
|
{_SC("Idle"), static_cast< SQInteger >(dpp::ps_idle)},
|
||||||
|
// Bit shift for desktop status
|
||||||
|
{_SC("ShiftDesktop"), static_cast< SQInteger >(PF_SHIFT_DESKTOP)},
|
||||||
|
{_SC("ShiftWeb"), static_cast< SQInteger >(PF_SHIFT_WEB)},
|
||||||
|
{_SC("ShiftMobile"), static_cast< SQInteger >(PF_SHIFT_MOBILE)},
|
||||||
|
{_SC("ShiftMain"), static_cast< SQInteger >(PF_SHIFT_MAIN)},
|
||||||
|
{_SC("StatusMask"), static_cast< SQInteger >(PF_STATUS_MASK)},
|
||||||
|
{_SC("ClearDesktop"), static_cast< SQInteger >(PF_CLEAR_DESKTOP)},
|
||||||
|
{_SC("ClearWeb"), static_cast< SQInteger >(PF_CLEAR_WEB)},
|
||||||
|
{_SC("ClearMobile"), static_cast< SQInteger >(PF_CLEAR_MOBILE)},
|
||||||
|
{_SC("ClearStatus"), static_cast< SQInteger >(PF_CLEAR_STATUS)},
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpActivityTypeEnum[] = {
|
||||||
|
{_SC("Game"), static_cast< SQInteger >(dpp::at_game)},
|
||||||
|
{_SC("Streaming"), static_cast< SQInteger >(dpp::at_streaming)},
|
||||||
|
{_SC("Listening"), static_cast< SQInteger >(dpp::at_listening)},
|
||||||
|
{_SC("Watching"), static_cast< SQInteger >(dpp::at_watching)},
|
||||||
|
{_SC("Custom"), static_cast< SQInteger >(dpp::at_custom)},
|
||||||
|
{_SC("Competing"), static_cast< SQInteger >(dpp::at_competing)},
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpActivityFlagsEnum[] = {
|
||||||
|
{_SC("Instance"), static_cast< SQInteger >(dpp::af_instance)},
|
||||||
|
{_SC("Join"), static_cast< SQInteger >(dpp::af_join)},
|
||||||
|
{_SC("Spectate"), static_cast< SQInteger >(dpp::af_spectate)},
|
||||||
|
{_SC("JoinRequest"), static_cast< SQInteger >(dpp::af_join_request)},
|
||||||
|
{_SC("Sync"), static_cast< SQInteger >(dpp::af_sync)},
|
||||||
|
{_SC("Play"), static_cast< SQInteger >(dpp::af_play)},
|
||||||
|
{_SC("PartyPrivacyFriends"), static_cast< SQInteger >(dpp::af_party_privacy_friends)},
|
||||||
|
{_SC("PartyPrivacyVoiceChannel"), static_cast< SQInteger >(dpp::af_party_privacy_voice_channel)},
|
||||||
|
{_SC("Embedded"), static_cast< SQInteger >(dpp::af_embedded)},
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpRegionEnum[] = {
|
||||||
|
{_SC("Brazil"), static_cast< SQInteger >(dpp::r_brazil)},
|
||||||
|
{_SC("CentralEurope"), static_cast< SQInteger >(dpp::r_central_europe)},
|
||||||
|
{_SC("HongKong"), static_cast< SQInteger >(dpp::r_hong_kong)},
|
||||||
|
{_SC("India"), static_cast< SQInteger >(dpp::r_india)},
|
||||||
|
{_SC("Japan"), static_cast< SQInteger >(dpp::r_japan)},
|
||||||
|
{_SC("Russia"), static_cast< SQInteger >(dpp::r_russia)},
|
||||||
|
{_SC("Singapore"), static_cast< SQInteger >(dpp::r_singapore)},
|
||||||
|
{_SC("SouthAfrica"), static_cast< SQInteger >(dpp::r_south_africa)},
|
||||||
|
{_SC("Sydney"), static_cast< SQInteger >(dpp::r_sydney)},
|
||||||
|
{_SC("UsCentral"), static_cast< SQInteger >(dpp::r_us_central)},
|
||||||
|
{_SC("UsEast"), static_cast< SQInteger >(dpp::r_us_east)},
|
||||||
|
{_SC("UsSouth"), static_cast< SQInteger >(dpp::r_us_south)},
|
||||||
|
{_SC("UsWest"), static_cast< SQInteger >(dpp::r_us_west)},
|
||||||
|
{_SC("WesternEurope"), static_cast< SQInteger >(dpp::r_western_europe)},
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpGuildFlagsEnum[] = {
|
||||||
|
{_SC("Large"), static_cast< SQInteger >(dpp::g_large)},
|
||||||
|
{_SC("Unavailable"), static_cast< SQInteger >(dpp::g_unavailable)},
|
||||||
|
{_SC("WidgetEnabled"), static_cast< SQInteger >(dpp::g_widget_enabled)},
|
||||||
|
{_SC("InviteSplash"), static_cast< SQInteger >(dpp::g_invite_splash)},
|
||||||
|
{_SC("VipRegions"), static_cast< SQInteger >(dpp::g_vip_regions)},
|
||||||
|
{_SC("VanityURL"), static_cast< SQInteger >(dpp::g_vanity_url)},
|
||||||
|
{_SC("Verified"), static_cast< SQInteger >(dpp::g_verified)},
|
||||||
|
{_SC("Partnered"), static_cast< SQInteger >(dpp::g_partnered)},
|
||||||
|
{_SC("Community"), static_cast< SQInteger >(dpp::g_community)},
|
||||||
|
{_SC("RoleSubscriptionEnabled"), static_cast< SQInteger >(dpp::g_role_subscription_enabled)},
|
||||||
|
{_SC("News"), static_cast< SQInteger >(dpp::g_news)},
|
||||||
|
{_SC("Discoverable"), static_cast< SQInteger >(dpp::g_discoverable)},
|
||||||
|
{_SC("Featureable"), static_cast< SQInteger >(dpp::g_featureable)},
|
||||||
|
{_SC("AnimatedIcon"), static_cast< SQInteger >(dpp::g_animated_icon)},
|
||||||
|
{_SC("Banner"), static_cast< SQInteger >(dpp::g_banner)},
|
||||||
|
{_SC("WelcomeScreenEnabled"), static_cast< SQInteger >(dpp::g_welcome_screen_enabled)},
|
||||||
|
{_SC("MemberVerificationGate"), static_cast< SQInteger >(dpp::g_member_verification_gate)},
|
||||||
|
{_SC("PreviewEnabled"), static_cast< SQInteger >(dpp::g_preview_enabled)},
|
||||||
|
{_SC("NoJoinNotifications"), static_cast< SQInteger >(dpp::g_no_join_notifications)},
|
||||||
|
{_SC("NoBoostNotifications"), static_cast< SQInteger >(dpp::g_no_boost_notifications)},
|
||||||
|
{_SC("HasAnimatedIcon"), static_cast< SQInteger >(dpp::g_has_animated_icon)},
|
||||||
|
{_SC("HasAnimatedBanner"), static_cast< SQInteger >(dpp::g_has_animated_banner)},
|
||||||
|
{_SC("NoSetupTips"), static_cast< SQInteger >(dpp::g_no_setup_tips)},
|
||||||
|
{_SC("NoStickerGreeting"), static_cast< SQInteger >(dpp::g_no_sticker_greeting)},
|
||||||
|
{_SC("MonetizationEnabled"), static_cast< SQInteger >(dpp::g_monetization_enabled)},
|
||||||
|
{_SC("MoreStickers"), static_cast< SQInteger >(dpp::g_more_stickers)},
|
||||||
|
{_SC("CreatorStorePageEnabled"), static_cast< SQInteger >(dpp::g_creator_store_page_enabled)},
|
||||||
|
{_SC("RoleIcons"), static_cast< SQInteger >(dpp::g_role_icons)},
|
||||||
|
{_SC("SevenDayThreadArchive"), static_cast< SQInteger >(dpp::g_seven_day_thread_archive)},
|
||||||
|
{_SC("ThreeDayThreadArchive"), static_cast< SQInteger >(dpp::g_three_day_thread_archive)},
|
||||||
|
{_SC("TicketedEvents"), static_cast< SQInteger >(dpp::g_ticketed_events)},
|
||||||
|
{_SC("ChannelBanners"), static_cast< SQInteger >(dpp::g_channel_banners)},
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpGuildFlagsExtraEnum[] = {
|
||||||
|
{_SC("PremiumProgressBarEnabled"), static_cast< SQInteger >(dpp::g_premium_progress_bar_enabled)},
|
||||||
|
{_SC("AnimatedBanner"), static_cast< SQInteger >(dpp::g_animated_banner)},
|
||||||
|
{_SC("AutoModeration"), static_cast< SQInteger >(dpp::g_auto_moderation)},
|
||||||
|
{_SC("InvitesDisabled"), static_cast< SQInteger >(dpp::g_invites_disabled)},
|
||||||
|
{_SC("DeveloperSupportServer"), static_cast< SQInteger >(dpp::g_developer_support_server)},
|
||||||
|
{_SC("NoRoleSubscriptionNotifications"), static_cast< SQInteger >(dpp::g_no_role_subscription_notifications)},
|
||||||
|
{_SC("NoRoleSubscriptionNotificationReplies"), static_cast< SQInteger >(dpp::g_no_role_subscription_notification_replies)},
|
||||||
|
{_SC("RoleSubscriptionsAvailableForPurchase"), static_cast< SQInteger >(dpp::g_role_subscriptions_available_for_purchase)},
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElement g_DpGuildMemberFlagsEnum[] = {
|
||||||
|
{_SC("Deaf"), static_cast< SQInteger >(dpp::gm_deaf)},
|
||||||
|
{_SC("Mute"), static_cast< SQInteger >(dpp::gm_mute)},
|
||||||
|
{_SC("Pending"), static_cast< SQInteger >(dpp::gm_pending)},
|
||||||
|
{_SC("AnimatedAvatar"), static_cast< SQInteger >(dpp::gm_animated_avatar)},
|
||||||
|
{_SC("VoiceAction"), static_cast< SQInteger >(dpp::gm_voice_action)},
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
static const EnumElements g_EnumList[] = {
|
||||||
|
{_SC("SqDiscordLogLevel"), g_DpLogLevelEnum},
|
||||||
|
{_SC("SqDiscordVoiceStateFlags"), g_DpVoiceStateFlagsEnum},
|
||||||
|
{_SC("SqDiscordEmojiFlags"), g_DpEmojiFlagsEnum},
|
||||||
|
{_SC("SqDiscordPresenceFlags"), g_DpPresenceFlagsEnum},
|
||||||
|
{_SC("SqDiscordPresenceStatus"), g_DpPresenceStatusEnum},
|
||||||
|
{_SC("SqDiscordActivityType"), g_DpActivityTypeEnum},
|
||||||
|
{_SC("SqDiscordActivityFlags"), g_DpActivityFlagsEnum},
|
||||||
|
{_SC("SqDiscordRegion"), g_DpRegionEnum},
|
||||||
|
{_SC("SqDiscordGuildFlags"), g_DpGuildFlagsEnum},
|
||||||
|
{_SC("SqDiscordGuildFlagsExtra"), g_DpGuildFlagsExtraEnum},
|
||||||
|
{_SC("SqDiscordGuildMemberFlags"), g_DpGuildMemberFlagsEnum},
|
||||||
|
};
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_Discord_Constants(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
RegisterEnumerations(vm, g_EnumList);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
Enumeration e(vm);
|
||||||
|
// Bind all events using their associated name
|
||||||
|
for (SQInteger i = 0; i < static_cast< SQInteger >(DpEventID::Max); ++i)
|
||||||
|
{
|
||||||
|
e.Const(DpEventID::NAME[i], i);
|
||||||
|
}
|
||||||
|
// Expose the constants
|
||||||
|
ConstTable(vm).Enum(_SC("SqDiscordEvent"), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
655
module/Library/Discord/Constants.hpp
Normal file
655
module/Library/Discord/Constants.hpp
Normal file
@ -0,0 +1,655 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <array>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Unique ID for each event.
|
||||||
|
*/
|
||||||
|
struct DpEventID
|
||||||
|
{
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* ID enumeration.
|
||||||
|
*/
|
||||||
|
enum Type
|
||||||
|
{
|
||||||
|
VoiceStateUpdate=0,
|
||||||
|
VoiceClientDisconnect,
|
||||||
|
VoiceClientSpeaking,
|
||||||
|
Log,
|
||||||
|
GuildJoinRequestDelete,
|
||||||
|
InteractionCreate,
|
||||||
|
SlashCommand,
|
||||||
|
ButtonClick,
|
||||||
|
AutoComplete,
|
||||||
|
SelectClick,
|
||||||
|
MessageContextMenu,
|
||||||
|
UserContextMenu,
|
||||||
|
FormSubmit,
|
||||||
|
GuildDelete,
|
||||||
|
ChannelDelete,
|
||||||
|
ChannelUpdate,
|
||||||
|
Ready,
|
||||||
|
MessageDelete,
|
||||||
|
GuildMemberRemove,
|
||||||
|
Resumed,
|
||||||
|
GuildRoleCreate,
|
||||||
|
TypingStart,
|
||||||
|
MessageReactionAdd,
|
||||||
|
GuildMembersChunk,
|
||||||
|
MessageReactionRemove,
|
||||||
|
GuildCreate,
|
||||||
|
ChannelCreate,
|
||||||
|
MessageReactionRemoveEmoji,
|
||||||
|
MessageDeleteDulk,
|
||||||
|
GuildRoleUpdate,
|
||||||
|
GuildRoleDelete,
|
||||||
|
ChannelPinsUpdate,
|
||||||
|
MessageReactionRemoveAll,
|
||||||
|
VoiceServerUpdate,
|
||||||
|
GuildEmojisUpdate,
|
||||||
|
GuildStickersUpdate,
|
||||||
|
PresenceUpdate,
|
||||||
|
WebhooksUpdate,
|
||||||
|
AutomodRuleCreate,
|
||||||
|
AutomodRuleUpdate,
|
||||||
|
AutomodRuleDelete,
|
||||||
|
AutomodRuleExecute,
|
||||||
|
GuildMemberAdd,
|
||||||
|
InviteDelete,
|
||||||
|
GuildUpdate,
|
||||||
|
GuildIntegrationsUpdate,
|
||||||
|
GuildMemberUpdate,
|
||||||
|
InviteCreate,
|
||||||
|
MessageUpdate,
|
||||||
|
UserUpdate,
|
||||||
|
MessageCreate,
|
||||||
|
GuildBanAdd,
|
||||||
|
GuildBanRemove,
|
||||||
|
IntegrationCreate,
|
||||||
|
IntegrationUpdate,
|
||||||
|
IntegrationDelete,
|
||||||
|
ThreadCreate,
|
||||||
|
ThreadUpdate,
|
||||||
|
ThreadDelete,
|
||||||
|
ThreadListSync,
|
||||||
|
ThreadMemberUpdate,
|
||||||
|
ThreadMembersUpdate,
|
||||||
|
GuildScheduledEventCreate,
|
||||||
|
GuildScheduledEventUpdate,
|
||||||
|
GuildScheduledEventDelete,
|
||||||
|
GuildScheduledEventUserAdd,
|
||||||
|
GuildScheduledEventUserRemove,
|
||||||
|
VoiceBufferSend,
|
||||||
|
VoiceUserTalking,
|
||||||
|
VoiceReady,
|
||||||
|
VoiceReceive,
|
||||||
|
VoiceReceiveCombined,
|
||||||
|
VoiceTrackMarker,
|
||||||
|
StageInstanceCreate,
|
||||||
|
StageInstanceUpdate,
|
||||||
|
StageInstanceDelete,
|
||||||
|
Max
|
||||||
|
};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* String identification for each event ID.
|
||||||
|
*/
|
||||||
|
static const std::array< const char *, static_cast< size_t >(Max) > NAME;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Structures that hold compile-time type information for events.
|
||||||
|
*/
|
||||||
|
struct DpVoiceStateUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::voice_state_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::VoiceStateUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "VoiceStateUpdate";
|
||||||
|
};
|
||||||
|
struct DpVoiceClientDisconnectEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::voice_client_disconnect_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::VoiceClientDisconnect;
|
||||||
|
static inline constexpr std::string_view Name = "VoiceClientDisconnect";
|
||||||
|
};
|
||||||
|
struct DpVoiceClientSpeakingEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::voice_client_speaking_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::VoiceClientSpeaking;
|
||||||
|
static inline constexpr std::string_view Name = "VoiceClientSpeaking";
|
||||||
|
};
|
||||||
|
struct DpLogEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::log_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::Log;
|
||||||
|
static inline constexpr std::string_view Name = "Log";
|
||||||
|
};
|
||||||
|
struct DpGuildJoinRequestDeleteEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_join_request_delete_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildJoinRequestDelete;
|
||||||
|
static inline constexpr std::string_view Name = "GuildJoinRequestDelete";
|
||||||
|
};
|
||||||
|
struct DpInteractionCreateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::interaction_create_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::InteractionCreate;
|
||||||
|
static inline constexpr std::string_view Name = "InteractionCreate";
|
||||||
|
};
|
||||||
|
struct DpSlashCommandEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::slashcommand_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::SlashCommand;
|
||||||
|
static inline constexpr std::string_view Name = "SlashCommand";
|
||||||
|
};
|
||||||
|
struct DpButtonClickEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::button_click_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::ButtonClick;
|
||||||
|
static inline constexpr std::string_view Name = "ButtonClick";
|
||||||
|
};
|
||||||
|
struct DpAutoCompleteEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::autocomplete_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::AutoComplete;
|
||||||
|
static inline constexpr std::string_view Name = "AutoComplete";
|
||||||
|
};
|
||||||
|
struct DpSelectClickEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::select_click_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::SelectClick;
|
||||||
|
static inline constexpr std::string_view Name = "SelectClick";
|
||||||
|
};
|
||||||
|
struct DpMessageContextMenuEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::message_context_menu_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::MessageContextMenu;
|
||||||
|
static inline constexpr std::string_view Name = "MessageContextMenu";
|
||||||
|
};
|
||||||
|
struct DpUserContextMenuEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::user_context_menu_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::UserContextMenu;
|
||||||
|
static inline constexpr std::string_view Name = "UserContextMenu";
|
||||||
|
};
|
||||||
|
struct DpFormSubmitEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::form_submit_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::FormSubmit;
|
||||||
|
static inline constexpr std::string_view Name = "FormSubmit";
|
||||||
|
};
|
||||||
|
struct DpGuildDeleteEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_delete_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildDelete;
|
||||||
|
static inline constexpr std::string_view Name = "GuildDelete";
|
||||||
|
};
|
||||||
|
struct DpChannelDeleteEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::channel_delete_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::ChannelDelete;
|
||||||
|
static inline constexpr std::string_view Name = "ChannelDelete";
|
||||||
|
};
|
||||||
|
struct DpChannelUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::channel_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::ChannelUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "ChannelUpdate";
|
||||||
|
};
|
||||||
|
struct DpReadyEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::ready_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::Ready;
|
||||||
|
static inline constexpr std::string_view Name = "Ready";
|
||||||
|
};
|
||||||
|
struct DpMessageDeleteEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::message_delete_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::MessageDelete;
|
||||||
|
static inline constexpr std::string_view Name = "MessageDelete";
|
||||||
|
};
|
||||||
|
struct DpGuildMemberRemoveEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_member_remove_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildMemberRemove;
|
||||||
|
static inline constexpr std::string_view Name = "GuildMemberRemove";
|
||||||
|
};
|
||||||
|
struct DpResumedEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::resumed_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::Resumed;
|
||||||
|
static inline constexpr std::string_view Name = "Resumed";
|
||||||
|
};
|
||||||
|
struct DpGuildRoleCreateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_role_create_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildRoleCreate;
|
||||||
|
static inline constexpr std::string_view Name = "GuildRoleCreate";
|
||||||
|
};
|
||||||
|
struct DpTypingStartEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::typing_start_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::TypingStart;
|
||||||
|
static inline constexpr std::string_view Name = "TypingStart";
|
||||||
|
};
|
||||||
|
struct DpMessageReactionAddEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::message_reaction_add_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::MessageReactionAdd;
|
||||||
|
static inline constexpr std::string_view Name = "MessageReactionAdd";
|
||||||
|
};
|
||||||
|
struct DpGuildMembersChunkEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_members_chunk_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildMembersChunk;
|
||||||
|
static inline constexpr std::string_view Name = "GuildMembersChunk";
|
||||||
|
};
|
||||||
|
struct DpMessageReactionRemoveEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::message_reaction_remove_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::MessageReactionRemove;
|
||||||
|
static inline constexpr std::string_view Name = "MessageReactionRemove";
|
||||||
|
};
|
||||||
|
struct DpGuildCreateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_create_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildCreate;
|
||||||
|
static inline constexpr std::string_view Name = "GuildCreate";
|
||||||
|
};
|
||||||
|
struct DpChannelCreateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::channel_create_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::ChannelCreate;
|
||||||
|
static inline constexpr std::string_view Name = "ChannelCreate";
|
||||||
|
};
|
||||||
|
struct DpMessageReactionRemoveEmojiEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::message_reaction_remove_emoji_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::MessageReactionRemoveEmoji;
|
||||||
|
static inline constexpr std::string_view Name = "MessageReactionRemoveEmoji";
|
||||||
|
};
|
||||||
|
struct DpMessageDeleteDulkEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::message_delete_bulk_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::MessageDeleteDulk;
|
||||||
|
static inline constexpr std::string_view Name = "MessageDeleteDulk";
|
||||||
|
};
|
||||||
|
struct DpGuildRoleUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_role_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildRoleUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "GuildRoleUpdate";
|
||||||
|
};
|
||||||
|
struct DpGuildRoleDeleteEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_role_delete_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildRoleDelete;
|
||||||
|
static inline constexpr std::string_view Name = "GuildRoleDelete";
|
||||||
|
};
|
||||||
|
struct DpChannelPinsUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::channel_pins_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::ChannelPinsUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "ChannelPinsUpdate";
|
||||||
|
};
|
||||||
|
struct DpMessageReactionRemoveAllEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::message_reaction_remove_all_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::MessageReactionRemoveAll;
|
||||||
|
static inline constexpr std::string_view Name = "MessageReactionRemoveAll";
|
||||||
|
};
|
||||||
|
struct DpVoiceServerUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::voice_server_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::VoiceServerUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "VoiceServerUpdate";
|
||||||
|
};
|
||||||
|
struct DpGuildEmojisUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_emojis_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildEmojisUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "GuildEmojisUpdate";
|
||||||
|
};
|
||||||
|
struct DpGuildStickersUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_stickers_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildStickersUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "GuildStickersUpdate";
|
||||||
|
};
|
||||||
|
struct DpPresenceUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::presence_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::PresenceUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "PresenceUpdate";
|
||||||
|
};
|
||||||
|
struct DpWebhooksUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::webhooks_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::WebhooksUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "WebhooksUpdate";
|
||||||
|
};
|
||||||
|
struct DpAutomodRuleCreateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::automod_rule_create_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::AutomodRuleCreate;
|
||||||
|
static inline constexpr std::string_view Name = "AutomodRuleCreate";
|
||||||
|
};
|
||||||
|
struct DpAutomodRuleUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::automod_rule_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::AutomodRuleUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "AutomodRuleUpdate";
|
||||||
|
};
|
||||||
|
struct DpAutomodRuleDeleteEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::automod_rule_delete_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::AutomodRuleDelete;
|
||||||
|
static inline constexpr std::string_view Name = "AutomodRuleDelete";
|
||||||
|
};
|
||||||
|
struct DpAutomodRuleExecuteEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::automod_rule_execute_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::AutomodRuleExecute;
|
||||||
|
static inline constexpr std::string_view Name = "AutomodRuleExecute";
|
||||||
|
};
|
||||||
|
struct DpGuildMemberAddEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_member_add_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildMemberAdd;
|
||||||
|
static inline constexpr std::string_view Name = "GuildMemberAdd";
|
||||||
|
};
|
||||||
|
struct DpInviteDeleteEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::invite_delete_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::InviteDelete;
|
||||||
|
static inline constexpr std::string_view Name = "InviteDelete";
|
||||||
|
};
|
||||||
|
struct DpGuildUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "GuildUpdate";
|
||||||
|
};
|
||||||
|
struct DpGuildIntegrationsUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_integrations_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildIntegrationsUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "GuildIntegrationsUpdate";
|
||||||
|
};
|
||||||
|
struct DpGuildMemberUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_member_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildMemberUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "GuildMemberUpdate";
|
||||||
|
};
|
||||||
|
struct DpInviteCreateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::invite_create_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::InviteCreate;
|
||||||
|
static inline constexpr std::string_view Name = "InviteCreate";
|
||||||
|
};
|
||||||
|
struct DpMessageUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::message_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::MessageUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "MessageUpdate";
|
||||||
|
};
|
||||||
|
struct DpUserUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::user_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::UserUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "UserUpdate";
|
||||||
|
};
|
||||||
|
struct DpMessageCreateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::message_create_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::MessageCreate;
|
||||||
|
static inline constexpr std::string_view Name = "MessageCreate";
|
||||||
|
};
|
||||||
|
struct DpGuildBanAddEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_ban_add_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildBanAdd;
|
||||||
|
static inline constexpr std::string_view Name = "GuildBanAdd";
|
||||||
|
};
|
||||||
|
struct DpGuildBanRemoveEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_ban_remove_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildBanRemove;
|
||||||
|
static inline constexpr std::string_view Name = "GuildBanRemove";
|
||||||
|
};
|
||||||
|
struct DpIntegrationCreateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::integration_create_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::IntegrationCreate;
|
||||||
|
static inline constexpr std::string_view Name = "IntegrationCreate";
|
||||||
|
};
|
||||||
|
struct DpIntegrationUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::integration_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::IntegrationUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "IntegrationUpdate";
|
||||||
|
};
|
||||||
|
struct DpIntegrationDeleteEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::integration_delete_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::IntegrationDelete;
|
||||||
|
static inline constexpr std::string_view Name = "IntegrationDelete";
|
||||||
|
};
|
||||||
|
struct DpThreadCreateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::thread_create_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::ThreadCreate;
|
||||||
|
static inline constexpr std::string_view Name = "ThreadCreate";
|
||||||
|
};
|
||||||
|
struct DpThreadUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::thread_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::ThreadUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "ThreadUpdate";
|
||||||
|
};
|
||||||
|
struct DpThreadDeleteEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::thread_delete_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::ThreadDelete;
|
||||||
|
static inline constexpr std::string_view Name = "ThreadDelete";
|
||||||
|
};
|
||||||
|
struct DpThreadListSyncEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::thread_list_sync_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::ThreadListSync;
|
||||||
|
static inline constexpr std::string_view Name = "ThreadListSync";
|
||||||
|
};
|
||||||
|
struct DpThreadMemberUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::thread_member_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::ThreadMemberUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "ThreadMemberUpdate";
|
||||||
|
};
|
||||||
|
struct DpThreadMembersUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::thread_members_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::ThreadMembersUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "ThreadMembersUpdate";
|
||||||
|
};
|
||||||
|
struct DpGuildScheduledEventCreateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_scheduled_event_create_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildScheduledEventCreate;
|
||||||
|
static inline constexpr std::string_view Name = "GuildScheduledEventCreate";
|
||||||
|
};
|
||||||
|
struct DpGuildScheduledEventUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_scheduled_event_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildScheduledEventUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "GuildScheduledEventUpdate";
|
||||||
|
};
|
||||||
|
struct DpGuildScheduledEventDeleteEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_scheduled_event_delete_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildScheduledEventDelete;
|
||||||
|
static inline constexpr std::string_view Name = "GuildScheduledEventDelete";
|
||||||
|
};
|
||||||
|
struct DpGuildScheduledEventUserAddEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_scheduled_event_user_add_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildScheduledEventUserAdd;
|
||||||
|
static inline constexpr std::string_view Name = "GuildScheduledEventUserAdd";
|
||||||
|
};
|
||||||
|
struct DpGuildScheduledEventUserRemoveEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::guild_scheduled_event_user_remove_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::GuildScheduledEventUserRemove;
|
||||||
|
static inline constexpr std::string_view Name = "GuildScheduledEventUserRemove";
|
||||||
|
};
|
||||||
|
struct DpVoiceBufferSendEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::voice_buffer_send_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::VoiceBufferSend;
|
||||||
|
static inline constexpr std::string_view Name = "VoiceBufferSend";
|
||||||
|
};
|
||||||
|
struct DpVoiceUserTalkingEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::voice_user_talking_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::VoiceUserTalking;
|
||||||
|
static inline constexpr std::string_view Name = "VoiceUserTalking";
|
||||||
|
};
|
||||||
|
struct DpVoiceReadyEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::voice_ready_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::VoiceReady;
|
||||||
|
static inline constexpr std::string_view Name = "VoiceReady";
|
||||||
|
};
|
||||||
|
struct DpVoiceReceiveEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::voice_receive_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::VoiceReceive;
|
||||||
|
static inline constexpr std::string_view Name = "VoiceReceive";
|
||||||
|
};
|
||||||
|
struct DpVoiceReceiveCombinedEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::voice_receive_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::VoiceReceiveCombined;
|
||||||
|
static inline constexpr std::string_view Name = "VoiceReceiveCombined";
|
||||||
|
};
|
||||||
|
struct DpVoiceTrackMarkerEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::voice_track_marker_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::VoiceTrackMarker;
|
||||||
|
static inline constexpr std::string_view Name = "VoiceTrackMarker";
|
||||||
|
};
|
||||||
|
struct DpStageInstanceCreateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::stage_instance_create_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::StageInstanceCreate;
|
||||||
|
static inline constexpr std::string_view Name = "StageInstanceCreate";
|
||||||
|
};
|
||||||
|
struct DpStageInstanceUpdateEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::stage_instance_update_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::StageInstanceUpdate;
|
||||||
|
static inline constexpr std::string_view Name = "StageInstanceUpdate";
|
||||||
|
};
|
||||||
|
struct DpStageInstanceDeleteEventInfo
|
||||||
|
{
|
||||||
|
using Type = dpp::stage_instance_delete_t;
|
||||||
|
static inline constexpr size_t ID = DpEventID::StageInstanceDelete;
|
||||||
|
static inline constexpr std::string_view Name = "StageInstanceDelete";
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Utility used to acquire event information at compile time.
|
||||||
|
*/
|
||||||
|
template < int > struct EventInfoID;
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Implementation.
|
||||||
|
*/
|
||||||
|
template < > struct EventInfoID< DpEventID::VoiceStateUpdate > : public DpVoiceStateUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::VoiceClientDisconnect > : public DpVoiceClientDisconnectEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::VoiceClientSpeaking > : public DpVoiceClientSpeakingEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::Log > : public DpLogEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildJoinRequestDelete > : public DpGuildJoinRequestDeleteEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::InteractionCreate > : public DpInteractionCreateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::SlashCommand > : public DpSlashCommandEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::ButtonClick > : public DpButtonClickEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::AutoComplete > : public DpAutoCompleteEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::SelectClick > : public DpSelectClickEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::MessageContextMenu > : public DpMessageContextMenuEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::UserContextMenu > : public DpUserContextMenuEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::FormSubmit > : public DpFormSubmitEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildDelete > : public DpGuildDeleteEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::ChannelDelete > : public DpChannelDeleteEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::ChannelUpdate > : public DpChannelUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::Ready > : public DpReadyEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::MessageDelete > : public DpMessageDeleteEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildMemberRemove > : public DpGuildMemberRemoveEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::Resumed > : public DpResumedEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildRoleCreate > : public DpGuildRoleCreateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::TypingStart > : public DpTypingStartEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::MessageReactionAdd > : public DpMessageReactionAddEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildMembersChunk > : public DpGuildMembersChunkEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::MessageReactionRemove > : public DpMessageReactionRemoveEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildCreate > : public DpGuildCreateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::ChannelCreate > : public DpChannelCreateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::MessageReactionRemoveEmoji > : public DpMessageReactionRemoveEmojiEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::MessageDeleteDulk > : public DpMessageDeleteDulkEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildRoleUpdate > : public DpGuildRoleUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildRoleDelete > : public DpGuildRoleDeleteEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::ChannelPinsUpdate > : public DpChannelPinsUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::MessageReactionRemoveAll > : public DpMessageReactionRemoveAllEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::VoiceServerUpdate > : public DpVoiceServerUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildEmojisUpdate > : public DpGuildEmojisUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildStickersUpdate > : public DpGuildStickersUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::PresenceUpdate > : public DpPresenceUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::WebhooksUpdate > : public DpWebhooksUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::AutomodRuleCreate > : public DpAutomodRuleCreateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::AutomodRuleUpdate > : public DpAutomodRuleUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::AutomodRuleDelete > : public DpAutomodRuleDeleteEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::AutomodRuleExecute > : public DpAutomodRuleExecuteEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildMemberAdd > : public DpGuildMemberAddEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::InviteDelete > : public DpInviteDeleteEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildUpdate > : public DpGuildUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildIntegrationsUpdate > : public DpGuildIntegrationsUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildMemberUpdate > : public DpGuildMemberUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::InviteCreate > : public DpInviteCreateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::MessageUpdate > : public DpMessageUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::UserUpdate > : public DpUserUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::MessageCreate > : public DpMessageCreateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildBanAdd > : public DpGuildBanAddEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildBanRemove > : public DpGuildBanRemoveEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::IntegrationCreate > : public DpIntegrationCreateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::IntegrationUpdate > : public DpIntegrationUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::IntegrationDelete > : public DpIntegrationDeleteEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::ThreadCreate > : public DpThreadCreateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::ThreadUpdate > : public DpThreadUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::ThreadDelete > : public DpThreadDeleteEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::ThreadListSync > : public DpThreadListSyncEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::ThreadMemberUpdate > : public DpThreadMemberUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::ThreadMembersUpdate > : public DpThreadMembersUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildScheduledEventCreate > : public DpGuildScheduledEventCreateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildScheduledEventUpdate > : public DpGuildScheduledEventUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildScheduledEventDelete > : public DpGuildScheduledEventDeleteEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildScheduledEventUserAdd > : public DpGuildScheduledEventUserAddEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::GuildScheduledEventUserRemove > : public DpGuildScheduledEventUserRemoveEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::VoiceBufferSend > : public DpVoiceBufferSendEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::VoiceUserTalking > : public DpVoiceUserTalkingEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::VoiceReady > : public DpVoiceReadyEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::VoiceReceive > : public DpVoiceReceiveEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::VoiceReceiveCombined > : public DpVoiceReceiveCombinedEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::VoiceTrackMarker > : public DpVoiceTrackMarkerEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::StageInstanceCreate > : public DpStageInstanceCreateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::StageInstanceUpdate > : public DpStageInstanceUpdateEventInfo { };
|
||||||
|
template < > struct EventInfoID< DpEventID::StageInstanceDelete > : public DpStageInstanceDeleteEventInfo { };
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
777
module/Library/Discord/Events.cpp
Normal file
777
module/Library/Discord/Events.cpp
Normal file
@ -0,0 +1,777 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Events.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpVoiceStateUpdateEvent, _SC("SqDiscordVoiceStateUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpVoiceClientDisconnectEvent, _SC("SqDiscordVoiceClientDisconnectEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpVoiceClientSpeakingEvent, _SC("SqDiscordVoiceClientSpeakingEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpLogEvent, _SC("SqDiscordLogEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildJoinRequestDeleteEvent, _SC("SqDiscordGuildJoinRequestDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpInteractionCreateEvent, _SC("SqDiscordInteractionCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpSlashCommandEvent, _SC("SqDiscordSlashCommandEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpButtonClickEvent, _SC("SqDiscordButtonClickEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpAutoCompleteEvent, _SC("SqDiscordAutoCompleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpSelectClickEvent, _SC("SqDiscordSelectClickEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpMessageContextMenuEvent, _SC("SqDiscordMessageContextMenuEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpUserContextMenuEvent, _SC("SqDiscordUserContextMenuEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpFormSubmitEvent, _SC("SqDiscordFormSubmitEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildDeleteEvent, _SC("SqDiscordGuildDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpChannelDeleteEvent, _SC("SqDiscordChannelDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpChannelUpdateEvent, _SC("SqDiscordChannelUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpReadyEvent, _SC("SqDiscordReadyEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpMessageDeleteEvent, _SC("SqDiscordMessageDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildMemberRemoveEvent, _SC("SqDiscordGuildMemberRemoveEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpResumedEvent, _SC("SqDiscordResumedEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildRoleCreateEvent, _SC("SqDiscordGuildRoleCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpTypingStartEvent, _SC("SqDiscordTypingStartEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpMessageReactionAddEvent, _SC("SqDiscordMessageReactionAddEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildMembersChunkEvent, _SC("SqDiscordGuildMembersChunkEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpMessageReactionRemoveEvent, _SC("SqDiscordMessageReactionRemoveEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildCreateEvent, _SC("SqDiscordGuildCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpChannelCreateEvent, _SC("SqDiscordChannelCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpMessageReactionRemoveEmojiEvent, _SC("SqDiscordMessageReactionRemoveEmojiEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpMessageDeleteDulkEvent, _SC("SqDiscordMessageDeleteDulkEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildRoleUpdateEvent, _SC("SqDiscordGuildRoleUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildRoleDeleteEvent, _SC("SqDiscordGuildRoleDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpChannelPinsUpdateEvent, _SC("SqDiscordChannelPinsUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpMessageReactionRemoveAllEvent, _SC("SqDiscordMessageReactionRemoveAllEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpVoiceServerUpdateEvent, _SC("SqDiscordVoiceServerUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildEmojisUpdateEvent, _SC("SqDiscordGuildEmojisUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildStickersUpdateEvent, _SC("SqDiscordGuildStickersUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpPresenceUpdateEvent, _SC("SqDiscordPresenceUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpWebhooksUpdateEvent, _SC("SqDiscordWebhooksUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpAutomodRuleCreateEvent, _SC("SqDiscordAutomodRuleCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpAutomodRuleUpdateEvent, _SC("SqDiscordAutomodRuleUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpAutomodRuleDeleteEvent, _SC("SqDiscordAutomodRuleDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpAutomodRuleExecuteEvent, _SC("SqDiscordAutomodRuleExecuteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildMemberAddEvent, _SC("SqDiscordGuildMemberAddEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpInviteDeleteEvent, _SC("SqDiscordInviteDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildUpdateEvent, _SC("SqDiscordGuildUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildIntegrationsUpdateEvent, _SC("SqDiscordGuildIntegrationsUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildMemberUpdateEvent, _SC("SqDiscordGuildMemberUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpInviteCreateEvent, _SC("SqDiscordInviteCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpMessageUpdateEvent, _SC("SqDiscordMessageUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpUserUpdateEvent, _SC("SqDiscordUserUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpMessageCreateEvent, _SC("SqDiscordMessageCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildBanAddEvent, _SC("SqDiscordGuildBanAddEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildBanRemoveEvent, _SC("SqDiscordGuildBanRemoveEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpIntegrationCreateEvent, _SC("SqDiscordIntegrationCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpIntegrationUpdateEvent, _SC("SqDiscordIntegrationUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpIntegrationDeleteEvent, _SC("SqDiscordIntegrationDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpThreadCreateEvent, _SC("SqDiscordThreadCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpThreadUpdateEvent, _SC("SqDiscordThreadUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpThreadDeleteEvent, _SC("SqDiscordThreadDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpThreadListSyncEvent, _SC("SqDiscordThreadListSyncEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpThreadMemberUpdateEvent, _SC("SqDiscordThreadMemberUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpThreadMembersUpdateEvent, _SC("SqDiscordThreadMembersUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildScheduledEventCreateEvent, _SC("SqDiscordGuildScheduledEventCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildScheduledEventUpdateEvent, _SC("SqDiscordGuildScheduledEventUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildScheduledEventDeleteEvent, _SC("SqDiscordGuildScheduledEventDeleteEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildScheduledEventUserAddEvent, _SC("SqDiscordGuildScheduledEventUserAddEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildScheduledEventUserRemoveEvent, _SC("SqDiscordGuildScheduledEventUserRemoveEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpVoiceBufferSendEvent, _SC("SqDiscordVoiceBufferSendEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpVoiceUserTalkingEvent, _SC("SqDiscordVoiceUserTalkingEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpVoiceReadyEvent, _SC("SqDiscordVoiceReadyEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpVoiceReceiveEvent, _SC("SqDiscordVoiceReceiveEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpVoiceReceiveCombinedEvent, _SC("SqDiscordVoiceReceiveCombinedEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpVoiceTrackMarkerEvent, _SC("SqDiscordVoiceTrackMarkerEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpStageInstanceCreateEvent, _SC("SqDiscordStageInstanceCreateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpStageInstanceUpdateEvent, _SC("SqDiscordStageInstanceUpdateEvent"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpStageInstanceDeleteEvent, _SC("SqDiscordStageInstanceDeleteEvent"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_Discord_Events(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceStateUpdate"),
|
||||||
|
Class< DpVoiceStateUpdateEvent, NoConstructor< DpVoiceStateUpdateEvent > >(vm, SqDpVoiceStateUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpVoiceStateUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceStateUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpVoiceStateUpdateEvent::GetRawEvent)
|
||||||
|
.Prop(_SC("State"), &DpVoiceStateUpdateEvent::GetState)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceClientDisconnect"),
|
||||||
|
Class< DpVoiceClientDisconnectEvent, NoConstructor< DpVoiceClientDisconnectEvent > >(vm, SqDpVoiceClientDisconnectEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpVoiceClientDisconnectEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceClientDisconnectEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpVoiceClientDisconnectEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceClientSpeaking"),
|
||||||
|
Class< DpVoiceClientSpeakingEvent, NoConstructor< DpVoiceClientSpeakingEvent > >(vm, SqDpVoiceClientSpeakingEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpVoiceClientSpeakingEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceClientSpeakingEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpVoiceClientSpeakingEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Log"),
|
||||||
|
Class< DpLogEvent, NoConstructor< DpLogEvent > >(vm, SqDpLogEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpLogEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpLogEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpLogEvent::GetRawEvent)
|
||||||
|
.Prop(_SC("Severity"), &DpLogEvent::GetSeverity)
|
||||||
|
.Prop(_SC("Message"), &DpLogEvent::GetMessage)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildJoinRequestDelete"),
|
||||||
|
Class< DpGuildJoinRequestDeleteEvent, NoConstructor< DpGuildJoinRequestDeleteEvent > >(vm, SqDpGuildJoinRequestDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildJoinRequestDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildJoinRequestDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildJoinRequestDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("InteractionCreate"),
|
||||||
|
Class< DpInteractionCreateEvent, NoConstructor< DpInteractionCreateEvent > >(vm, SqDpInteractionCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpInteractionCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpInteractionCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpInteractionCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("SlashCommand"),
|
||||||
|
Class< DpSlashCommandEvent, NoConstructor< DpSlashCommandEvent > >(vm, SqDpSlashCommandEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpSlashCommandEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpSlashCommandEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpSlashCommandEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ButtonClick"),
|
||||||
|
Class< DpButtonClickEvent, NoConstructor< DpButtonClickEvent > >(vm, SqDpButtonClickEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpButtonClickEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpButtonClickEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpButtonClickEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("AutoComplete"),
|
||||||
|
Class< DpAutoCompleteEvent, NoConstructor< DpAutoCompleteEvent > >(vm, SqDpAutoCompleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpAutoCompleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpAutoCompleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpAutoCompleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("SelectClick"),
|
||||||
|
Class< DpSelectClickEvent, NoConstructor< DpSelectClickEvent > >(vm, SqDpSelectClickEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpSelectClickEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpSelectClickEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpSelectClickEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageContextMenu"),
|
||||||
|
Class< DpMessageContextMenuEvent, NoConstructor< DpMessageContextMenuEvent > >(vm, SqDpMessageContextMenuEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpMessageContextMenuEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageContextMenuEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpMessageContextMenuEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("UserContextMenu"),
|
||||||
|
Class< DpUserContextMenuEvent, NoConstructor< DpUserContextMenuEvent > >(vm, SqDpUserContextMenuEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpUserContextMenuEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpUserContextMenuEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpUserContextMenuEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("FormSubmit"),
|
||||||
|
Class< DpFormSubmitEvent, NoConstructor< DpFormSubmitEvent > >(vm, SqDpFormSubmitEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpFormSubmitEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpFormSubmitEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpFormSubmitEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildDelete"),
|
||||||
|
Class< DpGuildDeleteEvent, NoConstructor< DpGuildDeleteEvent > >(vm, SqDpGuildDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ChannelDelete"),
|
||||||
|
Class< DpChannelDeleteEvent, NoConstructor< DpChannelDeleteEvent > >(vm, SqDpChannelDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpChannelDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpChannelDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpChannelDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ChannelUpdate"),
|
||||||
|
Class< DpChannelUpdateEvent, NoConstructor< DpChannelUpdateEvent > >(vm, SqDpChannelUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpChannelUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpChannelUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpChannelUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Ready"),
|
||||||
|
Class< DpReadyEvent, NoConstructor< DpReadyEvent > >(vm, SqDpReadyEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpReadyEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpReadyEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpReadyEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageDelete"),
|
||||||
|
Class< DpMessageDeleteEvent, NoConstructor< DpMessageDeleteEvent > >(vm, SqDpMessageDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpMessageDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpMessageDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildMemberRemove"),
|
||||||
|
Class< DpGuildMemberRemoveEvent, NoConstructor< DpGuildMemberRemoveEvent > >(vm, SqDpGuildMemberRemoveEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildMemberRemoveEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildMemberRemoveEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildMemberRemoveEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Resumed"),
|
||||||
|
Class< DpResumedEvent, NoConstructor< DpResumedEvent > >(vm, SqDpResumedEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpResumedEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpResumedEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpResumedEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildRoleCreate"),
|
||||||
|
Class< DpGuildRoleCreateEvent, NoConstructor< DpGuildRoleCreateEvent > >(vm, SqDpGuildRoleCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildRoleCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildRoleCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildRoleCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("TypingStart"),
|
||||||
|
Class< DpTypingStartEvent, NoConstructor< DpTypingStartEvent > >(vm, SqDpTypingStartEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpTypingStartEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpTypingStartEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpTypingStartEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageReactionAdd"),
|
||||||
|
Class< DpMessageReactionAddEvent, NoConstructor< DpMessageReactionAddEvent > >(vm, SqDpMessageReactionAddEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpMessageReactionAddEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageReactionAddEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpMessageReactionAddEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildMembersChunk"),
|
||||||
|
Class< DpGuildMembersChunkEvent, NoConstructor< DpGuildMembersChunkEvent > >(vm, SqDpGuildMembersChunkEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildMembersChunkEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildMembersChunkEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildMembersChunkEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageReactionRemove"),
|
||||||
|
Class< DpMessageReactionRemoveEvent, NoConstructor< DpMessageReactionRemoveEvent > >(vm, SqDpMessageReactionRemoveEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpMessageReactionRemoveEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageReactionRemoveEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpMessageReactionRemoveEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildCreate"),
|
||||||
|
Class< DpGuildCreateEvent, NoConstructor< DpGuildCreateEvent > >(vm, SqDpGuildCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ChannelCreate"),
|
||||||
|
Class< DpChannelCreateEvent, NoConstructor< DpChannelCreateEvent > >(vm, SqDpChannelCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpChannelCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpChannelCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpChannelCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageReactionRemoveEmoji"),
|
||||||
|
Class< DpMessageReactionRemoveEmojiEvent, NoConstructor< DpMessageReactionRemoveEmojiEvent > >(vm, SqDpMessageReactionRemoveEmojiEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpMessageReactionRemoveEmojiEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageReactionRemoveEmojiEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpMessageReactionRemoveEmojiEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageDeleteDulk"),
|
||||||
|
Class< DpMessageDeleteDulkEvent, NoConstructor< DpMessageDeleteDulkEvent > >(vm, SqDpMessageDeleteDulkEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpMessageDeleteDulkEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageDeleteDulkEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpMessageDeleteDulkEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildRoleUpdate"),
|
||||||
|
Class< DpGuildRoleUpdateEvent, NoConstructor< DpGuildRoleUpdateEvent > >(vm, SqDpGuildRoleUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildRoleUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildRoleUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildRoleUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildRoleDelete"),
|
||||||
|
Class< DpGuildRoleDeleteEvent, NoConstructor< DpGuildRoleDeleteEvent > >(vm, SqDpGuildRoleDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildRoleDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildRoleDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildRoleDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ChannelPinsUpdate"),
|
||||||
|
Class< DpChannelPinsUpdateEvent, NoConstructor< DpChannelPinsUpdateEvent > >(vm, SqDpChannelPinsUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpChannelPinsUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpChannelPinsUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpChannelPinsUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageReactionRemoveAll"),
|
||||||
|
Class< DpMessageReactionRemoveAllEvent, NoConstructor< DpMessageReactionRemoveAllEvent > >(vm, SqDpMessageReactionRemoveAllEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpMessageReactionRemoveAllEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageReactionRemoveAllEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpMessageReactionRemoveAllEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceServerUpdate"),
|
||||||
|
Class< DpVoiceServerUpdateEvent, NoConstructor< DpVoiceServerUpdateEvent > >(vm, SqDpVoiceServerUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpVoiceServerUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceServerUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpVoiceServerUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildEmojisUpdate"),
|
||||||
|
Class< DpGuildEmojisUpdateEvent, NoConstructor< DpGuildEmojisUpdateEvent > >(vm, SqDpGuildEmojisUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildEmojisUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildEmojisUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildEmojisUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildStickersUpdate"),
|
||||||
|
Class< DpGuildStickersUpdateEvent, NoConstructor< DpGuildStickersUpdateEvent > >(vm, SqDpGuildStickersUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildStickersUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildStickersUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildStickersUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("PresenceUpdate"),
|
||||||
|
Class< DpPresenceUpdateEvent, NoConstructor< DpPresenceUpdateEvent > >(vm, SqDpPresenceUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpPresenceUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpPresenceUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpPresenceUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("WebhooksUpdate"),
|
||||||
|
Class< DpWebhooksUpdateEvent, NoConstructor< DpWebhooksUpdateEvent > >(vm, SqDpWebhooksUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpWebhooksUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpWebhooksUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpWebhooksUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("AutomodRuleCreate"),
|
||||||
|
Class< DpAutomodRuleCreateEvent, NoConstructor< DpAutomodRuleCreateEvent > >(vm, SqDpAutomodRuleCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpAutomodRuleCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpAutomodRuleCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpAutomodRuleCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("AutomodRuleUpdate"),
|
||||||
|
Class< DpAutomodRuleUpdateEvent, NoConstructor< DpAutomodRuleUpdateEvent > >(vm, SqDpAutomodRuleUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpAutomodRuleUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpAutomodRuleUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpAutomodRuleUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("AutomodRuleDelete"),
|
||||||
|
Class< DpAutomodRuleDeleteEvent, NoConstructor< DpAutomodRuleDeleteEvent > >(vm, SqDpAutomodRuleDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpAutomodRuleDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpAutomodRuleDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpAutomodRuleDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("AutomodRuleExecute"),
|
||||||
|
Class< DpAutomodRuleExecuteEvent, NoConstructor< DpAutomodRuleExecuteEvent > >(vm, SqDpAutomodRuleExecuteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpAutomodRuleExecuteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpAutomodRuleExecuteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpAutomodRuleExecuteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildMemberAdd"),
|
||||||
|
Class< DpGuildMemberAddEvent, NoConstructor< DpGuildMemberAddEvent > >(vm, SqDpGuildMemberAddEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildMemberAddEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildMemberAddEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildMemberAddEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("InviteDelete"),
|
||||||
|
Class< DpInviteDeleteEvent, NoConstructor< DpInviteDeleteEvent > >(vm, SqDpInviteDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpInviteDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpInviteDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpInviteDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildUpdate"),
|
||||||
|
Class< DpGuildUpdateEvent, NoConstructor< DpGuildUpdateEvent > >(vm, SqDpGuildUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildIntegrationsUpdate"),
|
||||||
|
Class< DpGuildIntegrationsUpdateEvent, NoConstructor< DpGuildIntegrationsUpdateEvent > >(vm, SqDpGuildIntegrationsUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildIntegrationsUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildIntegrationsUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildIntegrationsUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildMemberUpdate"),
|
||||||
|
Class< DpGuildMemberUpdateEvent, NoConstructor< DpGuildMemberUpdateEvent > >(vm, SqDpGuildMemberUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildMemberUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildMemberUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildMemberUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("InviteCreate"),
|
||||||
|
Class< DpInviteCreateEvent, NoConstructor< DpInviteCreateEvent > >(vm, SqDpInviteCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpInviteCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpInviteCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpInviteCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageUpdate"),
|
||||||
|
Class< DpMessageUpdateEvent, NoConstructor< DpMessageUpdateEvent > >(vm, SqDpMessageUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpMessageUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpMessageUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("UserUpdate"),
|
||||||
|
Class< DpUserUpdateEvent, NoConstructor< DpUserUpdateEvent > >(vm, SqDpUserUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpUserUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpUserUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpUserUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("MessageCreate"),
|
||||||
|
Class< DpMessageCreateEvent, NoConstructor< DpMessageCreateEvent > >(vm, SqDpMessageCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpMessageCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpMessageCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpMessageCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildBanAdd"),
|
||||||
|
Class< DpGuildBanAddEvent, NoConstructor< DpGuildBanAddEvent > >(vm, SqDpGuildBanAddEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildBanAddEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildBanAddEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildBanAddEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildBanRemove"),
|
||||||
|
Class< DpGuildBanRemoveEvent, NoConstructor< DpGuildBanRemoveEvent > >(vm, SqDpGuildBanRemoveEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildBanRemoveEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildBanRemoveEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildBanRemoveEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("IntegrationCreate"),
|
||||||
|
Class< DpIntegrationCreateEvent, NoConstructor< DpIntegrationCreateEvent > >(vm, SqDpIntegrationCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpIntegrationCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpIntegrationCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpIntegrationCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("IntegrationUpdate"),
|
||||||
|
Class< DpIntegrationUpdateEvent, NoConstructor< DpIntegrationUpdateEvent > >(vm, SqDpIntegrationUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpIntegrationUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpIntegrationUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpIntegrationUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("IntegrationDelete"),
|
||||||
|
Class< DpIntegrationDeleteEvent, NoConstructor< DpIntegrationDeleteEvent > >(vm, SqDpIntegrationDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpIntegrationDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpIntegrationDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpIntegrationDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ThreadCreate"),
|
||||||
|
Class< DpThreadCreateEvent, NoConstructor< DpThreadCreateEvent > >(vm, SqDpThreadCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpThreadCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpThreadCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpThreadCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ThreadUpdate"),
|
||||||
|
Class< DpThreadUpdateEvent, NoConstructor< DpThreadUpdateEvent > >(vm, SqDpThreadUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpThreadUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpThreadUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpThreadUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ThreadDelete"),
|
||||||
|
Class< DpThreadDeleteEvent, NoConstructor< DpThreadDeleteEvent > >(vm, SqDpThreadDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpThreadDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpThreadDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpThreadDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ThreadListSync"),
|
||||||
|
Class< DpThreadListSyncEvent, NoConstructor< DpThreadListSyncEvent > >(vm, SqDpThreadListSyncEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpThreadListSyncEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpThreadListSyncEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpThreadListSyncEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ThreadMemberUpdate"),
|
||||||
|
Class< DpThreadMemberUpdateEvent, NoConstructor< DpThreadMemberUpdateEvent > >(vm, SqDpThreadMemberUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpThreadMemberUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpThreadMemberUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpThreadMemberUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ThreadMembersUpdate"),
|
||||||
|
Class< DpThreadMembersUpdateEvent, NoConstructor< DpThreadMembersUpdateEvent > >(vm, SqDpThreadMembersUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpThreadMembersUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpThreadMembersUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpThreadMembersUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildScheduledEventCreate"),
|
||||||
|
Class< DpGuildScheduledEventCreateEvent, NoConstructor< DpGuildScheduledEventCreateEvent > >(vm, SqDpGuildScheduledEventCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildScheduledEventCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildScheduledEventCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildScheduledEventCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildScheduledEventUpdate"),
|
||||||
|
Class< DpGuildScheduledEventUpdateEvent, NoConstructor< DpGuildScheduledEventUpdateEvent > >(vm, SqDpGuildScheduledEventUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildScheduledEventUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildScheduledEventUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildScheduledEventUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildScheduledEventDelete"),
|
||||||
|
Class< DpGuildScheduledEventDeleteEvent, NoConstructor< DpGuildScheduledEventDeleteEvent > >(vm, SqDpGuildScheduledEventDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildScheduledEventDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildScheduledEventDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildScheduledEventDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildScheduledEventUserAdd"),
|
||||||
|
Class< DpGuildScheduledEventUserAddEvent, NoConstructor< DpGuildScheduledEventUserAddEvent > >(vm, SqDpGuildScheduledEventUserAddEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildScheduledEventUserAddEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildScheduledEventUserAddEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildScheduledEventUserAddEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("GuildScheduledEventUserRemove"),
|
||||||
|
Class< DpGuildScheduledEventUserRemoveEvent, NoConstructor< DpGuildScheduledEventUserRemoveEvent > >(vm, SqDpGuildScheduledEventUserRemoveEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildScheduledEventUserRemoveEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpGuildScheduledEventUserRemoveEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpGuildScheduledEventUserRemoveEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceBufferSend"),
|
||||||
|
Class< DpVoiceBufferSendEvent, NoConstructor< DpVoiceBufferSendEvent > >(vm, SqDpVoiceBufferSendEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpVoiceBufferSendEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceBufferSendEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpVoiceBufferSendEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceUserTalking"),
|
||||||
|
Class< DpVoiceUserTalkingEvent, NoConstructor< DpVoiceUserTalkingEvent > >(vm, SqDpVoiceUserTalkingEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpVoiceUserTalkingEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceUserTalkingEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpVoiceUserTalkingEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceReady"),
|
||||||
|
Class< DpVoiceReadyEvent, NoConstructor< DpVoiceReadyEvent > >(vm, SqDpVoiceReadyEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpVoiceReadyEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceReadyEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpVoiceReadyEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceReceive"),
|
||||||
|
Class< DpVoiceReceiveEvent, NoConstructor< DpVoiceReceiveEvent > >(vm, SqDpVoiceReceiveEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpVoiceReceiveEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceReceiveEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpVoiceReceiveEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceReceive"),
|
||||||
|
Class< DpVoiceReceiveCombinedEvent, NoConstructor< DpVoiceReceiveCombinedEvent > >(vm, SqDpVoiceReceiveCombinedEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpVoiceReceiveCombinedEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceReceiveCombinedEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpVoiceReceiveCombinedEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceTrackMarker"),
|
||||||
|
Class< DpVoiceTrackMarkerEvent, NoConstructor< DpVoiceTrackMarkerEvent > >(vm, SqDpVoiceTrackMarkerEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpVoiceTrackMarkerEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpVoiceTrackMarkerEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpVoiceTrackMarkerEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("StageInstanceCreate"),
|
||||||
|
Class< DpStageInstanceCreateEvent, NoConstructor< DpStageInstanceCreateEvent > >(vm, SqDpStageInstanceCreateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpStageInstanceCreateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpStageInstanceCreateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpStageInstanceCreateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("StageInstanceUpdate"),
|
||||||
|
Class< DpStageInstanceUpdateEvent, NoConstructor< DpStageInstanceUpdateEvent > >(vm, SqDpStageInstanceUpdateEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpStageInstanceUpdateEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpStageInstanceUpdateEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpStageInstanceUpdateEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("StageInstanceDelete"),
|
||||||
|
Class< DpStageInstanceDeleteEvent, NoConstructor< DpStageInstanceDeleteEvent > >(vm, SqDpStageInstanceDeleteEvent::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpStageInstanceDeleteEvent::Fn)
|
||||||
|
.Func(_SC("_tostring"), &DpStageInstanceDeleteEvent::GetRawEvent)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Raw"), &DpStageInstanceDeleteEvent::GetRawEvent)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
2683
module/Library/Discord/Events.hpp
Normal file
2683
module/Library/Discord/Events.hpp
Normal file
File diff suppressed because it is too large
Load Diff
65
module/Library/Discord/Guild.cpp
Normal file
65
module/Library/Discord/Guild.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Guild.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuildMember, _SC("SqDiscordGuildMember"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpGuild, _SC("SqDiscordGuild"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_Discord_Guild(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
ns.Bind(_SC("GuildMember"),
|
||||||
|
Class< DpGuildMember, NoConstructor< DpGuildMember > >(vm, SqDpGuildMember::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuildMember::Fn)
|
||||||
|
.Func(_SC("_cmp"), &DpGuildMember::SqCmp)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpGuildMember::IsValid)
|
||||||
|
.Prop(_SC("JSON"), &DpGuildMember::BuildJSON)
|
||||||
|
.Prop(_SC("Nickname"), &DpGuildMember::GetNickname, &DpGuildMember::SetNickname)
|
||||||
|
.Prop(_SC("Roles"), &DpGuildMember::GetRoles)
|
||||||
|
.Prop(_SC("RolesCount"), &DpGuildMember::RolesCount)
|
||||||
|
.Prop(_SC("GuildID"), &DpGuildMember::GetGuildID, &DpGuildMember::SetGuildID)
|
||||||
|
.Prop(_SC("UserID"), &DpGuildMember::GetUserID, &DpGuildMember::SetUserID)
|
||||||
|
.Prop(_SC("Avatar"), &DpGuildMember::GetAvatar, &DpGuildMember::SetAvatar)
|
||||||
|
.Prop(_SC("CommunicationDisabledUntil"), &DpGuildMember::GetCommunicationDisabledUntil, &DpGuildMember::SetCommunicationDisabledUntil)
|
||||||
|
.Prop(_SC("JoinedAt"), &DpGuildMember::GetJoinedAt)
|
||||||
|
.Prop(_SC("PremiumSince"), &DpGuildMember::GetPremiumSince)
|
||||||
|
.Prop(_SC("Flags"), &DpGuildMember::GetFlags, &DpGuildMember::SetFlags)
|
||||||
|
.Prop(_SC("CommunicationDisabled"), &DpGuildMember::IsCommunicationDisabled)
|
||||||
|
.Prop(_SC("Deaf"), &DpGuildMember::GetDeaf, &DpGuildMember::SetDeaf)
|
||||||
|
.Prop(_SC("Muted"), &DpGuildMember::GetMuted, &DpGuildMember::SetMuted)
|
||||||
|
.Prop(_SC("IsPending"), &DpGuildMember::IsPending)
|
||||||
|
.Prop(_SC("HasAnimatedGuildAvatar"), &DpGuildMember::HasAnimatedGuildAvatar)
|
||||||
|
.Prop(_SC("Mention"), &DpGuildMember::GetMention)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("BuildJSON"), &DpGuildMember::BuildJSON_)
|
||||||
|
.Func(_SC("GetNickname"), &DpGuildMember::ApplyNickname)
|
||||||
|
.Func(_SC("AddRole"), &DpGuildMember::AddRole)
|
||||||
|
.Func(_SC("EachRole"), &DpGuildMember::EachRole)
|
||||||
|
.Func(_SC("ClearRoles"), &DpGuildMember::ClearRoles)
|
||||||
|
.Func(_SC("FilterRoles"), &DpGuildMember::FilterRoles)
|
||||||
|
.Func(_SC("GetFlags"), &DpGuildMember::ApplyFlags)
|
||||||
|
.Func(_SC("GetAvatarURL"), &DpGuildMember::GetAvatarURL)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Guild"),
|
||||||
|
Class< DpGuild, NoConstructor< DpGuild > >(vm, SqDpGuild::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpGuild::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpGuild::IsValid)
|
||||||
|
.Prop(_SC("JSON"), &DpGuild::BuildJSON)
|
||||||
|
.Prop(_SC("Name"), &DpGuild::GetName, &DpGuild::SetName)
|
||||||
|
.Prop(_SC("Description"), &DpGuild::GetDescription, &DpGuild::SetDescription)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("BuildJSON"), &DpGuild::BuildJSON_)
|
||||||
|
.Func(_SC("GetName"), &DpGuild::ApplyName)
|
||||||
|
.Func(_SC("GetDescription"), &DpGuild::ApplyDescription)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
421
module/Library/Discord/Guild.hpp
Normal file
421
module/Library/Discord/Guild.hpp
Normal file
@ -0,0 +1,421 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
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); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Build json representation of the object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON() const { return Valid().build_json(); }
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON_(bool with_id) const { return Valid().build_json(with_id); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if this member is equal to another member object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger SqCmp(const DpGuildMember & o) const
|
||||||
|
{
|
||||||
|
if (Valid() == o.Valid()) {
|
||||||
|
return 0;
|
||||||
|
// Nonsense...
|
||||||
|
} else if (Valid().user_id > o.Valid().user_id) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the nickname, or empty string if they don't have a nickname on this guild.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetNickname() const { return Valid().nickname; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the nickname.
|
||||||
|
*/
|
||||||
|
void SetNickname(StackStrF & name) const { Valid().set_nickname(name.ToStr()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the nickname.
|
||||||
|
*/
|
||||||
|
DpGuildMember & ApplyNickname(StackStrF & name) { SetNickname(name); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* 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 number of roles.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger RolesCount() const { return static_cast< SQInteger >(Valid().roles.size()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Add a new role.
|
||||||
|
*/
|
||||||
|
DpGuildMember & AddRole(dpp::snowflake role) { Valid().roles.push_back(role); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Iterate all roles.
|
||||||
|
*/
|
||||||
|
DpGuildMember & EachRole(Function & fn)
|
||||||
|
{
|
||||||
|
for (const auto & a : Valid().roles)
|
||||||
|
{
|
||||||
|
fn.Execute(a);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the number of roles.
|
||||||
|
*/
|
||||||
|
DpGuildMember & ClearRoles(dpp::snowflake role) { Valid().roles.clear(); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Filter roles.
|
||||||
|
*/
|
||||||
|
DpGuildMember & FilterRoles(Function & fn)
|
||||||
|
{
|
||||||
|
std::vector< dpp::snowflake > list;
|
||||||
|
// Reserve memory in advance
|
||||||
|
list.reserve(Valid().roles.size());
|
||||||
|
// Process each role individually
|
||||||
|
for (const auto & role : Valid().roles)
|
||||||
|
{
|
||||||
|
auto ret = fn.Eval(role);
|
||||||
|
// (null || true) == keep & false == skip
|
||||||
|
if (!ret.IsNull() || !ret.template Cast< bool >())
|
||||||
|
{
|
||||||
|
list.push_back(role); // Keep this role
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Use filtered roles
|
||||||
|
Valid().roles.swap(list);
|
||||||
|
// Allow chaining
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild id.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetGuildID() const { return Valid().guild_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the guild id.
|
||||||
|
*/
|
||||||
|
void SetGuildID(dpp::snowflake id) { Valid().guild_id = id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the user id.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetUserID() const { return Valid().user_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the guild id.
|
||||||
|
*/
|
||||||
|
void SetUserID(dpp::snowflake id) { Valid().guild_id = id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the user avatar (per-server avatar is a nitro only feature).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const dpp::utility::iconhash & GetAvatar() const { return Valid().avatar; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the user avatar (per-server avatar is a nitro only feature).
|
||||||
|
*/
|
||||||
|
void SetAvatar(const dpp::utility::iconhash & a) const { Valid().avatar = a; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the date and time when the time out will be removed; until then, they cannot interact with the guild.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetCommunicationDisabledUntil() const
|
||||||
|
{
|
||||||
|
return std::chrono::time_point_cast< std::chrono::seconds >(
|
||||||
|
std::chrono::system_clock::from_time_t(Valid().communication_disabled_until)
|
||||||
|
).time_since_epoch().count();
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Assign a timestamp until communication is disabled.
|
||||||
|
*/
|
||||||
|
void SetCommunicationDisabledUntil(SQInteger ts) const
|
||||||
|
{
|
||||||
|
Valid().set_communication_disabled_until(
|
||||||
|
std::chrono::system_clock::to_time_t(std::chrono::time_point< std::chrono::system_clock >(std::chrono::seconds(ts)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the date and time 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 is boosting.
|
||||||
|
*/
|
||||||
|
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 guild flags. Built from the bitmask defined by SqDiscordGuildMemberFlags.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetFlags() const { return static_cast< SQInteger >(Valid().flags); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the guild flags.
|
||||||
|
*/
|
||||||
|
void SetFlags(SQInteger f) const { Valid().flags = static_cast< uint8_t >(f); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the guild flags.
|
||||||
|
*/
|
||||||
|
DpGuildMember & ApplyFlags(SQInteger f) { SetFlags(f); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is in time-out (communication disabled).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsCommunicationDisabled() const { return Valid().is_communication_disabled(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is deafened.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool GetDeaf() const { return Valid().is_deaf(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is deafened.
|
||||||
|
*/
|
||||||
|
void SetDeaf(bool is_deafened) const { Valid().set_deaf(is_deafened); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is muted.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool GetMuted() const { return Valid().is_muted(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is muted.
|
||||||
|
*/
|
||||||
|
void SetMuted(bool is_muted) const { Valid().set_mute(is_muted); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the user is pending verification by membership screening.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsPending() const { return Valid().is_pending(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the the user's per-guild custom avatar is animated.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool HasAnimatedGuildAvatar() const { return Valid().has_animated_guild_avatar(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check whether the the user's per-guild custom avatar is animated.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string GetAvatarURL(SQInteger size, SQInteger format, bool animated) const
|
||||||
|
{ return Valid().get_avatar_url(static_cast< uint16_t >(size), static_cast< dpp::image_type >(format), animated); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve a ping/mention for the user by nickname.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string GetMention() const { return Valid().get_mention(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* 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); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Build json representation of the object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON() const { return Valid().build_json(); }
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON_(bool with_id) const { return Valid().build_json(with_id); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the guild name. Min length: 2, Max length: 100 (not including leading/trailing spaces)
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetName() const { return Valid().name; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the guild name. Min length: 2, Max length: 100 (not including leading/trailing spaces)
|
||||||
|
*/
|
||||||
|
void SetName(StackStrF & name) const { Valid().set_name(name.ToStr()); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the guild name. Min length: 2, Max length: 100 (not including leading/trailing spaces)
|
||||||
|
*/
|
||||||
|
DpGuild & ApplyName(StackStrF & name) { SetName(name); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the server description.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetDescription() const { return Valid().description; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the server description.
|
||||||
|
*/
|
||||||
|
void SetDescription(StackStrF & description) const { Valid().description = description.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the server description.
|
||||||
|
*/
|
||||||
|
DpGuild & ApplyDescription(StackStrF & description) { SetDescription(description); return *this; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
9
module/Library/Discord/Integration.cpp
Normal file
9
module/Library/Discord/Integration.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Integration.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
13
module/Library/Discord/Integration.hpp
Normal file
13
module/Library/Discord/Integration.hpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
9
module/Library/Discord/Message.cpp
Normal file
9
module/Library/Discord/Message.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Message.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
13
module/Library/Discord/Message.hpp
Normal file
13
module/Library/Discord/Message.hpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
117
module/Library/Discord/Misc.cpp
Normal file
117
module/Library/Discord/Misc.cpp
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Misc.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpCachePolicy, _SC("SqDiscordCachePolicy"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpUptime, _SC("SqDiscordUptime"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpIconHash, _SC("SqDiscordIconHash"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpVoiceState, _SC("SqDiscordVoiceState"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpEmoji, _SC("SqDiscordEmoji"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_Discord_Misc(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Uptime"),
|
||||||
|
Class< dpp::utility::uptime >(vm, SqDpUptime::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
.Ctor< double >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpUptime::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, SqDpIconHash::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
.Ctor< const std::string & >()
|
||||||
|
.Ctor< uint64_t, uint64_t >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpIconHash::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, SqDpCachePolicy::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
.Ctor< SQInteger >()
|
||||||
|
.Ctor< SQInteger, SQInteger >()
|
||||||
|
.Ctor< SQInteger, SQInteger, SQInteger >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpCachePolicy::Fn)
|
||||||
|
// Member Variables
|
||||||
|
.Var(_SC("UserPolicy"), &DpCachePolicy::mUserPolicy)
|
||||||
|
.Var(_SC("EmojiPolicy"), &DpCachePolicy::mEmojiPolicy)
|
||||||
|
.Var(_SC("RolePolicy"), &DpCachePolicy::mRolePolicy)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("VoiceState"),
|
||||||
|
Class< DpVoiceState, NoConstructor< DpVoiceState > >(vm, SqDpVoiceState::Str)
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpVoiceState::Fn)
|
||||||
|
// 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("RequestToSpeak"), &DpVoiceState::GetRequestToSpeak)
|
||||||
|
.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)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("BuildJSON"), &DpVoiceState::BuildJSON_)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Emoji"),
|
||||||
|
Class< DpEmoji, NoCopy< DpEmoji > >(vm, SqDpEmoji::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
.Ctor< StackStrF &, dpp::snowflake, SQInteger >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpEmoji::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpEmoji::IsValid)
|
||||||
|
.Prop(_SC("JSON"), &DpEmoji::BuildJSON)
|
||||||
|
.Prop(_SC("Name"), &DpEmoji::GetName, &DpEmoji::SetName)
|
||||||
|
.Prop(_SC("ImageData"), &DpEmoji::GetImageData)
|
||||||
|
.Prop(_SC("RequiresColons"), &DpEmoji::GetRequiresColons)
|
||||||
|
.Prop(_SC("IsManaged"), &DpEmoji::GetIsManaged)
|
||||||
|
.Prop(_SC("IsAnimated"), &DpEmoji::GetIsAnimated)
|
||||||
|
.Prop(_SC("IsAvailable"), &DpEmoji::GetIsAvailable)
|
||||||
|
.Prop(_SC("Format"), &DpEmoji::Format)
|
||||||
|
.Prop(_SC("Mention"), &DpEmoji::GetMention)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("SetName"), &DpEmoji::ApplyName)
|
||||||
|
.Func(_SC("GetMention"), &DpEmoji::GetMention_)
|
||||||
|
.Func(_SC("BuildJSON"), &DpEmoji::BuildJSON_)
|
||||||
|
.Func(_SC("LoadImage"), &DpEmoji::LoadImage)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
393
module/Library/Discord/Misc.hpp
Normal file
393
module/Library/Discord/Misc.hpp
Normal file
@ -0,0 +1,393 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Utilities.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
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)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* 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 channel id this user is connected to (may be empty).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetChannelID() const { return Valid().channel_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the user id this voice state is for.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetUserID() const { return Valid().user_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the session id for this voice state.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetSessionID() const { return Valid().session_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the voice state flags (see SqDiscordVoiceStateFlags).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetFlags() const { return Valid().flags; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the voice state flags (see SqDiscordVoiceStateFlags).
|
||||||
|
*/
|
||||||
|
void SetFlags(SQInteger flags) const { Valid().flags = flags; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the time at which the user requested to speak, or 0.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetRequestToSpeak() const {
|
||||||
|
return static_cast< SQInteger >(std::chrono::duration_cast< std::chrono::seconds >(
|
||||||
|
std::chrono::system_clock::from_time_t(Valid().request_to_speak).time_since_epoch()
|
||||||
|
).count());
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Build json representation of the object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON() const { return Valid().build_json(); }
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON_(bool with_id) const { return Valid().build_json(with_id); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if the user is deafened by the server.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsDeaf() const { return Valid().is_deaf(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if the user is muted by the server.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsMute() const { return Valid().is_mute(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if the user muted themselves.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsSelfMute() const { return Valid().is_self_mute(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if the user deafened themselves.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsSelfDeaf() const { return Valid().is_self_deaf(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if the user is streaming using "Go Live".
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool SelfStream() const { return Valid().self_stream(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if the user's camera is enabled.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool SelfVideo() const { return Valid().self_video(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Check if user is suppressed. "HELP HELP I'M BEING SUPPRESSED!"
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsSuppressed() const { return Valid().is_suppressed(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Represents the voice state of a user on a guild.
|
||||||
|
*/
|
||||||
|
struct DpEmoji
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::emoji >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced voice state instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Whether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpEmoji() noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpEmoji(Ptr::pointer ptr, bool owned = false) noexcept
|
||||||
|
: mPtr(ptr), mOwned(owned)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpEmoji(const Ptr::element_type & o) noexcept
|
||||||
|
: DpEmoji(new Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpEmoji(Ptr::element_type && o) noexcept
|
||||||
|
: DpEmoji(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpEmoji(StackStrF & name, dpp::snowflake id, SQInteger flags)
|
||||||
|
: DpEmoji(new Ptr::element_type(name.ToStr(), id, static_cast< uint8_t >(flags)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpEmoji(const DpEmoji & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpEmoji(DpEmoji && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpEmoji() noexcept { Cleanup(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpEmoji & operator = (const DpEmoji & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpEmoji & operator = (DpEmoji && 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 name of the emoji.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetName() const { return Valid().name; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the name of the emoji.
|
||||||
|
*/
|
||||||
|
void SetName(StackStrF & name) const { Valid().name = name.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the name of the emoji.
|
||||||
|
*/
|
||||||
|
DpEmoji & ApplyName(StackStrF & name) { SetName(name); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the user who uploaded the emoji.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetUserID() const { return Valid().user_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the user who uploaded the emoji.
|
||||||
|
*/
|
||||||
|
void SetUserID(dpp::snowflake id) const { Valid().user_id = id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the user who uploaded the emoji.
|
||||||
|
*/
|
||||||
|
DpEmoji & ApplyUserID(dpp::snowflake id) { SetUserID(id); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the flags for the emoji from SqDiscordEmojiFlags.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetFlags() const { return Valid().flags; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the flags for the emoji from SqDiscordEmojiFlags.
|
||||||
|
*/
|
||||||
|
void SetFlags(SQInteger flags) const { Valid().flags = static_cast< uint8_t >(flags); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the flags for the emoji from SqDiscordEmojiFlags.
|
||||||
|
*/
|
||||||
|
DpEmoji & ApplyFlags(SQInteger flags) { SetFlags(flags); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the image data for the emoji if uploading.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj GetImageData() const { return !Valid().image_data ? LightObj{} : LightObj(*Valid().image_data); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Create a mentionable emoji.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string GetMention_(StackStrF & name, dpp::snowflake id, bool is_animated = false) const
|
||||||
|
{ return Valid().get_mention(name.ToStr(), id, is_animated); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Build json representation of the object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON() const { return Valid().build_json(); }
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON_(bool with_id) const { return Valid().build_json(with_id); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve whether the Emoji requires colons.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool GetRequiresColons() const { return Valid().requires_colons(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve whether the Emoji is managed.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool GetIsManaged() const { return Valid().is_managed(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve whether the Emoji is animated.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool GetIsAnimated() const { return Valid().is_animated(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve whether the Emoji is available.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool GetIsAvailable() const { return Valid().is_available(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Load an image into the object as base64.
|
||||||
|
*/
|
||||||
|
DpEmoji & LoadImage(StackStrF & data, SQInteger type) { Valid().load_image(data.ToStr(), static_cast< dpp::image_type >(type)); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Format to name if unicode, name:id if has id or a:name:id if animated.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string Format() const { return Valid().format(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the mention/ping for the emoji.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string GetMention() const { return Valid().get_mention(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
143
module/Library/Discord/Presence.cpp
Normal file
143
module/Library/Discord/Presence.cpp
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Presence.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpActivityButton, _SC("SqDiscordActivityButton"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpActivityButtons, _SC("SqDiscordActivityButtons"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpActivityAssets, _SC("SqDiscordActivityAssets"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpActivitySecrets, _SC("SqDiscordActivitySecrets"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpActivity, _SC("SqDiscordActivity"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpActivities, _SC("SqDiscordActivities"))
|
||||||
|
SQMOD_DECL_TYPENAME(SqDpPresence, _SC("SqDiscordPresence"))
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
void Register_Discord_Presence(HSQUIRRELVM vm, Table & ns)
|
||||||
|
{
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ActivityButton"),
|
||||||
|
Class< DpActivityButton, NoCopy< DpActivityButton > >(vm, SqDpActivityButton::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpActivityButton::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpActivityButton::IsValid)
|
||||||
|
.Prop(_SC("Label"), &DpActivityButton::GetLabel, &DpActivityButton::SetLabel)
|
||||||
|
.Prop(_SC("URL"), &DpActivityButton::GetURL, &DpActivityButton::SetURL)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("SetLabel"), &DpActivityButton::ApplyLabel)
|
||||||
|
.Func(_SC("SetURL"), &DpActivityButton::ApplyURL)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
Register_Discord_VectorProxy< dpp::activity_button, DpActivityButton, SqDpActivityButton >(vm, ns, _SC("ActivityButtons"));
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ActivityAssets"),
|
||||||
|
Class< DpActivityAssets, NoCopy< DpActivityAssets > >(vm, SqDpActivityAssets::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpActivityAssets::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpActivityAssets::IsValid)
|
||||||
|
.Prop(_SC("LargeImage"), &DpActivityAssets::GetLargeImage, &DpActivityAssets::SetLargeImage)
|
||||||
|
.Prop(_SC("LargeText"), &DpActivityAssets::GetLargeText, &DpActivityAssets::SetLargeText)
|
||||||
|
.Prop(_SC("SmallImage"), &DpActivityAssets::GetSmallImage, &DpActivityAssets::SetSmallImage)
|
||||||
|
.Prop(_SC("SmallText"), &DpActivityAssets::GetSmallText, &DpActivityAssets::SetSmallText)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("SetLargeImage"), &DpActivityAssets::ApplyLargeImage)
|
||||||
|
.Func(_SC("SetLargeText"), &DpActivityAssets::ApplyLargeText)
|
||||||
|
.Func(_SC("SetSmallImage"), &DpActivityAssets::ApplySmallImage)
|
||||||
|
.Func(_SC("SetSmallText"), &DpActivityAssets::ApplySmallText)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("ActivitySecrets"),
|
||||||
|
Class< DpActivitySecrets, NoCopy< DpActivitySecrets > >(vm, SqDpActivitySecrets::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpActivitySecrets::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpActivitySecrets::IsValid)
|
||||||
|
.Prop(_SC("Join"), &DpActivitySecrets::GetJoin, &DpActivitySecrets::SetJoin)
|
||||||
|
.Prop(_SC("Spectate"), &DpActivitySecrets::GetSpectate, &DpActivitySecrets::SetSpectate)
|
||||||
|
.Prop(_SC("Match"), &DpActivitySecrets::GetMatch, &DpActivitySecrets::SetMatch)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("SetJoin"), &DpActivitySecrets::ApplyJoin)
|
||||||
|
.Func(_SC("SetSpectate"), &DpActivitySecrets::ApplySpectate)
|
||||||
|
.Func(_SC("SetMatch"), &DpActivitySecrets::ApplyMatch)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Activity"),
|
||||||
|
Class< DpActivity, NoCopy< DpActivity > >(vm, SqDpActivity::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
.Ctor< SQInteger, StackStrF &, StackStrF &, StackStrF & >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpActivity::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpActivity::IsValid)
|
||||||
|
.Prop(_SC("Name"), &DpActivity::GetName, &DpActivity::SetName)
|
||||||
|
.Prop(_SC("State"), &DpActivity::GetState, &DpActivity::SetState)
|
||||||
|
.Prop(_SC("Details"), &DpActivity::GetDetails, &DpActivity::SetDetails)
|
||||||
|
.Prop(_SC("Assets"), &DpActivity::GetAssets)
|
||||||
|
.Prop(_SC("Buttons"), &DpActivity::GetButtons)
|
||||||
|
.Prop(_SC("Emoji"), &DpActivity::GetEmoji)
|
||||||
|
.Prop(_SC("PartyID"), &DpActivity::GetPartyID)
|
||||||
|
.Prop(_SC("CurrentPartySize"), &DpActivity::GetCurrentPartySize)
|
||||||
|
.Prop(_SC("MaxPartySize"), &DpActivity::GetMaxPartySize)
|
||||||
|
.Prop(_SC("Secrets"), &DpActivity::GetSecrets)
|
||||||
|
.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)
|
||||||
|
.Prop(_SC("ApplicationID"), &DpActivity::GetApplicationID)
|
||||||
|
.Prop(_SC("Flags"), &DpActivity::GetFlags, &DpActivity::SetFlags)
|
||||||
|
.Prop(_SC("Instance"), &DpActivity::IsInstance)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("SetName"), &DpActivity::ApplyName)
|
||||||
|
.Func(_SC("SetState"), &DpActivity::ApplyState)
|
||||||
|
.Func(_SC("SetDetails"), &DpActivity::ApplyDetails)
|
||||||
|
.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)
|
||||||
|
.Func(_SC("SetFlags"), &DpActivity::ApplyFlags)
|
||||||
|
.Func(_SC("GetLargeAssetURL"), &DpActivity::GetLargeAssetURL)
|
||||||
|
.Func(_SC("GetSmallAssetURL"), &DpActivity::GetSmallAssetURL)
|
||||||
|
);
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
Register_Discord_VectorProxy< dpp::activity, DpActivity, SqDpActivities >(vm, ns, _SC("Activities"));
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
ns.Bind(_SC("Presence"),
|
||||||
|
Class< DpPresence, NoCopy< DpPresence > >(vm, SqDpPresence::Str)
|
||||||
|
// Constructors
|
||||||
|
.Ctor()
|
||||||
|
.Ctor< SQInteger, DpActivity & >()
|
||||||
|
.Ctor< SQInteger, SQInteger, StackStrF & >()
|
||||||
|
// Meta-methods
|
||||||
|
.SquirrelFunc(_SC("_typename"), &SqDpPresence::Fn)
|
||||||
|
// Member Properties
|
||||||
|
.Prop(_SC("Valid"), &DpPresence::IsValid)
|
||||||
|
.Prop(_SC("JSON"), &DpPresence::BuildJSON)
|
||||||
|
.Prop(_SC("UserID"), &DpPresence::GetUserID, &DpPresence::SetUserID)
|
||||||
|
.Prop(_SC("GuildID"), &DpPresence::GetGuildID, &DpPresence::SetGuildID)
|
||||||
|
.Prop(_SC("Flags"), &DpPresence::GetFlags, &DpPresence::SetFlags)
|
||||||
|
.Prop(_SC("Activities"), &DpPresence::GetActivities)
|
||||||
|
.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("BuildJSON"), &DpVoiceState::BuildJSON_)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
928
module/Library/Discord/Presence.hpp
Normal file
928
module/Library/Discord/Presence.hpp
Normal file
@ -0,0 +1,928 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Misc.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* An activity button is a custom button shown in the rich presence. Can be to join a game or whatever.
|
||||||
|
*/
|
||||||
|
struct DpActivityButton
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::activity_button >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced activity instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Whether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpActivityButton() noexcept
|
||||||
|
: DpActivityButton(new Ptr::element_type(), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpActivityButton(Ptr::pointer ptr, bool owned = false) noexcept
|
||||||
|
: mPtr(ptr), mOwned(owned)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
explicit DpActivityButton(const Ptr::element_type & o) noexcept
|
||||||
|
: DpActivityButton(new Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpActivityButton(Ptr::element_type && o) noexcept
|
||||||
|
: DpActivityButton(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpActivityButton(const DpActivityButton & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpActivityButton(DpActivityButton && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpActivityButton() noexcept { Cleanup(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpActivityButton & operator = (const DpActivityButton & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpActivityButton & operator = (DpActivityButton && 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 button 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 text shown on the button (1-32 characters).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetLabel() const { return Valid().label; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the text shown on the button (1-32 characters).
|
||||||
|
*/
|
||||||
|
void SetLabel(StackStrF & label) const { Valid().label = label.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the text shown on the button (1-32 characters).
|
||||||
|
*/
|
||||||
|
DpActivityButton & ApplyLabel(StackStrF & label) { SetLabel(label); return *this; }
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the url opened when clicking the button (1-512 characters). It's may be empty.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetURL() const { return Valid().url; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the url opened when clicking the button (1-512 characters).
|
||||||
|
*/
|
||||||
|
void SetURL(StackStrF & url) const { Valid().url = url.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the url opened when clicking the button (1-512 characters).
|
||||||
|
*/
|
||||||
|
DpActivityButton & ApplyURL(StackStrF & url) { SetURL(url); return *this; }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* An activity asset are the images and the hover text displayed in the rich presence.
|
||||||
|
*/
|
||||||
|
struct DpActivityAssets
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::activity_assets >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced activity instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Whether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpActivityAssets() noexcept
|
||||||
|
: DpActivityAssets(new Ptr::element_type(), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpActivityAssets(Ptr::pointer ptr, bool owned = false) noexcept
|
||||||
|
: mPtr(ptr), mOwned(owned)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
explicit DpActivityAssets(const Ptr::element_type & o) noexcept
|
||||||
|
: DpActivityAssets(new Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpActivityAssets(Ptr::element_type && o) noexcept
|
||||||
|
: DpActivityAssets(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpActivityAssets(const DpActivityAssets & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpActivityAssets(DpActivityAssets && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpActivityAssets() noexcept { Cleanup(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpActivityAssets & operator = (const DpActivityAssets & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpActivityAssets & operator = (DpActivityAssets && 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 assets 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 large asset image which usually contain snowflake ID or prefixed image ID.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetLargeImage() const { return Valid().large_image; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the large asset image.
|
||||||
|
*/
|
||||||
|
void SetLargeImage(StackStrF & large_image) const { Valid().large_image = large_image.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the large asset image.
|
||||||
|
*/
|
||||||
|
DpActivityAssets & ApplyLargeImage(StackStrF & large_image) { SetLargeImage(large_image); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the text displayed when hovering over the large image of the activity.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetLargeText() const { return Valid().large_text; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the text displayed when hovering over the large image of the activity.
|
||||||
|
*/
|
||||||
|
void SetLargeText(StackStrF & large_text) const { Valid().large_text = large_text.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the text displayed when hovering over the large image of the activity.
|
||||||
|
*/
|
||||||
|
DpActivityAssets & ApplyLargeText(StackStrF & large_text) { SetLargeText(large_text); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the small asset image which usually contain snowflake ID or prefixed image ID.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetSmallImage() const { return Valid().small_image; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the small asset image.
|
||||||
|
*/
|
||||||
|
void SetSmallImage(StackStrF & small_image) const { Valid().small_image = small_image.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the small asset image.
|
||||||
|
*/
|
||||||
|
DpActivityAssets & ApplySmallImage(StackStrF & small_image) { SetSmallImage(small_image); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the text displayed when hovering over the small image of the activity.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetSmallText() const { return Valid().small_text; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the text displayed when hovering over the small image of the activity.
|
||||||
|
*/
|
||||||
|
void SetSmallText(StackStrF & small_text) const { Valid().small_text = small_text.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the text displayed when hovering over the small image of the activity.
|
||||||
|
*/
|
||||||
|
DpActivityAssets & ApplySmallText(StackStrF & small_text) { SetSmallText(small_text); return *this; }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Secrets for Rich Presence joining and spectating.
|
||||||
|
*/
|
||||||
|
struct DpActivitySecrets
|
||||||
|
{
|
||||||
|
using Ptr = std::unique_ptr< dpp::activity_secrets >;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Referenced activity instance.
|
||||||
|
*/
|
||||||
|
Ptr mPtr{nullptr};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Whether the referenced pointer is owned.
|
||||||
|
*/
|
||||||
|
bool mOwned{false};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
DpActivitySecrets() noexcept
|
||||||
|
: DpActivitySecrets(new Ptr::element_type(), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
explicit DpActivitySecrets(Ptr::pointer ptr, bool owned = false) noexcept
|
||||||
|
: mPtr(ptr), mOwned(owned)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor.
|
||||||
|
*/
|
||||||
|
explicit DpActivitySecrets(const Ptr::element_type & o) noexcept
|
||||||
|
: DpActivitySecrets(new Ptr::element_type(o), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
explicit DpActivitySecrets(Ptr::element_type && o) noexcept
|
||||||
|
: DpActivitySecrets(new Ptr::element_type(std::forward< Ptr::element_type >(o)), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy constructor (disabled).
|
||||||
|
*/
|
||||||
|
DpActivitySecrets(const DpActivitySecrets & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move constructor.
|
||||||
|
*/
|
||||||
|
DpActivitySecrets(DpActivitySecrets && o) noexcept = default;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Destructor.
|
||||||
|
*/
|
||||||
|
~DpActivitySecrets() noexcept { Cleanup(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Copy assignment operator (disabled).
|
||||||
|
*/
|
||||||
|
DpActivitySecrets & operator = (const DpActivitySecrets & o) = delete;
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Move assignment operator.
|
||||||
|
*/
|
||||||
|
DpActivitySecrets & operator = (DpActivitySecrets && 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 secrets 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 secret for joining a party.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetJoin() const { return Valid().join; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the secret for joining a party.
|
||||||
|
*/
|
||||||
|
void SetJoin(StackStrF & join) const { Valid().join = join.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the secret for joining a party.
|
||||||
|
*/
|
||||||
|
DpActivitySecrets & ApplyJoin(StackStrF & join) { SetJoin(join); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the secret for spectating a game.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetSpectate() const { return Valid().spectate; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the secret for spectating a game.
|
||||||
|
*/
|
||||||
|
void SetSpectate(StackStrF & spectate) const { Valid().spectate = spectate.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the secret for spectating a game.
|
||||||
|
*/
|
||||||
|
DpActivitySecrets & ApplySpectate(StackStrF & spectate) { SetSpectate(spectate); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the secret for a specific instanced match.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetMatch() const { return Valid().match; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the secret for a specific instanced match.
|
||||||
|
*/
|
||||||
|
void SetMatch(StackStrF & match) const { Valid().match = match.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the secret for a specific instanced match.
|
||||||
|
*/
|
||||||
|
DpActivitySecrets & ApplyMatch(StackStrF & match) { SetMatch(match); return *this; }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* 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};
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
using Buttons = DpVectorProxy< dpp::activity_button, DpActivityButton >;
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
LightObj mSqAssets{};
|
||||||
|
LightObj mSqButtons{};
|
||||||
|
LightObj mSqEmoji{};
|
||||||
|
LightObj mSqSecrets{};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* 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()
|
||||||
|
{
|
||||||
|
// Cleanup activity assets, if any
|
||||||
|
if (!mSqAssets.IsNull())
|
||||||
|
{
|
||||||
|
mSqAssets.CastI< DpActivityAssets >()->Cleanup();
|
||||||
|
// Release script resources
|
||||||
|
mSqAssets.Release();
|
||||||
|
}
|
||||||
|
// Cleanup activity buttons, if any
|
||||||
|
if (!mSqButtons.IsNull())
|
||||||
|
{
|
||||||
|
mSqButtons.CastI< Buttons >()->Cleanup();
|
||||||
|
// Release script resources
|
||||||
|
mSqButtons.Release();
|
||||||
|
}
|
||||||
|
// Cleanup activity emoji, if any
|
||||||
|
if (!mSqEmoji.IsNull())
|
||||||
|
{
|
||||||
|
mSqEmoji.CastI< DpEmoji >()->Cleanup();
|
||||||
|
// Release script resources
|
||||||
|
mSqEmoji.Release();
|
||||||
|
}
|
||||||
|
// Cleanup activity secrets, if any
|
||||||
|
if (!mSqSecrets.IsNull())
|
||||||
|
{
|
||||||
|
mSqSecrets.CastI< DpActivitySecrets >()->Cleanup();
|
||||||
|
// Release script resources
|
||||||
|
mSqSecrets.Release();
|
||||||
|
}
|
||||||
|
// 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. e.g. "Vice City"
|
||||||
|
*/
|
||||||
|
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. e.g. "Waiting in lobby"
|
||||||
|
*/
|
||||||
|
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 details of the activity. What the player is currently doing.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD const std::string & GetDetails() const { return Valid().details; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the details of the activity.
|
||||||
|
*/
|
||||||
|
void SetDetails(StackStrF & details) const { Valid().details = details.ToStr(); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the details of the activity.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyDetails(StackStrF & details) { SetDetails(details); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the images for the presence and their hover texts.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj & GetAssets()
|
||||||
|
{
|
||||||
|
if (mSqAssets.IsNull())
|
||||||
|
{
|
||||||
|
mSqAssets = LightObj{SqTypeIdentity< DpActivityAssets >{}, SqVM(), &Valid().assets, false};
|
||||||
|
}
|
||||||
|
// Return the associated script object
|
||||||
|
return mSqAssets;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the url of the activity. Only applicable for certain sites such a YouTube.
|
||||||
|
*/
|
||||||
|
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 custom buttons shown in the Rich Presence (max 2).
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj & GetButtons()
|
||||||
|
{
|
||||||
|
if (mSqButtons.IsNull())
|
||||||
|
{
|
||||||
|
mSqButtons = LightObj{SqTypeIdentity< Buttons >{}, SqVM(), &Valid().buttons, false};
|
||||||
|
}
|
||||||
|
// Return the associated script object
|
||||||
|
return mSqButtons;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the emoji used for the custom status.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj & GetEmoji()
|
||||||
|
{
|
||||||
|
if (mSqEmoji.IsNull())
|
||||||
|
{
|
||||||
|
mSqEmoji = LightObj{SqTypeIdentity< DpEmoji >{}, SqVM(), &Valid().emoji, false};
|
||||||
|
}
|
||||||
|
// Return the associated script object
|
||||||
|
return mSqEmoji;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the ID of the party.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetPartyID() const { return Valid().party.id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the party's current size. Used to show the party's current size.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetCurrentPartySize() const { return Valid().party.current_size; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the party's maximum size. Used to show the party's maximum size.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetMaxPartySize() const { return Valid().party.maximum_size; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the secrets for rich presence joining and spectating.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj & GetSecrets()
|
||||||
|
{
|
||||||
|
if (mSqSecrets.IsNull())
|
||||||
|
{
|
||||||
|
mSqSecrets = LightObj{SqTypeIdentity< DpActivitySecrets >{}, SqVM(), &Valid().secrets, false};
|
||||||
|
}
|
||||||
|
// Return the associated script object
|
||||||
|
return mSqSecrets;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the type for the activity from SqDiscordActivityType.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetType() const { return Valid().type; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the type for the activity from SqDiscordActivityType.
|
||||||
|
*/
|
||||||
|
void SetType(SQInteger type) const { Valid().type = static_cast< dpp::activity_type >(type); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the type for the activity from SqDiscordActivityType.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyType(SQInteger type) { SetType(type); 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; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the creating application (e.g. a linked account on the user's client)
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD dpp::snowflake GetApplicationID() const { return Valid().application_id; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the flags for the activity from SqDiscordActivityFlags.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD SQInteger GetFlags() const { return Valid().flags; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the flags for the activity from SqDiscordActivityFlags.
|
||||||
|
*/
|
||||||
|
void SetFlags(SQInteger flags) const { Valid().flags = static_cast< uint8_t >(flags); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the flags for the activity from SqDiscordActivityFlags.
|
||||||
|
*/
|
||||||
|
DpActivity & ApplyFlags(SQInteger flags) { SetFlags(flags); return *this; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve whether or not the activity is an instanced game session.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD bool IsInstance() const { return Valid().is_instance; }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Get the assets large image url if they have one, otherwise returns an empty string.
|
||||||
|
* In case of prefixed image IDs (mp:{image_id}) it returns an empty string.
|
||||||
|
* See: https://discord.com/developers/docs/topics/gateway-events#activity-object-activity-asset-image
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string GetLargeAssetURL(SQInteger size, SQInteger format) const
|
||||||
|
{ return Valid().get_large_asset_url(static_cast< uint16_t >(size), static_cast< dpp::image_type >(format)); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Get the assets small image url if they have one, otherwise returns an empty string.
|
||||||
|
* In case of prefixed image IDs (mp:{image_id}) it returns an empty string.
|
||||||
|
* See: https://discord.com/developers/docs/topics/gateway-events#activity-object-activity-asset-image
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string GetSmallAssetURL(SQInteger size, SQInteger format) const
|
||||||
|
{ return Valid().get_small_asset_url(static_cast< uint16_t >(size), static_cast< dpp::image_type >(format)); }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* 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};
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
using Activities = DpVectorProxy< dpp::activity, DpActivity >;
|
||||||
|
// --------------------------------------------------------------------------------------------
|
||||||
|
LightObj mSqActivities{};
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* 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)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpPresence(SQInteger status, DpActivity & activity)
|
||||||
|
: DpPresence(new Ptr::element_type(static_cast< dpp::presence_status >(status), activity.Valid()), true)
|
||||||
|
{ }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Explicit constructor.
|
||||||
|
*/
|
||||||
|
DpPresence(SQInteger status, SQInteger type, StackStrF & description)
|
||||||
|
: DpPresence(new Ptr::element_type(static_cast< dpp::presence_status >(status), static_cast< dpp::activity_type >(status), description.ToStr()), 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()
|
||||||
|
{
|
||||||
|
// Cleanup presence activities, if any
|
||||||
|
if (!mSqActivities.IsNull())
|
||||||
|
{
|
||||||
|
mSqActivities.CastI< Activities >()->Cleanup();
|
||||||
|
// Release script resources
|
||||||
|
mSqActivities.Release();
|
||||||
|
}
|
||||||
|
// 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 list of activities.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD LightObj & GetActivities()
|
||||||
|
{
|
||||||
|
if (mSqActivities.IsNull())
|
||||||
|
{
|
||||||
|
mSqActivities = LightObj{SqTypeIdentity< Activities >{}, SqVM(), &Valid().activities, false};
|
||||||
|
}
|
||||||
|
// Return the associated script object
|
||||||
|
return mSqActivities;
|
||||||
|
}
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Build JSON string from this object.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON() const { return Valid().build_json(); }
|
||||||
|
SQMOD_NODISCARD std::string BuildJSON_(bool with_id) const { return Valid().build_json(with_id); }
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* 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()); }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
9
module/Library/Discord/Role.cpp
Normal file
9
module/Library/Discord/Role.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Role.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
13
module/Library/Discord/Role.hpp
Normal file
13
module/Library/Discord/Role.hpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
9
module/Library/Discord/User.cpp
Normal file
9
module/Library/Discord/User.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/User.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
13
module/Library/Discord/User.hpp
Normal file
13
module/Library/Discord/User.hpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
9
module/Library/Discord/Utilities.cpp
Normal file
9
module/Library/Discord/Utilities.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Library/Discord/Utilities.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
462
module/Library/Discord/Utilities.hpp
Normal file
462
module/Library/Discord/Utilities.hpp
Normal file
@ -0,0 +1,462 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace Sqrat {
|
||||||
|
|
||||||
|
// Allow the VM to treat the dpp::snowflake type as a integer.
|
||||||
|
template<> struct Var<dpp::snowflake>
|
||||||
|
{
|
||||||
|
dpp::snowflake value;
|
||||||
|
Var(HSQUIRRELVM vm, SQInteger idx)
|
||||||
|
{
|
||||||
|
sq_getinteger(vm, idx, reinterpret_cast<SQInteger*>(&static_cast<uint64_t&>(value)));
|
||||||
|
}
|
||||||
|
inline static void push(HSQUIRRELVM vm, const dpp::snowflake& value) noexcept
|
||||||
|
{
|
||||||
|
sq_pushinteger(vm, static_cast<SQInteger>(static_cast<uint64_t>(value)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Allow the VM to treat the dpp::snowflake type as a integer.
|
||||||
|
template<> struct Var<const dpp::snowflake&>
|
||||||
|
{
|
||||||
|
dpp::snowflake value;
|
||||||
|
Var(HSQUIRRELVM vm, SQInteger idx)
|
||||||
|
{
|
||||||
|
sq_getinteger(vm, idx, reinterpret_cast<SQInteger*>(&static_cast<uint64_t&>(value)));
|
||||||
|
}
|
||||||
|
inline static void push(HSQUIRRELVM vm, const dpp::snowflake& value) noexcept
|
||||||
|
{
|
||||||
|
sq_pushinteger(vm, static_cast<SQInteger>(static_cast<uint64_t>(value)));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
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_Discord_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
|
@ -13,9 +13,9 @@ SQMOD_DECL_TYPENAME(SqRxMatchesTypename, _SC("SqRxMatches"))
|
|||||||
SQMOD_DECL_TYPENAME(SqRxInstanceTypename, _SC("SqRxInstance"))
|
SQMOD_DECL_TYPENAME(SqRxInstanceTypename, _SC("SqRxInstance"))
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool RxInstance::STUDY = true;
|
// bool RxInstance::STUDY = true;
|
||||||
int RxInstance::OPTIONS = 0;
|
// int RxInstance::OPTIONS = 0;
|
||||||
int RxInstance::STUDY_OPTIONS = 0;
|
// int RxInstance::STUDY_OPTIONS = 0;
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_RegEx(HSQUIRRELVM vm)
|
void Register_RegEx(HSQUIRRELVM vm)
|
||||||
@ -61,131 +61,131 @@ void Register_RegEx(HSQUIRRELVM vm)
|
|||||||
.Func(_SC("WhileRange"), &RxMatches::WhileRange)
|
.Func(_SC("WhileRange"), &RxMatches::WhileRange)
|
||||||
.Func(_SC("SubStr"), &RxMatches::SubStr)
|
.Func(_SC("SubStr"), &RxMatches::SubStr)
|
||||||
);
|
);
|
||||||
RootTable(vm).Bind(_SC("SqRx"),
|
// RootTable(vm).Bind(_SC("SqRx"),
|
||||||
Class< RxInstance, NoCopy< RxInstance > >(vm, SqRxInstanceTypename::Str)
|
// Class< RxInstance, NoCopy< RxInstance > >(vm, SqRxInstanceTypename::Str)
|
||||||
// Constructors
|
// // Constructors
|
||||||
.Ctor()
|
// .Ctor()
|
||||||
.Ctor< StackStrF & >()
|
// .Ctor< StackStrF & >()
|
||||||
.Ctor< int, StackStrF & >()
|
// .Ctor< int, StackStrF & >()
|
||||||
.Ctor< int, bool, StackStrF & >()
|
// .Ctor< int, bool, StackStrF & >()
|
||||||
// Meta-methods
|
// // Meta-methods
|
||||||
.SquirrelFunc(_SC("_typename"), &SqRxInstanceTypename::Fn)
|
// .SquirrelFunc(_SC("_typename"), &SqRxInstanceTypename::Fn)
|
||||||
//.Func(_SC("_tostring"), &CPlayer::ToString)
|
// //.Func(_SC("_tostring"), &CPlayer::ToString)
|
||||||
// Static Values
|
// // Static Values
|
||||||
.SetStaticValue(_SC("STUDY"), RxInstance::STUDY)
|
// .SetStaticValue(_SC("STUDY"), RxInstance::STUDY)
|
||||||
.SetStaticValue(_SC("OPTIONS"), RxInstance::OPTIONS)
|
// .SetStaticValue(_SC("OPTIONS"), RxInstance::OPTIONS)
|
||||||
.SetStaticValue(_SC("STUDY_OPTIONS"), RxInstance::STUDY_OPTIONS)
|
// .SetStaticValue(_SC("STUDY_OPTIONS"), RxInstance::STUDY_OPTIONS)
|
||||||
// Properties
|
// // Properties
|
||||||
.Prop(_SC("Valid"), &RxInstance::IsValid)
|
// .Prop(_SC("Valid"), &RxInstance::IsValid)
|
||||||
.Prop(_SC("Studied"), &RxInstance::IsStudied)
|
// .Prop(_SC("Studied"), &RxInstance::IsStudied)
|
||||||
// Member Methods
|
// // Member Methods
|
||||||
.FmtFunc(_SC("CompileF"), &RxInstance::Compile1)
|
// .FmtFunc(_SC("CompileF"), &RxInstance::Compile1)
|
||||||
.FmtFunc(_SC("CompileExF"), &RxInstance::Compile2)
|
// .FmtFunc(_SC("CompileExF"), &RxInstance::Compile2)
|
||||||
.FmtFunc(_SC("TryCompileF"), &RxInstance::TryCompile1)
|
// .FmtFunc(_SC("TryCompileF"), &RxInstance::TryCompile1)
|
||||||
.FmtFunc(_SC("TryCompileExF"), &RxInstance::TryCompile2)
|
// .FmtFunc(_SC("TryCompileExF"), &RxInstance::TryCompile2)
|
||||||
.FmtFunc(_SC("MatchFirst"), &RxInstance::MatchFirst)
|
// .FmtFunc(_SC("MatchFirst"), &RxInstance::MatchFirst)
|
||||||
.FmtFunc(_SC("MatchFirstEx"), &RxInstance::MatchFirst_)
|
// .FmtFunc(_SC("MatchFirstEx"), &RxInstance::MatchFirst_)
|
||||||
.FmtFunc(_SC("MatchFirstFrom"), &RxInstance::MatchFirstFrom)
|
// .FmtFunc(_SC("MatchFirstFrom"), &RxInstance::MatchFirstFrom)
|
||||||
.FmtFunc(_SC("MatchFirstFromEx"), &RxInstance::MatchFirstFrom_)
|
// .FmtFunc(_SC("MatchFirstFromEx"), &RxInstance::MatchFirstFrom_)
|
||||||
.FmtFunc(_SC("Match"), &RxInstance::Match)
|
// .FmtFunc(_SC("Match"), &RxInstance::Match)
|
||||||
.FmtFunc(_SC("MatchEx"), &RxInstance::Match_)
|
// .FmtFunc(_SC("MatchEx"), &RxInstance::Match_)
|
||||||
.FmtFunc(_SC("MatchFrom"), &RxInstance::MatchFrom)
|
// .FmtFunc(_SC("MatchFrom"), &RxInstance::MatchFrom)
|
||||||
.FmtFunc(_SC("MatchFromEx"), &RxInstance::MatchFrom_)
|
// .FmtFunc(_SC("MatchFromEx"), &RxInstance::MatchFrom_)
|
||||||
.FmtFunc(_SC("Matches"), &RxInstance::Matches)
|
// .FmtFunc(_SC("Matches"), &RxInstance::Matches)
|
||||||
.FmtFunc(_SC("MatchesEx"), &RxInstance::Matches_)
|
// .FmtFunc(_SC("MatchesEx"), &RxInstance::Matches_)
|
||||||
.FmtFunc(_SC("MatchesEx2"), &RxInstance::MatchesEx)
|
// .FmtFunc(_SC("MatchesEx2"), &RxInstance::MatchesEx)
|
||||||
// Member Overloads
|
// // Member Overloads
|
||||||
.Overload(_SC("Compile"), &RxInstance::Compile1)
|
// .Overload(_SC("Compile"), &RxInstance::Compile1)
|
||||||
.Overload(_SC("Compile"), &RxInstance::Compile2)
|
// .Overload(_SC("Compile"), &RxInstance::Compile2)
|
||||||
.Overload(_SC("TryCompile"), &RxInstance::TryCompile1)
|
// .Overload(_SC("TryCompile"), &RxInstance::TryCompile1)
|
||||||
.Overload(_SC("TryCompile"), &RxInstance::TryCompile2)
|
// .Overload(_SC("TryCompile"), &RxInstance::TryCompile2)
|
||||||
.Overload(_SC("Study"), &RxInstance::Study0)
|
// .Overload(_SC("Study"), &RxInstance::Study0)
|
||||||
.Overload(_SC("Study"), &RxInstance::Study1)
|
// .Overload(_SC("Study"), &RxInstance::Study1)
|
||||||
);
|
// );
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
ConstTable(vm).Enum(_SC("SqRxOption"), Enumeration(vm)
|
// ConstTable(vm).Enum(_SC("SqRxOption"), Enumeration(vm)
|
||||||
.Const(_SC("Caseless"), static_cast< SQInteger >(PCRE_CASELESS))
|
// .Const(_SC("Caseless"), static_cast< SQInteger >(PCRE_CASELESS))
|
||||||
.Const(_SC("Multiline"), static_cast< SQInteger >(PCRE_MULTILINE))
|
// .Const(_SC("Multiline"), static_cast< SQInteger >(PCRE_MULTILINE))
|
||||||
.Const(_SC("Dotall"), static_cast< SQInteger >(PCRE_DOTALL))
|
// .Const(_SC("Dotall"), static_cast< SQInteger >(PCRE_DOTALL))
|
||||||
.Const(_SC("Extended"), static_cast< SQInteger >(PCRE_EXTENDED))
|
// .Const(_SC("Extended"), static_cast< SQInteger >(PCRE_EXTENDED))
|
||||||
.Const(_SC("Anchored"), static_cast< SQInteger >(PCRE_ANCHORED))
|
// .Const(_SC("Anchored"), static_cast< SQInteger >(PCRE_ANCHORED))
|
||||||
.Const(_SC("DollarEndOnly"), static_cast< SQInteger >(PCRE_DOLLAR_ENDONLY))
|
// .Const(_SC("DollarEndOnly"), static_cast< SQInteger >(PCRE_DOLLAR_ENDONLY))
|
||||||
.Const(_SC("Extra"), static_cast< SQInteger >(PCRE_EXTRA))
|
// .Const(_SC("Extra"), static_cast< SQInteger >(PCRE_EXTRA))
|
||||||
.Const(_SC("NotBOL"), static_cast< SQInteger >(PCRE_NOTBOL))
|
// .Const(_SC("NotBOL"), static_cast< SQInteger >(PCRE_NOTBOL))
|
||||||
.Const(_SC("NotEOL"), static_cast< SQInteger >(PCRE_NOTEOL))
|
// .Const(_SC("NotEOL"), static_cast< SQInteger >(PCRE_NOTEOL))
|
||||||
.Const(_SC("UnGreedy"), static_cast< SQInteger >(PCRE_UNGREEDY))
|
// .Const(_SC("UnGreedy"), static_cast< SQInteger >(PCRE_UNGREEDY))
|
||||||
.Const(_SC("NotEmpty"), static_cast< SQInteger >(PCRE_NOTEMPTY))
|
// .Const(_SC("NotEmpty"), static_cast< SQInteger >(PCRE_NOTEMPTY))
|
||||||
.Const(_SC("UTF8"), static_cast< SQInteger >(PCRE_UTF8))
|
// .Const(_SC("UTF8"), static_cast< SQInteger >(PCRE_UTF8))
|
||||||
.Const(_SC("UTF16"), static_cast< SQInteger >(PCRE_UTF16))
|
// .Const(_SC("UTF16"), static_cast< SQInteger >(PCRE_UTF16))
|
||||||
.Const(_SC("UTF32"), static_cast< SQInteger >(PCRE_UTF32))
|
// .Const(_SC("UTF32"), static_cast< SQInteger >(PCRE_UTF32))
|
||||||
.Const(_SC("NoAutoCapture"), static_cast< SQInteger >(PCRE_NO_AUTO_CAPTURE))
|
// .Const(_SC("NoAutoCapture"), static_cast< SQInteger >(PCRE_NO_AUTO_CAPTURE))
|
||||||
.Const(_SC("NoUTF8Check"), static_cast< SQInteger >(PCRE_NO_UTF8_CHECK))
|
// .Const(_SC("NoUTF8Check"), static_cast< SQInteger >(PCRE_NO_UTF8_CHECK))
|
||||||
.Const(_SC("NoUTF16Check"), static_cast< SQInteger >(PCRE_NO_UTF16_CHECK))
|
// .Const(_SC("NoUTF16Check"), static_cast< SQInteger >(PCRE_NO_UTF16_CHECK))
|
||||||
.Const(_SC("NoUTF32Check"), static_cast< SQInteger >(PCRE_NO_UTF32_CHECK))
|
// .Const(_SC("NoUTF32Check"), static_cast< SQInteger >(PCRE_NO_UTF32_CHECK))
|
||||||
.Const(_SC("AutoCallout"), static_cast< SQInteger >(PCRE_AUTO_CALLOUT))
|
// .Const(_SC("AutoCallout"), static_cast< SQInteger >(PCRE_AUTO_CALLOUT))
|
||||||
.Const(_SC("PartialSoft"), static_cast< SQInteger >(PCRE_PARTIAL_SOFT))
|
// .Const(_SC("PartialSoft"), static_cast< SQInteger >(PCRE_PARTIAL_SOFT))
|
||||||
.Const(_SC("Partial"), static_cast< SQInteger >(PCRE_PARTIAL))
|
// .Const(_SC("Partial"), static_cast< SQInteger >(PCRE_PARTIAL))
|
||||||
.Const(_SC("NeverUTF"), static_cast< SQInteger >(PCRE_NEVER_UTF))
|
// .Const(_SC("NeverUTF"), static_cast< SQInteger >(PCRE_NEVER_UTF))
|
||||||
.Const(_SC("DfaShortest"), static_cast< SQInteger >(PCRE_DFA_SHORTEST))
|
// .Const(_SC("DfaShortest"), static_cast< SQInteger >(PCRE_DFA_SHORTEST))
|
||||||
.Const(_SC("NoAutoPossess"), static_cast< SQInteger >(PCRE_NO_AUTO_POSSESS))
|
// .Const(_SC("NoAutoPossess"), static_cast< SQInteger >(PCRE_NO_AUTO_POSSESS))
|
||||||
.Const(_SC("DfaRestart"), static_cast< SQInteger >(PCRE_DFA_RESTART))
|
// .Const(_SC("DfaRestart"), static_cast< SQInteger >(PCRE_DFA_RESTART))
|
||||||
.Const(_SC("FirstLine"), static_cast< SQInteger >(PCRE_FIRSTLINE))
|
// .Const(_SC("FirstLine"), static_cast< SQInteger >(PCRE_FIRSTLINE))
|
||||||
.Const(_SC("DupNames"), static_cast< SQInteger >(PCRE_DUPNAMES))
|
// .Const(_SC("DupNames"), static_cast< SQInteger >(PCRE_DUPNAMES))
|
||||||
.Const(_SC("NewLineCR"), static_cast< SQInteger >(PCRE_NEWLINE_CR))
|
// .Const(_SC("NewLineCR"), static_cast< SQInteger >(PCRE_NEWLINE_CR))
|
||||||
.Const(_SC("NewLineLF"), static_cast< SQInteger >(PCRE_NEWLINE_LF))
|
// .Const(_SC("NewLineLF"), static_cast< SQInteger >(PCRE_NEWLINE_LF))
|
||||||
.Const(_SC("NewLineCRLF"), static_cast< SQInteger >(PCRE_NEWLINE_CRLF))
|
// .Const(_SC("NewLineCRLF"), static_cast< SQInteger >(PCRE_NEWLINE_CRLF))
|
||||||
.Const(_SC("NewLineAny"), static_cast< SQInteger >(PCRE_NEWLINE_ANY))
|
// .Const(_SC("NewLineAny"), static_cast< SQInteger >(PCRE_NEWLINE_ANY))
|
||||||
.Const(_SC("NewLineAnyCRLF"), static_cast< SQInteger >(PCRE_NEWLINE_ANYCRLF))
|
// .Const(_SC("NewLineAnyCRLF"), static_cast< SQInteger >(PCRE_NEWLINE_ANYCRLF))
|
||||||
.Const(_SC("BsrAnyCRLF"), static_cast< SQInteger >(PCRE_BSR_ANYCRLF))
|
// .Const(_SC("BsrAnyCRLF"), static_cast< SQInteger >(PCRE_BSR_ANYCRLF))
|
||||||
.Const(_SC("BsrUnicode"), static_cast< SQInteger >(PCRE_BSR_UNICODE))
|
// .Const(_SC("BsrUnicode"), static_cast< SQInteger >(PCRE_BSR_UNICODE))
|
||||||
.Const(_SC("JavaScriptCompat"), static_cast< SQInteger >(PCRE_JAVASCRIPT_COMPAT))
|
// .Const(_SC("JavaScriptCompat"), static_cast< SQInteger >(PCRE_JAVASCRIPT_COMPAT))
|
||||||
.Const(_SC("NoStartOptimize"), static_cast< SQInteger >(PCRE_NO_START_OPTIMIZE))
|
// .Const(_SC("NoStartOptimize"), static_cast< SQInteger >(PCRE_NO_START_OPTIMIZE))
|
||||||
.Const(_SC("NoStartOptimise"), static_cast< SQInteger >(PCRE_NO_START_OPTIMISE))
|
// .Const(_SC("NoStartOptimise"), static_cast< SQInteger >(PCRE_NO_START_OPTIMISE))
|
||||||
.Const(_SC("PartialHard"), static_cast< SQInteger >(PCRE_PARTIAL_HARD))
|
// .Const(_SC("PartialHard"), static_cast< SQInteger >(PCRE_PARTIAL_HARD))
|
||||||
.Const(_SC("NotEmptyAtStart"), static_cast< SQInteger >(PCRE_NOTEMPTY_ATSTART))
|
// .Const(_SC("NotEmptyAtStart"), static_cast< SQInteger >(PCRE_NOTEMPTY_ATSTART))
|
||||||
.Const(_SC("UCP"), static_cast< SQInteger >(PCRE_UCP))
|
// .Const(_SC("UCP"), static_cast< SQInteger >(PCRE_UCP))
|
||||||
);
|
// );
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
ConstTable(vm).Enum(_SC("SqRxError"), Enumeration(vm)
|
// ConstTable(vm).Enum(_SC("SqRxError"), Enumeration(vm)
|
||||||
.Const(_SC("NoMatch"), static_cast< SQInteger >(PCRE_ERROR_NOMATCH))
|
// .Const(_SC("NoMatch"), static_cast< SQInteger >(PCRE_ERROR_NOMATCH))
|
||||||
.Const(_SC("Null"), static_cast< SQInteger >(PCRE_ERROR_NULL))
|
// .Const(_SC("Null"), static_cast< SQInteger >(PCRE_ERROR_NULL))
|
||||||
.Const(_SC("BadOption"), static_cast< SQInteger >(PCRE_ERROR_BADOPTION))
|
// .Const(_SC("BadOption"), static_cast< SQInteger >(PCRE_ERROR_BADOPTION))
|
||||||
.Const(_SC("BadMagic"), static_cast< SQInteger >(PCRE_ERROR_BADMAGIC))
|
// .Const(_SC("BadMagic"), static_cast< SQInteger >(PCRE_ERROR_BADMAGIC))
|
||||||
.Const(_SC("UnknownOpCode"), static_cast< SQInteger >(PCRE_ERROR_UNKNOWN_OPCODE))
|
// .Const(_SC("UnknownOpCode"), static_cast< SQInteger >(PCRE_ERROR_UNKNOWN_OPCODE))
|
||||||
.Const(_SC("UnknownNode"), static_cast< SQInteger >(PCRE_ERROR_UNKNOWN_NODE))
|
// .Const(_SC("UnknownNode"), static_cast< SQInteger >(PCRE_ERROR_UNKNOWN_NODE))
|
||||||
.Const(_SC("NoMemory"), static_cast< SQInteger >(PCRE_ERROR_NOMEMORY))
|
// .Const(_SC("NoMemory"), static_cast< SQInteger >(PCRE_ERROR_NOMEMORY))
|
||||||
.Const(_SC("NoSubstring"), static_cast< SQInteger >(PCRE_ERROR_NOSUBSTRING))
|
// .Const(_SC("NoSubstring"), static_cast< SQInteger >(PCRE_ERROR_NOSUBSTRING))
|
||||||
.Const(_SC("MatchLimit"), static_cast< SQInteger >(PCRE_ERROR_MATCHLIMIT))
|
// .Const(_SC("MatchLimit"), static_cast< SQInteger >(PCRE_ERROR_MATCHLIMIT))
|
||||||
.Const(_SC("Callout"), static_cast< SQInteger >(PCRE_ERROR_CALLOUT))
|
// .Const(_SC("Callout"), static_cast< SQInteger >(PCRE_ERROR_CALLOUT))
|
||||||
.Const(_SC("BadUTF8"), static_cast< SQInteger >(PCRE_ERROR_BADUTF8))
|
// .Const(_SC("BadUTF8"), static_cast< SQInteger >(PCRE_ERROR_BADUTF8))
|
||||||
.Const(_SC("BadUTF16"), static_cast< SQInteger >(PCRE_ERROR_BADUTF16))
|
// .Const(_SC("BadUTF16"), static_cast< SQInteger >(PCRE_ERROR_BADUTF16))
|
||||||
.Const(_SC("BadUTF32"), static_cast< SQInteger >(PCRE_ERROR_BADUTF32))
|
// .Const(_SC("BadUTF32"), static_cast< SQInteger >(PCRE_ERROR_BADUTF32))
|
||||||
.Const(_SC("BadUTF8Offset"), static_cast< SQInteger >(PCRE_ERROR_BADUTF8_OFFSET))
|
// .Const(_SC("BadUTF8Offset"), static_cast< SQInteger >(PCRE_ERROR_BADUTF8_OFFSET))
|
||||||
.Const(_SC("BadUTF16Offset"), static_cast< SQInteger >(PCRE_ERROR_BADUTF16_OFFSET))
|
// .Const(_SC("BadUTF16Offset"), static_cast< SQInteger >(PCRE_ERROR_BADUTF16_OFFSET))
|
||||||
.Const(_SC("Partial"), static_cast< SQInteger >(PCRE_ERROR_PARTIAL))
|
// .Const(_SC("Partial"), static_cast< SQInteger >(PCRE_ERROR_PARTIAL))
|
||||||
.Const(_SC("BadPartial"), static_cast< SQInteger >(PCRE_ERROR_BADPARTIAL))
|
// .Const(_SC("BadPartial"), static_cast< SQInteger >(PCRE_ERROR_BADPARTIAL))
|
||||||
.Const(_SC("Internal"), static_cast< SQInteger >(PCRE_ERROR_INTERNAL))
|
// .Const(_SC("Internal"), static_cast< SQInteger >(PCRE_ERROR_INTERNAL))
|
||||||
.Const(_SC("BadCount"), static_cast< SQInteger >(PCRE_ERROR_BADCOUNT))
|
// .Const(_SC("BadCount"), static_cast< SQInteger >(PCRE_ERROR_BADCOUNT))
|
||||||
.Const(_SC("DfaUitem"), static_cast< SQInteger >(PCRE_ERROR_DFA_UITEM))
|
// .Const(_SC("DfaUitem"), static_cast< SQInteger >(PCRE_ERROR_DFA_UITEM))
|
||||||
.Const(_SC("DfaUcond"), static_cast< SQInteger >(PCRE_ERROR_DFA_UCOND))
|
// .Const(_SC("DfaUcond"), static_cast< SQInteger >(PCRE_ERROR_DFA_UCOND))
|
||||||
.Const(_SC("DfaUmLimit"), static_cast< SQInteger >(PCRE_ERROR_DFA_UMLIMIT))
|
// .Const(_SC("DfaUmLimit"), static_cast< SQInteger >(PCRE_ERROR_DFA_UMLIMIT))
|
||||||
.Const(_SC("DfaWsSize"), static_cast< SQInteger >(PCRE_ERROR_DFA_WSSIZE))
|
// .Const(_SC("DfaWsSize"), static_cast< SQInteger >(PCRE_ERROR_DFA_WSSIZE))
|
||||||
.Const(_SC("DfaRecurse"), static_cast< SQInteger >(PCRE_ERROR_DFA_RECURSE))
|
// .Const(_SC("DfaRecurse"), static_cast< SQInteger >(PCRE_ERROR_DFA_RECURSE))
|
||||||
.Const(_SC("RecursionLimit"), static_cast< SQInteger >(PCRE_ERROR_RECURSIONLIMIT))
|
// .Const(_SC("RecursionLimit"), static_cast< SQInteger >(PCRE_ERROR_RECURSIONLIMIT))
|
||||||
.Const(_SC("NullWsLimit"), static_cast< SQInteger >(PCRE_ERROR_NULLWSLIMIT))
|
// .Const(_SC("NullWsLimit"), static_cast< SQInteger >(PCRE_ERROR_NULLWSLIMIT))
|
||||||
.Const(_SC("BadNewLine"), static_cast< SQInteger >(PCRE_ERROR_BADNEWLINE))
|
// .Const(_SC("BadNewLine"), static_cast< SQInteger >(PCRE_ERROR_BADNEWLINE))
|
||||||
.Const(_SC("BadOffset"), static_cast< SQInteger >(PCRE_ERROR_BADOFFSET))
|
// .Const(_SC("BadOffset"), static_cast< SQInteger >(PCRE_ERROR_BADOFFSET))
|
||||||
.Const(_SC("ShortUTF8"), static_cast< SQInteger >(PCRE_ERROR_SHORTUTF8))
|
// .Const(_SC("ShortUTF8"), static_cast< SQInteger >(PCRE_ERROR_SHORTUTF8))
|
||||||
.Const(_SC("ShortUTF16"), static_cast< SQInteger >(PCRE_ERROR_SHORTUTF16))
|
// .Const(_SC("ShortUTF16"), static_cast< SQInteger >(PCRE_ERROR_SHORTUTF16))
|
||||||
.Const(_SC("RecurseLoop"), static_cast< SQInteger >(PCRE_ERROR_RECURSELOOP))
|
// .Const(_SC("RecurseLoop"), static_cast< SQInteger >(PCRE_ERROR_RECURSELOOP))
|
||||||
.Const(_SC("JitStackLimit"), static_cast< SQInteger >(PCRE_ERROR_JIT_STACKLIMIT))
|
// .Const(_SC("JitStackLimit"), static_cast< SQInteger >(PCRE_ERROR_JIT_STACKLIMIT))
|
||||||
.Const(_SC("BadMode"), static_cast< SQInteger >(PCRE_ERROR_BADMODE))
|
// .Const(_SC("BadMode"), static_cast< SQInteger >(PCRE_ERROR_BADMODE))
|
||||||
.Const(_SC("BadEndianness"), static_cast< SQInteger >(PCRE_ERROR_BADENDIANNESS))
|
// .Const(_SC("BadEndianness"), static_cast< SQInteger >(PCRE_ERROR_BADENDIANNESS))
|
||||||
.Const(_SC("DfaBadRestart"), static_cast< SQInteger >(PCRE_ERROR_DFA_BADRESTART))
|
// .Const(_SC("DfaBadRestart"), static_cast< SQInteger >(PCRE_ERROR_DFA_BADRESTART))
|
||||||
.Const(_SC("JitBadOption"), static_cast< SQInteger >(PCRE_ERROR_JIT_BADOPTION))
|
// .Const(_SC("JitBadOption"), static_cast< SQInteger >(PCRE_ERROR_JIT_BADOPTION))
|
||||||
.Const(_SC("BadLength"), static_cast< SQInteger >(PCRE_ERROR_BADLENGTH))
|
// .Const(_SC("BadLength"), static_cast< SQInteger >(PCRE_ERROR_BADLENGTH))
|
||||||
.Const(_SC("Unset"), static_cast< SQInteger >(PCRE_ERROR_UNSET))
|
// .Const(_SC("Unset"), static_cast< SQInteger >(PCRE_ERROR_UNSET))
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#ifdef POCO_UNBUNDLED
|
#ifdef POCO_UNBUNDLED
|
||||||
#include <pcre.h>
|
#include <pcre.h>
|
||||||
#else
|
#else
|
||||||
#include "pcre_config.h"
|
#include "pcre2_config.h"
|
||||||
#include "pcre.h"
|
#include "pcre2.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -31,6 +31,7 @@ struct RxMatch
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
SQInteger mLength{0};
|
SQInteger mLength{0};
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
@ -386,500 +387,499 @@ struct RxMatches
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
// /* ------------------------------------------------------------------------------------------------
|
||||||
*
|
// *
|
||||||
*/
|
// */
|
||||||
struct RxInstance
|
// struct RxInstance
|
||||||
{
|
// {
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Whether to analyze and optimize the pattern by default for evey new instance (true).
|
// * Whether to analyze and optimize the pattern by default for evey new instance (true).
|
||||||
*/
|
// */
|
||||||
static bool STUDY;
|
// static bool STUDY;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Default options for every new instance (0).
|
// * Default options for every new instance (0).
|
||||||
*/
|
// */
|
||||||
static int OPTIONS;
|
// static int OPTIONS;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Default study options for every new instance (0).
|
// * Default study options for every new instance (0).
|
||||||
*/
|
// */
|
||||||
static int STUDY_OPTIONS;
|
// static int STUDY_OPTIONS;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Default offset vector size (must be multiple of 3).
|
// * Default offset vector size (must be multiple of 3).
|
||||||
*/
|
// */
|
||||||
static constexpr int OVEC_SIZE = 63;
|
// static constexpr int OVEC_SIZE = 63;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Internal vector type used for offsets buffer.
|
// * Internal vector type used for offsets buffer.
|
||||||
*/
|
// */
|
||||||
using OVEC_t = std::vector< int >;
|
// using OVEC_t = std::vector< int >;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Internal RegularExpression instance.
|
// * Internal RegularExpression instance.
|
||||||
*/
|
// */
|
||||||
pcre * mPCRE{nullptr};
|
// pcre * mPCRE{nullptr};
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Internal RegularExpression instance.
|
// * Internal RegularExpression instance.
|
||||||
*/
|
// */
|
||||||
pcre_extra * mExtra{nullptr};
|
// pcre_extra * mExtra{nullptr};
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Internal buffer used for offsets.
|
// * Internal buffer used for offsets.
|
||||||
*/
|
// */
|
||||||
OVEC_t mOVEC{};
|
// OVEC_t mOVEC{};
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Default constructor.
|
// * Default constructor.
|
||||||
*/
|
// */
|
||||||
RxInstance() noexcept = default;
|
// RxInstance() noexcept = default;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Copy constructor (disabled).
|
// * Copy constructor (disabled).
|
||||||
*/
|
// */
|
||||||
RxInstance(const RxInstance &) = delete;
|
// RxInstance(const RxInstance &) = delete;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Move constructor.
|
// * Move constructor.
|
||||||
*/
|
// */
|
||||||
RxInstance(RxInstance && o) noexcept
|
// RxInstance(RxInstance && o) noexcept
|
||||||
: mPCRE(o.mPCRE), mExtra(o.mExtra), mOVEC(std::move(o.mOVEC)) // Replicate it
|
// : mPCRE(o.mPCRE), mExtra(o.mExtra), mOVEC(std::move(o.mOVEC)) // Replicate it
|
||||||
{
|
// {
|
||||||
o.mPCRE = nullptr; // Take ownership
|
// o.mPCRE = nullptr; // Take ownership
|
||||||
o.mExtra = nullptr; // Take ownership
|
// o.mExtra = nullptr; // Take ownership
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Basic constructor.
|
// * Basic constructor.
|
||||||
*/
|
// */
|
||||||
explicit RxInstance(StackStrF & pattern)
|
// explicit RxInstance(StackStrF & pattern)
|
||||||
: RxInstance(OPTIONS, STUDY, pattern)
|
// : RxInstance(OPTIONS, STUDY, pattern)
|
||||||
{
|
// {
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Basic constructor. With specific options.
|
// * Basic constructor. With specific options.
|
||||||
*/
|
// */
|
||||||
explicit RxInstance(int options, StackStrF & pattern)
|
// explicit RxInstance(int options, StackStrF & pattern)
|
||||||
: RxInstance(options, STUDY, pattern)
|
// : RxInstance(options, STUDY, pattern)
|
||||||
{
|
// {
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Basic constructor. With specific options.
|
// * Basic constructor. With specific options.
|
||||||
*/
|
// */
|
||||||
explicit RxInstance(int options, bool study, StackStrF & pattern)
|
// explicit RxInstance(int options, bool study, StackStrF & pattern)
|
||||||
: mPCRE(Compile_(pattern.mPtr, options)), mExtra(nullptr)
|
// : mPCRE(Compile_(pattern.mPtr, options)), mExtra(nullptr)
|
||||||
{
|
// {
|
||||||
if (study)
|
// if (study)
|
||||||
{
|
// {
|
||||||
Study0();
|
// Study0();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Internal constructor.
|
// * Internal constructor.
|
||||||
*/
|
// */
|
||||||
RxInstance(const char * pattern, int options, bool study)
|
// RxInstance(const char * pattern, int options, bool study)
|
||||||
: mPCRE(Compile_(pattern, options)), mExtra(nullptr)
|
// : mPCRE(Compile_(pattern, options)), mExtra(nullptr)
|
||||||
{
|
// {
|
||||||
if (study)
|
// if (study)
|
||||||
{
|
// {
|
||||||
Study0();
|
// Study0();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Destructor.
|
// * Destructor.
|
||||||
*/
|
// */
|
||||||
~RxInstance()
|
// ~RxInstance()
|
||||||
{
|
// {
|
||||||
Destroy();
|
// Destroy();
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Copy assignment operator (disabled).
|
// * Copy assignment operator (disabled).
|
||||||
*/
|
// */
|
||||||
RxInstance & operator = (const RxInstance &) = delete;
|
// RxInstance & operator = (const RxInstance &) = delete;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Move assignment operator.
|
// * Move assignment operator.
|
||||||
*/
|
// */
|
||||||
RxInstance & operator = (RxInstance && o) noexcept
|
// RxInstance & operator = (RxInstance && o) noexcept
|
||||||
{
|
// {
|
||||||
// Prevent self assignment
|
// // Prevent self assignment
|
||||||
if (this != &o)
|
// if (this != &o)
|
||||||
{
|
// {
|
||||||
// Release current instance, if any
|
// // Release current instance, if any
|
||||||
Destroy();
|
// Destroy();
|
||||||
// Replicate it
|
// // Replicate it
|
||||||
mPCRE = o.mPCRE;
|
// mPCRE = o.mPCRE;
|
||||||
mExtra = o.mExtra;
|
// mExtra = o.mExtra;
|
||||||
mOVEC = std::move(o.mOVEC);
|
// mOVEC = std::move(o.mOVEC);
|
||||||
// Take ownership
|
// // Take ownership
|
||||||
o.mPCRE = nullptr;
|
// o.mPCRE = nullptr;
|
||||||
o.mExtra = nullptr;
|
// o.mExtra = nullptr;
|
||||||
}
|
// }
|
||||||
return *this;
|
// return *this;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Estimate the size necessary for the offsets vector buffer.
|
// * Estimate the size necessary for the offsets vector buffer.
|
||||||
*/
|
// */
|
||||||
void EstimateOVEC(bool force = false)
|
// void EstimateOVEC(bool force = false)
|
||||||
{
|
// {
|
||||||
if (mOVEC.empty() || force)
|
// if (mOVEC.empty() || force)
|
||||||
{
|
// {
|
||||||
int size = 0;
|
// int size = 0;
|
||||||
// Attempt to estimate the size of the offsets vector buffer
|
// // Attempt to estimate the size of the offsets vector buffer
|
||||||
const int r = pcre_fullinfo(ValidPCRE(), mExtra, PCRE_INFO_CAPTURECOUNT, &size);
|
// const int r = pcre_fullinfo(ValidPCRE(), mExtra, PCRE_INFO_CAPTURECOUNT, &size);
|
||||||
// Check for errors
|
// // Check for errors
|
||||||
if (r != 0)
|
// if (r != 0)
|
||||||
{
|
// {
|
||||||
STHROWF("Rx: Offsets vector buffer estimation failed ({})", r);
|
// STHROWF("Rx: Offsets vector buffer estimation failed ({})", r);
|
||||||
}
|
// }
|
||||||
// Attempt to scale the vector (must be multiple of 3)
|
// // Attempt to scale the vector (must be multiple of 3)
|
||||||
mOVEC.resize((size + 1) * 3);
|
// mOVEC.resize((size + 1) * 3);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Return a valid `pcre` instance pointer or throw an exception.
|
// * Return a valid `pcre` instance pointer or throw an exception.
|
||||||
*/
|
// */
|
||||||
SQMOD_NODISCARD pcre * ValidPCRE() const
|
// SQMOD_NODISCARD pcre * ValidPCRE() const
|
||||||
{
|
// {
|
||||||
// Do we manage a valid instance?
|
// // Do we manage a valid instance?
|
||||||
if (mPCRE == nullptr)
|
// if (mPCRE == nullptr)
|
||||||
{
|
// {
|
||||||
STHROWF("Uninitialized Regular Expression instance.");
|
// STHROWF("Uninitialized Regular Expression instance.");
|
||||||
}
|
// }
|
||||||
// Return it
|
// // Return it
|
||||||
return mPCRE;
|
// return mPCRE;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Return a valid `pcre_extra` instance pointer or throw an exception.
|
// * Return a valid `pcre_extra` instance pointer or throw an exception.
|
||||||
*/
|
// */
|
||||||
SQMOD_NODISCARD pcre_extra * ValidExtra() const
|
// SQMOD_NODISCARD pcre_extra * ValidExtra() const
|
||||||
{
|
// {
|
||||||
// Do we manage a valid instance?
|
// // Do we manage a valid instance?
|
||||||
if (mExtra == nullptr)
|
// if (mExtra == nullptr)
|
||||||
{
|
// {
|
||||||
STHROWF("Regular Expression was not studied and optimized.");
|
// STHROWF("Regular Expression was not studied and optimized.");
|
||||||
}
|
// }
|
||||||
// Return it
|
// // Return it
|
||||||
return mExtra;
|
// return mExtra;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Compile the specified pattern.
|
// * Compile the specified pattern.
|
||||||
*/
|
// */
|
||||||
SQMOD_NODISCARD static pcre * Compile_(const char * pattern, int options = OPTIONS)
|
// SQMOD_NODISCARD static pcre * Compile_(const char * pattern, int options = OPTIONS)
|
||||||
{
|
// {
|
||||||
const char * error_msg = nullptr;
|
// const char * error_msg = nullptr;
|
||||||
int error_code, error_offset = 0;
|
// int error_code, error_offset = 0;
|
||||||
// Attempt to compile the specified pattern
|
// // Attempt to compile the specified pattern
|
||||||
pcre * ptr = pcre_compile2(pattern, options, &error_code, &error_msg, &error_offset, nullptr);
|
// pcre * ptr = pcre_compile2(pattern, options, &error_code, &error_msg, &error_offset, nullptr);
|
||||||
// Did the compilation failed?
|
// // Did the compilation failed?
|
||||||
if (ptr == nullptr)
|
// if (ptr == nullptr)
|
||||||
{
|
// {
|
||||||
STHROWF("Rx: {s} (code {}) (at offset {})", error_msg, error_code, error_offset);
|
// STHROWF("Rx: {s} (code {}) (at offset {})", error_msg, error_code, error_offset);
|
||||||
}
|
// }
|
||||||
// Return the `pcre` instance
|
// // Return the `pcre` instance
|
||||||
return ptr;
|
// return ptr;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Attempt to compile the specified pattern. Error information is returned instead of thrown.
|
// * Attempt to compile the specified pattern. Error information is returned instead of thrown.
|
||||||
*/
|
// */
|
||||||
SQMOD_NODISCARD static std::pair< pcre *, Table > TryCompile_(const char * pattern, int options = OPTIONS)
|
// SQMOD_NODISCARD static std::pair< pcre *, Table > TryCompile_(const char * pattern, int options = OPTIONS)
|
||||||
{
|
// {
|
||||||
const char * error_msg = nullptr;
|
// const char * error_msg = nullptr;
|
||||||
int error_code, error_offset = 0;
|
// int error_code, error_offset = 0;
|
||||||
// Attempt to compile the specified pattern
|
// // Attempt to compile the specified pattern
|
||||||
pcre * ptr = pcre_compile2(pattern, options, &error_code, &error_msg, &error_offset, nullptr);
|
// pcre * ptr = pcre_compile2(pattern, options, &error_code, &error_msg, &error_offset, nullptr);
|
||||||
// Did the compilation failed?
|
// // Did the compilation failed?
|
||||||
if (ptr == nullptr)
|
// if (ptr == nullptr)
|
||||||
{
|
// {
|
||||||
Table t;
|
// Table t;
|
||||||
t.SetValue("message", error_msg);
|
// t.SetValue("message", error_msg);
|
||||||
t.SetValue("code", error_code);
|
// t.SetValue("code", error_code);
|
||||||
t.SetValue("offset", error_offset);
|
// t.SetValue("offset", error_offset);
|
||||||
// Return the table with error information
|
// // Return the table with error information
|
||||||
return std::make_pair(ptr, std::move(t));
|
// return std::make_pair(ptr, std::move(t));
|
||||||
}
|
// }
|
||||||
// Return the `pcre` instance with no error information
|
// // Return the `pcre` instance with no error information
|
||||||
return std::make_pair(ptr, Table{});
|
// return std::make_pair(ptr, Table{});
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Compile the specified pattern.
|
// * Compile the specified pattern.
|
||||||
*/
|
// */
|
||||||
RxInstance & Compile1(StackStrF & pattern)
|
// RxInstance & Compile1(StackStrF & pattern)
|
||||||
{
|
// {
|
||||||
return Compile2(OPTIONS, pattern);
|
// return Compile2(OPTIONS, pattern);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Compile the specified pattern. With specific options.
|
// * Compile the specified pattern. With specific options.
|
||||||
*/
|
// */
|
||||||
RxInstance & Compile2(int options, StackStrF & pattern)
|
// RxInstance & Compile2(int options, StackStrF & pattern)
|
||||||
{
|
// {
|
||||||
// Release current instance, if any
|
// // Release current instance, if any
|
||||||
Destroy();
|
// Destroy();
|
||||||
// Attempt to compile
|
// // Attempt to compile
|
||||||
mPCRE = Compile_(pattern.mPtr, options);
|
// mPCRE = Compile_(pattern.mPtr, options);
|
||||||
// Allocate offsets vector buffer
|
// // Allocate offsets vector buffer
|
||||||
EstimateOVEC();
|
// EstimateOVEC();
|
||||||
// Allow chaining
|
// // Allow chaining
|
||||||
return *this;
|
// return *this;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Compile the specified pattern.
|
// * Compile the specified pattern.
|
||||||
*/
|
// */
|
||||||
Table TryCompile1(StackStrF & pattern)
|
// Table TryCompile1(StackStrF & pattern)
|
||||||
{
|
// {
|
||||||
return TryCompile2(OPTIONS, pattern);
|
// return TryCompile2(OPTIONS, pattern);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Compile the specified pattern. With specific options.
|
// * Compile the specified pattern. With specific options.
|
||||||
*/
|
// */
|
||||||
Table TryCompile2(int options, StackStrF & pattern)
|
// Table TryCompile2(int options, StackStrF & pattern)
|
||||||
{
|
// {
|
||||||
// Release current instance, if any
|
// // Release current instance, if any
|
||||||
Destroy();
|
// Destroy();
|
||||||
// Attempt to compile
|
// // Attempt to compile
|
||||||
auto p = TryCompile_(pattern.mPtr, options);
|
// auto p = TryCompile_(pattern.mPtr, options);
|
||||||
// Were there any compilation errors?
|
// // Were there any compilation errors?
|
||||||
if (p.first != nullptr)
|
// if (p.first != nullptr)
|
||||||
{
|
// {
|
||||||
mPCRE = p.first;
|
// mPCRE = p.first;
|
||||||
}
|
// }
|
||||||
// Return compilation info
|
// // Return compilation info
|
||||||
return p.second;
|
// return p.second;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Analyze the managed pattern and optimized it.
|
// * Analyze the managed pattern and optimized it.
|
||||||
*/
|
// */
|
||||||
RxInstance & Study0()
|
// RxInstance & Study0()
|
||||||
{
|
// {
|
||||||
return Study1(STUDY_OPTIONS);
|
// return Study1(STUDY_OPTIONS);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Analyze the managed pattern and optimized it. With specific options.
|
// * Analyze the managed pattern and optimized it. With specific options.
|
||||||
*/
|
// */
|
||||||
RxInstance & Study1(int options)
|
// RxInstance & Study1(int options)
|
||||||
{
|
// {
|
||||||
if (mExtra != nullptr)
|
// if (mExtra != nullptr)
|
||||||
{
|
// {
|
||||||
STHROWF("Regular Expression was already analyzed and optimized");
|
// STHROWF("Regular Expression was already analyzed and optimized");
|
||||||
}
|
// }
|
||||||
const char * error = nullptr;
|
// const char * error = nullptr;
|
||||||
// Study and optimize the expression
|
// // Study and optimize the expression
|
||||||
mExtra = pcre_study(ValidPCRE(), options, &error);
|
// mExtra = pcre_study(ValidPCRE(), options, &error);
|
||||||
// If there was an error studying the expression then throw it
|
// // If there was an error studying the expression then throw it
|
||||||
if (mExtra == nullptr && error != nullptr)
|
// if (mExtra == nullptr && error != nullptr)
|
||||||
{
|
// {
|
||||||
STHROWF("Rx: {s}", error);
|
// STHROWF("Rx: {s}", error);
|
||||||
}
|
// }
|
||||||
// Allow chaining
|
// // Allow chaining
|
||||||
return *this;
|
// return *this;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Release managed resources and revert to uninitialized instance.
|
// * Release managed resources and revert to uninitialized instance.
|
||||||
*/
|
// */
|
||||||
SQMOD_NODISCARD bool IsValid() const
|
// SQMOD_NODISCARD bool IsValid() const
|
||||||
{
|
// {
|
||||||
return (mPCRE != nullptr);
|
// return (mPCRE != nullptr);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Release managed resources and revert to uninitialized instance.
|
// * Release managed resources and revert to uninitialized instance.
|
||||||
*/
|
// */
|
||||||
SQMOD_NODISCARD bool IsStudied() const
|
// SQMOD_NODISCARD bool IsStudied() const
|
||||||
{
|
// {
|
||||||
return (mExtra != nullptr);
|
// return (mExtra != nullptr);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Release managed resources and revert to uninitialized instance.
|
// * Release managed resources and revert to uninitialized instance.
|
||||||
*/
|
// */
|
||||||
void Destroy()
|
// void Destroy()
|
||||||
{
|
// {
|
||||||
// Do we manage any instance?
|
// // Do we manage any instance?
|
||||||
if (mPCRE != nullptr)
|
// if (mPCRE != nullptr)
|
||||||
{
|
// {
|
||||||
pcre_free(mPCRE);
|
// pcre_free(mPCRE);
|
||||||
mPCRE = nullptr;
|
// mPCRE = nullptr;
|
||||||
}
|
// }
|
||||||
// Is the expression optimized?
|
// // Is the expression optimized?
|
||||||
if (mExtra != nullptr)
|
// if (mExtra != nullptr)
|
||||||
{
|
// {
|
||||||
pcre_free(mExtra);
|
// pcre_free(mExtra);
|
||||||
mExtra = nullptr;
|
// mExtra = nullptr;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Matches the given subject string against the pattern.
|
// * Matches the given subject string against the pattern.
|
||||||
* Returns the position of the first captured sub-string in m.
|
// * Returns the position of the first captured sub-string in m.
|
||||||
* If no part of the subject matches the pattern, m.mOffset is -1 and m.mLength is 0.
|
// * If no part of the subject matches the pattern, m.mOffset is -1 and m.mLength is 0.
|
||||||
* Returns the number of matches. Throws a exception in case of an error.
|
// * Returns the number of matches. Throws a exception in case of an error.
|
||||||
*/
|
// */
|
||||||
SQMOD_NODISCARD int MatchFirstFrom(SQInteger o, RxMatch & m, StackStrF & s)
|
// SQMOD_NODISCARD int MatchFirstFrom(SQInteger o, RxMatch & m, StackStrF & s)
|
||||||
{
|
// {
|
||||||
return MatchFirstFrom_(OPTIONS, o, m, s);
|
// return MatchFirstFrom_(OPTIONS, o, m, s);
|
||||||
}
|
// }
|
||||||
SQMOD_NODISCARD int MatchFirstFrom_(int f, SQInteger o, RxMatch & m, StackStrF & s)
|
// SQMOD_NODISCARD int MatchFirstFrom_(int f, SQInteger o, RxMatch & m, StackStrF & s)
|
||||||
{
|
// {
|
||||||
if (o > s.mLen)
|
// if (o > s.mLen)
|
||||||
{
|
// {
|
||||||
STHROWF("Rx: Offset is out of range");
|
// STHROWF("Rx: Offset is out of range");
|
||||||
}
|
// }
|
||||||
EstimateOVEC();
|
// EstimateOVEC();
|
||||||
// Attempt to execute the expression on the specified subject
|
// // Attempt to execute the expression on the specified subject
|
||||||
const int rc = pcre_exec(ValidPCRE(), mExtra, s.mPtr, static_cast< int >(s.mLen), static_cast< int >(o), f & 0xFFFF, mOVEC.data(), static_cast< int >(mOVEC.size()));
|
// const int rc = pcre_exec(ValidPCRE(), mExtra, s.mPtr, static_cast< int >(s.mLen), static_cast< int >(o), f & 0xFFFF, mOVEC.data(), static_cast< int >(mOVEC.size()));
|
||||||
// Was there a match?
|
// // Was there a match?
|
||||||
if (rc == PCRE_ERROR_NOMATCH)
|
// if (rc == PCRE_ERROR_NOMATCH)
|
||||||
{
|
// {
|
||||||
m.mOffset = -1;
|
// m.mOffset = -1;
|
||||||
m.mLength = 0;
|
// m.mLength = 0;
|
||||||
// No match found
|
// // No match found
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
// Bad options/flags?
|
// // Bad options/flags?
|
||||||
else if (rc == PCRE_ERROR_BADOPTION)
|
// else if (rc == PCRE_ERROR_BADOPTION)
|
||||||
{
|
// {
|
||||||
STHROWF("Rx: Bad option");
|
// STHROWF("Rx: Bad option");
|
||||||
}
|
// }
|
||||||
// Overflow?
|
// // Overflow?
|
||||||
else if (rc == 0)
|
// else if (rc == 0)
|
||||||
{
|
// {
|
||||||
STHROWF("Rx: too many captured sub-strings");
|
// STHROWF("Rx: too many captured sub-strings");
|
||||||
}
|
// }
|
||||||
// Some other error?
|
// // Some other error?
|
||||||
else if (rc < 0)
|
// else if (rc < 0)
|
||||||
{
|
// {
|
||||||
STHROWF("Rx: error {}", rc);
|
// STHROWF("Rx: error {}", rc);
|
||||||
}
|
// }
|
||||||
// Store match
|
// // Store match
|
||||||
m.mOffset = mOVEC[0];
|
// m.mOffset = mOVEC[0];
|
||||||
m.mLength = mOVEC[1] - mOVEC[0];
|
// m.mLength = mOVEC[1] - mOVEC[0];
|
||||||
// Yield result back to script
|
// // Yield result back to script
|
||||||
return rc;
|
// return rc;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Matches the given subject string against the pattern.
|
// * Matches the given subject string against the pattern.
|
||||||
* Returns the position of the first captured sub-string in m.
|
// * Returns the position of the first captured sub-string in m.
|
||||||
* If no part of the subject matches the pattern, m.mOffset is -1 and m.mLength is 0.
|
// * If no part of the subject matches the pattern, m.mOffset is -1 and m.mLength is 0.
|
||||||
* Returns the number of matches. Throws a exception in case of an error.
|
// * Returns the number of matches. Throws a exception in case of an error.
|
||||||
*/
|
// */
|
||||||
SQMOD_NODISCARD int MatchFirst(RxMatch & m, StackStrF & s)
|
// SQMOD_NODISCARD int MatchFirst(RxMatch & m, StackStrF & s)
|
||||||
{
|
// {
|
||||||
return MatchFirstFrom_(OPTIONS, 0, m, s);
|
// return MatchFirstFrom_(OPTIONS, 0, m, s);
|
||||||
}
|
// }
|
||||||
SQMOD_NODISCARD int MatchFirst_(int f, RxMatch & m, StackStrF & s)
|
// SQMOD_NODISCARD int MatchFirst_(int f, RxMatch & m, StackStrF & s)
|
||||||
{
|
// {
|
||||||
return MatchFirstFrom_(f, 0, m, s);
|
// return MatchFirstFrom_(f, 0, m, s);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Matches the given subject string against the pattern.
|
// * Matches the given subject string against the pattern.
|
||||||
* The first entry in m contains the position of the captured sub-string.
|
// * The first entry in m contains the position of the captured sub-string.
|
||||||
* The following entries identify matching sub-patterns. See the PCRE documentation for a more detailed explanation.
|
// * The following entries identify matching sub-patterns. See the PCRE documentation for a more detailed explanation.
|
||||||
* If no part of the subject matches the pattern, m is empty.
|
// * If no part of the subject matches the pattern, m is empty.
|
||||||
* Returns the number of matches. Throws an exception in case of an error.
|
// * Returns the number of matches. Throws an exception in case of an error.
|
||||||
*/
|
// */
|
||||||
SQMOD_NODISCARD int MatchFrom(SQInteger o, RxMatches & m, StackStrF & s)
|
// SQMOD_NODISCARD int MatchFrom(SQInteger o, RxMatches & m, StackStrF & s)
|
||||||
{
|
// {
|
||||||
return MatchFrom_(OPTIONS, o, m, s);
|
// return MatchFrom_(OPTIONS, o, m, s);
|
||||||
}
|
// }
|
||||||
SQMOD_NODISCARD int MatchFrom_(int f, SQInteger o, RxMatches & m, StackStrF & s)
|
// SQMOD_NODISCARD int MatchFrom_(int f, SQInteger o, RxMatches & m, StackStrF & s)
|
||||||
{
|
// {
|
||||||
if (o > s.mLen)
|
// if (o > s.mLen)
|
||||||
{
|
// {
|
||||||
STHROWF("Rx: Offset is out of range");
|
// STHROWF("Rx: Offset is out of range");
|
||||||
}
|
// }
|
||||||
EstimateOVEC();
|
// EstimateOVEC();
|
||||||
// Clear previous matches, if any
|
// // Clear previous matches, if any
|
||||||
m.mList.clear();
|
// m.mList.clear();
|
||||||
// Attempt to execute the expression on the specified subject
|
// // Attempt to execute the expression on the specified subject
|
||||||
const int rc = pcre_exec(ValidPCRE(), mExtra, s.mPtr, static_cast< int >(s.mLen), static_cast< int >(o), f & 0xFFFF, mOVEC.data(), static_cast< int >(mOVEC.size()));
|
// const int rc = pcre_exec(ValidPCRE(), mExtra, s.mPtr, static_cast< int >(s.mLen), static_cast< int >(o), f & 0xFFFF, mOVEC.data(), static_cast< int >(mOVEC.size()));
|
||||||
// Was there a match?
|
// // Was there a match?
|
||||||
if (rc == PCRE_ERROR_NOMATCH)
|
// if (rc == PCRE_ERROR_NOMATCH)
|
||||||
{
|
// {
|
||||||
return 0; // No match found
|
// return 0; // No match found
|
||||||
}
|
// }
|
||||||
// Bad options/flags?
|
// // Bad options/flags?
|
||||||
else if (rc == PCRE_ERROR_BADOPTION)
|
// else if (rc == PCRE_ERROR_BADOPTION)
|
||||||
{
|
// {
|
||||||
STHROWF("Rx: Bad option");
|
// STHROWF("Rx: Bad option");
|
||||||
}
|
// }
|
||||||
// Overflow?
|
// // Overflow?
|
||||||
else if (rc == 0)
|
// else if (rc == 0)
|
||||||
{
|
// {
|
||||||
STHROWF("Rx: too many captured sub-strings");
|
// STHROWF("Rx: too many captured sub-strings");
|
||||||
}
|
// }
|
||||||
// Some other error?
|
// // Some other error?
|
||||||
else if (rc < 0)
|
// else if (rc < 0)
|
||||||
{
|
// {
|
||||||
STHROWF("Rx: error {}", rc);
|
// STHROWF("Rx: error {}", rc);
|
||||||
}
|
// }
|
||||||
// Reserve space in advance
|
// // Reserve space in advance
|
||||||
m.mList.reserve(static_cast< size_t >(rc));
|
// m.mList.reserve(static_cast< size_t >(rc));
|
||||||
// Transfer matches to match-list
|
// // Transfer matches to match-list
|
||||||
for (int i = 0; i < rc; ++i)
|
// for (int i = 0; i < rc; ++i)
|
||||||
{
|
// {
|
||||||
m.mList.emplace_back(mOVEC[i*2], mOVEC[i*2+1] - mOVEC[i*2]);
|
// m.mList.emplace_back(mOVEC[i*2], mOVEC[i*2+1] - mOVEC[i*2]);
|
||||||
}
|
// }
|
||||||
// Yield result back to script
|
// // Yield result back to script
|
||||||
return rc;
|
// return rc;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
// /* --------------------------------------------------------------------------------------------
|
||||||
* Matches the given subject string against the pattern.
|
// * Matches the given subject string against the pattern.
|
||||||
* The first entry in m contains the position of the captured sub-string.
|
// * The first entry in m contains the position of the captured sub-string.
|
||||||
* The following entries identify matching sub-patterns. See the PCRE documentation for a more detailed explanation.
|
// * The following entries identify matching sub-patterns. See the PCRE documentation for a more detailed explanation.
|
||||||
* If no part of the subject matches the pattern, m is empty.
|
// * If no part of the subject matches the pattern, m is empty.
|
||||||
* Returns the number of matches. Throws an exception in case of an error.
|
// * Returns the number of matches. Throws an exception in case of an error.
|
||||||
*/
|
// */
|
||||||
SQMOD_NODISCARD int Match(RxMatches & m, StackStrF & s)
|
// SQMOD_NODISCARD int Match(RxMatches & m, StackStrF & s)
|
||||||
{
|
// {
|
||||||
return MatchFrom_(OPTIONS, 0, m, s);
|
// return MatchFrom_(OPTIONS, 0, m, s);
|
||||||
}
|
// }
|
||||||
SQMOD_NODISCARD int Match_(int f, RxMatches & m, StackStrF & s)
|
// SQMOD_NODISCARD int Match_(int f, RxMatches & m, StackStrF & s)
|
||||||
{
|
// {
|
||||||
return MatchFrom_(f, 0, m, s);
|
// return MatchFrom_(f, 0, m, s);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Returns true if and only if the subject matches the regular expression.
|
|
||||||
* Internally, this method sets the RE_ANCHORED and RE_NOTEMPTY options for matching,
|
|
||||||
* which means that the empty string will never match and the pattern is treated as if it starts with a ^.
|
|
||||||
*/
|
|
||||||
SQMOD_NODISCARD bool Matches(StackStrF & s)
|
|
||||||
{
|
|
||||||
return Matches_(PCRE_ANCHORED | PCRE_NOTEMPTY, s);
|
|
||||||
}
|
|
||||||
SQMOD_NODISCARD bool Matches_(SQInteger o, StackStrF & s)
|
|
||||||
{
|
|
||||||
return MatchesEx(PCRE_ANCHORED | PCRE_NOTEMPTY, 0, s);
|
|
||||||
}
|
|
||||||
SQMOD_NODISCARD bool MatchesEx(int f, SQInteger o, StackStrF & s)
|
|
||||||
{
|
|
||||||
RxMatch m;
|
|
||||||
const int rc = MatchFirstFrom_(f, o, m, s);
|
|
||||||
return (rc > 0) && (m.mOffset == o) && (m.mLength == (s.mLen - o));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// /* --------------------------------------------------------------------------------------------
|
||||||
|
// * Returns true if and only if the subject matches the regular expression.
|
||||||
|
// * Internally, this method sets the RE_ANCHORED and RE_NOTEMPTY options for matching,
|
||||||
|
// * which means that the empty string will never match and the pattern is treated as if it starts with a ^.
|
||||||
|
// */
|
||||||
|
// SQMOD_NODISCARD bool Matches(StackStrF & s)
|
||||||
|
// {
|
||||||
|
// return Matches_(PCRE_ANCHORED | PCRE_NOTEMPTY, s);
|
||||||
|
// }
|
||||||
|
// SQMOD_NODISCARD bool Matches_(SQInteger o, StackStrF & s)
|
||||||
|
// {
|
||||||
|
// return MatchesEx(PCRE_ANCHORED | PCRE_NOTEMPTY, 0, s);
|
||||||
|
// }
|
||||||
|
// SQMOD_NODISCARD bool MatchesEx(int f, SQInteger o, StackStrF & s)
|
||||||
|
// {
|
||||||
|
// RxMatch m;
|
||||||
|
// const int rc = MatchFirstFrom_(f, o, m, s);
|
||||||
|
// return (rc > 0) && (m.mOffset == o) && (m.mLength == (s.mLen - o));
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
@ -918,15 +918,23 @@ int32_t SQLiteStmtHnd::ExErrNo() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SQLiteConnection::TraceOutput(void * /*ptr*/, const char * sql)
|
int SQLiteConnection::InternalTrace(unsigned t, void * c, void * p, void * x)
|
||||||
{
|
{
|
||||||
LogInf("SQLite Trace: %s", sql);
|
if (t == SQLITE_TRACE_STMT)
|
||||||
}
|
{
|
||||||
|
auto xs = reinterpret_cast< const char * >(x);
|
||||||
|
if (xs[0] == '-' && xs[1] == '-') {
|
||||||
|
LogInf("SQLite Trace: %s", xs);
|
||||||
|
} else {
|
||||||
|
LogInf("SQLite Trace: %s", sqlite3_expanded_sql(reinterpret_cast< sqlite3_stmt * >(p)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogInf("SQLite profile (time: %llu): %s", time, *reinterpret_cast< sqlite3_uint64 * >(x));
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
return 0;
|
||||||
void SQLiteConnection::ProfileOutput(void * /*ptr*/, const char * sql, sqlite3_uint64 time)
|
|
||||||
{
|
|
||||||
LogInf("SQLite profile (time: %llu): %s", time, sql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -1133,7 +1141,7 @@ bool SQLiteConnection::TableExists(StackStrF & name) const
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SQLiteConnection::SetTracing(bool SQ_UNUSED_ARG(toggle)) // NOLINT(readability-convert-member-functions-to-static)
|
void SQLiteConnection::SetTracing(bool SQ_UNUSED_ARG(toggle)) // NOLINT(readability-convert-member-functions-to-static)
|
||||||
{
|
{
|
||||||
#if defined(SQLITE_OMIT_TRACE) || defined(SQLITE_OMIT_DEPRECATED)
|
#if defined(SQLITE_OMIT_TRACE)
|
||||||
STHROWF("The module was compiled without this feature");
|
STHROWF("The module was compiled without this feature");
|
||||||
#else
|
#else
|
||||||
// Check whether changes are necessary
|
// Check whether changes are necessary
|
||||||
@ -1144,12 +1152,28 @@ void SQLiteConnection::SetTracing(bool SQ_UNUSED_ARG(toggle)) // NOLINT(readabil
|
|||||||
// Do we have to disable it?
|
// Do we have to disable it?
|
||||||
else if (m_Handle->mTrace)
|
else if (m_Handle->mTrace)
|
||||||
{
|
{
|
||||||
sqlite3_trace(m_Handle->Access(), nullptr, nullptr);
|
// Is profiling active?
|
||||||
|
if (m_Handle->mProfile)
|
||||||
|
{
|
||||||
|
sqlite3_trace_v2(m_Handle->Access(), SQLITE_TRACE_PROFILE, &SQLiteConnection::InternalTrace, nullptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sqlite3_trace_v2(m_Handle->Access(), 0, nullptr, nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Go ahead and enable tracing
|
// Go ahead and enable tracing
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sqlite3_trace(m_Handle->Access(), &SQLiteConnection::TraceOutput, nullptr);
|
// Is profiling active?
|
||||||
|
if (m_Handle->mProfile)
|
||||||
|
{
|
||||||
|
sqlite3_trace_v2(m_Handle->Access(), SQLITE_TRACE_STMT|SQLITE_TRACE_PROFILE, &SQLiteConnection::InternalTrace, nullptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sqlite3_trace_v2(m_Handle->Access(), SQLITE_TRACE_STMT, &SQLiteConnection::InternalTrace, nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -1157,7 +1181,7 @@ void SQLiteConnection::SetTracing(bool SQ_UNUSED_ARG(toggle)) // NOLINT(readabil
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SQLiteConnection::SetProfiling(bool SQ_UNUSED_ARG(toggle)) // NOLINT(readability-convert-member-functions-to-static)
|
void SQLiteConnection::SetProfiling(bool SQ_UNUSED_ARG(toggle)) // NOLINT(readability-convert-member-functions-to-static)
|
||||||
{
|
{
|
||||||
#if defined(SQLITE_OMIT_TRACE) || defined(SQLITE_OMIT_DEPRECATED)
|
#if defined(SQLITE_OMIT_TRACE)
|
||||||
STHROWF("The module was compiled without this feature");
|
STHROWF("The module was compiled without this feature");
|
||||||
#else
|
#else
|
||||||
// Check whether changes are necessary
|
// Check whether changes are necessary
|
||||||
@ -1168,12 +1192,28 @@ void SQLiteConnection::SetProfiling(bool SQ_UNUSED_ARG(toggle)) // NOLINT(readab
|
|||||||
// Do we have to disable it?
|
// Do we have to disable it?
|
||||||
else if (m_Handle->mProfile)
|
else if (m_Handle->mProfile)
|
||||||
{
|
{
|
||||||
sqlite3_profile(m_Handle->Access(), nullptr, nullptr);
|
// Is tracing active?
|
||||||
|
if (m_Handle->mTrace)
|
||||||
|
{
|
||||||
|
sqlite3_trace_v2(m_Handle->Access(), SQLITE_TRACE_STMT, &SQLiteConnection::InternalTrace, nullptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sqlite3_trace_v2(m_Handle->Access(), 0, nullptr, nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Go ahead and enable profiling
|
// Go ahead and enable profiling
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sqlite3_profile(m_Handle->Access(), &SQLiteConnection::ProfileOutput, nullptr);
|
// Is tracing active?
|
||||||
|
if (m_Handle->mTrace)
|
||||||
|
{
|
||||||
|
sqlite3_trace_v2(m_Handle->Access(), SQLITE_TRACE_STMT|SQLITE_TRACE_PROFILE, &SQLiteConnection::InternalTrace, nullptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sqlite3_trace_v2(m_Handle->Access(), SQLITE_TRACE_PROFILE, &SQLiteConnection::InternalTrace, nullptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -436,14 +436,9 @@ private:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Callback function for ActivateTracing()
|
* Callback function for ActivateTracing() and ActivateProfiling()
|
||||||
*/
|
*/
|
||||||
static void TraceOutput(void * ptr, const char * sql);
|
static int InternalTrace(unsigned t, void * c, void * p, void * x);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
* Callback function for ActivateProfiling()
|
|
||||||
*/
|
|
||||||
static void ProfileOutput(void * ptr, const char * sql, sqlite3_uint64 time);
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed connection handle and throw an error if invalid.
|
* Validate the managed connection handle and throw an error if invalid.
|
||||||
|
@ -88,6 +88,7 @@ static SQInteger SqExtractIPv4(HSQUIRRELVM vm)
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
extern void Register_IdPool(HSQUIRRELVM vm, Table & ns);
|
extern void Register_IdPool(HSQUIRRELVM vm, Table & ns);
|
||||||
extern void Register_Vector(HSQUIRRELVM vm, Table & ns);
|
extern void Register_Vector(HSQUIRRELVM vm, Table & ns);
|
||||||
|
extern void Register_Template(HSQUIRRELVM vm, Table & ns);
|
||||||
extern void Register_Native_String(HSQUIRRELVM vm, Table & ns);
|
extern void Register_Native_String(HSQUIRRELVM vm, Table & ns);
|
||||||
extern void Register_ServerAnnouncer(HSQUIRRELVM vm, Table & ns);
|
extern void Register_ServerAnnouncer(HSQUIRRELVM vm, Table & ns);
|
||||||
|
|
||||||
@ -99,6 +100,7 @@ void Register_Utils(HSQUIRRELVM vm)
|
|||||||
|
|
||||||
Register_IdPool(vm, ns);
|
Register_IdPool(vm, ns);
|
||||||
Register_Vector(vm, ns);
|
Register_Vector(vm, ns);
|
||||||
|
Register_Template(vm, ns);
|
||||||
Register_Native_String(vm, ns);
|
Register_Native_String(vm, ns);
|
||||||
Register_ServerAnnouncer(vm, ns);
|
Register_ServerAnnouncer(vm, ns);
|
||||||
|
|
||||||
@ -110,7 +112,6 @@ void Register_Utils(HSQUIRRELVM vm)
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Register_IdPool(HSQUIRRELVM vm, Table & ns)
|
void Register_IdPool(HSQUIRRELVM vm, Table & ns)
|
||||||
{
|
{
|
||||||
// --------------------------------------------------------------------------------------------
|
|
||||||
ns.Bind(_SC("IdPool"),
|
ns.Bind(_SC("IdPool"),
|
||||||
Class< SqIdPool, NoCopy< SqIdPool > >(vm, SqIdPoolTypename::Str)
|
Class< SqIdPool, NoCopy< SqIdPool > >(vm, SqIdPoolTypename::Str)
|
||||||
// Constructors
|
// Constructors
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/Utils/JSON.hpp"
|
#include "Library/Utils/Template.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_JSON(HSQUIRRELVM vm, Table & ns)
|
void Register_Template(HSQUIRRELVM vm, Table & ns)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
50
module/Library/Utils/Template.hpp
Normal file
50
module/Library/Utils/Template.hpp
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
#include <inja/inja.hpp>
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
namespace SqMod {
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct SqTemplateData
|
||||||
|
{
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* JSON data.
|
||||||
|
*/
|
||||||
|
nlohmann::json mData{};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct SqTemplateEnvironment
|
||||||
|
{
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Environment instance.
|
||||||
|
*/
|
||||||
|
inja::Environment mEnv{};
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* Template engine loosely inspired by jinja for python.
|
||||||
|
*/
|
||||||
|
struct SqTemplateInstance
|
||||||
|
{
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Template instance.
|
||||||
|
*/
|
||||||
|
inja::Template mTpl{};
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // Namespace:: SqMod
|
@ -24,6 +24,9 @@ extern void ProcessRoutines();
|
|||||||
extern void ProcessTasks();
|
extern void ProcessTasks();
|
||||||
extern void ProcessThreads();
|
extern void ProcessThreads();
|
||||||
extern void ProcessNet();
|
extern void ProcessNet();
|
||||||
|
#ifdef SQMOD_DISCORD
|
||||||
|
extern void ProcessDiscord();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Will the scripts be reloaded at the end of the current event?
|
* Will the scripts be reloaded at the end of the current event?
|
||||||
@ -172,6 +175,10 @@ static void OnServerFrame(float elapsed_time)
|
|||||||
ProcessThreads();
|
ProcessThreads();
|
||||||
// Process network
|
// Process network
|
||||||
ProcessNet();
|
ProcessNet();
|
||||||
|
// Process Discord
|
||||||
|
#ifdef SQMOD_DISCORD
|
||||||
|
ProcessDiscord();
|
||||||
|
#endif
|
||||||
// Process log messages from other threads
|
// Process log messages from other threads
|
||||||
Logger::Get().ProcessQueue();
|
Logger::Get().ProcessQueue();
|
||||||
// See if a reload was requested
|
// See if a reload was requested
|
||||||
|
@ -30,6 +30,9 @@ extern void Register_CVehicle(HSQUIRRELVM vm);
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
extern void Register_Chrono(HSQUIRRELVM vm);
|
extern void Register_Chrono(HSQUIRRELVM vm);
|
||||||
extern void Register_CURL(HSQUIRRELVM vm);
|
extern void Register_CURL(HSQUIRRELVM vm);
|
||||||
|
#ifdef SQMOD_DISCORD
|
||||||
|
extern void Register_Discord(HSQUIRRELVM vm);
|
||||||
|
#endif
|
||||||
extern void Register_Format(HSQUIRRELVM vm);
|
extern void Register_Format(HSQUIRRELVM vm);
|
||||||
extern void Register_IO(HSQUIRRELVM vm);
|
extern void Register_IO(HSQUIRRELVM vm);
|
||||||
extern void Register_JSON(HSQUIRRELVM vm);
|
extern void Register_JSON(HSQUIRRELVM vm);
|
||||||
@ -98,6 +101,9 @@ bool RegisterAPI(HSQUIRRELVM vm)
|
|||||||
|
|
||||||
Register_Chrono(vm);
|
Register_Chrono(vm);
|
||||||
Register_CURL(vm);
|
Register_CURL(vm);
|
||||||
|
#ifdef SQMOD_DISCORD
|
||||||
|
Register_Discord(vm);
|
||||||
|
#endif
|
||||||
Register_Format(vm);
|
Register_Format(vm);
|
||||||
Register_IO(vm);
|
Register_IO(vm);
|
||||||
Register_JSON(vm);
|
Register_JSON(vm);
|
||||||
|
25
vendor/CMakeLists.txt
vendored
25
vendor/CMakeLists.txt
vendored
@ -8,6 +8,8 @@ add_subdirectory(TinyDir)
|
|||||||
add_subdirectory(SAJSON)
|
add_subdirectory(SAJSON)
|
||||||
add_subdirectory(CPR)
|
add_subdirectory(CPR)
|
||||||
add_subdirectory(UTF8)
|
add_subdirectory(UTF8)
|
||||||
|
add_subdirectory(JSON)
|
||||||
|
add_subdirectory(Inja)
|
||||||
add_subdirectory(PUGIXML)
|
add_subdirectory(PUGIXML)
|
||||||
add_subdirectory(CivetWeb)
|
add_subdirectory(CivetWeb)
|
||||||
if (ENABLE_BUILTIN_MYSQL_C)
|
if (ENABLE_BUILTIN_MYSQL_C)
|
||||||
@ -71,3 +73,26 @@ if (WIN32 OR MINGW)
|
|||||||
set(ZMQ_HAVE_IPC OFF CACHE INTERNAL "" FORCE)
|
set(ZMQ_HAVE_IPC OFF CACHE INTERNAL "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
add_subdirectory(ZMQ)
|
add_subdirectory(ZMQ)
|
||||||
|
if(ENABLE_DISCORD)
|
||||||
|
set(BUILD_TESTING OFF CACHE INTERNAL "" FORCE)
|
||||||
|
set(BUILD_VOICE_SUPPORT OFF CACHE INTERNAL "" FORCE)
|
||||||
|
set(DPP_INSTALL OFF CACHE INTERNAL "" FORCE)
|
||||||
|
set(DPP_BUILD_TEST OFF CACHE INTERNAL "" FORCE)
|
||||||
|
set(DPP_NO_VCPKG ON CACHE INTERNAL "" FORCE)
|
||||||
|
set(DPP_CORO OFF CACHE INTERNAL "" FORCE)
|
||||||
|
set(DPP_USE_EXTERNAL_JSON ON CACHE INTERNAL "" FORCE)
|
||||||
|
if (WIN32 OR MINGW)
|
||||||
|
set(BUILD_SHARED_LIBS ON CACHE INTERNAL "" FORCE)
|
||||||
|
endif()
|
||||||
|
add_subdirectory(DPP)
|
||||||
|
target_link_libraries(dpp PRIVATE nlohmann_json)
|
||||||
|
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE)
|
||||||
|
# We don't care about DPP warnings
|
||||||
|
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||||
|
target_compile_options(dpp PRIVATE -w)
|
||||||
|
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
target_compile_options(dpp PRIVATE -w)
|
||||||
|
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
|
target_compile_options(dpp PRIVATE /w)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
4
vendor/CPR/CMakeLists.txt
vendored
4
vendor/CPR/CMakeLists.txt
vendored
@ -51,6 +51,10 @@ add_library(CPR STATIC
|
|||||||
# Library includes
|
# Library includes
|
||||||
target_include_directories(CPR PRIVATE ${CMAKE_CURRENT_LIST_DIR}/cpr)
|
target_include_directories(CPR PRIVATE ${CMAKE_CURRENT_LIST_DIR}/cpr)
|
||||||
target_include_directories(CPR PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
target_include_directories(CPR PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||||
|
# Disable deprecated warnings
|
||||||
|
if (NOT MSVC)
|
||||||
|
target_compile_options(CPR PRIVATE -Wno-deprecated-declarations)
|
||||||
|
endif()
|
||||||
# Find CURK
|
# Find CURK
|
||||||
find_package(CURL REQUIRED)
|
find_package(CURL REQUIRED)
|
||||||
if (CURL_FOUND)
|
if (CURL_FOUND)
|
||||||
|
6
vendor/CivetWeb/CMakeLists.txt
vendored
6
vendor/CivetWeb/CMakeLists.txt
vendored
@ -10,7 +10,7 @@ add_library(CivetWeb STATIC
|
|||||||
wolfssl_extras.inl
|
wolfssl_extras.inl
|
||||||
handle_form.inl
|
handle_form.inl
|
||||||
md5.inl
|
md5.inl
|
||||||
mod_http2.inl
|
http2.inl
|
||||||
)
|
)
|
||||||
# Configure include folders
|
# Configure include folders
|
||||||
target_include_directories(CivetWeb PRIVATE ${CMAKE_CURRENT_LIST_DIR})
|
target_include_directories(CivetWeb PRIVATE ${CMAKE_CURRENT_LIST_DIR})
|
||||||
@ -25,14 +25,14 @@ target_compile_definitions(CivetWeb PUBLIC USE_TIMERS=1 USE_WEBSOCKET=1 USE_IPV6
|
|||||||
find_package(OpenSSL)
|
find_package(OpenSSL)
|
||||||
# Check SSL status
|
# Check SSL status
|
||||||
if (OPENSSL_FOUND)
|
if (OPENSSL_FOUND)
|
||||||
message(STATUS "CivetWeb: OpenSSL was found")
|
message(STATUS "CivetWeb: OpenSSL was found ${OPENSSL_VERSION}")
|
||||||
target_link_libraries(CivetWeb PUBLIC OpenSSL::Crypto OpenSSL::SSL)
|
target_link_libraries(CivetWeb PUBLIC OpenSSL::Crypto OpenSSL::SSL)
|
||||||
string(REPLACE "." ";" OPENSSL_VERSION_LIST ${OPENSSL_VERSION})
|
string(REPLACE "." ";" OPENSSL_VERSION_LIST ${OPENSSL_VERSION})
|
||||||
list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR)
|
list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR)
|
||||||
list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR)
|
list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR)
|
||||||
list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_PATCH)
|
list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_PATCH)
|
||||||
# Tell the library what SSL version to expect
|
# Tell the library what SSL version to expect
|
||||||
target_compile_definitions(CivetWeb PUBLIC "OPENSSL_API_${OPENSSL_VERSION_MAJOR}_${OPENSSL_VERSION_MINOR}")
|
target_compile_definitions(CivetWeb PRIVATE "OPENSSL_API_${OPENSSL_VERSION_MAJOR}_${OPENSSL_VERSION_MINOR}")
|
||||||
message(STATUS "CivetWeb: OPENSSL_API_${OPENSSL_VERSION_MAJOR}_${OPENSSL_VERSION_MINOR}")
|
message(STATUS "CivetWeb: OPENSSL_API_${OPENSSL_VERSION_MAJOR}_${OPENSSL_VERSION_MINOR}")
|
||||||
else()
|
else()
|
||||||
target_compile_definitions(CivetWeb PUBLIC NO_SSL=1)
|
target_compile_definitions(CivetWeb PUBLIC NO_SSL=1)
|
||||||
|
2382
vendor/CivetWeb/civetweb.c
vendored
2382
vendor/CivetWeb/civetweb.c
vendored
File diff suppressed because it is too large
Load Diff
2
vendor/CivetWeb/handle_form.inl
vendored
2
vendor/CivetWeb/handle_form.inl
vendored
@ -220,7 +220,7 @@ mg_handle_form_request(struct mg_connection *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* GET request: form data is in the query string. */
|
/* GET request: form data is in the query string. */
|
||||||
/* The entire data has already been loaded, so there is no nead to
|
/* The entire data has already been loaded, so there is no need to
|
||||||
* call mg_read. We just need to split the query string into key-value
|
* call mg_read. We just need to split the query string into key-value
|
||||||
* pairs. */
|
* pairs. */
|
||||||
data = conn->request_info.query_string;
|
data = conn->request_info.query_string;
|
||||||
|
@ -654,7 +654,7 @@ hpack_getnum(const uint8_t *buf,
|
|||||||
* the encoded string.
|
* the encoded string.
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
hpack_decode(const uint8_t *buf, int *i, struct mg_context *ctx)
|
hpack_decode(const uint8_t *buf, int *i, int max_i, struct mg_context *ctx)
|
||||||
{
|
{
|
||||||
uint64_t byte_len64;
|
uint64_t byte_len64;
|
||||||
int byte_len;
|
int byte_len;
|
||||||
@ -670,6 +670,11 @@ hpack_decode(const uint8_t *buf, int *i, struct mg_context *ctx)
|
|||||||
byte_len = (int)byte_len64;
|
byte_len = (int)byte_len64;
|
||||||
bit_len = byte_len * 8;
|
bit_len = byte_len * 8;
|
||||||
|
|
||||||
|
/* check size */
|
||||||
|
if ((*i) + byte_len > max_i) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Now read the string */
|
/* Now read the string */
|
||||||
if (!is_huff) {
|
if (!is_huff) {
|
||||||
/* Not huffman encoded: Copy directly */
|
/* Not huffman encoded: Copy directly */
|
||||||
@ -718,6 +723,10 @@ hpack_decode(const uint8_t *buf, int *i, struct mg_context *ctx)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (bytesStored == sizeof(str)) {
|
||||||
|
/* too long */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -820,7 +829,7 @@ hpack_encode(uint8_t *store, const char *load, int lower)
|
|||||||
|
|
||||||
|
|
||||||
static const char http2_pri[] = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n";
|
static const char http2_pri[] = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n";
|
||||||
static unsigned char http2_pri_len = 24; /* = strlen(http2_pri) */
|
static const unsigned char http2_pri_len = 24; /* = strlen(http2_pri) */
|
||||||
|
|
||||||
|
|
||||||
/* Read and check the HTTP/2 primer/preface:
|
/* Read and check the HTTP/2 primer/preface:
|
||||||
@ -829,17 +838,19 @@ static int
|
|||||||
is_valid_http2_primer(struct mg_connection *conn)
|
is_valid_http2_primer(struct mg_connection *conn)
|
||||||
{
|
{
|
||||||
size_t pri_len = http2_pri_len;
|
size_t pri_len = http2_pri_len;
|
||||||
char buf[32];
|
char buf[32]; /* Buffer must hold 24 bytes primer */
|
||||||
|
|
||||||
if (pri_len > sizeof(buf)) {
|
|
||||||
/* Should never be reached - the RFC primer has 24 bytes */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int read_pri_len = mg_read(conn, buf, pri_len);
|
int read_pri_len = mg_read(conn, buf, pri_len);
|
||||||
if ((read_pri_len != (int)pri_len)
|
if (read_pri_len != (int)pri_len) {
|
||||||
|| (0 != memcmp(buf, http2_pri, pri_len))) {
|
/* Size does not match.
|
||||||
|
* This includes cases where mg_read returns error codes */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (0 != memcmp(buf, http2_pri, pri_len)) {
|
||||||
|
/* Primer does not match */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* Primer does match */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -850,7 +861,7 @@ is_valid_http2_primer(struct mg_connection *conn)
|
|||||||
(conn)->client.sock, \
|
(conn)->client.sock, \
|
||||||
(conn)->ssl, \
|
(conn)->ssl, \
|
||||||
(const char *)(data), \
|
(const char *)(data), \
|
||||||
(int)(len));
|
(int)(len))
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -949,7 +960,7 @@ http2_send_response_headers(struct mg_connection *conn)
|
|||||||
uint16_t header_len = 0;
|
uint16_t header_len = 0;
|
||||||
int has_date = 0;
|
int has_date = 0;
|
||||||
int has_connection_header = 0;
|
int has_connection_header = 0;
|
||||||
int i;
|
int i, ok;
|
||||||
|
|
||||||
if ((conn->status_code < 100) || (conn->status_code > 999)) {
|
if ((conn->status_code < 100) || (conn->status_code > 999)) {
|
||||||
/* Invalid status: Set status to "Internal Server Error" */
|
/* Invalid status: Set status to "Internal Server Error" */
|
||||||
@ -1058,16 +1069,23 @@ http2_send_response_headers(struct mg_connection *conn)
|
|||||||
http2_header_frame[8] = (conn->http2.stream_id & 0xFFu);
|
http2_header_frame[8] = (conn->http2.stream_id & 0xFFu);
|
||||||
|
|
||||||
/* Send header frame */
|
/* Send header frame */
|
||||||
mg_xwrite(conn, http2_header_frame, 9);
|
ok = 1;
|
||||||
mg_xwrite(conn, header_bin, header_len);
|
if (mg_xwrite(conn, http2_header_frame, 9) != 9) {
|
||||||
|
ok = 0;
|
||||||
DEBUG_TRACE("HTTP2 response header sent: stream %u", conn->http2.stream_id);
|
} else if (mg_xwrite(conn, header_bin, header_len) != header_len) {
|
||||||
|
ok = 0;
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
DEBUG_TRACE("HTTP2 response header sent: stream %u",
|
||||||
|
conn->http2.stream_id);
|
||||||
|
} else {
|
||||||
|
DEBUG_TRACE("HTTP2 response header sending error: stream %u",
|
||||||
|
conn->http2.stream_id);
|
||||||
|
}
|
||||||
|
|
||||||
(void)has_connection_header; /* ignore for the moment */
|
(void)has_connection_header; /* ignore for the moment */
|
||||||
|
|
||||||
|
return ok;
|
||||||
return 42; /* TODO */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1420,8 +1438,13 @@ handle_http2(struct mg_connection *conn)
|
|||||||
/* Get Header name "key" */
|
/* Get Header name "key" */
|
||||||
if (idx == 0) {
|
if (idx == 0) {
|
||||||
/* Index 0: Header name encoded in following bytes */
|
/* Index 0: Header name encoded in following bytes */
|
||||||
key = hpack_decode(buf, &i, conn->phys_ctx);
|
key =
|
||||||
|
hpack_decode(buf, &i, (int)bytes_read, conn->phys_ctx);
|
||||||
CHECK_LEAK_HDR_ALLOC(key);
|
CHECK_LEAK_HDR_ALLOC(key);
|
||||||
|
if (!key) {
|
||||||
|
DEBUG_TRACE("HTTP2 key decoding error");
|
||||||
|
goto clean_http2;
|
||||||
|
}
|
||||||
} else if (/*(idx >= 15) &&*/ (idx <= 61)) {
|
} else if (/*(idx >= 15) &&*/ (idx <= 61)) {
|
||||||
/* Take key name from predefined header table */
|
/* Take key name from predefined header table */
|
||||||
key = mg_strdup_ctx(hpack_predefined[idx].name,
|
key = mg_strdup_ctx(hpack_predefined[idx].name,
|
||||||
@ -1480,8 +1503,16 @@ handle_http2(struct mg_connection *conn)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* Read value from HTTP2 stream */
|
/* Read value from HTTP2 stream */
|
||||||
val = hpack_decode(buf, &i, conn->phys_ctx); /* leak? */
|
val = hpack_decode(buf,
|
||||||
|
&i,
|
||||||
|
(int)bytes_read,
|
||||||
|
conn->phys_ctx); /* leak? */
|
||||||
CHECK_LEAK_HDR_ALLOC(val);
|
CHECK_LEAK_HDR_ALLOC(val);
|
||||||
|
if (!val) {
|
||||||
|
DEBUG_TRACE("HTTP2 value decoding error");
|
||||||
|
mg_free((void *)key);
|
||||||
|
goto clean_http2;
|
||||||
|
}
|
||||||
|
|
||||||
if (indexing) {
|
if (indexing) {
|
||||||
/* Add to index */
|
/* Add to index */
|
||||||
@ -1546,6 +1577,7 @@ handle_http2(struct mg_connection *conn)
|
|||||||
} else if (!strcmp(":path", key)) {
|
} else if (!strcmp(":path", key)) {
|
||||||
conn->request_info.local_uri = val;
|
conn->request_info.local_uri = val;
|
||||||
conn->request_info.request_uri = val;
|
conn->request_info.request_uri = val;
|
||||||
|
conn->request_info.local_uri_raw = val;
|
||||||
} else if (!strcmp(":status", key)) {
|
} else if (!strcmp(":status", key)) {
|
||||||
conn->status_code = atoi(val);
|
conn->status_code = atoi(val);
|
||||||
}
|
}
|
||||||
@ -1803,7 +1835,7 @@ HPACK_TABLE_TEST()
|
|||||||
|
|
||||||
for (i = 0; i < 256; i++) {
|
for (i = 0; i < 256; i++) {
|
||||||
if (reverse_map[i] == -1) {
|
if (reverse_map[i] == -1) {
|
||||||
ck_abort_msg("reverse map at %i mising", i);
|
ck_abort_msg("reverse map at %i missing", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
137
vendor/CivetWeb/include/civetweb.h
vendored
137
vendor/CivetWeb/include/civetweb.h
vendored
@ -23,9 +23,9 @@
|
|||||||
#ifndef CIVETWEB_HEADER_INCLUDED
|
#ifndef CIVETWEB_HEADER_INCLUDED
|
||||||
#define CIVETWEB_HEADER_INCLUDED
|
#define CIVETWEB_HEADER_INCLUDED
|
||||||
|
|
||||||
#define CIVETWEB_VERSION "1.15"
|
#define CIVETWEB_VERSION "1.16"
|
||||||
#define CIVETWEB_VERSION_MAJOR (1)
|
#define CIVETWEB_VERSION_MAJOR (1)
|
||||||
#define CIVETWEB_VERSION_MINOR (15)
|
#define CIVETWEB_VERSION_MINOR (16)
|
||||||
#define CIVETWEB_VERSION_PATCH (0)
|
#define CIVETWEB_VERSION_PATCH (0)
|
||||||
|
|
||||||
#ifndef CIVETWEB_API
|
#ifndef CIVETWEB_API
|
||||||
@ -654,7 +654,7 @@ CIVETWEB_API void *mg_get_thread_pointer(const struct mg_connection *conn);
|
|||||||
or write to the connection. */
|
or write to the connection. */
|
||||||
/* Note: An alternative is to use the init_connection callback
|
/* Note: An alternative is to use the init_connection callback
|
||||||
instead to initialize the user connection data pointer. It is
|
instead to initialize the user connection data pointer. It is
|
||||||
reccomended to supply a pointer to some user defined data structure
|
recommended to supply a pointer to some user defined data structure
|
||||||
as conn_data initializer in init_connection. In case it is required
|
as conn_data initializer in init_connection. In case it is required
|
||||||
to change some data after the init_connection call, store another
|
to change some data after the init_connection call, store another
|
||||||
data pointer in the user defined data structure and modify that
|
data pointer in the user defined data structure and modify that
|
||||||
@ -1128,7 +1128,7 @@ CIVETWEB_API int mg_get_var2(const char *data,
|
|||||||
required to increase this value at compile time.
|
required to increase this value at compile time.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
data: form encoded iput string. Will be modified by this function.
|
data: form encoded input string. Will be modified by this function.
|
||||||
form_fields: output list of name/value-pairs. A buffer with a size
|
form_fields: output list of name/value-pairs. A buffer with a size
|
||||||
specified by num_form_fields must be provided by the
|
specified by num_form_fields must be provided by the
|
||||||
caller.
|
caller.
|
||||||
@ -1341,6 +1341,22 @@ CIVETWEB_API int mg_url_decode(const char *src,
|
|||||||
CIVETWEB_API int mg_url_encode(const char *src, char *dst, size_t dst_len);
|
CIVETWEB_API int mg_url_encode(const char *src, char *dst, size_t dst_len);
|
||||||
|
|
||||||
|
|
||||||
|
/* BASE64-encode input buffer into destination buffer.
|
||||||
|
returns -1 on OK. */
|
||||||
|
CIVETWEB_API int mg_base64_encode(const unsigned char *src,
|
||||||
|
size_t src_len,
|
||||||
|
char *dst,
|
||||||
|
size_t *dst_len);
|
||||||
|
|
||||||
|
|
||||||
|
/* BASE64-decode input buffer into destination buffer.
|
||||||
|
returns -1 on OK. */
|
||||||
|
CIVETWEB_API int mg_base64_decode(const char *src,
|
||||||
|
size_t src_len,
|
||||||
|
unsigned char *dst,
|
||||||
|
size_t *dst_len);
|
||||||
|
|
||||||
|
|
||||||
/* MD5 hash given strings.
|
/* MD5 hash given strings.
|
||||||
Buffer 'buf' must be 33 bytes long. Varargs is a NULL terminated list of
|
Buffer 'buf' must be 33 bytes long. Varargs is a NULL terminated list of
|
||||||
ASCIIz strings. When function returns, buf will contain human-readable
|
ASCIIz strings. When function returns, buf will contain human-readable
|
||||||
@ -1350,6 +1366,40 @@ CIVETWEB_API int mg_url_encode(const char *src, char *dst, size_t dst_len);
|
|||||||
CIVETWEB_API char *mg_md5(char buf[33], ...);
|
CIVETWEB_API char *mg_md5(char buf[33], ...);
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(MG_MATCH_CONTEXT_MAX_MATCHES)
|
||||||
|
#define MG_MATCH_CONTEXT_MAX_MATCHES (32)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct mg_match_element {
|
||||||
|
const char *str; /* First character matching wildcard */
|
||||||
|
size_t len; /* Number of character matching wildcard */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct mg_match_context {
|
||||||
|
int case_sensitive; /* Input: 1 (case sensitive) or 0 (insensitive) */
|
||||||
|
size_t num_matches; /* Output: Number of wildcard matches returned. */
|
||||||
|
struct mg_match_element match[MG_MATCH_CONTEXT_MAX_MATCHES]; /* Output */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(MG_EXPERIMENTAL_INTERFACES)
|
||||||
|
/* Pattern matching and extraction function.
|
||||||
|
Parameters:
|
||||||
|
pat: Pattern string (see UserManual.md)
|
||||||
|
str: String to search for match patterns.
|
||||||
|
mcx: Match context (optional, can be NULL).
|
||||||
|
|
||||||
|
Return:
|
||||||
|
Number of characters matched.
|
||||||
|
-1 if no valid match was found.
|
||||||
|
Note: 0 characters might be a valid match for some patterns.
|
||||||
|
*/
|
||||||
|
CIVETWEB_API ptrdiff_t mg_match(const char *pat,
|
||||||
|
const char *str,
|
||||||
|
struct mg_match_context *mcx);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Print error message to the opened error log stream.
|
/* Print error message to the opened error log stream.
|
||||||
This utilizes the provided logging configuration.
|
This utilizes the provided logging configuration.
|
||||||
conn: connection (not used for sending data, but to get perameters)
|
conn: connection (not used for sending data, but to get perameters)
|
||||||
@ -1505,6 +1555,7 @@ CIVETWEB_API int mg_get_response(struct mg_connection *conn,
|
|||||||
* -1: parameter error
|
* -1: parameter error
|
||||||
* -2: invalid connection type
|
* -2: invalid connection type
|
||||||
* -3: invalid connection status
|
* -3: invalid connection status
|
||||||
|
* -4: network error (only if built with NO_RESPONSE_BUFFERING)
|
||||||
*/
|
*/
|
||||||
CIVETWEB_API int mg_response_header_start(struct mg_connection *conn,
|
CIVETWEB_API int mg_response_header_start(struct mg_connection *conn,
|
||||||
int status);
|
int status);
|
||||||
@ -1557,6 +1608,7 @@ CIVETWEB_API int mg_response_header_add_lines(struct mg_connection *conn,
|
|||||||
* -1: parameter error
|
* -1: parameter error
|
||||||
* -2: invalid connection type
|
* -2: invalid connection type
|
||||||
* -3: invalid connection status
|
* -3: invalid connection status
|
||||||
|
* -4: sending failed (network error)
|
||||||
*/
|
*/
|
||||||
CIVETWEB_API int mg_response_header_send(struct mg_connection *conn);
|
CIVETWEB_API int mg_response_header_send(struct mg_connection *conn);
|
||||||
|
|
||||||
@ -1600,7 +1652,7 @@ CIVETWEB_API unsigned mg_check_feature(unsigned feature);
|
|||||||
buffer: Store system information as string here.
|
buffer: Store system information as string here.
|
||||||
buflen: Length of buffer (including a byte required for a terminating 0).
|
buflen: Length of buffer (including a byte required for a terminating 0).
|
||||||
Return:
|
Return:
|
||||||
Available size of system information, exluding a terminating 0.
|
Available size of system information, excluding a terminating 0.
|
||||||
The information is complete, if the return value is smaller than buflen.
|
The information is complete, if the return value is smaller than buflen.
|
||||||
The result is a JSON formatted string, the exact content may vary.
|
The result is a JSON formatted string, the exact content may vary.
|
||||||
Note:
|
Note:
|
||||||
@ -1617,7 +1669,7 @@ CIVETWEB_API int mg_get_system_info(char *buffer, int buflen);
|
|||||||
buffer: Store context information here.
|
buffer: Store context information here.
|
||||||
buflen: Length of buffer (including a byte required for a terminating 0).
|
buflen: Length of buffer (including a byte required for a terminating 0).
|
||||||
Return:
|
Return:
|
||||||
Available size of system information, exluding a terminating 0.
|
Available size of system information, excluding a terminating 0.
|
||||||
The information is complete, if the return value is smaller than buflen.
|
The information is complete, if the return value is smaller than buflen.
|
||||||
The result is a JSON formatted string, the exact content may vary.
|
The result is a JSON formatted string, the exact content may vary.
|
||||||
Note:
|
Note:
|
||||||
@ -1646,7 +1698,7 @@ CIVETWEB_API void mg_disable_connection_keep_alive(struct mg_connection *conn);
|
|||||||
buffer: Store context information here.
|
buffer: Store context information here.
|
||||||
buflen: Length of buffer (including a byte required for a terminating 0).
|
buflen: Length of buffer (including a byte required for a terminating 0).
|
||||||
Return:
|
Return:
|
||||||
Available size of system information, exluding a terminating 0.
|
Available size of system information, excluding a terminating 0.
|
||||||
The information is complete, if the return value is smaller than buflen.
|
The information is complete, if the return value is smaller than buflen.
|
||||||
The result is a JSON formatted string, the exact content may vary.
|
The result is a JSON formatted string, the exact content may vary.
|
||||||
Note:
|
Note:
|
||||||
@ -1669,11 +1721,80 @@ CIVETWEB_API int mg_get_connection_info(const struct mg_context *ctx,
|
|||||||
Note: Experimental interfaces may change
|
Note: Experimental interfaces may change
|
||||||
*/
|
*/
|
||||||
struct mg_error_data {
|
struct mg_error_data {
|
||||||
unsigned *code; /* error code (number) */
|
unsigned code; /* error code (number) */
|
||||||
|
unsigned code_sub; /* error sub code (number) */
|
||||||
char *text; /* buffer for error text */
|
char *text; /* buffer for error text */
|
||||||
size_t text_buffer_size; /* size of buffer of "text" */
|
size_t text_buffer_size; /* size of buffer of "text" */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Values for error "code" in mg_error_data */
|
||||||
|
enum {
|
||||||
|
/* No error */
|
||||||
|
MG_ERROR_DATA_CODE_OK = 0u,
|
||||||
|
|
||||||
|
/* Caller provided invalid parameter */
|
||||||
|
MG_ERROR_DATA_CODE_INVALID_PARAM = 1u,
|
||||||
|
|
||||||
|
/* "configuration_option" contains invalid element */
|
||||||
|
MG_ERROR_DATA_CODE_INVALID_OPTION = 2u,
|
||||||
|
|
||||||
|
/* Initializen TLS / SSL library failed */
|
||||||
|
MG_ERROR_DATA_CODE_INIT_TLS_FAILED = 3u,
|
||||||
|
|
||||||
|
/* Mandatory "configuration_option" missing */
|
||||||
|
MG_ERROR_DATA_CODE_MISSING_OPTION = 4u,
|
||||||
|
|
||||||
|
/* Duplicate "authentication_domain" option */
|
||||||
|
MG_ERROR_DATA_CODE_DUPLICATE_DOMAIN = 5u,
|
||||||
|
|
||||||
|
/* Not enough memory */
|
||||||
|
MG_ERROR_DATA_CODE_OUT_OF_MEMORY = 6u,
|
||||||
|
|
||||||
|
/* Server already stopped */
|
||||||
|
MG_ERROR_DATA_CODE_SERVER_STOPPED = 7u,
|
||||||
|
|
||||||
|
/* mg_init_library must be called first */
|
||||||
|
MG_ERROR_DATA_CODE_INIT_LIBRARY_FAILED = 8u,
|
||||||
|
|
||||||
|
/* Operating system function failed */
|
||||||
|
MG_ERROR_DATA_CODE_OS_ERROR = 9u,
|
||||||
|
|
||||||
|
/* Failed to bind to server ports */
|
||||||
|
MG_ERROR_DATA_CODE_INIT_PORTS_FAILED = 10u,
|
||||||
|
|
||||||
|
/* Failed to switch user (option "run_as_user") */
|
||||||
|
MG_ERROR_DATA_CODE_INIT_USER_FAILED = 11u,
|
||||||
|
|
||||||
|
/* Access Control List error */
|
||||||
|
MG_ERROR_DATA_CODE_INIT_ACL_FAILED = 12u,
|
||||||
|
|
||||||
|
/* Global password file error */
|
||||||
|
MG_ERROR_DATA_CODE_INVALID_PASS_FILE = 13u,
|
||||||
|
|
||||||
|
/* Lua background script init error */
|
||||||
|
MG_ERROR_DATA_CODE_SCRIPT_ERROR = 14u,
|
||||||
|
|
||||||
|
/* Client: Host not found, invalid IP to connect */
|
||||||
|
MG_ERROR_DATA_CODE_HOST_NOT_FOUND = 15u,
|
||||||
|
|
||||||
|
/* Client: TCP connect timeout */
|
||||||
|
MG_ERROR_DATA_CODE_CONNECT_TIMEOUT = 16u,
|
||||||
|
|
||||||
|
/* Client: TCP connect failed */
|
||||||
|
MG_ERROR_DATA_CODE_CONNECT_FAILED = 17u,
|
||||||
|
|
||||||
|
/* Error using TLS client certificate */
|
||||||
|
MG_ERROR_DATA_CODE_TLS_CLIENT_CERT_ERROR = 18u,
|
||||||
|
|
||||||
|
/* Error setting trusted TLS server certificate for client connection */
|
||||||
|
MG_ERROR_DATA_CODE_TLS_SERVER_CERT_ERROR = 19u,
|
||||||
|
|
||||||
|
/* Error establishing TLS connection to HTTPS server */
|
||||||
|
MG_ERROR_DATA_CODE_TLS_CONNECT_ERROR = 20u
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct mg_init_data {
|
struct mg_init_data {
|
||||||
const struct mg_callbacks *callbacks; /* callback function pointer */
|
const struct mg_callbacks *callbacks; /* callback function pointer */
|
||||||
void *user_data; /* data */
|
void *user_data; /* data */
|
||||||
|
262
vendor/CivetWeb/match.inl
vendored
Normal file
262
vendor/CivetWeb/match.inl
vendored
Normal file
@ -0,0 +1,262 @@
|
|||||||
|
/* Reimplementation of pattern matching */
|
||||||
|
/* This file is part of the CivetWeb web server.
|
||||||
|
* See https://github.com/civetweb/civetweb/
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialize structure with 0 matches */
|
||||||
|
static void
|
||||||
|
match_context_reset(struct mg_match_context *mcx)
|
||||||
|
{
|
||||||
|
mcx->num_matches = 0;
|
||||||
|
memset(mcx->match, 0, sizeof(mcx->match));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Add a new match to the list of matches */
|
||||||
|
static void
|
||||||
|
match_context_push(const char *str, size_t len, struct mg_match_context *mcx)
|
||||||
|
{
|
||||||
|
if (mcx->num_matches < MG_MATCH_CONTEXT_MAX_MATCHES) {
|
||||||
|
mcx->match[mcx->num_matches].str = str;
|
||||||
|
mcx->match[mcx->num_matches].len = len;
|
||||||
|
mcx->num_matches++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ptrdiff_t
|
||||||
|
mg_match_impl(const char *pat,
|
||||||
|
size_t pat_len,
|
||||||
|
const char *str,
|
||||||
|
struct mg_match_context *mcx)
|
||||||
|
{
|
||||||
|
/* Parse string */
|
||||||
|
size_t i_pat = 0; /* Pattern index */
|
||||||
|
size_t i_str = 0; /* Pattern index */
|
||||||
|
|
||||||
|
int case_sensitive = ((mcx != NULL) ? mcx->case_sensitive : 0); /* 0 or 1 */
|
||||||
|
|
||||||
|
while (i_pat < pat_len) {
|
||||||
|
|
||||||
|
/* Pattern ? matches one character, except / and NULL character */
|
||||||
|
if ((pat[i_pat] == '?') && (str[i_str] != '\0')
|
||||||
|
&& (str[i_str] != '/')) {
|
||||||
|
size_t i_str_start = i_str;
|
||||||
|
do {
|
||||||
|
/* Advance as long as there are ? */
|
||||||
|
i_pat++;
|
||||||
|
i_str++;
|
||||||
|
} while ((pat[i_pat] == '?') && (str[i_str] != '\0')
|
||||||
|
&& (str[i_str] != '/') && (i_pat < pat_len));
|
||||||
|
|
||||||
|
/* If we have a match context, add the substring we just found */
|
||||||
|
if (mcx) {
|
||||||
|
match_context_push(str + i_str_start, i_str - i_str_start, mcx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reached end of pattern ? */
|
||||||
|
if (i_pat == pat_len) {
|
||||||
|
return (ptrdiff_t)i_str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pattern $ matches end of string */
|
||||||
|
if (pat[i_pat] == '$') {
|
||||||
|
return (str[i_str] == '\0') ? (ptrdiff_t)i_str : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Pattern * or ** matches multiple characters */
|
||||||
|
if (pat[i_pat] == '*') {
|
||||||
|
size_t len; /* length matched by "*" or "**" */
|
||||||
|
ptrdiff_t ret;
|
||||||
|
|
||||||
|
i_pat++;
|
||||||
|
if ((pat[i_pat] == '*') && (i_pat < pat_len)) {
|
||||||
|
/* Pattern ** matches all */
|
||||||
|
i_pat++;
|
||||||
|
len = strlen(str + i_str);
|
||||||
|
} else {
|
||||||
|
/* Pattern * matches all except / character */
|
||||||
|
len = strcspn(str + i_str, "/");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i_pat == pat_len) {
|
||||||
|
/* End of pattern reached. Add all to match context. */
|
||||||
|
if (mcx) {
|
||||||
|
match_context_push(str + i_str, len, mcx);
|
||||||
|
}
|
||||||
|
return (i_str + len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This loop searches for the longest possible match */
|
||||||
|
do {
|
||||||
|
ret = mg_match_impl(pat + i_pat,
|
||||||
|
(pat_len - (size_t)i_pat),
|
||||||
|
str + i_str + len,
|
||||||
|
mcx);
|
||||||
|
} while ((ret == -1) && (len-- > 0));
|
||||||
|
|
||||||
|
/* If we have a match context, add the substring we just found */
|
||||||
|
if (ret >= 0) {
|
||||||
|
if (mcx) {
|
||||||
|
match_context_push(str + i_str, len, mcx);
|
||||||
|
}
|
||||||
|
return (i_str + ret + len);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Single character compare */
|
||||||
|
if (case_sensitive) {
|
||||||
|
if (pat[i_pat] != str[i_str]) {
|
||||||
|
/* case sensitive compare: mismatch */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
} else if (lowercase(&pat[i_pat]) != lowercase(&str[i_str])) {
|
||||||
|
/* case insensitive compare: mismatch */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i_pat++;
|
||||||
|
i_str++;
|
||||||
|
}
|
||||||
|
return (ptrdiff_t)i_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ptrdiff_t
|
||||||
|
mg_match_alternatives(const char *pat,
|
||||||
|
size_t pat_len,
|
||||||
|
const char *str,
|
||||||
|
struct mg_match_context *mcx)
|
||||||
|
{
|
||||||
|
const char *match_alternative = (const char *)memchr(pat, '|', pat_len);
|
||||||
|
|
||||||
|
if (mcx != NULL) {
|
||||||
|
match_context_reset(mcx);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (match_alternative != NULL) {
|
||||||
|
/* Split at | for alternative match */
|
||||||
|
size_t left_size = (size_t)(match_alternative - pat);
|
||||||
|
|
||||||
|
/* Try left string first */
|
||||||
|
ptrdiff_t ret = mg_match_impl(pat, left_size, str, mcx);
|
||||||
|
if (ret >= 0) {
|
||||||
|
/* A 0-byte match is also valid */
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reset possible incomplete match data */
|
||||||
|
if (mcx != NULL) {
|
||||||
|
match_context_reset(mcx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If no match: try right side */
|
||||||
|
pat += left_size + 1;
|
||||||
|
pat_len -= left_size + 1;
|
||||||
|
match_alternative = (const char *)memchr(pat, '|', pat_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handled all | operators. This is the final string. */
|
||||||
|
return mg_match_impl(pat, pat_len, str, mcx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
match_compare(const void *p1, const void *p2, void *user)
|
||||||
|
{
|
||||||
|
const struct mg_match_element *e1 = (const struct mg_match_element *)p1;
|
||||||
|
const struct mg_match_element *e2 = (const struct mg_match_element *)p2;
|
||||||
|
|
||||||
|
/* unused */
|
||||||
|
(void)user;
|
||||||
|
|
||||||
|
if (e1->str > e2->str) {
|
||||||
|
return +1;
|
||||||
|
}
|
||||||
|
if (e1->str < e2->str) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(MG_EXPERIMENTAL_INTERFACES)
|
||||||
|
CIVETWEB_API
|
||||||
|
#else
|
||||||
|
static
|
||||||
|
#endif
|
||||||
|
ptrdiff_t
|
||||||
|
mg_match(const char *pat, const char *str, struct mg_match_context *mcx)
|
||||||
|
{
|
||||||
|
size_t pat_len = strlen(pat);
|
||||||
|
ptrdiff_t ret = mg_match_alternatives(pat, pat_len, str, mcx);
|
||||||
|
if (mcx != NULL) {
|
||||||
|
if (ret < 0) {
|
||||||
|
/* Remove possible incomplete data */
|
||||||
|
match_context_reset(mcx);
|
||||||
|
} else {
|
||||||
|
/* Join "?*" to one pattern. */
|
||||||
|
size_t i, j;
|
||||||
|
|
||||||
|
/* Use difference of two array elements instead of sizeof, since
|
||||||
|
* there may be some additional padding bytes. */
|
||||||
|
size_t elmsize =
|
||||||
|
(size_t)(&mcx->match[1]) - (size_t)(&mcx->match[0]);
|
||||||
|
|
||||||
|
/* First sort the matches by address ("str" begin to end) */
|
||||||
|
mg_sort(mcx->match, mcx->num_matches, elmsize, match_compare, NULL);
|
||||||
|
|
||||||
|
/* Join consecutive matches */
|
||||||
|
i = 1;
|
||||||
|
while (i < mcx->num_matches) {
|
||||||
|
if ((mcx->match[i - 1].str + mcx->match[i - 1].len)
|
||||||
|
== mcx->match[i].str) {
|
||||||
|
/* Two matches are consecutive. Join length. */
|
||||||
|
mcx->match[i - 1].len += mcx->match[i].len;
|
||||||
|
|
||||||
|
/* Shift all list elements. */
|
||||||
|
for (j = i + 1; j < mcx->num_matches; j++) {
|
||||||
|
mcx->match[j - 1].len = mcx->match[j].len;
|
||||||
|
mcx->match[j - 1].str = mcx->match[j].str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remove/blank last list element. */
|
||||||
|
mcx->num_matches--;
|
||||||
|
mcx->match[mcx->num_matches].str = NULL;
|
||||||
|
mcx->match[mcx->num_matches].len = 0;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ptrdiff_t
|
||||||
|
match_prefix(const char *pattern, size_t pattern_len, const char *str)
|
||||||
|
{
|
||||||
|
if (pattern == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return mg_match_alternatives(pattern, pattern_len, str, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ptrdiff_t
|
||||||
|
match_prefix_strlen(const char *pattern, const char *str)
|
||||||
|
{
|
||||||
|
if (pattern == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return mg_match_alternatives(pattern, strlen(pattern), str, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End of match.inl */
|
3
vendor/CivetWeb/md5.inl
vendored
3
vendor/CivetWeb/md5.inl
vendored
@ -131,6 +131,7 @@ MD5_STATIC void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(MD5_STATIC)
|
#if !defined(MD5_STATIC)
|
||||||
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -239,7 +240,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
|
|||||||
* On little-endian machines, we can process properly aligned
|
* On little-endian machines, we can process properly aligned
|
||||||
* data without copying it.
|
* data without copying it.
|
||||||
*/
|
*/
|
||||||
if (!((data - (const md5_byte_t *)0) & 3)) {
|
if (!(((uintptr_t)data) & 3)) {
|
||||||
/* data are properly aligned, a direct assignment is possible */
|
/* data are properly aligned, a direct assignment is possible */
|
||||||
/* cast through a (void *) should avoid a compiler warning,
|
/* cast through a (void *) should avoid a compiler warning,
|
||||||
see
|
see
|
||||||
|
2
vendor/CivetWeb/mod_zlib.inl
vendored
2
vendor/CivetWeb/mod_zlib.inl
vendored
@ -12,7 +12,7 @@ zalloc(void *opaque, uInt items, uInt size)
|
|||||||
{
|
{
|
||||||
struct mg_connection *conn = (struct mg_connection *)opaque;
|
struct mg_connection *conn = (struct mg_connection *)opaque;
|
||||||
void *ret = mg_calloc_ctx(items, size, conn->phys_ctx);
|
void *ret = mg_calloc_ctx(items, size, conn->phys_ctx);
|
||||||
(void)conn; /* mg_calloc_ctx makro might not need it */
|
(void)conn; /* mg_calloc_ctx macro might not need it */
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
28
vendor/CivetWeb/response.inl
vendored
28
vendor/CivetWeb/response.inl
vendored
@ -37,7 +37,7 @@ free_buffered_response_header_list(struct mg_connection *conn)
|
|||||||
|
|
||||||
|
|
||||||
/* Send first line of HTTP/1.x response */
|
/* Send first line of HTTP/1.x response */
|
||||||
static void
|
static int
|
||||||
send_http1_response_status_line(struct mg_connection *conn)
|
send_http1_response_status_line(struct mg_connection *conn)
|
||||||
{
|
{
|
||||||
const char *status_txt;
|
const char *status_txt;
|
||||||
@ -55,7 +55,13 @@ send_http1_response_status_line(struct mg_connection *conn)
|
|||||||
/* mg_get_response_code_text will never return NULL */
|
/* mg_get_response_code_text will never return NULL */
|
||||||
status_txt = mg_get_response_code_text(conn, conn->status_code);
|
status_txt = mg_get_response_code_text(conn, conn->status_code);
|
||||||
|
|
||||||
mg_printf(conn, "HTTP/%s %i %s\r\n", http_version, status_code, status_txt);
|
if (mg_printf(
|
||||||
|
conn, "HTTP/%s %i %s\r\n", http_version, status_code, status_txt)
|
||||||
|
< 10) {
|
||||||
|
/* Network sending failed */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -68,10 +74,12 @@ send_http1_response_status_line(struct mg_connection *conn)
|
|||||||
* -1: parameter error
|
* -1: parameter error
|
||||||
* -2: invalid connection type
|
* -2: invalid connection type
|
||||||
* -3: invalid connection status
|
* -3: invalid connection status
|
||||||
|
* -4: network error (only if built with NO_RESPONSE_BUFFERING)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mg_response_header_start(struct mg_connection *conn, int status)
|
mg_response_header_start(struct mg_connection *conn, int status)
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
if ((conn == NULL) || (status < 100) || (status > 999)) {
|
if ((conn == NULL) || (status < 100) || (status > 999)) {
|
||||||
/* Parameter error */
|
/* Parameter error */
|
||||||
return -1;
|
return -1;
|
||||||
@ -93,11 +101,13 @@ mg_response_header_start(struct mg_connection *conn, int status)
|
|||||||
#if !defined(NO_RESPONSE_BUFFERING)
|
#if !defined(NO_RESPONSE_BUFFERING)
|
||||||
free_buffered_response_header_list(conn);
|
free_buffered_response_header_list(conn);
|
||||||
#else
|
#else
|
||||||
send_http1_response_status_line(conn);
|
if (!send_http1_response_status_line(conn)) {
|
||||||
|
ret = -4;
|
||||||
|
};
|
||||||
conn->request_state = 1; /* Reset from 10 to 1 */
|
conn->request_state = 1; /* Reset from 10 to 1 */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -254,6 +264,7 @@ static int http2_send_response_headers(struct mg_connection *conn);
|
|||||||
* -1: parameter error
|
* -1: parameter error
|
||||||
* -2: invalid connection type
|
* -2: invalid connection type
|
||||||
* -3: invalid connection status
|
* -3: invalid connection status
|
||||||
|
* -4: network send failed
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
mg_response_header_send(struct mg_connection *conn)
|
mg_response_header_send(struct mg_connection *conn)
|
||||||
@ -285,12 +296,16 @@ mg_response_header_send(struct mg_connection *conn)
|
|||||||
#if defined(USE_HTTP2)
|
#if defined(USE_HTTP2)
|
||||||
if (conn->protocol_type == PROTOCOL_TYPE_HTTP2) {
|
if (conn->protocol_type == PROTOCOL_TYPE_HTTP2) {
|
||||||
int ret = http2_send_response_headers(conn);
|
int ret = http2_send_response_headers(conn);
|
||||||
return ret ? 0 : 0; /* todo */
|
free_buffered_response_header_list(conn);
|
||||||
|
return (ret ? 0 : -4);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Send */
|
/* Send */
|
||||||
send_http1_response_status_line(conn);
|
if (!send_http1_response_status_line(conn)) {
|
||||||
|
free_buffered_response_header_list(conn);
|
||||||
|
return -4;
|
||||||
|
};
|
||||||
for (i = 0; i < conn->response_info.num_headers; i++) {
|
for (i = 0; i < conn->response_info.num_headers; i++) {
|
||||||
mg_printf(conn,
|
mg_printf(conn,
|
||||||
"%s: %s\r\n",
|
"%s: %s\r\n",
|
||||||
@ -322,5 +337,6 @@ mg_response_header_send(struct mg_connection *conn)
|
|||||||
conn->request_state = 3;
|
conn->request_state = 3;
|
||||||
|
|
||||||
/* ok */
|
/* ok */
|
||||||
|
free_buffered_response_header_list(conn);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
48
vendor/CivetWeb/sort.inl
vendored
Normal file
48
vendor/CivetWeb/sort.inl
vendored
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/* Sort function. */
|
||||||
|
/* from https://github.com/bel2125/sort_r */
|
||||||
|
|
||||||
|
static void
|
||||||
|
mg_sort(void *data,
|
||||||
|
size_t elemcount,
|
||||||
|
size_t elemsize,
|
||||||
|
int (*compfunc)(const void *data1, const void *data2, void *userarg),
|
||||||
|
void *userarg)
|
||||||
|
{
|
||||||
|
/* We cannot use qsort_r here. For a detailed reason, see
|
||||||
|
* https://github.com/civetweb/civetweb/issues/1048#issuecomment-1047093014
|
||||||
|
* https://stackoverflow.com/questions/39560773/different-declarations-of-qsort-r-on-mac-and-linux
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* We use ShellSort here with this gap sequence: https://oeis.org/A102549 */
|
||||||
|
int A102549[9] = {1, 4, 10, 23, 57, 132, 301, 701, 1750};
|
||||||
|
int Aidx, gap, i, j, k;
|
||||||
|
void *tmp = alloca(elemsize);
|
||||||
|
|
||||||
|
for (Aidx = 8; Aidx >= 0; Aidx--) {
|
||||||
|
gap = A102549[Aidx];
|
||||||
|
if (gap > ((int)elemcount / 2)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (i = 0; i < gap; i++) {
|
||||||
|
for (j = i; j < (int)elemcount; j += gap) {
|
||||||
|
memcpy(tmp, (void *)((ptrdiff_t)data + elemsize * j), elemsize);
|
||||||
|
|
||||||
|
for (k = j; k >= gap; k -= gap) {
|
||||||
|
void *cmp =
|
||||||
|
(void *)((ptrdiff_t)data + elemsize * (k - gap));
|
||||||
|
int cmpres = compfunc(cmp, tmp, userarg);
|
||||||
|
if (cmpres > 0) {
|
||||||
|
memcpy((void *)((ptrdiff_t)data + elemsize * k),
|
||||||
|
cmp,
|
||||||
|
elemsize);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
memcpy((void *)((ptrdiff_t)data + elemsize * k), tmp, elemsize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end if sort.inl */
|
93
vendor/DPP/CMakeLists.txt
vendored
Normal file
93
vendor/DPP/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
#
|
||||||
|
# D++ (DPP), The Lightweight C++ Discord Library
|
||||||
|
#
|
||||||
|
# Copyright 2021 Craig Edwards <support@brainbox.cc>
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
cmake_minimum_required (VERSION 3.16)
|
||||||
|
|
||||||
|
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
||||||
|
option(BUILD_VOICE_SUPPORT "Build voice support" ON)
|
||||||
|
option(RUN_LDCONFIG "Run ldconfig after installation" ON)
|
||||||
|
option(DPP_INSTALL "Generate the install target" ON)
|
||||||
|
option(DPP_BUILD_TEST "Build the test program" ON)
|
||||||
|
option(DPP_NO_VCPKG "No VCPKG" OFF)
|
||||||
|
option(DPP_CORO "Experimental support for C++20 coroutines" OFF)
|
||||||
|
option(DPP_USE_EXTERNAL_JSON "Use an external installation of nlohmann::json" OFF)
|
||||||
|
|
||||||
|
include(CheckCXXSymbolExists)
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
add_compile_definitions(DPP_BUILD)
|
||||||
|
|
||||||
|
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/include/dpp/version.h" version_h)
|
||||||
|
|
||||||
|
if(NOT version_h MATCHES "DPP_VERSION_SHORT ([0-9][0-9])([0-9][0-9])([0-9][0-9])")
|
||||||
|
message(FATAL_ERROR "Cannot get DPP_VERSION_SHORT from version.h")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
math(EXPR DPP_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
||||||
|
math(EXPR DPP_VERSION_MINOR "${CMAKE_MATCH_2}")
|
||||||
|
math(EXPR DPP_VERSION_PATCH "${CMAKE_MATCH_3}")
|
||||||
|
|
||||||
|
string(CONCAT DPP_VERSION "${DPP_VERSION_MAJOR}.${DPP_VERSION_MINOR}.${DPP_VERSION_PATCH}")
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/cmake/")
|
||||||
|
|
||||||
|
if (DPP_NO_VCPKG)
|
||||||
|
message("-- INFO: Explicitly disabling VCPKG as running inside the CI action.")
|
||||||
|
else()
|
||||||
|
message("-- INFO: Using VCPKG if detected")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (WIN32 AND NOT MINGW AND BUILD_SHARED_LIBS)
|
||||||
|
message("-- INFO: Configuring .rc resource script")
|
||||||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/dpp/dpp.rc.in" "${CMAKE_CURRENT_SOURCE_DIR}/src/dpp/dpp.rc" NEWLINE_STYLE WIN32)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT DPP_NO_VCPKG AND EXISTS "${_VCPKG_ROOT_DIR}")
|
||||||
|
set(PROJECT_NAME "dpp")
|
||||||
|
project(
|
||||||
|
"${PROJECT_NAME}"
|
||||||
|
VERSION "${DPP_VERSION}"
|
||||||
|
LANGUAGES CXX
|
||||||
|
HOMEPAGE_URL "https://dpp.dev/"
|
||||||
|
DESCRIPTION "An incredibly lightweight C++ Discord library."
|
||||||
|
)
|
||||||
|
add_subdirectory(library-vcpkg)
|
||||||
|
else()
|
||||||
|
set(PROJECT_NAME "libdpp")
|
||||||
|
project(
|
||||||
|
"${PROJECT_NAME}"
|
||||||
|
VERSION "${DPP_VERSION}"
|
||||||
|
LANGUAGES CXX
|
||||||
|
HOMEPAGE_URL "https://dpp.dev/"
|
||||||
|
DESCRIPTION "An incredibly lightweight C++ Discord library."
|
||||||
|
)
|
||||||
|
add_subdirectory(library)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DPP_USE_EXTERNAL_JSON)
|
||||||
|
# We do nothing here, we just assume it is on the include path.
|
||||||
|
# nlohmann::json's cmake stuff does all kinds of weird, and is more hassle than it's worth.
|
||||||
|
# This functionality is here mostly for package maintainers so if you enable it you should
|
||||||
|
# know what you are doing.
|
||||||
|
message("-- Using external nlohmann::json")
|
||||||
|
target_compile_definitions(dpp PUBLIC DPP_USE_EXTERNAL_JSON)
|
||||||
|
else()
|
||||||
|
# Add the nlohmann single include to the include path. Note that nlohmann::json is kinda
|
||||||
|
# fussy, this is an older version because trying to use v3.11.2 gave a bunch of parse errors
|
||||||
|
# that made no sense, it seems they may have changed their parsing rules somehow.
|
||||||
|
message("-- Using bundled nlohmann::json")
|
||||||
|
endif()
|
15
vendor/DPP/CMakeSettings.json
vendored
Normal file
15
vendor/DPP/CMakeSettings.json
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "x64-Debug",
|
||||||
|
"generator": "Ninja",
|
||||||
|
"configurationType": "Release",
|
||||||
|
"inheritEnvironments": [ "msvc_x64_x64" ],
|
||||||
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
|
"cmakeCommandArgs": "",
|
||||||
|
"buildCommandArgs": "",
|
||||||
|
"ctestCommandArgs": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
134
vendor/DPP/CODE_OF_CONDUCT.md
vendored
Normal file
134
vendor/DPP/CODE_OF_CONDUCT.md
vendored
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
|
||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
We as members, contributors, and leaders pledge to make participation in our
|
||||||
|
community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||||
|
identity and expression, level of experience, education, socio-economic status,
|
||||||
|
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||||
|
identity and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||||
|
diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to a positive environment for our
|
||||||
|
community include:
|
||||||
|
|
||||||
|
* Demonstrating empathy and kindness toward other people
|
||||||
|
* Being respectful of differing opinions, viewpoints, and experiences
|
||||||
|
* Giving and gracefully accepting constructive feedback
|
||||||
|
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||||
|
and learning from the experience
|
||||||
|
* Focusing on what is best not just for us as individuals, but for the overall
|
||||||
|
community
|
||||||
|
|
||||||
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery, and sexual attention or advances of
|
||||||
|
any kind
|
||||||
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or email address,
|
||||||
|
without their explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
|
Community leaders are responsible for clarifying and enforcing our standards of
|
||||||
|
acceptable behavior and will take appropriate and fair corrective action in
|
||||||
|
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||||
|
or harmful.
|
||||||
|
|
||||||
|
Community leaders have the right and responsibility to remove, edit, or reject
|
||||||
|
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||||
|
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||||
|
decisions when appropriate.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all community spaces, and also applies when
|
||||||
|
an individual is officially representing the community in public spaces.
|
||||||
|
Examples of representing our community include using an official e-mail address,
|
||||||
|
posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported to the community leaders responsible for enforcement in the
|
||||||
|
[Discord][discord] server.
|
||||||
|
All complaints will be reviewed and investigated promptly and fairly.
|
||||||
|
|
||||||
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
|
reporter of any incident.
|
||||||
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining
|
||||||
|
the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||||
|
unprofessional or unwelcome in the community.
|
||||||
|
|
||||||
|
**Consequence**: A private, written warning from community leaders, providing
|
||||||
|
clarity around the nature of the violation and an explanation of why the
|
||||||
|
behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
|
||||||
|
**Community Impact**: A violation through a single incident or series of
|
||||||
|
actions.
|
||||||
|
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No
|
||||||
|
interaction with the people involved, including unsolicited interaction with
|
||||||
|
those enforcing the Code of Conduct, for a specified period of time. This
|
||||||
|
includes avoiding interactions in community spaces as well as external channels
|
||||||
|
like social media. Violating these terms may lead to a temporary or permanent
|
||||||
|
ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
|
||||||
|
**Community Impact**: A serious violation of community standards, including
|
||||||
|
sustained inappropriate behavior.
|
||||||
|
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public
|
||||||
|
communication with the community for a specified period of time. No public or
|
||||||
|
private interaction with the people involved, including unsolicited interaction
|
||||||
|
with those enforcing the Code of Conduct, is allowed during this period.
|
||||||
|
Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||||
|
community.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||||
|
version 2.1, available at
|
||||||
|
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||||
|
|
||||||
|
Community Impact Guidelines were inspired by
|
||||||
|
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see the FAQ at
|
||||||
|
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||||
|
[https://www.contributor-covenant.org/translations][translations].
|
||||||
|
|
||||||
|
[discord]: https://discord.gg/dpp
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||||
|
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||||
|
[FAQ]: https://www.contributor-covenant.org/faq
|
||||||
|
[translations]: https://www.contributor-covenant.org/translations
|
20
vendor/DPP/CONTRIBUTING.md
vendored
Normal file
20
vendor/DPP/CONTRIBUTING.md
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Contributing
|
||||||
|
|
||||||
|
When contributing to this repository, please do not feel intimidated! We welcome PRs from developers of all levels of experience and we were all new once.
|
||||||
|
|
||||||
|
## Pull Request Process
|
||||||
|
|
||||||
|
1. Pull requests should be made against the `dev` branch.
|
||||||
|
2. Ensure that the changed library can be built on your target system. Do not introduce any platform-
|
||||||
|
specific code.
|
||||||
|
3. Ensure that all methods and functions you add are **fully documented** using doxygen style comments.
|
||||||
|
4. Test your commit! Make a simple single-file test bot to demonstrate the change, include this with the PR
|
||||||
|
as an attached file on a comment, so we can test and see how it works.
|
||||||
|
5. Ensure that you do not break any existing API calls without discussing on Discord first!
|
||||||
|
6. Be sure to follow the coding style guide (if you are not sure, match the code style of existing files
|
||||||
|
including indent style etc).
|
||||||
|
7. Your PR must pass the CI actions before being allowed to be merged. Our PR actions check that the
|
||||||
|
build will compile on various platforms before release and makes precompiled versions of the library.
|
||||||
|
8. If you are on the discord server for the project and your PR is accepted, let a moderator know and we
|
||||||
|
will grant you the 'Contributors' role.
|
||||||
|
|
14
vendor/DPP/Dockerfile
vendored
Normal file
14
vendor/DPP/Dockerfile
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
FROM ubuntu:focal
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
RUN apt-get update && apt-get install --no-install-recommends -y libssl-dev zlib1g-dev libsodium-dev libopus-dev cmake pkg-config g++ gcc git make && apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /usr/src/DPP
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
WORKDIR /usr/src/DPP/build
|
||||||
|
|
||||||
|
RUN cmake .. -DDPP_BUILD_TEST=OFF
|
||||||
|
RUN make -j "$(nproc)"
|
||||||
|
RUN make install
|
2284
vendor/DPP/Doxyfile
vendored
Normal file
2284
vendor/DPP/Doxyfile
vendored
Normal file
File diff suppressed because it is too large
Load Diff
201
vendor/DPP/LICENSE
vendored
Normal file
201
vendor/DPP/LICENSE
vendored
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright 2021 Craig Edwards and D++ Contributors
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
134
vendor/DPP/README.md
vendored
Normal file
134
vendor/DPP/README.md
vendored
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
<div align="center"><img src="docpages/DPP-markdown-logo.png" alt="DPP"/>
|
||||||
|
<h3>An incredibly lightweight C++ Discord library</h3>
|
||||||
|
<br />
|
||||||
|
|
||||||
|
[![Discord](https://img.shields.io/discord/825407338755653642?style=flat)](https://discord.gg/dpp)
|
||||||
|
![Downloads](https://dl.dpp.dev/dlcount.php)
|
||||||
|
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/39b054c38bba411d9b25b39524016c9e)](https://www.codacy.com/gh/brainboxdotcc/DPP/dashboard?utm_source=github.com&utm_medium=referral&utm_content=brainboxdotcc/DPP&utm_campaign=Badge_Grade)
|
||||||
|
![Lines of code](https://img.shields.io/tokei/lines/github/brainboxdotcc/DPP)
|
||||||
|
[![D++ CI](https://github.com/brainboxdotcc/DPP/actions/workflows/ci.yml/badge.svg)](https://github.com/brainboxdotcc/DPP/actions/workflows/ci.yml)
|
||||||
|
[![AUR version](https://img.shields.io/aur/version/dpp)](https://aur.archlinux.org/packages/dpp) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
|
||||||
|
D++ is a lightweight and efficient library for **Discord** written in **modern C++**, covering as much of the API specification as possible with an **incredibly small memory footprint** even when caching large amounts of data.
|
||||||
|
|
||||||
|
### Library features:
|
||||||
|
|
||||||
|
* Support for Discord API v10
|
||||||
|
* Really small memory footprint
|
||||||
|
* Efficient caching system for guilds, channels, guild members, roles, users
|
||||||
|
* Sharding and clustering (Many shards, one process: specify the number of shards, or let the library decide)
|
||||||
|
* Highly optimised ETF (Erlang Term Format) support for very fast websocket throughput
|
||||||
|
* [Slash Commands/Interactions support](https://dpp.dev/slashcommands.html)
|
||||||
|
* [Voice support](https://dpp.dev/soundboard.html) (sending **and** receiving audio)
|
||||||
|
* The entire Discord API is available for use in the library
|
||||||
|
* Stable [Windows support](https://dpp.dev/buildwindows.html)
|
||||||
|
* Ready-made compiled packages for Windows, Raspberry Pi (ARM64/ARM7/ARMv6), Debian x86/x64 and RPM based distributions
|
||||||
|
* Highly scalable for large amounts of guilds and users
|
||||||
|
|
||||||
|
Want to help? Drop me a line or send a PR.
|
||||||
|
|
||||||
|
This library is in use on [TriviaBot](https://triviabot.co.uk/) and [Sporks bot](https://sporks.gg) and many other bots!
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
The documentation is constantly evolving and improving, generated from the code comments and markdown examples using Doxygen.
|
||||||
|
|
||||||
|
#### [View the D++ library documentation](https://dpp.dev/)
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
This is a simple ping-pong example using slash commands.
|
||||||
|
|
||||||
|
```c++
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
dpp::cluster bot(std::getenv("BOT_TOKEN"));
|
||||||
|
|
||||||
|
bot.on_slashcommand([](auto event) {
|
||||||
|
if (event.command.get_command_name() == "ping") {
|
||||||
|
event.reply("Pong!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bot.on_ready([&bot](auto event) {
|
||||||
|
if (dpp::run_once<struct register_bot_commands>()) {
|
||||||
|
bot.global_command_create(
|
||||||
|
dpp::slashcommand("ping", "Ping pong!", bot.me.id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bot.start(dpp::st_wait);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can find more examples in our [example page](https://dpp.dev/md_docpages_03_example_programs.html).
|
||||||
|
|
||||||
|
## Supported Systems
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
The library runs ideally on **Linux**.
|
||||||
|
|
||||||
|
### Mac OS X and FreeBSD
|
||||||
|
The library is well-functional and stable on **Mac OS X** and **FreeBSD** too.
|
||||||
|
|
||||||
|
### Raspberry Pi
|
||||||
|
For running your bot on a **Raspberry Pi**, we offer a prebuilt .deb package for ARM64, ARM6, and ARM7 so that you do not have to wait for it to compile.
|
||||||
|
|
||||||
|
### Windows
|
||||||
|
**Windows** is well-supported with ready-made compiled DLL and LIB files, please check out our [Windows Bot Template repository](https://github.com/brainboxdotcc/windows-bot-template). The Windows Bot repository can be cloned and integrated immediately into any Visual Studio 2019 and 2022 project in a matter of minutes.
|
||||||
|
|
||||||
|
### Other OS
|
||||||
|
The library should work fine on other operating systems as well, and if you run a D++ bot on something not listed here, please let us know!
|
||||||
|
|
||||||
|
## 🤝 Contributing
|
||||||
|
|
||||||
|
Contributions, issues and feature requests are welcome. After cloning and setting up project locally, you can just submit
|
||||||
|
a PR to this repo and it will be deployed once it's accepted.
|
||||||
|
|
||||||
|
Please read the [D++ Code Style Guide](https://dpp.dev/coding-standards.html) for more information on how we format pull requests.
|
||||||
|
|
||||||
|
## 💬 Get in touch
|
||||||
|
|
||||||
|
If you have various suggestions, questions or want to discuss things with our community, [Join our discord server](https://discord.gg/dpp)!
|
||||||
|
Make a humorous reference to brains in your nickname to get access to a secret brain cult channel! :)
|
||||||
|
|
||||||
|
[![Discord](https://img.shields.io/discord/825407338755653642?style=flat)](https://discord.gg/dpp)
|
||||||
|
|
||||||
|
## Show your support
|
||||||
|
|
||||||
|
We love people's support in growing and improving. Be sure to leave a ⭐️ if you like the project and also be sure to contribute, if you're interested!
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
### Build requirements
|
||||||
|
* [cmake](https://cmake.org/) (version 3.13+)
|
||||||
|
* A supported C++ compiler from the list below
|
||||||
|
|
||||||
|
### Supported compilers
|
||||||
|
* [g++](https://gcc.gnu.org) (version 8 or higher)
|
||||||
|
* [clang](https://clang.llvm.org/)
|
||||||
|
* AppleClang (12.0 or higher)
|
||||||
|
* Microsoft Visual Studio 2019 or 2022 (16.x/17.x)
|
||||||
|
* [mingw-w64](https://www.mingw-w64.org/) (gcc version 8 or higher)
|
||||||
|
|
||||||
|
Other compilers may work (either newer versions of those listed above, or different compilers entirely) but have not been tested by us.
|
||||||
|
|
||||||
|
### External Dependencies (You must install these)
|
||||||
|
* [OpenSSL](https://openssl.org/) (whichever `-dev` package comes with your OS)
|
||||||
|
* [zlib](https://zlib.net) (whichever `-dev` package comes with your OS)
|
||||||
|
|
||||||
|
#### Optional Dependencies
|
||||||
|
For voice support you require both of:
|
||||||
|
* [LibOpus](https://www.opus-codec.org)
|
||||||
|
* [libsodium](https://github.com/jedisct1/libsodium)
|
||||||
|
|
||||||
|
### Included Dependencies (Packaged with the library)
|
||||||
|
* [nlohmann::json](https://github.com/nlohmann/json)
|
14
vendor/DPP/SECURITY.md
vendored
Normal file
14
vendor/DPP/SECURITY.md
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
| Version | Supported |
|
||||||
|
| ------- | ------------------ |
|
||||||
|
| 10.0.x | ✅ |
|
||||||
|
| 9.0.x | ⛔ |
|
||||||
|
| 1.0.x | ⛔ |
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
To report a vulnerability please contact the development team confidentially on Discord. We will discuss via a group chat if necessary and action
|
||||||
|
the fix. Once the fix has been put into a release version, the vulnerability will be made public.
|
139
vendor/DPP/buildtools/changelog.php
vendored
Normal file
139
vendor/DPP/buildtools/changelog.php
vendored
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// D++ changelog generator, saves 15 minutes for each release :-)
|
||||||
|
|
||||||
|
// Pattern list
|
||||||
|
$categories = [
|
||||||
|
'break' => '💣 Breaking Changes',
|
||||||
|
'breaking' => '💣 Breaking Changes',
|
||||||
|
'feat' => '✨ New Features',
|
||||||
|
'feature' => '✨ New Features',
|
||||||
|
'add' => '✨ New Features',
|
||||||
|
'added' => '✨ New Features',
|
||||||
|
'fix' => '🐞 Bug Fixes',
|
||||||
|
'bug' => '🐞 Bug Fixes',
|
||||||
|
'bugfix' => '🐞 Bug Fixes',
|
||||||
|
'fixed' => '🐞 Bug Fixes',
|
||||||
|
'fixes' => '🐞 Bug Fixes',
|
||||||
|
'perf' => '🚀 Performance Improvements',
|
||||||
|
'performance' => '🚀 Performance Improvements',
|
||||||
|
'impro' => '♻️ Refactoring',
|
||||||
|
'improved' => '♻️ Refactoring',
|
||||||
|
'improvement' => '♻️ Refactoring',
|
||||||
|
'refactor' => '♻️ Refactoring',
|
||||||
|
'refactored' => '♻️ Refactoring',
|
||||||
|
'deprecated' => '♻️ Refactoring',
|
||||||
|
'deprecate' => '♻️ Refactoring',
|
||||||
|
'remove' => '♻️ Refactoring',
|
||||||
|
'change' => '♻️ Refactoring',
|
||||||
|
'changed' => '♻️ Refactoring',
|
||||||
|
'test' => '🚨 Testing',
|
||||||
|
'tests' => '🚨 Testing',
|
||||||
|
'testing' => '🚨 Testing',
|
||||||
|
'ci' => '👷 Build/CI',
|
||||||
|
'build' => '👷 Build/CI',
|
||||||
|
'docs' => '📚 Documentation',
|
||||||
|
'documentation' => '📚 Documentation',
|
||||||
|
'style' => '💎 Style Changes',
|
||||||
|
'chore' => '🔧 Chore',
|
||||||
|
'misc' => '📜 Miscellaneous Changes',
|
||||||
|
'update' => '📜 Miscellaneous Changes',
|
||||||
|
'updated' => '📜 Miscellaneous Changes',
|
||||||
|
];
|
||||||
|
|
||||||
|
$catgroup = [];
|
||||||
|
$changelog = [];
|
||||||
|
$githubstyle = true;
|
||||||
|
if (count($argv) > 2 && $argv[1] == '--discord') {
|
||||||
|
$githubstyle = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Magic sauce
|
||||||
|
exec("git log --format=\"%s\" $(git log --no-walk --tags | head -n1 | cut -d ' ' -f 2)..HEAD | grep -v '^Merge '", $changelog);
|
||||||
|
|
||||||
|
// Leadin
|
||||||
|
if ($githubstyle) {
|
||||||
|
echo "The changelog is listed below:\n\nRelease Changelog\n===========\n";
|
||||||
|
} else {
|
||||||
|
echo "The changelog is listed below:\n\n__**Release Changelog**__\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Case insensitive removal of duplicates
|
||||||
|
$changelog = array_intersect_key($changelog, array_unique(array_map("strtolower", $changelog)));
|
||||||
|
|
||||||
|
// remove duplicates where two entries are the same but one ends with a GitHub pull request link
|
||||||
|
foreach ($changelog as $item) {
|
||||||
|
$entryWithoutPrLink = preg_replace('/( \(#\d+\))$/', '', $item);
|
||||||
|
if ($entryWithoutPrLink === $item) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if $item ends with (#123)
|
||||||
|
foreach ($changelog as $key => $change) {
|
||||||
|
if ($entryWithoutPrLink === $change) {
|
||||||
|
unset($changelog[$key]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($changelog as $change) {
|
||||||
|
|
||||||
|
// Wrap anything that looks like a symbol name in backticks
|
||||||
|
$change = preg_replace('/([a-zA-Z][\w_\/\-]+\.\w+|\S+\(\)|\w+::\w+|dpp::\w+|utility::\w+|(\w+_\w+)+)/', '`$1`', $change);
|
||||||
|
$change = preg_replace("/vs(\d+)/", "Visual Studio $1", $change);
|
||||||
|
$change = preg_replace("/\bfaq\b/", "FAQ", $change);
|
||||||
|
$change = preg_replace("/\bdiscord\b/", "Discord", $change);
|
||||||
|
$change = preg_replace("/\bmicrosoft\b/", "Microsoft", $change);
|
||||||
|
$change = preg_replace("/\bwindows\b/", "Windows", $change);
|
||||||
|
$change = preg_replace("/\blinux\b/", "Linux", $change);
|
||||||
|
$change = preg_replace("/\sarm(\d+)\s/i", ' ARM$1 ', $change);
|
||||||
|
$change = preg_replace("/\b(was|is|wo)nt\b/i", '$1n\'t', $change);
|
||||||
|
$change = preg_replace("/\bfreebsd\b/", 'FreeBSD', $change);
|
||||||
|
$change = preg_replace("/``/", "`", $change);
|
||||||
|
|
||||||
|
// Match keywords against categories
|
||||||
|
$matched = false;
|
||||||
|
foreach ($categories as $cat => $header) {
|
||||||
|
// Purposefully ignored: comments that are one word, merge commits, and version bumps
|
||||||
|
if (strpos($change, ' ') === false || preg_match("/^Merge (branch|pull request|remote-tracking branch) /", $change) || preg_match("/version bump/i", $change)) {
|
||||||
|
$matched = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Groupings
|
||||||
|
if ((preg_match("/^" . $cat . ":/i", $change)) || (preg_match("/^\[" . $cat . "\//i", $change)) || (preg_match("/^\[" . $cat . "\]/i", $change)) || (preg_match("/^\[" . $cat . ":/i", $change)) || (preg_match("/^" . $cat . "\//i", $change)) || (preg_match("/^" . $cat . ":/i", $change))) {
|
||||||
|
if (!isset($catgroup[$header])) {
|
||||||
|
$catgroup[$header] = [];
|
||||||
|
}
|
||||||
|
$matched = true;
|
||||||
|
$catgroup[$header][] = preg_replace("/^\S+\s+/", "", $change);
|
||||||
|
break;
|
||||||
|
} else if (preg_match("/^" . $cat . " /i", $change)) {
|
||||||
|
if (!isset($catgroup[$header])) {
|
||||||
|
$catgroup[$header] = [];
|
||||||
|
}
|
||||||
|
$matched = true;
|
||||||
|
$catgroup[$header][] = $change;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output tidy formatting
|
||||||
|
foreach ($catgroup as $cat => $list) {
|
||||||
|
echo "\n" . ($githubstyle ? '## ' : '__**') . $cat . ($githubstyle ? '' : '**__') . "\n";
|
||||||
|
foreach ($list as $item) {
|
||||||
|
// Exclude bad commit messages like 'typo fix', 'test push' etc by pattern
|
||||||
|
if (!preg_match("/^(typo|test|fix)\s\w+$/", $item) && strpos($item, ' ') !== false) {
|
||||||
|
echo ($githubstyle ? '-' : '•') . ' ' . ucfirst(str_replace('@', '', $item)) . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Leadout
|
||||||
|
echo "\n\n**Thank you for using D++!**\n\n";
|
||||||
|
if (!$githubstyle) {
|
||||||
|
$version = $argv[2];
|
||||||
|
echo 'The ' . $version . ' download can be found here: <https://dl.dpp.dev/' . $version . '>';
|
||||||
|
echo "\n";
|
||||||
|
}
|
131
vendor/DPP/buildtools/classes/Generator/CoroGenerator.php
vendored
Normal file
131
vendor/DPP/buildtools/classes/Generator/CoroGenerator.php
vendored
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Dpp\Generator;
|
||||||
|
|
||||||
|
use Dpp\StructGeneratorInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate header and .cpp file for coroutine calls (starting with 'co_')
|
||||||
|
*/
|
||||||
|
class CoroGenerator implements StructGeneratorInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function generateHeaderStart(): string
|
||||||
|
{
|
||||||
|
return <<<EOT
|
||||||
|
/************************************************************************************
|
||||||
|
*
|
||||||
|
* D++, A Lightweight C++ library for Discord
|
||||||
|
*
|
||||||
|
* Copyright 2022 Craig Edwards and D++ contributors
|
||||||
|
* (https://github.com/brainboxdotcc/DPP/graphs/contributors)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/* Auto @generated by buildtools/make_coro_struct.php.
|
||||||
|
*
|
||||||
|
* DO NOT EDIT BY HAND!
|
||||||
|
*
|
||||||
|
* To re-generate this header file re-run the script!
|
||||||
|
*/
|
||||||
|
|
||||||
|
EOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function generateCppStart(): string
|
||||||
|
{
|
||||||
|
return $this->generateHeaderStart() . <<<EOT
|
||||||
|
|
||||||
|
#include <dpp/export.h>
|
||||||
|
#include <dpp/snowflake.h>
|
||||||
|
#include <dpp/cluster.h>
|
||||||
|
#include <dpp/coro.h>
|
||||||
|
|
||||||
|
namespace dpp {
|
||||||
|
|
||||||
|
|
||||||
|
EOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function checkForChanges(): bool
|
||||||
|
{
|
||||||
|
/* Check if we need to re-generate by comparing modification times */
|
||||||
|
$us = file_exists('include/dpp/cluster_coro_calls.h') ? filemtime('include/dpp/cluster_coro_calls.h') : 0;
|
||||||
|
$them = filemtime('include/dpp/cluster.h');
|
||||||
|
if ($them <= $us) {
|
||||||
|
echo "-- No change required.\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "-- Autogenerating include/dpp/cluster_coro_calls.h\n";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function generateHeaderDef(string $returnType, string $currentFunction, string $parameters, string $noDefaults, string $parameterNames): string
|
||||||
|
{
|
||||||
|
$parameterNames = preg_replace('/^, /', '', $parameterNames);
|
||||||
|
if (!empty($parameterNames)) {
|
||||||
|
$parameterNames .= ', ';
|
||||||
|
}
|
||||||
|
return "auto inline co_{$currentFunction}($noDefaults) {\n\treturn dpp::awaitable(this, [&] (auto cc) { this->$currentFunction({$parameterNames}cc); }); \n}\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function generateCppDef(string $returnType, string $currentFunction, string $parameters, string $noDefaults, string $parameterNames): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getCommentArray(): array
|
||||||
|
{
|
||||||
|
return [" * \memberof dpp::cluster"];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function saveHeader(string $content): void
|
||||||
|
{
|
||||||
|
$content .= "auto inline co_request(const std::string &url, http_method method, const std::string &postdata = \"\", const std::string &mimetype = \"text/plain\", const std::multimap<std::string, std::string> &headers = {}) {\n\treturn dpp::awaitable(this, [&] (auto cc) { this->request(url, method, cc, mimetype, headers); }); \n}\n\n";
|
||||||
|
file_put_contents('include/dpp/cluster_coro_calls.h', $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function saveCpp(string $cppcontent): void
|
||||||
|
{
|
||||||
|
/* No cpp file to save, code is all inline */
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
130
vendor/DPP/buildtools/classes/Generator/SyncGenerator.php
vendored
Normal file
130
vendor/DPP/buildtools/classes/Generator/SyncGenerator.php
vendored
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Dpp\Generator;
|
||||||
|
|
||||||
|
use Dpp\StructGeneratorInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate header and .cpp file for synchronous calls (ending in '_sync')
|
||||||
|
*/
|
||||||
|
class SyncGenerator implements StructGeneratorInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function generateHeaderStart(): string
|
||||||
|
{
|
||||||
|
return <<<EOT
|
||||||
|
/************************************************************************************
|
||||||
|
*
|
||||||
|
* D++, A Lightweight C++ library for Discord
|
||||||
|
*
|
||||||
|
* Copyright 2022 Craig Edwards and D++ contributors
|
||||||
|
* (https://github.com/brainboxdotcc/DPP/graphs/contributors)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/* Auto @generated by buildtools/make_sync_struct.php.
|
||||||
|
*
|
||||||
|
* DO NOT EDIT BY HAND!
|
||||||
|
*
|
||||||
|
* To re-generate this header file re-run the script!
|
||||||
|
*/
|
||||||
|
|
||||||
|
EOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function generateCppStart(): string
|
||||||
|
{
|
||||||
|
return $this->generateHeaderStart() . <<<EOT
|
||||||
|
|
||||||
|
#include <dpp/export.h>
|
||||||
|
#include <dpp/snowflake.h>
|
||||||
|
#include <dpp/cluster.h>
|
||||||
|
|
||||||
|
namespace dpp {
|
||||||
|
|
||||||
|
|
||||||
|
EOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function checkForChanges(): bool
|
||||||
|
{
|
||||||
|
/* Check if we need to re-generate by comparing modification times */
|
||||||
|
$us = file_exists('include/dpp/cluster_sync_calls.h') ? filemtime('include/dpp/cluster_sync_calls.h') : 0;
|
||||||
|
$them = filemtime('include/dpp/cluster.h');
|
||||||
|
if ($them <= $us) {
|
||||||
|
echo "-- No change required.\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "-- Autogenerating include/dpp/cluster_sync_calls.h\n";
|
||||||
|
echo "-- Autogenerating src/dpp/cluster_sync_calls.cpp\n";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function generateHeaderDef(string $returnType, string $currentFunction, string $parameters, string $noDefaults, string $parameterNames): string
|
||||||
|
{
|
||||||
|
return "$returnType {$currentFunction}_sync($parameters);\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function generateCppDef(string $returnType, string $currentFunction, string $parameters, string $noDefaults, string $parameterNames): string
|
||||||
|
{
|
||||||
|
return "$returnType cluster::{$currentFunction}_sync($noDefaults) {\n\treturn dpp::sync<$returnType>(this, &cluster::$currentFunction$parameterNames);\n}\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getCommentArray(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
" * \memberof dpp::cluster",
|
||||||
|
" * @throw dpp::rest_exception upon failure to execute REST function",
|
||||||
|
" * @warning This function is a blocking (synchronous) call and should only be used from within a separate thread.",
|
||||||
|
" * Avoid direct use of this function inside an event handler.",
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function saveHeader(string $content): void
|
||||||
|
{
|
||||||
|
file_put_contents('include/dpp/cluster_sync_calls.h', $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function saveCpp(string $cppcontent): void
|
||||||
|
{
|
||||||
|
file_put_contents('src/dpp/cluster_sync_calls.cpp', $cppcontent);
|
||||||
|
}
|
||||||
|
}
|
75
vendor/DPP/buildtools/classes/StructGeneratorInterface.php
vendored
Normal file
75
vendor/DPP/buildtools/classes/StructGeneratorInterface.php
vendored
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Dpp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a header/cpp generator used to auto-generate cpp/.h files.
|
||||||
|
*/
|
||||||
|
interface StructGeneratorInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Generate the start of the header file
|
||||||
|
*
|
||||||
|
* @return string header content
|
||||||
|
*/
|
||||||
|
public function generateHeaderStart(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the start of the cpp file
|
||||||
|
*
|
||||||
|
* @return string cpp content
|
||||||
|
*/
|
||||||
|
public function generateCppStart(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the script should run and re-generate content or not
|
||||||
|
*
|
||||||
|
* @return string true if the script should run, false to exit
|
||||||
|
*/
|
||||||
|
public function checkForchanges(): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate header definition for a function
|
||||||
|
*
|
||||||
|
* @param string $returnType Return type of function
|
||||||
|
* @param string $currentFunction Current function name
|
||||||
|
* @param string $parameters Current function parameters with default values
|
||||||
|
* @param string $noDefaults Current function parameters without default values
|
||||||
|
* @param string $parameterNames Parameter names only
|
||||||
|
* @return string header content to append
|
||||||
|
*/
|
||||||
|
public function generateHeaderDef(string $returnType, string $currentFunction, string $parameters, string $noDefaults, string $parameterNames): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate cpp definition for a function
|
||||||
|
*
|
||||||
|
* @param string $returnType Return type of function
|
||||||
|
* @param string $currentFunction Current function name
|
||||||
|
* @param string $parameters Current function parameters with default values
|
||||||
|
* @param string $noDefaults Current function parameters without default values
|
||||||
|
* @param string $parameterNames Parameter names only
|
||||||
|
* @return string cpp content to append
|
||||||
|
*/
|
||||||
|
public function generateCppDef(string $returnType, string $currentFunction, string $parameters, string $noDefaults, string $parameterNames): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return comment lines to add to each header definition
|
||||||
|
*
|
||||||
|
* @return array Comment lines to add
|
||||||
|
*/
|
||||||
|
public function getCommentArray(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save the .h file
|
||||||
|
*
|
||||||
|
* @param string $content Content to save
|
||||||
|
*/
|
||||||
|
public function saveHeader(string $content): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save the .cpp file
|
||||||
|
*
|
||||||
|
* @param string $cppcontent Content to save
|
||||||
|
*/
|
||||||
|
public function saveCpp(string $cppcontent): void;
|
||||||
|
};
|
31
vendor/DPP/buildtools/close-master-pr.php
vendored
Normal file
31
vendor/DPP/buildtools/close-master-pr.php
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// Comment on and close all PRs targeted at master branch
|
||||||
|
|
||||||
|
// Magic sauce
|
||||||
|
exec("gh pr list --base master | sed 's/\|/ /' |awk '{print $1}'", $master_prs);
|
||||||
|
|
||||||
|
foreach ($master_prs as $pr) {
|
||||||
|
$pr = (int)$pr;
|
||||||
|
if ($pr > 0) {
|
||||||
|
system("gh pr comment $pr -b \"You have opened a PR against the master branch. PRs must target the \`dev\` branch, as such this PR has been automatically closed. Please re-target your PR against the dev branch if you reopen it. Thank you for your contribution.\"");
|
||||||
|
system("gh pr close $pr");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tidy up the workflow run list so it isn't littered with these
|
||||||
|
exec("gh run list -w \"Close master-targeted PRs\"", $runs);
|
||||||
|
$runindex = 0;
|
||||||
|
foreach ($runs as $run) {
|
||||||
|
$run = preg_replace('/ /', ' ', $run);
|
||||||
|
$data = preg_split('/\s+/', $run);
|
||||||
|
$id = $data[sizeof($data) - 3];
|
||||||
|
$id = (int)$id;
|
||||||
|
if ($id > 0 && $runindex > 0) {
|
||||||
|
// Delete all but the first completed workflow run and this one
|
||||||
|
// (the first is the currently executing one!)
|
||||||
|
exec("gh api repos/brainboxdotcc/DPP/actions/runs/$id -X DELETE");
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
$runindex++;
|
||||||
|
}
|
17
vendor/DPP/buildtools/composer.json
vendored
Normal file
17
vendor/DPP/buildtools/composer.json
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "brainboxdotcc/dpp",
|
||||||
|
"description": "DPP Build Tools",
|
||||||
|
"type": "project",
|
||||||
|
"license": "Apache 2.0",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Dpp\\": "classes/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "brain"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {}
|
||||||
|
}
|
185
vendor/DPP/buildtools/make_struct.php
vendored
Normal file
185
vendor/DPP/buildtools/make_struct.php
vendored
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
chdir('buildtools');
|
||||||
|
|
||||||
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
|
|
||||||
|
use Dpp\StructGeneratorInterface;
|
||||||
|
|
||||||
|
if (count($argv) < 2) {
|
||||||
|
die("You must specify a generator type\n");
|
||||||
|
} else {
|
||||||
|
$generatorName = $argv[1];
|
||||||
|
$generator = new $generatorName();
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir('..');
|
||||||
|
|
||||||
|
/* Get the content of all cluster source files into an array */
|
||||||
|
exec("cat src/dpp/cluster/*.cpp", $clustercpp);
|
||||||
|
|
||||||
|
/* These methods have signatures incompatible with this script */
|
||||||
|
$blacklist = [
|
||||||
|
'channel_edit_permissions',
|
||||||
|
'message_add_reaction',
|
||||||
|
'message_delete_reaction',
|
||||||
|
'message_delete_reaction_emoji',
|
||||||
|
'message_delete_all_reactions',
|
||||||
|
'message_delete_own_reaction',
|
||||||
|
'message_get_reactions',
|
||||||
|
'channel_typing',
|
||||||
|
'application_role_connection_get', // TODO: rest_request_vector
|
||||||
|
'application_role_connection_update',
|
||||||
|
];
|
||||||
|
|
||||||
|
/* The script cannot determine the correct return type of these methods,
|
||||||
|
* so we specify it by hand here.
|
||||||
|
*/
|
||||||
|
$forcedReturn = [
|
||||||
|
'direct_message_create' => 'message',
|
||||||
|
'guild_get_members' => 'guild_member_map',
|
||||||
|
'guild_search_members' => 'guild_member_map',
|
||||||
|
'message_create' => 'message',
|
||||||
|
'message_edit' => 'message',
|
||||||
|
'thread_create_in_forum' => 'thread',
|
||||||
|
];
|
||||||
|
|
||||||
|
/* Get the contents of cluster.h into an array */
|
||||||
|
$header = explode("\n", file_get_contents('include/dpp/cluster.h'));
|
||||||
|
|
||||||
|
/* Finite state machine state constants */
|
||||||
|
const STATE_SEARCH_FOR_FUNCTION = 0;
|
||||||
|
const STATE_IN_FUNCTION = 1;
|
||||||
|
const STATE_END_OF_FUNCTION = 2;
|
||||||
|
|
||||||
|
$state = STATE_SEARCH_FOR_FUNCTION;
|
||||||
|
$currentFunction = $parameters = $returnType = '';
|
||||||
|
$content = $generator->generateHeaderStart();
|
||||||
|
$cppcontent = $generator->generatecppStart();
|
||||||
|
|
||||||
|
if (!$generator->checkForChanges()) {
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Scan every line of the C++ source */
|
||||||
|
foreach ($clustercpp as $cpp) {
|
||||||
|
/* Look for declaration of function body */
|
||||||
|
if ($state == STATE_SEARCH_FOR_FUNCTION &&
|
||||||
|
preg_match('/^\s*void\s+cluster::([^(]+)\s*\((.*)command_completion_event_t\s*callback\s*\)/', $cpp, $matches)) {
|
||||||
|
$currentFunction = $matches[1];
|
||||||
|
$parameters = preg_replace('/,\s*$/', '', $matches[2]);
|
||||||
|
if (!in_array($currentFunction, $blacklist)) {
|
||||||
|
$state = STATE_IN_FUNCTION;
|
||||||
|
}
|
||||||
|
/* Scan function body */
|
||||||
|
} elseif ($state == STATE_IN_FUNCTION) {
|
||||||
|
/* End of function */
|
||||||
|
if (preg_match('/^\}\s*$/', $cpp)) {
|
||||||
|
$state = STATE_END_OF_FUNCTION;
|
||||||
|
/* look for the return type of the method */
|
||||||
|
} elseif (preg_match('/rest_request<([^>]+)>/', $cpp, $matches)) {
|
||||||
|
/* rest_request<T> */
|
||||||
|
$returnType = $matches[1];
|
||||||
|
} elseif (preg_match('/rest_request_list<([^>]+)>/', $cpp, $matches)) {
|
||||||
|
/* rest_request_list<T> */
|
||||||
|
$returnType = $matches[1] . '_map';
|
||||||
|
} elseif (preg_match('/callback\(confirmation_callback_t\(\w+, ([^(]+)\(.*, \w+\)\)/', $cpp, $matches)) {
|
||||||
|
/* confirmation_callback_t */
|
||||||
|
$returnType = $matches[1];
|
||||||
|
} elseif (!empty($forcedReturn[$currentFunction])) {
|
||||||
|
/* Forced return type */
|
||||||
|
$returnType = $forcedReturn[$currentFunction];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Completed parsing of function body */
|
||||||
|
if ($state == STATE_END_OF_FUNCTION && !empty($currentFunction) && !empty($returnType)) {
|
||||||
|
if (!in_array($currentFunction, $blacklist)) {
|
||||||
|
$parameterList = explode(',', $parameters);
|
||||||
|
$parameterNames = [];
|
||||||
|
foreach ($parameterList as $parameter) {
|
||||||
|
$parts = explode(' ', trim($parameter));
|
||||||
|
$parameterNames[] = trim(preg_replace('/[\s\*\&]+/', '', $parts[count($parts) - 1]));
|
||||||
|
}
|
||||||
|
$content .= getComments($generator, $currentFunction, $returnType, $parameterNames) . "\n";
|
||||||
|
$fullParameters = getFullParameters($currentFunction, $parameterNames);
|
||||||
|
$parameterNames = trim(join(', ', $parameterNames));
|
||||||
|
if (!empty($parameterNames)) {
|
||||||
|
$parameterNames = ', ' . $parameterNames;
|
||||||
|
}
|
||||||
|
$noDefaults = $parameters;
|
||||||
|
$parameters = !empty($fullParameters) ? $fullParameters : $parameters;
|
||||||
|
$content .= $generator->generateHeaderDef($returnType, $currentFunction, $parameters, $noDefaults, $parameterNames);
|
||||||
|
$cppcontent .= $generator->generateCppDef($returnType, $currentFunction, $parameters, $noDefaults, $parameterNames);
|
||||||
|
}
|
||||||
|
$currentFunction = $parameters = $returnType = '';
|
||||||
|
$state = STATE_SEARCH_FOR_FUNCTION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$content .= <<<EOT
|
||||||
|
|
||||||
|
/* End of auto-generated definitions */
|
||||||
|
|
||||||
|
EOT;
|
||||||
|
$cppcontent .= <<<EOT
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/* End of auto-generated definitions */
|
||||||
|
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get parameters of a function with defaults
|
||||||
|
* @param string $currentFunction Current function name
|
||||||
|
* @param array $parameters Parameter names
|
||||||
|
* @return string Parameter list
|
||||||
|
*/
|
||||||
|
function getFullParameters(string $currentFunction, array $parameters): string
|
||||||
|
{
|
||||||
|
global $header;
|
||||||
|
foreach ($header as $line) {
|
||||||
|
if (preg_match('/^\s*void\s+' . $currentFunction . '\s*\((.*' . join('.*', $parameters) . '.*)command_completion_event_t\s*callback\s*/', $line, $matches)) {
|
||||||
|
return preg_replace('/,\s*$/', '', $matches[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the comment block of a function.
|
||||||
|
* Adds see/return doxygen tags
|
||||||
|
* @param string $currentFunction function name
|
||||||
|
* @param string $returnType Return type of function
|
||||||
|
* @param array $parameters Parameter names
|
||||||
|
* @return string Comment block
|
||||||
|
*/
|
||||||
|
function getComments(StructGeneratorInterface $generator, string $currentFunction, string $returnType, array $parameters): string
|
||||||
|
{
|
||||||
|
global $header;
|
||||||
|
/* First find the function */
|
||||||
|
foreach ($header as $i => $line) {
|
||||||
|
if (preg_match('/^\s*void\s+' . $currentFunction . '\s*\(.*' . join('.*', $parameters) . '.*command_completion_event_t\s*callback\s*/', $line)) {
|
||||||
|
/* Backpeddle */
|
||||||
|
$lineIndex = 1;
|
||||||
|
for ($n = $i; $n != 0; --$n, $lineIndex++) {
|
||||||
|
$header[$n] = preg_replace('/^\t+/', '', $header[$n]);
|
||||||
|
$header[$n] = preg_replace('/@see (.+?)$/', '@see dpp::cluster::' . $currentFunction . "\n * @see \\1", $header[$n]);
|
||||||
|
$header[$n] = preg_replace('/@param callback .*$/', '@return ' . $returnType . ' returned object on completion', $header[$n]);
|
||||||
|
if (preg_match('/\s*\* On success /i', $header[$n])) {
|
||||||
|
$header[$n] = "";
|
||||||
|
}
|
||||||
|
if (preg_match('/\s*\/\*\*\s*$/', $header[$n])) {
|
||||||
|
$part = array_slice($header, $n, $lineIndex - 1);
|
||||||
|
array_splice($part, count($part) - 1, 0, $generator->getCommentArray());
|
||||||
|
return str_replace("\n\n", "\n", join("\n", $part));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Finished parsing, output autogenerated files */
|
||||||
|
$generator->saveHeader($content);
|
||||||
|
$generator->savecpp($cppcontent);
|
12
vendor/DPP/buildtools/vendor/autoload.php
vendored
Normal file
12
vendor/DPP/buildtools/vendor/autoload.php
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload.php @generated by Composer
|
||||||
|
|
||||||
|
if (PHP_VERSION_ID < 50600) {
|
||||||
|
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once __DIR__ . '/composer/autoload_real.php';
|
||||||
|
|
||||||
|
return ComposerAutoloaderInit0e8415491642f27914717986db49b1db::getLoader();
|
572
vendor/DPP/buildtools/vendor/composer/ClassLoader.php
vendored
Normal file
572
vendor/DPP/buildtools/vendor/composer/ClassLoader.php
vendored
Normal file
@ -0,0 +1,572 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Composer.
|
||||||
|
*
|
||||||
|
* (c) Nils Adermann <naderman@naderman.de>
|
||||||
|
* Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||||
|
*
|
||||||
|
* $loader = new \Composer\Autoload\ClassLoader();
|
||||||
|
*
|
||||||
|
* // register classes with namespaces
|
||||||
|
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||||
|
* $loader->add('Symfony', __DIR__.'/framework');
|
||||||
|
*
|
||||||
|
* // activate the autoloader
|
||||||
|
* $loader->register();
|
||||||
|
*
|
||||||
|
* // to enable searching the include path (eg. for PEAR packages)
|
||||||
|
* $loader->setUseIncludePath(true);
|
||||||
|
*
|
||||||
|
* In this example, if you try to use a class in the Symfony\Component
|
||||||
|
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||||
|
* the autoloader will first look for the class under the component/
|
||||||
|
* directory, and it will then fallback to the framework/ directory if not
|
||||||
|
* found before giving up.
|
||||||
|
*
|
||||||
|
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||||
|
*
|
||||||
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
|
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||||
|
* @see https://www.php-fig.org/psr/psr-0/
|
||||||
|
* @see https://www.php-fig.org/psr/psr-4/
|
||||||
|
*/
|
||||||
|
class ClassLoader
|
||||||
|
{
|
||||||
|
/** @var ?string */
|
||||||
|
private $vendorDir;
|
||||||
|
|
||||||
|
// PSR-4
|
||||||
|
/**
|
||||||
|
* @var array[]
|
||||||
|
* @psalm-var array<string, array<string, int>>
|
||||||
|
*/
|
||||||
|
private $prefixLengthsPsr4 = array();
|
||||||
|
/**
|
||||||
|
* @var array[]
|
||||||
|
* @psalm-var array<string, array<int, string>>
|
||||||
|
*/
|
||||||
|
private $prefixDirsPsr4 = array();
|
||||||
|
/**
|
||||||
|
* @var array[]
|
||||||
|
* @psalm-var array<string, string>
|
||||||
|
*/
|
||||||
|
private $fallbackDirsPsr4 = array();
|
||||||
|
|
||||||
|
// PSR-0
|
||||||
|
/**
|
||||||
|
* @var array[]
|
||||||
|
* @psalm-var array<string, array<string, string[]>>
|
||||||
|
*/
|
||||||
|
private $prefixesPsr0 = array();
|
||||||
|
/**
|
||||||
|
* @var array[]
|
||||||
|
* @psalm-var array<string, string>
|
||||||
|
*/
|
||||||
|
private $fallbackDirsPsr0 = array();
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
|
private $useIncludePath = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string[]
|
||||||
|
* @psalm-var array<string, string>
|
||||||
|
*/
|
||||||
|
private $classMap = array();
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
|
private $classMapAuthoritative = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool[]
|
||||||
|
* @psalm-var array<string, bool>
|
||||||
|
*/
|
||||||
|
private $missingClasses = array();
|
||||||
|
|
||||||
|
/** @var ?string */
|
||||||
|
private $apcuPrefix;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var self[]
|
||||||
|
*/
|
||||||
|
private static $registeredLoaders = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ?string $vendorDir
|
||||||
|
*/
|
||||||
|
public function __construct($vendorDir = null)
|
||||||
|
{
|
||||||
|
$this->vendorDir = $vendorDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[]
|
||||||
|
*/
|
||||||
|
public function getPrefixes()
|
||||||
|
{
|
||||||
|
if (!empty($this->prefixesPsr0)) {
|
||||||
|
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
||||||
|
}
|
||||||
|
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array[]
|
||||||
|
* @psalm-return array<string, array<int, string>>
|
||||||
|
*/
|
||||||
|
public function getPrefixesPsr4()
|
||||||
|
{
|
||||||
|
return $this->prefixDirsPsr4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array[]
|
||||||
|
* @psalm-return array<string, string>
|
||||||
|
*/
|
||||||
|
public function getFallbackDirs()
|
||||||
|
{
|
||||||
|
return $this->fallbackDirsPsr0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array[]
|
||||||
|
* @psalm-return array<string, string>
|
||||||
|
*/
|
||||||
|
public function getFallbackDirsPsr4()
|
||||||
|
{
|
||||||
|
return $this->fallbackDirsPsr4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string[] Array of classname => path
|
||||||
|
* @psalm-return array<string, string>
|
||||||
|
*/
|
||||||
|
public function getClassMap()
|
||||||
|
{
|
||||||
|
return $this->classMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string[] $classMap Class to filename map
|
||||||
|
* @psalm-param array<string, string> $classMap
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function addClassMap(array $classMap)
|
||||||
|
{
|
||||||
|
if ($this->classMap) {
|
||||||
|
$this->classMap = array_merge($this->classMap, $classMap);
|
||||||
|
} else {
|
||||||
|
$this->classMap = $classMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-0 directories for a given prefix, either
|
||||||
|
* appending or prepending to the ones previously set for this prefix.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix
|
||||||
|
* @param string[]|string $paths The PSR-0 root directories
|
||||||
|
* @param bool $prepend Whether to prepend the directories
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function add($prefix, $paths, $prepend = false)
|
||||||
|
{
|
||||||
|
if (!$prefix) {
|
||||||
|
if ($prepend) {
|
||||||
|
$this->fallbackDirsPsr0 = array_merge(
|
||||||
|
(array) $paths,
|
||||||
|
$this->fallbackDirsPsr0
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->fallbackDirsPsr0 = array_merge(
|
||||||
|
$this->fallbackDirsPsr0,
|
||||||
|
(array) $paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$first = $prefix[0];
|
||||||
|
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||||
|
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($prepend) {
|
||||||
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||||
|
(array) $paths,
|
||||||
|
$this->prefixesPsr0[$first][$prefix]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||||
|
$this->prefixesPsr0[$first][$prefix],
|
||||||
|
(array) $paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-4 directories for a given namespace, either
|
||||||
|
* appending or prepending to the ones previously set for this namespace.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
|
* @param string[]|string $paths The PSR-4 base directories
|
||||||
|
* @param bool $prepend Whether to prepend the directories
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function addPsr4($prefix, $paths, $prepend = false)
|
||||||
|
{
|
||||||
|
if (!$prefix) {
|
||||||
|
// Register directories for the root namespace.
|
||||||
|
if ($prepend) {
|
||||||
|
$this->fallbackDirsPsr4 = array_merge(
|
||||||
|
(array) $paths,
|
||||||
|
$this->fallbackDirsPsr4
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$this->fallbackDirsPsr4 = array_merge(
|
||||||
|
$this->fallbackDirsPsr4,
|
||||||
|
(array) $paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||||
|
// Register directories for a new namespace.
|
||||||
|
$length = strlen($prefix);
|
||||||
|
if ('\\' !== $prefix[$length - 1]) {
|
||||||
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||||
|
}
|
||||||
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||||
|
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||||
|
} elseif ($prepend) {
|
||||||
|
// Prepend directories for an already registered namespace.
|
||||||
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||||
|
(array) $paths,
|
||||||
|
$this->prefixDirsPsr4[$prefix]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Append directories for an already registered namespace.
|
||||||
|
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||||
|
$this->prefixDirsPsr4[$prefix],
|
||||||
|
(array) $paths
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-0 directories for a given prefix,
|
||||||
|
* replacing any others previously set for this prefix.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix
|
||||||
|
* @param string[]|string $paths The PSR-0 base directories
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function set($prefix, $paths)
|
||||||
|
{
|
||||||
|
if (!$prefix) {
|
||||||
|
$this->fallbackDirsPsr0 = (array) $paths;
|
||||||
|
} else {
|
||||||
|
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a set of PSR-4 directories for a given namespace,
|
||||||
|
* replacing any others previously set for this namespace.
|
||||||
|
*
|
||||||
|
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||||
|
* @param string[]|string $paths The PSR-4 base directories
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setPsr4($prefix, $paths)
|
||||||
|
{
|
||||||
|
if (!$prefix) {
|
||||||
|
$this->fallbackDirsPsr4 = (array) $paths;
|
||||||
|
} else {
|
||||||
|
$length = strlen($prefix);
|
||||||
|
if ('\\' !== $prefix[$length - 1]) {
|
||||||
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||||
|
}
|
||||||
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||||
|
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns on searching the include path for class files.
|
||||||
|
*
|
||||||
|
* @param bool $useIncludePath
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setUseIncludePath($useIncludePath)
|
||||||
|
{
|
||||||
|
$this->useIncludePath = $useIncludePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Can be used to check if the autoloader uses the include path to check
|
||||||
|
* for classes.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getUseIncludePath()
|
||||||
|
{
|
||||||
|
return $this->useIncludePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns off searching the prefix and fallback directories for classes
|
||||||
|
* that have not been registered with the class map.
|
||||||
|
*
|
||||||
|
* @param bool $classMapAuthoritative
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||||
|
{
|
||||||
|
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should class lookup fail if not found in the current class map?
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isClassMapAuthoritative()
|
||||||
|
{
|
||||||
|
return $this->classMapAuthoritative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||||
|
*
|
||||||
|
* @param string|null $apcuPrefix
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setApcuPrefix($apcuPrefix)
|
||||||
|
{
|
||||||
|
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The APCu prefix in use, or null if APCu caching is not enabled.
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
*/
|
||||||
|
public function getApcuPrefix()
|
||||||
|
{
|
||||||
|
return $this->apcuPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers this instance as an autoloader.
|
||||||
|
*
|
||||||
|
* @param bool $prepend Whether to prepend the autoloader or not
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register($prepend = false)
|
||||||
|
{
|
||||||
|
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||||
|
|
||||||
|
if (null === $this->vendorDir) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($prepend) {
|
||||||
|
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
||||||
|
} else {
|
||||||
|
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||||
|
self::$registeredLoaders[$this->vendorDir] = $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregisters this instance as an autoloader.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function unregister()
|
||||||
|
{
|
||||||
|
spl_autoload_unregister(array($this, 'loadClass'));
|
||||||
|
|
||||||
|
if (null !== $this->vendorDir) {
|
||||||
|
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the given class or interface.
|
||||||
|
*
|
||||||
|
* @param string $class The name of the class
|
||||||
|
* @return true|null True if loaded, null otherwise
|
||||||
|
*/
|
||||||
|
public function loadClass($class)
|
||||||
|
{
|
||||||
|
if ($file = $this->findFile($class)) {
|
||||||
|
includeFile($file);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the path to the file where the class is defined.
|
||||||
|
*
|
||||||
|
* @param string $class The name of the class
|
||||||
|
*
|
||||||
|
* @return string|false The path if found, false otherwise
|
||||||
|
*/
|
||||||
|
public function findFile($class)
|
||||||
|
{
|
||||||
|
// class map lookup
|
||||||
|
if (isset($this->classMap[$class])) {
|
||||||
|
return $this->classMap[$class];
|
||||||
|
}
|
||||||
|
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (null !== $this->apcuPrefix) {
|
||||||
|
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
||||||
|
if ($hit) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = $this->findFileWithExtension($class, '.php');
|
||||||
|
|
||||||
|
// Search for Hack files if we are running on HHVM
|
||||||
|
if (false === $file && defined('HHVM_VERSION')) {
|
||||||
|
$file = $this->findFileWithExtension($class, '.hh');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null !== $this->apcuPrefix) {
|
||||||
|
apcu_add($this->apcuPrefix.$class, $file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (false === $file) {
|
||||||
|
// Remember that this class does not exist.
|
||||||
|
$this->missingClasses[$class] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the currently registered loaders indexed by their corresponding vendor directories.
|
||||||
|
*
|
||||||
|
* @return self[]
|
||||||
|
*/
|
||||||
|
public static function getRegisteredLoaders()
|
||||||
|
{
|
||||||
|
return self::$registeredLoaders;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $class
|
||||||
|
* @param string $ext
|
||||||
|
* @return string|false
|
||||||
|
*/
|
||||||
|
private function findFileWithExtension($class, $ext)
|
||||||
|
{
|
||||||
|
// PSR-4 lookup
|
||||||
|
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||||
|
|
||||||
|
$first = $class[0];
|
||||||
|
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||||
|
$subPath = $class;
|
||||||
|
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||||
|
$subPath = substr($subPath, 0, $lastPos);
|
||||||
|
$search = $subPath . '\\';
|
||||||
|
if (isset($this->prefixDirsPsr4[$search])) {
|
||||||
|
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
||||||
|
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||||
|
if (file_exists($file = $dir . $pathEnd)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-4 fallback dirs
|
||||||
|
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||||
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-0 lookup
|
||||||
|
if (false !== $pos = strrpos($class, '\\')) {
|
||||||
|
// namespaced class name
|
||||||
|
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||||
|
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||||
|
} else {
|
||||||
|
// PEAR-like class name
|
||||||
|
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($this->prefixesPsr0[$first])) {
|
||||||
|
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||||
|
if (0 === strpos($class, $prefix)) {
|
||||||
|
foreach ($dirs as $dir) {
|
||||||
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-0 fallback dirs
|
||||||
|
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||||
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// PSR-0 include paths.
|
||||||
|
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope isolated include.
|
||||||
|
*
|
||||||
|
* Prevents access to $this/self from included files.
|
||||||
|
*
|
||||||
|
* @param string $file
|
||||||
|
* @return void
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
function includeFile($file)
|
||||||
|
{
|
||||||
|
include $file;
|
||||||
|
}
|
21
vendor/DPP/buildtools/vendor/composer/LICENSE
vendored
Normal file
21
vendor/DPP/buildtools/vendor/composer/LICENSE
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is furnished
|
||||||
|
to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
10
vendor/DPP/buildtools/vendor/composer/autoload_classmap.php
vendored
Normal file
10
vendor/DPP/buildtools/vendor/composer/autoload_classmap.php
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_classmap.php @generated by Composer
|
||||||
|
|
||||||
|
$vendorDir = dirname(__DIR__);
|
||||||
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||||
|
);
|
9
vendor/DPP/buildtools/vendor/composer/autoload_namespaces.php
vendored
Normal file
9
vendor/DPP/buildtools/vendor/composer/autoload_namespaces.php
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_namespaces.php @generated by Composer
|
||||||
|
|
||||||
|
$vendorDir = dirname(__DIR__);
|
||||||
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
);
|
10
vendor/DPP/buildtools/vendor/composer/autoload_psr4.php
vendored
Normal file
10
vendor/DPP/buildtools/vendor/composer/autoload_psr4.php
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_psr4.php @generated by Composer
|
||||||
|
|
||||||
|
$vendorDir = dirname(__DIR__);
|
||||||
|
$baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'Dpp\\' => array($baseDir . '/classes'),
|
||||||
|
);
|
36
vendor/DPP/buildtools/vendor/composer/autoload_real.php
vendored
Normal file
36
vendor/DPP/buildtools/vendor/composer/autoload_real.php
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_real.php @generated by Composer
|
||||||
|
|
||||||
|
class ComposerAutoloaderInit0e8415491642f27914717986db49b1db
|
||||||
|
{
|
||||||
|
private static $loader;
|
||||||
|
|
||||||
|
public static function loadClassLoader($class)
|
||||||
|
{
|
||||||
|
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||||
|
require __DIR__ . '/ClassLoader.php';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return \Composer\Autoload\ClassLoader
|
||||||
|
*/
|
||||||
|
public static function getLoader()
|
||||||
|
{
|
||||||
|
if (null !== self::$loader) {
|
||||||
|
return self::$loader;
|
||||||
|
}
|
||||||
|
|
||||||
|
spl_autoload_register(array('ComposerAutoloaderInit0e8415491642f27914717986db49b1db', 'loadClassLoader'), true, true);
|
||||||
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||||
|
spl_autoload_unregister(array('ComposerAutoloaderInit0e8415491642f27914717986db49b1db', 'loadClassLoader'));
|
||||||
|
|
||||||
|
require __DIR__ . '/autoload_static.php';
|
||||||
|
call_user_func(\Composer\Autoload\ComposerStaticInit0e8415491642f27914717986db49b1db::getInitializer($loader));
|
||||||
|
|
||||||
|
$loader->register(true);
|
||||||
|
|
||||||
|
return $loader;
|
||||||
|
}
|
||||||
|
}
|
36
vendor/DPP/buildtools/vendor/composer/autoload_static.php
vendored
Normal file
36
vendor/DPP/buildtools/vendor/composer/autoload_static.php
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// autoload_static.php @generated by Composer
|
||||||
|
|
||||||
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
|
class ComposerStaticInit0e8415491642f27914717986db49b1db
|
||||||
|
{
|
||||||
|
public static $prefixLengthsPsr4 = array (
|
||||||
|
'D' =>
|
||||||
|
array (
|
||||||
|
'Dpp\\' => 4,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
public static $prefixDirsPsr4 = array (
|
||||||
|
'Dpp\\' =>
|
||||||
|
array (
|
||||||
|
0 => __DIR__ . '/../..' . '/classes',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
public static $classMap = array (
|
||||||
|
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||||
|
);
|
||||||
|
|
||||||
|
public static function getInitializer(ClassLoader $loader)
|
||||||
|
{
|
||||||
|
return \Closure::bind(function () use ($loader) {
|
||||||
|
$loader->prefixLengthsPsr4 = ComposerStaticInit0e8415491642f27914717986db49b1db::$prefixLengthsPsr4;
|
||||||
|
$loader->prefixDirsPsr4 = ComposerStaticInit0e8415491642f27914717986db49b1db::$prefixDirsPsr4;
|
||||||
|
$loader->classMap = ComposerStaticInit0e8415491642f27914717986db49b1db::$classMap;
|
||||||
|
|
||||||
|
}, null, ClassLoader::class);
|
||||||
|
}
|
||||||
|
}
|
52
vendor/DPP/cmake/ARM64ToolChain.cmake
vendored
Normal file
52
vendor/DPP/cmake/ARM64ToolChain.cmake
vendored
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
SET(CMAKE_SYSTEM_NAME Linux)
|
||||||
|
# Possibly needed tweak
|
||||||
|
#SET(CMAKE_SYSTEM_PROCESSOR aarch64)
|
||||||
|
|
||||||
|
SET(CMAKE_C_COMPILER ${COMPILER_ROOT}/aarch64-linux-gnu-gcc-8)
|
||||||
|
SET(CMAKE_CXX_COMPILER ${COMPILER_ROOT}/aarch64-linux-gnu-g++-8)
|
||||||
|
|
||||||
|
# Below call is necessary to avoid non-RT problem.
|
||||||
|
SET(CMAKE_LIBRARY_ARCHITECTURE aarch64-linux-gnu)
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE aarch64)
|
||||||
|
SET(CPACK_RPM_PACKAGE_ARCHITECTURE aarch64)
|
||||||
|
|
||||||
|
SET(RASPBERRY_ROOT_PATH ${CMAKE_SOURCE_DIR}/arm_raspberry)
|
||||||
|
SET(RASPBERRY_KINETIC_PATH ${RASPBERRY_ROOT_PATH}/opt/ros/kinetic)
|
||||||
|
|
||||||
|
SET(CMAKE_FIND_ROOT_PATH ${RASPBERRY_ROOT_PATH} ${CATKIN_DEVEL_PREFIX})
|
||||||
|
|
||||||
|
#If you have installed cross compiler to somewhere else, please specify that path.
|
||||||
|
SET(COMPILER_ROOT /usr/bin)
|
||||||
|
|
||||||
|
#Have to set this one to BOTH, to allow CMake to find rospack
|
||||||
|
#This set of variables controls whether the CMAKE_FIND_ROOT_PATH and CMAKE_SYSROOT are used for find_xxx() operations.
|
||||||
|
#SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
|
||||||
|
#SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
#SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
|
#SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
/usr/include/aarch64-linux-gnu)
|
||||||
|
|
||||||
|
SET(ZLIB_LIBRARY /lib/aarch64-linux-gnu/libz.so.1.2.11)
|
||||||
|
SET(OPENSSL_CRYPTO_LIBRARY /usr/lib/aarch64-linux-gnu/libcrypto.so)
|
||||||
|
SET(OPENSSL_SSL_LIBRARY /usr/lib/aarch64-linux-gnu/libssl.so)
|
||||||
|
|
||||||
|
SET(CMAKE_PREFIX_PATH ${RASPBERRY_KINETIC_PATH} ${RASPBERRY_ROOT_PATH}/usr)
|
||||||
|
|
||||||
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${RASPBERRY_ROOT_PATH} -Wno-psabi" CACHE INTERNAL "" FORCE)
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=${RASPBERRY_ROOT_PATH} -Wno-psabi" CACHE INTERNAL "" FORCE)
|
||||||
|
SET(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} --sysroot=${RASPBERRY_ROOT_PATH} -ldl" CACHE INTERNAL "" FORCE)
|
||||||
|
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${RASPBERRY_ROOT_PATH} -ldl" CACHE INTERNAL "" FORCE)
|
||||||
|
|
||||||
|
SET(LD_LIBRARY_PATH ${RASPBERRY_KINETIC_PATH}/lib)
|
||||||
|
|
||||||
|
EXECUTE_PROCESS(COMMAND printf "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal main multiverse restricted universe\ndeb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal main multiverse restricted universe\ndeb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-updates main multiverse restricted universe\ndeb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal-updates main multiverse restricted universe\ndeb [arch=amd64] http://security.ubuntu.com/ubuntu/ focal-security main multiverse restricted universe"
|
||||||
|
OUTPUT_FILE TMPFILE)
|
||||||
|
EXECUTE_PROCESS(COMMAND sudo mv TMPFILE /etc/apt/sources.list)
|
||||||
|
EXECUTE_PROCESS(COMMAND sudo dpkg --add-architecture arm64)
|
||||||
|
EXECUTE_PROCESS(COMMAND sudo apt-add-repository -y ppa:canonical-kernel-team/ppa)
|
||||||
|
EXECUTE_PROCESS(COMMAND sudo apt update)
|
||||||
|
EXECUTE_PROCESS(COMMAND sudo apt install -y cmake ninja-build gcc-8-aarch64-linux-gnu g++-8-aarch64-linux-gnu libc6-dev-arm64-cross zlib1g-dev:arm64 libssl-dev:arm64 libopus-dev:arm64 libsodium-dev:arm64)
|
||||||
|
EXECUTE_PROCESS(COMMAND sudo mv /usr/lib/aarch64-linux-gnu/pkgconfig/libsodium.pc /usr/lib/pkgconfig/)
|
||||||
|
|
64
vendor/DPP/cmake/ARMv6ToolChain.cmake
vendored
Normal file
64
vendor/DPP/cmake/ARMv6ToolChain.cmake
vendored
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
SET(CMAKE_SYSTEM_NAME Linux)
|
||||||
|
# Possibly needed tweak
|
||||||
|
#SET(CMAKE_SYSTEM_PROCESSOR armhf)
|
||||||
|
|
||||||
|
#If you have installed cross compiler to somewhere else, please specify that path.
|
||||||
|
SET(COMPILER_ROOT /opt/cross-pi-gcc)
|
||||||
|
|
||||||
|
SET(CMAKE_C_COMPILER ${COMPILER_ROOT}/bin/arm-linux-gnueabihf-gcc-8.3.0)
|
||||||
|
SET(CMAKE_CXX_COMPILER ${COMPILER_ROOT}/bin/arm-linux-gnueabihf-g++)
|
||||||
|
|
||||||
|
# Below call is necessary to avoid non-RT problem.
|
||||||
|
SET(CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf)
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE armhf)
|
||||||
|
SET(CPACK_RPM_PACKAGE_ARCHITECTURE armhf)
|
||||||
|
|
||||||
|
SET(RASPBERRY_ROOT_PATH ${CMAKE_CURRENT_LIST_DIR}/arm_raspberry)
|
||||||
|
SET(RASPBERRY_KINETIC_PATH ${RASPBERRY_ROOT_PATH}/opt/ros/kinetic)
|
||||||
|
|
||||||
|
SET(CMAKE_FIND_ROOT_PATH ${RASPBERRY_ROOT_PATH} ${CATKIN_DEVEL_PREFIX})
|
||||||
|
|
||||||
|
|
||||||
|
#Have to set this one to BOTH, to allow CMake to find rospack
|
||||||
|
#This set of variables controls whether the CMAKE_FIND_ROOT_PATH and CMAKE_SYSROOT are used for find_xxx() operations.
|
||||||
|
#SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
|
||||||
|
#SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
#SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
|
#SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||||
|
|
||||||
|
SET(CMAKE_PREFIX_PATH ${RASPBERRY_KINETIC_PATH} ${RASPBERRY_ROOT_PATH}/usr)
|
||||||
|
|
||||||
|
UNSET(CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES)
|
||||||
|
UNSET(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES)
|
||||||
|
|
||||||
|
SET(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${COMPILER_ROOT}/arm-linux-gnueabihf/libc/usr/include
|
||||||
|
${COMPILER_ROOT}/arm-linux-gnueabihf/include
|
||||||
|
${COMPILER_ROOT}/arm-linux-gnueabihf/include/c++/8.3.0
|
||||||
|
${COMPILER_ROOT}/arm-linux-gnueabihf/include/c++/8.3.0/arm-linux-gnueabihf
|
||||||
|
${COMPILER_ROOT}/lib/gcc/arm-linux-gnueabihf/8.3.0/include
|
||||||
|
${COMPILER_ROOT}/lib/gcc/arm-linux-gnueabihf/8.3.0/include-fixed
|
||||||
|
${CMAKE_SOURCE_DIR}/rootfs/usr/include/arm-linux-gnueabihf)
|
||||||
|
SET(CMAKE_INCLUDE_DIRECTORIES_BEFORE OFF)
|
||||||
|
|
||||||
|
SET(ZLIB_LIBRARY ${CMAKE_SOURCE_DIR}/rootfs/lib/arm-linux-gnueabihf/libz.so.1.2.11)
|
||||||
|
SET(OPENSSL_CRYPTO_LIBRARY ${CMAKE_SOURCE_DIR}/rootfs/usr/lib/arm-linux-gnueabihf/libcrypto.so.1.1)
|
||||||
|
SET(OPENSSL_SSL_LIBRARY ${CMAKE_SOURCE_DIR}/rootfs/usr/lib/arm-linux-gnueabihf/libssl.so.1.1)
|
||||||
|
|
||||||
|
SET(CMAKE_CXX_COMPILER_WORKS 1)
|
||||||
|
SET(CMAKE_C_FLAGS " ${CMAKE_C_FLAGS} -nostdinc --sysroot=${RASPBERRY_ROOT_PATH} -Wno-psabi " CACHE INTERNAL "" FORCE)
|
||||||
|
SET(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -nostdinc -nostdinc++ --sysroot=${RASPBERRY_ROOT_PATH} -Wno-psabi " CACHE INTERNAL "" FORCE)
|
||||||
|
SET(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} --sysroot=${RASPBERRY_ROOT_PATH} -ldl" CACHE INTERNAL "" FORCE)
|
||||||
|
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${RASPBERRY_ROOT_PATH} -ldl" CACHE INTERNAL "" FORCE)
|
||||||
|
|
||||||
|
SET(LD_LIBRARY_PATH ${RASPBERRY_KINETIC_PATH}/lib)
|
||||||
|
|
||||||
|
EXECUTE_PROCESS(COMMAND wget -P ${CMAKE_SOURCE_DIR}/rootfs -q http://content.dpp.dev/zlib1g_1.2.11.dfsg-1_armhf.deb http://content.dpp.dev/zlib1g-dev_1.2.11.dfsg-1_armhf.deb http://content.dpp.dev/libssl1.1_1.1.1m-1_armhf.deb http://content.dpp.dev/libssl-dev_1.1.1m-1_armhf.deb https://content.dpp.dev/raspi-toolchain.tar.gz)
|
||||||
|
|
||||||
|
EXECUTE_PROCESS(
|
||||||
|
COMMAND tar -xzf ${CMAKE_SOURCE_DIR}/rootfs/raspi-toolchain.tar.gz -C /opt
|
||||||
|
COMMAND sudo dpkg-deb -x ${CMAKE_SOURCE_DIR}/rootfs/zlib1g-dev_1.2.11.dfsg-1_armhf.deb ${CMAKE_SOURCE_DIR}/rootfs
|
||||||
|
COMMAND sudo dpkg-deb -x ${CMAKE_SOURCE_DIR}/rootfs/zlib1g_1.2.11.dfsg-1_armhf.deb ${CMAKE_SOURCE_DIR}/rootfs
|
||||||
|
COMMAND sudo dpkg-deb -x ${CMAKE_SOURCE_DIR}/rootfs/libssl-dev_1.1.1m-1_armhf.deb ${CMAKE_SOURCE_DIR}/rootfs
|
||||||
|
COMMAND sudo dpkg-deb -x ${CMAKE_SOURCE_DIR}/rootfs/libssl1.1_1.1.1m-1_armhf.deb ${CMAKE_SOURCE_DIR}/rootfs)
|
51
vendor/DPP/cmake/ARMv7ToolChain.cmake
vendored
Normal file
51
vendor/DPP/cmake/ARMv7ToolChain.cmake
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
SET(CMAKE_SYSTEM_NAME Linux)
|
||||||
|
# Possibly needed tweak
|
||||||
|
#SET(CMAKE_SYSTEM_PROCESSOR armhf)
|
||||||
|
|
||||||
|
SET(CMAKE_C_COMPILER ${COMPILER_ROOT}/arm-linux-gnueabihf-gcc-8)
|
||||||
|
SET(CMAKE_CXX_COMPILER ${COMPILER_ROOT}/arm-linux-gnueabihf-g++-8)
|
||||||
|
|
||||||
|
# Below call is necessary to avoid non-RT problem.
|
||||||
|
SET(CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf)
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE armhf)
|
||||||
|
SET(CPACK_RPM_PACKAGE_ARCHITECTURE armhf)
|
||||||
|
|
||||||
|
SET(RASPBERRY_ROOT_PATH ${CMAKE_SOURCE_DIR}/arm_raspberry)
|
||||||
|
SET(RASPBERRY_KINETIC_PATH ${RASPBERRY_ROOT_PATH}/opt/ros/kinetic)
|
||||||
|
|
||||||
|
SET(CMAKE_FIND_ROOT_PATH ${RASPBERRY_ROOT_PATH} ${CATKIN_DEVEL_PREFIX})
|
||||||
|
|
||||||
|
#If you have installed cross compiler to somewhere else, please specify that path.
|
||||||
|
SET(COMPILER_ROOT /usr/bin)
|
||||||
|
|
||||||
|
#Have to set this one to BOTH, to allow CMake to find rospack
|
||||||
|
#This set of variables controls whether the CMAKE_FIND_ROOT_PATH and CMAKE_SYSROOT are used for find_xxx() operations.
|
||||||
|
#SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
|
||||||
|
#SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||||
|
#SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||||
|
#SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
/usr/include/arm-linux-gnueabihf)
|
||||||
|
|
||||||
|
SET(ZLIB_LIBRARY /lib/arm-linux-gnueabihf/libz.so.1.2.11)
|
||||||
|
SET(OPENSSL_CRYPTO_LIBRARY /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.1)
|
||||||
|
SET(OPENSSL_SSL_LIBRARY /usr/lib/arm-linux-gnueabihf/libssl.so.1.1)
|
||||||
|
|
||||||
|
SET(CMAKE_PREFIX_PATH ${RASPBERRY_KINETIC_PATH} ${RASPBERRY_ROOT_PATH}/usr)
|
||||||
|
|
||||||
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${RASPBERRY_ROOT_PATH} -Wno-psabi" CACHE INTERNAL "" FORCE)
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --sysroot=${RASPBERRY_ROOT_PATH} -Wno-psabi" CACHE INTERNAL "" FORCE)
|
||||||
|
SET(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} --sysroot=${RASPBERRY_ROOT_PATH} -ldl" CACHE INTERNAL "" FORCE)
|
||||||
|
SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --sysroot=${RASPBERRY_ROOT_PATH} -ldl" CACHE INTERNAL "" FORCE)
|
||||||
|
|
||||||
|
SET(LD_LIBRARY_PATH ${RASPBERRY_KINETIC_PATH}/lib)
|
||||||
|
|
||||||
|
EXECUTE_PROCESS(COMMAND printf "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal main multiverse restricted universe\ndeb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ focal main multiverse restricted universe\ndeb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ focal-updates main multiverse restricted universe\ndeb [arch=amd64] http://archive.ubuntu.com/ubuntu/ focal-updates main multiverse restricted universe\ndeb [arch=amd64] http://security.ubuntu.com/ubuntu/ focal-security main multiverse restricted universe"
|
||||||
|
OUTPUT_FILE TMPFILE)
|
||||||
|
EXECUTE_PROCESS(COMMAND sudo mv TMPFILE /etc/apt/sources.list)
|
||||||
|
EXECUTE_PROCESS(COMMAND sudo dpkg --add-architecture armhf)
|
||||||
|
EXECUTE_PROCESS(COMMAND sudo apt update)
|
||||||
|
EXECUTE_PROCESS(COMMAND sudo apt install -y cmake ninja-build gcc-8-arm-linux-gnueabihf g++-8-arm-linux-gnueabihf zlib1g-dev:armhf libssl-dev:armhf libopus-dev:armhf libsodium-dev:armhf)
|
||||||
|
EXECUTE_PROCESS(COMMAND sudo mv /usr/lib/arm-linux-gnueabihf/pkgconfig/libsodium.pc /usr/lib/pkgconfig/)
|
||||||
|
|
66
vendor/DPP/cmake/CPackSetup.cmake
vendored
Normal file
66
vendor/DPP/cmake/CPackSetup.cmake
vendored
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
include(GNUInstallDirs)
|
||||||
|
set(DPP_EXPORT_NAME dpp)
|
||||||
|
set(DPP_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${DPP_EXPORT_NAME})
|
||||||
|
set(DPP_VERSION_FILE ${PROJECT_BINARY_DIR}/${DPP_EXPORT_NAME}-config-version.cmake)
|
||||||
|
|
||||||
|
# The three lines below are only used for windows builds
|
||||||
|
set(DPP_VERSIONED ${DPP_EXPORT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
|
||||||
|
set(DPP_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${DPP_VERSIONED})
|
||||||
|
set(DPP_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}/${DPP_VERSIONED})
|
||||||
|
|
||||||
|
|
||||||
|
## Pack the binary output
|
||||||
|
if (WIN32)
|
||||||
|
install(TARGETS dpp
|
||||||
|
EXPORT ${DPP_EXPORT_NAME}
|
||||||
|
LIBRARY DESTINATION ${DPP_INSTALL_LIBRARY_DIR}
|
||||||
|
ARCHIVE DESTINATION ${DPP_INSTALL_LIBRARY_DIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
INCLUDES DESTINATION ${DPP_INSTALL_INCLUDE_DIR})
|
||||||
|
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/" DESTINATION "${DPP_INSTALL_INCLUDE_DIR}")
|
||||||
|
else()
|
||||||
|
install(TARGETS dpp
|
||||||
|
EXPORT ${DPP_EXPORT_NAME}
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBRARY_DIR}
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBRARY_DIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDE_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
## Allow for a specific version to be chosen in the `find_package` command
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
write_basic_package_version_file(${DPP_VERSION_FILE}
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
COMPATIBILITY SameMajorVersion)
|
||||||
|
|
||||||
|
## Include the file which allows `find_package(dpp)` to function.
|
||||||
|
install(FILES "${CMAKE_SOURCE_DIR}/cmake/dpp-config.cmake" "${DPP_VERSION_FILE}" DESTINATION "${DPP_CMAKE_DIR}")
|
||||||
|
|
||||||
|
## Export the targets to allow other projects to easily include this project
|
||||||
|
install(EXPORT "${DPP_EXPORT_NAME}" DESTINATION "${DPP_CMAKE_DIR}" NAMESPACE dpp::)
|
||||||
|
|
||||||
|
# Prepare information for packaging into .zip, .deb, .rpm
|
||||||
|
## Project installation metadata
|
||||||
|
set(CPACK_PACKAGE_NAME libdpp) # Name of generated file
|
||||||
|
set(CPACK_PACKAGE_VENDOR Brainbox.cc) # Maker of the application
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An incredibly lightweight C++ Discord library")
|
||||||
|
set(CPACK_PACKAGE_DESCRIPTION "An incredibly lightweight C++ Discord library")
|
||||||
|
set(CPACK_PACKAGE_HOMEPAGE_URL "https://dpp.dev/")
|
||||||
|
set(CPACK_FREEBSD_PACKAGE_MAINTAINER "bsd@dpp.dev")
|
||||||
|
set(CPACK_FREEBSD_PACKAGE_ORIGIN "misc/libdpp")
|
||||||
|
set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0")
|
||||||
|
set(CPACK_PACKAGE_CONTACT "https://discord.gg/dpp") # D++ Development Discord
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsodium23 (>= 1.0.17-1), libopus0 (>= 1.3-1)")
|
||||||
|
set(CPACK_RPM_PACKAGE_REQUIRES "libsodium >= 1.0.17, opus >= 1.3.1")
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "An incredibly lightweight C++ Discord library")
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||||
|
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
|
||||||
|
|
||||||
|
## Select generated based on what operating system
|
||||||
|
if(WIN32)
|
||||||
|
set(CPACK_GENERATOR ZIP)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
set(CPACK_GENERATOR "DEB;RPM")
|
||||||
|
else()
|
||||||
|
set(CPACK_GENERATOR "TBZ2")
|
||||||
|
endif()
|
36
vendor/DPP/cmake/FindOpus.cmake
vendored
Normal file
36
vendor/DPP/cmake/FindOpus.cmake
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# OPUS_FOUND - system has opus
|
||||||
|
# OPUS_INCLUDE_DIRS - the opus include directory
|
||||||
|
# OPUS_LIBRARIES - The libraries needed to use opus
|
||||||
|
|
||||||
|
find_path(OPUS_INCLUDE_DIRS
|
||||||
|
NAMES opus/opus.h
|
||||||
|
PATH_SUFFIXES include
|
||||||
|
)
|
||||||
|
if(OPUS_INCLUDE_DIRS)
|
||||||
|
set(HAVE_OPUS_OPUS_H 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(OPUS_USE_STATIC_LIBS)
|
||||||
|
find_library(OPUS_LIBRARIES NAMES "libopus.a")
|
||||||
|
else()
|
||||||
|
find_library(OPUS_LIBRARIES NAMES opus)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(OPUS_LIBRARIES)
|
||||||
|
if(OPUS_USE_STATIC_LIBS)
|
||||||
|
find_library(LIBM NAMES "libm.a" "libm.tbd")
|
||||||
|
else()
|
||||||
|
find_library(LIBM NAMES m)
|
||||||
|
endif()
|
||||||
|
if(LIBM)
|
||||||
|
list(APPEND OPUS_LIBRARIES ${LIBM})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(Opus
|
||||||
|
DEFAULT_MSG
|
||||||
|
OPUS_INCLUDE_DIRS OPUS_LIBRARIES HAVE_OPUS_OPUS_H
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(OPUS_INCLUDE_DIRS OPUS_LIBRARIES HAVE_OPUS_OPUS_H)
|
293
vendor/DPP/cmake/FindSodium.cmake
vendored
Normal file
293
vendor/DPP/cmake/FindSodium.cmake
vendored
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
# Written in 2016 by Henrik Steffen Gaßmann <henrik@gassmann.onl>
|
||||||
|
#
|
||||||
|
# To the extent possible under law, the author(s) have dedicated all copyright
|
||||||
|
# and related and neighboring rights to this software to the public domain
|
||||||
|
# worldwide. This software is distributed without any warranty.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the CC0 Public Domain Dedication along with
|
||||||
|
# this software. If not, see
|
||||||
|
#
|
||||||
|
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
#
|
||||||
|
# ##############################################################################
|
||||||
|
# Tries to find the local libsodium installation.
|
||||||
|
#
|
||||||
|
# On Windows the sodium_DIR environment variable is used as a default hint which
|
||||||
|
# can be overridden by setting the corresponding cmake variable.
|
||||||
|
#
|
||||||
|
# Once done the following variables will be defined:
|
||||||
|
#
|
||||||
|
# sodium_FOUND sodium_INCLUDE_DIR sodium_LIBRARY_DEBUG sodium_LIBRARY_RELEASE
|
||||||
|
# sodium_VERSION_STRING
|
||||||
|
#
|
||||||
|
# Furthermore an imported "sodium" target is created.
|
||||||
|
#
|
||||||
|
|
||||||
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||||
|
set(_GCC_COMPATIBLE 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# static library option
|
||||||
|
if(NOT DEFINED sodium_USE_STATIC_LIBS)
|
||||||
|
option(sodium_USE_STATIC_LIBS "enable to statically link against sodium" OFF)
|
||||||
|
endif()
|
||||||
|
if(NOT (sodium_USE_STATIC_LIBS EQUAL sodium_USE_STATIC_LIBS_LAST))
|
||||||
|
unset(sodium_LIBRARY CACHE)
|
||||||
|
unset(sodium_LIBRARY_DEBUG CACHE)
|
||||||
|
unset(sodium_LIBRARY_RELEASE CACHE)
|
||||||
|
unset(sodium_DLL_DEBUG CACHE)
|
||||||
|
unset(sodium_DLL_RELEASE CACHE)
|
||||||
|
set(sodium_USE_STATIC_LIBS_LAST
|
||||||
|
${sodium_USE_STATIC_LIBS}
|
||||||
|
CACHE INTERNAL "internal change tracking variable")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ##############################################################################
|
||||||
|
# UNIX
|
||||||
|
if(UNIX)
|
||||||
|
# import pkg-config
|
||||||
|
find_package(PkgConfig)
|
||||||
|
if(PKG_CONFIG_FOUND)
|
||||||
|
pkg_check_modules(sodium_PKG QUIET libsodium)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(sodium_USE_STATIC_LIBS)
|
||||||
|
if(sodium_PKG_STATIC_LIBRARIES)
|
||||||
|
foreach(_libname ${sodium_PKG_STATIC_LIBRARIES})
|
||||||
|
if(NOT _libname MATCHES "^lib.*\\.a$") # ignore strings already ending
|
||||||
|
# with .a
|
||||||
|
list(INSERT sodium_PKG_STATIC_LIBRARIES 0 "lib${_libname}.a")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
list(REMOVE_DUPLICATES sodium_PKG_STATIC_LIBRARIES)
|
||||||
|
else()
|
||||||
|
# if pkgconfig for libsodium doesn't provide static lib info, then
|
||||||
|
# override PKG_STATIC here..
|
||||||
|
set(sodium_PKG_STATIC_LIBRARIES libsodium.a)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(XPREFIX sodium_PKG_STATIC)
|
||||||
|
else()
|
||||||
|
if(sodium_PKG_LIBRARIES STREQUAL "")
|
||||||
|
set(sodium_PKG_LIBRARIES sodium)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(XPREFIX sodium_PKG)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_path(sodium_INCLUDE_DIR sodium.h HINTS ${${XPREFIX}_INCLUDE_DIRS})
|
||||||
|
find_library(sodium_LIBRARY_DEBUG
|
||||||
|
NAMES ${${XPREFIX}_LIBRARIES}
|
||||||
|
HINTS ${${XPREFIX}_LIBRARY_DIRS})
|
||||||
|
find_library(sodium_LIBRARY_RELEASE
|
||||||
|
NAMES ${${XPREFIX}_LIBRARIES}
|
||||||
|
HINTS ${${XPREFIX}_LIBRARY_DIRS})
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# Windows
|
||||||
|
elseif(WIN32)
|
||||||
|
set(sodium_DIR "$ENV{sodium_DIR}" CACHE FILEPATH "sodium install directory")
|
||||||
|
mark_as_advanced(sodium_DIR)
|
||||||
|
|
||||||
|
find_path(sodium_INCLUDE_DIR sodium.h
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES include)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# detect target architecture
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp" [=[
|
||||||
|
#if defined _M_IX86
|
||||||
|
#error ARCH_VALUE x86_32
|
||||||
|
#elif defined _M_X64
|
||||||
|
#error ARCH_VALUE x86_64
|
||||||
|
#endif
|
||||||
|
#error ARCH_VALUE unknown
|
||||||
|
]=])
|
||||||
|
try_compile(_UNUSED_VAR "${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/arch.cpp"
|
||||||
|
OUTPUT_VARIABLE _COMPILATION_LOG)
|
||||||
|
string(REGEX
|
||||||
|
REPLACE ".*ARCH_VALUE ([a-zA-Z0-9_]+).*"
|
||||||
|
"\\1"
|
||||||
|
_TARGET_ARCH
|
||||||
|
"${_COMPILATION_LOG}")
|
||||||
|
|
||||||
|
# construct library path
|
||||||
|
if(_TARGET_ARCH STREQUAL "x86_32")
|
||||||
|
string(APPEND _PLATFORM_PATH "Win32")
|
||||||
|
elseif(_TARGET_ARCH STREQUAL "x86_64")
|
||||||
|
string(APPEND _PLATFORM_PATH "x64")
|
||||||
|
else()
|
||||||
|
message(
|
||||||
|
FATAL_ERROR
|
||||||
|
"the ${_TARGET_ARCH} architecture is not supported by Findsodium.cmake."
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
string(APPEND _PLATFORM_PATH "/$$CONFIG$$")
|
||||||
|
|
||||||
|
if(MSVC_VERSION LESS 1900)
|
||||||
|
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 60")
|
||||||
|
else()
|
||||||
|
math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 50")
|
||||||
|
endif()
|
||||||
|
string(APPEND _PLATFORM_PATH "/v${_VS_VERSION}")
|
||||||
|
|
||||||
|
if(sodium_USE_STATIC_LIBS)
|
||||||
|
string(APPEND _PLATFORM_PATH "/static")
|
||||||
|
else()
|
||||||
|
string(APPEND _PLATFORM_PATH "/dynamic")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
string(REPLACE "$$CONFIG$$"
|
||||||
|
"Debug"
|
||||||
|
_DEBUG_PATH_SUFFIX
|
||||||
|
"${_PLATFORM_PATH}")
|
||||||
|
string(REPLACE "$$CONFIG$$"
|
||||||
|
"Release"
|
||||||
|
_RELEASE_PATH_SUFFIX
|
||||||
|
"${_PLATFORM_PATH}")
|
||||||
|
|
||||||
|
find_library(sodium_LIBRARY_DEBUG libsodium.lib
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX})
|
||||||
|
find_library(sodium_LIBRARY_RELEASE libsodium.lib
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX})
|
||||||
|
if(NOT sodium_USE_STATIC_LIBS)
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES_BCK ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
|
||||||
|
find_library(sodium_DLL_DEBUG libsodium
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX})
|
||||||
|
find_library(sodium_DLL_RELEASE libsodium
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX})
|
||||||
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_BCK})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
elseif(_GCC_COMPATIBLE)
|
||||||
|
if(sodium_USE_STATIC_LIBS)
|
||||||
|
find_library(sodium_LIBRARY_DEBUG libsodium.a
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES lib)
|
||||||
|
find_library(sodium_LIBRARY_RELEASE libsodium.a
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES lib)
|
||||||
|
else()
|
||||||
|
find_library(sodium_LIBRARY_DEBUG libsodium.dll.a
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES lib)
|
||||||
|
find_library(sodium_LIBRARY_RELEASE libsodium.dll.a
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES lib)
|
||||||
|
|
||||||
|
file(GLOB _DLL
|
||||||
|
LIST_DIRECTORIES false
|
||||||
|
RELATIVE "${sodium_DIR}/bin"
|
||||||
|
"${sodium_DIR}/bin/libsodium*.dll")
|
||||||
|
find_library(sodium_DLL_DEBUG ${_DLL} libsodium
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES bin)
|
||||||
|
find_library(sodium_DLL_RELEASE ${_DLL} libsodium
|
||||||
|
HINTS ${sodium_DIR}
|
||||||
|
PATH_SUFFIXES bin)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "this platform is not supported by FindSodium.cmake")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ############################################################################
|
||||||
|
# unsupported
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "this platform is not supported by FindSodium.cmake")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# ##############################################################################
|
||||||
|
# common stuff
|
||||||
|
|
||||||
|
# extract sodium version
|
||||||
|
if(sodium_INCLUDE_DIR)
|
||||||
|
set(_VERSION_HEADER "${sodium_INCLUDE_DIR}/sodium/version.h")
|
||||||
|
if(EXISTS "${_VERSION_HEADER}")
|
||||||
|
file(READ "${_VERSION_HEADER}" _VERSION_HEADER_CONTENT)
|
||||||
|
string(
|
||||||
|
REGEX
|
||||||
|
REPLACE
|
||||||
|
".*#define[ \t]*SODIUM_VERSION_STRING[ \t]*\"([^\n]*)\".*"
|
||||||
|
"\\1"
|
||||||
|
sodium_VERSION_STRING
|
||||||
|
"${_VERSION_HEADER_CONTENT}")
|
||||||
|
set(sodium_VERSION_STRING "${sodium_VERSION_STRING}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# communicate results
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(sodium
|
||||||
|
REQUIRED_VARS
|
||||||
|
sodium_LIBRARY_RELEASE
|
||||||
|
sodium_LIBRARY_DEBUG
|
||||||
|
sodium_INCLUDE_DIR
|
||||||
|
VERSION_VAR
|
||||||
|
sodium_VERSION_STRING)
|
||||||
|
|
||||||
|
# mark file paths as advanced
|
||||||
|
mark_as_advanced(sodium_INCLUDE_DIR)
|
||||||
|
mark_as_advanced(sodium_LIBRARY_DEBUG)
|
||||||
|
mark_as_advanced(sodium_LIBRARY_RELEASE)
|
||||||
|
if(WIN32)
|
||||||
|
mark_as_advanced(sodium_DLL_DEBUG)
|
||||||
|
mark_as_advanced(sodium_DLL_RELEASE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# create imported target
|
||||||
|
if(sodium_USE_STATIC_LIBS)
|
||||||
|
set(_LIB_TYPE STATIC)
|
||||||
|
else()
|
||||||
|
set(_LIB_TYPE SHARED)
|
||||||
|
endif()
|
||||||
|
add_library(sodium ${_LIB_TYPE} IMPORTED)
|
||||||
|
|
||||||
|
set_target_properties(sodium
|
||||||
|
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||||
|
"${sodium_INCLUDE_DIR}"
|
||||||
|
IMPORTED_LINK_INTERFACE_LANGUAGES
|
||||||
|
"C")
|
||||||
|
|
||||||
|
if(sodium_USE_STATIC_LIBS)
|
||||||
|
set_target_properties(sodium
|
||||||
|
PROPERTIES INTERFACE_COMPILE_DEFINITIONS
|
||||||
|
"SODIUM_STATIC"
|
||||||
|
IMPORTED_LOCATION
|
||||||
|
"${sodium_LIBRARY_RELEASE}"
|
||||||
|
IMPORTED_LOCATION_DEBUG
|
||||||
|
"${sodium_LIBRARY_DEBUG}")
|
||||||
|
else()
|
||||||
|
if(UNIX)
|
||||||
|
set_target_properties(sodium
|
||||||
|
PROPERTIES IMPORTED_LOCATION
|
||||||
|
"${sodium_LIBRARY_RELEASE}"
|
||||||
|
IMPORTED_LOCATION_DEBUG
|
||||||
|
"${sodium_LIBRARY_DEBUG}")
|
||||||
|
elseif(WIN32)
|
||||||
|
set_target_properties(sodium
|
||||||
|
PROPERTIES IMPORTED_IMPLIB
|
||||||
|
"${sodium_LIBRARY_RELEASE}"
|
||||||
|
IMPORTED_IMPLIB_DEBUG
|
||||||
|
"${sodium_LIBRARY_DEBUG}")
|
||||||
|
if(NOT (sodium_DLL_DEBUG MATCHES ".*-NOTFOUND"))
|
||||||
|
set_target_properties(sodium
|
||||||
|
PROPERTIES IMPORTED_LOCATION_DEBUG
|
||||||
|
"${sodium_DLL_DEBUG}")
|
||||||
|
endif()
|
||||||
|
if(NOT (sodium_DLL_RELEASE MATCHES ".*-NOTFOUND"))
|
||||||
|
set_target_properties(sodium
|
||||||
|
PROPERTIES IMPORTED_LOCATION_RELWITHDEBINFO
|
||||||
|
"${sodium_DLL_RELEASE}"
|
||||||
|
IMPORTED_LOCATION_MINSIZEREL
|
||||||
|
"${sodium_DLL_RELEASE}"
|
||||||
|
IMPORTED_LOCATION_RELEASE
|
||||||
|
"${sodium_DLL_RELEASE}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
30
vendor/DPP/cmake/LINUXx86ToolChain.cmake
vendored
Normal file
30
vendor/DPP/cmake/LINUXx86ToolChain.cmake
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
SET(CMAKE_SYSTEM_NAME Linux)
|
||||||
|
# Possibly needed tweak
|
||||||
|
#SET(CMAKE_SYSTEM_PROCESSOR i386)
|
||||||
|
|
||||||
|
SET(CMAKE_C_COMPILER gcc-10)
|
||||||
|
SET(CMAKE_CXX_COMPILER g++-10)
|
||||||
|
|
||||||
|
# Below call is necessary to avoid non-RT problem.
|
||||||
|
SET(CMAKE_LIBRARY_ARCHITECTURE i386-linux-gnu)
|
||||||
|
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386)
|
||||||
|
SET(CPACK_RPM_PACKAGE_ARCHITECTURE i686)
|
||||||
|
|
||||||
|
#If you have installed cross compiler to somewhere else, please specify that path.
|
||||||
|
SET(COMPILER_ROOT /usr/bin)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
/usr/include/i386-linux-gnu)
|
||||||
|
|
||||||
|
SET(ZLIB_LIBRARY /lib/i386-linux-gnu/libz.so.1.2.11)
|
||||||
|
SET(OPENSSL_CRYPTO_LIBRARY /usr/lib/i386-linux-gnu/libcrypto.so)
|
||||||
|
SET(OPENSSL_SSL_LIBRARY /usr/lib/i386-linux-gnu/libssl.so)
|
||||||
|
|
||||||
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32 " CACHE INTERNAL "" FORCE)
|
||||||
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 " CACHE INTERNAL "" FORCE)
|
||||||
|
|
||||||
|
EXECUTE_PROCESS(COMMAND sudo dpkg --add-architecture i386)
|
||||||
|
EXECUTE_PROCESS(COMMAND sudo apt update)
|
||||||
|
EXECUTE_PROCESS(COMMAND sudo apt install -y g++-10 gcc-10-multilib glibc-*:i386 libc6-dev-i386 g++-10-multilib zlib1g-dev:i386 libssl-dev:i386 libopus-dev:i386 libsodium-dev:i386)
|
||||||
|
EXECUTE_PROCESS(COMMAND sudo mv /usr/lib/i386-linux-gnu/pkgconfig/libsodium.pc /usr/lib/pkgconfig/)
|
||||||
|
|
19
vendor/DPP/cmake/PostBuild.cmake
vendored
Normal file
19
vendor/DPP/cmake/PostBuild.cmake
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
string(ASCII 27 Esc)
|
||||||
|
set(ColourReset "${Esc}[m")
|
||||||
|
set(ColourBold "${Esc}[1m")
|
||||||
|
set(Red "${Esc}[31m")
|
||||||
|
set(Green "${Esc}[32m")
|
||||||
|
set(Yellow "${Esc}[33m")
|
||||||
|
set(Blue "${Esc}[34m")
|
||||||
|
set(Magenta "${Esc}[35m")
|
||||||
|
set(Cyan "${Esc}[36m")
|
||||||
|
set(White "${Esc}[37m")
|
||||||
|
set(BoldRed "${Esc}[1;31m")
|
||||||
|
set(BoldGreen "${Esc}[1;32m")
|
||||||
|
set(BoldYellow "${Esc}[1;33m")
|
||||||
|
set(BoldBlue "${Esc}[1;34m")
|
||||||
|
set(BoldMagenta "${Esc}[1;35m")
|
||||||
|
set(BoldCyan "${Esc}[1;36m")
|
||||||
|
set(BoldWhite "${Esc}[1;37m")
|
||||||
|
|
||||||
|
message("Type ${Green}sudo make install${ColourReset} to install D++")
|
11
vendor/DPP/cmake/PostInstall.cmake
vendored
Normal file
11
vendor/DPP/cmake/PostInstall.cmake
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
if (RUN_LDCONFIG)
|
||||||
|
if(LDCONFIG_EXECUTABLE)
|
||||||
|
message(STATUS "Running ldconfig")
|
||||||
|
|
||||||
|
execute_process(COMMAND ${LDCONFIG_EXECUTABLE} RESULT_VARIABLE ldconfig_result)
|
||||||
|
|
||||||
|
if (NOT ldconfig_result EQUAL 0)
|
||||||
|
message(WARNING "ldconfig failed")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
29
vendor/DPP/cmake/Raw-Files/Bottom-Of-Portfile.cmake
vendored
Normal file
29
vendor/DPP/cmake/Raw-Files/Bottom-Of-Portfile.cmake
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
HEAD_REF master
|
||||||
|
PATCHES
|
||||||
|
make-pkgconfig-required.patch
|
||||||
|
)
|
||||||
|
|
||||||
|
vcpkg_cmake_configure(
|
||||||
|
SOURCE_PATH "${SOURCE_PATH}"
|
||||||
|
DISABLE_PARALLEL_CONFIGURE
|
||||||
|
)
|
||||||
|
|
||||||
|
vcpkg_cmake_install()
|
||||||
|
|
||||||
|
vcpkg_cmake_config_fixup(NO_PREFIX_CORRECTION)
|
||||||
|
|
||||||
|
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share/dpp")
|
||||||
|
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
|
||||||
|
|
||||||
|
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
||||||
|
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
file(
|
||||||
|
INSTALL "${SOURCE_PATH}/LICENSE"
|
||||||
|
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}"
|
||||||
|
RENAME copyright
|
||||||
|
)
|
||||||
|
|
||||||
|
file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
|
||||||
|
|
22
vendor/DPP/cmake/Raw-Files/Bottom-Of-Version-File.txt
vendored
Normal file
22
vendor/DPP/cmake/Raw-Files/Bottom-Of-Version-File.txt
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
,
|
||||||
|
"description": "D++ Extremely Lightweight C++ Discord Library.",
|
||||||
|
"homepage": "https://dpp.dev/",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"supports": "((windows & !static & !uwp) | linux | osx)",
|
||||||
|
"dependencies": [
|
||||||
|
"libsodium",
|
||||||
|
"nlohmann-json",
|
||||||
|
"openssl",
|
||||||
|
"opus",
|
||||||
|
"zlib",
|
||||||
|
{
|
||||||
|
"name": "vcpkg-cmake",
|
||||||
|
"host": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "vcpkg-cmake-config",
|
||||||
|
"host": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
1
vendor/DPP/cmake/Raw-Files/Middle-Of-Portfile.cmake
vendored
Normal file
1
vendor/DPP/cmake/Raw-Files/Middle-Of-Portfile.cmake
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
SHA512
|
4
vendor/DPP/cmake/Raw-Files/Top-Of-Portfile.cmake
vendored
Normal file
4
vendor/DPP/cmake/Raw-Files/Top-Of-Portfile.cmake
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
vcpkg_from_github(
|
||||||
|
OUT_SOURCE_PATH SOURCE_PATH
|
||||||
|
REPO brainboxdotcc/DPP
|
||||||
|
REF
|
3
vendor/DPP/cmake/Raw-Files/Top-Of-Version-File.txt
vendored
Normal file
3
vendor/DPP/cmake/Raw-Files/Top-Of-Version-File.txt
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"name": "dpp",
|
||||||
|
"version":
|
4
vendor/DPP/cmake/Raw-Files/dpp.json
vendored
Normal file
4
vendor/DPP/cmake/Raw-Files/dpp.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"versions": [
|
||||||
|
]
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user