Skip to content

Commit

Permalink
upgrade to c++20
Browse files Browse the repository at this point in the history
  • Loading branch information
nomi-san committed Jan 11, 2024
1 parent e3fc616 commit 4a36871
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
6 changes: 4 additions & 2 deletions core/core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@
<AdditionalIncludeDirectories>.;src/</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<ConformanceMode>false</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down Expand Up @@ -208,7 +209,8 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>
<ConformanceMode>false</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
12 changes: 6 additions & 6 deletions core/src/browser/assets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static const set<wstr> KNOWN_ASSETS
L"eot", L"ttf", L"otf",
};

static const auto SCRIPT_IMPORT_CSS = u8R"(
static const auto SCRIPT_IMPORT_CSS = R"(
(async function () {
if (document.readyState !== 'complete')
await new Promise(res => document.addEventListener('DOMContentLoaded', res));
Expand All @@ -39,33 +39,33 @@ static const auto SCRIPT_IMPORT_CSS = u8R"(
})();
)";

static const auto SCRIPT_IMPORT_JSON = u8R"(
static const auto SCRIPT_IMPORT_JSON = R"(
const url = import.meta.url.replace(/\?.*$/, '');
const content = await fetch(url).then(r => r.text());
export default JSON.parse(content);
)";

static const auto SCRIPT_IMPORT_TOML = u8R"(
static const auto SCRIPT_IMPORT_TOML = R"(
const { parse } = __p('toml');
const url = import.meta.url.replace(/\?.*$/, '');
const content = await fetch(url).then(r => r.text());
export default parse(content);
)";

static const auto SCRIPT_IMPORT_YAML = u8R"(
static const auto SCRIPT_IMPORT_YAML = R"(
const { parse } = __p('yaml');
const url = import.meta.url.replace(/\?.*$/, '');
const content = await fetch(url).then(r => r.text());
export default parse(content);
)";

static const auto SCRIPT_IMPORT_RAW = u8R"(
static const auto SCRIPT_IMPORT_RAW = R"(
const url = import.meta.url.replace(/\?.*$/, '');
const content = await fetch(url).then(r => r.text());
export default content;
)";

static const auto SCRIPT_IMPORT_URL = u8R"(
static const auto SCRIPT_IMPORT_URL = R"(
const url = import.meta.url.replace(/\?.*$/, '');
export default url;
)";
Expand Down
7 changes: 5 additions & 2 deletions core/src/browser/riotclient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,11 @@ void SetRiotClientCredentials(const wstr &appPort, const wstr &authToken)
origin_.assign(L"https://127.0.0.1:");
origin_.append(appPort);

auto cred = L"riot:" + authToken;
CefScopedStr base64 = cef_base64encode(str{ cred.begin(), cred.end() }.data(), cred.length());
str cred = "riot:";
for (wchar_t c : authToken)
cred.append(1, (char)c);

CefScopedStr base64 = cef_base64encode(cred.data(), cred.length());

authorization_.assign(L"Basic ");
authorization_.append(base64.cstr());
Expand Down
10 changes: 5 additions & 5 deletions core/src/commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ struct CefRefCount : public T
{
template <typename U>
CefRefCount(const U *) noexcept : T{}, ref_(1) {
base.size = sizeof(U);
base.add_ref = _Base_AddRef;
base.release = _Base_Release;
base.has_one_ref = _Base_HasOneRef;
base.has_at_least_one_ref = _Base_HasAtLeastOneRef;
T::base.size = sizeof(U);
T::base.add_ref = _Base_AddRef;
T::base.release = _Base_Release;
T::base.has_one_ref = _Base_HasOneRef;
T::base.has_at_least_one_ref = _Base_HasAtLeastOneRef;
self_delete_ = [](void *self) noexcept { delete static_cast<U *>(self); };
}

Expand Down
8 changes: 4 additions & 4 deletions core/src/utils/cefstr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// utf8 string helpers

CefStrUtf8::CefStrUtf8() : cef_string_utf8_t{ "", 0, nullptr }
CefStrUtf8::CefStrUtf8() : cef_string_utf8_t{ (char *)"", 0, nullptr }
{
}

Expand All @@ -26,7 +26,7 @@ str CefStrUtf8::cstr() const

// utf16 string helpers

CefStrBase::CefStrBase() : cef_string_t{ L"", 0, nullptr }
CefStrBase::CefStrBase() : cef_string_t{ (char16 *)u"", 0, nullptr }
{
}

Expand Down Expand Up @@ -120,7 +120,7 @@ CefStrBase CefStr::borrow(const cef_string_t *s)
}
else
{
base.str = L"";
base.str = (char16 *)u"";
base.length = 0;
}

Expand All @@ -138,7 +138,7 @@ CefScopedStr::CefScopedStr(cef_string_userfree_t uf) : CefStrBase(), str_(uf)
}
else
{
cef_string_t::str = L"";
cef_string_t::str = (char16 *)u"";
cef_string_t::length = 0;
}
}
Expand Down

0 comments on commit 4a36871

Please sign in to comment.