Skip to content

Commit 14a1609

Browse files
committed
DiscordCoreAPI Release v1.80
-Removed C++ aliasing instances. -Fixed a segfault that was occurring under Linux. -Updated the Doxygen comments. -Fixed a disconnection issue with the UDPConnection class. -Implemented a UnorderedMap class to improve performance. -Implemented perfect forwarding in some of the caching functions. -Fixed a couple issues with the internal voice-streaming implementation. -Updated a function to be inlined. -Updated some function-local variables to be static constexpr. -Added the new Gateway intents. -Fixed the UpdatePresenceData sending behavior. -Removed a bunch of superfluous dllexport calls. -Fixed the ObjectCollector implementations. -Implemented a TimeStampBase and PermissionsBase class to support uint64_t and std::string versions of each. -Updated the UnorderedSet implementation. -Adding new AVX-detection code, as well as a fallback layer for non-avx systems. -Added a fully AVX512/AXV2/AVX enabled mixer for the audio subsystem. -Implemented DiscordCoreClient as a Singleton class. -Improved the UnorderedSet and UnorderedMap classes.
1 parent 7270251 commit 14a1609

File tree

98 files changed

+6611
-5148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+6611
-5148
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
name: Build-and-Test-CLANG
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- dev
9+
10+
11+
jobs:
12+
Build:
13+
runs-on: macos-latest
14+
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
clang: [16]
19+
build_type: [Debug, Release]
20+
std: [20]
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
25+
- name: Update Vcpkg and install other dependencies.
26+
run: |
27+
cd /usr/local/share/vcpkg
28+
./bootstrap-vcpkg.sh
29+
git stash
30+
git pull
31+
vcpkg update
32+
33+
- name: Install Clang17
34+
run: |
35+
brew install llvm
36+
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
37+
38+
- name: Copy the Jsonifier repo over.
39+
run: |
40+
sudo git clone https://github.com/RealTimeChris/Jsonifier
41+
sudo cp -r -v ./Jsonifier/Vcpkg/* /usr/local/share/vcpkg/
42+
43+
- name: Install the dependencies.
44+
run: |
45+
vcpkg install jsonifier:x64-osx
46+
vcpkg install opus:x64-osx
47+
vcpkg install libsodium:x64-osx
48+
vcpkg install openssl:x64-osx
49+
50+
- name: Configure CMake
51+
working-directory: Tests
52+
run: |
53+
cmake -S . -B ./Build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang-16 -DGITHUB_BRANCH_TYPE=${{github.ref}}
54+
55+
- name: Build the Test
56+
working-directory: Tests/Build
57+
run: |
58+
cmake --build . --config=${{matrix.build_type}}
59+
60+
- name: Install the Test
61+
working-directory: Tests/Build
62+
run: |
63+
cmake --install ./ --config=${{matrix.build_type}}
64+
65+
- name: Run the Test
66+
working-directory: Tests/Install/${{matrix.build_type}}
67+
run: |
68+
chmod u+x ./DiscordCoreAPITest
69+
./DiscordCoreAPITest
70+
continue-on-error: true
71+

.github/workflows/CLANG_17.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
clang: [17]
17+
clang: [16]
1818
build_type: [Debug, Release]
19-
std: [23]
19+
std: [20]
2020

2121
steps:
2222
- uses: actions/checkout@v3
@@ -61,9 +61,15 @@ jobs:
6161
run: |
6262
cmake --build . --config=${{matrix.build_type}}
6363
64-
- name: Run the Test
64+
- name: Install the Test
6565
working-directory: Tests/Build
6666
run: |
67+
cmake --install ./ --config=${{matrix.build_type}}
68+
69+
- name: Run the Test
70+
working-directory: Tests/Install/${{matrix.build_type}}
71+
run: |
72+
chmod u+x ./DiscordCoreAPITest
6773
./DiscordCoreAPITest
6874
continue-on-error: true
6975

.github/workflows/GCC_12.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
matrix:
1616
gcc: [12]
1717
build_type: [Debug, Release]
18-
std: [23]
18+
std: [20]
1919
env:
2020
CC: gcc-${{matrix.gcc}}
2121
CXX: g++-${{matrix.gcc}}
@@ -56,8 +56,14 @@ jobs:
5656
run: |
5757
cmake --build . --config=${{matrix.build_type}}
5858
59-
- name: Run the Test
59+
- name: Install the Test
6060
working-directory: Tests/Build
6161
run: |
62+
cmake --install ./ --config=${{matrix.build_type}}
63+
64+
- name: Run the Test
65+
working-directory: Tests/Install/${{matrix.build_type}}
66+
run: |
67+
chmod u+x ./DiscordCoreAPITest
6268
./DiscordCoreAPITest
6369
continue-on-error: true

.github/workflows/MSVC_2022.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
build_type: [Debug, Release]
17-
std: [23]
17+
std: [20]
1818

1919
steps:
2020
- uses: actions/checkout@v3
@@ -49,8 +49,13 @@ jobs:
4949
run: |
5050
cmake --build . --config=${{matrix.build_type}}
5151
52+
- name: Install the Test
53+
working-directory: Tests/Build
54+
run: |
55+
cmake --install ./ --config=${{matrix.build_type}}
56+
5257
- name: Run the Test
53-
working-directory: Tests/Build/${{matrix.build_type}}/
58+
working-directory: Tests/Install/${{matrix.build_type}}
5459
run: |
5560
./DiscordCoreAPITest.exe
5661
continue-on-error: true

BuildTools/Classes/Packager/Vcpkg.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ function constructPortAndVersionFile(string $sha512 = "0"): string
139139
endif()
140140
141141
vcpkg_from_github(
142-
OUT_SOURCE_PATH SOURCE_PATH
143-
REPO RealTimeChris/DiscordCoreAPI
144-
REF "v${VERSION}"
142+
OUT_SOURCE_PATH SOURCE_PATH
143+
REPO RealTimeChris/DiscordCoreAPI
144+
REF "v${VERSION}"
145145
SHA512 ' . $sha512 . '
146146
HEAD_REF main
147147
)
@@ -160,11 +160,7 @@ function constructPortAndVersionFile(string $sha512 = "0"): string
160160
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
161161
endif()
162162
163-
file(
164-
INSTALL "${SOURCE_PATH}/License.md"
165-
DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}"
166-
RENAME copyright
167-
)
163+
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/License.md")
168164
';
169165
// ./Vcpkg/ports/discordcoreapi/vcpkg.json
170166
$versionFileContent = '{

CMake/CollectVersion.cmake

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#
2+
# DiscordCoreAPI, A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.
3+
#
4+
# Copyright 2021, 2022, 2023 Chris M. (RealTimeChris)
5+
#
6+
# This library is free software; you can redistribute it and/or
7+
# modify it under the terms of the GNU Lesser General Public
8+
# License as published by the Free Software Foundation; either
9+
# version 2.1 of the License, or (at your option) any later version.
10+
#
11+
# This library is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
# Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public
17+
# License along with this library; if not, write to the Free Software
18+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19+
# USA
20+
#
21+
# CollectVersion.cmake - The script for collecting the library's version..
22+
# May 13, 2021
23+
# https://discordcoreapi.com
24+
25+
function(collect_version)
26+
27+
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/../Vcpkg/ports/discordcoreapi/vcpkg.json" JSON_STRING)
28+
foreach(IDX RANGE 1)
29+
string(JSON PRODUCT_VERSION GET "${JSON_STRING}" "version")
30+
endforeach()
31+
set(PRODUCT_VERSION "${PRODUCT_VERSION}" PARENT_SCOPE)
32+
string(REPLACE "." ";" PRODUCT_VERSION_LIST "${PRODUCT_VERSION}")
33+
list(GET PRODUCT_VERSION_LIST 0 VERSION_MAJOR)
34+
set(VERSION_MAJOR "${VERSION_MAJOR}" PARENT_SCOPE)
35+
list(GET PRODUCT_VERSION_LIST 1 VERSION_MINOR)
36+
set(VERSION_MINOR "${VERSION_MINOR}" PARENT_SCOPE)
37+
38+
endfunction()

CMake/DetectArchitecture.cmake

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# MIT License
2+
#
3+
# Copyright (c) 2023 RealTimeChris
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
6+
# software and associated documentation files (the "Software"), to deal in the Software
7+
# without restriction, including without limitation the rights to use, copy, modify, merge,
8+
# publish, distribute, sublicense, and/or sell copies of the Software, and to permit
9+
# persons to whom the Software is furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in all copies or
12+
# substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15+
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16+
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
17+
# FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18+
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19+
# DEALINGS IN THE SOFTWARE.
20+
#
21+
# CMakeLists.txt - The CMake script for building this library.
22+
# Dec 17, 2022
23+
# https://github.com/RealTimeChris/Jsonifier
24+
include(CheckCXXSourceRuns)
25+
26+
function(check_instruction_set INSTRUCTION_SET_NAME INSTRUCTION_SET_FLAG INSTRUCTION_SET_INTRINSIC)
27+
28+
set(INSTRUCTION_SET_CODE "
29+
#include <immintrin.h>
30+
#include <stdint.h>
31+
int main()
32+
{
33+
${INSTRUCTION_SET_INTRINSIC};
34+
return 0;
35+
}
36+
")
37+
38+
set(CMAKE_REQUIRED_FLAGS "${INSTRUCTION_SET_FLAG}")
39+
CHECK_CXX_SOURCE_RUNS("${INSTRUCTION_SET_CODE}" "${INSTRUCTION_SET_NAME}")
40+
if(${INSTRUCTION_SET_NAME})
41+
set(AVX_FLAG "${INSTRUCTION_SET_FLAG}" PARENT_SCOPE)
42+
set(AVX_NAME "${INSTRUCTION_SET_NAME}" PARENT_SCOPE)
43+
else()
44+
message(STATUS "Instruction set ${INSTRUCTION_SET_NAME} not supported. Falling back to the previous instruction set.")
45+
return()
46+
endif()
47+
endfunction()
48+
49+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
50+
set(INSTRUCTION_SETS
51+
"T_AVX?/arch:AVX?auto result = _mm_testz_ps(__m128{}, __m128{})"
52+
"T_AVX2?/arch:AVX2?auto result = _mm256_abs_epi16(__m256i{})"
53+
"T_AVX512?/arch:AVX512?auto result = _mm512_add_ps(__m512i{}, __m512i{}).auto result2 = _mm512_cmplt_epu8_mask(__m512i{}, __m512i{}).char newArray[64]{}.auto result = _mm_loadu_epi64(newArray)"
54+
)
55+
else()
56+
set(INSTRUCTION_SETS
57+
"T_AVX?-mavx.-mpclmul.-mbmi?auto result = _mm_testz_ps(__m128{}, __m128{})"
58+
"T_AVX2?-mavx2.-mpclmul.-mbmi?auto result = _mm256_abs_epi16(__m256i{})"
59+
"T_AVX512?-mavx512bw.-mavx512vl.-mavx512f.-mpclmul.-mbmi?auto result = _mm512_add_ps(__m512i{}, __m512i{}).auto result2 = _mm512_cmplt_epu8_mask(__m512i{}, __m512i{}).char newArray[64]{}.auto result = _mm_loadu_epi64(newArray)"
60+
)
61+
endif()
62+
63+
set(CMAKE_REQUIRED_FLAGS_SAVE "${CMAKE_REQUIRED_FLAGS}")
64+
65+
set(AVX_NAME "T_Fallback")
66+
67+
foreach(INSTRUCTION_SET IN LISTS INSTRUCTION_SETS)
68+
string(REPLACE "?" ";" CURRENT_LIST "${INSTRUCTION_SET}")
69+
list(GET CURRENT_LIST 0 INSTRUCTION_SET_NAME)
70+
list(GET CURRENT_LIST 1 INSTRUCTION_SET_FLAG)
71+
string(REPLACE "." ";" INSTRUCTION_SET_FLAG "${INSTRUCTION_SET_FLAG}")
72+
list(GET CURRENT_LIST 2 INSTRUCTION_SET_INTRINSIC)
73+
string(REPLACE "." ";" INSTRUCTION_SET_INTRINSIC "${INSTRUCTION_SET_INTRINSIC}")
74+
check_instruction_set("${INSTRUCTION_SET_NAME}" "${INSTRUCTION_SET_FLAG}" "${INSTRUCTION_SET_INTRINSIC}")
75+
endforeach()
76+
77+
message(STATUS "Detected CPU Architecture: ${AVX_NAME}")
78+
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_SAVE}")

CMake/FindAVX.cmake

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)