Skip to content

Commit

Permalink
Merge branch 'dev' into docs_change
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis authored Aug 2, 2023
2 parents 2c1f586 + f5bcb01 commit ec67da6
Show file tree
Hide file tree
Showing 45 changed files with 3,266 additions and 802 deletions.
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TODO: Discuss about -readability-identifier-length, -readability-avoid-const-params-in-decls
Checks: "-*,bugprone-*,cert-*,clang-analyzer-*,concurrency-*,cppcoreguidelines-*,llvm-namespace-comment,modernize-*,performance-*,portability-*,readability-*,-bugprone-implicit-widening-of-multiplication-result, -bugprone-easily-swappable-parameters,-readability-identifier-length,-portability-restrict-system-includes,-modernize-use-trailing-return-type,-cppcoreguidelines-non-private-member-variables-in-classes,-readability-avoid-const-params-in-decls"
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@
"koko",
"moyai",
"kaaba",
"stringified"
"stringified",
"STDCORO"
],
"flagWords": [
"hte"
Expand Down
33 changes: 33 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,46 @@
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "Release",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
},
{
"name": "x64-Debug-Coro",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DDPP_CORO=on",
"buildCommandArgs": "",
"ctestCommandArgs": ""
},
{
"name": "x64-Release-Coro",
"generator": "Ninja",
"configurationType": "Release",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DDPP_CORO=on",
"buildCommandArgs": "",
"ctestCommandArgs": ""
}
]
}
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ When contributing to this repository, please do not feel intimidated! We welcome
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.

8. Automated changes e.g. via grammarly or a static analysis tool will not usually be accepted into the code without proper thought out justification (by a human being, not an AI or an App) as to why the changes are required. Generally a PR should do more than fix a single spelling error for example as this just takes precious time for something which could be resolved a direct commit to the dev branch.
18 changes: 10 additions & 8 deletions buildtools/classes/Generator/CoroGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function generateHeaderStart(): string
public function generateCppStart(): string
{
return $this->generateHeaderStart() . <<<EOT
#ifdef DPP_CORO
#include <dpp/export.h>
#include <dpp/snowflake.h>
Expand All @@ -80,6 +81,7 @@ public function checkForChanges(): bool
}

echo "-- Autogenerating include/dpp/cluster_coro_calls.h\n";
echo "-- Autogenerating src/dpp/cluster_coro_calls.cpp\n";
return true;
}

Expand All @@ -88,19 +90,15 @@ public function checkForChanges(): bool
*/
public function generateHeaderDef(string $returnType, string $currentFunction, string $parameters, string $noDefaults, string $parameterTypes, 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";
return "awaitable<confirmation_callback_t> co_{$currentFunction}($parameters);\n\n";
}

/**
* @inheritDoc
*/
public function generateCppDef(string $returnType, string $currentFunction, string $parameters, string $noDefaults, string $parameterTypes, string $parameterNames): string
{
return '';
return "awaitable<confirmation_callback_t> cluster::co_${currentFunction}($noDefaults) {\n\treturn {this, static_cast<void (cluster::*)($parameterTypes". (!empty($parameterTypes) ? ", " : "") . "command_completion_event_t)>(&cluster::$currentFunction)$parameterNames};\n}\n\n";
}

/**
Expand All @@ -116,7 +114,7 @@ public function getCommentArray(): array
*/
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";
$content .= "awaitable<http_request_completion_t> 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\n";
file_put_contents('include/dpp/cluster_coro_calls.h', $content);
}

Expand All @@ -125,7 +123,11 @@ public function saveHeader(string $content): void
*/
public function saveCpp(string $cppcontent): void
{
/* No cpp file to save, code is all inline */
$cppcontent .= "dpp::awaitable<dpp::http_request_completion_t> dpp::cluster::co_request(const std::string &url, http_method method, const std::string &postdata, const std::string &mimetype, const std::multimap<std::string, std::string> &headers) {\n\treturn awaitable<http_request_completion_t>{[&](auto &&cc) { this->request(url, method, cc, postdata, mimetype, headers); }};\n}
#endif
";
file_put_contents('src/dpp/cluster_coro_calls.cpp', $cppcontent);
}

}
22 changes: 20 additions & 2 deletions buildtools/emojis.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,28 @@

echo "-- Autogenrating include/dpp/unicode_emoji.h\n";

$header = "#pragma once\n\nnamespace dpp { namespace unicode_emoji {\n";
$url = "https://raw.githubusercontent.com/ArkinSolomon/discord-emoji-converter/master/emojis.json";

$header = <<<END
#pragma once
namespace dpp {
/**
* The unicode emojis in this namespace are auto-generated from {$url}
*
* If you want to use this, you have to pull the header in separately. e.g.
* ```cpp
* #include <dpp/dpp.h>
* #include <dpp/unicode_emoji.h>
* ```
*/
namespace unicode_emoji {
END;

/* This JSON is generated originally via the NPM package maintained by Discord themselves at https://www.npmjs.com/package/discord-emoji */
$emojis = json_decode(file_get_contents("https://raw.githubusercontent.com/ArkinSolomon/discord-emoji-converter/master/emojis.json"));
$emojis = json_decode(file_get_contents($url));
if ($emojis) {
foreach ($emojis as $name=>$code) {
if (preg_match("/^\d+/", $name)) {
Expand Down
1 change: 1 addition & 0 deletions docpages/04_advanced_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
* \subpage coding-standards "Coding Style Standards"
* \subpage unit-tests "Unit Tests"
* \subpage lambdas-and-locals "Ownership of local variables and safely transferring into a lambda"
* \subpage coroutines "Advanced commands with coroutines"
7 changes: 7 additions & 0 deletions docpages/05_deprecated_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
\page deprecated Deprecated List

### Deprecation policy

We keep things marked as depreciated until next major API version.
If discord removes the function, we may remove the method from the library or replace it with a thrown exception depending on the type of function and at our discretion.
Such functions which are made to throw will then be removed at the next major API version.
Loading

0 comments on commit ec67da6

Please sign in to comment.