mirror of
https://github.com/InoriRus/Kyty.git
synced 2026-08-28 05:06:40 +00:00
add support of clang 14.0.3
This commit is contained in:
@@ -1235,7 +1235,7 @@ ByteBuffer ZipReader::ExtractFile(int file_index)
|
||||
|
||||
if (file_index < 0 || IsFileDirectory(file_index))
|
||||
{
|
||||
return ByteBuffer();
|
||||
return {};
|
||||
}
|
||||
|
||||
ZipFileStat s {};
|
||||
@@ -1243,7 +1243,7 @@ ByteBuffer ZipReader::ExtractFile(int file_index)
|
||||
|
||||
if (s.m_uncomp_size == 0)
|
||||
{
|
||||
return ByteBuffer();
|
||||
return {};
|
||||
}
|
||||
|
||||
void* ptr = mz_zip_reader_extract_to_heap(&m_p->zip, file_index, &size, 0);
|
||||
|
||||
@@ -28,7 +28,7 @@ using Math::Rand;
|
||||
|
||||
struct StatementPrivate
|
||||
{
|
||||
explicit StatementPrivate(ConnectionPrivate* p): p_stmt(nullptr), m_p(p), text(nullptr) {}
|
||||
explicit StatementPrivate(ConnectionPrivate* p): m_p(p) {}
|
||||
|
||||
void Prepare(const char* sql_text);
|
||||
[[nodiscard]] Statement::State Step() const;
|
||||
@@ -46,9 +46,9 @@ struct StatementPrivate
|
||||
|
||||
void DbgTest() const;
|
||||
|
||||
sqlite3_stmt* p_stmt;
|
||||
ConnectionPrivate* m_p;
|
||||
const char* text;
|
||||
sqlite3_stmt* p_stmt = nullptr;
|
||||
ConnectionPrivate* m_p = nullptr;
|
||||
const char* text = nullptr;
|
||||
};
|
||||
|
||||
struct ConnectionPrivate
|
||||
|
||||
@@ -389,7 +389,7 @@ Date Date::FromMacros(const String& date)
|
||||
|
||||
if (lst.Size() != 3)
|
||||
{
|
||||
return Date();
|
||||
return {};
|
||||
}
|
||||
|
||||
static const char* month_str[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
@@ -406,7 +406,7 @@ Date Date::FromMacros(const String& date)
|
||||
|
||||
if (month < 0)
|
||||
{
|
||||
return Date();
|
||||
return {};
|
||||
}
|
||||
|
||||
return Date(lst.At(2).ToInt32(), month, lst.At(1).ToInt32());
|
||||
@@ -673,7 +673,7 @@ Time Time::operator+(int secs) const
|
||||
|
||||
if (IsInvalid())
|
||||
{
|
||||
return Time();
|
||||
return {};
|
||||
}
|
||||
|
||||
int r = m_ms + ms_secs;
|
||||
@@ -698,7 +698,7 @@ Time Time::operator-(int secs) const
|
||||
|
||||
if (IsInvalid())
|
||||
{
|
||||
return Time();
|
||||
return {};
|
||||
}
|
||||
|
||||
int r = m_ms - ms_secs;
|
||||
@@ -768,7 +768,7 @@ DateTime DateTime::FromSystem()
|
||||
|
||||
if (t.is_invalid)
|
||||
{
|
||||
return DateTime();
|
||||
return {};
|
||||
}
|
||||
|
||||
return DateTime(Date(t.Year, t.Month, t.Day), Time(t.Hour, t.Minute, t.Second, t.Milliseconds));
|
||||
@@ -781,7 +781,7 @@ DateTime DateTime::FromSystemUTC()
|
||||
|
||||
if (t.is_invalid)
|
||||
{
|
||||
return DateTime();
|
||||
return {};
|
||||
}
|
||||
|
||||
return DateTime(Date(t.Year, t.Month, t.Day), Time(t.Hour, t.Minute, t.Second, t.Milliseconds));
|
||||
@@ -848,26 +848,29 @@ uint64_t DateTime::DistanceMs(const DateTime& other) const
|
||||
jd_t j1 = other.m_date.JulianDay();
|
||||
jd_t j2 = m_date.JulianDay();
|
||||
|
||||
return int64_t(j2 - j1 - 1) * int64_t(TIME_MS_IN_DAY) + (int64_t(TIME_MS_IN_DAY) - int64_t(other.m_time.MsecTotal())) +
|
||||
int64_t(m_time.MsecTotal());
|
||||
return static_cast<int64_t>(j2 - j1 - 1) * static_cast<int64_t>(TIME_MS_IN_DAY) +
|
||||
(static_cast<int64_t>(TIME_MS_IN_DAY) - static_cast<int64_t>(other.m_time.MsecTotal())) +
|
||||
static_cast<int64_t>(m_time.MsecTotal());
|
||||
}
|
||||
|
||||
DateTime DateTime::FromSQLiteJulian(double jd)
|
||||
{
|
||||
double i = NAN;
|
||||
double f = modf(jd + 0.5, &i);
|
||||
return DateTime(Date(jd_t(i)), Time(int(f * double(TIME_MS_IN_DAY))));
|
||||
return DateTime(Date(static_cast<jd_t>(i)), Time(static_cast<int>(f * static_cast<double>(TIME_MS_IN_DAY))));
|
||||
}
|
||||
|
||||
double DateTime::ToSQLiteJulian() const
|
||||
{
|
||||
return -0.5 + double(GetDate().JulianDay()) + double(GetTime().MsecTotal()) / double(TIME_MS_IN_DAY);
|
||||
return -0.5 + static_cast<double>(GetDate().JulianDay()) +
|
||||
static_cast<double>(GetTime().MsecTotal()) / static_cast<double>(TIME_MS_IN_DAY);
|
||||
}
|
||||
|
||||
int64_t DateTime::ToSQLiteJulianInt64() const
|
||||
{
|
||||
return -(static_cast<int64_t>(TIME_MS_IN_DAY)) / 2 + int64_t(GetDate().JulianDay()) * (static_cast<int64_t>(TIME_MS_IN_DAY)) +
|
||||
int64_t(GetTime().MsecTotal());
|
||||
return -(static_cast<int64_t>(TIME_MS_IN_DAY)) / 2 +
|
||||
static_cast<int64_t>(GetDate().JulianDay()) * (static_cast<int64_t>(TIME_MS_IN_DAY)) +
|
||||
static_cast<int64_t>(GetTime().MsecTotal());
|
||||
}
|
||||
|
||||
DateTime DateTime::FromUnix(double seconds)
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
#endif
|
||||
|
||||
#ifdef KYTY_UNDECORATE
|
||||
//String unDName(const String &mangled,
|
||||
// String unDName(const String &mangled,
|
||||
// void* (*memget)(size_t), void (*memfree)(void*),
|
||||
// unsigned short int flags);
|
||||
// unsigned short int flags);
|
||||
#endif
|
||||
|
||||
namespace Kyty::Core {
|
||||
@@ -199,7 +199,7 @@ void DebugMap::LoadCsv()
|
||||
|
||||
#endif
|
||||
|
||||
//EXIT("1");
|
||||
// EXIT("1");
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -269,7 +269,7 @@ void DebugMap::LoadMsvcLink(const String& name, int mode)
|
||||
if (DBG_PRINTF)
|
||||
{
|
||||
printf("%016" PRIx64 "; %s; %s\n", static_cast<uint64_t>(addr), func.utf8_str().GetData(), obj.utf8_str().GetData());
|
||||
fflush(stdout);
|
||||
// int ok = fflush(stdout);
|
||||
}
|
||||
|
||||
DebugFunctionInfo inf = {addr, 0, func.utf8_str(), obj.utf8_str()};
|
||||
@@ -365,7 +365,7 @@ void DebugMap::LoadMsvcLldLink(const String& name, int mode)
|
||||
if (DBG_PRINTF)
|
||||
{
|
||||
printf("%016" PRIx64 "; %s; %s\n", static_cast<uint64_t>(addr), func.utf8_str().GetData(), obj.utf8_str().GetData());
|
||||
fflush(stdout);
|
||||
// fflush(stdout);
|
||||
}
|
||||
|
||||
DebugFunctionInfo inf = {addr, 0, func.utf8_str(), obj.utf8_str()};
|
||||
@@ -417,7 +417,7 @@ void DebugMap::LoadMsvcLldLink(const String& name, int mode)
|
||||
{
|
||||
m_p->data[i - 1].length = m_p->data[i].addr - m_p->data[i - 1].addr;
|
||||
}
|
||||
|
||||
|
||||
#ifdef KYTY_UNDECORATE
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
// IWYU pragma: no_include <fileapi.h>
|
||||
// IWYU pragma: no_include <windows.h>
|
||||
// IWYU pragma: no_include <winbase.h>
|
||||
|
||||
#if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS
|
||||
#ifdef CreateDirectory
|
||||
@@ -931,7 +932,7 @@ DateTime File::GetLastAccessTimeUTC(const String& name)
|
||||
|
||||
if (t.is_invalid)
|
||||
{
|
||||
return DateTime();
|
||||
return {};
|
||||
}
|
||||
|
||||
return DateTime(Date(t.Year, t.Month, t.Day), Time(t.Hour, t.Minute, t.Second, t.Milliseconds));
|
||||
@@ -944,7 +945,7 @@ DateTime File::GetLastWriteTimeUTC(const String& name)
|
||||
|
||||
if (t.is_invalid)
|
||||
{
|
||||
return DateTime();
|
||||
return {};
|
||||
}
|
||||
|
||||
return DateTime(Date(t.Year, t.Month, t.Day), Time(t.Hour, t.Minute, t.Second, t.Milliseconds));
|
||||
|
||||
@@ -426,6 +426,13 @@ static bool MSpaceInternalInit(MSpaceContext& ctx, const char* name, void* base,
|
||||
|
||||
ctx = MSpaceContext();
|
||||
|
||||
int s = snprintf(ctx.name, sizeof(ctx.name), "%s", name);
|
||||
|
||||
if (static_cast<size_t>(s) >= sizeof(ctx.name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ctx.base = static_cast<MSpaceBlock*>(base);
|
||||
ctx.capacity = (capacity / sizeof(MSpaceBlock)) - 2;
|
||||
|
||||
@@ -438,8 +445,6 @@ static bool MSpaceInternalInit(MSpaceContext& ctx, const char* name, void* base,
|
||||
ctx.mutex = (thread_safe ? new Core::Mutex : nullptr);
|
||||
ctx.dbg_callback = dbg_callback;
|
||||
|
||||
snprintf(ctx.name, sizeof(ctx.name), "%s", name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,11 @@ public:
|
||||
KYTY_CLASS_NO_COPY(MemLock);
|
||||
|
||||
#ifdef MEM_TRACKER
|
||||
[[nodiscard]] bool IsRecursive() const { return g_mem_depth > 1; } // NOLINT(readability-convert-member-functions-to-static)
|
||||
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
|
||||
[[nodiscard]] bool IsRecursive() const
|
||||
{
|
||||
return g_mem_depth > 1;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -193,7 +197,7 @@ void core_memory_init()
|
||||
void* mem_alloc_check_alignment(void* ptr)
|
||||
{
|
||||
#ifdef MEM_ALLOC_ALIGNED
|
||||
if ((uintptr_t(ptr) & uintptr_t(MEM_ALLOC_ALIGN - 1)) != 0u)
|
||||
if ((reinterpret_cast<uintptr_t>(ptr) & static_cast<uintptr_t>(MEM_ALLOC_ALIGN - 1)) != 0u)
|
||||
{
|
||||
EXIT("mem alloc not aligned!\n");
|
||||
}
|
||||
|
||||
@@ -1155,7 +1155,7 @@ String String::Mid(uint32_t first, uint32_t count) const
|
||||
|
||||
if (first >= size)
|
||||
{
|
||||
return String();
|
||||
return {};
|
||||
}
|
||||
|
||||
if (first + count > size)
|
||||
@@ -1225,7 +1225,7 @@ String String::TrimRight() const
|
||||
return Mid(0, size - i);
|
||||
}
|
||||
}
|
||||
return String();
|
||||
return {};
|
||||
}
|
||||
|
||||
String String::TrimLeft() const
|
||||
@@ -1240,7 +1240,7 @@ String String::TrimLeft() const
|
||||
return Mid(i, size - i);
|
||||
}
|
||||
}
|
||||
return String();
|
||||
return {};
|
||||
}
|
||||
|
||||
String String::Trim() const
|
||||
@@ -1902,7 +1902,7 @@ String String::DirectoryWithoutFilename() const
|
||||
|
||||
if (index == STRING_INVALID_INDEX)
|
||||
{
|
||||
return String();
|
||||
return {};
|
||||
}
|
||||
|
||||
return Left(index + 1);
|
||||
@@ -1938,7 +1938,7 @@ String String::ExtensionWithoutFilename() const
|
||||
|
||||
if (index == STRING_INVALID_INDEX)
|
||||
{
|
||||
return String();
|
||||
return {};
|
||||
}
|
||||
|
||||
return Mid(index);
|
||||
@@ -1966,7 +1966,7 @@ String String::RemoveLast(uint32_t num) const
|
||||
|
||||
if (num >= size)
|
||||
{
|
||||
return String();
|
||||
return {};
|
||||
}
|
||||
|
||||
return Left(size - num);
|
||||
@@ -1978,7 +1978,7 @@ String String::RemoveFirst(uint32_t num) const
|
||||
|
||||
if (num >= size)
|
||||
{
|
||||
return String();
|
||||
return {};
|
||||
}
|
||||
|
||||
return Right(size - num);
|
||||
@@ -2097,7 +2097,7 @@ String String::SortChars() const
|
||||
|
||||
if (IsEmpty())
|
||||
{
|
||||
return String();
|
||||
return {};
|
||||
}
|
||||
auto size = m_data->Size() - 1;
|
||||
Vector<char32_t> d(size);
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
//#define KYTY_DEBUG_LOCKS_TIMED
|
||||
|
||||
#if !(defined(KYTY_DEBUG_LOCKS) || defined(KYTY_DEBUG_LOCKS_TIMED)) && defined(KYTY_WIN_CS)
|
||||
#include <windows.h>
|
||||
#include <windows.h> // IWYU pragma: keep
|
||||
// IWYU pragma: no_include <winbase.h>
|
||||
constexpr DWORD KYTY_CS_SPIN_COUNT = 4000;
|
||||
|
||||
// IWYU pragma: no_include <minwindef.h>
|
||||
@@ -84,8 +85,14 @@ struct MutexPrivate
|
||||
std::recursive_timed_mutex m_mutex;
|
||||
#else
|
||||
#ifdef KYTY_WIN_CS
|
||||
MutexPrivate() { InitializeCriticalSectionAndSpinCount(&m_cs, KYTY_CS_SPIN_COUNT); }
|
||||
~MutexPrivate() { DeleteCriticalSection(&m_cs); }
|
||||
MutexPrivate()
|
||||
{
|
||||
InitializeCriticalSectionAndSpinCount(&m_cs, KYTY_CS_SPIN_COUNT);
|
||||
}
|
||||
~MutexPrivate()
|
||||
{
|
||||
DeleteCriticalSection(&m_cs);
|
||||
}
|
||||
KYTY_CLASS_NO_COPY(MutexPrivate);
|
||||
CRITICAL_SECTION m_cs {};
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user