Update release (TextEditor and BlackSkin breaks)

This commit is contained in:
vczh
2016-04-10 14:35:47 -07:00
parent 0e57847bc8
commit 79e7704184
33 changed files with 2710 additions and 725 deletions
+249 -25
View File
File diff suppressed because it is too large Load Diff
+136 -35
View File
@@ -3649,6 +3649,8 @@ Resource Type Resolver
/// <summary>Provide a context for resource precompiling</summary> /// <summary>Provide a context for resource precompiling</summary>
struct GuiResourcePrecompileContext struct GuiResourcePrecompileContext
{ {
typedef collections::Dictionary<Ptr<DescriptableObject>, Ptr<DescriptableObject>> PropertyMap;
/// <summary>The folder to contain compiled objects.</summary> /// <summary>The folder to contain compiled objects.</summary>
Ptr<GuiResourceFolder> targetFolder; Ptr<GuiResourceFolder> targetFolder;
/// <summary>The root resource object.</summary> /// <summary>The root resource object.</summary>
@@ -3657,27 +3659,71 @@ Resource Type Resolver
vint passIndex; vint passIndex;
/// <summary>The path resolver. This is only for delay load resource.</summary> /// <summary>The path resolver. This is only for delay load resource.</summary>
Ptr<GuiResourcePathResolver> resolver; Ptr<GuiResourcePathResolver> resolver;
/// <summary>Additional properties for resource item contents</summary>
PropertyMap additionalProperties;
}; };
/// <summary> /// <summary>
/// Represents a precompiler for resources of a specified type. /// Represents a precompiler for resources of a specified type.
/// Current resources that needs precompiling: /// Current resources that needs precompiling:
/// Pass 0: Script (collect workflow scripts) /// <Workflow>
/// Pass 1: Script (compile view model scripts) /// Pass 0: Collect workflow scripts
/// Pass 2: Script (compile shared scripts) /// Pass 1: Compile ViewModel scripts
/// Pass 3: Instance /// Pass 2: Compile Shared scripts
/// <Instance>
/// Pass 3: Collect instance types
/// Pass 4: Validate instance dependency
/// Pass 5: Generate TemporaryClass scripts, ClassNameRecord
/// Pass 6: Compile TemporaryClass scripts
/// Pass 7: Generate InstanceCtor scripts
/// Pass 8: Compile InstanceCtor scripts
/// Pass 9: Unload InstanceCtor, Delete TemporaryClass, Generate InstanceClass scripts
/// Pass 10: Compile InstanceClass scripts
/// </summary> /// </summary>
class IGuiResourceTypeResolver_Precompile : public virtual IDescriptable, public Description<IGuiResourceTypeResolver_Precompile> class IGuiResourceTypeResolver_Precompile : public virtual IDescriptable, public Description<IGuiResourceTypeResolver_Precompile>
{ {
public: public:
enum PassNames
{
Workflow_Collect = 0,
Workflow_CompileViewModel = 1,
Workflow_CompileShared = 2,
Workflow_Max = Workflow_CompileShared,
Instance_CollectInstanceTypes = 3,
Instance_ValidateDependency = 4,
Instance_GenerateTemporaryClass = 5,
Instance_CompileTemporaryClass = 6,
Instance_GenerateInstanceCtor = 7,
Instance_CompileInstanceCtor = 8,
Instance_GenerateInstanceClass = 9,
Instance_CompileInstanceClass = 10,
Instance_Max = Instance_CompileInstanceClass,
};
enum PassSupport
{
NotSupported,
PerResource,
PerPass,
};
/// <summary>Get the maximum pass index that the precompiler needs.</summary> /// <summary>Get the maximum pass index that the precompiler needs.</summary>
/// <returns>Returns the maximum pass index. The precompiler doesn't not need to response to every pass.</returns> /// <returns>Returns the maximum pass index. The precompiler doesn't not need to response to every pass.</returns>
virtual vint GetMaxPassIndex() = 0; virtual vint GetMaxPassIndex() = 0;
/// <summary>Get how this resolver supports precompiling.</summary>
/// <param name="passIndex">The pass index.</param>
/// <returns>Returns how this resolver supports precompiling.</returns>
virtual PassSupport GetPassSupport(vint passIndex) = 0;
/// <summary>Precompile the resource item.</summary> /// <summary>Precompile the resource item.</summary>
/// <param name="resource">The resource to precompile.</param> /// <param name="resource">The resource to precompile.</param>
/// <param name="context">The context for precompiling.</param> /// <param name="context">The context for precompiling.</param>
/// <param name="errors">All collected errors during loading a resource.</param> /// <param name="errors">All collected errors during loading a resource.</param>
virtual void Precompile(Ptr<GuiResourceItem> resource, GuiResourcePrecompileContext& context, collections::List<WString>& errors) = 0; virtual void PerResourcePrecompile(Ptr<GuiResourceItem> resource, GuiResourcePrecompileContext& context, collections::List<WString>& errors) = 0;
/// <summary>Precompile for a pass.</summary>
/// <param name="context">The context for precompiling.</param>
/// <param name="errors">All collected errors during loading a resource.</param>
virtual void PerPassPrecompile(GuiResourcePrecompileContext& context, collections::List<WString>& errors) = 0;
}; };
/// <summary>Provide a context for resource initializing</summary> /// <summary>Provide a context for resource initializing</summary>
@@ -3691,7 +3737,7 @@ Resource Type Resolver
/// Current resources that needs precompiling: /// Current resources that needs precompiling:
/// Pass 0: Script (initialize view model scripts) /// Pass 0: Script (initialize view model scripts)
/// Pass 1: Script (initialize shared scripts) /// Pass 1: Script (initialize shared scripts)
/// Pass 3: Script (initialize instance scripts) /// Pass 2: Script (initialize instance scripts)
/// </summary> /// </summary>
class IGuiResourceTypeResolver_Initialize : public virtual IDescriptable, public Description<IGuiResourceTypeResolver_Precompile> class IGuiResourceTypeResolver_Initialize : public virtual IDescriptable, public Description<IGuiResourceTypeResolver_Precompile>
{ {
@@ -3797,6 +3843,14 @@ Resource Resolver Manager
/// <summary>Get the maximum initializing pass index.</summary> /// <summary>Get the maximum initializing pass index.</summary>
/// <returns>The maximum initializing pass index.</returns> /// <returns>The maximum initializing pass index.</returns>
virtual vint GetMaxInitializePassIndex() = 0; virtual vint GetMaxInitializePassIndex() = 0;
/// <summary>Get names of all per resource resolvers for a pass.</summary>
/// <param name="passIndex">The pass index.</param>
/// <param name="resolvers">Names of resolvers</param>
virtual void GetPerResourceResolverNames(vint passIndex, collections::List<WString>& names) = 0;
/// <summary>Get names of all per pass resolvers for a pass.</summary>
/// <param name="passIndex">The pass index.</param>
/// <param name="resolvers">Names of resolvers</param>
virtual void GetPerPassResolverNames(vint passIndex, collections::List<WString>& names) = 0;
}; };
extern IGuiResourceResolverManager* GetResourceResolverManager(); extern IGuiResourceResolverManager* GetResourceResolverManager();
@@ -8148,8 +8202,6 @@ Basic Construction
collections::SortedList<GuiComponent*> components; collections::SortedList<GuiComponent*> components;
SubscriptionList subscriptions; SubscriptionList subscriptions;
void ClearSubscriptions();
void ClearComponents();
void FinalizeInstance(); void FinalizeInstance();
public: public:
GuiInstanceRootObject(); GuiInstanceRootObject();
@@ -8167,6 +8219,8 @@ Basic Construction
/// <returns>Returns true if the window contains the subscription.</returns> /// <returns>Returns true if the window contains the subscription.</returns>
/// <param name="subscription">The subscription to test.</param> /// <param name="subscription">The subscription to test.</param>
bool ContainsSubscription(Ptr<description::IValueSubscription> subscription); bool ContainsSubscription(Ptr<description::IValueSubscription> subscription);
/// <summary>Clear all subscriptions.</summary>
void ClearSubscriptions();
/// <summary>Add a component. When this control host is disposing, all attached components will be deleted.</summary> /// <summary>Add a component. When this control host is disposing, all attached components will be deleted.</summary>
/// <returns>Returns true if this operation succeeded.</returns> /// <returns>Returns true if this operation succeeded.</returns>
@@ -8185,10 +8239,12 @@ Basic Construction
/// <returns>Returns true if the window contains the component.</returns> /// <returns>Returns true if the window contains the component.</returns>
/// <param name="component">The component to test.</param> /// <param name="component">The component to test.</param>
bool ContainsComponent(GuiComponent* component); bool ContainsComponent(GuiComponent* component);
/// <summary>Clear all components.</summary>
void ClearComponents();
}; };
/// <summary>Represnets a user customizable control.</summary> /// <summary>Represnets a user customizable control.</summary>
class GuiCustomControl : public GuiControl, public GuiInstanceRootObject, public Description<GuiCustomControl> class GuiCustomControl : public GuiControl, public GuiInstanceRootObject, public AggregatableDescription<GuiCustomControl>
{ {
public: public:
/// <summary>Create a control with a specified style controller.</summary> /// <summary>Create a control with a specified style controller.</summary>
@@ -9278,7 +9334,7 @@ Window
/// <summary> /// <summary>
/// Represents a normal window. /// Represents a normal window.
/// </summary> /// </summary>
class GuiWindow : public GuiControlHost, protected compositions::IGuiAltActionHost, public Description<GuiWindow> class GuiWindow : public GuiControlHost, protected compositions::IGuiAltActionHost, public AggregatableDescription<GuiWindow>
{ {
friend class GuiApplication; friend class GuiApplication;
public: public:
@@ -17772,7 +17828,7 @@ namespace vl
Control Template Control Template
***********************************************************************/ ***********************************************************************/
class GuiControlTemplate : public GuiTemplate, public Description<GuiControlTemplate> class GuiControlTemplate : public GuiTemplate, public AggregatableDescription<GuiControlTemplate>
{ {
public: public:
GuiControlTemplate(); GuiControlTemplate();
@@ -17786,7 +17842,7 @@ Control Template
GuiControlTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiControlTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiLabelTemplate :public GuiControlTemplate, public Description<GuiLabelTemplate> class GuiLabelTemplate :public GuiControlTemplate, public AggregatableDescription<GuiLabelTemplate>
{ {
public: public:
GuiLabelTemplate(); GuiLabelTemplate();
@@ -17799,7 +17855,7 @@ Control Template
GuiLabelTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiLabelTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiSinglelineTextBoxTemplate : public GuiControlTemplate, public Description<GuiSinglelineTextBoxTemplate> class GuiSinglelineTextBoxTemplate : public GuiControlTemplate, public AggregatableDescription<GuiSinglelineTextBoxTemplate>
{ {
public: public:
GuiSinglelineTextBoxTemplate(); GuiSinglelineTextBoxTemplate();
@@ -17812,7 +17868,7 @@ Control Template
GuiSinglelineTextBoxTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiSinglelineTextBoxTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiDocumentLabelTemplate : public GuiControlTemplate, public Description<GuiDocumentLabelTemplate> class GuiDocumentLabelTemplate : public GuiControlTemplate, public AggregatableDescription<GuiDocumentLabelTemplate>
{ {
public: public:
GuiDocumentLabelTemplate(); GuiDocumentLabelTemplate();
@@ -17824,7 +17880,7 @@ Control Template
GuiDocumentLabelTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiDocumentLabelTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiMenuTemplate : public GuiControlTemplate, public Description<GuiMenuTemplate> class GuiMenuTemplate : public GuiControlTemplate, public AggregatableDescription<GuiMenuTemplate>
{ {
public: public:
GuiMenuTemplate(); GuiMenuTemplate();
@@ -17838,7 +17894,7 @@ Control Template
Customizable, Customizable,
}; };
class GuiWindowTemplate : public GuiControlTemplate, public Description<GuiWindowTemplate> class GuiWindowTemplate : public GuiControlTemplate, public AggregatableDescription<GuiWindowTemplate>
{ {
public: public:
GuiWindowTemplate(); GuiWindowTemplate();
@@ -17865,7 +17921,7 @@ Control Template
GuiWindowTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiWindowTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiButtonTemplate : public GuiControlTemplate, public Description<GuiButtonTemplate> class GuiButtonTemplate : public GuiControlTemplate, public AggregatableDescription<GuiButtonTemplate>
{ {
public: public:
GuiButtonTemplate(); GuiButtonTemplate();
@@ -17877,7 +17933,7 @@ Control Template
GuiButtonTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiButtonTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiSelectableButtonTemplate : public GuiButtonTemplate, public Description<GuiSelectableButtonTemplate> class GuiSelectableButtonTemplate : public GuiButtonTemplate, public AggregatableDescription<GuiSelectableButtonTemplate>
{ {
public: public:
GuiSelectableButtonTemplate(); GuiSelectableButtonTemplate();
@@ -17889,7 +17945,7 @@ Control Template
GuiSelectableButtonTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiSelectableButtonTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiToolstripButtonTemplate : public GuiSelectableButtonTemplate, public Description<GuiToolstripButtonTemplate> class GuiToolstripButtonTemplate : public GuiSelectableButtonTemplate, public AggregatableDescription<GuiToolstripButtonTemplate>
{ {
public: public:
GuiToolstripButtonTemplate(); GuiToolstripButtonTemplate();
@@ -17906,7 +17962,7 @@ Control Template
GuiToolstripButtonTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiToolstripButtonTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiListViewColumnHeaderTemplate :public GuiToolstripButtonTemplate, public Description<GuiListViewColumnHeaderTemplate> class GuiListViewColumnHeaderTemplate :public GuiToolstripButtonTemplate, public AggregatableDescription<GuiListViewColumnHeaderTemplate>
{ {
public: public:
GuiListViewColumnHeaderTemplate(); GuiListViewColumnHeaderTemplate();
@@ -17918,7 +17974,7 @@ Control Template
GuiListViewColumnHeaderTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiListViewColumnHeaderTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiComboBoxTemplate : public GuiToolstripButtonTemplate, public Description<GuiComboBoxTemplate> class GuiComboBoxTemplate : public GuiToolstripButtonTemplate, public AggregatableDescription<GuiComboBoxTemplate>
{ {
public: public:
GuiComboBoxTemplate(); GuiComboBoxTemplate();
@@ -17930,7 +17986,7 @@ Control Template
GuiComboBoxTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiComboBoxTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiDatePickerTemplate : public GuiControlTemplate, public Description<GuiDatePickerTemplate> class GuiDatePickerTemplate : public GuiControlTemplate, public AggregatableDescription<GuiDatePickerTemplate>
{ {
public: public:
GuiDatePickerTemplate(); GuiDatePickerTemplate();
@@ -17947,7 +18003,7 @@ Control Template
GuiDatePickerTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiDatePickerTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiDateComboBoxTemplate : public GuiComboBoxTemplate, public Description<GuiDateComboBoxTemplate> class GuiDateComboBoxTemplate : public GuiComboBoxTemplate, public AggregatableDescription<GuiDateComboBoxTemplate>
{ {
public: public:
GuiDateComboBoxTemplate(); GuiDateComboBoxTemplate();
@@ -17959,7 +18015,7 @@ Control Template
GuiDateComboBoxTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiDateComboBoxTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiScrollTemplate : public GuiControlTemplate, public Description<GuiScrollTemplate> class GuiScrollTemplate : public GuiControlTemplate, public AggregatableDescription<GuiScrollTemplate>
{ {
public: public:
GuiScrollTemplate(); GuiScrollTemplate();
@@ -17974,7 +18030,7 @@ Control Template
GuiScrollTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiScrollTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiScrollViewTemplate : public GuiControlTemplate, public Description<GuiScrollViewTemplate> class GuiScrollViewTemplate : public GuiControlTemplate, public AggregatableDescription<GuiScrollViewTemplate>
{ {
public: public:
GuiScrollViewTemplate(); GuiScrollViewTemplate();
@@ -17988,7 +18044,7 @@ Control Template
GuiScrollViewTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiScrollViewTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiMultilineTextBoxTemplate : public GuiScrollViewTemplate, public Description<GuiMultilineTextBoxTemplate> class GuiMultilineTextBoxTemplate : public GuiScrollViewTemplate, public AggregatableDescription<GuiMultilineTextBoxTemplate>
{ {
public: public:
GuiMultilineTextBoxTemplate(); GuiMultilineTextBoxTemplate();
@@ -18001,7 +18057,7 @@ Control Template
GuiMultilineTextBoxTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiMultilineTextBoxTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiDocumentViewerTemplate : public GuiScrollViewTemplate, public Description<GuiDocumentViewerTemplate> class GuiDocumentViewerTemplate : public GuiScrollViewTemplate, public AggregatableDescription<GuiDocumentViewerTemplate>
{ {
public: public:
GuiDocumentViewerTemplate(); GuiDocumentViewerTemplate();
@@ -18013,7 +18069,7 @@ Control Template
GuiDocumentViewerTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiDocumentViewerTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiTextListTemplate : public GuiScrollViewTemplate, public Description<GuiTextListTemplate> class GuiTextListTemplate : public GuiScrollViewTemplate, public AggregatableDescription<GuiTextListTemplate>
{ {
public: public:
GuiTextListTemplate(); GuiTextListTemplate();
@@ -18027,7 +18083,7 @@ Control Template
GuiTextListTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiTextListTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiListViewTemplate : public GuiScrollViewTemplate, public Description<GuiListViewTemplate> class GuiListViewTemplate : public GuiScrollViewTemplate, public AggregatableDescription<GuiListViewTemplate>
{ {
public: public:
GuiListViewTemplate(); GuiListViewTemplate();
@@ -18043,7 +18099,7 @@ Control Template
GuiListViewTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiListViewTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiTreeViewTemplate : public GuiScrollViewTemplate, public Description<GuiTreeViewTemplate> class GuiTreeViewTemplate : public GuiScrollViewTemplate, public AggregatableDescription<GuiTreeViewTemplate>
{ {
public: public:
GuiTreeViewTemplate(); GuiTreeViewTemplate();
@@ -18057,7 +18113,7 @@ Control Template
GuiTreeViewTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiTreeViewTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiTabTemplate : public GuiControlTemplate, public Description<GuiTabTemplate> class GuiTabTemplate : public GuiControlTemplate, public AggregatableDescription<GuiTabTemplate>
{ {
public: public:
GuiTabTemplate(); GuiTabTemplate();
@@ -18078,7 +18134,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();
@@ -18091,7 +18147,7 @@ Item Template
GuiListItemTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiListItemTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiTreeItemTemplate : public GuiListItemTemplate, public Description<GuiTreeItemTemplate> class GuiTreeItemTemplate : public GuiListItemTemplate, public AggregatableDescription<GuiTreeItemTemplate>
{ {
public: public:
GuiTreeItemTemplate(); GuiTreeItemTemplate();
@@ -18103,7 +18159,7 @@ Item Template
GuiTreeItemTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiTreeItemTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiGridVisualizerTemplate : public GuiControlTemplate , public Description<GuiGridVisualizerTemplate> class GuiGridVisualizerTemplate : public GuiControlTemplate , public AggregatableDescription<GuiGridVisualizerTemplate>
{ {
public: public:
GuiGridVisualizerTemplate(); GuiGridVisualizerTemplate();
@@ -18117,7 +18173,7 @@ Item Template
GuiGridVisualizerTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL) GuiGridVisualizerTemplate_PROPERTIES(GUI_TEMPLATE_PROPERTY_DECL)
}; };
class GuiGridEditorTemplate : public GuiControlTemplate , public Description<GuiGridEditorTemplate> class GuiGridEditorTemplate : public GuiControlTemplate , public AggregatableDescription<GuiGridEditorTemplate>
{ {
public: public:
GuiGridEditorTemplate(); GuiGridEditorTemplate();
@@ -18801,6 +18857,51 @@ Helper Functions
#endif #endif
/***********************************************************************
RESOURCES\GUIRESOURCEMANAGER.H
***********************************************************************/
/***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI Reflection: Instance Loader
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_REFLECTION_GUIRESOURCEMANAGER
#define VCZH_PRESENTATION_REFLECTION_GUIRESOURCEMANAGER
namespace vl
{
namespace presentation
{
using namespace reflection;
/***********************************************************************
IGuiResourceManager
***********************************************************************/
class GuiResourceClassNameRecord : public Object, public Description<GuiResourceClassNameRecord>
{
public:
collections::List<WString> classNames;
};
class IGuiResourceManager : public IDescriptable, public Description<IGuiResourceManager>
{
public:
virtual bool SetResource(const WString& name, Ptr<GuiResource> resource, GuiResourceUsage usage = GuiResourceUsage::Application) = 0;
virtual Ptr<GuiResource> GetResource(const WString& name) = 0;
virtual Ptr<GuiResource> GetResourceFromClassName(const WString& classFullName) = 0;
};
extern IGuiResourceManager* GetResourceManager();
}
}
#endif
/*********************************************************************** /***********************************************************************
CONTROLS\TEXTEDITORPACKAGE\LANGUAGESERVICE\GUILANGUAGEOPERATIONS.H CONTROLS\TEXTEDITORPACKAGE\LANGUAGESERVICE\GUILANGUAGEOPERATIONS.H
***********************************************************************/ ***********************************************************************/
+1564 -229
View File
File diff suppressed because it is too large Load Diff
+113 -59
View File
@@ -306,6 +306,7 @@ Instance Namespace
public: public:
GlobalStringKey name; GlobalStringKey name;
WString typeName; WString typeName;
WString value;
bool readonly = false; bool readonly = false;
}; };
@@ -519,17 +520,18 @@ Instance Loader
typedef collections::Group<GlobalStringKey, ArgumentInfo> ArgumentMap; typedef collections::Group<GlobalStringKey, ArgumentInfo> ArgumentMap;
virtual GlobalStringKey GetTypeName() = 0; virtual GlobalStringKey GetTypeName() = 0;
virtual void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames); virtual void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames);
virtual void GetConstructorParameters(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames); virtual void GetConstructorParameters(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames);
virtual void GetPairedProperties(const PropertyInfo& propertyInfo, collections::List<GlobalStringKey>& propertyNames); virtual void GetPairedProperties(const PropertyInfo& propertyInfo, collections::List<GlobalStringKey>& propertyNames);
virtual Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo); virtual Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo);
virtual bool CanCreate(const TypeInfo& typeInfo); virtual bool CanCreate(const TypeInfo& typeInfo);
virtual Ptr<workflow::WfStatement> CreateInstance(const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, collections::List<WString>& errors); virtual Ptr<workflow::WfBaseConstructorCall> CreateRootInstance(const TypeInfo& typeInfo, Ptr<workflow::WfExpression> controlTemplate, collections::List<WString>& errors);
virtual Ptr<workflow::WfStatement> AssignParameters(const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, collections::List<WString>& errors); virtual Ptr<workflow::WfStatement> CreateInstance(const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, collections::List<WString>& errors);
virtual Ptr<workflow::WfExpression> GetParameter(const PropertyInfo& propertyInfo, GlobalStringKey variableName, collections::List<WString>& errors); virtual Ptr<workflow::WfStatement> AssignParameters(const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, collections::List<WString>& errors);
virtual Ptr<workflow::WfExpression> GetParameter(const PropertyInfo& propertyInfo, GlobalStringKey variableName, collections::List<WString>& errors);
}; };
/*********************************************************************** /***********************************************************************
@@ -542,6 +544,7 @@ Instance Binder
virtual GlobalStringKey GetBindingName() = 0; virtual GlobalStringKey GetBindingName() = 0;
virtual bool ApplicableToConstructorArgument() = 0; virtual bool ApplicableToConstructorArgument() = 0;
virtual bool RequirePropertyExist() = 0; virtual bool RequirePropertyExist() = 0;
virtual Ptr<workflow::WfExpression> GenerateConstructorArgument(IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, const WString& code, collections::List<WString>& errors) = 0;
virtual 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) = 0; virtual 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) = 0;
}; };
@@ -572,39 +575,7 @@ Instance Loader Manager
virtual GlobalStringKey GetParentTypeForVirtualType(GlobalStringKey virtualType) = 0; virtual GlobalStringKey GetParentTypeForVirtualType(GlobalStringKey virtualType) = 0;
}; };
struct InstanceLoadingSource
{
IGuiInstanceLoader* loader;
GlobalStringKey typeName;
Ptr<GuiResourceItem> item;
Ptr<GuiInstanceContext> context;
InstanceLoadingSource()
:loader(0)
{
}
InstanceLoadingSource(IGuiInstanceLoader* _loader, GlobalStringKey _typeName)
:loader(_loader)
, typeName(_typeName)
{
}
InstanceLoadingSource(Ptr<GuiResourceItem> _item)
:loader(0)
, item(_item)
, context(item->GetContent().Cast<GuiInstanceContext>())
{
}
operator bool()const
{
return loader != 0 || context;
}
};
extern IGuiInstanceLoaderManager* GetInstanceLoaderManager(); extern IGuiInstanceLoaderManager* GetInstanceLoaderManager();
extern InstanceLoadingSource FindInstanceLoadingSource(Ptr<GuiInstanceContext> context, GuiConstructorRepr* ctor);
} }
} }
@@ -788,8 +759,23 @@ namespace vl
typedef collections::Dictionary<GuiValueRepr*, PropertyResolving> PropertyResolvingMap; typedef collections::Dictionary<GuiValueRepr*, PropertyResolving> PropertyResolvingMap;
typedef collections::List<WString> ErrorList; typedef collections::List<WString> ErrorList;
struct ResolvingResult struct InstanceBaseRecord : public Object, public Description<InstanceBaseRecord>
{ {
typedef GlobalStringKey Key;
typedef IGuiInstanceLoader::TypeInfo Value;
collections::Dictionary<Key, Value> instanceBases;
};
struct ResolvingResult : public Object, public Description<ResolvingResult>
{
Ptr<workflow::WfModule> moduleForValidate;
Ptr<workflow::WfBlockStatement> moduleContent;
collections::List<GlobalStringKey> referenceNames;
IGuiInstanceLoader::ArgumentMap rootCtorArguments;
IGuiInstanceLoader* rootLoader = nullptr;
IGuiInstanceLoader::TypeInfo rootTypeInfo;
VariableTypeInfoMap typeInfos; VariableTypeInfoMap typeInfos;
TypeOverrideMap typeOverrides; TypeOverrideMap typeOverrides;
PropertyResolvingMap propertyResolvings; PropertyResolvingMap propertyResolvings;
@@ -814,20 +800,55 @@ WorkflowCompiler (Installation)
extern Ptr<workflow::WfStatement> Workflow_InstallBindProperty(GlobalStringKey variableName, description::IPropertyInfo* propertyInfo, Ptr<workflow::WfExpression> bindExpression); extern Ptr<workflow::WfStatement> Workflow_InstallBindProperty(GlobalStringKey variableName, description::IPropertyInfo* propertyInfo, Ptr<workflow::WfExpression> bindExpression);
extern Ptr<workflow::WfStatement> Workflow_InstallEvalProperty(GlobalStringKey variableName, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, Ptr<workflow::WfExpression> evalExpression, collections::List<WString>& errors); extern Ptr<workflow::WfStatement> Workflow_InstallEvalProperty(GlobalStringKey variableName, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, Ptr<workflow::WfExpression> evalExpression, collections::List<WString>& errors);
extern Ptr<workflow::WfStatement> Workflow_InstallEvent(GlobalStringKey variableName, description::IEventInfo* eventInfo, const WString& handlerName); extern Ptr<workflow::WfStatement> Workflow_InstallEvent(GlobalStringKey variableName, description::IEventInfo* eventInfo, const WString& handlerName);
extern Ptr<workflow::WfFunctionDeclaration> Workflow_GenerateEventHandler(description::IEventInfo* eventInfo);
extern Ptr<workflow::WfStatement> Workflow_InstallEvalEvent(GlobalStringKey variableName, description::IEventInfo* eventInfo, Ptr<workflow::WfStatement> evalStatement); extern Ptr<workflow::WfStatement> Workflow_InstallEvalEvent(GlobalStringKey variableName, description::IEventInfo* eventInfo, Ptr<workflow::WfStatement> evalStatement);
/*********************************************************************** /***********************************************************************
WorkflowCompiler (Compile) WorkflowCompiler (Compile)
***********************************************************************/ ***********************************************************************/
extern Ptr<workflow::WfModule> Workflow_CreateEmptyModule(Ptr<GuiInstanceContext> context); extern Ptr<workflow::WfModule> Workflow_CreateModuleWithUsings(Ptr<GuiInstanceContext> context);
extern Ptr<workflow::WfModule> Workflow_CreateModuleWithInitFunction(Ptr<GuiInstanceContext> context, types::ResolvingResult& resolvingResult, description::ITypeDescriptor* rootTypeDescriptor, Ptr<workflow::WfStatement> functionBody); extern Ptr<workflow::WfClassDeclaration> Workflow_InstallClass(const WString& className, Ptr<workflow::WfModule> module);
extern Ptr<workflow::WfBlockStatement> Workflow_InstallCtorClass(Ptr<GuiInstanceContext> context, types::ResolvingResult& resolvingResult, description::ITypeDescriptor* rootTypeDescriptor, Ptr<workflow::WfModule> module);
extern void Workflow_CreatePointerVariable(Ptr<workflow::WfModule> module, GlobalStringKey name, description::ITypeDescriptor* type, description::ITypeInfo* typeOverride); extern void Workflow_CreatePointerVariable(Ptr<workflow::WfClassDeclaration> ctorClass, GlobalStringKey name, description::ITypeDescriptor* type, description::ITypeInfo* typeOverride);
extern void Workflow_CreateVariablesForReferenceValues(Ptr<workflow::WfModule> module, types::ResolvingResult& resolvingResult); extern void Workflow_CreateVariablesForReferenceValues(Ptr<workflow::WfClassDeclaration> ctorClass, types::ResolvingResult& resolvingResult);
struct InstanceLoadingSource
{
IGuiInstanceLoader* loader;
GlobalStringKey typeName;
Ptr<GuiResourceItem> item;
Ptr<GuiInstanceContext> context;
InstanceLoadingSource()
:loader(0)
{
}
InstanceLoadingSource(IGuiInstanceLoader* _loader, GlobalStringKey _typeName)
:loader(_loader)
, typeName(_typeName)
{
}
InstanceLoadingSource(Ptr<GuiResourceItem> _item)
:loader(0)
, item(_item)
, context(item->GetContent().Cast<GuiInstanceContext>())
{
}
operator bool()const
{
return loader != 0 || context;
}
};
extern InstanceLoadingSource FindInstanceLoadingSource(Ptr<GuiInstanceContext> context, GuiConstructorRepr* ctor, Ptr<types::InstanceBaseRecord> ibRecord = nullptr);
extern bool Workflow_ValidateStatement(Ptr<GuiInstanceContext> context, types::ResolvingResult& resolvingResult, description::ITypeDescriptor* rootTypeDescriptor, types::ErrorList& errors, const WString& code, Ptr<workflow::WfStatement> statement); extern bool Workflow_ValidateStatement(Ptr<GuiInstanceContext> context, types::ResolvingResult& resolvingResult, description::ITypeDescriptor* rootTypeDescriptor, types::ErrorList& errors, const WString& code, Ptr<workflow::WfStatement> statement);
extern Ptr<workflow::runtime::WfAssembly> Workflow_PrecompileInstanceContext(Ptr<GuiInstanceContext> context, types::ErrorList& errors); extern Ptr<workflow::WfModule> Workflow_PrecompileInstanceContext(Ptr<GuiInstanceContext> context, types::ResolvingResult& resolvingResult, types::ErrorList& errors);
extern Ptr<workflow::WfModule> Workflow_GenerateInstanceClass(Ptr<GuiInstanceContext> context, Ptr<types::InstanceBaseRecord> ibRecord, types::ResolvingResult& resolvingResult, types::ErrorList& errors, bool beforePrecompile);
} }
} }
@@ -1216,19 +1237,11 @@ GuiVrtualTypeInstanceLoader
return typeName == typeInfo.typeName; return typeName == typeInfo.typeName;
} }
Ptr<workflow::WfStatement> CreateInstance(const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, collections::List<WString>& errors)override Ptr<workflow::WfExpression> CreateInstance_ControlTemplate(const TypeInfo& typeInfo, Ptr<workflow::WfExpression> controlTemplate, collections::List<WString>& errors)
{ {
CHECK_ERROR(typeName == typeInfo.typeName, L"GuiTemplateControlInstanceLoader::CreateInstance# Wrong type info is provided."); if (controlTemplate)
vint indexControlTemplate = arguments.Keys().IndexOf(GlobalStringKey::_ControlTemplate);
Ptr<WfExpression> createStyleExpr;
if (indexControlTemplate == -1)
{ {
createStyleExpr = CreateIThemeCall(styleMethod); if (auto controlTemplateTd = GetControlTemplateType(controlTemplate, typeInfo, errors))
}
else
{
if (auto controlTemplateTd = GetControlTemplateType(arguments.GetByIndex(indexControlTemplate)[0].expression, typeInfo, errors))
{ {
auto styleType = TypeInfoRetriver<TControlStyle*>::CreateTypeInfo(); auto styleType = TypeInfoRetriver<TControlStyle*>::CreateTypeInfo();
@@ -1236,13 +1249,54 @@ GuiVrtualTypeInstanceLoader
auto createStyle = MakePtr<WfNewClassExpression>(); auto createStyle = MakePtr<WfNewClassExpression>();
createStyle->type = GetTypeFromTypeInfo(styleType.Obj()); createStyle->type = GetTypeFromTypeInfo(styleType.Obj());
createStyle->arguments.Add(refFactory); createStyle->arguments.Add(refFactory);
createStyleExpr = createStyle;
return createStyle;
} }
else else
{ {
return nullptr; return nullptr;
} }
} }
else
{
return CreateIThemeCall(styleMethod);
}
}
Ptr<workflow::WfBaseConstructorCall> CreateRootInstance(const TypeInfo& typeInfo, Ptr<workflow::WfExpression> controlTemplate, collections::List<WString>& errors)override
{
auto controlType = TypeInfoRetriver<TControl>::CreateTypeInfo();
if (auto createStyleExpr = CreateInstance_ControlTemplate(typeInfo, controlTemplate, errors))
{
auto createControl = MakePtr<WfBaseConstructorCall>();
createControl->type = GetTypeFromTypeInfo(controlType.Obj());
createControl->arguments.Add(createStyleExpr);
return createControl;
}
else
{
return nullptr;
}
}
Ptr<workflow::WfStatement> CreateInstance(const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, collections::List<WString>& errors)override
{
CHECK_ERROR(typeName == typeInfo.typeName, L"GuiTemplateControlInstanceLoader::CreateInstance# Wrong type info is provided.");
vint indexControlTemplate = arguments.Keys().IndexOf(GlobalStringKey::_ControlTemplate);
Ptr<WfExpression> createStyleExpr;
{
Ptr<WfExpression> controlTemplate;
if (indexControlTemplate != -1)
{
controlTemplate = arguments.GetByIndex(indexControlTemplate)[0].expression;
}
if (!(createStyleExpr = CreateInstance_ControlTemplate(typeInfo, controlTemplate, errors)))
{
return nullptr;
}
}
auto block = MakePtr<WfBlockStatement>(); auto block = MakePtr<WfBlockStatement>();
{ {
+44 -135
View File
@@ -64,7 +64,7 @@ Compiled Workflow Type Resolver (Workflow)
vint GetMaxPassIndex()override vint GetMaxPassIndex()override
{ {
return 2; return 3;
} }
void Initialize(Ptr<GuiResourceItem> resource, GuiResourceInitializeContext& context)override void Initialize(Ptr<GuiResourceItem> resource, GuiResourceInitializeContext& context)override
@@ -78,7 +78,7 @@ Compiled Workflow Type Resolver (Workflow)
{ {
if (context.usage == GuiResourceUsage::DevelopmentTool) if (context.usage == GuiResourceUsage::DevelopmentTool)
{ {
compiled->Initialize(false); compiled->Initialize(true);
} }
} }
break; break;
@@ -89,9 +89,19 @@ Compiled Workflow Type Resolver (Workflow)
} }
break; break;
case 2: case 2:
if (compiled->type == GuiInstanceCompiledWorkflow::InstanceCtor && compiled->type != GuiInstanceCompiledWorkflow::InstanceClass) if (compiled->type == GuiInstanceCompiledWorkflow::InstanceCtor)
{ {
compiled->Initialize(false); if (context.usage == GuiResourceUsage::Application)
{
compiled->Initialize(true);
}
}
else if (compiled->type == GuiInstanceCompiledWorkflow::InstanceClass)
{
if (context.usage == GuiResourceUsage::DevelopmentTool)
{
compiled->Initialize(true);
}
} }
break; break;
} }
@@ -115,25 +125,32 @@ Compiled Workflow Type Resolver (Workflow)
internal::ContextFreeWriter writer(stream); internal::ContextFreeWriter writer(stream);
vint type = (vint)obj->type; vint type = (vint)obj->type;
writer << type << obj->classFullName; writer << type;
MemoryStream memoryStream; if (obj->type != GuiInstanceCompiledWorkflow::TemporaryClass)
obj->assembly->Serialize(memoryStream); {
writer << (IStream&)memoryStream; MemoryStream memoryStream;
obj->assembly->Serialize(memoryStream);
writer << (IStream&)memoryStream;
}
} }
} }
Ptr<DescriptableObject> ResolveResourcePrecompiled(stream::IStream& stream, collections::List<WString>& errors)override Ptr<DescriptableObject> ResolveResourcePrecompiled(stream::IStream& stream, collections::List<WString>& errors)override
{ {
internal::ContextFreeReader reader(stream); internal::ContextFreeReader reader(stream);
auto obj = MakePtr<GuiInstanceCompiledWorkflow>();
vint type; vint type;
auto memoryStream = MakePtr<MemoryStream>();; reader << type;
reader << type << obj->classFullName << (IStream&)*memoryStream.Obj();
auto obj = MakePtr<GuiInstanceCompiledWorkflow>();
obj->type = (GuiInstanceCompiledWorkflow::AssemblyType)type; obj->type = (GuiInstanceCompiledWorkflow::AssemblyType)type;
obj->binaryToLoad = memoryStream; if (obj->type != GuiInstanceCompiledWorkflow::TemporaryClass)
{
auto memoryStream = MakePtr<MemoryStream>();
reader << (IStream&)*memoryStream.Obj();
obj->binaryToLoad = memoryStream;
}
return obj; return obj;
} }
}; };
@@ -167,128 +184,6 @@ Plugin
} }
} }
/***********************************************************************
GUIINSTANCEPARTIALCLASS.CPP
***********************************************************************/
namespace vl
{
namespace presentation
{
using namespace collections;
using namespace reflection::description;
using namespace workflow::runtime;
using namespace controls;
/***********************************************************************
Workflow_RunPrecompiledScript
***********************************************************************/
Ptr<workflow::runtime::WfRuntimeGlobalContext> Workflow_RunPrecompiledScript(Ptr<GuiResource> resource, Ptr<GuiResourceItem> resourceItem, description::Value rootInstance)
{
auto compiled = resourceItem->GetContent().Cast<GuiInstanceCompiledWorkflow>();
auto globalContext = MakePtr<WfRuntimeGlobalContext>(compiled->assembly);
LoadFunction<void()>(globalContext, L"<initialize>")();
auto resolver = MakePtr<GuiResourcePathResolver>(resource, resource->GetWorkingDirectory());
LoadFunction<void(Value, Ptr<GuiResourcePathResolver>)>(globalContext, L"<initialize-instance>")(rootInstance, resolver);
return globalContext;
}
/***********************************************************************
IGuiInstanceResourceManager
***********************************************************************/
IGuiInstanceResourceManager* instanceResourceManager = 0;
IGuiInstanceResourceManager* GetInstanceResourceManager()
{
return instanceResourceManager;
}
class GuiInstanceResourceManager : public Object, public IGuiInstanceResourceManager, public IGuiPlugin
{
protected:
typedef Dictionary<WString, Ptr<GuiResource>> ResourceMap;
typedef Pair<Ptr<GuiResource>, Ptr<GuiResourceItem>> ResourceItemPair;
typedef Dictionary<WString, ResourceItemPair> ResourceItemMap;
ResourceMap resources;
ResourceItemMap instanceCtors;
void GetClassesInResource(Ptr<GuiResource> resource, Ptr<GuiResourceFolder> folder)
{
FOREACH(Ptr<GuiResourceItem>, item, folder->GetItems())
{
if (auto compiled = item->GetContent().Cast<GuiInstanceCompiledWorkflow>())
{
if (compiled->type == GuiInstanceCompiledWorkflow::InstanceCtor)
{
if (!instanceCtors.Keys().Contains(compiled->classFullName))
{
instanceCtors.Add(compiled->classFullName, ResourceItemPair(resource, item));
}
}
}
}
FOREACH(Ptr<GuiResourceFolder>, subFolder, folder->GetFolders())
{
GetClassesInResource(resource, subFolder);
}
}
public:
GuiInstanceResourceManager()
{
}
void Load()override
{
instanceResourceManager = this;
}
void AfterLoad()override
{
}
void Unload()override
{
instanceResourceManager = nullptr;
}
bool SetResource(const WString& name, Ptr<GuiResource> resource, GuiResourceUsage usage)override
{
vint index = resources.Keys().IndexOf(name);
if (index != -1) return false;
resource->Initialize(usage);
resources.Add(name, resource);
GetClassesInResource(resource, resource);
return true;
}
Ptr<GuiResource> GetResource(const WString& name)override
{
vint index = resources.Keys().IndexOf(name);
return index == -1 ? nullptr : resources.Values()[index];
}
Ptr<GuiInstanceConstructorResult> RunInstanceConstructor(const WString& classFullName, description::Value instance)override
{
vint index = instanceCtors.Keys().IndexOf(classFullName);
if (index == -1) return nullptr;
auto pair = instanceCtors.Values()[index];
auto context = Workflow_RunPrecompiledScript(pair.key, pair.value, instance);
auto result = MakePtr<GuiInstanceConstructorResult>();
result->context = context;
return result;
}
};
GUI_REGISTER_PLUGIN(GuiInstanceResourceManager)
}
}
/*********************************************************************** /***********************************************************************
TYPEDESCRIPTORS\GUIREFLECTIONBASIC.CPP TYPEDESCRIPTORS\GUIREFLECTIONBASIC.CPP
***********************************************************************/ ***********************************************************************/
@@ -907,6 +802,18 @@ Type Declaration
CLASS_MEMBER_METHOD(ResolveResource, {L"protocol" _ L"path"}) CLASS_MEMBER_METHOD(ResolveResource, {L"protocol" _ L"path"})
END_CLASS_MEMBER(GuiResourcePathResolver) END_CLASS_MEMBER(GuiResourcePathResolver)
BEGIN_ENUM_ITEM(GuiResourceUsage)
ENUM_CLASS_ITEM(DevelopmentTool)
ENUM_CLASS_ITEM(Application)
END_ENUM_ITEM(GuiResourceUsage)
BEGIN_INTERFACE_MEMBER_NOPROXY(IGuiResourceManager)
CLASS_MEMBER_STATIC_EXTERNALMETHOD(GetResourceManager, NO_PARAMETER, IGuiResourceManager*(*)(), &GetResourceManager)
CLASS_MEMBER_METHOD(SetResource, { L"name" _ L"resource" _ L"usage" })
CLASS_MEMBER_METHOD(GetResource, { L"name" })
CLASS_MEMBER_METHOD(GetResourceFromClassName, { L"name" })
END_INTERFACE_MEMBER(IGuiResourceManager)
BEGIN_INTERFACE_MEMBER_NOPROXY(IGuiGraphicsElement) BEGIN_INTERFACE_MEMBER_NOPROXY(IGuiGraphicsElement)
END_INTERFACE_MEMBER(IGuiGraphicsElement) END_INTERFACE_MEMBER(IGuiGraphicsElement)
@@ -1646,11 +1553,13 @@ Type Declaration
CLASS_MEMBER_METHOD(AddSubscription, {L"subscription"}) CLASS_MEMBER_METHOD(AddSubscription, {L"subscription"})
CLASS_MEMBER_METHOD(RemoveSubscription, {L"subscription"}) CLASS_MEMBER_METHOD(RemoveSubscription, {L"subscription"})
CLASS_MEMBER_METHOD(ContainsSubscription, {L"subscription"}) CLASS_MEMBER_METHOD(ContainsSubscription, {L"subscription"})
CLASS_MEMBER_METHOD(ClearSubscriptions, NO_PARAMETER)
CLASS_MEMBER_METHOD(AddComponent, {L"component"}) CLASS_MEMBER_METHOD(AddComponent, {L"component"})
CLASS_MEMBER_METHOD(AddControlHostComponent, {L"controlHost"}) CLASS_MEMBER_METHOD(AddControlHostComponent, {L"controlHost"})
CLASS_MEMBER_METHOD(RemoveComponent, {L"component"}) CLASS_MEMBER_METHOD(RemoveComponent, {L"component"})
CLASS_MEMBER_METHOD(ContainsComponent, {L"component"}) CLASS_MEMBER_METHOD(ContainsComponent, {L"component"})
CLASS_MEMBER_METHOD(ClearComponents, NO_PARAMETER)
END_CLASS_MEMBER(GuiInstanceRootObject) END_CLASS_MEMBER(GuiInstanceRootObject)
BEGIN_CLASS_MEMBER(GuiDialogBase) BEGIN_CLASS_MEMBER(GuiDialogBase)
+31 -42
View File
@@ -92,6 +92,8 @@ Type List
F(presentation::GuiResourceFolder)\ F(presentation::GuiResourceFolder)\
F(presentation::GuiResource)\ F(presentation::GuiResource)\
F(presentation::GuiResourcePathResolver)\ F(presentation::GuiResourcePathResolver)\
F(presentation::GuiResourceUsage)\
F(presentation::IGuiResourceManager)\
F(presentation::elements::IGuiGraphicsElement)\ F(presentation::elements::IGuiGraphicsElement)\
F(presentation::compositions::GuiGraphicsComposition)\ F(presentation::compositions::GuiGraphicsComposition)\
F(presentation::compositions::GuiGraphicsComposition::MinSizeLimitation)\ F(presentation::compositions::GuiGraphicsComposition::MinSizeLimitation)\
@@ -2063,6 +2065,11 @@ Interfaces:
namespace vl namespace vl
{ {
namespace workflow
{
class WfModule;
}
namespace presentation namespace presentation
{ {
class GuiInstanceCompiledWorkflow : public Object, public Description<GuiInstanceCompiledWorkflow> class GuiInstanceCompiledWorkflow : public Object, public Description<GuiInstanceCompiledWorkflow>
@@ -2074,13 +2081,14 @@ namespace vl
Shared, Shared,
InstanceCtor, InstanceCtor,
InstanceClass, InstanceClass,
TemporaryClass,
}; };
collections::List<WString> codes; collections::List<WString> codes;
collections::List<Ptr<workflow::WfModule>> modules;
Ptr<stream::MemoryStream> binaryToLoad; Ptr<stream::MemoryStream> binaryToLoad;
AssemblyType type = AssemblyType::Shared; AssemblyType type = AssemblyType::Shared;
WString classFullName;
Ptr<workflow::runtime::WfAssembly> assembly; Ptr<workflow::runtime::WfAssembly> assembly;
Ptr<workflow::runtime::WfRuntimeGlobalContext> context; Ptr<workflow::runtime::WfRuntimeGlobalContext> context;
@@ -2244,7 +2252,7 @@ Macros
this,\ this,\
L ## #EVENTNAME,\ L ## #EVENTNAME,\
[](DescriptableObject* thisObject, bool addEventHandler){\ [](DescriptableObject* thisObject, bool addEventHandler){\
return &dynamic_cast<ClassType*>(thisObject)->EVENTNAME;\ return &thisObject->SafeAggregationCast<ClassType>()->EVENTNAME;\
}\ }\
)\ )\
);\ );\
@@ -2255,7 +2263,7 @@ Macros
this,\ this,\
L ## #EVENTNAME,\ L ## #EVENTNAME,\
[](DescriptableObject* thisObject, bool addEventHandler){\ [](DescriptableObject* thisObject, bool addEventHandler){\
GuiGraphicsComposition* composition=dynamic_cast<GuiGraphicsComposition*>(thisObject);\ GuiGraphicsComposition* composition=thisObject->SafeAggregationCast<GuiGraphicsComposition>();\
if(!addEventHandler && !composition->HasEventReceiver())\ if(!addEventHandler && !composition->HasEventReceiver())\
{\ {\
return (GuiGraphicsEvent<GuiEventArgumentTypeRetriver<decltype(&GuiGraphicsEventReceiver::EVENTNAME)>::Type>*)0;\ return (GuiGraphicsEvent<GuiEventArgumentTypeRetriver<decltype(&GuiGraphicsEventReceiver::EVENTNAME)>::Type>*)0;\
@@ -2319,26 +2327,6 @@ namespace vl
{ {
using namespace reflection; using namespace reflection;
/***********************************************************************
Resource
***********************************************************************/
class GuiInstanceConstructorResult : public Object
{
public:
Ptr<workflow::runtime::WfRuntimeGlobalContext> context;
};
class IGuiInstanceResourceManager : public IDescriptable, public Description<IGuiInstanceResourceManager>
{
public:
virtual bool SetResource(const WString& name, Ptr<GuiResource> resource, GuiResourceUsage usage = GuiResourceUsage::Application) = 0;
virtual Ptr<GuiResource> GetResource(const WString& name) = 0;
virtual Ptr<GuiInstanceConstructorResult> RunInstanceConstructor(const WString& classFullName, description::Value instance) = 0;
};
extern IGuiInstanceResourceManager* GetInstanceResourceManager();
/*********************************************************************** /***********************************************************************
PartialClass PartialClass
***********************************************************************/ ***********************************************************************/
@@ -2346,20 +2334,33 @@ PartialClass
template<typename T> template<typename T>
class GuiInstancePartialClass class GuiInstancePartialClass
{ {
typedef reflection::description::Value Value;
private: private:
WString className; WString className;
Ptr<workflow::runtime::WfRuntimeGlobalContext> context; Value ctorInstance;
protected: protected:
bool InitializeFromResource() bool InitializeFromResource()
{ {
if (!context) if (ctorInstance.IsNull())
{ {
auto value = description::Value::From(dynamic_cast<T*>(this)); auto rootInstance = Value::From(dynamic_cast<T*>(this));
if (auto result = GetInstanceResourceManager()->RunInstanceConstructor(className, value)) auto resource = GetResourceManager()->GetResourceFromClassName(className);
auto ctorFullName = className + L"<Ctor>";
auto td = description::GetTypeDescriptor(ctorFullName);
if (!td) return false;
auto ctor = td->GetConstructorGroup()->GetMethod(0);
collections::Array<Value> arguments;
ctorInstance = ctor->Invoke(Value(), arguments);
auto initialize = td->GetMethodGroupByName(L"<initialize-instance>", false)->GetMethod(0);
{ {
context = result->context; arguments.Resize(2);
return true; auto resolver = MakePtr<GuiResourcePathResolver>(resource, resource->GetWorkingDirectory());
arguments[0] = rootInstance;
arguments[1] = Value::From(resolver.Obj());
initialize->Invoke(ctorInstance, arguments);
} }
} }
return false; return false;
@@ -2368,19 +2369,7 @@ PartialClass
template<typename TControl> template<typename TControl>
void LoadInstanceReference(const WString& name, TControl*& reference) void LoadInstanceReference(const WString& name, TControl*& reference)
{ {
reference = 0; reference = ctorInstance.GetProperty(name).GetRawPtr()->template SafeAggregationCast<TControl>();
vint index = context->assembly->variableNames.IndexOf(name);
CHECK_ERROR(index != -1, L"GuiInstancePartialClass<T>::LoadInstanceReference<TControl>(const WString&, TControl*&)#Failed to find instance reference.");
auto value = context->globalVariables->variables[index];
auto td = description::GetTypeDescriptor<TControl>();
if (!value.GetTypeDescriptor() || !value.GetTypeDescriptor()->CanConvertTo(td))
{
CHECK_ERROR(index != -1, L"GuiInstancePartialClass<T>::LoadInstanceReference<TControl>(const WString&, TControl*&)#Wrong instance reference type.");
return;
}
reference = description::UnboxValue<TControl*>(value);
} }
public: public:
GuiInstancePartialClass(const WString& _className) GuiInstancePartialClass(const WString& _className)
+58 -6
View File
@@ -13635,7 +13635,7 @@ ParsingMultiplePrintNodeRecorder
} }
/*********************************************************************** /***********************************************************************
ParsingEmptyPrintNodeRecorder ParsingOriginalLocationRecorder
***********************************************************************/ ***********************************************************************/
ParsingOriginalLocationRecorder::ParsingOriginalLocationRecorder(Ptr<IParsingPrintNodeRecorder> _recorder) ParsingOriginalLocationRecorder::ParsingOriginalLocationRecorder(Ptr<IParsingPrintNodeRecorder> _recorder)
@@ -13655,7 +13655,7 @@ ParsingEmptyPrintNodeRecorder
} }
/*********************************************************************** /***********************************************************************
ParsingEmptyPrintNodeRecorder ParsingGeneratedLocationRecorder
***********************************************************************/ ***********************************************************************/
ParsingGeneratedLocationRecorder::ParsingGeneratedLocationRecorder(RangeMap& _rangeMap) ParsingGeneratedLocationRecorder::ParsingGeneratedLocationRecorder(RangeMap& _rangeMap)
@@ -13672,6 +13672,23 @@ ParsingEmptyPrintNodeRecorder
rangeMap.Add(node, range); rangeMap.Add(node, range);
} }
/***********************************************************************
ParsingUpdateLocationRecorder
***********************************************************************/
ParsingUpdateLocationRecorder::ParsingUpdateLocationRecorder()
{
}
ParsingUpdateLocationRecorder::~ParsingUpdateLocationRecorder()
{
}
void ParsingUpdateLocationRecorder::Record(ParsingTreeCustomBase* node, const ParsingTextRange& range)
{
node->codeRange = range;
}
/*********************************************************************** /***********************************************************************
ParsingWriter ParsingWriter
***********************************************************************/ ***********************************************************************/
@@ -15582,6 +15599,7 @@ DescriptableObject
InitializeAggregation(0); InitializeAggregation(0);
} }
aggregationInfo[aggregationSize] = value; aggregationInfo[aggregationSize] = value;
aggregationInfo[aggregationSize + 1] = value;
for (vint i = 0; i < aggregationSize; i++) for (vint i = 0; i < aggregationSize; i++)
{ {
if (aggregationInfo[i]) if (aggregationInfo[i])
@@ -15629,8 +15647,32 @@ DescriptableObject
CHECK_ERROR(!IsAggregated(), L"vl::reflection::DescriptableObject::InitializeAggregation(vint)#This function should not be called on aggregated objects."); CHECK_ERROR(!IsAggregated(), L"vl::reflection::DescriptableObject::InitializeAggregation(vint)#This function should not be called on aggregated objects.");
CHECK_ERROR(size >= 0, L"vl::reflection::DescriptableObject::InitializeAggregation(vint)#Size shout not be negative."); CHECK_ERROR(size >= 0, L"vl::reflection::DescriptableObject::InitializeAggregation(vint)#Size shout not be negative.");
aggregationSize = size; aggregationSize = size;
aggregationInfo = new DescriptableObject*[size + 1]; aggregationInfo = new DescriptableObject*[size + 2];
memset(aggregationInfo, 0, sizeof(*aggregationInfo) * (size + 1)); memset(aggregationInfo, 0, sizeof(*aggregationInfo) * (size + 2));
}
void DescriptableObject::FinalizeAggregation()
{
if (IsAggregated())
{
if (auto root = GetAggregationRoot())
{
if (aggregationInfo[aggregationSize + 1] == nullptr)
{
return;
}
else
{
aggregationInfo[aggregationSize + 1] = nullptr;
}
if (!root->destructing)
{
destructing = true;
delete root;
}
}
}
} }
DescriptableObject::DescriptableObject() DescriptableObject::DescriptableObject()
@@ -15651,9 +15693,9 @@ DescriptableObject
{ {
if (auto root = GetAggregationRoot()) if (auto root = GetAggregationRoot())
{ {
if (!root->destructing) if (aggregationInfo[aggregationSize + 1] != nullptr)
{ {
delete root; CHECK_ERROR(!IsAggregated(), L"vl::reflection::DescriptableObject::~DescriptableObject0()#FinalizeAggregation function should be called.");
} }
} }
for (vint i = 0; i < aggregationSize; i++) for (vint i = 0; i < aggregationSize; i++)
@@ -17434,6 +17476,11 @@ TypeDescriptorImpl
return typeDescriptorFlags; return typeDescriptorFlags;
} }
bool TypeDescriptorImpl::IsAggregatable()
{
return false;
}
const WString& TypeDescriptorImpl::GetTypeName() const WString& TypeDescriptorImpl::GetTypeName()
{ {
return typeName; return typeName;
@@ -17736,6 +17783,11 @@ SerializableTypeDescriptorBase
return typeDescriptorFlags; return typeDescriptorFlags;
} }
bool SerializableTypeDescriptorBase::IsAggregatable()
{
return false;
}
const WString& SerializableTypeDescriptorBase::GetTypeName() const WString& SerializableTypeDescriptorBase::GetTypeName()
{ {
return typeName; return typeName;
+40 -2
View File
@@ -8172,6 +8172,7 @@ Attribute
void SetAggregationParent(vint index, DescriptableObject* value); void SetAggregationParent(vint index, DescriptableObject* value);
void SetAggregationParent(vint index, Ptr<DescriptableObject>& value); void SetAggregationParent(vint index, Ptr<DescriptableObject>& value);
void InitializeAggregation(vint size); void InitializeAggregation(vint size);
void FinalizeAggregation();
template<typename T> template<typename T>
void SafeAggregationCast(T*& result) void SafeAggregationCast(T*& result)
@@ -8233,6 +8234,15 @@ Attribute
/// ... /// ...
/// }; /// };
/// ///
/// If you want YourClass to be inheritable in scripts, instead of using Description, you should use AggregatableDescription, like this:
/// class YourClass : public AggregatableDescription<YourClass>
/// {
/// ~YourClass()
/// {
/// FinalizeAggregation();
/// }
/// };
///
/// After you have complete your type, use the following macros and functions to register your class into the global type table. Everything should be defined in vl::reflection::description namespaces. /// After you have complete your type, use the following macros and functions to register your class into the global type table. Everything should be defined in vl::reflection::description namespaces.
/// Some of the predefined type has already been registered, if your types depend on these types, you should load those types by calling some or all of them: /// Some of the predefined type has already been registered, if your types depend on these types, you should load those types by calling some or all of them:
/// [F:vl.reflection.description.LoadPredefinedTypes] /// [F:vl.reflection.description.LoadPredefinedTypes]
@@ -8486,6 +8496,11 @@ Attribute
} }
}; };
template<typename T>
class AggregatableDescription : public Description<T>
{
};
template<typename T> template<typename T>
description::ITypeDescriptor* Description<T>::associatedTypeDescriptor=0; description::ITypeDescriptor* Description<T>::associatedTypeDescriptor=0;
@@ -8792,6 +8807,8 @@ ITypeDescriptor
{ {
public: public:
virtual TypeDescriptorFlags GetTypeDescriptorFlags() = 0; virtual TypeDescriptorFlags GetTypeDescriptorFlags() = 0;
virtual bool IsAggregatable() = 0;
virtual const WString& GetTypeName() = 0; virtual const WString& GetTypeName() = 0;
virtual const WString& GetCppFullTypeName() = 0; virtual const WString& GetCppFullTypeName() = 0;
virtual IValueSerializer* GetValueSerializer() = 0; virtual IValueSerializer* GetValueSerializer() = 0;
@@ -8988,6 +9005,11 @@ Interface Implementation Proxy (Implement)
template<typename TInterface, typename ...TBaseInterfaces> template<typename TInterface, typename ...TBaseInterfaces>
class ValueInterfaceImpl : public virtual ValueInterfaceRoot, public virtual TInterface, public ValueInterfaceProxy<TBaseInterfaces>... class ValueInterfaceImpl : public virtual ValueInterfaceRoot, public virtual TInterface, public ValueInterfaceProxy<TBaseInterfaces>...
{ {
public:
~ValueInterfaceImpl()
{
FinalizeAggregation();
}
}; };
#pragma warning(pop) #pragma warning(pop)
@@ -9688,6 +9710,15 @@ Logging
void Record(ParsingTreeCustomBase* node, const ParsingTextRange& range)override; void Record(ParsingTreeCustomBase* node, const ParsingTextRange& range)override;
}; };
class ParsingUpdateLocationRecorder : public Object, public virtual IParsingPrintNodeRecorder
{
public:
ParsingUpdateLocationRecorder();
~ParsingUpdateLocationRecorder();
void Record(ParsingTreeCustomBase* node, const ParsingTextRange& range)override;
};
class ParsingWriter : public stream::TextWriter class ParsingWriter : public stream::TextWriter
{ {
typedef collections::Pair<ParsingTreeCustomBase*, ParsingTextPos> NodePosPair; typedef collections::Pair<ParsingTreeCustomBase*, ParsingTextPos> NodePosPair;
@@ -10962,6 +10993,7 @@ SerializableTypeDescriptor
~SerializableTypeDescriptorBase(); ~SerializableTypeDescriptorBase();
TypeDescriptorFlags GetTypeDescriptorFlags()override; TypeDescriptorFlags GetTypeDescriptorFlags()override;
bool IsAggregatable()override;
const WString& GetTypeName()override; const WString& GetTypeName()override;
const WString& GetCppFullTypeName()override; const WString& GetCppFullTypeName()override;
IValueSerializer* GetValueSerializer()override; IValueSerializer* GetValueSerializer()override;
@@ -11505,6 +11537,8 @@ TypeDescriptorImpl
~TypeDescriptorImpl(); ~TypeDescriptorImpl();
TypeDescriptorFlags GetTypeDescriptorFlags()override; TypeDescriptorFlags GetTypeDescriptorFlags()override;
bool IsAggregatable()override;
const WString& GetTypeName()override; const WString& GetTypeName()override;
const WString& GetCppFullTypeName()override; const WString& GetCppFullTypeName()override;
IValueSerializer* GetValueSerializer()override; IValueSerializer* GetValueSerializer()override;
@@ -13875,7 +13909,7 @@ InterfaceProxy
#define BEGIN_INTERFACE_PROXY_NOPARENT_HEADER(INTERFACE)\ #define BEGIN_INTERFACE_PROXY_NOPARENT_HEADER(INTERFACE)\
template<>\ template<>\
class ValueInterfaceProxy<INTERFACE> : ValueInterfaceImpl<INTERFACE>\ class ValueInterfaceProxy<INTERFACE> : public ValueInterfaceImpl<INTERFACE>\
{\ {\
typedef INTERFACE _interface_proxy_InterfaceType;\ typedef INTERFACE _interface_proxy_InterfaceType;\
public:\ public:\
@@ -13890,7 +13924,7 @@ InterfaceProxy
#define BEGIN_INTERFACE_PROXY_HEADER(INTERFACE, ...)\ #define BEGIN_INTERFACE_PROXY_HEADER(INTERFACE, ...)\
template<>\ template<>\
class ValueInterfaceProxy<INTERFACE> : ValueInterfaceImpl<INTERFACE, __VA_ARGS__>\ class ValueInterfaceProxy<INTERFACE> : public ValueInterfaceImpl<INTERFACE, __VA_ARGS__>\
{\ {\
typedef INTERFACE _interface_proxy_InterfaceType;\ typedef INTERFACE _interface_proxy_InterfaceType;\
public:\ public:\
@@ -14038,6 +14072,10 @@ Class
Description<TYPENAME>::SetAssociatedTypeDescroptor(0);\ Description<TYPENAME>::SetAssociatedTypeDescroptor(0);\
}\ }\
protected:\ protected:\
bool IsAggregatable()override\
{\
return AcceptValue<typename RequiresConvertable<TYPENAME, AggregatableDescription<TYPENAME>>::YesNoType>::Result;\
}\
void LoadInternal()override\ void LoadInternal()override\
{ {
+36 -23
View File
@@ -1586,11 +1586,13 @@ Serialization (TypeImpl)
static void IOClass(WfReader& reader, WfClass* td) static void IOClass(WfReader& reader, WfClass* td)
{ {
reader << td->destructorFunctionIndex;
IOCustomType(reader, td, true); IOCustomType(reader, td, true);
} }
static void IOClass(WfWriter& writer, WfClass* td) static void IOClass(WfWriter& writer, WfClass* td)
{ {
writer << td->destructorFunctionIndex;
IOCustomType(writer, td, true); IOCustomType(writer, td, true);
} }
@@ -3405,15 +3407,14 @@ WfRuntimeThreadContext
if (OPERATOR_OpConvertToType(result, converted, ins)) if (OPERATOR_OpConvertToType(result, converted, ins))
{ {
PushValue(converted); PushValue(converted);
return WfRuntimeExecutionAction::ExecuteInstruction;
} }
else else
{ {
WString from = result.IsNull() ? L"<null>" : L"<" + result.GetText() + L"> of " + result.GetTypeDescriptor()->GetTypeName(); WString from = result.IsNull() ? L"<null>" : L"<" + result.GetText() + L"> of " + result.GetTypeDescriptor()->GetTypeName();
WString to = ins.typeDescriptorParameter->GetTypeName(); WString to = ins.typeDescriptorParameter->GetTypeName();
RaiseException(L"Failed to convert from \"" + from + L"\" to \"" + to + L"\".", false); RaiseException(L"Failed to convert from \"" + from + L"\" to \"" + to + L"\".", false);
return WfRuntimeExecutionAction::Nop;
} }
return WfRuntimeExecutionAction::ExecuteInstruction;
} }
case WfInsCode::TryConvertToType: case WfInsCode::TryConvertToType:
{ {
@@ -4459,38 +4460,41 @@ WfInterfaceConstructor
for (vint i = 0; i < baseTypes.Count(); i++) for (vint i = 0; i < baseTypes.Count(); i++)
{ {
auto td = baseTypes[i]; auto td = baseTypes[i];
if (auto group = td->GetConstructorGroup()) if (td != description::GetTypeDescriptor<IDescriptable>())
{ {
vint count = group->GetMethodCount(); if (auto group = td->GetConstructorGroup())
IMethodInfo* selectedCtor = nullptr;
for (vint j = 0; j < count; j++)
{ {
auto ctor = group->GetMethod(j); vint count = group->GetMethodCount();
if (ctor->GetParameterCount() == 1) IMethodInfo* selectedCtor = nullptr;
for (vint j = 0; j < count; j++)
{ {
auto type = ctor->GetParameter(0)->GetType(); auto ctor = group->GetMethod(j);
if (type->GetDecorator() == ITypeInfo::SharedPtr && type->GetTypeDescriptor() == description::GetTypeDescriptor<IValueInterfaceProxy>()) if (ctor->GetParameterCount() == 1)
{ {
selectedCtor = ctor; auto type = ctor->GetParameter(0)->GetType();
break; if (type->GetDecorator() == ITypeInfo::SharedPtr && type->GetTypeDescriptor() == description::GetTypeDescriptor<IValueInterfaceProxy>())
{
selectedCtor = ctor;
break;
}
} }
} }
}
if (selectedCtor) if (selectedCtor)
{ {
baseCtors.Add(selectedCtor); baseCtors.Add(selectedCtor);
}
else
{
throw ArgumentCountMismtatchException(group);
}
} }
else else
{ {
throw ArgumentCountMismtatchException(group); throw ConstructorNotExistsException(td);
} }
} }
else
{
throw ConstructorNotExistsException(td);
}
} }
} }
@@ -4831,12 +4835,21 @@ WfClassInstance
WfClassInstance::WfClassInstance(ITypeDescriptor* _typeDescriptor) WfClassInstance::WfClassInstance(ITypeDescriptor* _typeDescriptor)
:Description<WfClassInstance>(_typeDescriptor) :Description<WfClassInstance>(_typeDescriptor)
{ {
classType = dynamic_cast<WfCustomType*>(_typeDescriptor); classType = dynamic_cast<WfClass*>(_typeDescriptor);
InitializeAggregation(classType->GetExpandedBaseTypes().Count()); InitializeAggregation(classType->GetExpandedBaseTypes().Count());
} }
WfClassInstance::~WfClassInstance() WfClassInstance::~WfClassInstance()
{ {
if (classType->destructorFunctionIndex != -1)
{
auto capturedVariables = MakePtr<WfRuntimeVariableContext>();
capturedVariables->variables.Resize(1);
capturedVariables->variables[0] = Value::From(this);
auto argumentArray = IValueList::Create();
WfRuntimeLambda::Invoke(classType->GetGlobalContext(), capturedVariables, classType->destructorFunctionIndex, argumentArray);
}
} }
void WfClassInstance::InstallBaseObject(ITypeDescriptor* td, Value& value) void WfClassInstance::InstallBaseObject(ITypeDescriptor* td, Value& value)
+3 -1
View File
@@ -561,6 +561,8 @@ Custom Type
{ {
friend class WfTypeImpl; friend class WfTypeImpl;
public: public:
vint destructorFunctionIndex = -1;
WfClass(const WString& typeName); WfClass(const WString& typeName);
~WfClass(); ~WfClass();
}; };
@@ -582,7 +584,7 @@ Instance
typedef reflection::description::ITypeDescriptor ITypeDescriptor; typedef reflection::description::ITypeDescriptor ITypeDescriptor;
typedef reflection::description::Value Value; typedef reflection::description::Value Value;
protected: protected:
WfCustomType* classType = nullptr; WfClass* classType = nullptr;
public: public:
WfClassInstance(ITypeDescriptor* _typeDescriptor); WfClassInstance(ITypeDescriptor* _typeDescriptor);
File diff suppressed because one or more lines are too long
+22
View File
@@ -195,6 +195,7 @@ namespace vl
class WfNewInterfaceExpression; class WfNewInterfaceExpression;
class WfBaseConstructorCall; class WfBaseConstructorCall;
class WfConstructorDeclaration; class WfConstructorDeclaration;
class WfDestructorDeclaration;
class WfClassDeclaration; class WfClassDeclaration;
class WfModuleUsingFragment; class WfModuleUsingFragment;
class WfModuleUsingNameFragment; class WfModuleUsingNameFragment;
@@ -980,6 +981,7 @@ namespace vl
virtual void Visit(WfEventDeclaration* node)=0; virtual void Visit(WfEventDeclaration* node)=0;
virtual void Visit(WfPropertyDeclaration* node)=0; virtual void Visit(WfPropertyDeclaration* node)=0;
virtual void Visit(WfConstructorDeclaration* node)=0; virtual void Visit(WfConstructorDeclaration* node)=0;
virtual void Visit(WfDestructorDeclaration* node)=0;
virtual void Visit(WfClassDeclaration* node)=0; virtual void Visit(WfClassDeclaration* node)=0;
}; };
@@ -1153,6 +1155,16 @@ namespace vl
static vl::Ptr<WfConstructorDeclaration> Convert(vl::Ptr<vl::parsing::ParsingTreeNode> node, const vl::collections::List<vl::regex::RegexToken>& tokens); static vl::Ptr<WfConstructorDeclaration> Convert(vl::Ptr<vl::parsing::ParsingTreeNode> node, const vl::collections::List<vl::regex::RegexToken>& tokens);
}; };
class WfDestructorDeclaration : public WfDeclaration, vl::reflection::Description<WfDestructorDeclaration>
{
public:
vl::Ptr<WfStatement> statement;
void Accept(WfDeclaration::IVisitor* visitor)override;
static vl::Ptr<WfDestructorDeclaration> Convert(vl::Ptr<vl::parsing::ParsingTreeNode> node, const vl::collections::List<vl::regex::RegexToken>& tokens);
};
class WfClassDeclaration : public WfDeclaration, vl::reflection::Description<WfClassDeclaration> class WfClassDeclaration : public WfDeclaration, vl::reflection::Description<WfClassDeclaration>
{ {
public: public:
@@ -1355,6 +1367,7 @@ namespace vl
DECL_TYPE_INFO(vl::workflow::WfConstructorType) DECL_TYPE_INFO(vl::workflow::WfConstructorType)
DECL_TYPE_INFO(vl::workflow::WfBaseConstructorCall) DECL_TYPE_INFO(vl::workflow::WfBaseConstructorCall)
DECL_TYPE_INFO(vl::workflow::WfConstructorDeclaration) DECL_TYPE_INFO(vl::workflow::WfConstructorDeclaration)
DECL_TYPE_INFO(vl::workflow::WfDestructorDeclaration)
DECL_TYPE_INFO(vl::workflow::WfClassDeclaration) DECL_TYPE_INFO(vl::workflow::WfClassDeclaration)
DECL_TYPE_INFO(vl::workflow::WfModuleUsingFragment) DECL_TYPE_INFO(vl::workflow::WfModuleUsingFragment)
DECL_TYPE_INFO(vl::workflow::WfModuleUsingNameFragment) DECL_TYPE_INFO(vl::workflow::WfModuleUsingNameFragment)
@@ -1684,6 +1697,11 @@ namespace vl
INVOKE_INTERFACE_PROXY(Visit, node); INVOKE_INTERFACE_PROXY(Visit, node);
} }
void Visit(vl::workflow::WfDestructorDeclaration* node)override
{
INVOKE_INTERFACE_PROXY(Visit, node);
}
void Visit(vl::workflow::WfClassDeclaration* node)override void Visit(vl::workflow::WfClassDeclaration* node)override
{ {
INVOKE_INTERFACE_PROXY(Visit, node); INVOKE_INTERFACE_PROXY(Visit, node);
@@ -2202,6 +2220,7 @@ Code Generation
{ {
typedef collections::Dictionary<WfLexicalSymbol*, vint> SymbolIndexMap; typedef collections::Dictionary<WfLexicalSymbol*, vint> SymbolIndexMap;
typedef collections::Dictionary<WfConstructorDeclaration*, vint> ConstructorIndexMap; typedef collections::Dictionary<WfConstructorDeclaration*, vint> ConstructorIndexMap;
typedef collections::Dictionary<WfDestructorDeclaration*, vint> DestructorIndexMap;
typedef collections::Dictionary<parsing::ParsingTreeCustomBase*, parsing::ParsingTextRange> NodePositionMap; typedef collections::Dictionary<parsing::ParsingTreeCustomBase*, parsing::ParsingTextRange> NodePositionMap;
typedef collections::Dictionary<Ptr<WfLexicalFunctionConfig>, vint> ThisStackCountMap; typedef collections::Dictionary<Ptr<WfLexicalFunctionConfig>, vint> ThisStackCountMap;
public: public:
@@ -2210,6 +2229,7 @@ Code Generation
SymbolIndexMap globalVariables; SymbolIndexMap globalVariables;
SymbolIndexMap globalFunctions; SymbolIndexMap globalFunctions;
ConstructorIndexMap constructors; ConstructorIndexMap constructors;
DestructorIndexMap destructors;
SymbolIndexMap closureFunctions; SymbolIndexMap closureFunctions;
Ptr<WfCodegenFunctionContext> functionContext; Ptr<WfCodegenFunctionContext> functionContext;
NodePositionMap nodePositionsBeforeCodegen; NodePositionMap nodePositionsBeforeCodegen;
@@ -2344,6 +2364,7 @@ Error Messages
static Ptr<parsing::ParsingError> WrongDeclaration(WfEventDeclaration* node); static Ptr<parsing::ParsingError> WrongDeclaration(WfEventDeclaration* node);
static Ptr<parsing::ParsingError> WrongDeclaration(WfPropertyDeclaration* node); static Ptr<parsing::ParsingError> WrongDeclaration(WfPropertyDeclaration* node);
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> WrongDeclarationInInterfaceConstructor(WfDeclaration* node); static Ptr<parsing::ParsingError> WrongDeclarationInInterfaceConstructor(WfDeclaration* node);
// E: Module error // E: Module error
@@ -2379,6 +2400,7 @@ Error Messages
static Ptr<parsing::ParsingError> DuplicatedBaseInterface(WfClassDeclaration* node, reflection::description::ITypeDescriptor* type); static Ptr<parsing::ParsingError> DuplicatedBaseInterface(WfClassDeclaration* node, reflection::description::ITypeDescriptor* type);
static Ptr<parsing::ParsingError> WrongBaseConstructorCall(WfBaseConstructorCall* node, reflection::description::ITypeDescriptor* type); static Ptr<parsing::ParsingError> WrongBaseConstructorCall(WfBaseConstructorCall* node, reflection::description::ITypeDescriptor* type);
static Ptr<parsing::ParsingError> DuplicatedBaseConstructorCall(WfBaseConstructorCall* node, reflection::description::ITypeDescriptor* type); static Ptr<parsing::ParsingError> DuplicatedBaseConstructorCall(WfBaseConstructorCall* node, reflection::description::ITypeDescriptor* type);
static Ptr<parsing::ParsingError> TooManyDestructor(WfDestructorDeclaration* node, WfClassDeclaration* classDecl);
}; };
} }
} }
BIN
View File
Binary file not shown.
Binary file not shown.
@@ -17,7 +17,7 @@ void GuiMain()
List<WString> errors; List<WString> errors;
FileStream fileStream(L"../UIRes/BlackSkin.bin", FileStream::ReadOnly); FileStream fileStream(L"../UIRes/BlackSkin.bin", FileStream::ReadOnly);
auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors); auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors);
GetInstanceResourceManager()->SetResource(L"Resource", resource); GetResourceManager()->SetResource(L"Resource", resource);
} }
demo::MainWindow window; demo::MainWindow window;
window.MoveToScreenCenter(); window.MoveToScreenCenter();
@@ -15,7 +15,7 @@ void GuiMain()
List<WString> errors; List<WString> errors;
FileStream fileStream(L"../UIRes/ContainersAndButtons.bin", FileStream::ReadOnly); FileStream fileStream(L"../UIRes/ContainersAndButtons.bin", FileStream::ReadOnly);
auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors); auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors);
GetInstanceResourceManager()->SetResource(L"Resource", resource); GetResourceManager()->SetResource(L"Resource", resource);
} }
demo::MainWindow window; demo::MainWindow window;
window.MoveToScreenCenter(); window.MoveToScreenCenter();
+1 -1
View File
@@ -17,7 +17,7 @@ void GuiMain()
List<WString> errors; List<WString> errors;
FileStream fileStream(L"../UIRes/TextEditor.bin", FileStream::ReadOnly); FileStream fileStream(L"../UIRes/TextEditor.bin", FileStream::ReadOnly);
auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors); auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors);
GetInstanceResourceManager()->SetResource(L"Resource", resource); GetResourceManager()->SetResource(L"Resource", resource);
} }
demo::MainWindow window; demo::MainWindow window;
window.MoveToScreenCenter(); window.MoveToScreenCenter();
Binary file not shown.
+1 -1
View File
@@ -15,7 +15,7 @@ void GuiMain()
List<WString> errors; List<WString> errors;
FileStream fileStream(L"../UIRes/CppXml.bin", FileStream::ReadOnly); FileStream fileStream(L"../UIRes/CppXml.bin", FileStream::ReadOnly);
auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors); auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors);
GetInstanceResourceManager()->SetResource(L"Resource", resource); GetResourceManager()->SetResource(L"Resource", resource);
} }
helloworld::MainWindow window; helloworld::MainWindow window;
window.MoveToScreenCenter(); window.MoveToScreenCenter();
+1 -1
View File
@@ -80,7 +80,7 @@ void GuiMain()
List<WString> errors; List<WString> errors;
FileStream fileStream(L"../UIRes/MVVM.bin", FileStream::ReadOnly); FileStream fileStream(L"../UIRes/MVVM.bin", FileStream::ReadOnly);
auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors); auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors);
GetInstanceResourceManager()->SetResource(L"Resource", resource); GetResourceManager()->SetResource(L"Resource", resource);
} }
auto viewModel = MakePtr<ViewModel>(); auto viewModel = MakePtr<ViewModel>();
auto window = new helloworld::MainWindow(viewModel); auto window = new helloworld::MainWindow(viewModel);
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -15,7 +15,7 @@ void GuiMain()
List<WString> errors; List<WString> errors;
FileStream fileStream(L"../UIRes/Alignment.bin", FileStream::ReadOnly); FileStream fileStream(L"../UIRes/Alignment.bin", FileStream::ReadOnly);
auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors); auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors);
GetInstanceResourceManager()->SetResource(L"Resource", resource); GetResourceManager()->SetResource(L"Resource", resource);
} }
demo::MainWindow window; demo::MainWindow window;
window.MoveToScreenCenter(); window.MoveToScreenCenter();
+1 -1
View File
@@ -15,7 +15,7 @@ void GuiMain()
List<WString> errors; List<WString> errors;
FileStream fileStream(L"../UIRes/Flow.bin", FileStream::ReadOnly); FileStream fileStream(L"../UIRes/Flow.bin", FileStream::ReadOnly);
auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors); auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors);
GetInstanceResourceManager()->SetResource(L"Resource", resource); GetResourceManager()->SetResource(L"Resource", resource);
} }
demo::MainWindow window; demo::MainWindow window;
window.MoveToScreenCenter(); window.MoveToScreenCenter();
@@ -24,7 +24,7 @@ void GuiMain()
List<WString> errors; List<WString> errors;
FileStream fileStream(L"../UIRes/RichTextEmbedding.bin", FileStream::ReadOnly); FileStream fileStream(L"../UIRes/RichTextEmbedding.bin", FileStream::ReadOnly);
auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors); auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors);
GetInstanceResourceManager()->SetResource(L"Resource", resource); GetResourceManager()->SetResource(L"Resource", resource);
} }
demo::MainWindow window(new ViewModel); demo::MainWindow window(new ViewModel);
window.MoveToScreenCenter(); window.MoveToScreenCenter();
+1 -1
View File
@@ -15,7 +15,7 @@ void GuiMain()
List<WString> errors; List<WString> errors;
FileStream fileStream(L"../UIRes/Stack.bin", FileStream::ReadOnly); FileStream fileStream(L"../UIRes/Stack.bin", FileStream::ReadOnly);
auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors); auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors);
GetInstanceResourceManager()->SetResource(L"Resource", resource); GetResourceManager()->SetResource(L"Resource", resource);
} }
demo::MainWindow window; demo::MainWindow window;
window.MoveToScreenCenter(); window.MoveToScreenCenter();
+1 -1
View File
@@ -15,7 +15,7 @@ void GuiMain()
List<WString> errors; List<WString> errors;
FileStream fileStream(L"../UIRes/Table.bin", FileStream::ReadOnly); FileStream fileStream(L"../UIRes/Table.bin", FileStream::ReadOnly);
auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors); auto resource = GuiResource::LoadPrecompiledBinary(fileStream, errors);
GetInstanceResourceManager()->SetResource(L"Resource", resource); GetResourceManager()->SetResource(L"Resource", resource);
} }
demo::MainWindow window; demo::MainWindow window;
window.MoveToScreenCenter(); window.MoveToScreenCenter();
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.