Update release

This commit is contained in:
vczh
2024-02-26 03:40:56 -08:00
parent 7c296af0f4
commit 9688e6bd4f
21 changed files with 3405 additions and 2837 deletions
+10 -10
View File
@@ -4905,9 +4905,9 @@ GuiGraphicsHost
timerManager.Play();
DateTime now = DateTime::UtcTime();
if (now.totalMilliseconds - lastCaretTime >= CaretInterval)
if (now.osMilliseconds - lastCaretTime >= CaretInterval)
{
lastCaretTime = now.totalMilliseconds;
lastCaretTime = now.osMilliseconds;
if (focusedComposition && focusedComposition->HasEventReceiver())
{
focusedComposition->GetEventReceiver()->caretNotify.Execute(GuiEventArgs(focusedComposition));
@@ -16337,7 +16337,7 @@ GuiTimedAnimation
class GuiTimedAnimation : public Object, public virtual IGuiAnimation
{
protected:
DateTime startTime;
DateTime startUtcTime;
vuint64_t time;
bool running = false;
@@ -16352,7 +16352,7 @@ GuiTimedAnimation
void Start()override
{
startTime = DateTime::LocalTime();
startUtcTime = DateTime::UtcTime();
time = 0;
running = true;
}
@@ -16365,7 +16365,7 @@ GuiTimedAnimation
void Resume()override
{
startTime = DateTime::LocalTime();
startUtcTime = DateTime::UtcTime();
running = true;
}
@@ -16373,7 +16373,7 @@ GuiTimedAnimation
{
if (running)
{
return time + (DateTime::LocalTime().totalMilliseconds - startTime.totalMilliseconds);
return time + (DateTime::UtcTime().osMilliseconds - startUtcTime.osMilliseconds);
}
else
{
@@ -59037,7 +59037,7 @@ SharedAsyncService::DelayItem
:service(_service)
,proc(_proc)
,status(INativeDelay::Pending)
,executeTime(DateTime::LocalTime().Forward(milliseconds))
, executeUtcTime(DateTime::UtcTime().Forward(milliseconds))
,executeInMainThread(_executeInMainThread)
{
}
@@ -59057,7 +59057,7 @@ SharedAsyncService::DelayItem
{
if(status==INativeDelay::Pending)
{
executeTime=DateTime::LocalTime().Forward(milliseconds);
executeUtcTime =DateTime::UtcTime().Forward(milliseconds);
return true;
}
}
@@ -59095,7 +59095,7 @@ SharedAsyncService
void SharedAsyncService::ExecuteAsyncTasks()
{
DateTime now=DateTime::LocalTime();
auto now=DateTime::UtcTime();
Array<TaskItem> items;
List<Ptr<DelayItem>> executableDelayItems;
@@ -59107,7 +59107,7 @@ SharedAsyncService
for(vint i=delayItems.Count()-1;i>=0;i--)
{
Ptr<DelayItem> item=delayItems[i];
if(now.filetime>=item->executeTime.filetime)
if(now >= item->executeUtcTime)
{
item->status=INativeDelay::Executing;
executableDelayItems.Add(item);
+1 -1
View File
@@ -27302,7 +27302,7 @@ namespace vl
SharedAsyncService* service;
Func<void()> proc;
ExecuteStatus status;
DateTime executeTime;
DateTime executeUtcTime;
bool executeInMainThread;
ExecuteStatus GetStatus()override;
+118 -76
View File
@@ -80,86 +80,128 @@ namespace vl
DateTime
***********************************************************************/
DateTime ConvertTMToDateTime(tm* timeinfo, vint milliseconds)
class LinuxDateTimeImpl : public Object, public virtual IDateTimeImpl
{
time_t timer = mktime(timeinfo);
DateTime dt;
dt.year = timeinfo->tm_year + 1900;
dt.month = timeinfo->tm_mon + 1;
dt.day = timeinfo->tm_mday;
dt.dayOfWeek = timeinfo->tm_wday;
dt.hour = timeinfo->tm_hour;
dt.minute = timeinfo->tm_min;
dt.second = timeinfo->tm_sec;
dt.milliseconds = milliseconds;
public:
// in Linux and macOS, filetime will be mktime(t) * 1000 + gettimeofday().tv_usec / 1000
dt.filetime = (vuint64_t)timer * 1000 + milliseconds;
dt.totalMilliseconds = (vuint64_t)timer * 1000 + milliseconds;
return dt;
}
static void TimeToOSInternal(time_t timer, vint milliseconds, vuint64_t& osInternal)
{
osInternal = (vuint64_t)timer * 1000 + milliseconds;
}
DateTime DateTime::LocalTime()
static void OSInternalToTime(vuint64_t osInternal, time_t& timer, vint& milliseconds)
{
timer = (time_t)(osInternal / 1000);
milliseconds = (vint)(osInternal % 1000);
}
static vuint64_t ConvertTMTToOSInternal(tm* timeinfo, vint milliseconds)
{
time_t timer = mktime(timeinfo);
vuint64_t osInternal;
TimeToOSInternal(timer, milliseconds, osInternal);
return osInternal;
}
static DateTime ConvertTMToDateTime(tm* timeinfo, vint milliseconds)
{
time_t timer = mktime(timeinfo);
DateTime dt;
dt.year = timeinfo->tm_year + 1900;
dt.month = timeinfo->tm_mon + 1;
dt.day = timeinfo->tm_mday;
dt.dayOfWeek = timeinfo->tm_wday;
dt.hour = timeinfo->tm_hour;
dt.minute = timeinfo->tm_min;
dt.second = timeinfo->tm_sec;
dt.milliseconds = milliseconds;
// in Linux and macOS, filetime will be mktime(t) * 1000 + gettimeofday().tv_usec / 1000
TimeToOSInternal(timer, milliseconds, dt.osInternal);
dt.osMilliseconds = dt.osInternal;
return dt;
}
DateTime FromDateTime(vint _year, vint _month, vint _day, vint _hour, vint _minute, vint _second, vint _milliseconds) override
{
tm timeinfo;
memset(&timeinfo, 0, sizeof(timeinfo));
timeinfo.tm_year = _year - 1900;
timeinfo.tm_mon = _month - 1;
timeinfo.tm_mday = _day;
timeinfo.tm_hour = _hour;
timeinfo.tm_min = _minute;
timeinfo.tm_sec = _second;
timeinfo.tm_isdst = -1;
return ConvertTMToDateTime(&timeinfo, _milliseconds);
}
DateTime FromOSInternal(vuint64_t osInternal) override
{
time_t timer;
vint milliseconds;
OSInternalToTime(osInternal, timer, milliseconds);
tm* timeinfo = localtime(&timer);
return ConvertTMToDateTime(timeinfo, milliseconds);
}
vuint64_t LocalTime() override
{
struct timeval tv;
gettimeofday(&tv, nullptr);
tm* timeinfo = localtime(&tv.tv_sec);
return ConvertTMTToOSInternal(timeinfo, tv.tv_usec / 1000);
}
vuint64_t UtcTime() override
{
struct timeval tv;
gettimeofday(&tv, nullptr);
tm* timeinfo = gmtime(&tv.tv_sec);
return ConvertTMTToOSInternal(timeinfo, tv.tv_usec / 1000);
}
vuint64_t LocalToUtcTime(vuint64_t osInternal) override
{
time_t timer;
vint milliseconds;
OSInternalToTime(osInternal, timer, milliseconds);
tm* timeinfo = gmtime(&timer);
return ConvertTMTToOSInternal(timeinfo, milliseconds);
}
vuint64_t UtcToLocalTime(vuint64_t osInternal) override
{
time_t timer;
vint milliseconds;
OSInternalToTime(osInternal, timer, milliseconds);
time_t localTimer = mktime(localtime(&timer));
time_t utcTimer = mktime(gmtime(&timer));
timer += localTimer - utcTimer;
TimeToOSInternal(timer, milliseconds, osInternal);
return osInternal;
}
vuint64_t Forward(vuint64_t osInternal, vuint64_t milliseconds) override
{
return osInternal + milliseconds;
}
vuint64_t Backward(vuint64_t osInternal, vuint64_t milliseconds) override
{
return osInternal - milliseconds;
}
};
LinuxDateTimeImpl osDateTimeImpl;
IDateTimeImpl* GetOSDateTimeImpl()
{
struct timeval tv;
gettimeofday(&tv, nullptr);
tm* timeinfo = localtime(&tv.tv_sec);
return ConvertTMToDateTime(timeinfo, tv.tv_usec / 1000);
}
DateTime DateTime::UtcTime()
{
struct timeval tv;
gettimeofday(&tv, nullptr);
tm* timeinfo = gmtime(&tv.tv_sec);
return ConvertTMToDateTime(timeinfo, tv.tv_usec / 1000);
}
DateTime DateTime::FromDateTime(vint _year, vint _month, vint _day, vint _hour, vint _minute, vint _second, vint _milliseconds)
{
tm timeinfo;
memset(&timeinfo, 0, sizeof(timeinfo));
timeinfo.tm_year = _year - 1900;
timeinfo.tm_mon = _month - 1;
timeinfo.tm_mday = _day;
timeinfo.tm_hour = _hour;
timeinfo.tm_min = _minute;
timeinfo.tm_sec = _second;
timeinfo.tm_isdst = -1;
return ConvertTMToDateTime(&timeinfo, _milliseconds);
}
DateTime DateTime::FromFileTime(vuint64_t filetime)
{
time_t timer = (time_t)(filetime / 1000);
tm* timeinfo = localtime(&timer);
return ConvertTMToDateTime(timeinfo, filetime % 1000);
}
DateTime DateTime::ToLocalTime()
{
time_t localTimer = time(nullptr);
time_t utcTimer = mktime(gmtime(&localTimer));
time_t timer = (time_t)(filetime / 1000) + localTimer - utcTimer;
tm* timeinfo = localtime(&timer);
return ConvertTMToDateTime(timeinfo, milliseconds);
}
DateTime DateTime::ToUtcTime()
{
time_t timer = (time_t)(filetime / 1000);
tm* timeinfo = gmtime(&timer);
return ConvertTMToDateTime(timeinfo, milliseconds);
}
DateTime DateTime::Forward(vuint64_t milliseconds)
{
return FromFileTime(filetime + milliseconds);
}
DateTime DateTime::Backward(vuint64_t milliseconds)
{
return FromFileTime(filetime - milliseconds);
return &osDateTimeImpl;
}
}
+122 -100
View File
@@ -112,111 +112,133 @@ namespace vl
DateTime
***********************************************************************/
DateTime SystemTimeToDateTime(const SYSTEMTIME& systemTime)
class WindowsDateTimeImpl : public Object, public virtual IDateTimeImpl
{
DateTime dateTime;
dateTime.year = systemTime.wYear;
dateTime.month = systemTime.wMonth;
dateTime.dayOfWeek = systemTime.wDayOfWeek;
dateTime.day = systemTime.wDay;
dateTime.hour = systemTime.wHour;
dateTime.minute = systemTime.wMinute;
dateTime.second = systemTime.wSecond;
dateTime.milliseconds = systemTime.wMilliseconds;
public:
FILETIME fileTime;
SystemTimeToFileTime(&systemTime, &fileTime);
ULARGE_INTEGER largeInteger;
largeInteger.HighPart = fileTime.dwHighDateTime;
largeInteger.LowPart = fileTime.dwLowDateTime;
dateTime.filetime = largeInteger.QuadPart;
dateTime.totalMilliseconds = dateTime.filetime / 10000;
static vuint64_t FileTimeToOSInternal(FILETIME fileTime)
{
ULARGE_INTEGER largeInteger;
largeInteger.HighPart = fileTime.dwHighDateTime;
largeInteger.LowPart = fileTime.dwLowDateTime;
return largeInteger.QuadPart;
}
return dateTime;
}
static FILETIME OSInternalToFileTime(vuint64_t osInternal)
{
ULARGE_INTEGER largeInteger;
largeInteger.QuadPart = osInternal;
SYSTEMTIME DateTimeToSystemTime(const DateTime& dateTime)
FILETIME fileTime;
fileTime.dwHighDateTime = largeInteger.HighPart;
fileTime.dwLowDateTime = largeInteger.LowPart;
return fileTime;
}
static DateTime SystemTimeToDateTime(const SYSTEMTIME& systemTime)
{
DateTime dateTime;
dateTime.year = systemTime.wYear;
dateTime.month = systemTime.wMonth;
dateTime.dayOfWeek = systemTime.wDayOfWeek;
dateTime.day = systemTime.wDay;
dateTime.hour = systemTime.wHour;
dateTime.minute = systemTime.wMinute;
dateTime.second = systemTime.wSecond;
dateTime.milliseconds = systemTime.wMilliseconds;
FILETIME fileTime;
SystemTimeToFileTime(&systemTime, &fileTime);
dateTime.osInternal = FileTimeToOSInternal(fileTime);
dateTime.osMilliseconds = dateTime.osInternal / 10000;
return dateTime;
}
DateTime FromDateTime(vint _year, vint _month, vint _day, vint _hour, vint _minute, vint _second, vint _milliseconds) override
{
SYSTEMTIME systemTime;
memset(&systemTime, 0, sizeof(systemTime));
systemTime.wYear = (WORD)_year;
systemTime.wMonth = (WORD)_month;
systemTime.wDay = (WORD)_day;
systemTime.wHour = (WORD)_hour;
systemTime.wMinute = (WORD)_minute;
systemTime.wSecond = (WORD)_second;
systemTime.wMilliseconds = (WORD)_milliseconds;
FILETIME fileTime;
SystemTimeToFileTime(&systemTime, &fileTime);
FileTimeToSystemTime(&fileTime, &systemTime);
return SystemTimeToDateTime(systemTime);
}
DateTime FromOSInternal(vuint64_t osInternal) override
{
ULARGE_INTEGER largeInteger;
largeInteger.QuadPart = osInternal;
FILETIME fileTime;
fileTime.dwHighDateTime = largeInteger.HighPart;
fileTime.dwLowDateTime = largeInteger.LowPart;
SYSTEMTIME systemTime;
FileTimeToSystemTime(&fileTime, &systemTime);
return SystemTimeToDateTime(systemTime);
}
vuint64_t LocalTime() override
{
SYSTEMTIME systemTime;
GetLocalTime(&systemTime);
FILETIME fileTime;
SystemTimeToFileTime(&systemTime, &fileTime);
return FileTimeToOSInternal(fileTime);
}
vuint64_t UtcTime() override
{
FILETIME fileTime;
GetSystemTimeAsFileTime(&fileTime);
return FileTimeToOSInternal(fileTime);
}
vuint64_t LocalToUtcTime(vuint64_t osInternal) override
{
FILETIME fileTime = OSInternalToFileTime(osInternal);
SYSTEMTIME utcTime, localTime;
FileTimeToSystemTime(&fileTime, &localTime);
TzSpecificLocalTimeToSystemTime(NULL, &localTime, &utcTime);
SystemTimeToFileTime(&utcTime, &fileTime);
return FileTimeToOSInternal(fileTime);
}
vuint64_t UtcToLocalTime(vuint64_t osInternal) override
{
FILETIME fileTime = OSInternalToFileTime(osInternal);
SYSTEMTIME utcTime, localTime;
FileTimeToSystemTime(&fileTime, &utcTime);
SystemTimeToTzSpecificLocalTime(NULL, &utcTime, &localTime);
SystemTimeToFileTime(&localTime, &fileTime);
return FileTimeToOSInternal(fileTime);
}
vuint64_t Forward(vuint64_t osInternal, vuint64_t milliseconds) override
{
return osInternal + milliseconds * 10000;
}
vuint64_t Backward(vuint64_t osInternal, vuint64_t milliseconds) override
{
return osInternal - milliseconds * 10000;
}
};
WindowsDateTimeImpl osDateTimeImpl;
IDateTimeImpl* GetOSDateTimeImpl()
{
ULARGE_INTEGER largeInteger;
largeInteger.QuadPart = dateTime.filetime;
FILETIME fileTime;
fileTime.dwHighDateTime = largeInteger.HighPart;
fileTime.dwLowDateTime = largeInteger.LowPart;
SYSTEMTIME systemTime;
FileTimeToSystemTime(&fileTime, &systemTime);
return systemTime;
}
DateTime DateTime::LocalTime()
{
SYSTEMTIME systemTime;
GetLocalTime(&systemTime);
return SystemTimeToDateTime(systemTime);
}
DateTime DateTime::UtcTime()
{
SYSTEMTIME utcTime;
GetSystemTime(&utcTime);
return SystemTimeToDateTime(utcTime);
}
DateTime DateTime::FromDateTime(vint _year, vint _month, vint _day, vint _hour, vint _minute, vint _second, vint _milliseconds)
{
SYSTEMTIME systemTime;
memset(&systemTime, 0, sizeof(systemTime));
systemTime.wYear = (WORD)_year;
systemTime.wMonth = (WORD)_month;
systemTime.wDay = (WORD)_day;
systemTime.wHour = (WORD)_hour;
systemTime.wMinute = (WORD)_minute;
systemTime.wSecond = (WORD)_second;
systemTime.wMilliseconds = (WORD)_milliseconds;
FILETIME fileTime;
SystemTimeToFileTime(&systemTime, &fileTime);
FileTimeToSystemTime(&fileTime, &systemTime);
return SystemTimeToDateTime(systemTime);
}
DateTime DateTime::FromFileTime(vuint64_t filetime)
{
ULARGE_INTEGER largeInteger;
largeInteger.QuadPart = filetime;
FILETIME fileTime;
fileTime.dwHighDateTime = largeInteger.HighPart;
fileTime.dwLowDateTime = largeInteger.LowPart;
SYSTEMTIME systemTime;
FileTimeToSystemTime(&fileTime, &systemTime);
return SystemTimeToDateTime(systemTime);
}
DateTime DateTime::ToLocalTime()
{
SYSTEMTIME utcTime = DateTimeToSystemTime(*this);
SYSTEMTIME localTime;
SystemTimeToTzSpecificLocalTime(NULL, &utcTime, &localTime);
return SystemTimeToDateTime(localTime);
}
DateTime DateTime::ToUtcTime()
{
SYSTEMTIME localTime = DateTimeToSystemTime(*this);
SYSTEMTIME utcTime;
TzSpecificLocalTimeToSystemTime(NULL, &localTime, &utcTime);
return SystemTimeToDateTime(utcTime);
}
DateTime DateTime::Forward(vuint64_t milliseconds)
{
return FromFileTime(filetime + milliseconds * 10000);
}
DateTime DateTime::Backward(vuint64_t milliseconds)
{
return FromFileTime(filetime - milliseconds * 10000);
return &osDateTimeImpl;
}
}
+120 -40
View File
@@ -301,6 +301,77 @@ PartialOrderingProcessor
}
}
/***********************************************************************
.\PRIMITIVES\DATETIME.CPP
***********************************************************************/
/***********************************************************************
Author: Zihan Chen (vczh)
Licensed under https://github.com/vczh-libraries/License
***********************************************************************/
namespace vl
{
extern IDateTimeImpl* GetOSDateTimeImpl();
IDateTimeImpl* dateTimeImpl = nullptr;
IDateTimeImpl* GetDateTimeImpl()
{
return dateTimeImpl ? dateTimeImpl : GetOSDateTimeImpl();
}
void InjectDateTimeImpl(IDateTimeImpl* impl)
{
dateTimeImpl = impl;
}
/***********************************************************************
DateTime
***********************************************************************/
DateTime DateTime::LocalTime()
{
return GetDateTimeImpl()->FromOSInternal(GetDateTimeImpl()->LocalTime());
}
DateTime DateTime::UtcTime()
{
return GetDateTimeImpl()->FromOSInternal(GetDateTimeImpl()->UtcTime());
}
DateTime DateTime::FromDateTime(vint _year, vint _month, vint _day, vint _hour, vint _minute, vint _second, vint _milliseconds)
{
return GetDateTimeImpl()->FromDateTime(_year, _month, _day, _hour, _minute, _second, _milliseconds);
}
DateTime DateTime::FromOSInternal(vuint64_t _osInternal)
{
return GetDateTimeImpl()->FromOSInternal(_osInternal);
}
DateTime DateTime::ToLocalTime()
{
return GetDateTimeImpl()->FromOSInternal(GetDateTimeImpl()->UtcToLocalTime(osInternal));
}
DateTime DateTime::ToUtcTime()
{
return GetDateTimeImpl()->FromOSInternal(GetDateTimeImpl()->LocalToUtcTime(osInternal));
}
DateTime DateTime::Forward(vuint64_t milliseconds)
{
return GetDateTimeImpl()->FromOSInternal(GetDateTimeImpl()->Forward(osInternal, milliseconds));
}
DateTime DateTime::Backward(vuint64_t milliseconds)
{
return GetDateTimeImpl()->FromOSInternal(GetDateTimeImpl()->Backward(osInternal, milliseconds));
}
}
/***********************************************************************
.\STRINGS\CONVERSION.CPP
***********************************************************************/
@@ -550,6 +621,31 @@ UtfConversion<char16_t>
return 1;
}
}
/***********************************************************************
UtfConversion<char16be_t>
***********************************************************************/
vint UtfConversion<char16be_t>::From32(char32_t source, char16be_t(&dest)[BufferLength])
{
char16_t destle[BufferLength];
vint result = UtfConversion<char16_t>::From32(source, destle);
SwapByteForUtf16BE(destle[0]);
SwapByteForUtf16BE(destle[1]);
dest[0].value = destle[0];
dest[1].value = destle[1];
return result;
}
vint UtfConversion<char16be_t>::To32(const char16be_t* source, vint sourceLength, char32_t& dest)
{
char16_t destle[BufferLength];
if (sourceLength >= 1) destle[0] = source[0].value;
if (sourceLength >= 2) destle[1] = source[1].value;
SwapByteForUtf16BE(destle[0]);
SwapByteForUtf16BE(destle[1]);
return UtfConversion<char16_t>::To32(destle, sourceLength, dest);
}
}
/***********************************************************************
@@ -581,24 +677,25 @@ String Conversions (buffer walkthrough)
}
}
template<typename T>
vint _utftou32(const T* s, char32_t* d, vint chars)
template<typename TFrom, typename TTo>
vint _utftoutf(const TFrom* s, TTo* d, vint chars)
{
return _utftoutf_reader<T, char32_t, encoding::UtfStringTo32Reader<T>>(s, d, chars);
return _utftoutf_reader<TFrom, TTo, encoding::UtfStringToStringReader<TFrom, TTo>>(s, d, chars);
}
template<typename T>
vint _u32toutf(const char32_t* s, T* d, vint chars)
{
return _utftoutf_reader<char32_t, T, encoding::UtfStringFrom32Reader<T>>(s, d, chars);
}
template vint _utftoutf<wchar_t, char8_t>(const wchar_t* s, char8_t* d, vint chars);
template vint _utftoutf<wchar_t, char16_t>(const wchar_t* s, char16_t* d, vint chars);
template vint _utftoutf<char8_t, wchar_t>(const char8_t* s, wchar_t* d, vint chars);
template vint _utftoutf<char8_t, char16_t>(const char8_t* s, char16_t* d, vint chars);
template vint _utftoutf<char16_t, wchar_t>(const char16_t* s, wchar_t* d, vint chars);
template vint _utftoutf<char16_t, char8_t>(const char16_t* s, char8_t* d, vint chars);
template vint _utftou32<wchar_t>(const wchar_t* s, char32_t* d, vint chars);
template vint _utftou32<char8_t>(const char8_t* s, char32_t* d, vint chars);
template vint _utftou32<char16_t>(const char16_t* s, char32_t* d, vint chars);
template vint _u32toutf<wchar_t>(const char32_t* s, wchar_t* d, vint chars);
template vint _u32toutf<char8_t>(const char32_t* s, char8_t* d, vint chars);
template vint _u32toutf<char16_t>(const char32_t* s, char16_t* d, vint chars);
template vint _utftoutf<char32_t, char8_t>(const char32_t* s, char8_t* d, vint chars);
template vint _utftoutf<char32_t, char16_t>(const char32_t* s, char16_t* d, vint chars);
template vint _utftoutf<char32_t, wchar_t>(const char32_t* s, wchar_t* d, vint chars);
template vint _utftoutf<char8_t, char32_t>(const char8_t* s, char32_t* d, vint chars);
template vint _utftoutf<char16_t, char32_t>(const char16_t* s, char32_t* d, vint chars);
template vint _utftoutf<wchar_t, char32_t>(const wchar_t* s, char32_t* d, vint chars);
/***********************************************************************
String Conversions (direct)
@@ -614,42 +711,25 @@ String Conversions (direct)
Convert(source.Buffer(), buffer, len);
return ObjectString<TTo>::TakeOver(buffer, len - 1);
}
AString wtoa (const WString& source) { return ConvertStringDirect<wchar_t, char, _wtoa>(source); }
WString atow (const AString& source) { return ConvertStringDirect<char, wchar_t, _atow>(source); }
#if defined VCZH_WCHAR_UTF16
U32String wtou32 (const WString& source) { return ConvertStringDirect<wchar_t, char32_t, _utftou32<wchar_t>>(source); }
WString u32tow (const U32String& source) { return ConvertStringDirect<char32_t, wchar_t, _u32toutf<wchar_t>>(source); }
U32String wtou32 (const WString& source) { return ConvertStringDirect<wchar_t, char32_t, _utftoutf<wchar_t, char32_t>>(source); }
WString u32tow (const U32String& source) { return ConvertStringDirect<char32_t, wchar_t, _utftoutf<char32_t, wchar_t>>(source); }
#elif defined VCZH_WCHAR_UTF32
U32String wtou32 (const WString& source) { return U32String::UnsafeCastFrom(source); }
WString u32tow (const U32String& source) { return WString::UnsafeCastFrom(source); }
#endif
U32String u8tou32 (const U8String& source) { return ConvertStringDirect<char8_t, char32_t, _utftou32<char8_t>>(source); }
U8String u32tou8 (const U32String& source) { return ConvertStringDirect<char32_t, char8_t, _u32toutf<char8_t>>(source); }
U32String u16tou32(const U16String& source) { return ConvertStringDirect<char16_t, char32_t, _utftou32<char16_t>>(source); }
U16String u32tou16(const U32String& source) { return ConvertStringDirect<char32_t, char16_t, _u32toutf<char16_t>>(source); }
/***********************************************************************
String Conversions (buffer walkthrough indirect)
***********************************************************************/
template<typename TFrom, typename TTo>
vint _utftoutf(const TFrom* s, TTo* d, vint chars)
{
return _utftoutf_reader<TFrom, TTo, encoding::UtfStringToStringReader<TFrom, TTo>>(s, d, chars);
}
template vint _utftoutf<wchar_t, char8_t>(const wchar_t* s, char8_t* d, vint chars);
template vint _utftoutf<wchar_t, char16_t>(const wchar_t* s, char16_t* d, vint chars);
template vint _utftoutf<char8_t, wchar_t>(const char8_t* s, wchar_t* d, vint chars);
template vint _utftoutf<char8_t, char16_t>(const char8_t* s, char16_t* d, vint chars);
template vint _utftoutf<char16_t, wchar_t>(const char16_t* s, wchar_t* d, vint chars);
template vint _utftoutf<char16_t, char8_t>(const char16_t* s, char8_t* d, vint chars);
U32String u8tou32 (const U8String& source) { return ConvertStringDirect<char8_t, char32_t, _utftoutf<char8_t, char32_t>>(source); }
U8String u32tou8 (const U32String& source) { return ConvertStringDirect<char32_t, char8_t, _utftoutf<char32_t, char8_t>>(source); }
U32String u16tou32(const U16String& source) { return ConvertStringDirect<char16_t, char32_t, _utftoutf<char16_t, char32_t>>(source); }
U16String u32tou16(const U32String& source) { return ConvertStringDirect<char32_t, char16_t, _utftoutf<char32_t, char16_t>>(source); }
/***********************************************************************
String Conversions (unicode indirect)
***********************************************************************/
AString wtoa (const WString& source) { return ConvertStringDirect<wchar_t, char, _wtoa>(source); }
WString atow (const AString& source) { return ConvertStringDirect<char, wchar_t, _atow>(source); }
U8String wtou8 (const WString& source) { return ConvertStringDirect<wchar_t, char8_t, _utftoutf<wchar_t, char8_t>>(source); }
WString u8tow (const U8String& source) { return ConvertStringDirect<char8_t, wchar_t, _utftoutf<char8_t, wchar_t>>(source); }
#if defined VCZH_WCHAR_UTF16
+355 -104
View File
File diff suppressed because it is too large Load Diff
-4
View File
@@ -1072,10 +1072,6 @@ namespace vl
using namespace glr;
using namespace glr::automaton;
SERIALIZE_ENUM(AstInsType)
SERIALIZE_ENUM(EdgePriority)
SERIALIZE_ENUM(ReturnRuleType)
BEGIN_SERIALIZATION(AstIns)
SERIALIZE(type)
SERIALIZE(param)
+12 -54
View File
@@ -1541,7 +1541,7 @@ ThreadLocalStorage
/***********************************************************************
.\STREAM\CHARFORMAT.LINUX.CPP
.\ENCODING\CHARFORMAT\CHARFORMAT.LINUX.CPP
***********************************************************************/
/***********************************************************************
Author: Zihan Chen (vczh)
@@ -1558,16 +1558,25 @@ namespace vl
{
namespace stream
{
using namespace vl::encoding;
bool IsMbcsLeadByte(char c)
{
return (vint8_t)c < 0;
}
void MbcsToWChar(wchar_t* wideBuffer, vint wideChars, vint wideReaded, char* mbcsBuffer, vint mbcsChars)
{
AString a = AString::CopyFrom(mbcsBuffer, mbcsChars);
WString w = atow(a);
memcpy(wideBuffer, w.Buffer(), wideReaded * sizeof(wchar_t));
}
/***********************************************************************
Mbcs
MbcsEncoder
***********************************************************************/
vint MbcsEncoder::WriteString(wchar_t* _buffer, vint chars, bool freeToUpdate)
vint MbcsEncoder::WriteString(wchar_t* _buffer, vint chars)
{
WString w = WString::CopyFrom(_buffer, chars);
AString a = wtoa(w);
@@ -1582,57 +1591,6 @@ Mbcs
return chars;
}
void MbcsToWChar(wchar_t* wideBuffer, vint wideChars, vint wideReaded, char* mbcsBuffer, vint mbcsChars)
{
AString a = AString::CopyFrom(mbcsBuffer, mbcsChars);
WString w = atow(a);
memcpy(wideBuffer, w.Buffer(), wideReaded * sizeof(wchar_t));
}
/***********************************************************************
Utf8
***********************************************************************/
vint Utf8Encoder::WriteString(wchar_t* _buffer, vint chars, bool freeToUpdate)
{
WCharToUtfReader<char8_t> reader(_buffer, chars);
while (char8_t c = reader.Read())
{
vint written = stream->Write(&c, sizeof(c));
if (written != sizeof(c))
{
Close();
return 0;
}
}
if (reader.HasIllegalChar())
{
Close();
return 0;
}
return chars;
}
}
}
/***********************************************************************
.\STREAM\CHARFORMAT_TESTENCODING.LINUX.CPP
***********************************************************************/
/***********************************************************************
Author: Zihan Chen (vczh)
Licensed under https://github.com/vczh-libraries/License
***********************************************************************/
#ifndef VCZH_GCC
static_assert(false, "Do not build this file for Windows applications.");
#endif
namespace vl
{
namespace stream
{
/***********************************************************************
Helper Functions
***********************************************************************/
+21 -48
View File
@@ -625,7 +625,19 @@ namespace vl
{
using namespace collections;
extern SYSTEMTIME DateTimeToSystemTime(const DateTime& dateTime);
SYSTEMTIME DateTimeToSystemTime(const DateTime& dateTime)
{
SYSTEMTIME systemTime;
systemTime.wYear = (WORD)dateTime.year;
systemTime.wMonth = (WORD)dateTime.month;
systemTime.wDayOfWeek = (WORD)dateTime.dayOfWeek;
systemTime.wDay = (WORD)dateTime.day;
systemTime.wHour = (WORD)dateTime.hour;
systemTime.wMinute = (WORD)dateTime.minute;
systemTime.wSecond = (WORD)dateTime.second;
systemTime.wMilliseconds = (WORD)dateTime.milliseconds;
return systemTime;
}
BOOL CALLBACK Locale_EnumLocalesProcEx(
_In_ LPWSTR lpLocaleString,
@@ -1748,7 +1760,7 @@ ThreadLocalStorage
/***********************************************************************
.\STREAM\CHARFORMAT.WINDOWS.CPP
.\ENCODING\CHARFORMAT\CHARFORMAT.WINDOWS.CPP
***********************************************************************/
/***********************************************************************
Author: Zihan Chen (vczh)
@@ -1770,11 +1782,16 @@ namespace vl
return IsDBCSLeadByte(c);
}
void MbcsToWChar(wchar_t* wideBuffer, vint wideChars, vint wideReaded, char* mbcsBuffer, vint mbcsChars)
{
MultiByteToWideChar(CP_THREAD_ACP, 0, mbcsBuffer, (int)mbcsChars, wideBuffer, (int)wideChars);
}
/***********************************************************************
Mbcs
MbcsEncoder
***********************************************************************/
vint MbcsEncoder::WriteString(wchar_t* _buffer, vint chars, bool freeToUpdate)
vint MbcsEncoder::WriteString(wchar_t* _buffer, vint chars)
{
vint length = WideCharToMultiByte(CP_THREAD_ACP, 0, _buffer, (int)chars, NULL, NULL, NULL, NULL);
char* mbcs = new char[length];
@@ -1790,50 +1807,6 @@ Mbcs
return chars;
}
void MbcsToWChar(wchar_t* wideBuffer, vint wideChars, vint wideReaded, char* mbcsBuffer, vint mbcsChars)
{
MultiByteToWideChar(CP_THREAD_ACP, 0, mbcsBuffer, (int)mbcsChars, wideBuffer, (int)wideChars);
}
/***********************************************************************
Utf8
***********************************************************************/
vint Utf8Encoder::WriteString(wchar_t* _buffer, vint chars, bool freeToUpdate)
{
vint length = WideCharToMultiByte(CP_UTF8, 0, _buffer, (int)chars, NULL, NULL, NULL, NULL);
char* mbcs = new char[length];
WideCharToMultiByte(CP_UTF8, 0, _buffer, (int)chars, mbcs, (int)length, NULL, NULL);
vint result = stream->Write(mbcs, length);
delete[] mbcs;
if (result != length)
{
Close();
return 0;
}
return chars;
}
}
}
/***********************************************************************
.\STREAM\CHARFORMAT_TESTENCODING.WINDOWS.CPP
***********************************************************************/
/***********************************************************************
Author: Zihan Chen (vczh)
Licensed under https://github.com/vczh-libraries/License
***********************************************************************/
#ifndef VCZH_MSVC
static_assert(false, "Do not build this file for non-Windows applications.");
#endif
namespace vl
{
namespace stream
{
/***********************************************************************
Helper Functions
***********************************************************************/
+1814 -1658
View File
File diff suppressed because it is too large Load Diff
+827 -720
View File
File diff suppressed because it is too large Load Diff
+1 -3
View File
@@ -6681,7 +6681,7 @@ Logger (ParsingTable)
writer.WriteLine(L"");
}
writer.WriteMonospacedEnglishTable(stringTable, rows, columns);
WriteMonospacedEnglishTable(writer, stringTable, rows, columns);
writer.WriteLine(L"");
writer.WriteLine(L"Metadata(Tokens):");
@@ -8044,8 +8044,6 @@ ParsingTable (Serialization)
SERIALIZE(creatorRule)
END_SERIALIZATION
SERIALIZE_ENUM(ParsingTable::Instruction::InstructionType)
BEGIN_SERIALIZATION(ParsingTable::LookAheadInfo)
SERIALIZE(tokens)
SERIALIZE(state)
+2 -6
View File
@@ -970,10 +970,6 @@ Metadata
Serialization
***********************************************************************/
SERIALIZE_ENUM(reflection::description::ITypeInfo::Decorator)
SERIALIZE_ENUM(reflection::description::TypeInfoHint)
SERIALIZE_ENUM(reflection::description::TypeDescriptorFlags)
BEGIN_SERIALIZATION(reflection::description::IdRange)
SERIALIZE(start)
SERIALIZE(count)
@@ -4728,8 +4724,8 @@ LoadPredefinedTypes
STRUCT_MEMBER(minute)
STRUCT_MEMBER(second)
STRUCT_MEMBER(milliseconds)
STRUCT_MEMBER(totalMilliseconds)
STRUCT_MEMBER(filetime)
STRUCT_MEMBER(osMilliseconds)
STRUCT_MEMBER(osInternal)
END_STRUCT_MEMBER(DateTime)
BEGIN_INTERFACE_MEMBER(IValueEnumerator)
+2 -2
View File
@@ -1288,8 +1288,8 @@ namespace vl
struct CharReader
{
private:
encoding::UtfStringTo32Reader<T> reader;
const T* input;
encoding::UtfStringToStringReader<T, char32_t> reader;
const T* input;
public:
CharReader(const T* _input)
-6
View File
@@ -825,11 +825,6 @@ Sys
return DateTime::FromDateTime(year, month, day, hour, minute, second, milliseconds);
}
DateTime Sys::CreateDateTime(vuint64_t filetime)
{
return DateTime::FromFileTime(filetime);
}
Ptr<IValueEnumerable> Sys::ReverseEnumerable(Ptr<IValueEnumerable> value)
{
auto list = value.Cast<IValueReadonlyList>();
@@ -1067,7 +1062,6 @@ WfLoadLibraryTypes
CLASS_MEMBER_STATIC_METHOD_OVERLOAD(CreateDateTime, {L"year" _ L"month" _ L"day" }, DateTime(*)(vint, vint, vint))
CLASS_MEMBER_STATIC_METHOD_OVERLOAD(CreateDateTime, { L"year" _ L"month" _ L"day" _ L"hour" _ L"minute" _ L"second" _ L"milliseconds" }, DateTime(*)(vint, vint, vint, vint, vint, vint, vint))
CLASS_MEMBER_STATIC_METHOD_OVERLOAD(CreateDateTime, { L"filetime" }, DateTime(*)(vuint64_t))
END_CLASS_MEMBER(Sys)
BEGIN_CLASS_MEMBER(Math)
-1
View File
@@ -719,7 +719,6 @@ Libraries
static DateTime Backward(DateTime dt, vuint64_t milliseconds);
static DateTime CreateDateTime(vint year, vint month, vint day);
static DateTime CreateDateTime(vint year, vint month, vint day, vint hour, vint minute, vint second, vint milliseconds);
static DateTime CreateDateTime(vuint64_t filetime);
static Ptr<IValueEnumerable> ReverseEnumerable(Ptr<IValueEnumerable> value);
};
-4
View File
@@ -929,10 +929,6 @@ Serizliation (Data Structures)
SERIALIZE(lastInstruction)
END_SERIALIZATION
SERIALIZE_ENUM(WfInsCode)
SERIALIZE_ENUM(WfInsType)
SERIALIZE_ENUM(Value::ValueType)
/***********************************************************************
Serizliation (ITypeDescriptor)
***********************************************************************/
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.