This commit is contained in:
Zihan Chen
2016-12-21 10:51:19 -08:00
parent f8f322a468
commit 9bb7194921
41 changed files with 2204 additions and 629 deletions
+3 -2
View File
@@ -4410,7 +4410,7 @@ GuiWindow
{ {
owner->SetEnabled(false); owner->SetEnabled(false);
GetNativeWindow()->SetParent(owner->GetNativeWindow()); GetNativeWindow()->SetParent(owner->GetNativeWindow());
auto container = CreateEventHandlerContainer<GuiEventArgs>(); auto container = MakePtr<IGuiGraphicsEventHandler::Container>();
container->handler = WindowClosed.AttachLambda([=](GuiGraphicsComposition* sender, GuiEventArgs& arguments) container->handler = WindowClosed.AttachLambda([=](GuiGraphicsComposition* sender, GuiEventArgs& arguments)
{ {
GetApplication()->InvokeInMainThread([=]() GetApplication()->InvokeInMainThread([=]()
@@ -4744,7 +4744,7 @@ namespace vl
} }
} }
WString GetValueText(Value& value) WString GetValueText(const Value& value)
{ {
if (auto td = value.GetTypeDescriptor()) if (auto td = value.GetTypeDescriptor())
{ {
@@ -24629,6 +24629,7 @@ GuiTabTemplate
GuiTabTemplate::~GuiTabTemplate() GuiTabTemplate::~GuiTabTemplate()
{ {
FinalizeAggregation();
} }
/*********************************************************************** /***********************************************************************
+71 -70
View File
@@ -5284,6 +5284,9 @@ Colorized Plain Text (model)
/// Background color. /// Background color.
/// </summary> /// </summary>
Color background; Color background;
bool operator==(const ColorItem& value)const { return text == value.text && background == value.background; }
bool operator!=(const ColorItem& value)const { return !(*this == value); }
}; };
/// <summary> /// <summary>
@@ -5304,8 +5307,8 @@ Colorized Plain Text (model)
/// </summary> /// </summary>
ColorItem selectedUnfocused; ColorItem selectedUnfocused;
bool operator==(const ColorEntry& value){return false;} bool operator==(const ColorEntry& value)const {return normal == value.normal && selectedFocused == value.selectedFocused && selectedUnfocused == value.selectedUnfocused;}
bool operator!=(const ColorEntry& value){return true;} bool operator!=(const ColorEntry& value)const {return !(*this == value);}
}; };
} }
@@ -5826,6 +5829,16 @@ namespace vl
Event Event
***********************************************************************/ ***********************************************************************/
class IGuiGraphicsEventHandler : public virtual IDescriptable, public Description<IGuiGraphicsEventHandler>
{
public:
class Container
{
public:
Ptr<IGuiGraphicsEventHandler> handler;
};
};
template<typename T> template<typename T>
class GuiGraphicsEvent : public Object, public Description<GuiGraphicsEvent<T>> class GuiGraphicsEvent : public Object, public Description<GuiGraphicsEvent<T>>
{ {
@@ -5833,20 +5846,8 @@ Event
typedef void(RawFunctionType)(GuiGraphicsComposition*, T&); typedef void(RawFunctionType)(GuiGraphicsComposition*, T&);
typedef Func<RawFunctionType> FunctionType; typedef Func<RawFunctionType> FunctionType;
typedef T ArgumentType; typedef T ArgumentType;
class IHandler : public virtual IDescriptable, public Description<IHandler>
{
public:
virtual void Execute(GuiGraphicsComposition* sender, T& argument)=0;
};
class HandlerContainer
{
public:
Ptr<IHandler> handler;
};
class FunctionHandler : public Object, public IHandler class FunctionHandler : public Object, public IGuiGraphicsEventHandler
{ {
protected: protected:
FunctionType handler; FunctionType handler;
@@ -5856,7 +5857,7 @@ Event
{ {
} }
void Execute(GuiGraphicsComposition* sender, T& argument)override void Execute(GuiGraphicsComposition* sender, T& argument)
{ {
handler(sender, argument); handler(sender, argument);
} }
@@ -5864,12 +5865,31 @@ Event
protected: protected:
struct HandlerNode struct HandlerNode
{ {
Ptr<IHandler> handler; Ptr<FunctionHandler> handler;
Ptr<HandlerNode> next; Ptr<HandlerNode> next;
}; };
GuiGraphicsComposition* sender; GuiGraphicsComposition* sender;
Ptr<HandlerNode> handlers; Ptr<HandlerNode> handlers;
bool Attach(Ptr<FunctionHandler> handler)
{
Ptr<HandlerNode>* currentHandler = &handlers;
while (*currentHandler)
{
if ((*currentHandler)->handler == handler)
{
return false;
}
else
{
currentHandler = &(*currentHandler)->next;
}
}
(*currentHandler) = new HandlerNode;
(*currentHandler)->handler = handler;
return true;
}
public: public:
GuiGraphicsEvent(GuiGraphicsComposition* _sender=0) GuiGraphicsEvent(GuiGraphicsComposition* _sender=0)
:sender(_sender) :sender(_sender)
@@ -5890,63 +5910,50 @@ Event
sender=_sender; sender=_sender;
} }
bool Attach(Ptr<IHandler> handler)
{
Ptr<HandlerNode>* currentHandler=&handlers;
while(*currentHandler)
{
if((*currentHandler)->handler==handler)
{
return false;
}
else
{
currentHandler=&(*currentHandler)->next;
}
}
(*currentHandler)=new HandlerNode;
(*currentHandler)->handler=handler;
return true;
}
template<typename TClass, typename TMethod> template<typename TClass, typename TMethod>
Ptr<IHandler> AttachMethod(TClass* receiver, TMethod TClass::* method) Ptr<IGuiGraphicsEventHandler> AttachMethod(TClass* receiver, TMethod TClass::* method)
{ {
Ptr<IHandler> handler=new FunctionHandler(FunctionType(receiver, method)); auto handler=MakePtr<FunctionHandler>(FunctionType(receiver, method));
Attach(handler); Attach(handler);
return handler; return handler;
} }
Ptr<IHandler> AttachFunction(RawFunctionType* function) Ptr<IGuiGraphicsEventHandler> AttachFunction(RawFunctionType* function)
{ {
Ptr<IHandler> handler=new FunctionHandler(FunctionType(function)); auto handler = MakePtr<FunctionHandler>(FunctionType(function));
Attach(handler); Attach(handler);
return handler; return handler;
} }
Ptr<IHandler> AttachFunction(const FunctionType& function) Ptr<IGuiGraphicsEventHandler> AttachFunction(const FunctionType& function)
{ {
Ptr<IHandler> handler=new FunctionHandler(function); auto handler = MakePtr<FunctionHandler>(function);
Attach(handler); Attach(handler);
return handler; return handler;
} }
template<typename TLambda> template<typename TLambda>
Ptr<IHandler> AttachLambda(const TLambda& lambda) Ptr<IGuiGraphicsEventHandler> AttachLambda(const TLambda& lambda)
{ {
Ptr<IHandler> handler=new FunctionHandler(FunctionType(lambda)); auto handler = MakePtr<FunctionHandler>(FunctionType(lambda));
Attach(handler); Attach(handler);
return handler; return handler;
} }
bool Detach(Ptr<IHandler> handler) bool Detach(Ptr<IGuiGraphicsEventHandler> handler)
{ {
Ptr<HandlerNode>* currentHandler=&handlers; auto typedHandler = handler.Cast<FunctionHandler>();
if (!typedHandler)
{
return false;
}
auto currentHandler=&handlers;
while(*currentHandler) while(*currentHandler)
{ {
if((*currentHandler)->handler==handler) if((*currentHandler)->handler == typedHandler)
{ {
Ptr<HandlerNode> next=(*currentHandler)->next; auto next=(*currentHandler)->next;
(*currentHandler)=next; (*currentHandler)=next;
return true; return true;
} }
@@ -5960,7 +5967,7 @@ Event
void ExecuteWithNewSender(T& argument, GuiGraphicsComposition* newSender) void ExecuteWithNewSender(T& argument, GuiGraphicsComposition* newSender)
{ {
Ptr<HandlerNode>* currentHandler=&handlers; auto currentHandler=&handlers;
while(*currentHandler) while(*currentHandler)
{ {
(*currentHandler)->handler->Execute(newSender?newSender:sender, argument); (*currentHandler)->handler->Execute(newSender?newSender:sender, argument);
@@ -5980,12 +5987,6 @@ Event
} }
}; };
template<typename T>
Ptr<typename GuiGraphicsEvent<T>::HandlerContainer> CreateEventHandlerContainer()
{
return new typename GuiGraphicsEvent<T>::HandlerContainer;
}
/*********************************************************************** /***********************************************************************
Predefined Events Predefined Events
***********************************************************************/ ***********************************************************************/
@@ -10705,18 +10706,18 @@ List Control
class VisibleStyleHelper class VisibleStyleHelper
{ {
public: public:
Ptr<compositions::GuiMouseEvent::IHandler> leftButtonDownHandler; Ptr<compositions::IGuiGraphicsEventHandler> leftButtonDownHandler;
Ptr<compositions::GuiMouseEvent::IHandler> leftButtonUpHandler; Ptr<compositions::IGuiGraphicsEventHandler> leftButtonUpHandler;
Ptr<compositions::GuiMouseEvent::IHandler> leftButtonDoubleClickHandler; Ptr<compositions::IGuiGraphicsEventHandler> leftButtonDoubleClickHandler;
Ptr<compositions::GuiMouseEvent::IHandler> middleButtonDownHandler; Ptr<compositions::IGuiGraphicsEventHandler> middleButtonDownHandler;
Ptr<compositions::GuiMouseEvent::IHandler> middleButtonUpHandler; Ptr<compositions::IGuiGraphicsEventHandler> middleButtonUpHandler;
Ptr<compositions::GuiMouseEvent::IHandler> middleButtonDoubleClickHandler; Ptr<compositions::IGuiGraphicsEventHandler> middleButtonDoubleClickHandler;
Ptr<compositions::GuiMouseEvent::IHandler> rightButtonDownHandler; Ptr<compositions::IGuiGraphicsEventHandler> rightButtonDownHandler;
Ptr<compositions::GuiMouseEvent::IHandler> rightButtonUpHandler; Ptr<compositions::IGuiGraphicsEventHandler> rightButtonUpHandler;
Ptr<compositions::GuiMouseEvent::IHandler> rightButtonDoubleClickHandler; Ptr<compositions::IGuiGraphicsEventHandler> rightButtonDoubleClickHandler;
Ptr<compositions::GuiMouseEvent::IHandler> mouseMoveHandler; Ptr<compositions::IGuiGraphicsEventHandler> mouseMoveHandler;
Ptr<compositions::GuiNotifyEvent::IHandler> mouseEnterHandler; Ptr<compositions::IGuiGraphicsEventHandler> mouseEnterHandler;
Ptr<compositions::GuiNotifyEvent::IHandler> mouseLeaveHandler; Ptr<compositions::IGuiGraphicsEventHandler> mouseLeaveHandler;
}; };
friend class collections::ArrayBase<Ptr<VisibleStyleHelper>>; friend class collections::ArrayBase<Ptr<VisibleStyleHelper>>;
@@ -17186,7 +17187,7 @@ namespace vl
compositions::IGuiShortcutKeyItem* shortcutKeyItem; compositions::IGuiShortcutKeyItem* shortcutKeyItem;
bool enabled; bool enabled;
bool selected; bool selected;
Ptr<compositions::GuiNotifyEvent::IHandler> shortcutKeyItemExecutedHandler; Ptr<compositions::IGuiGraphicsEventHandler> shortcutKeyItemExecutedHandler;
Ptr<ShortcutBuilder> shortcutBuilder; Ptr<ShortcutBuilder> shortcutBuilder;
GuiControlHost* shortcutOwner; GuiControlHost* shortcutOwner;
@@ -17471,7 +17472,7 @@ Toolstrip Component
{ {
protected: protected:
GuiToolstripCommand* command; GuiToolstripCommand* command;
Ptr<compositions::GuiNotifyEvent::IHandler> descriptionChangedHandler; Ptr<compositions::IGuiGraphicsEventHandler> descriptionChangedHandler;
void UpdateCommandContent(); void UpdateCommandContent();
void OnClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments); void OnClicked(compositions::GuiGraphicsComposition* sender, compositions::GuiEventArgs& arguments);
@@ -18391,7 +18392,7 @@ Control Template
Item Template Item Template
***********************************************************************/ ***********************************************************************/
class GuiListItemTemplate : public GuiTemplate, public Description<GuiListItemTemplate> class GuiListItemTemplate : public GuiTemplate, public AggregatableDescription<GuiListItemTemplate>
{ {
public: public:
GuiListItemTemplate(); GuiListItemTemplate();
+48 -7
View File
@@ -1072,6 +1072,7 @@ namespace vl
using namespace workflow::analyzer; using namespace workflow::analyzer;
using namespace workflow::runtime; using namespace workflow::runtime;
using namespace controls; using namespace controls;
using namespace stream;
/*********************************************************************** /***********************************************************************
GuiResourceInstanceBinder (uri) GuiResourceInstanceBinder (uri)
@@ -1220,7 +1221,22 @@ GuiBindInstanceBinder (bind)
Ptr<workflow::WfStatement> GenerateInstallStatement(GlobalStringKey variableName, description::IPropertyInfo* propertyInfo, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, const WString& code, collections::List<WString>& errors)override Ptr<workflow::WfStatement> GenerateInstallStatement(GlobalStringKey variableName, description::IPropertyInfo* propertyInfo, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, const WString& code, collections::List<WString>& errors)override
{ {
if (auto expression = Workflow_ParseExpression(L"bind(" + code + L")", errors)) WString typeExpr;
{
auto type = GetTypeFromTypeInfo(propertyInfo->GetReturn());
MemoryStream stream;
{
StreamWriter writer(stream);
WfPrint(type, L"", writer);
}
stream.SeekFromBegin(0);
{
StreamReader reader(stream);
typeExpr = reader.ReadToEnd();
}
}
if (auto expression = Workflow_ParseExpression(L"bind((" + code + L") of (" + typeExpr + L"))", errors))
{ {
return Workflow_InstallBindProperty(variableName, propertyInfo, expression); return Workflow_InstallBindProperty(variableName, propertyInfo, expression);
} }
@@ -4054,9 +4070,9 @@ GuiListViewInstanceLoader
if (indexView != -1) if (indexView != -1)
{ {
auto viewExpr = arguments.GetByIndex(indexView)[0].expression; auto viewExpr = arguments.GetByIndex(indexView)[0].expression;
if (auto inferExpr = viewExpr.Cast<WfInferExpression>()) if (auto inferExpr = viewExpr.template Cast<WfInferExpression>())
{ {
if (auto refExpr = inferExpr->expression.Cast<WfReferenceExpression>()) if (auto refExpr = inferExpr->expression.template Cast<WfReferenceExpression>())
{ {
auto enumType = description::GetTypeDescriptor<ListViewViewType>()->GetEnumType(); auto enumType = description::GetTypeDescriptor<ListViewViewType>()->GetEnumType();
vint index = enumType->IndexOfItem(refExpr->name.value); vint index = enumType->IndexOfItem(refExpr->name.value);
@@ -4108,12 +4124,37 @@ GuiListViewInstanceLoader
else else
{ {
{ {
auto stringValue = MakePtr<WfStringExpression>(); auto ctorExpr = MakePtr<WfConstructorExpression>();
stringValue->value.value = L"x:32 y:32"; {
auto argument = MakePtr<WfConstructorArgument>();
{
auto key = MakePtr<WfReferenceExpression>();
key->name.value = L"x";
argument->key = key;
auto iconSizeValue = MakePtr<WfTypeCastingExpression>(); auto value = MakePtr<WfIntegerExpression>();
value->value.value = L"32";
argument->value = value;
}
ctorExpr->arguments.Add(argument);
}
{
auto argument = MakePtr<WfConstructorArgument>();
{
auto key = MakePtr<WfReferenceExpression>();
key->name.value = L"y";
argument->key = key;
auto value = MakePtr<WfIntegerExpression>();
value->value.value = L"32";
argument->value = value;
}
ctorExpr->arguments.Add(argument);
}
auto iconSizeValue = MakePtr<WfInferExpression>();
iconSizeValue->type = GetTypeFromTypeInfo(TypeInfoRetriver<Size>::CreateTypeInfo().Obj()); iconSizeValue->type = GetTypeFromTypeInfo(TypeInfoRetriver<Size>::CreateTypeInfo().Obj());
iconSizeValue->expression = stringValue; iconSizeValue->expression = ctorExpr;
createStyle->arguments.Add(iconSizeValue); createStyle->arguments.Add(iconSizeValue);
} }
+43 -3
View File
@@ -2155,6 +2155,43 @@ Type List
GuiEventInfoImpl GuiEventInfoImpl
***********************************************************************/ ***********************************************************************/
class GuiEventInfoCpp : public Object, public IEventInfo::ICpp
{
public:
WString handlerType;
WString attachTemplate;
WString detachTemplate;
WString invokeTemplate;
GuiEventInfoCpp()
:handlerType(L"::vl::Ptr<::vl::presentation::compositions::IGuiGraphicsEventHandler>", false)
, attachTemplate(L"$This->GetEventReceiver()->$Name.AttachLambda($Handler)", false)
, detachTemplate(L"$This->GetEventReceiver()->$Name.Detach($Handler)", false)
, invokeTemplate(L"$This->GetEventReceiver()->$Name.Execute($Arguments)", false)
{
}
const WString& GetHandlerType()override
{
return handlerType;
}
const WString& GetAttachTemplate()override
{
return attachTemplate;
}
const WString& GetDetachTemplate()override
{
return detachTemplate;
}
const WString& GetInvokeTemplate()override
{
return invokeTemplate;
}
};
template<typename T> template<typename T>
class GuiEventInfoImpl : public EventInfoImpl class GuiEventInfoImpl : public EventInfoImpl
{ {
@@ -2166,6 +2203,7 @@ GuiEventInfoImpl
typedef Func<GuiGraphicsEvent<T>*(DescriptableObject*, bool)> EventRetriverFunction; typedef Func<GuiGraphicsEvent<T>*(DescriptableObject*, bool)> EventRetriverFunction;
EventRetriverFunction eventRetriver; EventRetriverFunction eventRetriver;
Ptr<GuiEventInfoCpp> cpp;
void AttachInternal(DescriptableObject* thisObject, IEventHandler* eventHandler)override void AttachInternal(DescriptableObject* thisObject, IEventHandler* eventHandler)override
{ {
@@ -2202,7 +2240,7 @@ GuiEventInfoImpl
GuiGraphicsEvent<T>* eventObject=eventRetriver(thisObject, false); GuiGraphicsEvent<T>* eventObject=eventRetriver(thisObject, false);
if(eventObject) if(eventObject)
{ {
auto handler=handlerImpl->GetDescriptableTag().Cast<typename GuiGraphicsEvent<T>::IHandler>(); auto handler=handlerImpl->GetDescriptableTag().Cast<presentation::compositions::IGuiGraphicsEventHandler>();
if(handler) if(handler)
{ {
eventObject->Detach(handler); eventObject->Detach(handler);
@@ -2229,10 +2267,12 @@ GuiEventInfoImpl
{ {
return TypeInfoRetriver<Func<void(GuiGraphicsComposition*, T*)>>::CreateTypeInfo(); return TypeInfoRetriver<Func<void(GuiGraphicsComposition*, T*)>>::CreateTypeInfo();
} }
public: public:
GuiEventInfoImpl(ITypeDescriptor* _ownerTypeDescriptor, const WString& _name, const EventRetriverFunction& _eventRetriver) GuiEventInfoImpl(ITypeDescriptor* _ownerTypeDescriptor, const WString& _name, const EventRetriverFunction& _eventRetriver)
:EventInfoImpl(_ownerTypeDescriptor, _name) :EventInfoImpl(_ownerTypeDescriptor, _name)
,eventRetriver(_eventRetriver) , eventRetriver(_eventRetriver)
, cpp(MakePtr<GuiEventInfoCpp>())
{ {
} }
@@ -2242,7 +2282,7 @@ GuiEventInfoImpl
ICpp* GetCpp()override ICpp* GetCpp()override
{ {
throw 0; return cpp.Obj();
} }
}; };
+12 -10
View File
@@ -483,20 +483,22 @@ FilePath
void FilePath::Initialize() void FilePath::Initialize()
{ {
Array<wchar_t> buffer(fullPath.Length() + 1);
#if defined VCZH_MSVC
wcscpy_s(&buffer[0], fullPath.Length() + 1, fullPath.Buffer());
#elif defined VCZH_GCC
wcscpy(&buffer[0], fullPath.Buffer());
#endif
for (vint i = 0; i < buffer.Count(); i++)
{ {
if (buffer[i] == L'\\' || buffer[i] == L'/') Array<wchar_t> buffer(fullPath.Length() + 1);
#if defined VCZH_MSVC
wcscpy_s(&buffer[0], fullPath.Length() + 1, fullPath.Buffer());
#elif defined VCZH_GCC
wcscpy(&buffer[0], fullPath.Buffer());
#endif
for (vint i = 0; i < buffer.Count(); i++)
{ {
buffer[i] = Delimiter; if (buffer[i] == L'\\' || buffer[i] == L'/')
{
buffer[i] = Delimiter;
}
} }
fullPath = &buffer[0];
} }
fullPath = &buffer[0];
#if defined VCZH_MSVC #if defined VCZH_MSVC
if (fullPath.Length() < 2 || fullPath[1] != L':') if (fullPath.Length() < 2 || fullPath[1] != L':')
+434 -305
View File
File diff suppressed because it is too large Load Diff
+402 -12
View File
File diff suppressed because it is too large Load Diff
+167 -33
View File
@@ -295,33 +295,24 @@ namespace vl
namespace reflection namespace reflection
{ {
template<> #define DEFINE_DESCRIPTION(TYPE)\
class Description<workflow::typeimpl::WfClassInstance> : public virtual DescriptableObject template<>\
{ class Description<workflow::typeimpl::TYPE> : public virtual DescriptableObject\
private: {\
description::ITypeDescriptor* associatedTypeDescriptor; private:\
description::ITypeDescriptor* associatedTypeDescriptor;\
public:\
Description(description::ITypeDescriptor* _associatedTypeDescriptor)\
:associatedTypeDescriptor(_associatedTypeDescriptor)\
{\
typeDescriptor = &associatedTypeDescriptor;\
}\
};\
public: DEFINE_DESCRIPTION(WfClassInstance)
Description(description::ITypeDescriptor* _associatedTypeDescriptor) DEFINE_DESCRIPTION(WfInterfaceInstance)
:associatedTypeDescriptor(_associatedTypeDescriptor)
{
typeDescriptor = &associatedTypeDescriptor;
}
};
template<> #undef DEFINE_DESCRIPTION
class Description<workflow::typeimpl::WfInterfaceInstance> : public virtual DescriptableObject
{
private:
description::ITypeDescriptor* associatedTypeDescriptor;
public:
Description(description::ITypeDescriptor* _associatedTypeDescriptor)
:associatedTypeDescriptor(_associatedTypeDescriptor)
{
typeDescriptor = &associatedTypeDescriptor;
}
};
} }
namespace workflow namespace workflow
@@ -508,6 +499,23 @@ Field
void SetReturn(Ptr<ITypeInfo> typeInfo); void SetReturn(Ptr<ITypeInfo> typeInfo);
}; };
class WfStructField : public reflection::description::FieldInfoImpl
{
typedef reflection::description::ITypeDescriptor ITypeDescriptor;
typedef reflection::description::ITypeInfo ITypeInfo;
typedef reflection::description::Value Value;
protected:
Value GetValueInternal(const Value& thisObject)override;
void SetValueInternal(Value& thisObject, const Value& newValue)override;
public:
WfStructField(ITypeDescriptor* ownerTypeDescriptor, const WString& name);
~WfStructField();
ICpp* GetCpp()override;
void SetReturn(Ptr<ITypeInfo> typeInfo);
};
/*********************************************************************** /***********************************************************************
Property Property
***********************************************************************/ ***********************************************************************/
@@ -530,7 +538,25 @@ Property
Custom Type Custom Type
***********************************************************************/ ***********************************************************************/
class WfCustomType : public reflection::description::TypeDescriptorImpl struct WfTypeInfoContent : reflection::description::TypeInfoContent
{
WString workflowTypeName;
WfTypeInfoContent(const WString& _workflowTypeName);
};
template<typename TBase>
class WfCustomTypeBase : private WfTypeInfoContent, public TBase
{
public:
WfCustomTypeBase(reflection::description::TypeDescriptorFlags typeDescriptorFlags, const WString& typeName)
:WfTypeInfoContent(typeName)
, TBase(typeDescriptorFlags, this)
{
}
};
class WfCustomType : public WfCustomTypeBase<reflection::description::TypeDescriptorImpl>
{ {
protected: protected:
typedef reflection::description::TypeDescriptorFlags TypeDescriptorFlags; typedef reflection::description::TypeDescriptorFlags TypeDescriptorFlags;
@@ -539,13 +565,6 @@ Custom Type
typedef reflection::description::IMethodGroupInfo IMethodGroupInfo; typedef reflection::description::IMethodGroupInfo IMethodGroupInfo;
typedef collections::List<ITypeDescriptor*> TypeDescriptorList; typedef collections::List<ITypeDescriptor*> TypeDescriptorList;
struct WfTypeInfoContent : reflection::description::TypeInfoContent
{
WString workflowTypeName;
WfTypeInfoContent(const WString& _workflowTypeName);
};
protected: protected:
runtime::WfRuntimeGlobalContext* globalContext = nullptr; runtime::WfRuntimeGlobalContext* globalContext = nullptr;
bool baseTypeExpanded = false; bool baseTypeExpanded = false;
@@ -588,6 +607,89 @@ Custom Type
~WfInterface(); ~WfInterface();
}; };
class WfStruct : public WfCustomTypeBase<reflection::description::ValueTypeDescriptorBase>
{
using FieldMap = collections::Dictionary<WString, Ptr<WfStructField>>;
using IPropertyInfo = reflection::description::IPropertyInfo;
using IValueType = reflection::description::IValueType;
protected:
class WfValueType : public Object, public virtual IValueType
{
using Value = reflection::description::Value;
protected:
WfStruct* owner;
public:
WfValueType(WfStruct* _owner);
Value CreateDefault()override;
CompareResult Compare(const Value& a, const Value& b)override;
};
protected:
FieldMap fields;
public:
WfStruct(const WString& typeName);
~WfStruct();
vint GetPropertyCount()override;
IPropertyInfo* GetProperty(vint index)override;
bool IsPropertyExists(const WString& name, bool inheritable)override;
IPropertyInfo* GetPropertyByName(const WString& name, bool inheritable)override;
void AddMember(Ptr<WfStructField> value);
};
class WfEnum : public WfCustomTypeBase<reflection::description::ValueTypeDescriptorBase>
{
using EnumItemMap = collections::Dictionary<WString, vuint64_t>;
using IValueType = reflection::description::IValueType;
using IEnumType = reflection::description::IEnumType;
using Value = reflection::description::Value;
protected:
class WfValueType : public Object, public virtual IValueType
{
protected:
WfEnum* owner;
public:
WfValueType(WfEnum* _owner);
Value CreateDefault()override;
CompareResult Compare(const Value& a, const Value& b)override;
};
class WfEnumType : public Object, public virtual IEnumType
{
protected:
WfEnum* owner;
public:
WfEnumType(WfEnum* _owner);
bool IsFlagEnum()override;
vint GetItemCount()override;
WString GetItemName(vint index)override;
vuint64_t GetItemValue(vint index)override;
vint IndexOfItem(WString name)override;
Value ToEnum(vuint64_t value)override;
vuint64_t FromEnum(const Value& value)override;
};
protected:
EnumItemMap enumItems;
public:
WfEnum(bool isFlags, const WString& typeName);
~WfEnum();
void AddEnumItem(const WString& name, vuint64_t value);
};
/*********************************************************************** /***********************************************************************
Instance Instance
***********************************************************************/ ***********************************************************************/
@@ -621,6 +723,36 @@ Instance
Ptr<IValueInterfaceProxy> GetProxy(); Ptr<IValueInterfaceProxy> GetProxy();
}; };
struct WfStructInstance
{
using FieldValueMap = collections::Dictionary<WfStructField*, reflection::description::Value>;
FieldValueMap fieldValues;
WfStructInstance()
{
}
WfStructInstance(const WfStructInstance& si)
{
CopyFrom(fieldValues, si.fieldValues);
}
WfStructInstance& operator=(const WfStructInstance& si)
{
if (this != &si)
{
CopyFrom(fieldValues, si.fieldValues);
}
return *this;
}
};
struct WfEnumInstance
{
vuint64_t value = 0;
};
/*********************************************************************** /***********************************************************************
Plugin Plugin
***********************************************************************/ ***********************************************************************/
@@ -633,6 +765,8 @@ Plugin
public: public:
collections::List<Ptr<WfClass>> classes; collections::List<Ptr<WfClass>> classes;
collections::List<Ptr<WfInterface>> interfaces; collections::List<Ptr<WfInterface>> interfaces;
collections::List<Ptr<WfStruct>> structs;
collections::List<Ptr<WfEnum>> enums;
runtime::WfRuntimeGlobalContext* GetGlobalContext(); runtime::WfRuntimeGlobalContext* GetGlobalContext();
void SetGlobalContext(runtime::WfRuntimeGlobalContext* _globalContext); void SetGlobalContext(runtime::WfRuntimeGlobalContext* _globalContext);
File diff suppressed because one or more lines are too long
+112 -16
View File
@@ -109,21 +109,24 @@ namespace vl
KEYWORD_CATCH = 80, KEYWORD_CATCH = 80,
KEYWORD_FINALLY = 81, KEYWORD_FINALLY = 81,
KEYWORD_CLASS = 82, KEYWORD_CLASS = 82,
KEYWORD_PROP = 83, KEYWORD_ENUM = 83,
KEYWORD_EVENT = 84, KEYWORD_FLAGENUM = 84,
KEYWORD_STATIC = 85, KEYWORD_STRUCT = 85,
KEYWORD_OVERRIDE = 86, KEYWORD_PROP = 86,
KEYWORD_USING = 87, KEYWORD_EVENT = 87,
KEYWORD_NAMESPACE = 88, KEYWORD_STATIC = 88,
KEYWORD_MODULE = 89, KEYWORD_OVERRIDE = 89,
KEYWORD_UNIT = 90, KEYWORD_USING = 90,
NAME = 91, KEYWORD_NAMESPACE = 91,
ORDERED_NAME = 92, KEYWORD_MODULE = 92,
FLOAT = 93, KEYWORD_UNIT = 93,
INTEGER = 94, NAME = 94,
STRING = 95, ORDERED_NAME = 95,
FORMATSTRING = 96, FLOAT = 96,
SPACE = 97, INTEGER = 97,
STRING = 98,
FORMATSTRING = 99,
SPACE = 100,
}; };
class WfType; class WfType;
class WfPredefinedType; class WfPredefinedType;
@@ -198,6 +201,11 @@ namespace vl
class WfConstructorDeclaration; class WfConstructorDeclaration;
class WfDestructorDeclaration; class WfDestructorDeclaration;
class WfClassDeclaration; class WfClassDeclaration;
class WfEnumItemIntersection;
class WfEnumItem;
class WfEnumDeclaration;
class WfStructMember;
class WfStructDeclaration;
class WfModuleUsingFragment; class WfModuleUsingFragment;
class WfModuleUsingNameFragment; class WfModuleUsingNameFragment;
class WfModuleUsingWildCardFragment; class WfModuleUsingWildCardFragment;
@@ -985,6 +993,8 @@ namespace vl
virtual void Visit(WfConstructorDeclaration* node)=0; virtual void Visit(WfConstructorDeclaration* node)=0;
virtual void Visit(WfDestructorDeclaration* node)=0; virtual void Visit(WfDestructorDeclaration* node)=0;
virtual void Visit(WfClassDeclaration* node)=0; virtual void Visit(WfClassDeclaration* node)=0;
virtual void Visit(WfEnumDeclaration* node)=0;
virtual void Visit(WfStructDeclaration* node)=0;
}; };
virtual void Accept(WfDeclaration::IVisitor* visitor)=0; virtual void Accept(WfDeclaration::IVisitor* visitor)=0;
@@ -1180,6 +1190,67 @@ namespace vl
static vl::Ptr<WfClassDeclaration> Convert(vl::Ptr<vl::parsing::ParsingTreeNode> node, const vl::collections::List<vl::regex::RegexToken>& tokens); static vl::Ptr<WfClassDeclaration> Convert(vl::Ptr<vl::parsing::ParsingTreeNode> node, const vl::collections::List<vl::regex::RegexToken>& tokens);
}; };
enum class WfEnumKind
{
Normal,
Flag,
};
enum class WfEnumItemKind
{
Constant,
Intersection,
};
class WfEnumItemIntersection : public vl::parsing::ParsingTreeCustomBase, vl::reflection::Description<WfEnumItemIntersection>
{
public:
vl::parsing::ParsingToken name;
static vl::Ptr<WfEnumItemIntersection> Convert(vl::Ptr<vl::parsing::ParsingTreeNode> node, const vl::collections::List<vl::regex::RegexToken>& tokens);
};
class WfEnumItem : public vl::parsing::ParsingTreeCustomBase, vl::reflection::Description<WfEnumItem>
{
public:
vl::parsing::ParsingToken name;
WfEnumItemKind kind;
vl::parsing::ParsingToken number;
vl::collections::List<vl::Ptr<WfEnumItemIntersection>> intersections;
static vl::Ptr<WfEnumItem> Convert(vl::Ptr<vl::parsing::ParsingTreeNode> node, const vl::collections::List<vl::regex::RegexToken>& tokens);
};
class WfEnumDeclaration : public WfDeclaration, vl::reflection::Description<WfEnumDeclaration>
{
public:
WfEnumKind kind;
vl::collections::List<vl::Ptr<WfEnumItem>> items;
void Accept(WfDeclaration::IVisitor* visitor)override;
static vl::Ptr<WfEnumDeclaration> Convert(vl::Ptr<vl::parsing::ParsingTreeNode> node, const vl::collections::List<vl::regex::RegexToken>& tokens);
};
class WfStructMember : public vl::parsing::ParsingTreeCustomBase, vl::reflection::Description<WfStructMember>
{
public:
vl::parsing::ParsingToken name;
vl::Ptr<WfType> type;
static vl::Ptr<WfStructMember> Convert(vl::Ptr<vl::parsing::ParsingTreeNode> node, const vl::collections::List<vl::regex::RegexToken>& tokens);
};
class WfStructDeclaration : public WfDeclaration, vl::reflection::Description<WfStructDeclaration>
{
public:
vl::collections::List<vl::Ptr<WfStructMember>> members;
void Accept(WfDeclaration::IVisitor* visitor)override;
static vl::Ptr<WfStructDeclaration> Convert(vl::Ptr<vl::parsing::ParsingTreeNode> node, const vl::collections::List<vl::regex::RegexToken>& tokens);
};
class WfModuleUsingFragment abstract : public vl::parsing::ParsingTreeCustomBase, vl::reflection::Description<WfModuleUsingFragment> class WfModuleUsingFragment abstract : public vl::parsing::ParsingTreeCustomBase, vl::reflection::Description<WfModuleUsingFragment>
{ {
public: public:
@@ -1371,6 +1442,13 @@ namespace vl
DECL_TYPE_INFO(vl::workflow::WfConstructorDeclaration) DECL_TYPE_INFO(vl::workflow::WfConstructorDeclaration)
DECL_TYPE_INFO(vl::workflow::WfDestructorDeclaration) DECL_TYPE_INFO(vl::workflow::WfDestructorDeclaration)
DECL_TYPE_INFO(vl::workflow::WfClassDeclaration) DECL_TYPE_INFO(vl::workflow::WfClassDeclaration)
DECL_TYPE_INFO(vl::workflow::WfEnumKind)
DECL_TYPE_INFO(vl::workflow::WfEnumItemKind)
DECL_TYPE_INFO(vl::workflow::WfEnumItemIntersection)
DECL_TYPE_INFO(vl::workflow::WfEnumItem)
DECL_TYPE_INFO(vl::workflow::WfEnumDeclaration)
DECL_TYPE_INFO(vl::workflow::WfStructMember)
DECL_TYPE_INFO(vl::workflow::WfStructDeclaration)
DECL_TYPE_INFO(vl::workflow::WfModuleUsingFragment) DECL_TYPE_INFO(vl::workflow::WfModuleUsingFragment)
DECL_TYPE_INFO(vl::workflow::WfModuleUsingNameFragment) DECL_TYPE_INFO(vl::workflow::WfModuleUsingNameFragment)
DECL_TYPE_INFO(vl::workflow::WfModuleUsingWildCardFragment) DECL_TYPE_INFO(vl::workflow::WfModuleUsingWildCardFragment)
@@ -1709,6 +1787,16 @@ namespace vl
INVOKE_INTERFACE_PROXY(Visit, node); INVOKE_INTERFACE_PROXY(Visit, node);
} }
void Visit(vl::workflow::WfEnumDeclaration* node)override
{
INVOKE_INTERFACE_PROXY(Visit, node);
}
void Visit(vl::workflow::WfStructDeclaration* node)override
{
INVOKE_INTERFACE_PROXY(Visit, node);
}
END_INTERFACE_PROXY(vl::workflow::WfDeclaration::IVisitor) END_INTERFACE_PROXY(vl::workflow::WfDeclaration::IVisitor)
BEGIN_INTERFACE_PROXY_NOPARENT_SHAREDPTR(vl::workflow::WfModuleUsingFragment::IVisitor) BEGIN_INTERFACE_PROXY_NOPARENT_SHAREDPTR(vl::workflow::WfModuleUsingFragment::IVisitor)
@@ -1953,7 +2041,7 @@ Scope Manager
typedef collections::Dictionary<Ptr<WfExpression>, ResolveExpressionResult> ExpressionResolvingMap; typedef collections::Dictionary<Ptr<WfExpression>, ResolveExpressionResult> ExpressionResolvingMap;
typedef collections::Dictionary<parsing::ParsingTreeCustomBase*, Ptr<WfLexicalCapture>> LambdaCaptureMap; typedef collections::Dictionary<parsing::ParsingTreeCustomBase*, Ptr<WfLexicalCapture>> LambdaCaptureMap;
typedef collections::Dictionary<WfFunctionDeclaration*, IMethodInfo*> InterfaceMethodImplementationMap; typedef collections::Dictionary<WfFunctionDeclaration*, IMethodInfo*> InterfaceMethodImplementationMap;
typedef collections::Dictionary<Ptr<WfDeclaration>, Ptr<typeimpl::WfCustomType>> DeclarationTypeMap; typedef collections::Dictionary<Ptr<WfDeclaration>, Ptr<ITypeDescriptor>> DeclarationTypeMap;
typedef collections::Dictionary<Ptr<WfDeclaration>, Ptr<IMemberInfo>> DeclarationMemberInfoMap; typedef collections::Dictionary<Ptr<WfDeclaration>, Ptr<IMemberInfo>> DeclarationMemberInfoMap;
typedef collections::Pair<WfConstructorDeclaration*, ITypeDescriptor*> BaseConstructorCallKey; typedef collections::Pair<WfConstructorDeclaration*, ITypeDescriptor*> BaseConstructorCallKey;
@@ -2101,6 +2189,7 @@ Global Name
***********************************************************************/ ***********************************************************************/
extern void BuildGlobalNameFromTypeDescriptors(WfLexicalScopeManager* manager); extern void BuildGlobalNameFromTypeDescriptors(WfLexicalScopeManager* manager);
extern void BuildNameForDeclaration(WfLexicalScopeManager* manager, Ptr<WfLexicalScopeName> name, WfDeclaration* decl);
extern void BuildGlobalNameFromModules(WfLexicalScopeManager* manager); extern void BuildGlobalNameFromModules(WfLexicalScopeManager* manager);
extern void ValidateScopeName(WfLexicalScopeManager* manager, Ptr<WfLexicalScopeName> name); extern void ValidateScopeName(WfLexicalScopeManager* manager, Ptr<WfLexicalScopeName> name);
@@ -2374,6 +2463,13 @@ Error Messages
static Ptr<parsing::ParsingError> WrongDeclaration(WfConstructorDeclaration* node); static Ptr<parsing::ParsingError> WrongDeclaration(WfConstructorDeclaration* node);
static Ptr<parsing::ParsingError> WrongDeclaration(WfDestructorDeclaration* node); static Ptr<parsing::ParsingError> WrongDeclaration(WfDestructorDeclaration* node);
static Ptr<parsing::ParsingError> WrongDeclarationInInterfaceConstructor(WfDeclaration* node); static Ptr<parsing::ParsingError> WrongDeclarationInInterfaceConstructor(WfDeclaration* node);
static Ptr<parsing::ParsingError> EnumValuesNotConsecutiveFromZero(WfEnumDeclaration* node);
static Ptr<parsing::ParsingError> FlagValuesNotConsecutiveFromZero(WfEnumDeclaration* node);
static Ptr<parsing::ParsingError> FlagValueNotExists(WfEnumItemIntersection* node, WfEnumDeclaration* owner);
static Ptr<parsing::ParsingError> DuplicatedEnumValue(WfEnumItem* node, WfEnumDeclaration* owner);
static Ptr<parsing::ParsingError> StructContainsNonValueType(WfStructMember* node, WfStructDeclaration* owner);
static Ptr<parsing::ParsingError> StructRecursivelyIncludeItself(WfStructDeclaration* node, const WString& path);
static Ptr<parsing::ParsingError> DuplicatedStructMember(WfStructMember* node, WfStructDeclaration* owner);
// E: Module error // E: Module error
static Ptr<parsing::ParsingError> WrongUsingPathWildCard(WfModuleUsingPath* node); static Ptr<parsing::ParsingError> WrongUsingPathWildCard(WfModuleUsingPath* node);
BIN
View File
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.
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.
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.