Update release

This commit is contained in:
vczh
2021-10-27 01:31:04 -07:00
parent d239be3f23
commit 0f571d5019
22 changed files with 447 additions and 759 deletions
+101 -101
View File
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -978,10 +978,10 @@ ITEM(BACKSLASH, 0xDC) /* OEM_5 */ \
ITEM(LEFT_BRACKET, 0xDD) /* OEM_6 */ \
ITEM(APOSTROPHE, 0xDE) /* OEM_7 */ \
#define GUI_DEFINE_KEYBOARD_CODE_ENUM_ITEM(NAME, CODE) _##NAME = CODE,
#define GUI_DEFINE_KEYBOARD_CODE_ENUM_ITEM(NAME, CODE) KEY_##NAME = CODE,
enum class VKEY
{
_UNKNOWN = -1,
KEY_UNKNOWN = -1,
GUI_DEFINE_KEYBOARD_CODE(GUI_DEFINE_KEYBOARD_CODE_ENUM_ITEM)
};
#undef GUI_DEFINE_KEYBOARD_CODE_ENUM_ITEM
@@ -5905,7 +5905,7 @@ Alt-Combined Shortcut Key Interfaces Helpers
AltActionMap currentActiveAltActions;
AltControlMap currentActiveAltTitles;
WString currentAltPrefix;
VKEY supressAltKey = VKEY::_UNKNOWN;
VKEY supressAltKey = VKEY::KEY_UNKNOWN;
void EnterAltHost(IGuiAltActionHost* host);
void LeaveAltHost();
@@ -9838,11 +9838,11 @@ namespace vl
namespace controls
{
template<typename T, typename Enabled = YesType>
template<typename T, typename=void>
struct QueryServiceHelper;
template<typename T>
struct QueryServiceHelper<T, typename PointerConvertable<decltype(T::Identifier), const wchar_t* const>::YesNoType>
struct QueryServiceHelper<T, std::enable_if_t<std::is_convertible_v<decltype(T::Identifier), const wchar_t* const>>>
{
static WString GetIdentifier()
{
@@ -9851,7 +9851,7 @@ namespace vl
};
template<typename T>
struct QueryServiceHelper<T, typename PointerConvertable<decltype(T::GetIdentifier()), WString>::YesNoType>
struct QueryServiceHelper<T, std::enable_if_t<std::is_convertible_v<decltype(T::GetIdentifier()), WString>>>
{
static WString GetIdentifier()
{
+1 -1
View File
@@ -9705,7 +9705,7 @@ FindInstanceLoadingSource
template<typename TCallback>
auto FindByTag(Ptr<GuiInstanceContext> context, GlobalStringKey namespaceName, const WString& typeName, TCallback callback)
-> typename RemoveCVR<decltype(callback({}).Value())>::Type
-> std::remove_cvref_t<decltype(callback({}).Value())>
{
vint index = context->namespaces.Keys().IndexOf(namespaceName);
if (index != -1)
+2 -2
View File
@@ -361,9 +361,9 @@ Type Declaration
STRUCT_MEMBER(verticalAntialias)
END_STRUCT_MEMBER(FontProperties)
#define GUI_DEFINE_KEYBOARD_CODE_ENUM_ITEM(NAME, CODE) ENUM_CLASS_ITEM(_##NAME)
#define GUI_DEFINE_KEYBOARD_CODE_ENUM_ITEM(NAME, CODE) ENUM_CLASS_ITEM(KEY_##NAME)
BEGIN_ENUM_ITEM(VKEY)
ENUM_CLASS_ITEM(_UNKNOWN)
ENUM_CLASS_ITEM(KEY_UNKNOWN)
GUI_DEFINE_KEYBOARD_CODE(GUI_DEFINE_KEYBOARD_CODE_ENUM_ITEM)
END_ENUM_ITEM(VKEY)
#undef GUI_DEFINE_KEYBOARD_CODE_ENUM_ITEM
+21 -21
View File
@@ -8282,11 +8282,11 @@ WindowsForm
if (nonClient)
{
info.ctrl = WinIsKeyPressing(VKEY::_CONTROL);
info.shift = WinIsKeyPressing(VKEY::_SHIFT);
info.left= WinIsKeyPressing(VKEY::_LBUTTON);
info.middle= WinIsKeyPressing(VKEY::_MBUTTON);
info.right = WinIsKeyPressing(VKEY::_RBUTTON);
info.ctrl = WinIsKeyPressing(VKEY::KEY_CONTROL);
info.shift = WinIsKeyPressing(VKEY::KEY_SHIFT);
info.left= WinIsKeyPressing(VKEY::KEY_LBUTTON);
info.middle= WinIsKeyPressing(VKEY::KEY_MBUTTON);
info.right = WinIsKeyPressing(VKEY::KEY_RBUTTON);
POINTS point = MAKEPOINTS(lParam);
NativePoint offset = GetClientBoundsInScreen().LeftTop();
@@ -8295,11 +8295,11 @@ WindowsForm
}
else
{
info.ctrl=((VKEY)wParam & VKEY::_CONTROL)!=(VKEY)0;
info.shift=((VKEY)wParam & VKEY::_SHIFT)!= (VKEY)0;
info.left=((VKEY)wParam & VKEY::_LBUTTON)!= (VKEY)0;
info.middle=((VKEY)wParam & VKEY::_MBUTTON)!= (VKEY)0;
info.right=((VKEY)wParam & VKEY::_RBUTTON)!= (VKEY)0;
info.ctrl=((VKEY)wParam & VKEY::KEY_CONTROL)!=(VKEY)0;
info.shift=((VKEY)wParam & VKEY::KEY_SHIFT)!= (VKEY)0;
info.left=((VKEY)wParam & VKEY::KEY_LBUTTON)!= (VKEY)0;
info.middle=((VKEY)wParam & VKEY::KEY_MBUTTON)!= (VKEY)0;
info.right=((VKEY)wParam & VKEY::KEY_RBUTTON)!= (VKEY)0;
POINTS point = MAKEPOINTS(lParam);
@@ -8322,10 +8322,10 @@ WindowsForm
{
NativeWindowKeyInfo info;
info.code=(VKEY)wParam;
info.ctrl=WinIsKeyPressing(VKEY::_CONTROL);
info.shift=WinIsKeyPressing(VKEY::_SHIFT);
info.alt=WinIsKeyPressing(VKEY::_MENU);
info.capslock=WinIsKeyToggled(VKEY::_CAPITAL);
info.ctrl=WinIsKeyPressing(VKEY::KEY_CONTROL);
info.shift=WinIsKeyPressing(VKEY::KEY_SHIFT);
info.alt=WinIsKeyPressing(VKEY::KEY_MENU);
info.capslock=WinIsKeyToggled(VKEY::KEY_CAPITAL);
info.autoRepeatKeyDown = (((vuint32_t)lParam) >> 30) % 2 == 1;
return info;
}
@@ -8334,10 +8334,10 @@ WindowsForm
{
NativeWindowCharInfo info;
info.code=(wchar_t)wParam;
info.ctrl=WinIsKeyPressing(VKEY::_CONTROL);
info.shift=WinIsKeyPressing(VKEY::_SHIFT);
info.alt=WinIsKeyPressing(VKEY::_MENU);
info.capslock=WinIsKeyToggled(VKEY::_CAPITAL);
info.ctrl=WinIsKeyPressing(VKEY::KEY_CONTROL);
info.shift=WinIsKeyPressing(VKEY::KEY_SHIFT);
info.alt=WinIsKeyPressing(VKEY::KEY_MENU);
info.capslock=WinIsKeyToggled(VKEY::KEY_CAPITAL);
return info;
}
#pragma pop_macro("_CONTROL")
@@ -8772,7 +8772,7 @@ WindowsForm
{
NativeWindowKeyInfo info=ConvertKey(wParam, lParam);
info.autoRepeatKeyDown = false;
if (supressingAlt && !info.ctrl && !info.shift && info.code == VKEY::_MENU)
if (supressingAlt && !info.ctrl && !info.shift && info.code == VKEY::KEY_MENU)
{
supressingAlt = false;
break;
@@ -8786,7 +8786,7 @@ WindowsForm
case WM_SYSKEYDOWN:
{
NativeWindowKeyInfo info=ConvertKey(wParam, lParam);
if (supressingAlt && !info.ctrl && !info.shift && info.code == VKEY::_MENU)
if (supressingAlt && !info.ctrl && !info.shift && info.code == VKEY::KEY_MENU)
{
break;
}
@@ -14610,7 +14610,7 @@ WindowsInputService
VKEY WindowsInputService::GetKey(const WString& name)
{
vint index = keys.Keys().IndexOf(name);
return index == -1 ? VKEY::_UNKNOWN : keys.Values()[index];
return index == -1 ? VKEY::KEY_UNKNOWN : keys.Values()[index];
}
}
}
-12
View File
@@ -1453,18 +1453,6 @@ UniscribeColor
}
}
template<>
struct POD<presentation::elements_windows_gdi::UniscribeColorRange>
{
static const bool Result=true;
};
template<>
struct POD<presentation::elements_windows_gdi::UniscribeColor>
{
static const bool Result=true;
};
namespace presentation
{
namespace elements_windows_gdi
+141 -160
View File
@@ -12,33 +12,10 @@ Author: Zihan Chen (vczh)
Licensed under https://github.com/vczh-libraries/License
***********************************************************************/
#include <time.h>
#if defined VCZH_MSVC
#include <Windows.h>
#elif defined VCZH_GCC
#include <sys/time.h>
#endif
namespace vl
{
/***********************************************************************
NotCopyable
***********************************************************************/
NotCopyable::NotCopyable()
{
}
NotCopyable::NotCopyable(const NotCopyable&)
{
}
NotCopyable& NotCopyable::operator=(const NotCopyable&)
{
return *this;
}
/***********************************************************************
Error
***********************************************************************/
@@ -52,14 +29,151 @@ Error
{
return description;
}
}
/***********************************************************************
Object
.\CONSOLE.CPP
***********************************************************************/
/***********************************************************************
Author: Zihan Chen (vczh)
Licensed under https://github.com/vczh-libraries/License
***********************************************************************/
Object::~Object()
#if defined VCZH_MSVC
#include <Windows.h>
#elif defined VCZH_GCC
#include <iostream>
#include <string>
using namespace std;
#endif
namespace vl
{
namespace console
{
/***********************************************************************
Console
***********************************************************************/
void Console::Write(const wchar_t* string, vint length)
{
#if defined VCZH_MSVC
HANDLE outHandle=GetStdHandle(STD_OUTPUT_HANDLE);
DWORD fileMode=0;
DWORD written=0;
if((GetFileType(outHandle) & FILE_TYPE_CHAR) && GetConsoleMode(outHandle, &fileMode))
{
WriteConsole(outHandle, string, (int)length, &written,0);
}
else
{
int codePage = GetConsoleOutputCP();
int charCount = WideCharToMultiByte(codePage, 0, string, -1, 0, 0, 0, 0);
char* codePageBuffer = new char[charCount];
WideCharToMultiByte(codePage, 0, string, -1, codePageBuffer, charCount, 0, 0);
WriteFile(outHandle, codePageBuffer, charCount-1, &written, 0);
delete[] codePageBuffer;
}
#elif defined VCZH_GCC
wstring s(string, string+length);
wcout<<s<<ends;
#endif
}
void Console::Write(const wchar_t* string)
{
Write(string, wcslen(string));
}
void Console::Write(const WString& string)
{
Write(string.Buffer(), string.Length());
}
void Console::WriteLine(const WString& string)
{
Write(string);
Write(L"\r\n");
}
WString Console::Read()
{
#if defined VCZH_MSVC
WString result;
DWORD count;
for(;;)
{
wchar_t buffer;
ReadConsole(GetStdHandle(STD_INPUT_HANDLE),&buffer,1,&count,0);
if(buffer==L'\r')
{
ReadConsole(GetStdHandle(STD_INPUT_HANDLE),&buffer,1,&count,0);
break;
}
else if(buffer==L'\n')
{
break;
}
else
{
result=result+WString::FromChar(buffer);
}
}
return result;
#elif defined VCZH_GCC
wstring s;
getline(wcin, s, L'\n');
return s.c_str();
#endif
}
void Console::SetColor(bool red, bool green, bool blue, bool light)
{
#if defined VCZH_MSVC
WORD attribute=0;
if(red)attribute |=FOREGROUND_RED;
if(green)attribute |=FOREGROUND_GREEN;
if(blue)attribute |=FOREGROUND_BLUE;
if(light)attribute |=FOREGROUND_INTENSITY;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),attribute);
SetConsoleTextAttribute(GetStdHandle(STD_INPUT_HANDLE),attribute);
#elif defined VCZH_GCC
int color = (blue?1:0)*4 + (green?1:0)*2 + (red?1:0);
if(light)
wprintf(L"\x1B[00;3%dm", color);
else
wprintf(L"\x1B[01;3%dm", color);
#endif
}
void Console::SetTitle(const WString& string)
{
#if defined VCZH_MSVC
SetConsoleTitle(string.Buffer());
#endif
}
}
}
/***********************************************************************
.\DATETIME.CPP
***********************************************************************/
/***********************************************************************
Author: Zihan Chen (vczh)
Licensed under https://github.com/vczh-libraries/License
***********************************************************************/
#include <time.h>
#if defined VCZH_MSVC
#elif defined VCZH_GCC
#include <sys/time.h>
#endif
namespace vl
{
/***********************************************************************
DateTime
@@ -262,139 +376,6 @@ DateTime
return FromFileTime(filetime-milliseconds);
#endif
}
/***********************************************************************
Interface
***********************************************************************/
Interface::~Interface()
{
}
}
/***********************************************************************
.\CONSOLE.CPP
***********************************************************************/
/***********************************************************************
Author: Zihan Chen (vczh)
Licensed under https://github.com/vczh-libraries/License
***********************************************************************/
#if defined VCZH_MSVC
#elif defined VCZH_GCC
#include <iostream>
#include <string>
using namespace std;
#endif
namespace vl
{
namespace console
{
/***********************************************************************
Console
***********************************************************************/
void Console::Write(const wchar_t* string, vint length)
{
#if defined VCZH_MSVC
HANDLE outHandle=GetStdHandle(STD_OUTPUT_HANDLE);
DWORD fileMode=0;
DWORD written=0;
if((GetFileType(outHandle) & FILE_TYPE_CHAR) && GetConsoleMode(outHandle, &fileMode))
{
WriteConsole(outHandle, string, (int)length, &written,0);
}
else
{
int codePage = GetConsoleOutputCP();
int charCount = WideCharToMultiByte(codePage, 0, string, -1, 0, 0, 0, 0);
char* codePageBuffer = new char[charCount];
WideCharToMultiByte(codePage, 0, string, -1, codePageBuffer, charCount, 0, 0);
WriteFile(outHandle, codePageBuffer, charCount-1, &written, 0);
delete[] codePageBuffer;
}
#elif defined VCZH_GCC
wstring s(string, string+length);
wcout<<s<<ends;
#endif
}
void Console::Write(const wchar_t* string)
{
Write(string, wcslen(string));
}
void Console::Write(const WString& string)
{
Write(string.Buffer(), string.Length());
}
void Console::WriteLine(const WString& string)
{
Write(string);
Write(L"\r\n");
}
WString Console::Read()
{
#if defined VCZH_MSVC
WString result;
DWORD count;
for(;;)
{
wchar_t buffer;
ReadConsole(GetStdHandle(STD_INPUT_HANDLE),&buffer,1,&count,0);
if(buffer==L'\r')
{
ReadConsole(GetStdHandle(STD_INPUT_HANDLE),&buffer,1,&count,0);
break;
}
else if(buffer==L'\n')
{
break;
}
else
{
result=result+WString::FromChar(buffer);
}
}
return result;
#elif defined VCZH_GCC
wstring s;
getline(wcin, s, L'\n');
return s.c_str();
#endif
}
void Console::SetColor(bool red, bool green, bool blue, bool light)
{
#if defined VCZH_MSVC
WORD attribute=0;
if(red)attribute |=FOREGROUND_RED;
if(green)attribute |=FOREGROUND_GREEN;
if(blue)attribute |=FOREGROUND_BLUE;
if(light)attribute |=FOREGROUND_INTENSITY;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),attribute);
SetConsoleTextAttribute(GetStdHandle(STD_INPUT_HANDLE),attribute);
#elif defined VCZH_GCC
int color = (blue?1:0)*4 + (green?1:0)*2 + (red?1:0);
if(light)
wprintf(L"\x1B[00;3%dm", color);
else
wprintf(L"\x1B[01;3%dm", color);
#endif
}
void Console::SetTitle(const WString& string)
{
#if defined VCZH_MSVC
SetConsoleTitle(string.Buffer());
#endif
}
}
}
@@ -1665,7 +1646,7 @@ UnitTest
#ifdef VCZH_MSVC
__try
{
SuppressCppFailure(ForwardValue<TCallback&&>(callback));
SuppressCppFailure(std::forward<TCallback&&>(callback));
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
@@ -1681,7 +1662,7 @@ UnitTest
{
if (suppressFailure)
{
SuppressCFailure(ForwardValue<TCallback&&>(callback));
SuppressCFailure(std::forward<TCallback&&>(callback));
}
else
{
+91 -372
View File
File diff suppressed because it is too large Load Diff
+35 -15
View File
@@ -438,16 +438,17 @@ Kernel Mode Objects
}
/// <summary>Base type of all synchronization objects.</summary>
class WaitableObject : public Object, public NotCopyable
class WaitableObject : public Object
{
#if defined VCZH_MSVC
private:
threading_internal::WaitableData* waitableData;
protected:
WaitableObject();
void SetData(threading_internal::WaitableData* data);
public:
NOT_COPYABLE(WaitableObject);
/// <summary>Test if the object has already been created. Some of the synchronization objects should initialize itself after the constructor.</summary>
/// <returns>Returns true if the object has already been created.</returns>
/// <remarks>This function is only available in Windows.</remarks>
@@ -712,12 +713,13 @@ Kernel Mode Objects in Process
/// In Windows, enter a owned critical section will not result in dead lock.
/// In Linux and macOS, it works like a mutex.
/// </remarks>
class CriticalSection : public Object, public NotCopyable
class CriticalSection : public Object
{
private:
friend class ConditionVariable;
threading_internal::CriticalSectionData* internalData;
public:
NOT_COPYABLE(CriticalSection);
/// <summary>Create a critical section.</summary>
CriticalSection();
~CriticalSection();
@@ -731,11 +733,12 @@ Kernel Mode Objects in Process
void Leave();
public:
class Scope : public Object, public NotCopyable
class Scope : public Object
{
private:
CriticalSection* criticalSection;
public:
NOT_COPYABLE(Scope);
Scope(CriticalSection& _criticalSection);
~Scope();
};
@@ -758,12 +761,13 @@ Kernel Mode Objects in Process
/// }
/// ]]></code></program>
/// </summary>
class ReaderWriterLock : public Object, public NotCopyable
class ReaderWriterLock : public Object
{
private:
friend class ConditionVariable;
threading_internal::ReaderWriterLockData* internalData;
public:
NOT_COPYABLE(ReaderWriterLock);
/// <summary>Create a reader writer lock.</summary>
ReaderWriterLock();
~ReaderWriterLock();
@@ -783,31 +787,34 @@ Kernel Mode Objects in Process
/// <summary>Release a writer lock.</summary>
void LeaveWriter();
public:
class ReaderScope : public Object, public NotCopyable
class ReaderScope : public Object
{
private:
ReaderWriterLock* lock;
public:
NOT_COPYABLE(ReaderScope);
ReaderScope(ReaderWriterLock& _lock);
~ReaderScope();
};
class WriterScope : public Object, public NotCopyable
class WriterScope : public Object
{
private:
ReaderWriterLock* lock;
public:
NOT_COPYABLE(WriterScope);
WriterScope(ReaderWriterLock& _lock);
~WriterScope();
};
};
/// <summary>Conditional variable.</summary>
class ConditionVariable : public Object, public NotCopyable
class ConditionVariable : public Object
{
private:
threading_internal::ConditionVariableData* internalData;
public:
NOT_COPYABLE(ConditionVariable);
/// <summary>Create a conditional variable.</summary>
ConditionVariable();
~ConditionVariable();
@@ -868,11 +875,12 @@ User Mode Objects
/// }
/// ]]></code></program>
/// </summary>
class SpinLock : public Object, public NotCopyable
class SpinLock : public Object
{
protected:
volatile LockedInt token;
public:
NOT_COPYABLE(SpinLock);
/// <summary>Create a spin lock.</summary>
SpinLock();
~SpinLock();
@@ -886,11 +894,12 @@ User Mode Objects
void Leave();
public:
class Scope : public Object, public NotCopyable
class Scope : public Object
{
private:
SpinLock* spinLock;
public:
NOT_COPYABLE(Scope);
Scope(SpinLock& _spinLock);
~Scope();
};
@@ -910,7 +919,7 @@ Thread Local Storage
/// This class is designed to define global variables.
/// Dynamically allocation will result in undefined behavior.
/// </remarks>
class ThreadLocalStorage : public Object, private NotCopyable
class ThreadLocalStorage : public Object
{
typedef void(*Destructor)(void*);
protected:
@@ -920,6 +929,7 @@ Thread Local Storage
static void PushStorage(ThreadLocalStorage* storage);
public:
NOT_COPYABLE(ThreadLocalStorage);
ThreadLocalStorage(Destructor _destructor);
~ThreadLocalStorage();
@@ -943,7 +953,7 @@ Thread Local Storage
/// Dynamically allocation will result in undefined behavior.
/// </remarks>
template<typename T>
class ThreadVariable : public Object, private NotCopyable
class ThreadVariable : public Object
{
protected:
ThreadLocalStorage storage;
@@ -956,6 +966,8 @@ Thread Local Storage
}
}
public:
NOT_COPYABLE(ThreadVariable);
/// <summary>Create a thread local variable.</summary>
ThreadVariable()
:storage(&Destructor)
@@ -996,12 +1008,14 @@ Thread Local Storage
};
template<typename T>
class ThreadVariable<T*> : public Object, private NotCopyable
class ThreadVariable<T*> : public Object
{
protected:
ThreadLocalStorage storage;
public:
NOT_COPYABLE(ThreadVariable);
ThreadVariable()
:storage(nullptr)
{
@@ -2517,9 +2531,12 @@ Text Related
***********************************************************************/
/// <summary>Text reader. All line breaks are normalized to CRLF regardless whatever in the input stream.</summary>
class TextReader : public Object, private NotCopyable
class TextReader : public Object
{
public:
NOT_COPYABLE(TextReader);
TextReader() = default;
/// <summary>Test does the reader reach the end or not.</summary>
/// <returns>Returns true if the reader reaches the end.</returns>
virtual bool IsEnd()=0;
@@ -2539,9 +2556,12 @@ Text Related
};
/// <summary>Text writer.</summary>
class TextWriter : public Object, private NotCopyable
class TextWriter : public Object
{
public:
NOT_COPYABLE(TextWriter);
TextWriter() = default;
/// <summary>Write a single character.</summary>
/// <param name="c">The character to write.</param>
virtual void WriteChar(wchar_t c)=0;
+26 -26
View File
@@ -698,7 +698,7 @@ ReferenceCounterOperator
}
template<typename T>
struct ReferenceCounterOperator<T, typename PointerConvertable<T, reflection::DescriptableObject>::YesNoType>
struct ReferenceCounterOperator<T, std::enable_if_t<std::is_convertible_v<T*, reflection::DescriptableObject*>>>
{
static __forceinline volatile vint* CreateCounter(T* reference)
{
@@ -1833,7 +1833,7 @@ ValueType
{
private:
template<typename U = T>
static CompareResult ComparePrimitiveInternal(const U& a, const U& b, typename AcceptAlways<vint, decltype(&TypedValueSerializerProvider<U>::Compare)>::Type)
static CompareResult ComparePrimitiveInternal(const U& a, const U& b, std::enable_if_t<sizeof(decltype(&TypedValueSerializerProvider<U>::Compare)) >= 0, vint>)
{
return TypedValueSerializerProvider<U>::Compare(a, b);
}
@@ -4072,7 +4072,7 @@ TypeInfoRetriver
#ifndef VCZH_DEBUG_NO_REFLECTION
static Ptr<ITypeInfo> CreateTypeInfo()
{
return DetailTypeInfoRetriver<typename RemoveCVR<T>::Type, TypeFlag>::CreateTypeInfo(Hint);
return DetailTypeInfoRetriver<std::remove_cvref_t<T>, TypeFlag>::CreateTypeInfo(Hint);
}
#endif
};
@@ -4094,7 +4094,7 @@ TypeInfoRetriver Helper Functions (BoxValue, UnboxValue)
template<typename T>
Value BoxValue(const T& object, ITypeDescriptor* typeDescriptor=0)
{
using Type = typename RemoveCVR<T>::Type;
using Type = std::remove_cvref_t<T>;
return ValueAccessor<Type, TypeInfoRetriver<Type>::Decorator>::BoxValue(object, typeDescriptor);
}
@@ -4107,7 +4107,7 @@ TypeInfoRetriver Helper Functions (BoxValue, UnboxValue)
template<typename T>
T UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor=0, const WString& valueName=L"value")
{
using Type = typename RemoveCVR<T>::Type;
using Type = std::remove_cvref_t<T>;
return ValueAccessor<Type, TypeInfoRetriver<Type>::Decorator>::UnboxValue(value, typeDescriptor, valueName);
}
@@ -5774,7 +5774,7 @@ ValueFunctionProxyWrapper<Func<R(TArgs...)>>
template<typename R, typename ...TArgs>
struct BoxedFunctionInvoker
{
static Value Invoke(const Func<R(TArgs...)>& function, Ptr<IValueList> arguments, typename RemoveCVR<TArgs>::Type&& ...args)
static Value Invoke(const Func<R(TArgs...)>& function, Ptr<IValueList> arguments, std::remove_cvref_t<TArgs>&& ...args)
{
UnboxSpecifiedParameter(arguments, 0, args...);
R result = function(args...);
@@ -5785,7 +5785,7 @@ ValueFunctionProxyWrapper<Func<R(TArgs...)>>
template<typename ...TArgs>
struct BoxedFunctionInvoker<void, TArgs...>
{
static Value Invoke(const Func<void(TArgs...)>& function, Ptr<IValueList> arguments, typename RemoveCVR<TArgs>::Type&& ...args)
static Value Invoke(const Func<void(TArgs...)>& function, Ptr<IValueList> arguments, std::remove_cvref_t<TArgs>&& ...args)
{
UnboxSpecifiedParameter(arguments, 0, args...);
function(args...);
@@ -5822,7 +5822,7 @@ ValueFunctionProxyWrapper<Func<R(TArgs...)>>
CHECK_FAIL(L"Argument count mismatch.");
#endif
}
return internal_helper::BoxedFunctionInvoker<R, TArgs...>::Invoke(function, arguments, typename RemoveCVR<TArgs>::Type()...);
return internal_helper::BoxedFunctionInvoker<R, TArgs...>::Invoke(function, arguments, std::remove_cvref_t<TArgs>()...);
}
};
@@ -5873,7 +5873,7 @@ ParameterAccessor<Func<R(TArgs...)>>
result=[functionProxy](TArgs ...args)
{
Ptr<IValueList> arguments = IValueList::Create();
internal_helper::AddValueToList(arguments, ForwardValue<TArgs>(args)...);
internal_helper::AddValueToList(arguments, std::forward<TArgs>(args)...);
typedef typename TypeInfoRetriver<R>::TempValueType ResultType;
ResultType proxyResult;
description::UnboxParameter<ResultType>(functionProxy->Invoke(arguments), proxyResult);
@@ -5928,7 +5928,7 @@ CustomConstructorInfoImpl<R(TArgs...)>
template<typename R, typename ...TArgs>
struct BoxedConstructorInvoker
{
static Value Invoke(MethodInfoImpl* methodInfo, collections::Array<Value>& arguments, typename RemoveCVR<TArgs>::Type&& ...args)
static Value Invoke(MethodInfoImpl* methodInfo, collections::Array<Value>& arguments, std::remove_cvref_t<TArgs>&& ...args)
{
UnboxSpecifiedParameter(methodInfo, arguments, 0, args...);
R result = new typename TypeInfoRetriver<R>::Type(args...);
@@ -5961,7 +5961,7 @@ CustomConstructorInfoImpl<R(TArgs...)>
protected:
Value InvokeInternal(const Value& thisObject, collections::Array<Value>& arguments)override
{
return internal_helper::BoxedConstructorInvoker<R, TArgs...>::Invoke(this, arguments, typename RemoveCVR<TArgs>::Type()...);
return internal_helper::BoxedConstructorInvoker<R, TArgs...>::Invoke(this, arguments, std::remove_cvref_t<TArgs>()...);
}
Value CreateFunctionProxyInternal(const Value& thisObject)override
@@ -5998,7 +5998,7 @@ CustomStaticMethodInfoImpl<TClass, R(TArgs...)>
template<typename TClass, typename R, typename ...TArgs>
struct BoxedMethodInvoker
{
static Value Invoke(TClass* object, R(__thiscall TClass::* method)(TArgs...), MethodInfoImpl* methodInfo, collections::Array<Value>& arguments, typename RemoveCVR<TArgs>::Type&& ...args)
static Value Invoke(TClass* object, R(__thiscall TClass::* method)(TArgs...), MethodInfoImpl* methodInfo, collections::Array<Value>& arguments, std::remove_cvref_t<TArgs>&& ...args)
{
UnboxSpecifiedParameter(methodInfo, arguments, 0, args...);
R result = (object->*method)(args...);
@@ -6009,7 +6009,7 @@ CustomStaticMethodInfoImpl<TClass, R(TArgs...)>
template<typename TClass, typename ...TArgs>
struct BoxedMethodInvoker<TClass, void, TArgs...>
{
static Value Invoke(TClass* object, void(__thiscall TClass::* method)(TArgs...), MethodInfoImpl* methodInfo, collections::Array<Value>& arguments, typename RemoveCVR<TArgs>::Type&& ...args)
static Value Invoke(TClass* object, void(__thiscall TClass::* method)(TArgs...), MethodInfoImpl* methodInfo, collections::Array<Value>& arguments, std::remove_cvref_t<TArgs>&& ...args)
{
UnboxSpecifiedParameter(methodInfo, arguments, 0, args...);
(object->*method)(args...);
@@ -6020,7 +6020,7 @@ CustomStaticMethodInfoImpl<TClass, R(TArgs...)>
template<typename TClass, typename R, typename ...TArgs>
struct BoxedExternalMethodInvoker
{
static Value Invoke(TClass* object, R(*method)(TClass*, TArgs...), MethodInfoImpl* methodInfo, collections::Array<Value>& arguments, typename RemoveCVR<TArgs>::Type&& ...args)
static Value Invoke(TClass* object, R(*method)(TClass*, TArgs...), MethodInfoImpl* methodInfo, collections::Array<Value>& arguments, std::remove_cvref_t<TArgs>&& ...args)
{
UnboxSpecifiedParameter(methodInfo, arguments, 0, args...);
R result = method(object, args...);
@@ -6031,7 +6031,7 @@ CustomStaticMethodInfoImpl<TClass, R(TArgs...)>
template<typename TClass, typename ...TArgs>
struct BoxedExternalMethodInvoker<TClass, void, TArgs...>
{
static Value Invoke(TClass* object, void(*method)(TClass*, TArgs...), MethodInfoImpl* methodInfo, collections::Array<Value>& arguments, typename RemoveCVR<TArgs>::Type&& ...args)
static Value Invoke(TClass* object, void(*method)(TClass*, TArgs...), MethodInfoImpl* methodInfo, collections::Array<Value>& arguments, std::remove_cvref_t<TArgs>&& ...args)
{
UnboxSpecifiedParameter(methodInfo, arguments, 0, args...);
method(object, args...);
@@ -6084,7 +6084,7 @@ CustomStaticMethodInfoImpl<TClass, R(TArgs...)>
Value InvokeInternal(const Value& thisObject, collections::Array<Value>& arguments)override
{
TClass* object=UnboxValue<TClass*>(thisObject, GetOwnerTypeDescriptor(), L"thisObject");
return internal_helper::BoxedMethodInvoker<TClass, R, TArgs...>::Invoke(object, method, this, arguments, typename RemoveCVR<TArgs>::Type()...);
return internal_helper::BoxedMethodInvoker<TClass, R, TArgs...>::Invoke(object, method, this, arguments, std::remove_cvref_t<TArgs>()...);
}
Value CreateFunctionProxyInternal(const Value& thisObject)override
@@ -6111,7 +6111,7 @@ CustomStaticMethodInfoImpl<TClass, R(TArgs...)>
Value InvokeInternal(const Value& thisObject, collections::Array<Value>& arguments)override
{
TClass* object=UnboxValue<TClass*>(thisObject, GetOwnerTypeDescriptor(), L"thisObject");
return internal_helper::BoxedExternalMethodInvoker<TClass, R, TArgs...>::Invoke(object, method, this, arguments, typename RemoveCVR<TArgs>::Type()...);
return internal_helper::BoxedExternalMethodInvoker<TClass, R, TArgs...>::Invoke(object, method, this, arguments, std::remove_cvref_t<TArgs>()...);
}
Value CreateFunctionProxyInternal(const Value& thisObject)override
@@ -6138,7 +6138,7 @@ CustomStaticMethodInfoImpl<R(TArgs...)>
template<typename R, typename ...TArgs>
struct BoxedStaticMethodInvoker
{
static Value Invoke(R(* method)(TArgs...), MethodInfoImpl* methodInfo, collections::Array<Value>& arguments, typename RemoveCVR<TArgs>::Type&& ...args)
static Value Invoke(R(* method)(TArgs...), MethodInfoImpl* methodInfo, collections::Array<Value>& arguments, std::remove_cvref_t<TArgs>&& ...args)
{
UnboxSpecifiedParameter(methodInfo, arguments, 0, args...);
R result = method(args...);
@@ -6149,7 +6149,7 @@ CustomStaticMethodInfoImpl<R(TArgs...)>
template<typename ...TArgs>
struct BoxedStaticMethodInvoker<void, TArgs...>
{
static Value Invoke(void(* method)(TArgs...), MethodInfoImpl* methodInfo, collections::Array<Value>& arguments, typename RemoveCVR<TArgs>::Type&& ...args)
static Value Invoke(void(* method)(TArgs...), MethodInfoImpl* methodInfo, collections::Array<Value>& arguments, std::remove_cvref_t<TArgs>&& ...args)
{
UnboxSpecifiedParameter(methodInfo, arguments, 0, args...);
method(args...);
@@ -6166,7 +6166,7 @@ CustomStaticMethodInfoImpl<R(TArgs...)>
Value InvokeInternal(const Value& thisObject, collections::Array<Value>& arguments)override
{
return internal_helper::BoxedStaticMethodInvoker<R, TArgs...>::Invoke(method, this, arguments, typename RemoveCVR<TArgs>::Type()...);
return internal_helper::BoxedStaticMethodInvoker<R, TArgs...>::Invoke(method, this, arguments, std::remove_cvref_t<TArgs>()...);
}
Value CreateFunctionProxyInternal(const Value& thisObject)override
@@ -6192,7 +6192,7 @@ CustomEventInfoImpl<void(TArgs...)>
template<typename ...TArgs>
struct BoxedEventInvoker
{
static void Invoke(Event<void(TArgs...)>& eventObject, Ptr<IValueList> arguments, typename RemoveCVR<TArgs>::Type&& ...args)
static void Invoke(Event<void(TArgs...)>& eventObject, Ptr<IValueList> arguments, std::remove_cvref_t<TArgs>&& ...args)
{
UnboxSpecifiedParameter(arguments, 0, args...);
eventObject(args...);
@@ -6213,7 +6213,7 @@ CustomEventInfoImpl<void(TArgs...)>
auto func = Func<void(TArgs...)>([=](TArgs ...args)
{
auto arguments = IValueList::Create();
internal_helper::AddValueToList(arguments, ForwardValue<TArgs>(args)...);
internal_helper::AddValueToList(arguments, std::forward<TArgs>(args)...);
handler->Invoke(arguments);
});
return EventHelper<TArgs...>::Attach(eventObject, func);
@@ -6230,7 +6230,7 @@ CustomEventInfoImpl<void(TArgs...)>
{
TClass* object = UnboxValue<TClass*>(Value::From(thisObject), GetOwnerTypeDescriptor(), L"thisObject");
Event<void(TArgs...)>& eventObject = object->*eventRef;
internal_helper::BoxedEventInvoker<TArgs...>::Invoke(eventObject, arguments, typename RemoveCVR<TArgs>::Type()...);
internal_helper::BoxedEventInvoker<TArgs...>::Invoke(eventObject, arguments, typename std::remove_cvref_t<TArgs>()...);
}
Ptr<ITypeInfo> GetHandlerTypeInternal()override
@@ -6545,13 +6545,13 @@ ParameterAccessor<TStruct>
typeDescriptor = GetTypeDescriptor<typename TypeInfoRetriver<T>::Type>();
}
#endif
using Type = typename vl::RemoveCVR<T>::Type;
using Type = std::remove_cvref_t<T>;
return Value::From(new IValueType::TypedBox<Type>(object), typeDescriptor);
}
static T UnboxValue(const Value& value, ITypeDescriptor* typeDescriptor, const WString& valueName)
{
using Type = typename vl::RemoveCVR<T>::Type;
using Type = std::remove_cvref_t<T>;
if (auto unboxedValue = value.GetBoxedValue().Cast<IValueType::TypedBox<Type>>())
{
return unboxedValue->value;
@@ -6911,7 +6911,7 @@ Class
protected:\
bool IsAggregatable()override\
{\
return AcceptValue<typename PointerConvertable<TYPENAME, AggregatableDescription<TYPENAME>>::YesNoType>::Result;\
return std::is_convertible_v<TYPENAME*, AggregatableDescription<TYPENAME>*>;\
}\
void LoadInternal()override\
{
-12
View File
@@ -3422,18 +3422,6 @@ Data Structures for Backtracking
};
}
template<>
struct POD<regex_internal::StateSaver>
{
static const bool Result = true;
};
template<>
struct POD<regex_internal::ExtensionSaver>
{
static const bool Result = true;
};
namespace regex_internal
{
using namespace collections;
+14 -17
View File
@@ -58,7 +58,7 @@ Data Structure
};
/// <summary>A match produces by a <see cref="Regex"/>.</summary>
class RegexMatch : public Object, private NotCopyable
class RegexMatch : public Object
{
friend class Regex;
public:
@@ -76,6 +76,7 @@ Data Structure
RegexMatch(const WString& _string, regex_internal::RichResult* _result, regex_internal::RichInterpretor* _rich);
RegexMatch(const RegexString& _result);
public:
NOT_COPYABLE(RegexMatch);
/// <summary>
/// Test if this match is a succeeded match or a failed match.
@@ -216,7 +217,7 @@ Regex
/// Testing only returns a bool very indicating success or failure.
/// </p>
/// </summary>
class Regex : public Object, private NotCopyable
class Regex : public Object
{
protected:
regex_internal::PureInterpretor* pure = nullptr;
@@ -224,6 +225,7 @@ Regex
void Process(const WString& text, bool keepEmpty, bool keepSuccess, bool keepFail, RegexMatch::List& matches)const;
public:
NOT_COPYABLE(Regex);
/// <summary>Create a regular expression. It will crash if the regular expression produces syntax error.</summary>
/// <param name="code">The regular expression in a string.</param>
/// <param name="preferPure">Set to true to use DFA if possible.</param>
@@ -1009,7 +1011,7 @@ Tokenizer
};
/// <summary>Lexical analyzer.</summary>
class RegexLexer : public Object, private NotCopyable
class RegexLexer : public Object
{
protected:
regex_internal::PureInterpretor* pure = nullptr;
@@ -1018,6 +1020,7 @@ Tokenizer
RegexProc proc;
public:
NOT_COPYABLE(RegexLexer);
/// <summary>Create a lexical analyzer by a set of regular expressions. [F:vl.regex.RegexToken.token] will be the index of the matched regular expression in the first argument.</summary>
/// <param name="tokens">ALl regular expression, each one represent a kind of tokens.</param>
/// <param name="_proc">Configuration of all callbacks.</param>
@@ -1089,12 +1092,6 @@ Data Structure
bool operator!=(wchar_t item)const;
};
}
template<>
struct POD<regex_internal::CharRange>
{
static const bool Result=true;
};
}
#endif
@@ -1231,9 +1228,12 @@ namespace vl
Regex Expression AST
***********************************************************************/
class Expression : public Object, private NotCopyable
class Expression : public Object
{
public:
NOT_COPYABLE(Expression);
Expression() = default;
typedef Ptr<Expression> Ref;
typedef collections::Dictionary<WString, Expression::Ref> Map;
@@ -1342,7 +1342,7 @@ Regex Expression AST
void Apply(IRegexExpressionAlgorithm& algorithm);
};
class RegexExpression : public Object, private NotCopyable
class RegexExpression : public Object
{
public:
typedef Ptr<RegexExpression> Ref;
@@ -1350,6 +1350,9 @@ Regex Expression AST
Expression::Map definitions; // Named regex to be referred
Expression::Ref expression; // Regex to match
NOT_COPYABLE(RegexExpression);
RegexExpression() = default;
Expression::Ref Merge();
};
@@ -1660,12 +1663,6 @@ namespace vl
};
}
template<>
struct POD<regex_internal::CaptureRecord>
{
static const bool Result=true;
};
namespace regex_internal
{
class RichResult
+2 -2
View File
@@ -21515,9 +21515,9 @@ namespace vl
writer.WriteLine(L";");
writer.WriteString(tryPrefix);
writer.WriteString(L"::vl::__vwsn::RunOnExit<::vl::RemoveCVR<decltype(");
writer.WriteString(L"::vl::__vwsn::RunOnExit<::std::remove_cvref_t<decltype(");
writer.WriteString(blockName);
writer.WriteString(L")>::Type> ");
writer.WriteString(L")>> ");
writer.WriteString(blockName);
writer.WriteString(L"_dtor(&");
writer.WriteString(blockName);
+7 -12
View File
@@ -67,14 +67,14 @@ namespace vl
Ptr<T> Ensure(Ptr<T>&& pointer)
{
CHECK_ERROR(pointer != nullptr, L"The pointer cannot be null.");
return MoveValue(pointer);
return std::move(pointer);
}
template<typename T>
Nullable<T> Ensure(Nullable<T>&& nullable)
{
CHECK_ERROR(nullable, L"The pointer cannot be null.");
return MoveValue(nullable);
return std::move(nullable);
}
template<typename T>
@@ -87,18 +87,16 @@ namespace vl
template<typename T>
WString ToString(const T& value)
{
using Type = typename RemoveCVR<T>::Type;
WString str;
CHECK_ERROR(reflection::description::TypedValueSerializerProvider<T>::Serialize(value, str), L"Failed to serialize.");
CHECK_ERROR(reflection::description::TypedValueSerializerProvider<std::remove_cvref_t<T>>::Serialize(value, str), L"Failed to serialize.");
return str;
}
template<typename T>
T Parse(const WString& str)
{
using Type = typename RemoveCVR<T>::Type;
T value;
CHECK_ERROR(reflection::description::TypedValueSerializerProvider<T>::Deserialize(str, value), L"Failed to serialize.");
CHECK_ERROR(reflection::description::TypedValueSerializerProvider<std::remove_cvref_t<T>>::Deserialize(str, value), L"Failed to serialize.");
return value;
}
@@ -153,16 +151,14 @@ namespace vl
template<typename T>
reflection::description::Value Box(const T& value)
{
using Type = typename RemoveCVR<T>::Type;
return reflection::description::BoxParameter<Type>(const_cast<T&>(value));
return reflection::description::BoxParameter<std::remove_cvref_t<T>>(const_cast<T&>(value));
}
template<typename T>
T Unbox(const reflection::description::Value& value)
{
using Type = typename RemoveCVR<T>::Type;
T result;
reflection::description::UnboxParameter<Type>(value, result);
reflection::description::UnboxParameter<std::remove_cvref_t<T>>(value, result);
return result;
}
@@ -206,8 +202,7 @@ namespace vl
template<typename T>
T UnboxWeak(const reflection::description::Value& value)
{
using Type = typename RemoveCVR<T>::Type;
return UnboxWeakHelper<Type>::Unbox(value);
return UnboxWeakHelper<std::remove_cvref_t<T>>::Unbox(value);
}
template<typename T>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.