Skip to content

Commit

Permalink
Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
edo9300 committed Sep 6, 2024
1 parent 4936241 commit 3cc86c6
Show file tree
Hide file tree
Showing 45 changed files with 412 additions and 2,276 deletions.
15 changes: 13 additions & 2 deletions deps/gframe/Android/COSAndroidOperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@
#endif

#include <sys/utsname.h>
#include <android/ndk-version.h>
#if __NDK_MAJOR__ >= 19
#include <android/api-level.h>
#include <fmt/format.h>
#else
#include <sys/system_properties.h>
#include <cstdlib>
static inline int android_get_device_api_level() {
char value[92] = { 0 };
if (__system_property_get("ro.build.version.sdk", value) < 1) return -1;
int api_level = std::atoi(value);
return (api_level > 0) ? api_level : -1;
}
#endif
#include "COSAndroidOperator.h"
#include "porting_android.h"

Expand All @@ -19,7 +30,7 @@ COSAndroidOperator::COSAndroidOperator() {
#endif
struct utsname LinuxInfo;
uname(&LinuxInfo);
const auto verstring = fmt::format("Android version: {} {} {} {} {}",
const auto verstring = epro::format("Android version: {} {} {} {} {}",
android_get_device_api_level(), LinuxInfo.sysname, LinuxInfo.release, LinuxInfo.version, LinuxInfo.machine);
OperatingSystem = { verstring.data(), (u32)verstring.size() };
}
Expand Down
2 changes: 1 addition & 1 deletion deps/gframe/CGUISkinSystem/CGUISkinSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ void CGUISkinSystem::loadCustomColors(gui::CImageGUISkin * skin) {
#include "../custom_skin_enum.inl"
#undef DECLR
};
constexpr auto wtmp = L"Skin/Custom/"_sv;
constexpr auto wtmp = L"Skin/Custom/"sv;
auto* children = registry->listNodeChildren(L"", wtmp.data());
if(!children)
return;
Expand Down
2 changes: 1 addition & 1 deletion deps/gframe/CGUITTFont/CGUITTFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ CGUITTGlyphPage* CGUITTFont::getLastGlyphPage() const {

CGUITTGlyphPage* CGUITTFont::createGlyphPage(const u8& pixel_mode) {
// Name of our page.
auto name = fmt::format("TTFontGlyphPage_{}.{}.{}._{}",
auto name = epro::format("TTFontGlyphPage_{}.{}.{}._{}",
tt_face->family_name, tt_face->style_name, size, Glyph_Pages.size()); // The newly created page will be at the end of the collection.

// Create the new page.
Expand Down
46 changes: 16 additions & 30 deletions deps/gframe/CGUITTFont/irrUString.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ constexpr uchar32_t UTF_REPLACEMENT_CHARACTER = 0xFFFD;
//! \param high The high value of the pair.
//! \param low The low value of the pair.
//! \return The UTF-32 character expressed by the surrogate pair.
inline uchar32_t toUTF32(uchar16_t high, uchar16_t low) {
inline constexpr uchar32_t toUTF32(uchar16_t high, uchar16_t low) {
// Convert the surrogate pair into a single UTF-32 character.
uchar32_t x = ((high & ((1 << 6) - 1)) << 10) | (low & ((1 << 10) - 1));
uchar32_t wu = ((high >> 6) & ((1 << 5) - 1)) + 1;
Expand Down Expand Up @@ -435,33 +435,27 @@ class ustring16 {
}


#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4127) //conditional expression is constant
#endif
//! Returns the length of a ustring16 in full characters.
//! \return Length of a ustring16 in full characters.
u32 size() const {
if(sizeof(wchar_t) == 4)
if constexpr(sizeof(wchar_t) == 4) {
return size_raw_;

if(size_ != 0xffffffff)
return size_;

const uchar16_t* array = reinterpret_cast<const uchar16_t*>(data_);
size_ = 0;
for(u32 i = 0; i < size_raw_; ++i, ++size_) {
if(UTF16_IS_SURROGATE_HI(array[i])) {
if((i + 1) >= size_raw_)
break;
++i;
} else {
if(size_ != 0xffffffff)
return size_;

const uchar16_t* array = reinterpret_cast<const uchar16_t*>(data_);
size_ = 0;
for(u32 i = 0; i < size_raw_; ++i, ++size_) {
if(UTF16_IS_SURROGATE_HI(array[i])) {
if((i + 1) >= size_raw_)
break;
++i;
}
}
return size_;
}
return size_;
}
#ifdef _MSC_VER
#pragma warning(pop) //conditional expression is constant
#endif


//! Informs if the ustring is empty or not.
Expand Down Expand Up @@ -515,23 +509,15 @@ class ustring16 {
}


#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4127) //conditional expression is constant
#endif
//! Validate the existing ustring16, checking for valid surrogate pairs and checking for proper termination.
//! \return A reference to our current string.
void validate() {
// Validate all unicode characters.
if(sizeof(wchar_t) == 4) {
if constexpr(sizeof(wchar_t) == 4) {
size_ = size_raw_;
return;
}
}
#ifdef _MSC_VER
#pragma warning(pop) //conditional expression is constant
#endif


//! Returns the raw number of UTF-16 code points in the string which includes the individual surrogates.
//! \return The raw number of UTF-16 code points, excluding the trialing NUL.
Expand Down
2 changes: 1 addition & 1 deletion deps/gframe/RNG/SplitMix64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SplitMix64
constexpr SplitMix64(StateType initialState) noexcept : s(initialState)
{}

ResultType operator()() noexcept
constexpr ResultType operator()() noexcept
{
uint64_t z = (s += 0x9e3779b97f4a7c15);
z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
Expand Down
2 changes: 1 addition & 1 deletion deps/gframe/RNG/Xoshiro256.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Xoshiro256StarStar
constexpr Xoshiro256StarStar(const StateType& initialState) noexcept : s(initialState)
{}

ResultType operator()() noexcept
constexpr ResultType operator()() noexcept
{
const uint64_t result = rotl(s[1] * 5, 7) * 9;

Expand Down
2 changes: 1 addition & 1 deletion deps/gframe/address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Host Host::resolve(epro::stringview address, uint16_t port) {
hints.ai_flags = EVUTIL_AI_ADDRCONFIG;
auto getAddrInfo = [&](auto ai_family) {
hints.ai_family = ai_family;
return evutil_getaddrinfo(address.data(), fmt::to_string(port).data(), &hints, &answer) == 0;
return evutil_getaddrinfo(address.data(), epro::to_string(port).data(), &hints, &answer) == 0;
};
//Give priority to ipv4 addresses
if(getAddrInfo(AF_INET)) {
Expand Down
6 changes: 3 additions & 3 deletions deps/gframe/address.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <cstdint>
#include <string>
#include <fmt/core.h>
#include "fmt.h"
#include "bufferio.h"
#include "text_types.h"

Expand Down Expand Up @@ -60,8 +60,8 @@ struct fmt::formatter<epro::Address, T> {
template<typename FormatContext>
auto format(const epro::Address& address, FormatContext& ctx) const {
static constexpr auto format_str = CHAR_T_STRINGVIEW(T, "{}");
return fmt::format_to(ctx.out(), format_str.data(), address.format<T>());
return format_to(ctx.out(), format_str, address.format<T>());
}
};

#endif //ADDRESS_H
#endif //ADDRESS_H
Loading

0 comments on commit 3cc86c6

Please sign in to comment.