mirror of
https://github.com/vczh-libraries/Release.git
synced 2026-02-07 04:21:39 +08:00
10236 lines
358 KiB
C++
10236 lines
358 KiB
C++
/***********************************************************************
|
|
THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MODIFY
|
|
DEVELOPER: Zihan Chen(vczh)
|
|
***********************************************************************/
|
|
#include "GacUICompiler.h"
|
|
|
|
/***********************************************************************
|
|
GUIINSTANCEHELPERTYPES.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
namespace helper_types
|
|
{
|
|
}
|
|
}
|
|
|
|
#ifndef VCZH_DEBUG_NO_REFLECTION
|
|
|
|
namespace reflection
|
|
{
|
|
namespace description
|
|
{
|
|
using namespace presentation::helper_types;
|
|
|
|
/***********************************************************************
|
|
Type Declaration
|
|
***********************************************************************/
|
|
|
|
GUIREFLECTIONHELPERTYPES_TYPELIST(IMPL_VL_TYPE_INFO)
|
|
|
|
#define _ ,
|
|
|
|
BEGIN_STRUCT_MEMBER(SiteValue)
|
|
STRUCT_MEMBER(row)
|
|
STRUCT_MEMBER(column)
|
|
STRUCT_MEMBER(rowSpan)
|
|
STRUCT_MEMBER(columnSpan)
|
|
END_STRUCT_MEMBER(SiteValue)
|
|
|
|
BEGIN_ENUM_ITEM(ListViewViewType)
|
|
ENUM_ITEM_NAMESPACE(ListViewViewType)
|
|
ENUM_NAMESPACE_ITEM(BigIcon)
|
|
ENUM_NAMESPACE_ITEM(SmallIcon)
|
|
ENUM_NAMESPACE_ITEM(List)
|
|
ENUM_NAMESPACE_ITEM(Tile)
|
|
ENUM_NAMESPACE_ITEM(Information)
|
|
ENUM_NAMESPACE_ITEM(Detail)
|
|
END_ENUM_ITEM(ListViewViewType)
|
|
|
|
#undef _
|
|
}
|
|
}
|
|
|
|
namespace presentation
|
|
{
|
|
using namespace reflection::description;
|
|
using namespace controls;
|
|
|
|
/***********************************************************************
|
|
Type Loader
|
|
***********************************************************************/
|
|
|
|
class GuiHelperTypesLoader : public Object, public ITypeLoader
|
|
{
|
|
public:
|
|
void Load(ITypeManager* manager)
|
|
{
|
|
GUIREFLECTIONHELPERTYPES_TYPELIST(ADD_TYPE_INFO)
|
|
}
|
|
|
|
void Unload(ITypeManager* manager)
|
|
{
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiHelperTypesLoaderPlugin
|
|
***********************************************************************/
|
|
|
|
class GuiHelperTypesLoaderPlugin : public Object, public IGuiPlugin
|
|
{
|
|
public:
|
|
void Load()override
|
|
{
|
|
ITypeManager* manager=GetGlobalTypeManager();
|
|
if(manager)
|
|
{
|
|
Ptr<ITypeLoader> loader=new GuiHelperTypesLoader;
|
|
manager->AddTypeLoader(loader);
|
|
}
|
|
}
|
|
|
|
void AfterLoad()override
|
|
{
|
|
}
|
|
|
|
void Unload()override
|
|
{
|
|
}
|
|
};
|
|
GUI_REGISTER_PLUGIN(GuiHelperTypesLoaderPlugin)
|
|
}
|
|
#endif
|
|
}
|
|
|
|
/***********************************************************************
|
|
GUIINSTANCELOADER.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
using namespace collections;
|
|
using namespace parsing;
|
|
using namespace parsing::xml;
|
|
using namespace parsing::tabling;
|
|
using namespace controls;
|
|
using namespace regex;
|
|
using namespace reflection::description;
|
|
using namespace stream;
|
|
using namespace workflow;
|
|
using namespace workflow::analyzer;
|
|
using namespace workflow::typeimpl;
|
|
|
|
/***********************************************************************
|
|
GuiInstancePropertyInfo
|
|
***********************************************************************/
|
|
|
|
Ptr<GuiInstancePropertyInfo> GuiInstancePropertyInfo::Unsupported()
|
|
{
|
|
return new GuiInstancePropertyInfo;
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GuiInstancePropertyInfo::Assign(Ptr<description::ITypeInfo> typeInfo)
|
|
{
|
|
auto info = MakePtr<GuiInstancePropertyInfo>();
|
|
info->support = SupportAssign;
|
|
if (typeInfo) info->acceptableTypes.Add(typeInfo);
|
|
return info;
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GuiInstancePropertyInfo::AssignWithParent(Ptr<description::ITypeInfo> typeInfo)
|
|
{
|
|
auto info = Assign(typeInfo);
|
|
info->mergability = MergeWithParent;
|
|
return info;
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GuiInstancePropertyInfo::Collection(Ptr<description::ITypeInfo> typeInfo)
|
|
{
|
|
auto info = Assign(typeInfo);
|
|
info->support = SupportCollection;
|
|
return info;
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GuiInstancePropertyInfo::CollectionWithParent(Ptr<description::ITypeInfo> typeInfo)
|
|
{
|
|
auto info = Collection(typeInfo);
|
|
info->mergability = MergeWithParent;
|
|
return info;
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GuiInstancePropertyInfo::Set(Ptr<description::ITypeInfo> typeInfo)
|
|
{
|
|
auto info = MakePtr<GuiInstancePropertyInfo>();
|
|
info->support = SupportSet;
|
|
if (typeInfo) info->acceptableTypes.Add(typeInfo);
|
|
return info;
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GuiInstancePropertyInfo::Array(Ptr<description::ITypeInfo> typeInfo)
|
|
{
|
|
auto info = MakePtr<GuiInstancePropertyInfo>();
|
|
info->support = SupportArray;
|
|
if (typeInfo) info->acceptableTypes.Add(typeInfo);
|
|
return info;
|
|
}
|
|
|
|
/***********************************************************************
|
|
IGuiInstanceLoader
|
|
***********************************************************************/
|
|
|
|
void IGuiInstanceLoader::ClearReflectionCache()
|
|
{
|
|
}
|
|
|
|
void IGuiInstanceLoader::GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)
|
|
{
|
|
}
|
|
|
|
void IGuiInstanceLoader::GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)
|
|
{
|
|
}
|
|
|
|
void IGuiInstanceLoader::GetPairedProperties(const PropertyInfo& propertyInfo, collections::List<GlobalStringKey>& propertyNames)
|
|
{
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> IGuiInstanceLoader::GetPropertyType(const PropertyInfo& propertyInfo)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
bool IGuiInstanceLoader::CanCreate(const TypeInfo& typeInfo)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
Ptr<workflow::WfBaseConstructorCall> IGuiInstanceLoader::CreateRootInstance(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, ArgumentMap& arguments, GuiResourceError::List& errors)
|
|
{
|
|
CHECK_FAIL(L"IGuiInstanceLoader::CreateControlTemplateArgument(types::ResolvingResult&, const TypeInfo&, Ptr<workflow::WfExpression>, collections::List<WString>&)#This function is not implemented.");
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> IGuiInstanceLoader::InitializeRootInstance(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceError::List& errors)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> IGuiInstanceLoader::CreateInstance(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos tagPosition, GuiResourceError::List& errors)
|
|
{
|
|
CHECK_FAIL(L"IGuiInstanceLoader::CreateInstance(types::ResolvingResult&, const TypeInfo&, GlobalStringKey, ArgumentMap&, collections::List<WString>&)#This function is not implemented.");
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> IGuiInstanceLoader::AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)
|
|
{
|
|
CHECK_FAIL(L"IGuiInstanceLoader::AssignParameters(types::ResolvingResult&, const TypeInfo&, GlobalStringKey, ArgumentMap&, collections::List<WString>&)#This function is not implemented.");
|
|
}
|
|
|
|
Ptr<workflow::WfExpression> IGuiInstanceLoader::GetParameter(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const PropertyInfo& propertyInfo, GlobalStringKey variableName, GuiResourceTextPos attPosition, GuiResourceError::List& errors)
|
|
{
|
|
CHECK_FAIL(L"IGuiInstanceLoader::GetParameter(types::ResolvingResult&, const PropertyInfo&, GlobalStringKey, collections::List<WString>&)#This function is not implemented.");
|
|
}
|
|
|
|
/***********************************************************************
|
|
GuiInstanceContext::ElementName Parser
|
|
***********************************************************************/
|
|
|
|
class GuiInstanceContextElementNameParser : public Object, public IGuiParser<GuiInstanceContext::ElementName>
|
|
{
|
|
typedef GuiInstanceContext::ElementName ElementName;
|
|
public:
|
|
Regex regexElementName;
|
|
|
|
GuiInstanceContextElementNameParser()
|
|
:regexElementName(L"((<namespaceName>[a-zA-Z_]/w*):)?((<category>[a-zA-Z_]/w*).)?(<name>[a-zA-Z_]/w*)(-(<binding>[a-zA-Z_]/w*))?")
|
|
{
|
|
}
|
|
|
|
Ptr<ElementName> ParseInternal(const WString& text, collections::List<Ptr<parsing::ParsingError>>& errors)override
|
|
{
|
|
Ptr<RegexMatch> match = regexElementName.MatchHead(text);
|
|
if (!match || match->Result().Length() != text.Length())
|
|
{
|
|
errors.Add(MakePtr<ParsingError>(L"Failed to parse an element name \"" + text + L"\"."));
|
|
return nullptr;
|
|
}
|
|
|
|
Ptr<ElementName> elementName = new ElementName;
|
|
if (match->Groups().Keys().Contains(L"namespaceName"))
|
|
{
|
|
elementName->namespaceName = match->Groups()[L"namespaceName"][0].Value();
|
|
}
|
|
if (match->Groups().Keys().Contains(L"category"))
|
|
{
|
|
elementName->category = match->Groups()[L"category"][0].Value();
|
|
}
|
|
if (match->Groups().Keys().Contains(L"name"))
|
|
{
|
|
elementName->name = match->Groups()[L"name"][0].Value();
|
|
}
|
|
if (match->Groups().Keys().Contains(L"binding"))
|
|
{
|
|
elementName->binding = match->Groups()[L"binding"][0].Value();
|
|
}
|
|
return elementName;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiDefaultInstanceLoader
|
|
***********************************************************************/
|
|
|
|
#define CTOR_PARAM_PREFIX\
|
|
static const wchar_t Prefix[] = L"<ctor-parameter>";\
|
|
static const vint PrefixLength = (vint)sizeof(Prefix) / sizeof(*Prefix) - 1;\
|
|
|
|
#define CTOR_PARAM_NAME(NAME) (NAME).Right((NAME).Length() - PrefixLength)
|
|
|
|
class GuiDefaultInstanceLoader : public Object, public IGuiInstanceLoader
|
|
{
|
|
protected:
|
|
typedef Tuple<ITypeDescriptor*, GlobalStringKey> FieldKey;
|
|
typedef Tuple<Ptr<GuiInstancePropertyInfo>, IPropertyInfo*> PropertyType;
|
|
|
|
Dictionary<FieldKey, PropertyType> propertyTypes;
|
|
Dictionary<ITypeDescriptor*, IMethodInfo*> defaultConstructors;
|
|
Dictionary<ITypeDescriptor*, IMethodInfo*> instanceConstructors;
|
|
public:
|
|
IMethodInfo* GetDefaultConstructor(ITypeDescriptor* typeDescriptor)
|
|
{
|
|
IMethodInfo* ctor = nullptr;
|
|
vint index = defaultConstructors.Keys().IndexOf(typeDescriptor);
|
|
if (index == -1)
|
|
{
|
|
if (auto ctors = typeDescriptor->GetConstructorGroup())
|
|
{
|
|
vint count = ctors->GetMethodCount();
|
|
for (vint i = 0; i < count; i++)
|
|
{
|
|
IMethodInfo* method = ctors->GetMethod(i);
|
|
if (method->GetParameterCount() == 0)
|
|
{
|
|
ctor = method;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
defaultConstructors.Add(typeDescriptor, ctor);
|
|
}
|
|
else
|
|
{
|
|
ctor = defaultConstructors.Values()[index];
|
|
}
|
|
return ctor;
|
|
}
|
|
|
|
IMethodInfo* GetInstanceConstructor(ITypeDescriptor* typeDescriptor)
|
|
{
|
|
CTOR_PARAM_PREFIX
|
|
|
|
IMethodInfo* ctor = nullptr;
|
|
vint index = instanceConstructors.Keys().IndexOf(typeDescriptor);
|
|
if (index == -1)
|
|
{
|
|
if (dynamic_cast<WfClass*>(typeDescriptor))
|
|
{
|
|
if (auto group = typeDescriptor->GetConstructorGroup())
|
|
{
|
|
if (group->GetMethodCount() == 1)
|
|
{
|
|
auto method = group->GetMethod(0);
|
|
vint count = method->GetParameterCount();
|
|
for (vint i = 0; i < count; i++)
|
|
{
|
|
const auto& name = method->GetParameter(i)->GetName();
|
|
if (name.Length() <= PrefixLength || name.Left(PrefixLength) != Prefix)
|
|
{
|
|
goto FINISHED;
|
|
}
|
|
|
|
if (!typeDescriptor->GetPropertyByName(CTOR_PARAM_NAME(name), false))
|
|
{
|
|
goto FINISHED;
|
|
}
|
|
}
|
|
ctor = method;
|
|
}
|
|
}
|
|
}
|
|
FINISHED:
|
|
instanceConstructors.Add(typeDescriptor, ctor);
|
|
}
|
|
else
|
|
{
|
|
ctor = instanceConstructors.Values()[index];
|
|
}
|
|
return ctor;
|
|
}
|
|
|
|
GlobalStringKey GetTypeName()override
|
|
{
|
|
return GlobalStringKey::Empty;
|
|
}
|
|
|
|
void ClearReflectionCache()override
|
|
{
|
|
propertyTypes.Clear();
|
|
defaultConstructors.Clear();
|
|
instanceConstructors.Clear();
|
|
}
|
|
|
|
//***********************************************************************************
|
|
|
|
ITypeInfo* ProcessGenericType(ITypeInfo* propType, bool& readableList, bool& writableList, bool& collectionType)
|
|
{
|
|
readableList = false;
|
|
writableList = false;
|
|
collectionType = false;
|
|
if (propType->GetDecorator() == ITypeInfo::SharedPtr && propType->GetElementType()->GetDecorator() == ITypeInfo::Generic)
|
|
{
|
|
auto genericType = propType->GetElementType();
|
|
if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor<IValueList>())
|
|
{
|
|
readableList = true;
|
|
writableList = true;
|
|
collectionType = true;
|
|
return genericType->GetGenericArgument(0);
|
|
}
|
|
else if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor<IValueEnumerator>())
|
|
{
|
|
collectionType = true;
|
|
return genericType->GetGenericArgument(0);
|
|
}
|
|
else if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor<IValueEnumerable>())
|
|
{
|
|
readableList = true;
|
|
collectionType = true;
|
|
return genericType->GetGenericArgument(0);
|
|
}
|
|
else if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor<IValueReadonlyList>())
|
|
{
|
|
readableList = true;
|
|
collectionType = true;
|
|
return genericType->GetGenericArgument(0);
|
|
}
|
|
else if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor<IValueReadonlyDictionary>())
|
|
{
|
|
collectionType = true;
|
|
return nullptr;
|
|
}
|
|
else if (genericType->GetTypeDescriptor() == description::GetTypeDescriptor<IValueDictionary>())
|
|
{
|
|
collectionType = true;
|
|
return nullptr;
|
|
}
|
|
}
|
|
return propType;
|
|
}
|
|
|
|
ITypeInfo* GetPropertyReflectionTypeInfo(const PropertyInfo& propertyInfo, GuiInstancePropertyInfo::Support& support)
|
|
{
|
|
support = GuiInstancePropertyInfo::NotSupport;
|
|
IPropertyInfo* prop = propertyInfo.typeInfo.typeInfo->GetTypeDescriptor()->GetPropertyByName(propertyInfo.propertyName.ToString(), true);
|
|
if (prop)
|
|
{
|
|
ITypeInfo* propType = prop->GetReturn();
|
|
bool readableList = false;
|
|
bool writableList = false;
|
|
bool collectionType = false;
|
|
auto propValueType = ProcessGenericType(propType, readableList, writableList, collectionType);
|
|
|
|
if (prop->IsWritable())
|
|
{
|
|
if (collectionType)
|
|
{
|
|
if (readableList)
|
|
{
|
|
support = GuiInstancePropertyInfo::SupportArray;
|
|
return propValueType;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
support = GuiInstancePropertyInfo::SupportAssign;
|
|
return propValueType;
|
|
}
|
|
}
|
|
else if (prop->IsReadable())
|
|
{
|
|
if (collectionType)
|
|
{
|
|
if (writableList)
|
|
{
|
|
support = GuiInstancePropertyInfo::SupportCollection;
|
|
return propValueType;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (propType->GetDecorator() == ITypeInfo::SharedPtr || propType->GetDecorator() == ITypeInfo::RawPtr)
|
|
{
|
|
if (propType->GetElementType()->GetDecorator() != ITypeInfo::Generic)
|
|
{
|
|
support = GuiInstancePropertyInfo::SupportSet;
|
|
return propValueType;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
void CollectPropertyNames(const TypeInfo& typeInfo, ITypeDescriptor* typeDescriptor, collections::List<GlobalStringKey>& propertyNames)
|
|
{
|
|
vint propertyCount = typeDescriptor->GetPropertyCount();
|
|
for (vint i = 0; i < propertyCount; i++)
|
|
{
|
|
GlobalStringKey propertyName = GlobalStringKey::Get(typeDescriptor->GetProperty(i)->GetName());
|
|
if (!propertyNames.Contains(propertyName))
|
|
{
|
|
auto info = GetPropertyType(PropertyInfo(typeInfo, propertyName));
|
|
if (info && info->support != GuiInstancePropertyInfo::NotSupport)
|
|
{
|
|
propertyNames.Add(propertyName);
|
|
}
|
|
}
|
|
}
|
|
|
|
vint parentCount = typeDescriptor->GetBaseTypeDescriptorCount();
|
|
for (vint i = 0; i < parentCount; i++)
|
|
{
|
|
CollectPropertyNames(typeInfo, typeDescriptor->GetBaseTypeDescriptor(i), propertyNames);
|
|
}
|
|
}
|
|
|
|
//***********************************************************************************
|
|
|
|
void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
if (CanCreate(typeInfo))
|
|
{
|
|
CTOR_PARAM_PREFIX
|
|
|
|
if (auto ctor = GetInstanceConstructor(typeInfo.typeInfo->GetTypeDescriptor()))
|
|
{
|
|
vint count = ctor->GetParameterCount();
|
|
for (vint i = 0; i < count; i++)
|
|
{
|
|
const auto& name = ctor->GetParameter(i)->GetName();
|
|
propertyNames.Add(GlobalStringKey::Get(CTOR_PARAM_NAME(name)));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
GetRequiredPropertyNames(typeInfo, propertyNames);
|
|
CollectPropertyNames(typeInfo, typeInfo.typeInfo->GetTypeDescriptor(), propertyNames);
|
|
}
|
|
|
|
PropertyType GetPropertyTypeCached(const PropertyInfo& propertyInfo)
|
|
{
|
|
CTOR_PARAM_PREFIX
|
|
|
|
FieldKey key(propertyInfo.typeInfo.typeInfo->GetTypeDescriptor(), propertyInfo.propertyName);
|
|
vint index = propertyTypes.Keys().IndexOf(key);
|
|
if (index == -1)
|
|
{
|
|
GuiInstancePropertyInfo::Support support = GuiInstancePropertyInfo::NotSupport;
|
|
if (ITypeInfo* propType = GetPropertyReflectionTypeInfo(propertyInfo, support))
|
|
{
|
|
Ptr<GuiInstancePropertyInfo> result = new GuiInstancePropertyInfo;
|
|
result->support = support;
|
|
result->acceptableTypes.Add(CopyTypeInfo(propType));
|
|
|
|
if (auto ctor = GetInstanceConstructor(propertyInfo.typeInfo.typeInfo->GetTypeDescriptor()))
|
|
{
|
|
vint count = ctor->GetParameterCount();
|
|
for (vint i = 0; i < count; i++)
|
|
{
|
|
const auto& name = ctor->GetParameter(i)->GetName();
|
|
if (CTOR_PARAM_NAME(name) == propertyInfo.propertyName.ToString())
|
|
{
|
|
result->usage = GuiInstancePropertyInfo::ConstructorArgument;
|
|
result->bindability = GuiInstancePropertyInfo::Bindable;
|
|
}
|
|
}
|
|
}
|
|
|
|
IPropertyInfo* prop = propertyInfo.typeInfo.typeInfo->GetTypeDescriptor()->GetPropertyByName(propertyInfo.propertyName.ToString(), true);
|
|
PropertyType value(result, prop);
|
|
propertyTypes.Add(key, value);
|
|
return value;
|
|
}
|
|
else
|
|
{
|
|
PropertyType value(GuiInstancePropertyInfo::Unsupported(), 0);
|
|
propertyTypes.Add(key, value);
|
|
return value;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return propertyTypes.Values()[index];
|
|
}
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
return GetPropertyTypeCached(propertyInfo).f0;
|
|
}
|
|
|
|
//***********************************************************************************
|
|
|
|
bool CanCreate(const TypeInfo& typeInfo)override
|
|
{
|
|
return
|
|
GetDefaultConstructor(typeInfo.typeInfo->GetTypeDescriptor()) != nullptr ||
|
|
GetInstanceConstructor(typeInfo.typeInfo->GetTypeDescriptor()) != nullptr;
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> CreateInstance(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos tagPosition, GuiResourceError::List& errors)override
|
|
{
|
|
CTOR_PARAM_PREFIX
|
|
auto defaultCtor = GetDefaultConstructor(typeInfo.typeInfo->GetTypeDescriptor());
|
|
auto instanceCtor = GetInstanceConstructor(typeInfo.typeInfo->GetTypeDescriptor());
|
|
|
|
auto create = MakePtr<WfNewClassExpression>();
|
|
if (defaultCtor)
|
|
{
|
|
create->type = GetTypeFromTypeInfo(defaultCtor->GetReturn());
|
|
}
|
|
else
|
|
{
|
|
create->type = GetTypeFromTypeInfo(instanceCtor->GetReturn());
|
|
|
|
vint count = instanceCtor->GetParameterCount();
|
|
for (vint i = 0; i < count; i++)
|
|
{
|
|
const auto& name = instanceCtor->GetParameter(i)->GetName();
|
|
auto key = GlobalStringKey::Get(CTOR_PARAM_NAME(name));
|
|
|
|
vint index = arguments.Keys().IndexOf(key);
|
|
if (index == -1)
|
|
{
|
|
return nullptr;
|
|
}
|
|
else
|
|
{
|
|
create->arguments.Add(arguments.GetByIndex(index)[0].expression);
|
|
}
|
|
}
|
|
}
|
|
|
|
auto refValue = MakePtr<WfReferenceExpression>();
|
|
refValue->name.value = variableName.ToString();
|
|
|
|
auto assign = MakePtr<WfBinaryExpression>();
|
|
assign->op = WfBinaryOperator::Assign;
|
|
assign->first = refValue;
|
|
assign->second = create;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = assign;
|
|
return stat;
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
PropertyType propertyType = GetPropertyTypeCached(PropertyInfo(typeInfo, prop));
|
|
if (propertyType.f1)
|
|
{
|
|
switch (propertyType.f0->support)
|
|
{
|
|
case GuiInstancePropertyInfo::SupportCollection:
|
|
{
|
|
const auto& values = arguments.GetByIndex(index);
|
|
if (values.Count() > 0)
|
|
{
|
|
{
|
|
auto refValue = MakePtr<WfReferenceExpression>();
|
|
refValue->name.value = variableName.ToString();
|
|
|
|
auto refProp = MakePtr<WfMemberExpression>();
|
|
refProp->parent = refValue;
|
|
refProp->name.value = prop.ToString();
|
|
|
|
auto varDesc = MakePtr<WfVariableDeclaration>();
|
|
varDesc->name.value = L"<collection>";
|
|
varDesc->expression = refProp;
|
|
|
|
auto stat = MakePtr<WfVariableStatement>();
|
|
stat->variable = varDesc;
|
|
block->statements.Add(stat);
|
|
}
|
|
|
|
for (vint i = 0; i < values.Count(); i++)
|
|
{
|
|
auto refCollection = MakePtr<WfReferenceExpression>();
|
|
refCollection->name.value = L"<collection>";
|
|
|
|
auto refAdd = MakePtr<WfMemberExpression>();
|
|
refAdd->parent = refCollection;
|
|
refAdd->name.value = L"Add";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refAdd;
|
|
call->arguments.Add(values[i].expression);
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case GuiInstancePropertyInfo::SupportArray:
|
|
{
|
|
auto refArray = MakePtr<WfConstructorExpression>();
|
|
FOREACH(ArgumentInfo, item, arguments.GetByIndex(index))
|
|
{
|
|
auto argument = MakePtr<WfConstructorArgument>();
|
|
argument->key = item.expression;
|
|
refArray->arguments.Add(argument);
|
|
}
|
|
|
|
auto refValue = MakePtr<WfReferenceExpression>();
|
|
refValue->name.value = variableName.ToString();
|
|
|
|
auto refProp = MakePtr<WfMemberExpression>();
|
|
refProp->parent = refValue;
|
|
refProp->name.value = prop.ToString();
|
|
|
|
auto assign = MakePtr<WfBinaryExpression>();
|
|
assign->op = WfBinaryOperator::Assign;
|
|
assign->first = refProp;
|
|
assign->second = refArray;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = assign;
|
|
block->statements.Add(stat);
|
|
}
|
|
break;
|
|
case GuiInstancePropertyInfo::SupportAssign:
|
|
{
|
|
auto& propertyValue = arguments.GetByIndex(index)[0];
|
|
if (propertyValue.expression)
|
|
{
|
|
|
|
auto refValue = MakePtr<WfReferenceExpression>();
|
|
refValue->name.value = variableName.ToString();
|
|
|
|
auto refProp = MakePtr<WfMemberExpression>();
|
|
refProp->parent = refValue;
|
|
refProp->name.value = prop.ToString();
|
|
|
|
auto assign = MakePtr<WfBinaryExpression>();
|
|
assign->op = WfBinaryOperator::Assign;
|
|
assign->first = refProp;
|
|
assign->second = propertyValue.expression;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = assign;
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, attPosition,
|
|
L"Precompile: Property \"" +
|
|
prop.ToString() +
|
|
L"\" of type \"" +
|
|
typeInfo.typeName.ToString() +
|
|
L"\" is not assignable."));
|
|
}
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
Ptr<workflow::WfExpression> GetParameter(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const PropertyInfo& propertyInfo, GlobalStringKey variableName, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto refValue = MakePtr<WfReferenceExpression>();
|
|
refValue->name.value = variableName.ToString();
|
|
|
|
auto refProp = MakePtr<WfMemberExpression>();
|
|
refProp->parent = refValue;
|
|
refProp->name.value = propertyInfo.propertyName.ToString();
|
|
|
|
return refProp;
|
|
}
|
|
};
|
|
#undef CTOR_PARAM_NAME
|
|
#undef CTOR_PARAM_PREFIX
|
|
|
|
/***********************************************************************
|
|
GuiInstanceLoaderManager
|
|
***********************************************************************/
|
|
|
|
IGuiInstanceLoaderManager* instanceLoaderManager = 0;
|
|
|
|
IGuiInstanceLoaderManager* GetInstanceLoaderManager()
|
|
{
|
|
return instanceLoaderManager;
|
|
}
|
|
|
|
class GuiInstanceLoaderManager : public Object, public IGuiInstanceLoaderManager, public IGuiPlugin
|
|
{
|
|
protected:
|
|
typedef Dictionary<GlobalStringKey, Ptr<IGuiInstanceBinder>> BinderMap;
|
|
typedef Dictionary<GlobalStringKey, Ptr<IGuiInstanceEventBinder>> EventBinderMap;
|
|
typedef List<Ptr<IGuiInstanceDeserializer>> DeserializerList;
|
|
|
|
struct VirtualTypeInfo
|
|
{
|
|
GlobalStringKey typeName;
|
|
ITypeDescriptor* typeDescriptor = nullptr;
|
|
GlobalStringKey parentTypeName; // for virtual type only
|
|
Ptr<IGuiInstanceLoader> loader;
|
|
|
|
List<ITypeDescriptor*> parentTypes; // all direct or indirect base types that does not has a type info
|
|
List<VirtualTypeInfo*> parentTypeInfos; // type infos for all registered direct or indirect base types
|
|
};
|
|
|
|
typedef Dictionary<GlobalStringKey, Ptr<VirtualTypeInfo>> VirtualTypeInfoMap;
|
|
|
|
Ptr<IGuiInstanceLoader> rootLoader;
|
|
BinderMap binders;
|
|
EventBinderMap eventBinders;
|
|
DeserializerList deserializers;
|
|
VirtualTypeInfoMap typeInfos;
|
|
|
|
bool IsTypeExists(GlobalStringKey name)
|
|
{
|
|
return GetGlobalTypeManager()->GetTypeDescriptor(name.ToString()) != 0 || typeInfos.Keys().Contains(name);
|
|
}
|
|
|
|
void FindParentTypeInfos(Ptr<VirtualTypeInfo> typeInfo, ITypeDescriptor* searchType)
|
|
{
|
|
if (searchType != typeInfo->typeDescriptor)
|
|
{
|
|
vint index = typeInfos.Keys().IndexOf(GlobalStringKey::Get(searchType->GetTypeName()));
|
|
if (index == -1)
|
|
{
|
|
typeInfo->parentTypes.Add(searchType);
|
|
}
|
|
else
|
|
{
|
|
typeInfo->parentTypeInfos.Add(typeInfos.Values()[index].Obj());
|
|
return;
|
|
}
|
|
}
|
|
|
|
vint count = searchType->GetBaseTypeDescriptorCount();
|
|
for (vint i = 0; i < count; i++)
|
|
{
|
|
ITypeDescriptor* baseType = searchType->GetBaseTypeDescriptor(i);
|
|
FindParentTypeInfos(typeInfo, baseType);
|
|
}
|
|
}
|
|
|
|
void FillParentTypeInfos(Ptr<VirtualTypeInfo> typeInfo)
|
|
{
|
|
if (typeInfo->parentTypeName != GlobalStringKey::Empty)
|
|
{
|
|
typeInfo->typeDescriptor = nullptr;
|
|
}
|
|
typeInfo->parentTypes.Clear();
|
|
typeInfo->parentTypeInfos.Clear();
|
|
|
|
ITypeDescriptor* searchType = typeInfo->typeDescriptor;
|
|
if (!searchType)
|
|
{
|
|
vint index = typeInfos.Keys().IndexOf(typeInfo->parentTypeName);
|
|
if (index == -1)
|
|
{
|
|
searchType = GetGlobalTypeManager()->GetTypeDescriptor(typeInfo->parentTypeName.ToString());
|
|
typeInfo->typeDescriptor = searchType;
|
|
typeInfo->parentTypes.Add(searchType);
|
|
}
|
|
else
|
|
{
|
|
VirtualTypeInfo* parentTypeInfo = typeInfos.Values()[index].Obj();
|
|
typeInfo->typeDescriptor = parentTypeInfo->typeDescriptor;
|
|
typeInfo->parentTypeInfos.Add(parentTypeInfo);
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (searchType)
|
|
{
|
|
FindParentTypeInfos(typeInfo, searchType);
|
|
}
|
|
}
|
|
|
|
IGuiInstanceLoader* GetLoaderFromType(ITypeDescriptor* typeDescriptor)
|
|
{
|
|
vint index = typeInfos.Keys().IndexOf(GlobalStringKey::Get(typeDescriptor->GetTypeName()));
|
|
if (index == -1)
|
|
{
|
|
vint count = typeDescriptor->GetBaseTypeDescriptorCount();
|
|
for (vint i = 0; i < count; i++)
|
|
{
|
|
ITypeDescriptor* baseType = typeDescriptor->GetBaseTypeDescriptor(i);
|
|
IGuiInstanceLoader* loader = GetLoaderFromType(baseType);
|
|
if (loader) return loader;
|
|
}
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return typeInfos.Values()[index]->loader.Obj();
|
|
}
|
|
}
|
|
public:
|
|
GuiInstanceLoaderManager()
|
|
{
|
|
rootLoader = new GuiDefaultInstanceLoader;
|
|
}
|
|
|
|
void Load()override
|
|
{
|
|
instanceLoaderManager = this;
|
|
}
|
|
|
|
void AfterLoad()override
|
|
{
|
|
IGuiParserManager* manager = GetParserManager();
|
|
manager->SetParser(L"INSTANCE-ELEMENT-NAME", new GuiInstanceContextElementNameParser);
|
|
}
|
|
|
|
void Unload()override
|
|
{
|
|
instanceLoaderManager = nullptr;
|
|
}
|
|
|
|
bool AddInstanceBinder(Ptr<IGuiInstanceBinder> binder)override
|
|
{
|
|
if (binders.Keys().Contains(binder->GetBindingName())) return false;
|
|
binders.Add(binder->GetBindingName(), binder);
|
|
return true;
|
|
}
|
|
|
|
IGuiInstanceBinder* GetInstanceBinder(GlobalStringKey bindingName)override
|
|
{
|
|
vint index = binders.Keys().IndexOf(bindingName);
|
|
return index == -1 ? nullptr : binders.Values()[index].Obj();
|
|
}
|
|
|
|
bool AddInstanceEventBinder(Ptr<IGuiInstanceEventBinder> binder)override
|
|
{
|
|
if (eventBinders.Keys().Contains(binder->GetBindingName())) return false;
|
|
eventBinders.Add(binder->GetBindingName(), binder);
|
|
return true;
|
|
}
|
|
|
|
IGuiInstanceEventBinder* GetInstanceEventBinder(GlobalStringKey bindingName)override
|
|
{
|
|
vint index = eventBinders.Keys().IndexOf(bindingName);
|
|
return index == -1 ? nullptr : eventBinders.Values()[index].Obj();
|
|
}
|
|
|
|
bool AddInstanceDeserializer(Ptr<IGuiInstanceDeserializer> deserializer)override
|
|
{
|
|
if (deserializers.Contains(deserializer.Obj())) return false;
|
|
deserializers.Add(deserializer);
|
|
return true;
|
|
}
|
|
|
|
IGuiInstanceDeserializer* GetInstanceDeserializer(description::ITypeInfo* typeInfo)override
|
|
{
|
|
FOREACH(Ptr<IGuiInstanceDeserializer>, deserializer, deserializers)
|
|
{
|
|
if (deserializer->CanDeserialize(typeInfo))
|
|
{
|
|
return deserializer.Obj();
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
bool CreateVirtualType(GlobalStringKey parentType, Ptr<IGuiInstanceLoader> loader)override
|
|
{
|
|
if (IsTypeExists(loader->GetTypeName()) || !IsTypeExists(parentType)) return false;
|
|
|
|
Ptr<VirtualTypeInfo> typeInfo = new VirtualTypeInfo;
|
|
typeInfo->typeName = loader->GetTypeName();
|
|
typeInfo->parentTypeName = parentType;
|
|
typeInfo->loader = loader;
|
|
typeInfos.Add(loader->GetTypeName(), typeInfo);
|
|
FillParentTypeInfos(typeInfo);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool SetLoader(Ptr<IGuiInstanceLoader> loader)override
|
|
{
|
|
vint index = typeInfos.Keys().IndexOf(loader->GetTypeName());
|
|
if (index != -1) return false;
|
|
|
|
ITypeDescriptor* typeDescriptor = GetGlobalTypeManager()->GetTypeDescriptor(loader->GetTypeName().ToString());
|
|
if (typeDescriptor == 0) return false;
|
|
|
|
Ptr<VirtualTypeInfo> typeInfo = new VirtualTypeInfo;
|
|
typeInfo->typeName = loader->GetTypeName();
|
|
typeInfo->typeDescriptor = typeDescriptor;
|
|
typeInfo->loader = loader;
|
|
typeInfos.Add(typeInfo->typeName, typeInfo);
|
|
FillParentTypeInfos(typeInfo);
|
|
|
|
FOREACH(Ptr<VirtualTypeInfo>, derived, typeInfos.Values())
|
|
{
|
|
if (derived->parentTypes.Contains(typeInfo->typeDescriptor))
|
|
{
|
|
FillParentTypeInfos(derived);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
IGuiInstanceLoader* GetLoader(GlobalStringKey typeName)override
|
|
{
|
|
vint index = typeInfos.Keys().IndexOf(typeName);
|
|
if (index != -1)
|
|
{
|
|
return typeInfos.Values()[index]->loader.Obj();
|
|
}
|
|
|
|
ITypeDescriptor* typeDescriptor = GetGlobalTypeManager()->GetTypeDescriptor(typeName.ToString());
|
|
if (typeDescriptor)
|
|
{
|
|
IGuiInstanceLoader* loader = GetLoaderFromType(typeDescriptor);
|
|
return loader ? loader : rootLoader.Obj();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
IGuiInstanceLoader* GetParentLoader(IGuiInstanceLoader* loader)override
|
|
{
|
|
vint index = typeInfos.Keys().IndexOf(loader->GetTypeName());
|
|
if (index != -1)
|
|
{
|
|
Ptr<VirtualTypeInfo> typeInfo = typeInfos.Values()[index];
|
|
if (typeInfo->parentTypeInfos.Count() > 0)
|
|
{
|
|
return typeInfo->parentTypeInfos[0]->loader.Obj();
|
|
}
|
|
return rootLoader.Obj();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
Ptr<description::ITypeInfo> GetTypeInfoForType(GlobalStringKey typeName)override
|
|
{
|
|
vint index = typeInfos.Keys().IndexOf(typeName);
|
|
auto td = index == -1
|
|
? GetGlobalTypeManager()->GetTypeDescriptor(typeName.ToString())
|
|
: typeInfos.Values()[index]->typeDescriptor;
|
|
if (!td) return nullptr;
|
|
|
|
if (auto ctor = td->GetConstructorGroup())
|
|
{
|
|
return CopyTypeInfo(ctor->GetMethod(0)->GetReturn());
|
|
}
|
|
else
|
|
{
|
|
return MakePtr<RawPtrTypeInfo>(MakePtr<TypeDescriptorTypeInfo>(td, TypeInfoHint::Normal));
|
|
}
|
|
}
|
|
|
|
void GetVirtualTypes(collections::List<GlobalStringKey>& typeNames)override
|
|
{
|
|
for (vint i = 0; i < typeInfos.Count(); i++)
|
|
{
|
|
if (typeInfos.Values()[i]->parentTypeName != GlobalStringKey::Empty)
|
|
{
|
|
typeNames.Add(typeInfos.Keys()[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
GlobalStringKey GetParentTypeForVirtualType(GlobalStringKey virtualType)override
|
|
{
|
|
vint index = typeInfos.Keys().IndexOf(virtualType);
|
|
if (index != -1)
|
|
{
|
|
auto typeInfo = typeInfos.Values()[index];
|
|
return typeInfo->parentTypeName;
|
|
}
|
|
return GlobalStringKey::Empty;
|
|
}
|
|
|
|
void ClearReflectionCache()override
|
|
{
|
|
rootLoader->ClearReflectionCache();
|
|
FOREACH(Ptr<VirtualTypeInfo>, info, typeInfos.Values())
|
|
{
|
|
info->loader->ClearReflectionCache();
|
|
}
|
|
}
|
|
};
|
|
GUI_REGISTER_PLUGIN(GuiInstanceLoaderManager)
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
GUIINSTANCELOADER_PREDEFINEDINSTANCEBINDERS.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
using namespace collections;
|
|
using namespace reflection::description;
|
|
using namespace parsing;
|
|
using namespace workflow;
|
|
using namespace workflow::analyzer;
|
|
using namespace workflow::runtime;
|
|
using namespace controls;
|
|
using namespace stream;
|
|
|
|
/***********************************************************************
|
|
GuiResourceInstanceBinder (uri)
|
|
***********************************************************************/
|
|
|
|
class GuiResourceInstanceBinder : public Object, public IGuiInstanceBinder
|
|
{
|
|
public:
|
|
GlobalStringKey GetBindingName()override
|
|
{
|
|
return GlobalStringKey::_Uri;
|
|
}
|
|
|
|
bool ApplicableToConstructorArgument()override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool RequirePropertyExist()override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
Ptr<workflow::WfExpression> GenerateConstructorArgument(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, const WString& code, GuiResourceTextPos position, GuiResourceError::List& errors)override
|
|
{
|
|
CHECK_FAIL(L"GuiResourceInstanceBinder::GenerateConstructorArgument()#This binder does not support binding to constructor arguments. Please call ApplicableToConstructorArgument() to determine before calling this function.");
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> GenerateInstallStatement(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GlobalStringKey variableName, description::IPropertyInfo* propertyInfo, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, const WString& code, GuiResourceTextPos position, GuiResourceError::List& errors)override
|
|
{
|
|
WString protocol, path;
|
|
if (!IsResourceUrl(code, protocol, path))
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, position, L"Precompile: \"" + code + L"\" is not a valid resource uri."));
|
|
return nullptr;
|
|
}
|
|
else
|
|
{
|
|
return Workflow_InstallUriProperty(precompileContext, resolvingResult, variableName, loader, prop, propInfo, protocol, path, position, errors);
|
|
}
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiReferenceInstanceBinder (ref)
|
|
***********************************************************************/
|
|
|
|
class GuiReferenceInstanceBinder : public Object, public IGuiInstanceBinder
|
|
{
|
|
public:
|
|
GlobalStringKey GetBindingName()override
|
|
{
|
|
return GlobalStringKey::_Ref;
|
|
}
|
|
|
|
bool ApplicableToConstructorArgument()override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool RequirePropertyExist()override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
Ptr<workflow::WfExpression> GenerateConstructorArgument(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, const WString& code, GuiResourceTextPos position, GuiResourceError::List& errors)override
|
|
{
|
|
CHECK_FAIL(L"GuiReferenceInstanceBinder::GenerateConstructorArgument()#This binder does not support binding to constructor arguments. Please call ApplicableToConstructorArgument() to determine before calling this function.");
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> GenerateInstallStatement(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GlobalStringKey variableName, description::IPropertyInfo* propertyInfo, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, const WString& code, GuiResourceTextPos position, GuiResourceError::List& errors)override
|
|
{
|
|
auto expression = MakePtr<WfReferenceExpression>();
|
|
expression->name.value = code;
|
|
return Workflow_InstallEvalProperty(precompileContext, resolvingResult, variableName, loader, prop, propInfo, expression, position, errors);
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiEvalInstanceBinder (eval)
|
|
***********************************************************************/
|
|
|
|
class GuiEvalInstanceBinder : public Object, public IGuiInstanceBinder
|
|
{
|
|
public:
|
|
GlobalStringKey GetBindingName()override
|
|
{
|
|
return GlobalStringKey::_Eval;
|
|
}
|
|
|
|
bool ApplicableToConstructorArgument()override
|
|
{
|
|
return true;
|
|
}
|
|
|
|
bool RequirePropertyExist()override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
Ptr<workflow::WfExpression> GenerateConstructorArgument(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, const WString& code, GuiResourceTextPos position, GuiResourceError::List& errors)override
|
|
{
|
|
return Workflow_ParseExpression(precompileContext, { resolvingResult.resource }, code, position, errors);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> GenerateInstallStatement(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GlobalStringKey variableName, description::IPropertyInfo* propertyInfo, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, const WString& code, GuiResourceTextPos position, GuiResourceError::List& errors)override
|
|
{
|
|
if(auto expression = Workflow_ParseExpression(precompileContext, { resolvingResult.resource }, code, position, errors))
|
|
{
|
|
return Workflow_InstallEvalProperty(precompileContext, resolvingResult, variableName, loader, prop, propInfo, expression, position, errors);
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiBindInstanceBinder (bind)
|
|
***********************************************************************/
|
|
|
|
class GuiBindInstanceBinder : public Object, public IGuiInstanceBinder
|
|
{
|
|
public:
|
|
GlobalStringKey GetBindingName()override
|
|
{
|
|
return GlobalStringKey::_Bind;
|
|
}
|
|
|
|
bool ApplicableToConstructorArgument()override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool RequirePropertyExist()override
|
|
{
|
|
return true;
|
|
}
|
|
|
|
Ptr<workflow::WfExpression> GenerateConstructorArgument(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, const WString& code, GuiResourceTextPos position, GuiResourceError::List& errors)override
|
|
{
|
|
CHECK_FAIL(L"GuiBindInstanceBinder::GenerateConstructorArgument()#This binder does not support binding to constructor arguments. Please call ApplicableToConstructorArgument() to determine before calling this function.");
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> GenerateInstallStatement(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GlobalStringKey variableName, description::IPropertyInfo* propertyInfo, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, const WString& code, GuiResourceTextPos position, GuiResourceError::List& errors)override
|
|
{
|
|
if(auto expression = Workflow_ParseExpression(precompileContext, { resolvingResult.resource }, code, position, errors))
|
|
{
|
|
auto inferExpr = MakePtr<WfInferExpression>();
|
|
inferExpr->expression = expression;
|
|
inferExpr->type = GetTypeFromTypeInfo(propertyInfo->GetReturn());
|
|
|
|
auto bindExpr = MakePtr<WfBindExpression>();
|
|
bindExpr->expression = inferExpr;
|
|
|
|
return Workflow_InstallBindProperty(precompileContext, resolvingResult, variableName, propertyInfo, bindExpr);
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiFormatInstanceBinder (format)
|
|
***********************************************************************/
|
|
|
|
class GuiFormatInstanceBinder : public Object, public IGuiInstanceBinder
|
|
{
|
|
public:
|
|
GlobalStringKey GetBindingName()override
|
|
{
|
|
return GlobalStringKey::_Format;
|
|
}
|
|
|
|
bool ApplicableToConstructorArgument()override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool RequirePropertyExist()override
|
|
{
|
|
return true;
|
|
}
|
|
|
|
Ptr<workflow::WfExpression> GenerateConstructorArgument(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, const WString& code, GuiResourceTextPos position, GuiResourceError::List& errors)override
|
|
{
|
|
CHECK_FAIL(L"GuiFormatInstanceBinder::GenerateConstructorArgument()#This binder does not support binding to constructor arguments. Please call ApplicableToConstructorArgument() to determine before calling this function.");
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> GenerateInstallStatement(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GlobalStringKey variableName, description::IPropertyInfo* propertyInfo, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, const WString& code, GuiResourceTextPos position, GuiResourceError::List& errors)override
|
|
{
|
|
if (auto expression = Workflow_ParseExpression(precompileContext, { resolvingResult.resource }, L"bind($\"" + code + L"\")", position, errors, { 0,7 })) // bind($"
|
|
{
|
|
return Workflow_InstallBindProperty(precompileContext, resolvingResult, variableName, propertyInfo, expression);
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiEvalInstanceEventBinder (eval)
|
|
***********************************************************************/
|
|
|
|
class GuiEvalInstanceEventBinder : public Object, public IGuiInstanceEventBinder
|
|
{
|
|
public:
|
|
GlobalStringKey GetBindingName()override
|
|
{
|
|
return GlobalStringKey::_Eval;
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> GenerateInstallStatement(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GlobalStringKey variableName, description::IEventInfo* eventInfo, const WString& code, GuiResourceTextPos position, GuiResourceError::List& errors)override
|
|
{
|
|
bool coroutine = false;
|
|
{
|
|
auto reading = code.Buffer();
|
|
while (true)
|
|
{
|
|
switch (*reading)
|
|
{
|
|
case ' ':
|
|
case '\t':
|
|
case '\r':
|
|
case '\n':
|
|
reading++;
|
|
break;
|
|
default:
|
|
goto BEGIN_TESTING;
|
|
}
|
|
}
|
|
BEGIN_TESTING:
|
|
coroutine = *reading == '$';
|
|
}
|
|
|
|
auto parseFunction = coroutine ? &Workflow_ParseCoProviderStatement : &Workflow_ParseStatement;
|
|
if (auto statement = parseFunction(precompileContext, { resolvingResult.resource }, code, position, errors, { 0,0 }))
|
|
{
|
|
return Workflow_InstallEvalEvent(precompileContext, resolvingResult, variableName, eventInfo, statement);
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiPredefinedInstanceBindersPlugin
|
|
***********************************************************************/
|
|
|
|
class GuiPredefinedInstanceBindersPlugin : public Object, public IGuiPlugin
|
|
{
|
|
public:
|
|
GuiPredefinedInstanceBindersPlugin()
|
|
{
|
|
}
|
|
|
|
void Load()override
|
|
{
|
|
WfLoadTypes();
|
|
GuiIqLoadTypes();
|
|
}
|
|
|
|
void AfterLoad()override
|
|
{
|
|
{
|
|
IGuiParserManager* manager = GetParserManager();
|
|
manager->SetParsingTable(L"WORKFLOW", &WfLoadTable);
|
|
manager->SetTableParser(L"WORKFLOW", L"WORKFLOW-TYPE", &WfParseType);
|
|
manager->SetTableParser(L"WORKFLOW", L"WORKFLOW-EXPRESSION", &WfParseExpression);
|
|
manager->SetTableParser(L"WORKFLOW", L"WORKFLOW-STATEMENT", &WfParseStatement);
|
|
manager->SetTableParser(L"WORKFLOW", L"WORKFLOW-COPROVIDER-STATEMENT", &WfParseCoProviderStatement);
|
|
manager->SetTableParser(L"WORKFLOW", L"WORKFLOW-DECLARATION", &WfParseDeclaration);
|
|
manager->SetTableParser(L"WORKFLOW", L"WORKFLOW-MODULE", &WfParseModule);
|
|
manager->SetParsingTable(L"INSTANCE-QUERY", &GuiIqLoadTable);
|
|
manager->SetTableParser(L"INSTANCE-QUERY", L"INSTANCE-QUERY", &GuiIqParse);
|
|
}
|
|
{
|
|
IGuiInstanceLoaderManager* manager=GetInstanceLoaderManager();
|
|
|
|
manager->AddInstanceBinder(new GuiResourceInstanceBinder);
|
|
manager->AddInstanceBinder(new GuiReferenceInstanceBinder);
|
|
manager->AddInstanceBinder(new GuiEvalInstanceBinder);
|
|
manager->AddInstanceEventBinder(new GuiEvalInstanceEventBinder);
|
|
manager->AddInstanceBinder(new GuiBindInstanceBinder);
|
|
manager->AddInstanceBinder(new GuiFormatInstanceBinder);
|
|
}
|
|
}
|
|
|
|
void Unload()override
|
|
{
|
|
}
|
|
};
|
|
GUI_REGISTER_PLUGIN(GuiPredefinedInstanceBindersPlugin)
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
GUIINSTANCELOADER_PREDEFINEDINSTANCEDESERIALIZERS.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
using namespace collections;
|
|
using namespace reflection::description;
|
|
using namespace workflow;
|
|
using namespace workflow::analyzer;
|
|
using namespace controls;
|
|
using namespace templates;
|
|
|
|
/***********************************************************************
|
|
GuiTemplatePropertyDeserializer
|
|
***********************************************************************/
|
|
|
|
class GuiTemplatePropertyDeserializer : public Object, public IGuiInstanceDeserializer
|
|
{
|
|
protected:
|
|
Ptr<ITypeInfo> stringType;
|
|
|
|
bool IsTemplatePropertyType(ITypeInfo* propType)
|
|
{
|
|
if (propType->GetDecorator() == ITypeInfo::SharedPtr)
|
|
{
|
|
auto genericType = propType->GetElementType();
|
|
if (genericType->GetDecorator() == ITypeInfo::Generic && genericType->GetGenericArgumentCount() == 2)
|
|
{
|
|
if (genericType->GetElementType()->GetTypeDescriptor() == description::GetTypeDescriptor<IValueFunctionProxy>())
|
|
{
|
|
if (genericType->GetGenericArgument(1)->GetTypeDescriptor() == description::GetTypeDescriptor<Value>())
|
|
{
|
|
auto returnType = genericType->GetGenericArgument(0);
|
|
if (returnType->GetDecorator() == ITypeInfo::RawPtr)
|
|
{
|
|
if (returnType->GetElementType()->GetTypeDescriptor()->CanConvertTo(description::GetTypeDescriptor<GuiTemplate>()))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool IsDataVisualizerFactoryType(ITypeInfo* propType)
|
|
{
|
|
return propType->GetDecorator() == ITypeInfo::SharedPtr && propType->GetTypeDescriptor() == description::GetTypeDescriptor<list::IDataVisualizerFactory>();
|
|
}
|
|
|
|
bool IsDataEditorFactoryType(ITypeInfo* propType)
|
|
{
|
|
return propType->GetDecorator() == ITypeInfo::SharedPtr && propType->GetTypeDescriptor() == description::GetTypeDescriptor<list::IDataEditorFactory>();
|
|
}
|
|
|
|
public:
|
|
GuiTemplatePropertyDeserializer()
|
|
{
|
|
stringType = TypeInfoRetriver<WString>::CreateTypeInfo();
|
|
}
|
|
|
|
bool CanDeserialize(description::ITypeInfo* typeInfo)override
|
|
{
|
|
return IsTemplatePropertyType(typeInfo);
|
|
}
|
|
|
|
description::ITypeInfo* DeserializeAs(description::ITypeInfo* typeInfo)override
|
|
{
|
|
return stringType.Obj();
|
|
}
|
|
|
|
static void GetItemTemplateType(
|
|
types::ResolvingResult& resolvingResult,
|
|
WString typeNamesString,
|
|
List<ITypeDescriptor*>& tds,
|
|
GuiResourceTextPos tagPosition,
|
|
GuiResourceError::List& errors
|
|
)
|
|
{
|
|
List<WString> typeNames;
|
|
SplitBySemicolon(typeNamesString, typeNames);
|
|
if (typeNames.Count() == 0)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, tagPosition,
|
|
L"Precompile: Template list \"" +
|
|
typeNamesString +
|
|
L"\" cannot be empty."));
|
|
}
|
|
|
|
FOREACH(WString, controlTemplateName, typeNames)
|
|
{
|
|
auto controlTemplateTd = description::GetTypeDescriptor(controlTemplateName);
|
|
if (!controlTemplateTd)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, tagPosition,
|
|
L"Precompile: Type \"" +
|
|
controlTemplateName +
|
|
L"\" does not exist."));
|
|
continue;
|
|
}
|
|
tds.Add(controlTemplateTd);
|
|
}
|
|
}
|
|
|
|
static Ptr<WfExpression> CreateTemplateFactory(
|
|
types::ResolvingResult& resolvingResult,
|
|
List<ITypeDescriptor*>& controlTemplateTds,
|
|
ITypeInfo* templateType,
|
|
GuiResourceTextPos tagPosition,
|
|
GuiResourceError::List& errors
|
|
)
|
|
{
|
|
auto funcCreateTemplate = MakePtr<WfFunctionDeclaration>();
|
|
funcCreateTemplate->anonymity = WfFunctionAnonymity::Anonymous;
|
|
funcCreateTemplate->returnType = GetTypeFromTypeInfo(templateType);
|
|
|
|
auto argViewModel = MakePtr<WfFunctionArgument>();
|
|
argViewModel->type = GetTypeFromTypeInfo(TypeInfoRetriver<Value>::CreateTypeInfo().Obj());
|
|
argViewModel->name.value = L"<viewModel>";
|
|
funcCreateTemplate->arguments.Add(argViewModel);
|
|
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
funcCreateTemplate->statement = block;
|
|
|
|
ITypeDescriptor* stopControlTemplateTd = nullptr;
|
|
FOREACH(ITypeDescriptor*, controlTemplateTd, controlTemplateTds)
|
|
{
|
|
if (!controlTemplateTd->CanConvertTo(templateType->GetTypeDescriptor()))
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, tagPosition,
|
|
L"Precompile: Type \"" +
|
|
controlTemplateTd->GetTypeName() +
|
|
L"\" cannot be used here because it requires \"" +
|
|
templateType->GetTypeDescriptor()->GetTypeName() +
|
|
L"\" or its derived classes."));
|
|
}
|
|
|
|
if (stopControlTemplateTd)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, tagPosition,
|
|
L"Precompile: Type \"" +
|
|
controlTemplateTd->GetTypeName() +
|
|
L"\" will never be tried, because \"" +
|
|
stopControlTemplateTd->GetTypeName() +
|
|
L"\", which is listed before, has a default constructor. So whatever the view model is, it will be the last choice."));
|
|
continue;
|
|
}
|
|
|
|
ITypeInfo* viewModelType = nullptr;
|
|
{
|
|
auto ctors = controlTemplateTd->GetConstructorGroup();
|
|
if (ctors->GetMethodCount() != 1)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, tagPosition,
|
|
L"Precompile: To use type \"" +
|
|
controlTemplateTd->GetTypeName() +
|
|
L"\" as a control template or item template, it should have exactly one constructor."));
|
|
continue;
|
|
}
|
|
|
|
auto ctor = ctors->GetMethod(0);
|
|
if (ctor->GetParameterCount() > 1)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, tagPosition,
|
|
L"Precompile: To use type \"" +
|
|
controlTemplateTd->GetTypeName() +
|
|
L"\" as a control template or item template, its constructor cannot have more than one parameter."));
|
|
continue;
|
|
}
|
|
|
|
if (ctor->GetParameterCount() != 0)
|
|
{
|
|
viewModelType = ctor->GetParameter(0)->GetType();
|
|
}
|
|
}
|
|
|
|
if (!viewModelType)
|
|
{
|
|
stopControlTemplateTd = controlTemplateTd;
|
|
}
|
|
|
|
auto subBlock = MakePtr<WfBlockStatement>();
|
|
block->statements.Add(subBlock);
|
|
|
|
Ptr<ITypeInfo> controlTemplateType;
|
|
{
|
|
auto elementType = MakePtr<TypeDescriptorTypeInfo>(controlTemplateTd, TypeInfoHint::Normal);
|
|
auto pointerType = MakePtr<RawPtrTypeInfo>(elementType);
|
|
|
|
controlTemplateType = pointerType;
|
|
}
|
|
|
|
Ptr<WfBlockStatement> returnStatBlock;
|
|
if (viewModelType)
|
|
{
|
|
auto refViewModel = MakePtr<WfReferenceExpression>();
|
|
refViewModel->name.value = L"<viewModel>";
|
|
|
|
auto condition = MakePtr<WfTypeTestingExpression>();
|
|
condition->test = WfTypeTesting::IsType;
|
|
condition->expression = refViewModel;
|
|
condition->type = GetTypeFromTypeInfo(viewModelType);
|
|
|
|
auto ifStat = MakePtr<WfIfStatement>();
|
|
subBlock->statements.Add(ifStat);
|
|
ifStat->expression = condition;
|
|
|
|
returnStatBlock = MakePtr<WfBlockStatement>();
|
|
ifStat->trueBranch = returnStatBlock;
|
|
}
|
|
else
|
|
{
|
|
returnStatBlock = subBlock;
|
|
}
|
|
|
|
{
|
|
auto createControlTemplate = MakePtr<WfNewClassExpression>();
|
|
createControlTemplate->type = GetTypeFromTypeInfo(controlTemplateType.Obj());
|
|
if (viewModelType)
|
|
{
|
|
auto refViewModel = MakePtr<WfReferenceExpression>();
|
|
refViewModel->name.value = L"<viewModel>";
|
|
|
|
auto cast = MakePtr<WfTypeCastingExpression>();
|
|
cast->strategy = WfTypeCastingStrategy::Strong;
|
|
cast->expression = refViewModel;
|
|
cast->type = GetTypeFromTypeInfo(viewModelType);
|
|
createControlTemplate->arguments.Add(cast);
|
|
}
|
|
|
|
auto returnStat = MakePtr<WfReturnStatement>();
|
|
returnStat->expression = createControlTemplate;
|
|
returnStatBlock->statements.Add(returnStat);
|
|
}
|
|
}
|
|
|
|
if (!stopControlTemplateTd)
|
|
{
|
|
auto value = MakePtr<WfStringExpression>();
|
|
value->value.value = L"Cannot find a matched control template to create.";
|
|
|
|
auto raiseStat = MakePtr<WfRaiseExceptionStatement>();
|
|
raiseStat->expression = value;
|
|
|
|
block->statements.Add(raiseStat);
|
|
}
|
|
|
|
auto expr = MakePtr<WfFunctionExpression>();
|
|
expr->function = funcCreateTemplate;
|
|
return expr;
|
|
}
|
|
|
|
static Ptr<WfExpression> CreateDataVisualizerFactory(
|
|
types::ResolvingResult& resolvingResult,
|
|
List<ITypeDescriptor*>& controlTemplateTds,
|
|
GuiResourceTextPos tagPosition,
|
|
GuiResourceError::List& errors
|
|
)
|
|
{
|
|
auto templateType = TypeInfoRetriver<GuiGridVisualizerTemplate*>::CreateTypeInfo();
|
|
Ptr<WfExpression> previousFactory;
|
|
FOREACH_INDEXER(ITypeDescriptor*, controlTemplateTd, index, controlTemplateTds)
|
|
{
|
|
List<ITypeDescriptor*> tds;
|
|
tds.Add(controlTemplateTd);
|
|
auto refFactory = CreateTemplateFactory(resolvingResult, tds, templateType.Obj(), tagPosition, errors);
|
|
auto createStyle = MakePtr<WfNewClassExpression>();
|
|
if (index == 0)
|
|
{
|
|
createStyle->type = GetTypeFromTypeInfo(TypeInfoRetriver<Ptr<GuiBindableDataVisualizer::Factory>>::CreateTypeInfo().Obj());
|
|
}
|
|
else
|
|
{
|
|
createStyle->type = GetTypeFromTypeInfo(TypeInfoRetriver<Ptr<GuiBindableDataVisualizer::DecoratedFactory>>::CreateTypeInfo().Obj());
|
|
}
|
|
createStyle->arguments.Add(refFactory);
|
|
|
|
if (index > 0)
|
|
{
|
|
createStyle->arguments.Add(previousFactory);
|
|
}
|
|
previousFactory = createStyle;
|
|
}
|
|
return previousFactory;
|
|
}
|
|
|
|
static Ptr<WfExpression> CreateDataEditorFactory(
|
|
types::ResolvingResult& resolvingResult,
|
|
List<ITypeDescriptor*>& controlTemplateTds,
|
|
GuiResourceTextPos tagPosition,
|
|
GuiResourceError::List& errors
|
|
)
|
|
{
|
|
auto templateType = TypeInfoRetriver<GuiGridEditorTemplate*>::CreateTypeInfo();
|
|
auto refFactory = CreateTemplateFactory(resolvingResult, controlTemplateTds, templateType.Obj(), tagPosition, errors);
|
|
auto createStyle = MakePtr<WfNewClassExpression>();
|
|
createStyle->type = GetTypeFromTypeInfo(TypeInfoRetriver<Ptr<GuiBindableDataEditor::Factory>>::CreateTypeInfo().Obj());
|
|
createStyle->arguments.Add(refFactory);
|
|
return createStyle;
|
|
}
|
|
|
|
Ptr<workflow::WfExpression> Deserialize(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, description::ITypeInfo* typeInfo, Ptr<workflow::WfExpression> valueExpression, GuiResourceTextPos tagPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto stringExpr = valueExpression.Cast<WfStringExpression>();
|
|
|
|
List<ITypeDescriptor*> tds;
|
|
GetItemTemplateType(resolvingResult, stringExpr->value.value, tds, tagPosition, errors);
|
|
|
|
if (IsDataVisualizerFactoryType(typeInfo))
|
|
{
|
|
return CreateDataVisualizerFactory(resolvingResult, tds, tagPosition, errors);
|
|
}
|
|
else if (IsDataEditorFactoryType(typeInfo))
|
|
{
|
|
return CreateDataEditorFactory(resolvingResult, tds, tagPosition, errors);
|
|
}
|
|
else
|
|
{
|
|
auto templateType = typeInfo->GetElementType()->GetGenericArgument(0);
|
|
return CreateTemplateFactory(resolvingResult, tds, templateType, tagPosition, errors);
|
|
}
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiItemPropertyDeserializer
|
|
***********************************************************************/
|
|
|
|
class GuiItemPropertyDeserializer : public Object, public IGuiInstanceDeserializer
|
|
{
|
|
protected:
|
|
Ptr<ITypeInfo> stringType;
|
|
|
|
bool IsItemPropertyType(ITypeInfo* propType)
|
|
{
|
|
if (propType->GetDecorator() == ITypeInfo::SharedPtr)
|
|
{
|
|
auto genericType = propType->GetElementType();
|
|
if (genericType->GetDecorator() == ITypeInfo::Generic && genericType->GetGenericArgumentCount() == 2)
|
|
{
|
|
if (genericType->GetElementType()->GetTypeDescriptor() == description::GetTypeDescriptor<IValueFunctionProxy>())
|
|
{
|
|
if (genericType->GetGenericArgument(1)->GetTypeDescriptor() == description::GetTypeDescriptor<Value>())
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool IsWritableItemPropertyType(ITypeInfo* propType)
|
|
{
|
|
if (propType->GetDecorator() == ITypeInfo::SharedPtr)
|
|
{
|
|
auto genericType = propType->GetElementType();
|
|
if (genericType->GetDecorator() == ITypeInfo::Generic && genericType->GetGenericArgumentCount() == 4)
|
|
{
|
|
if (genericType->GetElementType()->GetTypeDescriptor() == description::GetTypeDescriptor<IValueFunctionProxy>())
|
|
{
|
|
if (genericType->GetGenericArgument(1)->GetTypeDescriptor() == description::GetTypeDescriptor<Value>()
|
|
&& genericType->GetGenericArgument(3)->GetTypeDescriptor() == description::GetTypeDescriptor<bool>())
|
|
{
|
|
if (IsSameType(genericType->GetGenericArgument(0), genericType->GetGenericArgument(2)))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public:
|
|
GuiItemPropertyDeserializer()
|
|
{
|
|
stringType = TypeInfoRetriver<WString>::CreateTypeInfo();
|
|
}
|
|
|
|
bool CanDeserialize(description::ITypeInfo* typeInfo)override
|
|
{
|
|
return IsItemPropertyType(typeInfo) || IsWritableItemPropertyType(typeInfo);
|
|
}
|
|
|
|
description::ITypeInfo* DeserializeAs(description::ITypeInfo* typeInfo)override
|
|
{
|
|
return stringType.Obj();
|
|
}
|
|
|
|
Ptr<workflow::WfExpression> Deserialize(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, description::ITypeInfo* typeInfo, Ptr<workflow::WfExpression> valueExpression, GuiResourceTextPos tagPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto stringExpr = valueExpression.Cast<WfStringExpression>();
|
|
Ptr<WfExpression> propertyExpression;
|
|
{
|
|
propertyExpression = Workflow_ParseExpression(precompileContext, { resolvingResult.resource }, stringExpr->value.value, tagPosition, errors);
|
|
if (!propertyExpression)
|
|
{
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
vint indexItemType = resolvingResult.envVars.Keys().IndexOf(GlobalStringKey::Get(L"ItemType"));
|
|
if (indexItemType == -1)
|
|
{
|
|
auto error
|
|
= L"Precompile: env.ItemType must be specified before deserializing \""
|
|
+ stringExpr->value.value
|
|
+ L"\" to value of type \""
|
|
+ typeInfo->GetTypeFriendlyName()
|
|
+ L"\".";
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, tagPosition, error));
|
|
return nullptr;
|
|
}
|
|
|
|
Ptr<WfType> itemType;
|
|
{
|
|
const auto& values = resolvingResult.envVars.GetByIndex(indexItemType);
|
|
auto itemTypeValue = values[values.Count() - 1];
|
|
|
|
itemType = Workflow_ParseType(precompileContext, { resolvingResult.resource }, itemTypeValue->value, itemTypeValue->valuePosition, errors);
|
|
if (!itemType)
|
|
{
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
vint indexItemName = resolvingResult.envVars.Keys().IndexOf(GlobalStringKey::Get(L"ItemName"));
|
|
WString itemName(L"item", false);
|
|
if (indexItemName != -1)
|
|
{
|
|
const auto& values = resolvingResult.envVars.GetByIndex(indexItemName);
|
|
itemName = values[values.Count() - 1]->value;
|
|
}
|
|
|
|
if (auto refExpr = propertyExpression.Cast<WfReferenceExpression>())
|
|
{
|
|
if (refExpr->name.value != itemName)
|
|
{
|
|
auto refItem = MakePtr<WfReferenceExpression>();
|
|
refItem->name.value = itemName;
|
|
|
|
auto member = MakePtr<WfMemberExpression>();
|
|
member->parent = refItem;
|
|
member->name.value = refExpr->name.value;
|
|
|
|
propertyExpression = member;
|
|
}
|
|
}
|
|
|
|
bool isWritableItemProperty = IsWritableItemPropertyType(typeInfo);
|
|
|
|
auto funcDecl = MakePtr<WfFunctionDeclaration>();
|
|
funcDecl->anonymity = WfFunctionAnonymity::Anonymous;
|
|
{
|
|
auto genericType = typeInfo->GetElementType();
|
|
funcDecl->returnType = GetTypeFromTypeInfo(genericType->GetGenericArgument(0));
|
|
{
|
|
auto argument = MakePtr<WfFunctionArgument>();
|
|
argument->name.value = L"<item>";
|
|
argument->type = GetTypeFromTypeInfo(genericType->GetGenericArgument(1));
|
|
funcDecl->arguments.Add(argument);
|
|
}
|
|
|
|
if (isWritableItemProperty)
|
|
{
|
|
{
|
|
auto argument = MakePtr<WfFunctionArgument>();
|
|
argument->name.value = L"<value>";
|
|
argument->type = GetTypeFromTypeInfo(genericType->GetGenericArgument(2));
|
|
funcDecl->arguments.Add(argument);
|
|
}
|
|
{
|
|
auto argument = MakePtr<WfFunctionArgument>();
|
|
argument->name.value = L"<update>";
|
|
argument->type = GetTypeFromTypeInfo(genericType->GetGenericArgument(3));
|
|
funcDecl->arguments.Add(argument);
|
|
}
|
|
}
|
|
}
|
|
|
|
auto funcBlock = MakePtr<WfBlockStatement>();
|
|
funcDecl->statement = funcBlock;
|
|
|
|
{
|
|
auto refItem = MakePtr<WfReferenceExpression>();
|
|
refItem->name.value = L"<item>";
|
|
|
|
auto refCast = MakePtr<WfTypeCastingExpression>();
|
|
refCast->strategy = WfTypeCastingStrategy::Strong;
|
|
refCast->type = itemType;
|
|
refCast->expression = refItem;
|
|
|
|
auto varDecl = MakePtr<WfVariableDeclaration>();
|
|
varDecl->name.value = itemName;
|
|
varDecl->expression = refCast;
|
|
|
|
auto varStat = MakePtr<WfVariableStatement>();
|
|
varStat->variable = varDecl;
|
|
funcBlock->statements.Add(varStat);
|
|
}
|
|
|
|
Ptr<WfReturnStatement> returnStat;
|
|
{
|
|
returnStat = MakePtr<WfReturnStatement>();
|
|
returnStat->expression = propertyExpression;
|
|
}
|
|
|
|
if (isWritableItemProperty)
|
|
{
|
|
auto ifStat = MakePtr<WfIfStatement>();
|
|
funcBlock->statements.Add(ifStat);
|
|
{
|
|
auto refUpdate = MakePtr<WfReferenceExpression>();
|
|
refUpdate->name.value = L"<update>";
|
|
|
|
ifStat->expression = refUpdate;
|
|
}
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
ifStat->trueBranch = block;
|
|
|
|
{
|
|
auto refValue = MakePtr<WfReferenceExpression>();
|
|
refValue->name.value = L"<value>";
|
|
|
|
auto assignExpr = MakePtr<WfBinaryExpression>();
|
|
assignExpr->op = WfBinaryOperator::Assign;
|
|
assignExpr->first = CopyExpression(propertyExpression);
|
|
assignExpr->second = refValue;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = assignExpr;
|
|
block->statements.Add(stat);
|
|
}
|
|
{
|
|
auto returnStat = MakePtr<WfReturnStatement>();
|
|
block->statements.Add(returnStat);
|
|
|
|
auto returnType = typeInfo->GetElementType()->GetGenericArgument(0);
|
|
returnStat->expression = CreateDefaultValue(returnType);
|
|
}
|
|
}
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
ifStat->falseBranch = block;
|
|
|
|
block->statements.Add(returnStat);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
funcBlock->statements.Add(returnStat);
|
|
}
|
|
|
|
auto funcExpr = MakePtr<WfFunctionExpression>();
|
|
funcExpr->function = funcDecl;
|
|
return funcExpr;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiPredefinedInstanceDeserializersPlugin
|
|
***********************************************************************/
|
|
|
|
class GuiPredefinedInstanceDeserializersPlugin : public Object, public IGuiPlugin
|
|
{
|
|
public:
|
|
GuiPredefinedInstanceDeserializersPlugin()
|
|
{
|
|
}
|
|
|
|
void Load()override
|
|
{
|
|
}
|
|
|
|
void AfterLoad()override
|
|
{
|
|
IGuiInstanceLoaderManager* manager = GetInstanceLoaderManager();
|
|
manager->AddInstanceDeserializer(new GuiTemplatePropertyDeserializer);
|
|
manager->AddInstanceDeserializer(new GuiItemPropertyDeserializer);
|
|
}
|
|
|
|
void Unload()override
|
|
{
|
|
}
|
|
};
|
|
GUI_REGISTER_PLUGIN(GuiPredefinedInstanceDeserializersPlugin)
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
GUIINSTANCELOADER_PREDEFINEDTYPERESOLVERS.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
using namespace parsing;
|
|
using namespace parsing::xml;
|
|
using namespace workflow;
|
|
using namespace workflow::analyzer;
|
|
using namespace workflow::emitter;
|
|
using namespace workflow::runtime;
|
|
using namespace reflection::description;
|
|
using namespace collections;
|
|
using namespace stream;
|
|
|
|
using namespace controls;
|
|
|
|
class WorkflowVirtualScriptPositionVisitor : public traverse_visitor::ModuleVisitor
|
|
{
|
|
public:
|
|
GuiResourcePrecompileContext& context;
|
|
Ptr<types::ScriptPosition> sp;
|
|
|
|
WorkflowVirtualScriptPositionVisitor(GuiResourcePrecompileContext& _context)
|
|
:context(_context)
|
|
{
|
|
sp = Workflow_GetScriptPosition(context);
|
|
}
|
|
|
|
void Visit(WfVirtualExpression* node)override
|
|
{
|
|
traverse_visitor::ExpressionVisitor::Visit(node);
|
|
vint index = sp->nodePositions.Keys().IndexOf(node);
|
|
if (index != -1)
|
|
{
|
|
auto record = sp->nodePositions.Values()[index];
|
|
Workflow_RecordScriptPosition(context, record.position, node->expandedExpression, record.availableAfter);
|
|
}
|
|
}
|
|
|
|
void Visit(WfVirtualDeclaration* node)override
|
|
{
|
|
traverse_visitor::DeclarationVisitor::Visit(node);
|
|
vint index = sp->nodePositions.Keys().IndexOf(node);
|
|
if (index != -1)
|
|
{
|
|
auto record = sp->nodePositions.Values()[index];
|
|
FOREACH(Ptr<WfDeclaration>, decl, node->expandedDeclarations)
|
|
{
|
|
Workflow_RecordScriptPosition(context, record.position, decl, record.availableAfter);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
Ptr<GuiInstanceCompiledWorkflow> Workflow_GetModule(GuiResourcePrecompileContext& context, const WString& path)
|
|
{
|
|
return context.targetFolder->GetValueByPath(path).Cast<GuiInstanceCompiledWorkflow>();
|
|
}
|
|
|
|
void Workflow_AddModule(GuiResourcePrecompileContext& context, const WString& path, Ptr<WfModule> module, GuiInstanceCompiledWorkflow::AssemblyType assemblyType, GuiResourceTextPos tagPosition)
|
|
{
|
|
auto compiled = Workflow_GetModule(context, path);
|
|
if (!compiled)
|
|
{
|
|
compiled = new GuiInstanceCompiledWorkflow;
|
|
compiled->type = assemblyType;
|
|
context.targetFolder->CreateValueByPath(path, L"Workflow", compiled);
|
|
}
|
|
else
|
|
{
|
|
CHECK_ERROR(compiled->type == assemblyType, L"Workflow_AddModule(GuiResourcePrecompiledContext&, const WString&, GuiInstanceCompiledWorkflow::AssemblyType)#Unexpected assembly type.");
|
|
}
|
|
|
|
if (compiled)
|
|
{
|
|
GuiInstanceCompiledWorkflow::ModuleRecord record;
|
|
record.module = module;
|
|
record.position = tagPosition;
|
|
record.shared = assemblyType == GuiInstanceCompiledWorkflow::Shared;
|
|
compiled->modules.Add(record);
|
|
}
|
|
}
|
|
|
|
void Workflow_GenerateAssembly(GuiResourcePrecompileContext& context, const WString& path, GuiResourceError::List& errors, bool keepMetadata)
|
|
{
|
|
auto compiled = Workflow_GetModule(context, path);
|
|
if (!compiled)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!compiled->assembly)
|
|
{
|
|
List<WString> codes;
|
|
auto manager = Workflow_GetSharedManager();
|
|
manager->Clear(false, true);
|
|
|
|
auto addCode = [&codes](TextReader& reader)
|
|
{
|
|
vint row = 0;
|
|
WString code;
|
|
while (!reader.IsEnd())
|
|
{
|
|
auto rowHeader = itow(++row);
|
|
while (rowHeader.Length() < 6)
|
|
{
|
|
rowHeader = L" " + rowHeader;
|
|
}
|
|
code += rowHeader + L" : " + reader.ReadLine() + L"\r\n";
|
|
}
|
|
codes.Add(code);
|
|
};
|
|
|
|
for (vint i = 0; i < compiled->modules.Count(); i++)
|
|
{
|
|
manager->AddModule(compiled->modules[i].module);
|
|
}
|
|
|
|
if (manager->errors.Count() == 0)
|
|
{
|
|
manager->Rebuild(true);
|
|
}
|
|
|
|
if (manager->errors.Count() == 0)
|
|
{
|
|
compiled->assembly = GenerateAssembly(manager);
|
|
compiled->Initialize(true);
|
|
}
|
|
else
|
|
{
|
|
WorkflowVirtualScriptPositionVisitor visitor(context);
|
|
for (vint i = 0; i < compiled->modules.Count(); i++)
|
|
{
|
|
auto module = compiled->modules[i];
|
|
visitor.VisitField(module.module.Obj());
|
|
Workflow_RecordScriptPosition(context, module.position, module.module);
|
|
}
|
|
|
|
auto sp = Workflow_GetScriptPosition(context);
|
|
for (vint i = 0; i < manager->errors.Count(); i++)
|
|
{
|
|
auto error = manager->errors[i];
|
|
errors.Add({ sp->nodePositions[error->parsingTree].computedPosition, error->errorMessage });
|
|
}
|
|
}
|
|
|
|
if (keepMetadata)
|
|
{
|
|
compiled->metadata = Workflow_TransferSharedManager();
|
|
}
|
|
else
|
|
{
|
|
manager->Clear(false, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
Shared Script Type Resolver (Script)
|
|
***********************************************************************/
|
|
|
|
#define Path_Shared L"Workflow/Shared"
|
|
#define Path_TemporaryClass L"Workflow/TemporaryClass"
|
|
#define Path_InstanceClass L"Workflow/InstanceClass"
|
|
|
|
class GuiResourceSharedScriptTypeResolver
|
|
: public Object
|
|
, public IGuiResourceTypeResolver
|
|
, private IGuiResourceTypeResolver_Precompile
|
|
, private IGuiResourceTypeResolver_IndirectLoad
|
|
{
|
|
public:
|
|
WString GetType()override
|
|
{
|
|
return L"Script";
|
|
}
|
|
|
|
bool XmlSerializable()override
|
|
{
|
|
return true;
|
|
}
|
|
|
|
bool StreamSerializable()override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
WString GetPreloadType()override
|
|
{
|
|
return L"Xml";
|
|
}
|
|
|
|
bool IsDelayLoad()override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
vint GetMaxPassIndex()override
|
|
{
|
|
return Workflow_Max;
|
|
}
|
|
|
|
PassSupport GetPassSupport(vint passIndex)override
|
|
{
|
|
switch (passIndex)
|
|
{
|
|
case Workflow_Collect:
|
|
return PerResource;
|
|
case Workflow_Compile:
|
|
return PerPass;
|
|
default:
|
|
return NotSupported;
|
|
}
|
|
}
|
|
|
|
void PerResourcePrecompile(Ptr<GuiResourceItem> resource, GuiResourcePrecompileContext& context, GuiResourceError::List& errors)override
|
|
{
|
|
switch (context.passIndex)
|
|
{
|
|
case Workflow_Collect:
|
|
{
|
|
if (auto obj = resource->GetContent().Cast<GuiInstanceSharedScript>())
|
|
{
|
|
if (obj->language == L"Workflow")
|
|
{
|
|
if (auto module = Workflow_ParseModule(context, obj->codePosition.originalLocation, obj->code, obj->codePosition, errors))
|
|
{
|
|
Workflow_AddModule(context, Path_Shared, module, GuiInstanceCompiledWorkflow::Shared, obj->codePosition);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
void PerPassPrecompile(GuiResourcePrecompileContext& context, GuiResourceError::List& errors)override
|
|
{
|
|
switch (context.passIndex)
|
|
{
|
|
case Workflow_Compile:
|
|
Workflow_GenerateAssembly(context, Path_Shared, errors, false);
|
|
break;
|
|
}
|
|
}
|
|
|
|
IGuiResourceTypeResolver_Precompile* Precompile()override
|
|
{
|
|
return this;
|
|
}
|
|
|
|
IGuiResourceTypeResolver_IndirectLoad* IndirectLoad()override
|
|
{
|
|
return this;
|
|
}
|
|
|
|
Ptr<DescriptableObject> Serialize(Ptr<GuiResourceItem> resource, Ptr<DescriptableObject> content)override
|
|
{
|
|
if (auto obj = content.Cast<GuiInstanceSharedScript>())
|
|
{
|
|
return obj->SaveToXml();
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
Ptr<DescriptableObject> ResolveResource(Ptr<GuiResourceItem> resource, Ptr<GuiResourcePathResolver> resolver, GuiResourceError::List& errors)override
|
|
{
|
|
Ptr<XmlDocument> xml = resource->GetContent().Cast<XmlDocument>();
|
|
if (xml)
|
|
{
|
|
auto schema = GuiInstanceSharedScript::LoadFromXml(resource, xml, errors);
|
|
return schema;
|
|
}
|
|
return 0;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
Instance Type Resolver (Instance)
|
|
***********************************************************************/
|
|
|
|
class GuiResourceInstanceTypeResolver
|
|
: public Object
|
|
, public IGuiResourceTypeResolver
|
|
, private IGuiResourceTypeResolver_Precompile
|
|
, private IGuiResourceTypeResolver_IndirectLoad
|
|
{
|
|
public:
|
|
WString GetType()override
|
|
{
|
|
return L"Instance";
|
|
}
|
|
|
|
bool XmlSerializable()override
|
|
{
|
|
return true;
|
|
}
|
|
|
|
bool StreamSerializable()override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
WString GetPreloadType()override
|
|
{
|
|
return L"Xml";
|
|
}
|
|
|
|
bool IsDelayLoad()override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
vint GetMaxPassIndex()override
|
|
{
|
|
return Instance_Max;
|
|
}
|
|
|
|
PassSupport GetPassSupport(vint passIndex)override
|
|
{
|
|
switch (passIndex)
|
|
{
|
|
case Instance_CollectInstanceTypes:
|
|
case Instance_CollectEventHandlers:
|
|
case Instance_GenerateInstanceClass:
|
|
return PerResource;
|
|
case Instance_CompileInstanceTypes:
|
|
case Instance_CompileEventHandlers:
|
|
case Instance_CompileInstanceClass:
|
|
return PerPass;
|
|
default:
|
|
return NotSupported;
|
|
}
|
|
}
|
|
|
|
#define ENSURE_ASSEMBLY_EXISTS(PATH)\
|
|
if (auto compiled = Workflow_GetModule(context, PATH))\
|
|
{\
|
|
if (!compiled->assembly)\
|
|
{\
|
|
break;\
|
|
}\
|
|
}\
|
|
else\
|
|
{\
|
|
break;\
|
|
}\
|
|
|
|
#define UNLOAD_ASSEMBLY(PATH)\
|
|
if (auto compiled = Workflow_GetModule(context, PATH))\
|
|
{\
|
|
compiled->context = nullptr;\
|
|
}\
|
|
|
|
#define DELETE_ASSEMBLY(PATH)\
|
|
if (auto compiled = Workflow_GetModule(context, PATH))\
|
|
{\
|
|
compiled->context = nullptr;\
|
|
compiled->assembly = nullptr;\
|
|
}\
|
|
|
|
void PerResourcePrecompile(Ptr<GuiResourceItem> resource, GuiResourcePrecompileContext& context, GuiResourceError::List& errors)override
|
|
{
|
|
switch (context.passIndex)
|
|
{
|
|
case Instance_CollectEventHandlers:
|
|
ENSURE_ASSEMBLY_EXISTS(Path_TemporaryClass)
|
|
case Instance_CollectInstanceTypes:
|
|
{
|
|
if (auto obj = resource->GetContent().Cast<GuiInstanceContext>())
|
|
{
|
|
if (obj->className == L"")
|
|
{
|
|
errors.Add(GuiResourceError({ resource }, obj->tagPosition,
|
|
L"Precompile: Instance \"" +
|
|
(obj->instance->typeNamespace == GlobalStringKey::Empty
|
|
? obj->instance->typeName.ToString()
|
|
: obj->instance->typeNamespace.ToString() + L":" + obj->instance->typeName.ToString()
|
|
) +
|
|
L"\" should have the class name specified in the ref.Class attribute."));
|
|
}
|
|
|
|
obj->ApplyStyles(resource, context.resolver, errors);
|
|
|
|
types::ResolvingResult resolvingResult;
|
|
resolvingResult.resource = resource;
|
|
resolvingResult.context = obj;
|
|
if (auto module = Workflow_GenerateInstanceClass(context, resolvingResult, errors, context.passIndex))
|
|
{
|
|
Workflow_AddModule(context, Path_TemporaryClass, module, GuiInstanceCompiledWorkflow::TemporaryClass, obj->tagPosition);
|
|
}
|
|
|
|
if (context.passIndex == Instance_CollectInstanceTypes)
|
|
{
|
|
auto record = context.targetFolder->GetValueByPath(L"ClassNameRecord").Cast<GuiResourceClassNameRecord>();
|
|
if (!record)
|
|
{
|
|
record = MakePtr<GuiResourceClassNameRecord>();
|
|
context.targetFolder->CreateValueByPath(L"ClassNameRecord", L"ClassNameRecord", record);
|
|
}
|
|
record->classNames.Add(obj->className);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case Instance_GenerateInstanceClass:
|
|
{
|
|
ENSURE_ASSEMBLY_EXISTS(Path_TemporaryClass)
|
|
if (auto obj = resource->GetContent().Cast<GuiInstanceContext>())
|
|
{
|
|
vint previousErrorCount = errors.Count();
|
|
|
|
types::ResolvingResult resolvingResult;
|
|
resolvingResult.resource = resource;
|
|
resolvingResult.context = obj;
|
|
resolvingResult.rootTypeInfo = Workflow_CollectReferences(context, resolvingResult, errors);
|
|
|
|
if (errors.Count() == previousErrorCount)
|
|
{
|
|
if (auto ctorModule = Workflow_PrecompileInstanceContext(context, resolvingResult, errors))
|
|
{
|
|
if (auto instanceModule = Workflow_GenerateInstanceClass(context, resolvingResult, errors, context.passIndex))
|
|
{
|
|
Workflow_AddModule(context, Path_InstanceClass, ctorModule, GuiInstanceCompiledWorkflow::InstanceClass, obj->tagPosition);
|
|
Workflow_AddModule(context, Path_InstanceClass, instanceModule, GuiInstanceCompiledWorkflow::InstanceClass, obj->tagPosition);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
void PerPassPrecompile(GuiResourcePrecompileContext& context, GuiResourceError::List& errors)override
|
|
{
|
|
WString path;
|
|
switch (context.passIndex)
|
|
{
|
|
case Instance_CompileInstanceTypes:
|
|
DELETE_ASSEMBLY(Path_Shared)
|
|
path = Path_TemporaryClass;
|
|
break;
|
|
case Instance_CompileEventHandlers:
|
|
DELETE_ASSEMBLY(Path_TemporaryClass)
|
|
path = Path_TemporaryClass;
|
|
break;
|
|
case Instance_CompileInstanceClass:
|
|
UNLOAD_ASSEMBLY(Path_TemporaryClass)
|
|
path = Path_InstanceClass;
|
|
break;
|
|
default:
|
|
return;
|
|
}
|
|
|
|
auto sharedCompiled = Workflow_GetModule(context, Path_Shared);
|
|
auto compiled = Workflow_GetModule(context, path);
|
|
if (sharedCompiled && compiled)
|
|
{
|
|
CopyFrom(
|
|
compiled->modules,
|
|
From(sharedCompiled->modules)
|
|
.Where([](const GuiInstanceCompiledWorkflow::ModuleRecord& module)
|
|
{
|
|
return module.shared;
|
|
}),
|
|
true
|
|
);
|
|
}
|
|
|
|
switch (context.passIndex)
|
|
{
|
|
case Instance_CompileInstanceTypes:
|
|
Workflow_GenerateAssembly(context, path, errors, false);
|
|
compiled->modules.Clear();
|
|
break;
|
|
case Instance_CompileEventHandlers:
|
|
Workflow_GenerateAssembly(context, path, errors, false);
|
|
break;
|
|
case Instance_CompileInstanceClass:
|
|
Workflow_GenerateAssembly(context, path, errors, true);
|
|
break;
|
|
default:;
|
|
}
|
|
Workflow_ClearScriptPosition(context);
|
|
GetInstanceLoaderManager()->ClearReflectionCache();
|
|
}
|
|
|
|
#undef DELETE_ASSEMBLY
|
|
#undef UNLOAD_ASSEMBLY
|
|
#undef ENSURE_ASSEMBLY_EXISTS
|
|
|
|
IGuiResourceTypeResolver_Precompile* Precompile()override
|
|
{
|
|
return this;
|
|
}
|
|
|
|
IGuiResourceTypeResolver_IndirectLoad* IndirectLoad()override
|
|
{
|
|
return this;
|
|
}
|
|
|
|
Ptr<DescriptableObject> Serialize(Ptr<GuiResourceItem> resource, Ptr<DescriptableObject> content)override
|
|
{
|
|
if (auto obj = content.Cast<GuiInstanceContext>())
|
|
{
|
|
return obj->SaveToXml();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
Ptr<DescriptableObject> ResolveResource(Ptr<GuiResourceItem> resource, Ptr<GuiResourcePathResolver> resolver, GuiResourceError::List& errors)override
|
|
{
|
|
Ptr<XmlDocument> xml = resource->GetContent().Cast<XmlDocument>();
|
|
if (xml)
|
|
{
|
|
Ptr<GuiInstanceContext> context = GuiInstanceContext::LoadFromXml(resource, xml, errors);
|
|
return context;
|
|
}
|
|
return 0;
|
|
}
|
|
};
|
|
|
|
#undef Path_Shared
|
|
#undef Path_TemporaryClass
|
|
#undef Path_InstanceClass
|
|
|
|
/***********************************************************************
|
|
Instance Style Type Resolver (InstanceStyle)
|
|
***********************************************************************/
|
|
|
|
class GuiResourceInstanceStyleResolver
|
|
: public Object
|
|
, public IGuiResourceTypeResolver
|
|
, private IGuiResourceTypeResolver_IndirectLoad
|
|
{
|
|
public:
|
|
WString GetType()override
|
|
{
|
|
return L"InstanceStyle";
|
|
}
|
|
|
|
bool XmlSerializable()override
|
|
{
|
|
return true;
|
|
}
|
|
|
|
bool StreamSerializable()override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
WString GetPreloadType()override
|
|
{
|
|
return L"Xml";
|
|
}
|
|
|
|
bool IsDelayLoad()override
|
|
{
|
|
return false;
|
|
}
|
|
|
|
IGuiResourceTypeResolver_IndirectLoad* IndirectLoad()override
|
|
{
|
|
return this;
|
|
}
|
|
|
|
Ptr<DescriptableObject> Serialize(Ptr<GuiResourceItem> resource, Ptr<DescriptableObject> content)override
|
|
{
|
|
if (auto obj = content.Cast<GuiInstanceStyleContext>())
|
|
{
|
|
return obj->SaveToXml();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
Ptr<DescriptableObject> ResolveResource(Ptr<GuiResourceItem> resource, Ptr<GuiResourcePathResolver> resolver, GuiResourceError::List& errors)override
|
|
{
|
|
Ptr<XmlDocument> xml = resource->GetContent().Cast<XmlDocument>();
|
|
if (xml)
|
|
{
|
|
auto context = GuiInstanceStyleContext::LoadFromXml(resource, xml, errors);
|
|
return context;
|
|
}
|
|
return 0;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
Plugin
|
|
***********************************************************************/
|
|
|
|
class GuiCompilerTypeResolversPlugin : public Object, public IGuiPlugin
|
|
{
|
|
public:
|
|
GuiCompilerTypeResolversPlugin()
|
|
{
|
|
}
|
|
|
|
void Load()override
|
|
{
|
|
}
|
|
|
|
void AfterLoad()override
|
|
{
|
|
IGuiResourceResolverManager* manager = GetResourceResolverManager();
|
|
manager->SetTypeResolver(new GuiResourceInstanceTypeResolver);
|
|
manager->SetTypeResolver(new GuiResourceInstanceStyleResolver);
|
|
manager->SetTypeResolver(new GuiResourceSharedScriptTypeResolver);
|
|
}
|
|
|
|
void Unload()override
|
|
{
|
|
}
|
|
};
|
|
GUI_REGISTER_PLUGIN(GuiCompilerTypeResolversPlugin)
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
GUIINSTANCEREPRESENTATION.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
using namespace collections;
|
|
using namespace parsing;
|
|
using namespace parsing::xml;
|
|
using namespace templates;
|
|
using namespace stream;
|
|
|
|
/***********************************************************************
|
|
GuiValueRepr
|
|
***********************************************************************/
|
|
|
|
void GuiValueRepr::CloneBody(Ptr<GuiValueRepr> repr)
|
|
{
|
|
repr->fromStyle = fromStyle;
|
|
repr->tagPosition = tagPosition;
|
|
}
|
|
|
|
/***********************************************************************
|
|
GuiTextRepr
|
|
***********************************************************************/
|
|
|
|
Ptr<GuiValueRepr> GuiTextRepr::Clone()
|
|
{
|
|
auto repr = MakePtr<GuiTextRepr>();
|
|
GuiValueRepr::CloneBody(repr);
|
|
repr->text = text;
|
|
return repr;
|
|
}
|
|
|
|
void GuiTextRepr::FillXml(Ptr<parsing::xml::XmlElement> xml)
|
|
{
|
|
if (!fromStyle)
|
|
{
|
|
auto xmlText = MakePtr<XmlText>();
|
|
xmlText->content.value = text;
|
|
xml->subNodes.Add(xmlText);
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
GuiAttSetterRepr
|
|
***********************************************************************/
|
|
|
|
void GuiAttSetterRepr::CloneBody(Ptr<GuiAttSetterRepr> repr)
|
|
{
|
|
GuiValueRepr::CloneBody(repr);
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, name, index, setters.Keys())
|
|
{
|
|
auto src = setters.Values()[index];
|
|
auto dst = MakePtr<SetterValue>();
|
|
|
|
dst->binding = src->binding;
|
|
dst->attPosition = src->attPosition;
|
|
FOREACH(Ptr<GuiValueRepr>, value, src->values)
|
|
{
|
|
dst->values.Add(value->Clone());
|
|
}
|
|
|
|
repr->setters.Add(name, dst);
|
|
}
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, name, index, eventHandlers.Keys())
|
|
{
|
|
auto src = eventHandlers.Values()[index];
|
|
auto dst = MakePtr<EventValue>();
|
|
|
|
dst->binding = src->binding;
|
|
dst->value = src->value;
|
|
dst->fromStyle = src->fromStyle;
|
|
dst->attPosition = src->attPosition;
|
|
dst->valuePosition = src->valuePosition;
|
|
|
|
repr->eventHandlers.Add(name, dst);
|
|
}
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, name, index, environmentVariables.Keys())
|
|
{
|
|
auto src = environmentVariables.Values()[index];
|
|
auto dst = MakePtr<EnvVarValue>();
|
|
|
|
dst->value = src->value;
|
|
dst->fromStyle = src->fromStyle;
|
|
dst->attPosition = src->attPosition;
|
|
dst->valuePosition = src->valuePosition;
|
|
|
|
repr->environmentVariables.Add(name, dst);
|
|
}
|
|
|
|
repr->instanceName = instanceName;
|
|
}
|
|
|
|
Ptr<GuiValueRepr> GuiAttSetterRepr::Clone()
|
|
{
|
|
auto repr = MakePtr<GuiAttSetterRepr>();
|
|
GuiAttSetterRepr::CloneBody(repr);
|
|
repr->fromStyle = fromStyle;
|
|
return repr;
|
|
}
|
|
|
|
void GuiAttSetterRepr::FillXml(Ptr<parsing::xml::XmlElement> xml)
|
|
{
|
|
if (!fromStyle)
|
|
{
|
|
if (instanceName != GlobalStringKey::Empty)
|
|
{
|
|
auto attName = MakePtr<XmlAttribute>();
|
|
attName->name.value = L"ref.Name";
|
|
attName->value.value = instanceName.ToString();
|
|
xml->attributes.Add(attName);
|
|
}
|
|
|
|
for (vint i = 0; i < setters.Count(); i++)
|
|
{
|
|
auto key = setters.Keys()[i];
|
|
auto value = setters.Values()[i];
|
|
if (key == GlobalStringKey::Empty)
|
|
{
|
|
FOREACH(Ptr<GuiValueRepr>, repr, value->values)
|
|
{
|
|
repr->FillXml(xml);
|
|
}
|
|
}
|
|
else if (From(value->values).Any([](Ptr<GuiValueRepr> value) {return !value->fromStyle; }))
|
|
{
|
|
bool containsElement = From(value->values)
|
|
.Any([](Ptr<GuiValueRepr> value)
|
|
{
|
|
return !value->fromStyle && !value.Cast<GuiTextRepr>();
|
|
});
|
|
|
|
if (containsElement)
|
|
{
|
|
auto xmlProp = MakePtr<XmlElement>();
|
|
xmlProp->name.value = L"att." + key.ToString();
|
|
if (value->binding != GlobalStringKey::Empty)
|
|
{
|
|
xmlProp->name.value += L"-" + value->binding.ToString();
|
|
}
|
|
|
|
FOREACH(Ptr<GuiValueRepr>, repr, value->values)
|
|
{
|
|
if (!repr.Cast<GuiTextRepr>())
|
|
{
|
|
repr->FillXml(xmlProp);
|
|
}
|
|
}
|
|
xml->subNodes.Add(xmlProp);
|
|
}
|
|
else
|
|
{
|
|
FOREACH(Ptr<GuiValueRepr>, repr, value->values)
|
|
{
|
|
if (auto textRepr = repr.Cast<GuiTextRepr>())
|
|
{
|
|
if (!textRepr->fromStyle)
|
|
{
|
|
auto att = MakePtr<XmlAttribute>();
|
|
att->name.value = key.ToString();
|
|
if (value->binding != GlobalStringKey::Empty)
|
|
{
|
|
att->name.value += L"-" + value->binding.ToString();
|
|
}
|
|
att->value.value = textRepr->text;
|
|
xml->attributes.Add(att);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for (vint i = 0; i < eventHandlers.Count(); i++)
|
|
{
|
|
auto key = eventHandlers.Keys()[i];
|
|
auto value = eventHandlers.Values()[i];
|
|
if (!value->fromStyle)
|
|
{
|
|
auto xmlEvent = MakePtr<XmlElement>();
|
|
xmlEvent->name.value = L"ev." + key.ToString();
|
|
if (value->binding != GlobalStringKey::Empty)
|
|
{
|
|
xmlEvent->name.value += L"-" + value->binding.ToString();
|
|
}
|
|
xml->subNodes.Add(xmlEvent);
|
|
|
|
auto xmlText = MakePtr<XmlCData>();
|
|
xmlText->content.value = value->value;
|
|
xmlEvent->subNodes.Add(xmlText);
|
|
}
|
|
}
|
|
|
|
for (vint i = 0; i < environmentVariables.Count(); i++)
|
|
{
|
|
auto key = environmentVariables.Keys()[i];
|
|
auto value = environmentVariables.Values()[i];
|
|
if (!value->fromStyle)
|
|
{
|
|
auto xmlEnvVar = MakePtr<XmlElement>();
|
|
xmlEnvVar->name.value = L"env." + key.ToString();
|
|
xml->subNodes.Add(xmlEnvVar);
|
|
|
|
auto xmlText = MakePtr<XmlText>();
|
|
xmlText->content.value = value->value;
|
|
xmlEnvVar->subNodes.Add(xmlText);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
GuiConstructorRepr
|
|
***********************************************************************/
|
|
|
|
Ptr<GuiValueRepr> GuiConstructorRepr::Clone()
|
|
{
|
|
auto repr = MakePtr<GuiConstructorRepr>();
|
|
GuiAttSetterRepr::CloneBody(repr);
|
|
repr->fromStyle = fromStyle;
|
|
repr->typeNamespace = typeNamespace;
|
|
repr->typeName = typeName;
|
|
repr->styleName = styleName;
|
|
return repr;
|
|
}
|
|
|
|
void GuiConstructorRepr::FillXml(Ptr<parsing::xml::XmlElement> xml)
|
|
{
|
|
if (!fromStyle)
|
|
{
|
|
auto xmlCtor = MakePtr<XmlElement>();
|
|
if (typeNamespace == GlobalStringKey::Empty)
|
|
{
|
|
xmlCtor->name.value = typeName.ToString();
|
|
}
|
|
else
|
|
{
|
|
xmlCtor->name.value = typeNamespace.ToString() + L":" + typeName.ToString();
|
|
}
|
|
|
|
if (styleName)
|
|
{
|
|
auto attStyle = MakePtr<XmlAttribute>();
|
|
attStyle->name.value = L"ref.Style";
|
|
attStyle->value.value = styleName.Value();
|
|
xml->attributes.Add(attStyle);
|
|
}
|
|
|
|
GuiAttSetterRepr::FillXml(xmlCtor);
|
|
xml->subNodes.Add(xmlCtor);
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
GuiInstanceContext
|
|
***********************************************************************/
|
|
|
|
void GuiInstanceContext::CollectDefaultAttributes(Ptr<GuiResourceItem> resource, GuiAttSetterRepr::ValueList& values, Ptr<parsing::xml::XmlElement> xml, GuiResourceError::List& errors)
|
|
{
|
|
if (auto parser = GetParserManager()->GetParser<ElementName>(L"INSTANCE-ELEMENT-NAME"))
|
|
{
|
|
// test if there is only one text value in the xml
|
|
if (xml->subNodes.Count() == 1)
|
|
{
|
|
if (Ptr<XmlText> text = xml->subNodes[0].Cast<XmlText>())
|
|
{
|
|
Ptr<GuiTextRepr> value = new GuiTextRepr;
|
|
value->text = text->content.value;
|
|
value->tagPosition = { {resource},text->content.codeRange.start };
|
|
values.Add(value);
|
|
}
|
|
else if (Ptr<XmlCData> text = xml->subNodes[0].Cast<XmlCData>())
|
|
{
|
|
Ptr<GuiTextRepr> value = new GuiTextRepr;
|
|
value->text = text->content.value;
|
|
value->tagPosition = { {resource},text->content.codeRange.start };
|
|
value->tagPosition.column += 9; // <![CDATA[
|
|
values.Add(value);
|
|
}
|
|
}
|
|
|
|
// collect default attributes
|
|
FOREACH(Ptr<XmlElement>, element, XmlGetElements(xml))
|
|
{
|
|
if(auto name = parser->Parse({ resource }, element->name.value, element->codeRange.start, errors))
|
|
{
|
|
if (name->IsCtorName())
|
|
{
|
|
// collect constructor values in the default attribute setter
|
|
auto ctor = LoadCtor(resource, element, errors);
|
|
if (ctor)
|
|
{
|
|
values.Add(ctor);
|
|
}
|
|
}
|
|
else if (!name->IsPropertyElementName() && !name->IsEventElementName())
|
|
{
|
|
errors.Add(GuiResourceError({ {resource},element->codeRange.start }, L"Unknown element name: \"" + element->name.value + L"\"."));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void GuiInstanceContext::CollectAttributes(Ptr<GuiResourceItem> resource, GuiAttSetterRepr::SetteValuerMap& setters, Ptr<parsing::xml::XmlElement> xml, GuiResourceError::List& errors)
|
|
{
|
|
if (auto parser = GetParserManager()->GetParser<ElementName>(L"INSTANCE-ELEMENT-NAME"))
|
|
{
|
|
Ptr<GuiAttSetterRepr::SetterValue> defaultValue = new GuiAttSetterRepr::SetterValue;
|
|
|
|
// collect default attributes
|
|
CollectDefaultAttributes(resource, defaultValue->values, xml, errors);
|
|
if (defaultValue->values.Count() > 0)
|
|
{
|
|
setters.Add(GlobalStringKey::Empty, defaultValue);
|
|
}
|
|
|
|
// collect values
|
|
FOREACH(Ptr<XmlElement>, element, XmlGetElements(xml))
|
|
{
|
|
if(auto name = parser->Parse({ resource }, element->name.value, element->name.codeRange.start, errors))
|
|
{
|
|
if (name->IsPropertyElementName())
|
|
{
|
|
// collect a value as a new attribute setter
|
|
if (setters.Keys().Contains(GlobalStringKey::Get(name->name)))
|
|
{
|
|
errors.Add(GuiResourceError({ {resource},element->codeRange.start }, L"Duplicated property \"" + name->name + L"\"."));
|
|
}
|
|
else
|
|
{
|
|
Ptr<GuiAttSetterRepr::SetterValue> sv = new GuiAttSetterRepr::SetterValue;
|
|
sv->binding = GlobalStringKey::Get(name->binding);
|
|
sv->attPosition = { {resource},element->codeRange.start };
|
|
|
|
if (name->binding == L"set")
|
|
{
|
|
// if the binding is "set", it means that this element is a complete setter element
|
|
Ptr<GuiAttSetterRepr> setter = new GuiAttSetterRepr;
|
|
FillAttSetter(resource, setter, element, errors);
|
|
sv->values.Add(setter);
|
|
}
|
|
else
|
|
{
|
|
// if the binding is not "set", then this is a single-value attribute or a colection attribute
|
|
// fill all data into this attribute
|
|
CollectDefaultAttributes(resource, sv->values, element, errors);
|
|
}
|
|
|
|
if (sv->values.Count() > 0)
|
|
{
|
|
setters.Add(GlobalStringKey::Get(name->name), sv);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void GuiInstanceContext::CollectEvents(Ptr<GuiResourceItem> resource, GuiAttSetterRepr::EventHandlerMap& eventHandlers, Ptr<parsing::xml::XmlElement> xml, GuiResourceError::List& errors)
|
|
{
|
|
if (auto parser = GetParserManager()->GetParser<ElementName>(L"INSTANCE-ELEMENT-NAME"))
|
|
{
|
|
// collect values
|
|
FOREACH(Ptr<XmlElement>, element, XmlGetElements(xml))
|
|
{
|
|
if(auto name = parser->Parse({ resource }, element->name.value, element->name.codeRange.start, errors))
|
|
{
|
|
if (name->IsEventElementName())
|
|
{
|
|
// collect a value as an event setter
|
|
if (eventHandlers.Keys().Contains(GlobalStringKey::Get(name->name)))
|
|
{
|
|
errors.Add(GuiResourceError({ {resource},element->codeRange.start }, L"Duplicated event \"" + name->name + L"\"."));
|
|
}
|
|
else
|
|
{
|
|
// test if there is only one text value in the xml
|
|
if (element->subNodes.Count() == 1)
|
|
{
|
|
if (Ptr<XmlText> text = element->subNodes[0].Cast<XmlText>())
|
|
{
|
|
auto value = MakePtr<GuiAttSetterRepr::EventValue>();
|
|
value->binding = GlobalStringKey::Get(name->binding);
|
|
value->value = text->content.value;
|
|
value->attPosition = { {resource},element->codeRange.start };
|
|
value->valuePosition = { {resource},text->content.codeRange.start };
|
|
eventHandlers.Add(GlobalStringKey::Get(name->name), value);
|
|
if (text->content.codeRange.start.row != text->content.codeRange.end.row)
|
|
{
|
|
errors.Add(GuiResourceError({ {resource},element->codeRange.start }, L"Multiple lines script should be contained in a CDATA section."));
|
|
}
|
|
goto EVENT_SUCCESS;
|
|
}
|
|
else if (Ptr<XmlCData> text = element->subNodes[0].Cast<XmlCData>())
|
|
{
|
|
auto value = MakePtr<GuiAttSetterRepr::EventValue>();
|
|
value->binding = GlobalStringKey::Get(name->binding);
|
|
value->value = text->content.value;
|
|
value->attPosition = { {resource},element->codeRange.start };
|
|
value->valuePosition = { {resource},text->content.codeRange.start };
|
|
value->valuePosition.column += 9; // <![CDATA[
|
|
eventHandlers.Add(GlobalStringKey::Get(name->name), value);
|
|
}
|
|
goto EVENT_SUCCESS;
|
|
}
|
|
errors.Add(GuiResourceError({ {resource},element->codeRange.start }, L"Event script should be contained in a text or CDATA section."));
|
|
EVENT_SUCCESS:;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void GuiInstanceContext::FillAttSetter(Ptr<GuiResourceItem> resource, Ptr<GuiAttSetterRepr> setter, Ptr<parsing::xml::XmlElement> xml, GuiResourceError::List& errors)
|
|
{
|
|
if (auto parser = GetParserManager()->GetParser<ElementName>(L"INSTANCE-ELEMENT-NAME"))
|
|
{
|
|
setter->tagPosition = { {resource},xml->codeRange.start };
|
|
|
|
// collect attributes as setters
|
|
FOREACH(Ptr<XmlAttribute>, att, xml->attributes)
|
|
{
|
|
if(auto name = parser->Parse({ resource }, att->name.value, att->name.codeRange.start, errors))
|
|
{
|
|
if (name->IsReferenceAttributeName())
|
|
{
|
|
// collect reference attributes
|
|
if (name->name == L"Name")
|
|
{
|
|
setter->instanceName = GlobalStringKey::Get(att->value.value);
|
|
}
|
|
}
|
|
else if (name->IsEnvironmentAttributeName())
|
|
{
|
|
// collect environment variables
|
|
if (setter->environmentVariables.Keys().Contains(GlobalStringKey::Get(name->name)))
|
|
{
|
|
errors.Add(GuiResourceError({ {resource},att->name.codeRange.start }, L"Duplicated environment variable \"" + name->name + L"\"."));
|
|
}
|
|
else
|
|
{
|
|
auto value = MakePtr<GuiAttSetterRepr::EnvVarValue>();
|
|
value->value = att->value.value;
|
|
value->attPosition = { {resource},att->codeRange.start };
|
|
value->valuePosition = { {resource},att->value.codeRange.start };
|
|
value->valuePosition.column += 1;
|
|
setter->environmentVariables.Add(GlobalStringKey::Get(name->name), value);
|
|
}
|
|
}
|
|
else if (name->IsPropertyAttributeName())
|
|
{
|
|
// collect attributes setters
|
|
if (setter->setters.Keys().Contains(GlobalStringKey::Get(name->name)))
|
|
{
|
|
errors.Add(GuiResourceError({ {resource},att->name.codeRange.start }, L"Duplicated property \"" + name->name + L"\"."));
|
|
}
|
|
else
|
|
{
|
|
auto sv = MakePtr<GuiAttSetterRepr::SetterValue>();
|
|
sv->binding = GlobalStringKey::Get(name->binding);
|
|
sv->attPosition = { {resource},att->codeRange.start };
|
|
setter->setters.Add(GlobalStringKey::Get(name->name), sv);
|
|
|
|
Ptr<GuiTextRepr> value = new GuiTextRepr;
|
|
value->text = att->value.value;
|
|
value->tagPosition = { {resource},att->value.codeRange.start };
|
|
value->tagPosition.column += 1;
|
|
sv->values.Add(value);
|
|
}
|
|
}
|
|
else if (name->IsEventAttributeName())
|
|
{
|
|
// collect event setters
|
|
if (setter->eventHandlers.Keys().Contains(GlobalStringKey::Get(name->name)))
|
|
{
|
|
errors.Add(GuiResourceError({ {resource},att->name.codeRange.start }, L"Duplicated event \"" + name->name + L"\"."));
|
|
}
|
|
else
|
|
{
|
|
auto value = MakePtr<GuiAttSetterRepr::EventValue>();
|
|
value->binding = GlobalStringKey::Get(name->binding);
|
|
value->value = att->value.value;
|
|
value->attPosition = { {resource},att->codeRange.start };
|
|
value->valuePosition = { {resource},att->value.codeRange.start };
|
|
value->valuePosition.column += 1;
|
|
setter->eventHandlers.Add(GlobalStringKey::Get(name->name), value);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ {resource},att->name.codeRange.start }, L"Unknown attribute name: \"" + att->name.value + L"\"."));
|
|
}
|
|
}
|
|
}
|
|
|
|
// collect attributes and events
|
|
CollectAttributes(resource, setter->setters, xml, errors);
|
|
CollectEvents(resource, setter->eventHandlers, xml, errors);
|
|
}
|
|
}
|
|
|
|
Ptr<GuiConstructorRepr> GuiInstanceContext::LoadCtor(Ptr<GuiResourceItem> resource, Ptr<parsing::xml::XmlElement> xml, GuiResourceError::List& errors)
|
|
{
|
|
if (auto parser = GetParserManager()->GetParser<ElementName>(L"INSTANCE-ELEMENT-NAME"))
|
|
{
|
|
if(auto ctorName = parser->Parse({ resource }, xml->name.value, xml->name.codeRange.start, errors))
|
|
{
|
|
if (ctorName->IsCtorName())
|
|
{
|
|
Ptr<GuiConstructorRepr> ctor = new GuiConstructorRepr;
|
|
ctor->typeNamespace = GlobalStringKey::Get(ctorName->namespaceName);
|
|
ctor->typeName = GlobalStringKey::Get(ctorName->name);
|
|
// collect attributes as setters
|
|
FOREACH(Ptr<XmlAttribute>, att, xml->attributes)
|
|
{
|
|
if(auto attName = parser->Parse({ resource }, att->name.value, att->name.codeRange.start, errors))
|
|
{
|
|
if (attName->IsReferenceAttributeName())
|
|
{
|
|
if (attName->name == L"Style")
|
|
{
|
|
ctor->styleName = att->value.value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
FillAttSetter(resource, ctor, xml, errors);
|
|
return ctor;
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ {resource},xml->codeRange.start }, L"Wrong constructor name \"" + xml->name.value + L"\"."));
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
Ptr<GuiInstanceContext> GuiInstanceContext::LoadFromXml(Ptr<GuiResourceItem> resource, Ptr<parsing::xml::XmlDocument> xml, GuiResourceError::List& errors)
|
|
{
|
|
Ptr<GuiInstanceContext> context = new GuiInstanceContext;
|
|
context->tagPosition = { {resource},xml->rootElement->codeRange.start };
|
|
|
|
if (xml->rootElement->name.value == L"Instance")
|
|
{
|
|
if (auto codeBehindAttr = XmlGetAttribute(xml->rootElement, L"ref.CodeBehind"))
|
|
{
|
|
context->codeBehind = codeBehindAttr->value.value == L"true";
|
|
}
|
|
|
|
// load type name
|
|
if (auto classAttr = XmlGetAttribute(xml->rootElement, L"ref.Class"))
|
|
{
|
|
context->className = classAttr->value.value;
|
|
context->classPosition = { {resource},classAttr->codeRange.start };
|
|
}
|
|
|
|
// load style names
|
|
if (auto styleAttr = XmlGetAttribute(xml->rootElement, L"ref.Styles"))
|
|
{
|
|
SplitBySemicolon(styleAttr->value.value, context->stylePaths);
|
|
context->stylePosition = { {resource},styleAttr->codeRange.start };
|
|
}
|
|
|
|
// load namespaces
|
|
List<Ptr<XmlAttribute>> namespaceAttributes;
|
|
CopyFrom(namespaceAttributes, xml->rootElement->attributes);
|
|
if (!XmlGetAttribute(xml->rootElement, L"xmlns"))
|
|
{
|
|
Ptr<XmlAttribute> att = new XmlAttribute;
|
|
att->name.value = L"xmlns";
|
|
att->value.value =
|
|
L"presentation::controls::Gui*;"
|
|
L"presentation::elements::Gui*Element;"
|
|
L"presentation::compositions::Gui*Composition;"
|
|
L"presentation::compositions::Gui*;"
|
|
L"presentation::templates::Gui*;"
|
|
L"system::*;"
|
|
L"system::reflection::*;"
|
|
L"presentation::*;"
|
|
L"presentation::Gui*;"
|
|
L"presentation::controls::*;"
|
|
L"presentation::controls::list::*;"
|
|
L"presentation::controls::tree::*;"
|
|
L"presentation::elements::*;"
|
|
L"presentation::elements::Gui*;"
|
|
L"presentation::elements::text::*;"
|
|
L"presentation::compositions::*;"
|
|
L"presentation::templates::*";
|
|
namespaceAttributes.Add(att);
|
|
}
|
|
FOREACH(Ptr<XmlAttribute>, att, namespaceAttributes)
|
|
{
|
|
// check if the attribute defines a namespace
|
|
WString attName = att->name.value;
|
|
if (attName.Length() >= 5 && attName.Left(5) == L"xmlns")
|
|
{
|
|
GlobalStringKey ns;
|
|
if (attName.Length() > 6)
|
|
{
|
|
if (attName.Left(6) == L"xmlns:")
|
|
{
|
|
ns = GlobalStringKey::Get(attName.Sub(6, attName.Length() - 6));
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
// create a data structure for the namespace
|
|
Ptr<NamespaceInfo> info;
|
|
vint index = context->namespaces.Keys().IndexOf(ns);
|
|
if (index == -1)
|
|
{
|
|
info = new NamespaceInfo;
|
|
info->name = ns;
|
|
info->attPosition = { {resource},att->codeRange.start };
|
|
context->namespaces.Add(ns, info);
|
|
}
|
|
else
|
|
{
|
|
info = context->namespaces.Values()[index];
|
|
}
|
|
|
|
// extract all patterns in the namespace, split the value by ';'
|
|
List<WString> patterns;
|
|
SplitBySemicolon(att->value.value, patterns);
|
|
FOREACH(WString, pattern, patterns)
|
|
{
|
|
// add the pattern to the namespace
|
|
Ptr<GuiInstanceNamespace> ns = new GuiInstanceNamespace;
|
|
Pair<vint, vint> star = INVLOC.FindFirst(pattern, L"*", Locale::None);
|
|
if (star.key == -1)
|
|
{
|
|
ns->prefix = pattern;
|
|
}
|
|
else
|
|
{
|
|
ns->prefix = pattern.Sub(0, star.key);
|
|
ns->postfix = pattern.Sub(star.key + star.value, pattern.Length() - star.key - star.value);
|
|
}
|
|
info->namespaces.Add(ns);
|
|
}
|
|
}
|
|
}
|
|
|
|
// load instance
|
|
FOREACH(Ptr<XmlElement>, element, XmlGetElements(xml->rootElement))
|
|
{
|
|
if (element->name.value == L"ref.Parameter")
|
|
{
|
|
auto attName = XmlGetAttribute(element, L"Name");
|
|
auto attClass = XmlGetAttribute(element, L"Class");
|
|
if (attName && attClass)
|
|
{
|
|
auto parameter = MakePtr<GuiInstanceParameter>();
|
|
parameter->name = GlobalStringKey::Get(attName->value.value);
|
|
parameter->className = GlobalStringKey::Get(attClass->value.value);
|
|
parameter->tagPosition = { {resource},element->codeRange.start };
|
|
parameter->classPosition = { {resource},attClass->value.codeRange.start };
|
|
parameter->classPosition.column += 1;
|
|
context->parameters.Add(parameter);
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ {resource},element->codeRange.start }, L"ref.Parameter requires the following attributes existing at the same time: Name, Class."));
|
|
}
|
|
}
|
|
|
|
#define COLLECT_SCRIPT(NAME, SCRIPT, POSITION)\
|
|
(element->name.value == L"ref." #NAME)\
|
|
{\
|
|
if (element->subNodes.Count() == 1)\
|
|
{\
|
|
if (auto cdata = element->subNodes[0].Cast<XmlCData>())\
|
|
{\
|
|
context->SCRIPT = cdata->content.value;\
|
|
context->POSITION = { {resource},cdata->codeRange.start };\
|
|
context->POSITION.column += 9; /* <![CDATA[ */\
|
|
goto NAME##_SCRIPT_SUCCESS;\
|
|
}\
|
|
}\
|
|
errors.Add(GuiResourceError({ {resource},element->codeRange.start }, L"Script should be contained in a CDATA section."));\
|
|
NAME##_SCRIPT_SUCCESS:;\
|
|
}\
|
|
|
|
else if COLLECT_SCRIPT(Members, memberScript, memberPosition)
|
|
else if COLLECT_SCRIPT(Ctor, ctorScript, ctorPosition)
|
|
else if COLLECT_SCRIPT(Dtor, dtorScript, dtorPosition)
|
|
|
|
#undef COLLECT_SCRIPT
|
|
else if (!context->instance)
|
|
{
|
|
context->instance = LoadCtor(resource, element, errors);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ {resource},xml->rootElement->codeRange.start }, L"The root element of instance should be \"Instance\"."));
|
|
}
|
|
|
|
return context->instance ? context : nullptr;
|
|
}
|
|
|
|
Ptr<parsing::xml::XmlDocument> GuiInstanceContext::SaveToXml()
|
|
{
|
|
auto xmlInstance = MakePtr<XmlElement>();
|
|
xmlInstance->name.value = L"Instance";
|
|
|
|
{
|
|
auto attCodeBehind = MakePtr<XmlAttribute>();
|
|
attCodeBehind->name.value = L"ref.CodeBehind";
|
|
attCodeBehind->value.value = codeBehind ? L"true" : L"false";
|
|
xmlInstance->attributes.Add(attCodeBehind);
|
|
}
|
|
|
|
auto attClass = MakePtr<XmlAttribute>();
|
|
attClass->name.value = L"ref.Class";
|
|
attClass->value.value = className;
|
|
xmlInstance->attributes.Add(attClass);
|
|
|
|
for (vint i = 0; i < namespaces.Count(); i++)
|
|
{
|
|
auto key = namespaces.Keys()[i];
|
|
auto value = namespaces.Values()[i];
|
|
|
|
auto xmlns = MakePtr<XmlAttribute>();
|
|
xmlns->name.value = L"xmlns";
|
|
if (key != GlobalStringKey::Empty)
|
|
{
|
|
xmlns->name.value += L":" + key.ToString();
|
|
}
|
|
xmlInstance->attributes.Add(xmlns);
|
|
|
|
for (vint j = 0; j < value->namespaces.Count(); j++)
|
|
{
|
|
auto ns = value->namespaces[j];
|
|
if (j != 0)
|
|
{
|
|
xmlns->value.value += L";";
|
|
}
|
|
xmlns->value.value += ns->prefix + L"*" + ns->postfix;
|
|
}
|
|
}
|
|
|
|
FOREACH(Ptr<GuiInstanceParameter>, parameter, parameters)
|
|
{
|
|
auto xmlParameter = MakePtr<XmlElement>();
|
|
xmlParameter->name.value = L"ref.Parameter";
|
|
xmlInstance->subNodes.Add(xmlParameter);
|
|
|
|
auto attName = MakePtr<XmlAttribute>();
|
|
attName->name.value = L"Name";
|
|
attName->value.value = parameter->name.ToString();
|
|
xmlParameter->attributes.Add(attName);
|
|
|
|
auto attClass = MakePtr<XmlAttribute>();
|
|
attClass->name.value = L"Class";
|
|
attClass->value.value = parameter->className.ToString();
|
|
xmlParameter->attributes.Add(attClass);
|
|
}
|
|
|
|
#define SERIALIZE_SCRIPT(NAME, SCRIPT)\
|
|
if (SCRIPT != L"")\
|
|
{\
|
|
auto xmlScript = MakePtr<XmlElement>();\
|
|
xmlScript->name.value = L"ref." #NAME;\
|
|
xmlInstance->subNodes.Add(xmlScript);\
|
|
auto text = MakePtr<XmlCData>();\
|
|
text->content.value = SCRIPT;\
|
|
xmlScript->subNodes.Add(text);\
|
|
}\
|
|
|
|
SERIALIZE_SCRIPT(Members, memberScript)
|
|
SERIALIZE_SCRIPT(Ctpr, ctorScript)
|
|
SERIALIZE_SCRIPT(Dtor, dtorScript)
|
|
|
|
#undef SERIALIZE_SCRIPT
|
|
|
|
if (stylePaths.Count() > 0)
|
|
{
|
|
auto attStyles = MakePtr<XmlAttribute>();
|
|
attStyles->name.value = L"ref.Styles";
|
|
xmlInstance->attributes.Add(attStyles);
|
|
|
|
for (vint j = 0; j < stylePaths.Count(); j++)
|
|
{
|
|
if (j != 0)
|
|
{
|
|
attStyles->value.value += L";";
|
|
}
|
|
attStyles->value.value += stylePaths[j];
|
|
}
|
|
}
|
|
|
|
instance->FillXml(xmlInstance);
|
|
|
|
auto doc = MakePtr<XmlDocument>();
|
|
doc->rootElement = xmlInstance;
|
|
return doc;
|
|
}
|
|
|
|
bool GuiInstanceContext::ApplyStyles(Ptr<GuiResourceItem> resource, Ptr<GuiResourcePathResolver> resolver, GuiResourceError::List& errors)
|
|
{
|
|
if (!appliedStyles)
|
|
{
|
|
appliedStyles = true;
|
|
|
|
List<Ptr<GuiInstanceStyle>> styles;
|
|
FOREACH(WString, uri, stylePaths)
|
|
{
|
|
WString protocol, path;
|
|
if (IsResourceUrl(uri, protocol, path))
|
|
{
|
|
if (auto styleContext = resolver->ResolveResource(protocol, path).Cast<GuiInstanceStyleContext>())
|
|
{
|
|
CopyFrom(styles, styleContext->styles, true);
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ resource }, stylePosition, L"Failed to find the style referred in attribute \"ref.Styles\": \"" + uri + L"\"."));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ resource }, stylePosition, L"Invalid path in attribute \"ref.Styles\": \"" + uri + L"\"."));
|
|
}
|
|
}
|
|
|
|
FOREACH(Ptr<GuiInstanceStyle>, style, styles)
|
|
{
|
|
List<Ptr<GuiConstructorRepr>> output;
|
|
ExecuteQuery(style->query, this, output);
|
|
FOREACH(Ptr<GuiConstructorRepr>, ctor, output)
|
|
{
|
|
ApplyStyle(style, ctor);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
GuiInstanceStyle
|
|
***********************************************************************/
|
|
|
|
namespace visitors
|
|
{
|
|
class SetStyleMarkVisitor : public Object, public GuiValueRepr::IVisitor
|
|
{
|
|
public:
|
|
void Visit(GuiTextRepr* repr)override
|
|
{
|
|
repr->fromStyle = true;
|
|
}
|
|
|
|
void Visit(GuiAttSetterRepr* repr)override
|
|
{
|
|
repr->fromStyle = true;
|
|
FOREACH(Ptr<GuiAttSetterRepr::SetterValue>, value, repr->setters.Values())
|
|
{
|
|
FOREACH(Ptr<GuiValueRepr>, subValue, value->values)
|
|
{
|
|
subValue->Accept(this);
|
|
}
|
|
}
|
|
FOREACH(Ptr<GuiAttSetterRepr::EventValue>, value, repr->eventHandlers.Values())
|
|
{
|
|
value->fromStyle = true;
|
|
}
|
|
FOREACH(Ptr<GuiAttSetterRepr::EnvVarValue>, value, repr->environmentVariables.Values())
|
|
{
|
|
value->fromStyle = true;
|
|
}
|
|
}
|
|
|
|
void Visit(GuiConstructorRepr* repr)override
|
|
{
|
|
Visit((GuiAttSetterRepr*)repr);
|
|
}
|
|
};
|
|
}
|
|
using namespace visitors;
|
|
|
|
Ptr<GuiInstanceStyle> GuiInstanceStyle::LoadFromXml(Ptr<GuiResourceItem> resource, Ptr<parsing::xml::XmlElement> xml, GuiResourceError::List& errors)
|
|
{
|
|
auto style = MakePtr<GuiInstanceStyle>();
|
|
if (auto pathAttr = XmlGetAttribute(xml, L"ref.Path"))
|
|
{
|
|
auto position = pathAttr->value.codeRange.start;
|
|
position.column += 1;
|
|
|
|
auto parser = GetParserManager()->GetParser<GuiIqQuery>(L"INSTANCE-QUERY");
|
|
auto query = parser->Parse({ resource }, pathAttr->value.value, position, errors);
|
|
if (!query) return nullptr;
|
|
style->query = query;
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ {resource},xml->codeRange.start }, L"Missing attribute \"ref.Path\" in <Style>."));
|
|
}
|
|
style->setter = MakePtr<GuiAttSetterRepr>();
|
|
GuiInstanceContext::FillAttSetter(resource, style->setter, xml, errors);
|
|
|
|
SetStyleMarkVisitor visitor;
|
|
style->setter->Accept(&visitor);
|
|
return style;
|
|
}
|
|
|
|
Ptr<parsing::xml::XmlElement> GuiInstanceStyle::SaveToXml()
|
|
{
|
|
auto xmlStyle = MakePtr<XmlElement>();
|
|
xmlStyle->name.value = L"Style";
|
|
|
|
auto attPath = MakePtr<XmlAttribute>();
|
|
attPath->name.value = L"ref.Path";
|
|
{
|
|
MemoryStream stream;
|
|
{
|
|
StreamWriter writer(stream);
|
|
GuiIqPrint(query, writer);
|
|
}
|
|
stream.SeekFromBegin(0);
|
|
{
|
|
StreamReader reader(stream);
|
|
attPath->value.value = reader.ReadToEnd();
|
|
}
|
|
}
|
|
xmlStyle->attributes.Add(attPath);
|
|
|
|
setter->FillXml(xmlStyle);
|
|
return xmlStyle;
|
|
}
|
|
|
|
/***********************************************************************
|
|
GuiInstanceStyleContext
|
|
***********************************************************************/
|
|
|
|
Ptr<GuiInstanceStyleContext> GuiInstanceStyleContext::LoadFromXml(Ptr<GuiResourceItem> resource, Ptr<parsing::xml::XmlDocument> xml, GuiResourceError::List& errors)
|
|
{
|
|
auto context = MakePtr<GuiInstanceStyleContext>();
|
|
if (xml->rootElement->name.value == L"Styles")
|
|
{
|
|
FOREACH(Ptr<XmlElement>, styleElement, XmlGetElements(xml->rootElement))
|
|
{
|
|
if (styleElement->name.value == L"Style")
|
|
{
|
|
if (auto style = GuiInstanceStyle::LoadFromXml(resource, styleElement, errors))
|
|
{
|
|
context->styles.Add(style);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ {resource},styleElement->codeRange.start }, L"Unknown element in <Styles>: \"" + styleElement->name.value + L"\"."));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ {resource},xml->rootElement->codeRange.start }, L"The root element of instance styles should be \"Styles\"."));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
Ptr<parsing::xml::XmlDocument> GuiInstanceStyleContext::SaveToXml()
|
|
{
|
|
auto xmlStyles = MakePtr<XmlElement>();
|
|
xmlStyles->name.value = L"Styles";
|
|
|
|
FOREACH(Ptr<GuiInstanceStyle>, style, styles)
|
|
{
|
|
xmlStyles->subNodes.Add(style->SaveToXml());
|
|
}
|
|
|
|
auto doc = MakePtr<XmlDocument>();
|
|
doc->rootElement = xmlStyles;
|
|
return doc;
|
|
}
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
GUIINSTANCESHAREDSCRIPT.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
using namespace parsing::xml;
|
|
|
|
/***********************************************************************
|
|
GuiInstanceSharedScript
|
|
***********************************************************************/
|
|
|
|
Ptr<GuiInstanceSharedScript> GuiInstanceSharedScript::LoadFromXml(Ptr<GuiResourceItem> resource, Ptr<parsing::xml::XmlDocument> xml, GuiResourceError::List& errors)
|
|
{
|
|
if (xml->rootElement->subNodes.Count() == 1)
|
|
{
|
|
if (auto cdata = xml->rootElement->subNodes[0].Cast<XmlCData>())
|
|
{
|
|
auto script = MakePtr<GuiInstanceSharedScript>();
|
|
script->language = xml->rootElement->name.value;
|
|
script->code = cdata->content.value;
|
|
script->codePosition = { {resource},cdata->codeRange.start };
|
|
script->codePosition.column += 9; // <![CDATA[
|
|
return script;
|
|
}
|
|
}
|
|
errors.Add(GuiResourceError({ {resource},xml->rootElement->codeRange.start }, L"Script should be contained in a CDATA section."));
|
|
return nullptr;
|
|
}
|
|
|
|
Ptr<parsing::xml::XmlElement> GuiInstanceSharedScript::SaveToXml()
|
|
{
|
|
auto cdata = MakePtr<XmlCData>();
|
|
cdata->content.value = code;
|
|
|
|
auto xml = MakePtr<XmlElement>();
|
|
xml->name.value = language;
|
|
xml->subNodes.Add(cdata);
|
|
|
|
return xml;
|
|
}
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
INSTANCELOADERS\GUIINSTANCELOADER_COMPOSITIONS.CPP
|
|
***********************************************************************/
|
|
|
|
#ifndef VCZH_DEBUG_NO_REFLECTION
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
namespace instance_loaders
|
|
{
|
|
|
|
/***********************************************************************
|
|
GuiAxisInstanceLoader
|
|
***********************************************************************/
|
|
|
|
class GuiAxisInstanceLoader : public Object, public IGuiInstanceLoader
|
|
{
|
|
protected:
|
|
GlobalStringKey typeName;
|
|
GlobalStringKey _AxisDirection;
|
|
|
|
public:
|
|
GuiAxisInstanceLoader()
|
|
{
|
|
typeName = GlobalStringKey::Get(description::TypeInfo<GuiAxis>::content.typeName);
|
|
_AxisDirection = GlobalStringKey::Get(L"AxisDirection");
|
|
}
|
|
|
|
GlobalStringKey GetTypeName()override
|
|
{
|
|
return typeName;
|
|
}
|
|
|
|
void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
if (CanCreate(typeInfo))
|
|
{
|
|
propertyNames.Add(_AxisDirection);
|
|
}
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
GetRequiredPropertyNames(typeInfo, propertyNames);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == _AxisDirection)
|
|
{
|
|
auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver<AxisDirection>::CreateTypeInfo());
|
|
info->usage = GuiInstancePropertyInfo::ConstructorArgument;
|
|
return info;
|
|
}
|
|
return IGuiInstanceLoader::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
bool CanCreate(const TypeInfo& typeInfo)override
|
|
{
|
|
return typeName == typeInfo.typeName;
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> CreateInstance(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos tagPosition, GuiResourceError::List& errors)override
|
|
{
|
|
if (CanCreate(typeInfo))
|
|
{
|
|
vint indexAxisDirection = arguments.Keys().IndexOf(_AxisDirection);
|
|
if (indexAxisDirection != -1)
|
|
{
|
|
auto createExpr = MakePtr<WfNewClassExpression>();
|
|
createExpr->type = GetTypeFromTypeInfo(TypeInfoRetriver<Ptr<GuiAxis>>::CreateTypeInfo().Obj());
|
|
createExpr->arguments.Add(arguments.GetByIndex(indexAxisDirection)[0].expression);
|
|
|
|
auto refVariable = MakePtr<WfReferenceExpression>();
|
|
refVariable->name.value = variableName.ToString();
|
|
|
|
auto assignExpr = MakePtr<WfBinaryExpression>();
|
|
assignExpr->op = WfBinaryOperator::Assign;
|
|
assignExpr->first = refVariable;
|
|
assignExpr->second = createExpr;
|
|
|
|
auto assignStat = MakePtr<WfExpressionStatement>();
|
|
assignStat->expression = assignExpr;
|
|
return assignStat;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiCompositionInstanceLoader
|
|
***********************************************************************/
|
|
|
|
class GuiCompositionInstanceLoader : public Object, public IGuiInstanceLoader
|
|
{
|
|
protected:
|
|
GlobalStringKey typeName;
|
|
|
|
public:
|
|
GuiCompositionInstanceLoader()
|
|
{
|
|
typeName = GlobalStringKey::Get(description::TypeInfo<GuiGraphicsComposition>::content.typeName);
|
|
}
|
|
|
|
GlobalStringKey GetTypeName()override
|
|
{
|
|
return typeName;
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
propertyNames.Add(GlobalStringKey::Empty);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == GlobalStringKey::Empty)
|
|
{
|
|
auto info = GuiInstancePropertyInfo::Collection(nullptr);
|
|
info->acceptableTypes.Add(TypeInfoRetriver<GuiControl*>::CreateTypeInfo());
|
|
info->acceptableTypes.Add(TypeInfoRetriver<GuiGraphicsComposition*>::CreateTypeInfo());
|
|
info->acceptableTypes.Add(TypeInfoRetriver<Ptr<IGuiGraphicsElement>>::CreateTypeInfo());
|
|
return info;
|
|
}
|
|
return IGuiInstanceLoader::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
const auto& values = arguments.GetByIndex(index);
|
|
if (prop == GlobalStringKey::Empty)
|
|
{
|
|
auto value = values[0].expression;
|
|
auto td = values[0].typeInfo->GetTypeDescriptor();
|
|
|
|
Ptr<WfExpression> expr;
|
|
if (td->CanConvertTo(description::GetTypeDescriptor<IGuiGraphicsElement>()))
|
|
{
|
|
auto refComposition = MakePtr<WfReferenceExpression>();
|
|
refComposition->name.value = variableName.ToString();
|
|
|
|
auto refOwnedElement = MakePtr<WfMemberExpression>();
|
|
refOwnedElement->parent = refComposition;
|
|
refOwnedElement->name.value = L"OwnedElement";
|
|
|
|
auto assign = MakePtr<WfBinaryExpression>();
|
|
assign->op = WfBinaryOperator::Assign;
|
|
assign->first = refOwnedElement;
|
|
assign->second = value;
|
|
|
|
expr = assign;
|
|
}
|
|
else if (td->CanConvertTo(description::GetTypeDescriptor<GuiControl>()))
|
|
{
|
|
auto refBoundsComposition = MakePtr<WfMemberExpression>();
|
|
refBoundsComposition->parent = value;
|
|
refBoundsComposition->name.value = L"BoundsComposition";
|
|
|
|
auto refComposition = MakePtr<WfReferenceExpression>();
|
|
refComposition->name.value = variableName.ToString();
|
|
|
|
auto refAddChild = MakePtr<WfMemberExpression>();
|
|
refAddChild->parent = refComposition;
|
|
refAddChild->name.value = L"AddChild";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refAddChild;
|
|
call->arguments.Add(refBoundsComposition);
|
|
|
|
expr = call;
|
|
}
|
|
else if (td->CanConvertTo(description::GetTypeDescriptor<GuiGraphicsComposition>()))
|
|
{
|
|
auto refComposition = MakePtr<WfReferenceExpression>();
|
|
refComposition->name.value = variableName.ToString();
|
|
|
|
auto refAddChild = MakePtr<WfMemberExpression>();
|
|
refAddChild->parent = refComposition;
|
|
refAddChild->name.value = L"AddChild";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refAddChild;
|
|
call->arguments.Add(value);
|
|
|
|
expr = call;
|
|
}
|
|
|
|
if (expr)
|
|
{
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = expr;
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiTableCompositionInstanceLoader
|
|
***********************************************************************/
|
|
|
|
class GuiTableCompositionInstanceLoader : public Object, public IGuiInstanceLoader
|
|
{
|
|
protected:
|
|
GlobalStringKey typeName;
|
|
GlobalStringKey _Rows, _Columns;
|
|
|
|
public:
|
|
GuiTableCompositionInstanceLoader()
|
|
{
|
|
typeName = GlobalStringKey::Get(description::TypeInfo<GuiTableComposition>::content.typeName);
|
|
_Rows = GlobalStringKey::Get(L"Rows");
|
|
_Columns = GlobalStringKey::Get(L"Columns");
|
|
}
|
|
|
|
GlobalStringKey GetTypeName()override
|
|
{
|
|
return typeName;
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
propertyNames.Add(_Rows);
|
|
propertyNames.Add(_Columns);
|
|
}
|
|
|
|
void GetPairedProperties(const PropertyInfo& propertyInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
if (propertyInfo.propertyName == _Rows || propertyInfo.propertyName == _Columns)
|
|
{
|
|
propertyNames.Add(_Rows);
|
|
propertyNames.Add(_Columns);
|
|
}
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == _Rows || propertyInfo.propertyName == _Columns)
|
|
{
|
|
return GuiInstancePropertyInfo::Array(TypeInfoRetriver<GuiCellOption>::CreateTypeInfo());
|
|
}
|
|
return IGuiInstanceLoader::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
if (prop == _Rows)
|
|
{
|
|
auto indexColumns = arguments.Keys().IndexOf(_Columns);
|
|
if (indexColumns != -1)
|
|
{
|
|
auto& rows = arguments.GetByIndex(index);
|
|
auto& columns = arguments.GetByIndex(indexColumns);
|
|
|
|
{
|
|
auto refComposition = MakePtr<WfReferenceExpression>();
|
|
refComposition->name.value = variableName.ToString();
|
|
|
|
auto refSetRowsAndColumns = MakePtr<WfMemberExpression>();
|
|
refSetRowsAndColumns->parent = refComposition;
|
|
refSetRowsAndColumns->name.value = L"SetRowsAndColumns";
|
|
|
|
auto rowsExpr = MakePtr<WfIntegerExpression>();
|
|
rowsExpr->value.value = itow(rows.Count());
|
|
|
|
auto columnsExpr = MakePtr<WfIntegerExpression>();
|
|
columnsExpr->value.value = itow(columns.Count());
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refSetRowsAndColumns;
|
|
call->arguments.Add(rowsExpr);
|
|
call->arguments.Add(columnsExpr);
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
block->statements.Add(stat);
|
|
}
|
|
|
|
for (vint i = 0; i < rows.Count(); i++)
|
|
{
|
|
auto refComposition = MakePtr<WfReferenceExpression>();
|
|
refComposition->name.value = variableName.ToString();
|
|
|
|
auto refSetRowOption = MakePtr<WfMemberExpression>();
|
|
refSetRowOption->parent = refComposition;
|
|
refSetRowOption->name.value = L"SetRowOption";
|
|
|
|
auto indexExpr = MakePtr<WfIntegerExpression>();
|
|
indexExpr->value.value = itow(i);
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refSetRowOption;
|
|
call->arguments.Add(indexExpr);
|
|
call->arguments.Add(rows[i].expression);
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
block->statements.Add(stat);
|
|
}
|
|
|
|
for (vint i = 0; i < columns.Count(); i++)
|
|
{
|
|
auto refComposition = MakePtr<WfReferenceExpression>();
|
|
refComposition->name.value = variableName.ToString();
|
|
|
|
auto refSetColumnOption = MakePtr<WfMemberExpression>();
|
|
refSetColumnOption->parent = refComposition;
|
|
refSetColumnOption->name.value = L"SetColumnOption";
|
|
|
|
auto indexExpr = MakePtr<WfIntegerExpression>();
|
|
indexExpr->value.value = itow(i);
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refSetColumnOption;
|
|
call->arguments.Add(indexExpr);
|
|
call->arguments.Add(columns[i].expression);
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiCellCompositionInstanceLoader
|
|
***********************************************************************/
|
|
|
|
class GuiCellCompositionInstanceLoader : public Object, public IGuiInstanceLoader
|
|
{
|
|
protected:
|
|
GlobalStringKey typeName;
|
|
GlobalStringKey _Site;
|
|
|
|
public:
|
|
GuiCellCompositionInstanceLoader()
|
|
{
|
|
typeName = GlobalStringKey::Get(description::TypeInfo<GuiCellComposition>::content.typeName);
|
|
_Site = GlobalStringKey::Get(L"Site");
|
|
}
|
|
|
|
GlobalStringKey GetTypeName()override
|
|
{
|
|
return typeName;
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
propertyNames.Add(_Site);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == _Site)
|
|
{
|
|
return GuiInstancePropertyInfo::Assign(TypeInfoRetriver<SiteValue>::CreateTypeInfo());
|
|
}
|
|
return IGuiInstanceLoader::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
if (prop == _Site)
|
|
{
|
|
SiteValue site;
|
|
{
|
|
auto siteExpr = arguments.GetByIndex(index)[0].expression;
|
|
if (auto inferExpr = siteExpr.Cast<WfInferExpression>())
|
|
{
|
|
if (auto ctorExpr = inferExpr->expression.Cast<WfConstructorExpression>())
|
|
{
|
|
auto st = description::GetTypeDescriptor<vint>()->GetSerializableType();
|
|
FOREACH(Ptr<WfConstructorArgument>, argument, ctorExpr->arguments)
|
|
{
|
|
if (auto keyExpr = argument->key.Cast<WfReferenceExpression>())
|
|
{
|
|
if (auto valueExpr = argument->value.Cast<WfIntegerExpression>())
|
|
{
|
|
Value value;
|
|
if (st->Deserialize(valueExpr->value.value, value))
|
|
{
|
|
vint propValue = UnboxValue<vint>(value);
|
|
if (keyExpr->name.value == L"row")
|
|
{
|
|
site.row = propValue;
|
|
}
|
|
else if (keyExpr->name.value == L"column")
|
|
{
|
|
site.column = propValue;
|
|
}
|
|
else if (keyExpr->name.value == L"rowSpan")
|
|
{
|
|
site.rowSpan = propValue;
|
|
}
|
|
else if (keyExpr->name.value == L"columnSpan")
|
|
{
|
|
site.columnSpan = propValue;
|
|
}
|
|
else
|
|
{
|
|
goto ILLEGAL_SITE_PROPERTY;
|
|
}
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
goto ILLEGAL_SITE_PROPERTY;
|
|
}
|
|
goto FINISH_SITE_PROPERTY;
|
|
}
|
|
}
|
|
ILLEGAL_SITE_PROPERTY:
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, attPosition,
|
|
L"Precompile: The value of property \"Site\" of type \"" +
|
|
typeInfo.typeName.ToString() +
|
|
L"\" is not in a correct format: \"row:<integer> column:<integer> [rowSpan:<integer>] [columnSpan:<integer>]\"."));
|
|
continue;
|
|
}
|
|
FINISH_SITE_PROPERTY:;
|
|
|
|
{
|
|
auto refComposition = MakePtr<WfReferenceExpression>();
|
|
refComposition->name.value = variableName.ToString();
|
|
|
|
auto refSetSite = MakePtr<WfMemberExpression>();
|
|
refSetSite->parent = refComposition;
|
|
refSetSite->name.value = L"SetSite";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refSetSite;
|
|
|
|
auto GetValueText = [](const Value& value)
|
|
{
|
|
WString result;
|
|
auto st = value.GetTypeDescriptor()->GetSerializableType();
|
|
st->Serialize(value, result);
|
|
return result;
|
|
};
|
|
|
|
{
|
|
auto arg = MakePtr<WfIntegerExpression>();
|
|
arg->value.value = itow(site.row);
|
|
call->arguments.Add(arg);
|
|
}
|
|
{
|
|
auto arg = MakePtr<WfIntegerExpression>();
|
|
arg->value.value = itow(site.column);
|
|
call->arguments.Add(arg);
|
|
}
|
|
{
|
|
auto arg = MakePtr<WfIntegerExpression>();
|
|
arg->value.value = itow(site.rowSpan);
|
|
call->arguments.Add(arg);
|
|
}
|
|
{
|
|
auto arg = MakePtr<WfIntegerExpression>();
|
|
arg->value.value = itow(site.columnSpan);
|
|
call->arguments.Add(arg);
|
|
}
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
Initialization
|
|
***********************************************************************/
|
|
|
|
void LoadCompositions(IGuiInstanceLoaderManager* manager)
|
|
{
|
|
manager->SetLoader(new GuiAxisInstanceLoader);
|
|
manager->SetLoader(new GuiCompositionInstanceLoader);
|
|
manager->SetLoader(new GuiTableCompositionInstanceLoader);
|
|
manager->SetLoader(new GuiCellCompositionInstanceLoader);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|
|
/***********************************************************************
|
|
INSTANCELOADERS\GUIINSTANCELOADER_DOCUMENT.CPP
|
|
***********************************************************************/
|
|
|
|
#ifndef VCZH_DEBUG_NO_REFLECTION
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
namespace instance_loaders
|
|
{
|
|
|
|
/***********************************************************************
|
|
GuiDocumentItemInstanceLoader
|
|
***********************************************************************/
|
|
|
|
class GuiDocumentItemInstanceLoader : public Object, public IGuiInstanceLoader
|
|
{
|
|
protected:
|
|
GlobalStringKey typeName;
|
|
GlobalStringKey _Name;
|
|
|
|
public:
|
|
GuiDocumentItemInstanceLoader()
|
|
{
|
|
typeName = GlobalStringKey::Get(description::TypeInfo<GuiDocumentItem>::content.typeName);
|
|
_Name = GlobalStringKey::Get(L"Name");
|
|
}
|
|
|
|
GlobalStringKey GetTypeName()override
|
|
{
|
|
return typeName;
|
|
}
|
|
|
|
void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
if (CanCreate(typeInfo))
|
|
{
|
|
propertyNames.Add(_Name);
|
|
}
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
GetRequiredPropertyNames(typeInfo, propertyNames);
|
|
propertyNames.Add(GlobalStringKey::Empty);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == GlobalStringKey::Empty)
|
|
{
|
|
auto info = GuiInstancePropertyInfo::Collection(nullptr);
|
|
info->acceptableTypes.Add(TypeInfoRetriver<GuiControl*>::CreateTypeInfo());
|
|
info->acceptableTypes.Add(TypeInfoRetriver<GuiGraphicsComposition*>::CreateTypeInfo());
|
|
return info;
|
|
}
|
|
else if (propertyInfo.propertyName == _Name)
|
|
{
|
|
auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver<WString>::CreateTypeInfo());
|
|
info->usage = GuiInstancePropertyInfo::ConstructorArgument;
|
|
return info;
|
|
}
|
|
return IGuiInstanceLoader::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
|
|
bool CanCreate(const TypeInfo& typeInfo)override
|
|
{
|
|
return typeName == typeInfo.typeName;
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> CreateInstance(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos tagPosition, GuiResourceError::List& errors)override
|
|
{
|
|
if (CanCreate(typeInfo))
|
|
{
|
|
vint indexName = arguments.Keys().IndexOf(_Name);
|
|
if (indexName != -1)
|
|
{
|
|
auto type = TypeInfoRetriver<Ptr<GuiDocumentItem>>::CreateTypeInfo();
|
|
auto createExpr = MakePtr<WfNewClassExpression>();
|
|
createExpr->type = GetTypeFromTypeInfo(type.Obj());
|
|
createExpr->arguments.Add(arguments.GetByIndex(indexName)[0].expression);
|
|
|
|
auto refVariable = MakePtr<WfReferenceExpression>();
|
|
refVariable->name.value = variableName.ToString();
|
|
|
|
auto assignExpr = MakePtr<WfBinaryExpression>();
|
|
assignExpr->op = WfBinaryOperator::Assign;
|
|
assignExpr->first = refVariable;
|
|
assignExpr->second = createExpr;
|
|
|
|
auto assignStat = MakePtr<WfExpressionStatement>();
|
|
assignStat->expression = assignExpr;
|
|
return assignStat;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
const auto& values = arguments.GetByIndex(index);
|
|
if (prop == GlobalStringKey::Empty)
|
|
{
|
|
auto value = values[0].expression;
|
|
auto td = values[0].typeInfo->GetTypeDescriptor();
|
|
|
|
Ptr<WfExpression> compositionExpr;
|
|
if (td->CanConvertTo(description::GetTypeDescriptor<GuiControl>()))
|
|
{
|
|
auto member = MakePtr<WfMemberExpression>();
|
|
member->parent = value;
|
|
member->name.value = L"BoundsComposition";
|
|
compositionExpr = member;
|
|
}
|
|
else if (td->CanConvertTo(description::GetTypeDescriptor<GuiGraphicsComposition>()))
|
|
{
|
|
compositionExpr = value;
|
|
}
|
|
|
|
if (compositionExpr)
|
|
{
|
|
auto refItem = MakePtr<WfReferenceExpression>();
|
|
refItem->name.value = variableName.ToString();
|
|
|
|
auto refContainer = MakePtr<WfMemberExpression>();
|
|
refContainer->parent = refItem;
|
|
refContainer->name.value = L"Container";
|
|
|
|
auto refAddChild = MakePtr<WfMemberExpression>();
|
|
refAddChild->parent = refContainer;
|
|
refAddChild->name.value = L"AddChild";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refAddChild;
|
|
call->arguments.Add(compositionExpr);
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiDocumentInstanceLoaderBase
|
|
***********************************************************************/
|
|
|
|
template<typename TBaseType>
|
|
class GuiDocumentInstanceLoaderBase : public TBaseType
|
|
{
|
|
public:
|
|
using PropertyInfo = IGuiInstanceLoader::PropertyInfo;
|
|
using ArgumentMap = IGuiInstanceLoader::ArgumentMap;
|
|
|
|
GuiDocumentInstanceLoaderBase(const WString& _typeName, const WString& _styleMethod)
|
|
:TBaseType(_typeName, _styleMethod)
|
|
{
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
propertyNames.Add(GlobalStringKey::Empty);
|
|
TBaseType::GetPropertyNames(typeInfo, propertyNames);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == GlobalStringKey::Empty)
|
|
{
|
|
return GuiInstancePropertyInfo::CollectionWithParent(TypeInfoRetriver<Ptr<GuiDocumentItem>>::CreateTypeInfo());
|
|
}
|
|
return TBaseType::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
const auto& values = arguments.GetByIndex(index);
|
|
if (prop == GlobalStringKey::Empty)
|
|
{
|
|
auto refControl = MakePtr<WfReferenceExpression>();
|
|
refControl->name.value = variableName.ToString();
|
|
|
|
auto refAddDocumentItem = MakePtr<WfMemberExpression>();
|
|
refAddDocumentItem->parent = refControl;
|
|
refAddDocumentItem->name.value = L"AddDocumentItem";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refAddDocumentItem;
|
|
call->arguments.Add(values[0].expression);
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return TBaseType::AssignParameters(precompileContext, resolvingResult, typeInfo, variableName, arguments, attPosition, errors);
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiDocumentViewerInstanceLoader
|
|
***********************************************************************/
|
|
|
|
#define BASE_TYPE GuiTemplateControlInstanceLoader<GuiDocumentViewer, GuiDocumentViewerTemplate_StyleProvider, GuiDocumentViewerTemplate>
|
|
class GuiDocumentViewerInstanceLoader : public GuiDocumentInstanceLoaderBase<BASE_TYPE>
|
|
{
|
|
public:
|
|
GuiDocumentViewerInstanceLoader()
|
|
:GuiDocumentInstanceLoaderBase<BASE_TYPE>(description::TypeInfo<GuiDocumentViewer>::content.typeName, L"CreateDocumentViewerStyle")
|
|
{
|
|
}
|
|
};
|
|
#undef BASE_TYPE
|
|
|
|
/***********************************************************************
|
|
GuiDocumentLabelInstanceLoader
|
|
***********************************************************************/
|
|
|
|
#define BASE_TYPE GuiTemplateControlInstanceLoader<GuiDocumentLabel, GuiDocumentLabelTemplate_StyleProvider, GuiDocumentLabelTemplate>
|
|
class GuiDocumentLabelInstanceLoader : public GuiDocumentInstanceLoaderBase<BASE_TYPE>
|
|
{
|
|
public:
|
|
GuiDocumentLabelInstanceLoader()
|
|
:GuiDocumentInstanceLoaderBase<BASE_TYPE>(description::TypeInfo<GuiDocumentLabel>::content.typeName, L"CreateDocumentLabelStyle")
|
|
{
|
|
}
|
|
};
|
|
#undef BASE_TYPE
|
|
|
|
/***********************************************************************
|
|
Initialization
|
|
***********************************************************************/
|
|
|
|
void LoadDocumentControls(IGuiInstanceLoaderManager* manager)
|
|
{
|
|
manager->SetLoader(new GuiDocumentItemInstanceLoader);
|
|
manager->SetLoader(new GuiDocumentViewerInstanceLoader);
|
|
manager->SetLoader(new GuiDocumentLabelInstanceLoader);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|
|
/***********************************************************************
|
|
INSTANCELOADERS\GUIINSTANCELOADER_LIST.CPP
|
|
***********************************************************************/
|
|
|
|
#ifndef VCZH_DEBUG_NO_REFLECTION
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
namespace instance_loaders
|
|
{
|
|
|
|
template<typename TItemTemplateStyle>
|
|
Ptr<WfStatement> CreateSetControlTemplateStyle(types::ResolvingResult& resolvingResult, GlobalStringKey variableName, Ptr<WfExpression> argument, const WString& propertyName)
|
|
{
|
|
auto createStyle = MakePtr<WfNewClassExpression>();
|
|
createStyle->type = GetTypeFromTypeInfo(TypeInfoRetriver<Ptr<TItemTemplateStyle>>::CreateTypeInfo().Obj());
|
|
createStyle->arguments.Add(argument);
|
|
|
|
auto refControl = MakePtr<WfReferenceExpression>();
|
|
refControl->name.value = variableName.ToString();
|
|
|
|
auto refStyleProvider = MakePtr<WfMemberExpression>();
|
|
refStyleProvider->parent = refControl;
|
|
refStyleProvider->name.value = propertyName;
|
|
|
|
auto assign = MakePtr<WfBinaryExpression>();
|
|
assign->op = WfBinaryOperator::Assign;
|
|
assign->first = refStyleProvider;
|
|
assign->second = createStyle;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = assign;
|
|
return stat;
|
|
}
|
|
|
|
/***********************************************************************
|
|
GuiVirtualTextListControlInstanceLoader
|
|
***********************************************************************/
|
|
|
|
class GuiVirtualTextListControlInstanceLoader : public Object, public IGuiInstanceLoader
|
|
{
|
|
protected:
|
|
GlobalStringKey typeName;
|
|
|
|
public:
|
|
GuiVirtualTextListControlInstanceLoader()
|
|
{
|
|
typeName = GlobalStringKey::Get(description::TypeInfo<GuiVirtualTextList>::content.typeName);
|
|
}
|
|
|
|
GlobalStringKey GetTypeName()override
|
|
{
|
|
return typeName;
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
propertyNames.Add(GlobalStringKey::_ItemTemplate);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == GlobalStringKey::_ItemTemplate)
|
|
{
|
|
auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver<TemplateProperty<GuiTextListItemTemplate>>::CreateTypeInfo());
|
|
return info;
|
|
}
|
|
return IGuiInstanceLoader::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
const auto& values = arguments.GetByIndex(index);
|
|
if (prop == GlobalStringKey::_ItemTemplate)
|
|
{
|
|
if (auto stat = CreateSetControlTemplateStyle<GuiTextListItemTemplate_ItemStyleProvider>(resolvingResult, variableName, arguments.GetByIndex(index)[0].expression, L"StyleProvider"))
|
|
{
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiComboBoxInstanceLoader
|
|
***********************************************************************/
|
|
|
|
#define BASE_TYPE GuiTemplateControlInstanceLoader<GuiComboBoxListControl, GuiComboBoxTemplate_StyleProvider, GuiComboBoxTemplate>
|
|
class GuiComboBoxInstanceLoader : public BASE_TYPE
|
|
{
|
|
protected:
|
|
GlobalStringKey _ListControl;
|
|
|
|
void AddAdditionalArguments(types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceError::List& errors, Ptr<WfNewClassExpression> createControl)override
|
|
{
|
|
vint indexListControl = arguments.Keys().IndexOf(_ListControl);
|
|
if (indexListControl != -1)
|
|
{
|
|
createControl->arguments.Add(arguments.GetByIndex(indexListControl)[0].expression);
|
|
}
|
|
}
|
|
public:
|
|
GuiComboBoxInstanceLoader()
|
|
:BASE_TYPE(L"presentation::controls::GuiComboBox", L"CreateComboBoxStyle")
|
|
{
|
|
_ListControl = GlobalStringKey::Get(L"ListControl");
|
|
}
|
|
|
|
void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
if (CanCreate(typeInfo))
|
|
{
|
|
propertyNames.Add(_ListControl);
|
|
}
|
|
BASE_TYPE::GetRequiredPropertyNames(typeInfo, propertyNames);
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
GetRequiredPropertyNames(typeInfo, propertyNames);
|
|
propertyNames.Add(GlobalStringKey::_ItemTemplate);
|
|
BASE_TYPE::GetPropertyNames(typeInfo, propertyNames);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == _ListControl)
|
|
{
|
|
auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver<GuiSelectableListControl*>::CreateTypeInfo());
|
|
info->usage = GuiInstancePropertyInfo::ConstructorArgument;
|
|
return info;
|
|
}
|
|
else if (propertyInfo.propertyName == GlobalStringKey::_ItemTemplate)
|
|
{
|
|
auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver<TemplateProperty<GuiControlTemplate>>::CreateTypeInfo());
|
|
return info;
|
|
}
|
|
return BASE_TYPE::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
const auto& values = arguments.GetByIndex(index);
|
|
if (prop == GlobalStringKey::_ItemTemplate)
|
|
{
|
|
if (auto stat = CreateSetControlTemplateStyle<GuiControlTemplate_ItemStyleProvider>(resolvingResult, variableName, arguments.GetByIndex(index)[0].expression, L"StyleProvider"))
|
|
{
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
#undef BASE_TYPE
|
|
|
|
/***********************************************************************
|
|
GuiListViewInstanceLoader
|
|
***********************************************************************/
|
|
|
|
#define BASE_TYPE GuiTemplateControlInstanceLoader<TControl, GuiListViewTemplate_StyleProvider, GuiListViewTemplate>
|
|
template<typename TControl>
|
|
class GuiListViewInstanceLoaderBase : public BASE_TYPE
|
|
{
|
|
protected:
|
|
GlobalStringKey _View, _IconSize;
|
|
|
|
void PrepareAdditionalArgumentsAfterCreation(types::ResolvingResult& resolvingResult, const typename BASE_TYPE::TypeInfo& typeInfo, GlobalStringKey variableName, typename BASE_TYPE::ArgumentMap& arguments, GuiResourceError::List& errors, Ptr<WfBlockStatement> block)override
|
|
{
|
|
auto view = ListViewViewType::Detail;
|
|
Ptr<WfExpression> iconSize;
|
|
{
|
|
vint indexView = arguments.Keys().IndexOf(_View);
|
|
if (indexView != -1)
|
|
{
|
|
auto viewArgument = arguments.GetByIndex(indexView)[0];
|
|
if (auto inferExpr = viewArgument.expression.template Cast<WfInferExpression>())
|
|
{
|
|
if (auto refExpr = inferExpr->expression.template Cast<WfReferenceExpression>())
|
|
{
|
|
auto enumType = description::GetTypeDescriptor<ListViewViewType>()->GetEnumType();
|
|
vint index = enumType->IndexOfItem(refExpr->name.value);
|
|
if (index == -1)
|
|
{
|
|
goto ILLEGAL_VIEW_PROPERTY;
|
|
}
|
|
|
|
view = UnboxValue<ListViewViewType>(enumType->ToEnum(enumType->GetItemValue(index)));
|
|
goto FINISH_VIEW_PROPERTY;
|
|
}
|
|
}
|
|
ILLEGAL_VIEW_PROPERTY:
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, viewArgument.attPosition,
|
|
L"Precompile: The value of property \"View\" of type \"" +
|
|
typeInfo.typeName.ToString() +
|
|
L"\" is not in a correct format: \"BigIcon | SmallIcon | List | Tile | Information | Detail\"."));
|
|
FINISH_VIEW_PROPERTY:;
|
|
}
|
|
|
|
vint indexIconSize = arguments.Keys().IndexOf(_IconSize);
|
|
if (indexIconSize != -1)
|
|
{
|
|
iconSize = arguments.GetByIndex(indexIconSize)[0].expression;
|
|
}
|
|
}
|
|
|
|
Ptr<ITypeInfo> itemStyleType;
|
|
switch (view)
|
|
{
|
|
#define VIEW_TYPE_CASE(NAME) case ListViewViewType::NAME: itemStyleType = TypeInfoRetriver<Ptr<list::ListView##NAME##ContentProvider>>::CreateTypeInfo(); break;
|
|
VIEW_TYPE_CASE(BigIcon)
|
|
VIEW_TYPE_CASE(SmallIcon)
|
|
VIEW_TYPE_CASE(List)
|
|
VIEW_TYPE_CASE(Tile)
|
|
VIEW_TYPE_CASE(Information)
|
|
VIEW_TYPE_CASE(Detail)
|
|
#undef VIEW_TYPE_CASE
|
|
}
|
|
|
|
auto createStyle = MakePtr<WfNewClassExpression>();
|
|
createStyle->type = GetTypeFromTypeInfo(itemStyleType.Obj());
|
|
|
|
if (iconSize)
|
|
{
|
|
createStyle->arguments.Add(iconSize);
|
|
|
|
auto falseValue = MakePtr<WfLiteralExpression>();
|
|
falseValue->value = WfLiteralValue::False;
|
|
createStyle->arguments.Add(falseValue);
|
|
}
|
|
else
|
|
{
|
|
{
|
|
auto ctorExpr = MakePtr<WfConstructorExpression>();
|
|
{
|
|
auto argument = MakePtr<WfConstructorArgument>();
|
|
{
|
|
auto key = MakePtr<WfReferenceExpression>();
|
|
key->name.value = L"x";
|
|
argument->key = key;
|
|
|
|
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->expression = ctorExpr;
|
|
|
|
createStyle->arguments.Add(iconSizeValue);
|
|
}
|
|
{
|
|
auto trueValue = MakePtr<WfLiteralExpression>();
|
|
trueValue->value = WfLiteralValue::True;
|
|
createStyle->arguments.Add(trueValue);
|
|
}
|
|
}
|
|
|
|
auto refControl = MakePtr<WfReferenceExpression>();
|
|
refControl->name.value = variableName.ToString();
|
|
|
|
auto refChangeItemStyle = MakePtr<WfMemberExpression>();
|
|
refChangeItemStyle->parent = refControl;
|
|
refChangeItemStyle->name.value = L"ChangeItemStyle";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refChangeItemStyle;
|
|
call->arguments.Add(createStyle);
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
block->statements.Add(stat);
|
|
}
|
|
|
|
public:
|
|
GuiListViewInstanceLoaderBase()
|
|
:BASE_TYPE(description::TypeInfo<TControl>::content.typeName, L"CreateListViewStyle")
|
|
{
|
|
_View = GlobalStringKey::Get(L"View");
|
|
_IconSize = GlobalStringKey::Get(L"IconSize");
|
|
}
|
|
|
|
void GetPropertyNames(const typename BASE_TYPE::TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
if (CanCreate(typeInfo))
|
|
{
|
|
propertyNames.Add(_View);
|
|
propertyNames.Add(_IconSize);
|
|
}
|
|
BASE_TYPE::GetPropertyNames(typeInfo, propertyNames);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const typename BASE_TYPE::PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == _View)
|
|
{
|
|
auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver<ListViewViewType>::CreateTypeInfo());
|
|
info->usage = GuiInstancePropertyInfo::ConstructorArgument;
|
|
return info;
|
|
}
|
|
else if (propertyInfo.propertyName == _IconSize)
|
|
{
|
|
auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver<Size>::CreateTypeInfo());
|
|
info->usage = GuiInstancePropertyInfo::ConstructorArgument;
|
|
return info;
|
|
}
|
|
return BASE_TYPE::GetPropertyType(propertyInfo);
|
|
}
|
|
};
|
|
#undef BASE_TYPE
|
|
|
|
class GuiListViewInstanceLoader : public GuiListViewInstanceLoaderBase<GuiListView>
|
|
{
|
|
};
|
|
|
|
class GuiBindableListViewInstanceLoader : public GuiListViewInstanceLoaderBase<GuiBindableListView>
|
|
{
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiVirtualTreeViewInstanceLoader
|
|
***********************************************************************/
|
|
|
|
class GuiVirtualTreeViewInstanceLoader : public Object, public IGuiInstanceLoader
|
|
{
|
|
protected:
|
|
GlobalStringKey typeName;
|
|
|
|
public:
|
|
GuiVirtualTreeViewInstanceLoader()
|
|
{
|
|
typeName = GlobalStringKey::Get(description::TypeInfo<GuiVirtualTreeView>::content.typeName);
|
|
}
|
|
|
|
GlobalStringKey GetTypeName()override
|
|
{
|
|
return typeName;
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
propertyNames.Add(GlobalStringKey::_ItemTemplate);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == GlobalStringKey::_ItemTemplate)
|
|
{
|
|
auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver<TemplateProperty<GuiTreeItemTemplate>>::CreateTypeInfo());
|
|
return info;
|
|
}
|
|
return IGuiInstanceLoader::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
const auto& values = arguments.GetByIndex(index);
|
|
if (prop == GlobalStringKey::_ItemTemplate)
|
|
{
|
|
if (auto stat = CreateSetControlTemplateStyle<GuiTreeItemTemplate_ItemStyleProvider>(resolvingResult, variableName, arguments.GetByIndex(index)[0].expression, L"NodeStyleProvider"))
|
|
{
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiTreeViewInstanceLoader
|
|
***********************************************************************/
|
|
|
|
#define BASE_TYPE GuiTemplateControlInstanceLoader<TControl, GuiTreeViewTemplate_StyleProvider, GuiTreeViewTemplate>
|
|
template<typename TControl>
|
|
class GuiTreeViewInstanceLoaderBase : public BASE_TYPE
|
|
{
|
|
protected:
|
|
bool bindable;
|
|
GlobalStringKey _Nodes, _IconSize;
|
|
|
|
void PrepareAdditionalArgumentsAfterCreation(types::ResolvingResult& resolvingResult, const typename BASE_TYPE::TypeInfo& typeInfo, GlobalStringKey variableName, typename BASE_TYPE::ArgumentMap& arguments, GuiResourceError::List& errors, Ptr<WfBlockStatement> block)override
|
|
{
|
|
vint indexIconSize = arguments.Keys().IndexOf(_IconSize);
|
|
if (indexIconSize != -1)
|
|
{
|
|
Ptr<ITypeInfo> itemStyleType = TypeInfoRetriver<Ptr<tree::TreeViewNodeItemStyleProvider>>::CreateTypeInfo();
|
|
|
|
auto createStyle = MakePtr<WfNewClassExpression>();
|
|
createStyle->type = GetTypeFromTypeInfo(itemStyleType.Obj());
|
|
{
|
|
auto iconSize = arguments.GetByIndex(indexIconSize)[0].expression;
|
|
createStyle->arguments.Add(iconSize);
|
|
}
|
|
{
|
|
auto falseValue = MakePtr<WfLiteralExpression>();
|
|
falseValue->value = WfLiteralValue::False;
|
|
createStyle->arguments.Add(falseValue);
|
|
}
|
|
|
|
auto refControl = MakePtr<WfReferenceExpression>();
|
|
refControl->name.value = variableName.ToString();
|
|
|
|
auto refSetNodeStyleProvider = MakePtr<WfMemberExpression>();
|
|
refSetNodeStyleProvider->parent = refControl;
|
|
refSetNodeStyleProvider->name.value = L"SetNodeStyleProvider";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refSetNodeStyleProvider;
|
|
call->arguments.Add(createStyle);
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
|
|
public:
|
|
GuiTreeViewInstanceLoaderBase(bool _bindable)
|
|
:BASE_TYPE(description::TypeInfo<TControl>::content.typeName, L"CreateTreeViewStyle")
|
|
, bindable(_bindable)
|
|
{
|
|
_Nodes = GlobalStringKey::Get(L"Nodes");
|
|
_IconSize = GlobalStringKey::Get(L"IconSize");
|
|
}
|
|
|
|
void GetPropertyNames(const typename BASE_TYPE::TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
if (CanCreate(typeInfo))
|
|
{
|
|
propertyNames.Add(_IconSize);
|
|
}
|
|
if (!bindable)
|
|
{
|
|
propertyNames.Add(_Nodes);
|
|
}
|
|
BASE_TYPE::GetPropertyNames(typeInfo, propertyNames);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const typename BASE_TYPE::PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == _IconSize)
|
|
{
|
|
auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver<Size>::CreateTypeInfo());
|
|
info->usage = GuiInstancePropertyInfo::ConstructorArgument;
|
|
return info;
|
|
}
|
|
else if (propertyInfo.propertyName == _Nodes)
|
|
{
|
|
if (!bindable)
|
|
{
|
|
return GuiInstancePropertyInfo::Collection(TypeInfoRetriver<Ptr<tree::MemoryNodeProvider>>::CreateTypeInfo());
|
|
}
|
|
}
|
|
return BASE_TYPE::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const typename BASE_TYPE::TypeInfo& typeInfo, GlobalStringKey variableName, typename BASE_TYPE::ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
if (prop == _Nodes)
|
|
{
|
|
auto refControl = MakePtr<WfReferenceExpression>();
|
|
refControl->name.value = variableName.ToString();
|
|
|
|
auto refNodes = MakePtr<WfMemberExpression>();
|
|
refNodes->parent = refControl;
|
|
refNodes->name.value = L"Nodes";
|
|
|
|
auto refChildren = MakePtr<WfMemberExpression>();
|
|
refChildren->parent = refNodes;
|
|
refChildren->name.value = L"Children";
|
|
|
|
auto refAdd = MakePtr<WfMemberExpression>();
|
|
refAdd->parent = refChildren;
|
|
refAdd->name.value = L"Add";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refAdd;
|
|
call->arguments.Add(arguments.GetByIndex(index)[0].expression);
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return BASE_TYPE::AssignParameters(precompileContext, resolvingResult, typeInfo, variableName, arguments, attPosition, errors);
|
|
}
|
|
};
|
|
#undef BASE_TYPE
|
|
|
|
class GuiTreeViewInstanceLoader : public GuiTreeViewInstanceLoaderBase<GuiTreeView>
|
|
{
|
|
public:
|
|
GuiTreeViewInstanceLoader()
|
|
:GuiTreeViewInstanceLoaderBase<GuiTreeView>(false)
|
|
{
|
|
}
|
|
};
|
|
|
|
class GuiBindableTreeViewInstanceLoader : public GuiTreeViewInstanceLoaderBase<GuiBindableTreeView>
|
|
{
|
|
public:
|
|
GuiBindableTreeViewInstanceLoader()
|
|
:GuiTreeViewInstanceLoaderBase<GuiBindableTreeView>(true)
|
|
{
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiBindableDataGridInstanceLoader
|
|
***********************************************************************/
|
|
|
|
#define BASE_TYPE GuiTemplateControlInstanceLoader<GuiBindableDataGrid, GuiListViewTemplate_StyleProvider, GuiListViewTemplate>
|
|
class GuiBindableDataGridInstanceLoader : public BASE_TYPE
|
|
{
|
|
protected:
|
|
GlobalStringKey typeName;
|
|
GlobalStringKey _ViewModelContext;
|
|
GlobalStringKey _Columns;
|
|
|
|
void AddAdditionalArguments(types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceError::List& errors, Ptr<WfNewClassExpression> createControl)override
|
|
{
|
|
auto indexViewModelContext = arguments.Keys().IndexOf(_ViewModelContext);
|
|
if (indexViewModelContext == -1)
|
|
{
|
|
auto nullExpr = MakePtr<WfLiteralExpression>();
|
|
nullExpr->value = WfLiteralValue::Null;
|
|
createControl->arguments.Add(nullExpr);
|
|
}
|
|
else
|
|
{
|
|
createControl->arguments.Add(arguments.GetByIndex(indexViewModelContext)[0].expression);
|
|
}
|
|
}
|
|
public:
|
|
GuiBindableDataGridInstanceLoader()
|
|
:BASE_TYPE(description::TypeInfo<GuiBindableDataGrid>::content.typeName, L"CreateListViewStyle")
|
|
{
|
|
typeName = GlobalStringKey::Get(description::TypeInfo<GuiBindableDataGrid>::content.typeName);
|
|
_ViewModelContext = GlobalStringKey::Get(L"ViewModelContext");
|
|
_Columns = GlobalStringKey::Get(L"Columns");
|
|
}
|
|
|
|
GlobalStringKey GetTypeName()override
|
|
{
|
|
return typeName;
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
propertyNames.Add(_ViewModelContext);
|
|
propertyNames.Add(_Columns);
|
|
BASE_TYPE::GetPropertyNames(typeInfo, propertyNames);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == _ViewModelContext)
|
|
{
|
|
auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver<Value>::CreateTypeInfo());
|
|
info->usage = GuiInstancePropertyInfo::ConstructorArgument;
|
|
info->bindability = GuiInstancePropertyInfo::Bindable;
|
|
return info;
|
|
}
|
|
else if (propertyInfo.propertyName == _Columns)
|
|
{
|
|
return GuiInstancePropertyInfo::Collection(TypeInfoRetriver<Ptr<list::BindableDataColumn>>::CreateTypeInfo());
|
|
}
|
|
return BASE_TYPE::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
if (prop == _Columns)
|
|
{
|
|
auto refControl = MakePtr<WfReferenceExpression>();
|
|
refControl->name.value = variableName.ToString();
|
|
|
|
auto refAddBindableColumn = MakePtr<WfMemberExpression>();
|
|
refAddBindableColumn->parent = refControl;
|
|
refAddBindableColumn->name.value = L"AddBindableColumn";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refAddBindableColumn;
|
|
call->arguments.Add(arguments.GetByIndex(index)[0].expression);
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return BASE_TYPE::AssignParameters(precompileContext, resolvingResult, typeInfo, variableName, arguments, attPosition, errors);
|
|
}
|
|
};
|
|
#undef BASE_TYPE
|
|
|
|
/***********************************************************************
|
|
GuiTreeNodeInstanceLoader
|
|
***********************************************************************/
|
|
|
|
class GuiTreeNodeInstanceLoader : public Object, public IGuiInstanceLoader
|
|
{
|
|
protected:
|
|
GlobalStringKey typeName;
|
|
GlobalStringKey _Text, _Image, _Tag;
|
|
|
|
public:
|
|
GuiTreeNodeInstanceLoader()
|
|
:typeName(GlobalStringKey::Get(L"presentation::controls::tree::TreeNode"))
|
|
{
|
|
_Text = GlobalStringKey::Get(L"Text");
|
|
_Image = GlobalStringKey::Get(L"Image");
|
|
_Tag = GlobalStringKey::Get(L"Tag");
|
|
}
|
|
|
|
GlobalStringKey GetTypeName()override
|
|
{
|
|
return typeName;
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
propertyNames.Add(_Text);
|
|
propertyNames.Add(_Image);
|
|
propertyNames.Add(_Tag);
|
|
propertyNames.Add(GlobalStringKey::Empty);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == _Text)
|
|
{
|
|
return GuiInstancePropertyInfo::Assign(TypeInfoRetriver<WString>::CreateTypeInfo());
|
|
}
|
|
else if (propertyInfo.propertyName == _Image)
|
|
{
|
|
return GuiInstancePropertyInfo::Assign(TypeInfoRetriver<Ptr<GuiImageData>>::CreateTypeInfo());
|
|
}
|
|
else if (propertyInfo.propertyName == _Tag)
|
|
{
|
|
return GuiInstancePropertyInfo::Assign(TypeInfoRetriver<Value>::CreateTypeInfo());
|
|
}
|
|
else if (propertyInfo.propertyName == GlobalStringKey::Empty)
|
|
{
|
|
return GuiInstancePropertyInfo::Collection(TypeInfoRetriver<Ptr<tree::MemoryNodeProvider>>::CreateTypeInfo());
|
|
}
|
|
return IGuiInstanceLoader::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
bool CanCreate(const TypeInfo& typeInfo)override
|
|
{
|
|
return typeInfo.typeName == GetTypeName();
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> CreateInstance(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos tagPosition, GuiResourceError::List& errors)override
|
|
{
|
|
if (CanCreate(typeInfo))
|
|
{
|
|
auto createItem = MakePtr<WfNewClassExpression>();
|
|
createItem->type = GetTypeFromTypeInfo(TypeInfoRetriver<Ptr<tree::TreeViewItem>>::CreateTypeInfo().Obj());
|
|
|
|
auto createNode = MakePtr<WfNewClassExpression>();
|
|
createNode->type = GetTypeFromTypeInfo(TypeInfoRetriver<Ptr<tree::MemoryNodeProvider>>::CreateTypeInfo().Obj());
|
|
createNode->arguments.Add(createItem);
|
|
|
|
auto refNode = MakePtr<WfReferenceExpression>();
|
|
refNode->name.value = variableName.ToString();
|
|
|
|
auto assign = MakePtr<WfBinaryExpression>();
|
|
assign->op = WfBinaryOperator::Assign;
|
|
assign->first = refNode;
|
|
assign->second = createNode;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = assign;
|
|
return stat;
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
if (prop == GlobalStringKey::Empty)
|
|
{
|
|
auto refNode = MakePtr<WfReferenceExpression>();
|
|
refNode->name.value = variableName.ToString();
|
|
|
|
auto refChildren = MakePtr<WfMemberExpression>();
|
|
refChildren->parent = refNode;
|
|
refChildren->name.value = L"Children";
|
|
|
|
auto refAdd = MakePtr<WfMemberExpression>();
|
|
refAdd->parent = refChildren;
|
|
refAdd->name.value = L"Add";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refAdd;
|
|
call->arguments.Add(arguments.GetByIndex(index)[0].expression);
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
block->statements.Add(stat);
|
|
}
|
|
else if (prop == _Text || prop == _Image || prop == _Tag)
|
|
{
|
|
{
|
|
auto refNode = MakePtr<WfReferenceExpression>();
|
|
refNode->name.value = variableName.ToString();
|
|
|
|
auto refData = MakePtr<WfMemberExpression>();
|
|
refData->parent = refNode;
|
|
refData->name.value = L"Data";
|
|
|
|
auto castExpr = MakePtr<WfTypeCastingExpression>();
|
|
castExpr->strategy = WfTypeCastingStrategy::Strong;
|
|
castExpr->type = GetTypeFromTypeInfo(TypeInfoRetriver<Ptr<tree::TreeViewItem>>::CreateTypeInfo().Obj());
|
|
castExpr->expression = refData;
|
|
|
|
auto refProp = MakePtr<WfMemberExpression>();
|
|
refProp->parent = castExpr;
|
|
if (prop == _Text)
|
|
{
|
|
refProp->name.value = L"text";
|
|
}
|
|
else if (prop == _Image)
|
|
{
|
|
refProp->name.value = L"image";
|
|
}
|
|
else if (prop == _Tag)
|
|
{
|
|
refProp->name.value = L"tag";
|
|
}
|
|
|
|
auto assign = MakePtr<WfBinaryExpression>();
|
|
assign->op = WfBinaryOperator::Assign;
|
|
assign->first = refProp;
|
|
assign->second = arguments.GetByIndex(index)[0].expression;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = assign;
|
|
block->statements.Add(stat);
|
|
}
|
|
|
|
if (prop != _Tag)
|
|
{
|
|
auto refNode = MakePtr<WfReferenceExpression>();
|
|
refNode->name.value = variableName.ToString();
|
|
|
|
auto refNotifyDataModified = MakePtr<WfMemberExpression>();
|
|
refNotifyDataModified->parent = refNode;
|
|
refNotifyDataModified->name.value = L"NotifyDataModified";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refNotifyDataModified;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
Initialization
|
|
***********************************************************************/
|
|
|
|
void LoadListControls(IGuiInstanceLoaderManager* manager)
|
|
{
|
|
manager->CreateVirtualType(
|
|
GlobalStringKey::Get(description::TypeInfo<GuiComboBoxListControl>::content.typeName),
|
|
new GuiComboBoxInstanceLoader
|
|
);
|
|
|
|
manager->SetLoader(new GuiVirtualTextListControlInstanceLoader);
|
|
|
|
manager->SetLoader(new GuiListViewInstanceLoader);
|
|
manager->SetLoader(new GuiBindableListViewInstanceLoader);
|
|
|
|
manager->SetLoader(new GuiVirtualTreeViewInstanceLoader);
|
|
manager->SetLoader(new GuiTreeViewInstanceLoader);
|
|
manager->SetLoader(new GuiBindableTreeViewInstanceLoader);
|
|
|
|
manager->SetLoader(new GuiBindableDataGridInstanceLoader);
|
|
|
|
manager->CreateVirtualType(
|
|
GlobalStringKey::Get(description::TypeInfo<tree::MemoryNodeProvider>::content.typeName),
|
|
new GuiTreeNodeInstanceLoader
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|
|
/***********************************************************************
|
|
INSTANCELOADERS\GUIINSTANCELOADER_PLUGIN.CPP
|
|
***********************************************************************/
|
|
/*
|
|
GuiInstanceLoader_Plugin.cpp
|
|
GuiControl
|
|
default: GuiControl*, GuiGraphicsComposition*
|
|
GuiInstanceRootObject
|
|
default: GuiComponent*
|
|
GuiInstanceLoader_TemplateControl
|
|
GuiControl
|
|
ctor: ControlTemplate(ItemTemplate<T>)
|
|
GuiInstanceLoader_Compositions.cpp
|
|
GuiAxis
|
|
ctor: AxisDirection
|
|
GuiComposition
|
|
default: GuiControl*, GuiGraphicsComposition*, Ptr<IGuiGraphicsElement>
|
|
GuiTableComposition
|
|
Rows, Columns: array(GuiCellOption)
|
|
GuiCellComposition
|
|
Site: SiteValue
|
|
GuiInstanceLoader_Document.cpp
|
|
GuiDocumentItem
|
|
default: GuiControl*, GuiGraphicsComposition*
|
|
GuiDocumentViewer, GuiDocumentLable
|
|
default: Ptr<GuiDocumentItem>
|
|
GuiInstanceLoader_List.cpp
|
|
GuiVirtualTextList
|
|
ItemTemplate: TemplateProperty<GuiTextListItemTemplate>
|
|
GuiComboBox
|
|
ItemTemplate: TemplateProperty<GuiControlTemplate>
|
|
GuiListView, GuiBindableListView
|
|
ctor: View(ListViewViewType), IconSize(Size)
|
|
GuiVirtualTreeView
|
|
ItemTemplate: TemplateProperty<GuiTreeItemTemplate>
|
|
GuiTreeView, GuiBindableTreeView
|
|
ctor: IconSize(Size)
|
|
Nodes: array(Ptr<tree::MemoryNodeProvider>)
|
|
GuiBindableDataGrid
|
|
ctor: ViewModelContext
|
|
Columns: collection(Ptr<list::BindableDataColumn>)
|
|
tree::TreeNode
|
|
Text, Image, Tag
|
|
GuiInstanceLoader_Tab.cpp
|
|
GuiTab
|
|
default: GuiTabPage*
|
|
GuiTabPage
|
|
default: GuiControl*, GuiGraphicsComposition*
|
|
GuiInstanceLoader_Templates.cpp
|
|
GuiTemplate
|
|
ctor: \w+(ItemTemplate<T>)
|
|
GuiInstanceLoader_Toolstrip.cpp
|
|
GuiToolstripMenu, GuiToolstripMenuBar, GuiToolstripToolBar
|
|
default: collection(GuiControl*)
|
|
GuiToolstripButton
|
|
SubMenu-set: GuiToolstripMenu*
|
|
*/
|
|
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
namespace instance_loaders
|
|
{
|
|
|
|
#ifndef VCZH_DEBUG_NO_REFLECTION
|
|
|
|
/***********************************************************************
|
|
GuiControlInstanceLoader
|
|
***********************************************************************/
|
|
|
|
class GuiControlInstanceLoader : public Object, public IGuiInstanceLoader
|
|
{
|
|
protected:
|
|
GlobalStringKey typeName;
|
|
|
|
public:
|
|
GuiControlInstanceLoader()
|
|
{
|
|
typeName = GlobalStringKey::Get(description::TypeInfo<GuiControl>::content.typeName);
|
|
}
|
|
|
|
GlobalStringKey GetTypeName()override
|
|
{
|
|
return typeName;
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
propertyNames.Add(GlobalStringKey::Empty);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == GlobalStringKey::Empty)
|
|
{
|
|
auto info = GuiInstancePropertyInfo::Collection(nullptr);
|
|
info->acceptableTypes.Add(TypeInfoRetriver<GuiControl*>::CreateTypeInfo());
|
|
info->acceptableTypes.Add(TypeInfoRetriver<GuiGraphicsComposition*>::CreateTypeInfo());
|
|
if (propertyInfo.typeInfo.typeInfo->GetTypeDescriptor()->CanConvertTo(description::GetTypeDescriptor<GuiInstanceRootObject>()))
|
|
{
|
|
info->acceptableTypes.Add(TypeInfoRetriver<GuiComponent*>::CreateTypeInfo());
|
|
}
|
|
return info;
|
|
}
|
|
return IGuiInstanceLoader::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
const auto& values = arguments.GetByIndex(index);
|
|
if (prop == GlobalStringKey::Empty)
|
|
{
|
|
auto value = values[0].expression;
|
|
auto td = values[0].typeInfo->GetTypeDescriptor();
|
|
|
|
Ptr<WfExpression> expr;
|
|
if (td->CanConvertTo(description::GetTypeDescriptor<GuiComponent>()))
|
|
{
|
|
auto refControl = MakePtr<WfReferenceExpression>();
|
|
refControl->name.value = variableName.ToString();
|
|
|
|
auto refAddComponent = MakePtr<WfMemberExpression>();
|
|
refAddComponent->parent = refControl;
|
|
refAddComponent->name.value = L"AddComponent";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refAddComponent;
|
|
call->arguments.Add(value);
|
|
|
|
expr = call;
|
|
}
|
|
else if (td->CanConvertTo(description::GetTypeDescriptor<GuiControlHost>()))
|
|
{
|
|
auto refControl = MakePtr<WfReferenceExpression>();
|
|
refControl->name.value = variableName.ToString();
|
|
|
|
auto refAddControlHostComponent = MakePtr<WfMemberExpression>();
|
|
refAddControlHostComponent->parent = refControl;
|
|
refAddControlHostComponent->name.value = L"AddControlHostComponent";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refAddControlHostComponent;
|
|
call->arguments.Add(value);
|
|
|
|
expr = call;
|
|
}
|
|
else if (td->CanConvertTo(description::GetTypeDescriptor<GuiControl>()))
|
|
{
|
|
auto refControl = MakePtr<WfReferenceExpression>();
|
|
refControl->name.value = variableName.ToString();
|
|
|
|
auto refAddChild = MakePtr<WfMemberExpression>();
|
|
refAddChild->parent = refControl;
|
|
refAddChild->name.value = L"AddChild";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refAddChild;
|
|
call->arguments.Add(value);
|
|
|
|
expr = call;
|
|
}
|
|
else if (td->CanConvertTo(description::GetTypeDescriptor<GuiGraphicsComposition>()))
|
|
{
|
|
auto refControl = MakePtr<WfReferenceExpression>();
|
|
refControl->name.value = variableName.ToString();
|
|
|
|
auto refContainerComposition = MakePtr<WfMemberExpression>();
|
|
refContainerComposition->parent = refControl;
|
|
refContainerComposition->name.value = L"ContainerComposition";
|
|
|
|
auto refAddChild = MakePtr<WfMemberExpression>();
|
|
refAddChild->parent = refContainerComposition;
|
|
refAddChild->name.value = L"AddChild";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refAddChild;
|
|
call->arguments.Add(value);
|
|
|
|
expr = call;
|
|
}
|
|
|
|
if (expr)
|
|
{
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = expr;
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
#endif
|
|
|
|
/***********************************************************************
|
|
GuiPredefinedInstanceLoadersPlugin
|
|
***********************************************************************/
|
|
|
|
Ptr<WfExpression> CreateStandardDataPicker(IGuiInstanceLoader::ArgumentMap&)
|
|
{
|
|
using TControl = GuiDatePicker;
|
|
using TControlStyle = GuiDateComboBoxTemplate_StyleProvider;
|
|
using TTemplate = GuiDatePickerTemplate;
|
|
|
|
auto controlType = TypeInfoRetriver<TControl*>::CreateTypeInfo();
|
|
auto createControl = MakePtr<WfNewClassExpression>();
|
|
createControl->type = GetTypeFromTypeInfo(controlType.Obj());
|
|
createControl->arguments.Add(GuiTemplateControlInstanceLoader<TControl, TControlStyle, TTemplate>::CreateIThemeCall(L"CreateDatePickerStyle"));
|
|
|
|
return createControl;
|
|
}
|
|
|
|
void InitializeTrackerProgressBar(const WString& variableName, Ptr<WfBlockStatement> block)
|
|
{
|
|
auto refVariable = MakePtr<WfReferenceExpression>();
|
|
refVariable->name.value = variableName;
|
|
|
|
auto refSetPageSize = MakePtr<WfMemberExpression>();
|
|
refSetPageSize->parent = refVariable;
|
|
refSetPageSize->name.value = L"SetPageSize";
|
|
|
|
auto refZero = MakePtr<WfIntegerExpression>();
|
|
refZero->value.value = L"0";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refSetPageSize;
|
|
call->arguments.Add(refZero);
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
block->statements.Add(stat);
|
|
}
|
|
|
|
extern void LoadTabControls(IGuiInstanceLoaderManager* manager);
|
|
extern void LoadToolstripControls(IGuiInstanceLoaderManager* manager);
|
|
extern void LoadListControls(IGuiInstanceLoaderManager* manager);
|
|
extern void LoadDocumentControls(IGuiInstanceLoaderManager* manager);
|
|
extern void LoadCompositions(IGuiInstanceLoaderManager* manager);
|
|
extern void LoadTemplates(IGuiInstanceLoaderManager* manager);
|
|
|
|
class GuiPredefinedInstanceLoadersPlugin : public Object, public IGuiPlugin
|
|
{
|
|
public:
|
|
void Load()override
|
|
{
|
|
}
|
|
|
|
void AfterLoad()override
|
|
{
|
|
#ifndef VCZH_DEBUG_NO_REFLECTION
|
|
IGuiInstanceLoaderManager* manager=GetInstanceLoaderManager();
|
|
|
|
#define ADD_VIRTUAL_TYPE_LOADER(TYPENAME, LOADER)\
|
|
manager->CreateVirtualType(\
|
|
GlobalStringKey::Get(description::TypeInfo<TYPENAME>::content.typeName),\
|
|
new LOADER\
|
|
)
|
|
|
|
#define ADD_TEMPLATE_CONTROL(TYPENAME, STYLE_METHOD, TEMPLATE)\
|
|
manager->SetLoader(\
|
|
new GuiTemplateControlInstanceLoader<TYPENAME, TEMPLATE##_StyleProvider, TEMPLATE>(\
|
|
L"presentation::controls::" L ## #TYPENAME,\
|
|
L ## #STYLE_METHOD\
|
|
)\
|
|
)
|
|
|
|
#define ADD_TEMPLATE_CONTROL_2(TYPENAME, STYLE_METHOD, ARGUMENT_METHOD, TEMPLATE)\
|
|
manager->SetLoader(\
|
|
new GuiTemplateControlInstanceLoader<TYPENAME, TEMPLATE##_StyleProvider, TEMPLATE>(\
|
|
L"presentation::controls::" L ## #TYPENAME,\
|
|
L ## #STYLE_METHOD,\
|
|
L ## #ARGUMENT_METHOD\
|
|
)\
|
|
)
|
|
|
|
#define ADD_TEMPLATE_CONTROL_3(TYPENAME, STYLE_METHOD, ARGUMENT_FUNCTION, TEMPLATE)\
|
|
manager->SetLoader(\
|
|
new GuiTemplateControlInstanceLoader<TYPENAME, TEMPLATE##_StyleProvider, TEMPLATE>(\
|
|
L"presentation::controls::" L ## #TYPENAME,\
|
|
L ## #STYLE_METHOD,\
|
|
ARGUMENT_FUNCTION\
|
|
)\
|
|
)
|
|
|
|
#define ADD_VIRTUAL_CONTROL(VIRTUALTYPENAME, TYPENAME, STYLE_METHOD, TEMPLATE)\
|
|
manager->CreateVirtualType(GlobalStringKey::Get(description::TypeInfo<TYPENAME>::content.typeName),\
|
|
new GuiTemplateControlInstanceLoader<TYPENAME, TEMPLATE##_StyleProvider, TEMPLATE>(\
|
|
L"presentation::controls::Gui" L ## #VIRTUALTYPENAME,\
|
|
L ## #STYLE_METHOD\
|
|
)\
|
|
)
|
|
|
|
#define ADD_VIRTUAL_CONTROL_2(VIRTUALTYPENAME, TYPENAME, STYLE_METHOD, ARGUMENT_METHOD, TEMPLATE)\
|
|
manager->CreateVirtualType(GlobalStringKey::Get(description::TypeInfo<TYPENAME>::content.typeName),\
|
|
new GuiTemplateControlInstanceLoader<TYPENAME, TEMPLATE##_StyleProvider, TEMPLATE>(\
|
|
L"presentation::controls::Gui" L ## #VIRTUALTYPENAME,\
|
|
L ## #STYLE_METHOD,\
|
|
L ## #ARGUMENT_METHOD\
|
|
)\
|
|
)
|
|
|
|
#define ADD_VIRTUAL_CONTROL_F(VIRTUALTYPENAME, TYPENAME, STYLE_METHOD, TEMPLATE, INIT_FUNCTION)\
|
|
manager->CreateVirtualType(GlobalStringKey::Get(description::TypeInfo<TYPENAME>::content.typeName),\
|
|
new GuiTemplateControlInstanceLoader<TYPENAME, TEMPLATE##_StyleProvider, TEMPLATE>(\
|
|
L"presentation::controls::Gui" L ## #VIRTUALTYPENAME,\
|
|
L ## #STYLE_METHOD,\
|
|
INIT_FUNCTION\
|
|
)\
|
|
)
|
|
|
|
manager->SetLoader(new GuiControlInstanceLoader);
|
|
|
|
ADD_TEMPLATE_CONTROL ( GuiCustomControl, CreateCustomControlStyle, GuiControlTemplate );
|
|
ADD_TEMPLATE_CONTROL ( GuiLabel, CreateLabelStyle, GuiLabelTemplate );
|
|
ADD_TEMPLATE_CONTROL ( GuiButton, CreateButtonStyle, GuiButtonTemplate );
|
|
ADD_TEMPLATE_CONTROL ( GuiScrollContainer, CreateScrollContainerStyle, GuiScrollViewTemplate );
|
|
ADD_TEMPLATE_CONTROL ( GuiWindow, CreateWindowStyle, GuiWindowTemplate );
|
|
ADD_TEMPLATE_CONTROL_2 ( GuiTextList, CreateTextListStyle, CreateTextListItemStyle, GuiTextListTemplate );
|
|
ADD_TEMPLATE_CONTROL_2 ( GuiBindableTextList, CreateTextListStyle, CreateTextListItemStyle, GuiTextListTemplate );
|
|
ADD_TEMPLATE_CONTROL ( GuiMultilineTextBox, CreateMultilineTextBoxStyle, GuiMultilineTextBoxTemplate );
|
|
ADD_TEMPLATE_CONTROL ( GuiSinglelineTextBox, CreateTextBoxStyle, GuiSinglelineTextBoxTemplate );
|
|
ADD_TEMPLATE_CONTROL ( GuiDatePicker, CreateDatePickerStyle, GuiDatePickerTemplate );
|
|
ADD_TEMPLATE_CONTROL_3 ( GuiDateComboBox, CreateComboBoxStyle, CreateStandardDataPicker, GuiDateComboBoxTemplate );
|
|
ADD_TEMPLATE_CONTROL ( GuiStringGrid, CreateListViewStyle, GuiListViewTemplate );
|
|
|
|
ADD_VIRTUAL_CONTROL (GroupBox, GuiControl, CreateGroupBoxStyle, GuiControlTemplate );
|
|
ADD_VIRTUAL_CONTROL (MenuSplitter, GuiControl, CreateMenuSplitterStyle, GuiControlTemplate );
|
|
ADD_VIRTUAL_CONTROL (MenuBarButton, GuiToolstripButton, CreateMenuBarButtonStyle, GuiToolstripButtonTemplate );
|
|
ADD_VIRTUAL_CONTROL (MenuItemButton, GuiToolstripButton, CreateMenuItemButtonStyle, GuiToolstripButtonTemplate );
|
|
ADD_VIRTUAL_CONTROL (ToolstripDropdownButton, GuiToolstripButton, CreateToolBarDropdownButtonStyle, GuiToolstripButtonTemplate );
|
|
ADD_VIRTUAL_CONTROL (ToolstripSplitButton, GuiToolstripButton, CreateToolBarSplitButtonStyle, GuiToolstripButtonTemplate );
|
|
ADD_VIRTUAL_CONTROL (ToolstripSplitter, GuiControl, CreateToolBarSplitterStyle, GuiControlTemplate );
|
|
ADD_VIRTUAL_CONTROL (CheckBox, GuiSelectableButton, CreateCheckBoxStyle, GuiSelectableButtonTemplate );
|
|
ADD_VIRTUAL_CONTROL (RadioButton, GuiSelectableButton, CreateRadioButtonStyle, GuiSelectableButtonTemplate );
|
|
ADD_VIRTUAL_CONTROL (HScroll, GuiScroll, CreateHScrollStyle, GuiScrollTemplate );
|
|
ADD_VIRTUAL_CONTROL (VScroll, GuiScroll, CreateVScrollStyle, GuiScrollTemplate );
|
|
ADD_VIRTUAL_CONTROL (DocumentTextBox, GuiDocumentLabel, CreateDocumentTextBoxStyle, GuiDocumentLabelTemplate );
|
|
ADD_VIRTUAL_CONTROL_F (HTracker, GuiScroll, CreateHTrackerStyle, GuiScrollTemplate, InitializeTrackerProgressBar);
|
|
ADD_VIRTUAL_CONTROL_F (VTracker, GuiScroll, CreateVTrackerStyle, GuiScrollTemplate, InitializeTrackerProgressBar);
|
|
ADD_VIRTUAL_CONTROL_F (ProgressBar, GuiScroll, CreateProgressBarStyle, GuiScrollTemplate, InitializeTrackerProgressBar);
|
|
ADD_VIRTUAL_CONTROL_2 (CheckTextList, GuiTextList, CreateTextListStyle, CreateCheckTextListItemStyle, GuiTextListTemplate );
|
|
ADD_VIRTUAL_CONTROL_2 (RadioTextList, GuiTextList, CreateTextListStyle, CreateRadioTextListItemStyle, GuiTextListTemplate );
|
|
|
|
LoadTabControls(manager);
|
|
LoadToolstripControls(manager);
|
|
LoadListControls(manager);
|
|
LoadDocumentControls(manager);
|
|
LoadCompositions(manager);
|
|
LoadTemplates(manager);
|
|
|
|
#undef ADD_VIRTUAL_TYPE_LOADER
|
|
#undef ADD_TEMPLATE_CONTROL
|
|
#undef ADD_TEMPLATE_CONTROL_2
|
|
#undef ADD_TEMPLATE_CONTROL_3
|
|
#undef ADD_VIRTUAL_CONTROL
|
|
#undef ADD_VIRTUAL_CONTROL_2
|
|
#undef ADD_VIRTUAL_CONTROL_F
|
|
#endif
|
|
}
|
|
|
|
void Unload()override
|
|
{
|
|
}
|
|
};
|
|
GUI_REGISTER_PLUGIN(GuiPredefinedInstanceLoadersPlugin)
|
|
}
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
INSTANCELOADERS\GUIINSTANCELOADER_TAB.CPP
|
|
***********************************************************************/
|
|
|
|
#ifndef VCZH_DEBUG_NO_REFLECTION
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
namespace instance_loaders
|
|
{
|
|
|
|
/***********************************************************************
|
|
GuiTabInstanceLoader
|
|
***********************************************************************/
|
|
|
|
#define BASE_TYPE GuiTemplateControlInstanceLoader<GuiTab, GuiTabTemplate_StyleProvider, GuiTabTemplate>
|
|
class GuiTabInstanceLoader : public BASE_TYPE
|
|
{
|
|
public:
|
|
GuiTabInstanceLoader()
|
|
:BASE_TYPE(description::TypeInfo<GuiTab>::content.typeName, L"CreateTabStyle")
|
|
{
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
propertyNames.Add(GlobalStringKey::Empty);
|
|
BASE_TYPE::GetPropertyNames(typeInfo, propertyNames);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == GlobalStringKey::Empty)
|
|
{
|
|
return GuiInstancePropertyInfo::CollectionWithParent(TypeInfoRetriver<GuiTabPage*>::CreateTypeInfo());
|
|
}
|
|
return BASE_TYPE::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
const auto& values = arguments.GetByIndex(index);
|
|
if (prop == GlobalStringKey::Empty)
|
|
{
|
|
auto value = values[0].expression;
|
|
auto td = values[0].typeInfo->GetTypeDescriptor();
|
|
|
|
Ptr<WfExpression> expr;
|
|
if (td->CanConvertTo(description::GetTypeDescriptor<GuiTabPage>()))
|
|
{
|
|
auto refControl = MakePtr<WfReferenceExpression>();
|
|
refControl->name.value = variableName.ToString();
|
|
|
|
auto refCreatePage = MakePtr<WfMemberExpression>();
|
|
refCreatePage->parent = refControl;
|
|
refCreatePage->name.value = L"CreatePage";
|
|
|
|
auto refMinus1 = MakePtr<WfIntegerExpression>();
|
|
refMinus1->value.value = L"-1";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refCreatePage;
|
|
call->arguments.Add(value);
|
|
call->arguments.Add(refMinus1);
|
|
|
|
expr = call;
|
|
}
|
|
|
|
if (expr)
|
|
{
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = expr;
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return BASE_TYPE::AssignParameters(precompileContext, resolvingResult, typeInfo, variableName, arguments, attPosition, errors);
|
|
}
|
|
};
|
|
#undef BASE_TYPE
|
|
|
|
/***********************************************************************
|
|
GuiTabPageInstanceLoader
|
|
***********************************************************************/
|
|
|
|
class GuiTabPageInstanceLoader : public Object, public IGuiInstanceLoader
|
|
{
|
|
protected:
|
|
GlobalStringKey typeName;
|
|
|
|
public:
|
|
GuiTabPageInstanceLoader()
|
|
{
|
|
typeName = GlobalStringKey::Get(description::TypeInfo<GuiTabPage>::content.typeName);
|
|
}
|
|
|
|
GlobalStringKey GetTypeName()override
|
|
{
|
|
return typeName;
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
propertyNames.Add(GlobalStringKey::Empty);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == GlobalStringKey::Empty)
|
|
{
|
|
auto info = GuiInstancePropertyInfo::Collection(nullptr);
|
|
info->acceptableTypes.Add(TypeInfoRetriver<GuiControl*>::CreateTypeInfo());
|
|
info->acceptableTypes.Add(TypeInfoRetriver<GuiGraphicsComposition*>::CreateTypeInfo());
|
|
return info;
|
|
}
|
|
return IGuiInstanceLoader::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
const auto& values = arguments.GetByIndex(index);
|
|
if (prop == GlobalStringKey::Empty)
|
|
{
|
|
auto value = values[0].expression;
|
|
auto td = values[0].typeInfo->GetTypeDescriptor();
|
|
|
|
Ptr<WfExpression> expr;
|
|
if (td->CanConvertTo(description::GetTypeDescriptor<GuiControl>()))
|
|
{
|
|
auto refBoundsComposition = MakePtr<WfMemberExpression>();
|
|
refBoundsComposition->parent = value;
|
|
refBoundsComposition->name.value = L"BoundsComposition";
|
|
|
|
expr = refBoundsComposition;
|
|
}
|
|
else if (td->CanConvertTo(description::GetTypeDescriptor<GuiGraphicsComposition>()))
|
|
{
|
|
expr = value;
|
|
}
|
|
|
|
if (expr)
|
|
{
|
|
auto refControl = MakePtr<WfReferenceExpression>();
|
|
refControl->name.value = variableName.ToString();
|
|
|
|
auto refContainerComposition = MakePtr<WfMemberExpression>();
|
|
refContainerComposition->parent = refControl;
|
|
refContainerComposition->name.value = L"ContainerComposition";
|
|
|
|
auto refAddChild = MakePtr<WfMemberExpression>();
|
|
refAddChild->parent = refContainerComposition;
|
|
refAddChild->name.value = L"AddChild";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refAddChild;
|
|
call->arguments.Add(expr);
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
Initialization
|
|
***********************************************************************/
|
|
|
|
void LoadTabControls(IGuiInstanceLoaderManager* manager)
|
|
{
|
|
manager->SetLoader(new GuiTabInstanceLoader);
|
|
manager->SetLoader(new GuiTabPageInstanceLoader);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|
|
/***********************************************************************
|
|
INSTANCELOADERS\GUIINSTANCELOADER_TEMPLATES.CPP
|
|
***********************************************************************/
|
|
|
|
#ifndef VCZH_DEBUG_NO_REFLECTION
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
namespace instance_loaders
|
|
{
|
|
|
|
/***********************************************************************
|
|
GuiTemplateInstanceLoader
|
|
***********************************************************************/
|
|
|
|
class GuiTemplateInstanceLoader : public Object, public IGuiInstanceLoader
|
|
{
|
|
protected:
|
|
GlobalStringKey typeName;
|
|
|
|
public:
|
|
GuiTemplateInstanceLoader()
|
|
{
|
|
typeName = GlobalStringKey::Get(description::TypeInfo<GuiTemplate>::content.typeName);
|
|
}
|
|
|
|
GlobalStringKey GetTypeName()override
|
|
{
|
|
return typeName;
|
|
}
|
|
|
|
void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
List<ITypeDescriptor*> tds;
|
|
tds.Add(typeInfo.typeInfo->GetTypeDescriptor());
|
|
|
|
for (vint i = 0; i < tds.Count(); i++)
|
|
{
|
|
auto td = tds[i];
|
|
if (td != description::GetTypeDescriptor<GuiWindowTemplate>())
|
|
{
|
|
vint propCount = td->GetPropertyCount();
|
|
for (vint i = 0; i < propCount; i++)
|
|
{
|
|
auto prop = td->GetProperty(i);
|
|
if (prop->IsWritable() && INVLOC.EndsWith(prop->GetName(), L"Template", Locale::None))
|
|
{
|
|
propertyNames.Add(GlobalStringKey::Get(prop->GetName()));
|
|
}
|
|
}
|
|
|
|
vint baseCount = td->GetBaseTypeDescriptorCount();
|
|
for (vint i = 0; i < baseCount; i++)
|
|
{
|
|
auto baseTd = td->GetBaseTypeDescriptor(i);
|
|
if (!tds.Contains(baseTd))
|
|
{
|
|
tds.Add(baseTd);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
Initialization
|
|
***********************************************************************/
|
|
|
|
void LoadTemplates(IGuiInstanceLoaderManager* manager)
|
|
{
|
|
manager->SetLoader(new GuiTemplateInstanceLoader);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|
|
/***********************************************************************
|
|
INSTANCELOADERS\GUIINSTANCELOADER_TOOLSTRIP.CPP
|
|
***********************************************************************/
|
|
|
|
#ifndef VCZH_DEBUG_NO_REFLECTION
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
namespace instance_loaders
|
|
{
|
|
Ptr<workflow::WfStatement> AddControlToToolstrip(GlobalStringKey variableName, IGuiInstanceLoader::ArgumentMap& arguments, GuiResourceError::List& errors)
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, prop, index, arguments.Keys())
|
|
{
|
|
const auto& values = arguments.GetByIndex(index);
|
|
if (prop == GlobalStringKey::Empty)
|
|
{
|
|
auto value = values[0].expression;
|
|
auto td = values[0].typeInfo->GetTypeDescriptor();
|
|
|
|
Ptr<WfExpression> expr;
|
|
if (td->CanConvertTo(description::GetTypeDescriptor<GuiControl>()))
|
|
{
|
|
auto refControl = MakePtr<WfReferenceExpression>();
|
|
refControl->name.value = variableName.ToString();
|
|
|
|
auto refToolstripItems = MakePtr<WfMemberExpression>();
|
|
refToolstripItems->parent = refControl;
|
|
refToolstripItems->name.value = L"ToolstripItems";
|
|
|
|
auto refAdd = MakePtr<WfMemberExpression>();
|
|
refAdd->parent = refToolstripItems;
|
|
refAdd->name.value = L"Add";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refAdd;
|
|
call->arguments.Add(value);
|
|
|
|
expr = call;
|
|
}
|
|
|
|
if (expr)
|
|
{
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = expr;
|
|
block->statements.Add(stat);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (block->statements.Count() > 0)
|
|
{
|
|
return block;
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
/***********************************************************************
|
|
GuiToolstripInstanceLoaderBase
|
|
***********************************************************************/
|
|
|
|
template<typename TBaseType>
|
|
class GuiToolstripInstanceLoaderBase : public TBaseType
|
|
{
|
|
public:
|
|
using ArgumentMap = IGuiInstanceLoader::ArgumentMap;
|
|
using PropertyInfo = IGuiInstanceLoader::PropertyInfo;
|
|
|
|
GuiToolstripInstanceLoaderBase(const WString& _typeName, const WString& _styleMethod, Ptr<WfExpression>(*_argumentFunction)(ArgumentMap&))
|
|
:TBaseType(_typeName, _styleMethod, _argumentFunction)
|
|
{
|
|
}
|
|
|
|
GuiToolstripInstanceLoaderBase(const WString& _typeName, const WString& _styleMethod)
|
|
:TBaseType(_typeName, _styleMethod)
|
|
{
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
propertyNames.Add(GlobalStringKey::Empty);
|
|
TBaseType::GetPropertyNames(typeInfo, propertyNames);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == GlobalStringKey::Empty)
|
|
{
|
|
return GuiInstancePropertyInfo::CollectionWithParent(TypeInfoRetriver<GuiControl*>::CreateTypeInfo());
|
|
}
|
|
return TBaseType::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
if (auto statement = AddControlToToolstrip(variableName, arguments, errors))
|
|
{
|
|
return statement;
|
|
}
|
|
else
|
|
{
|
|
return TBaseType::AssignParameters(precompileContext, resolvingResult, typeInfo, variableName, arguments, attPosition, errors);
|
|
}
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
GuiToolstripMenuInstanceLoader
|
|
***********************************************************************/
|
|
|
|
#define BASE_TYPE GuiTemplateControlInstanceLoader<GuiToolstripMenu, GuiMenuTemplate_StyleProvider, GuiMenuTemplate>
|
|
class GuiToolstripMenuInstanceLoader : public GuiToolstripInstanceLoaderBase<BASE_TYPE>
|
|
{
|
|
public:
|
|
static Ptr<WfExpression> ArgumentFunction(ArgumentMap&)
|
|
{
|
|
auto expr = MakePtr<WfLiteralExpression>();
|
|
expr->value = WfLiteralValue::Null;
|
|
return expr;
|
|
}
|
|
public:
|
|
GuiToolstripMenuInstanceLoader()
|
|
:GuiToolstripInstanceLoaderBase<BASE_TYPE>(description::TypeInfo<GuiToolstripMenu>::content.typeName, L"CreateMenuStyle", ArgumentFunction)
|
|
{
|
|
}
|
|
};
|
|
#undef BASE_TYPE
|
|
|
|
/***********************************************************************
|
|
GuiToolstripMenuBarInstanceLoader
|
|
***********************************************************************/
|
|
|
|
#define BASE_TYPE GuiTemplateControlInstanceLoader<GuiToolstripMenuBar, GuiControlTemplate_StyleProvider, GuiControlTemplate>
|
|
class GuiToolstripMenuBarInstanceLoader : public GuiToolstripInstanceLoaderBase<BASE_TYPE>
|
|
{
|
|
public:
|
|
GuiToolstripMenuBarInstanceLoader()
|
|
:GuiToolstripInstanceLoaderBase<BASE_TYPE>(description::TypeInfo<GuiToolstripMenuBar>::content.typeName, L"CreateMenuBarStyle")
|
|
{
|
|
}
|
|
};
|
|
#undef BASE_TYPE
|
|
|
|
/***********************************************************************
|
|
GuiToolstripToolBarInstanceLoader
|
|
***********************************************************************/
|
|
|
|
#define BASE_TYPE GuiTemplateControlInstanceLoader<GuiToolstripToolBar, GuiControlTemplate_StyleProvider, GuiControlTemplate>
|
|
class GuiToolstripToolBarInstanceLoader : public GuiToolstripInstanceLoaderBase<BASE_TYPE>
|
|
{
|
|
public:
|
|
GuiToolstripToolBarInstanceLoader()
|
|
:GuiToolstripInstanceLoaderBase<BASE_TYPE>(description::TypeInfo<GuiToolstripToolBar>::content.typeName, L"CreateToolBarStyle")
|
|
{
|
|
}
|
|
};
|
|
#undef BASE_TYPE
|
|
|
|
/***********************************************************************
|
|
GuiToolstripButtonInstanceLoader
|
|
***********************************************************************/
|
|
|
|
#define BASE_TYPE GuiTemplateControlInstanceLoader<GuiToolstripButton, GuiToolstripButtonTemplate_StyleProvider, GuiToolstripButtonTemplate>
|
|
class GuiToolstripButtonInstanceLoader : public BASE_TYPE
|
|
{
|
|
protected:
|
|
GlobalStringKey _SubMenu;
|
|
|
|
public:
|
|
GuiToolstripButtonInstanceLoader()
|
|
:BASE_TYPE(description::TypeInfo<GuiToolstripButton>::content.typeName, L"CreateToolBarButtonStyle")
|
|
{
|
|
_SubMenu = GlobalStringKey::Get(L"SubMenu");
|
|
}
|
|
|
|
void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames)override
|
|
{
|
|
propertyNames.Add(_SubMenu);
|
|
BASE_TYPE::GetPropertyNames(typeInfo, propertyNames);
|
|
}
|
|
|
|
Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo)override
|
|
{
|
|
if (propertyInfo.propertyName == _SubMenu)
|
|
{
|
|
return GuiInstancePropertyInfo::Set(TypeInfoRetriver<GuiToolstripMenu*>::CreateTypeInfo());
|
|
}
|
|
return BASE_TYPE::GetPropertyType(propertyInfo);
|
|
}
|
|
|
|
Ptr<workflow::WfExpression> GetParameter(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const PropertyInfo& propertyInfo, GlobalStringKey variableName, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override
|
|
{
|
|
if (propertyInfo.propertyName == _SubMenu)
|
|
{
|
|
auto refControl = MakePtr<WfReferenceExpression>();
|
|
refControl->name.value = variableName.ToString();
|
|
|
|
auto refEnsureToolstripSubMenu = MakePtr<WfMemberExpression>();
|
|
refEnsureToolstripSubMenu->parent = refControl;
|
|
refEnsureToolstripSubMenu->name.value = L"EnsureToolstripSubMenu";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = refEnsureToolstripSubMenu;
|
|
|
|
return call;
|
|
}
|
|
return BASE_TYPE::GetParameter(precompileContext, resolvingResult, propertyInfo, variableName, attPosition, errors);
|
|
}
|
|
};
|
|
#undef BASE_TYPE
|
|
|
|
/***********************************************************************
|
|
Initialization
|
|
***********************************************************************/
|
|
|
|
void LoadToolstripControls(IGuiInstanceLoaderManager* manager)
|
|
{
|
|
manager->SetLoader(new GuiToolstripMenuInstanceLoader);
|
|
manager->SetLoader(new GuiToolstripMenuBarInstanceLoader);
|
|
manager->SetLoader(new GuiToolstripToolBarInstanceLoader);
|
|
manager->SetLoader(new GuiToolstripButtonInstanceLoader);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|
|
/***********************************************************************
|
|
INSTANCEQUERY\GUIINSTANCEQUERY.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
using namespace collections;
|
|
|
|
/***********************************************************************
|
|
ExecuteQueryVisitor
|
|
***********************************************************************/
|
|
|
|
class ExecuteQueryVisitor : public Object, public GuiIqQuery::IVisitor
|
|
{
|
|
public:
|
|
Ptr<GuiInstanceContext> context;
|
|
List<Ptr<GuiConstructorRepr>>& input;
|
|
List<Ptr<GuiConstructorRepr>>& output;
|
|
|
|
ExecuteQueryVisitor(Ptr<GuiInstanceContext> _context, List<Ptr<GuiConstructorRepr>>& _input, List<Ptr<GuiConstructorRepr>>& _output)
|
|
:context(_context), input(_input), output(_output)
|
|
{
|
|
}
|
|
|
|
static bool TestCtor(GuiIqPrimaryQuery* node, GlobalStringKey attribute, Ptr<GuiConstructorRepr> ctor)
|
|
{
|
|
if (node->attributeNameOption == GuiIqNameOption::Specified && node->attributeName.value != attribute.ToString())
|
|
{
|
|
return false;
|
|
}
|
|
if (node->typeNameOption == GuiIqNameOption::Specified && node->typeName.value != ctor->typeName.ToString())
|
|
{
|
|
return false;
|
|
}
|
|
if (node->referenceName.value != L"")
|
|
{
|
|
bool instanceName = ctor->instanceName != GlobalStringKey::Empty && node->referenceName.value == ctor->instanceName.ToString();
|
|
bool styleName = ctor->styleName && node->referenceName.value == ctor->styleName.Value();
|
|
return instanceName || styleName;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void Traverse(GuiIqPrimaryQuery* node, Ptr<GuiAttSetterRepr> setter)
|
|
{
|
|
if (setter)
|
|
{
|
|
FOREACH_INDEXER(GlobalStringKey, attribute, index, setter->setters.Keys())
|
|
{
|
|
auto setterValue = setter->setters.Values()[index];
|
|
FOREACH(Ptr<GuiValueRepr>, value, setterValue->values)
|
|
{
|
|
if (auto ctor = value.Cast<GuiConstructorRepr>())
|
|
{
|
|
if (TestCtor(node, attribute, ctor))
|
|
{
|
|
output.Add(ctor);
|
|
}
|
|
}
|
|
if (node->childOption == GuiIqChildOption::Indirect)
|
|
{
|
|
if (auto setter = value.Cast<GuiAttSetterRepr>())
|
|
{
|
|
Traverse(node, setter);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (TestCtor(node, GlobalStringKey::Empty, context->instance))
|
|
{
|
|
output.Add(context->instance);
|
|
}
|
|
if (node->childOption == GuiIqChildOption::Indirect)
|
|
{
|
|
Traverse(node, context->instance);
|
|
}
|
|
}
|
|
}
|
|
|
|
void Visit(GuiIqPrimaryQuery* node)override
|
|
{
|
|
auto inputExists = &input;
|
|
if (inputExists)
|
|
{
|
|
FOREACH(Ptr<GuiConstructorRepr>, setter, input)
|
|
{
|
|
Traverse(node, setter);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Traverse(node, 0);
|
|
}
|
|
}
|
|
|
|
void Visit(GuiIqCascadeQuery* node)override
|
|
{
|
|
List<Ptr<GuiConstructorRepr>> temp;
|
|
ExecuteQuery(node->parent, context, input, temp);
|
|
ExecuteQuery(node->child, context, temp, output);
|
|
}
|
|
|
|
void Visit(GuiIqSetQuery* node)override
|
|
{
|
|
List<Ptr<GuiConstructorRepr>> first, second;
|
|
ExecuteQuery(node->first, context, input, first);
|
|
ExecuteQuery(node->second, context, input, second);
|
|
|
|
switch (node->op)
|
|
{
|
|
case GuiIqBinaryOperator::ExclusiveOr:
|
|
CopyFrom(output, From(first).Except(second).Union(From(second).Except(second)));
|
|
break;
|
|
case GuiIqBinaryOperator::Intersect:
|
|
CopyFrom(output, From(first).Intersect(second));
|
|
break;
|
|
case GuiIqBinaryOperator::Union:
|
|
CopyFrom(output, From(first).Union(second));
|
|
break;
|
|
case GuiIqBinaryOperator::Substract:
|
|
CopyFrom(output, From(first).Except(second));
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
ExecuteQuery
|
|
***********************************************************************/
|
|
|
|
void ExecuteQuery(Ptr<GuiIqQuery> query, Ptr<GuiInstanceContext> context, collections::List<Ptr<GuiConstructorRepr>>& input, collections::List<Ptr<GuiConstructorRepr>>& output)
|
|
{
|
|
ExecuteQueryVisitor visitor(context, input, output);
|
|
query->Accept(&visitor);
|
|
}
|
|
|
|
void ExecuteQuery(Ptr<GuiIqQuery> query, Ptr<GuiInstanceContext> context, collections::List<Ptr<GuiConstructorRepr>>& output)
|
|
{
|
|
ExecuteQuery(query, context, *(List<Ptr<GuiConstructorRepr>>*)0, output);
|
|
}
|
|
|
|
/***********************************************************************
|
|
ApplyStyle
|
|
***********************************************************************/
|
|
|
|
void ApplyStyleInternal(Ptr<GuiAttSetterRepr> src, Ptr<GuiAttSetterRepr> dst)
|
|
{
|
|
FOREACH_INDEXER(GlobalStringKey, attribute, srcIndex, src->setters.Keys())
|
|
{
|
|
auto srcValue = src->setters.Values()[srcIndex];
|
|
vint dstIndex = dst->setters.Keys().IndexOf(attribute);
|
|
if (dstIndex == -1)
|
|
{
|
|
dst->setters.Add(attribute, srcValue);
|
|
}
|
|
else
|
|
{
|
|
auto dstValue = dst->setters.Values()[dstIndex];
|
|
if (srcValue->binding == dstValue->binding)
|
|
{
|
|
if (srcValue->binding == GlobalStringKey::_Set)
|
|
{
|
|
ApplyStyleInternal(srcValue->values[0].Cast<GuiAttSetterRepr>(), dstValue->values[0].Cast<GuiAttSetterRepr>());
|
|
}
|
|
else
|
|
{
|
|
CopyFrom(dstValue->values, srcValue->values, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, eventName, srcIndex, src->eventHandlers.Keys())
|
|
{
|
|
if (!dst->eventHandlers.Keys().Contains(eventName))
|
|
{
|
|
auto srcValue = src->eventHandlers.Values()[srcIndex];
|
|
dst->eventHandlers.Add(eventName, srcValue);
|
|
}
|
|
}
|
|
|
|
FOREACH_INDEXER(GlobalStringKey, varName, srcIndex, src->environmentVariables.Keys())
|
|
{
|
|
if (!dst->environmentVariables.Keys().Contains(varName))
|
|
{
|
|
auto srcValue = src->environmentVariables.Values()[srcIndex];
|
|
dst->environmentVariables.Add(varName, srcValue);
|
|
}
|
|
}
|
|
}
|
|
|
|
void ApplyStyle(Ptr<GuiInstanceStyle> style, Ptr<GuiConstructorRepr> ctor)
|
|
{
|
|
ApplyStyleInternal(style->setter->Clone().Cast<GuiAttSetterRepr>(), ctor);
|
|
}
|
|
|
|
/***********************************************************************
|
|
GuiIqPrint
|
|
***********************************************************************/
|
|
|
|
class GuiIqPrintVisitor : public Object, public GuiIqQuery::IVisitor
|
|
{
|
|
public:
|
|
stream::StreamWriter& writer;
|
|
|
|
GuiIqPrintVisitor(stream::StreamWriter& _writer)
|
|
:writer(_writer)
|
|
{
|
|
}
|
|
|
|
void Visit(GuiIqPrimaryQuery* node)override
|
|
{
|
|
switch (node->childOption)
|
|
{
|
|
case GuiIqChildOption::Direct:
|
|
writer.WriteString(L"/");
|
|
break;
|
|
case GuiIqChildOption::Indirect:
|
|
writer.WriteString(L"//");
|
|
break;
|
|
}
|
|
|
|
if (node->attributeNameOption == GuiIqNameOption::Specified)
|
|
{
|
|
writer.WriteChar(L'@');
|
|
writer.WriteString(node->attributeName.value);
|
|
writer.WriteChar(L':');
|
|
}
|
|
|
|
if (node->typeNameOption == GuiIqNameOption::Specified)
|
|
{
|
|
writer.WriteString(node->typeName.value);
|
|
}
|
|
else
|
|
{
|
|
writer.WriteChar(L'*');
|
|
}
|
|
|
|
if (node->referenceName.value != L"")
|
|
{
|
|
writer.WriteChar(L'.');
|
|
writer.WriteString(node->referenceName.value);
|
|
}
|
|
}
|
|
|
|
void Visit(GuiIqCascadeQuery* node)override
|
|
{
|
|
node->parent->Accept(this);
|
|
node->child->Accept(this);
|
|
}
|
|
|
|
void Visit(GuiIqSetQuery* node)override
|
|
{
|
|
writer.WriteChar(L'(');
|
|
node->first->Accept(this);
|
|
switch (node->op)
|
|
{
|
|
case GuiIqBinaryOperator::ExclusiveOr:
|
|
writer.WriteString(L" ^ ");
|
|
break;
|
|
case GuiIqBinaryOperator::Intersect:
|
|
writer.WriteString(L" * ");
|
|
break;
|
|
case GuiIqBinaryOperator::Union:
|
|
writer.WriteString(L" + ");
|
|
break;
|
|
case GuiIqBinaryOperator::Substract:
|
|
writer.WriteString(L" - ");
|
|
break;
|
|
}
|
|
node->second->Accept(this);
|
|
writer.WriteChar(L')');
|
|
}
|
|
};
|
|
|
|
void GuiIqPrint(Ptr<GuiIqQuery> query, stream::StreamWriter& writer)
|
|
{
|
|
GuiIqPrintVisitor visitor(writer);
|
|
query->Accept(&visitor);
|
|
}
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
INSTANCEQUERY\GUIINSTANCEQUERY_AST.CPP
|
|
***********************************************************************/
|
|
/***********************************************************************
|
|
Vczh Library++ 3.0
|
|
Developer: Zihan Chen(vczh)
|
|
Parser::GuiInstanceQuery_Parser.parser.txt
|
|
|
|
This file is generated by: Vczh Parser Generator
|
|
***********************************************************************/
|
|
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
/***********************************************************************
|
|
Visitor Pattern Implementation
|
|
***********************************************************************/
|
|
|
|
void GuiIqPrimaryQuery::Accept(GuiIqQuery::IVisitor* visitor)
|
|
{
|
|
visitor->Visit(this);
|
|
}
|
|
|
|
void GuiIqCascadeQuery::Accept(GuiIqQuery::IVisitor* visitor)
|
|
{
|
|
visitor->Visit(this);
|
|
}
|
|
|
|
void GuiIqSetQuery::Accept(GuiIqQuery::IVisitor* visitor)
|
|
{
|
|
visitor->Visit(this);
|
|
}
|
|
|
|
}
|
|
}
|
|
namespace vl
|
|
{
|
|
namespace reflection
|
|
{
|
|
namespace description
|
|
{
|
|
#ifndef VCZH_DEBUG_NO_REFLECTION
|
|
using namespace vl::presentation;
|
|
|
|
#define PARSING_TOKEN_FIELD(NAME)\
|
|
CLASS_MEMBER_EXTERNALMETHOD_TEMPLATE(get_##NAME, NO_PARAMETER, vl::WString(ClassType::*)(), [](ClassType* node) { return node->NAME.value; }, L"*", L"*")\
|
|
CLASS_MEMBER_EXTERNALMETHOD_TEMPLATE(set_##NAME, { L"value" }, void(ClassType::*)(const vl::WString&), [](ClassType* node, const vl::WString& value) { node->NAME.value = value; }, L"*", L"*")\
|
|
CLASS_MEMBER_PROPERTY_REFERENCETEMPLATE(NAME, get_##NAME, set_##NAME, L"$This->$Name.value")\
|
|
|
|
IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqQuery, presentation::GuiIqQuery)
|
|
IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqNameOption, presentation::GuiIqNameOption)
|
|
IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqChildOption, presentation::GuiIqChildOption)
|
|
IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqPrimaryQuery, presentation::GuiIqPrimaryQuery)
|
|
IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqCascadeQuery, presentation::GuiIqCascadeQuery)
|
|
IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqBinaryOperator, presentation::GuiIqBinaryOperator)
|
|
IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqSetQuery, presentation::GuiIqSetQuery)
|
|
IMPL_TYPE_INFO_RENAME(vl::presentation::GuiIqQuery::IVisitor, presentation::GuiIqQuery::IVisitor)
|
|
|
|
BEGIN_CLASS_MEMBER(GuiIqQuery)
|
|
CLASS_MEMBER_METHOD_OVERLOAD(Accept, {L"visitor"}, void(GuiIqQuery::*)(GuiIqQuery::IVisitor* visitor))
|
|
END_CLASS_MEMBER(GuiIqQuery)
|
|
|
|
BEGIN_ENUM_ITEM(GuiIqNameOption)
|
|
ENUM_ITEM_NAMESPACE(GuiIqNameOption)
|
|
ENUM_NAMESPACE_ITEM(Specified)
|
|
ENUM_NAMESPACE_ITEM(Any)
|
|
END_ENUM_ITEM(GuiIqNameOption)
|
|
|
|
BEGIN_ENUM_ITEM(GuiIqChildOption)
|
|
ENUM_ITEM_NAMESPACE(GuiIqChildOption)
|
|
ENUM_NAMESPACE_ITEM(Direct)
|
|
ENUM_NAMESPACE_ITEM(Indirect)
|
|
END_ENUM_ITEM(GuiIqChildOption)
|
|
|
|
BEGIN_CLASS_MEMBER(GuiIqPrimaryQuery)
|
|
CLASS_MEMBER_BASE(GuiIqQuery)
|
|
|
|
CLASS_MEMBER_CONSTRUCTOR(vl::Ptr<GuiIqPrimaryQuery>(), NO_PARAMETER)
|
|
|
|
CLASS_MEMBER_FIELD(childOption)
|
|
CLASS_MEMBER_FIELD(attributeNameOption)
|
|
PARSING_TOKEN_FIELD(attributeName)
|
|
CLASS_MEMBER_FIELD(typeNameOption)
|
|
PARSING_TOKEN_FIELD(typeName)
|
|
PARSING_TOKEN_FIELD(referenceName)
|
|
END_CLASS_MEMBER(GuiIqPrimaryQuery)
|
|
|
|
BEGIN_CLASS_MEMBER(GuiIqCascadeQuery)
|
|
CLASS_MEMBER_BASE(GuiIqQuery)
|
|
|
|
CLASS_MEMBER_CONSTRUCTOR(vl::Ptr<GuiIqCascadeQuery>(), NO_PARAMETER)
|
|
|
|
CLASS_MEMBER_FIELD(parent)
|
|
CLASS_MEMBER_FIELD(child)
|
|
END_CLASS_MEMBER(GuiIqCascadeQuery)
|
|
|
|
BEGIN_ENUM_ITEM(GuiIqBinaryOperator)
|
|
ENUM_ITEM_NAMESPACE(GuiIqBinaryOperator)
|
|
ENUM_NAMESPACE_ITEM(ExclusiveOr)
|
|
ENUM_NAMESPACE_ITEM(Intersect)
|
|
ENUM_NAMESPACE_ITEM(Union)
|
|
ENUM_NAMESPACE_ITEM(Substract)
|
|
END_ENUM_ITEM(GuiIqBinaryOperator)
|
|
|
|
BEGIN_CLASS_MEMBER(GuiIqSetQuery)
|
|
CLASS_MEMBER_BASE(GuiIqQuery)
|
|
|
|
CLASS_MEMBER_CONSTRUCTOR(vl::Ptr<GuiIqSetQuery>(), NO_PARAMETER)
|
|
|
|
CLASS_MEMBER_FIELD(first)
|
|
CLASS_MEMBER_FIELD(second)
|
|
CLASS_MEMBER_FIELD(op)
|
|
END_CLASS_MEMBER(GuiIqSetQuery)
|
|
|
|
BEGIN_INTERFACE_MEMBER(GuiIqQuery::IVisitor)
|
|
CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(GuiIqQuery::IVisitor::*)(GuiIqPrimaryQuery* node))
|
|
CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(GuiIqQuery::IVisitor::*)(GuiIqCascadeQuery* node))
|
|
CLASS_MEMBER_METHOD_OVERLOAD(Visit, {L"node"}, void(GuiIqQuery::IVisitor::*)(GuiIqSetQuery* node))
|
|
END_INTERFACE_MEMBER(GuiIqQuery)
|
|
|
|
#undef PARSING_TOKEN_FIELD
|
|
|
|
class GuiIqTypeLoader : public vl::Object, public ITypeLoader
|
|
{
|
|
public:
|
|
void Load(ITypeManager* manager)
|
|
{
|
|
ADD_TYPE_INFO(vl::presentation::GuiIqQuery)
|
|
ADD_TYPE_INFO(vl::presentation::GuiIqNameOption)
|
|
ADD_TYPE_INFO(vl::presentation::GuiIqChildOption)
|
|
ADD_TYPE_INFO(vl::presentation::GuiIqPrimaryQuery)
|
|
ADD_TYPE_INFO(vl::presentation::GuiIqCascadeQuery)
|
|
ADD_TYPE_INFO(vl::presentation::GuiIqBinaryOperator)
|
|
ADD_TYPE_INFO(vl::presentation::GuiIqSetQuery)
|
|
ADD_TYPE_INFO(vl::presentation::GuiIqQuery::IVisitor)
|
|
}
|
|
|
|
void Unload(ITypeManager* manager)
|
|
{
|
|
}
|
|
};
|
|
#endif
|
|
|
|
bool GuiIqLoadTypes()
|
|
{
|
|
#ifndef VCZH_DEBUG_NO_REFLECTION
|
|
ITypeManager* manager=GetGlobalTypeManager();
|
|
if(manager)
|
|
{
|
|
Ptr<ITypeLoader> loader=new GuiIqTypeLoader;
|
|
return manager->AddTypeLoader(loader);
|
|
}
|
|
#endif
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
INSTANCEQUERY\GUIINSTANCEQUERY_PARSER.CPP
|
|
***********************************************************************/
|
|
/***********************************************************************
|
|
Vczh Library++ 3.0
|
|
Developer: Zihan Chen(vczh)
|
|
Parser::GuiInstanceQuery_Parser.parser.txt
|
|
|
|
This file is generated by: Vczh Parser Generator
|
|
***********************************************************************/
|
|
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
/***********************************************************************
|
|
ParserText
|
|
***********************************************************************/
|
|
|
|
const wchar_t parserTextBuffer[] =
|
|
L"\r\n" L""
|
|
L"\r\n" L"class Query"
|
|
L"\r\n" L"{"
|
|
L"\r\n" L"}"
|
|
L"\r\n" L""
|
|
L"\r\n" L"enum NameOption"
|
|
L"\r\n" L"{"
|
|
L"\r\n" L"\tSpecified,"
|
|
L"\r\n" L"\tAny,"
|
|
L"\r\n" L"}"
|
|
L"\r\n" L""
|
|
L"\r\n" L"enum ChildOption"
|
|
L"\r\n" L"{"
|
|
L"\r\n" L"\tDirect,"
|
|
L"\r\n" L"\tIndirect,"
|
|
L"\r\n" L"}"
|
|
L"\r\n" L""
|
|
L"\r\n" L"class PrimaryQuery : Query"
|
|
L"\r\n" L"{"
|
|
L"\r\n" L"\tChildOption\t\tchildOption;"
|
|
L"\r\n" L"\tNameOption\t\tattributeNameOption;"
|
|
L"\r\n" L"\ttoken\t\t\tattributeName;"
|
|
L"\r\n" L"\tNameOption\t\ttypeNameOption;"
|
|
L"\r\n" L"\ttoken\t\t\ttypeName;"
|
|
L"\r\n" L"\ttoken\t\t\treferenceName;"
|
|
L"\r\n" L"}"
|
|
L"\r\n" L""
|
|
L"\r\n" L"class CascadeQuery : Query"
|
|
L"\r\n" L"{"
|
|
L"\r\n" L"\tQuery\t\t\tparent;"
|
|
L"\r\n" L"\tQuery\t\t\tchild;"
|
|
L"\r\n" L"}"
|
|
L"\r\n" L""
|
|
L"\r\n" L"enum BinaryOperator"
|
|
L"\r\n" L"{"
|
|
L"\r\n" L"\tExclusiveOr,"
|
|
L"\r\n" L"\tIntersect,"
|
|
L"\r\n" L"\tUnion,"
|
|
L"\r\n" L"\tSubstract,"
|
|
L"\r\n" L"}"
|
|
L"\r\n" L""
|
|
L"\r\n" L"class SetQuery : Query"
|
|
L"\r\n" L"{"
|
|
L"\r\n" L"\tQuery\t\t\tfirst;"
|
|
L"\r\n" L"\tQuery\t\t\tsecond;"
|
|
L"\r\n" L"\tBinaryOperator\top;"
|
|
L"\r\n" L"}"
|
|
L"\r\n" L""
|
|
L"\r\n" L"token INDIRECT = \"////\";"
|
|
L"\r\n" L"token DIRECT = \"//\";"
|
|
L"\r\n" L"token NAME = \"[a-zA-Z_][a-zA-Z0-9]*\";"
|
|
L"\r\n" L"token WILDCARD = \"/*\";"
|
|
L"\r\n" L"token OPEN = \"/(\";"
|
|
L"\r\n" L"token CLOSE = \"/)\";"
|
|
L"\r\n" L"token XOR = \"/^\";"
|
|
L"\r\n" L"token INTERSECT = \"/*\";"
|
|
L"\r\n" L"token UNION = \"/+\";"
|
|
L"\r\n" L"token SUBSTRACT = \"-\";"
|
|
L"\r\n" L"token ATTRIBUTE = \"@\";"
|
|
L"\r\n" L"token COLON = \":\";"
|
|
L"\r\n" L"token DOT = \".\";"
|
|
L"\r\n" L""
|
|
L"\r\n" L"discardtoken SPACE = \"/s+\";"
|
|
L"\r\n" L""
|
|
L"\r\n" L"rule PrimaryQuery QPrimaryFragment"
|
|
L"\r\n" L"\t=\t("
|
|
L"\r\n" L"\t\t\t(NAME : typeName with {typeNameOption=\"Specified\"})"
|
|
L"\r\n" L"\t\t\t| (\"*\" with {typeNameOption=\"Any\"})"
|
|
L"\r\n" L"\t\t)"
|
|
L"\r\n" L"\t\t[\".\" NAME : referenceName] as PrimaryQuery"
|
|
L"\r\n" L"\t;"
|
|
L"\r\n" L""
|
|
L"\r\n" L"rule PrimaryQuery QPrimaryAttributed"
|
|
L"\r\n" L"\t= !QPrimaryFragment with {attributeNameOption=\"Any\"}"
|
|
L"\r\n" L"\t= \"@\" [NAME : attributeName] \":\" !QPrimaryFragment with {attributeNameOption=\"Specified\"}"
|
|
L"\r\n" L"\t;"
|
|
L"\r\n" L""
|
|
L"\r\n" L"rule PrimaryQuery QPrimary"
|
|
L"\r\n" L"\t= (\"/\" with {childOption=\"Direct\"}) !QPrimaryAttributed"
|
|
L"\r\n" L"\t= (\"//\" with {childOption=\"Indirect\"}) !QPrimaryAttributed"
|
|
L"\r\n" L"\t= \"(\" !QueryRoot \")\""
|
|
L"\r\n" L"\t;"
|
|
L"\r\n" L""
|
|
L"\r\n" L"rule Query Query0"
|
|
L"\r\n" L"\t= !QPrimary"
|
|
L"\r\n" L"\t= Query0 : parent QPrimary : child as CascadeQuery;"
|
|
L"\r\n" L""
|
|
L"\r\n" L"rule Query Query1"
|
|
L"\r\n" L"\t= !Query0"
|
|
L"\r\n" L"\t= Query1 : first \"^\" Query0 : second as SetQuery with {op=\"ExclusiveOr\"}"
|
|
L"\r\n" L"\t= Query1 : first \"*\" Query0 : second as SetQuery with {op=\"Intersect\"}"
|
|
L"\r\n" L"\t;"
|
|
L"\r\n" L"\t"
|
|
L"\r\n" L"rule Query Query2"
|
|
L"\r\n" L"\t= !Query1"
|
|
L"\r\n" L"\t= Query2 : first \"+\" Query1 : second as SetQuery with {op=\"Union\"}"
|
|
L"\r\n" L"\t= Query2 : first \"-\" Query1 : second as SetQuery with {op=\"Substract\"}"
|
|
L"\r\n" L"\t;"
|
|
L"\r\n" L""
|
|
L"\r\n" L"rule Query QueryRoot"
|
|
L"\r\n" L"\t= !Query2"
|
|
L"\r\n" L"\t;"
|
|
;
|
|
|
|
vl::WString GuiIqGetParserTextBuffer()
|
|
{
|
|
return parserTextBuffer;
|
|
}
|
|
|
|
/***********************************************************************
|
|
SerializedTable
|
|
***********************************************************************/
|
|
|
|
const vint parserBufferLength = 5788; // 27819 bytes before compressing
|
|
const vint parserBufferBlock = 1024;
|
|
const vint parserBufferRemain = 668;
|
|
const vint parserBufferRows = 6;
|
|
const char* parserBuffer[] = {
|
|
"\x00\x00\x81\x81\x84\x02\x81\x80\x07\x82\x00\x87\x80\x83\x21\x33\x3B\x31\x30\x64\x65\x11\x35\x35\x32\x39\x3D\x7F\x18\x99\x98\x8A\x85\x84\x8C\x28\x39\x69\x6D\x21\x36\x83\x8D\x8B\x8A\x8D\x19\x85\x08\x80\x0A\x90\x81\x92\x8B\x28\x99\x88\x0B\x93\x98\x83\x29\x32\x74\x2F\xA7\x91\x9B\x03\x94\x8E\x81\x1C\x8C\x8E\x90\x82\x8C\x8A\x8B\x96\x05\xC8\xA3\x28\x39\x34\x34\x33\x98\x1B\xBE\x81\x82\xAF\x81\x8A\x9C\x03\x2B\xD8\x80\x90\x33\x95\x32\x36\x3A\x50\xFF\x7F\x86\x81\x87\x8D\x91\x91\x79\x3A\x8D\x0B\x9B\xB0\x81\x30\x3A\x74\x20\xA2\x35\x34\x3D\x32\x27\x30\x6D\x65\x21\xA3\xB9\x85\xB0\x90\x91\x24\xC6\xB9\x33\x0B\x94\xC2\xB6\xB8\x72\xF4\xB6\xB8\xB5\x37\x24\x38\x3A\x69\x6F\x2E\x3B\xB2\xA8\x82\xB2\xC0\x69\x82\xFD\x88\x8B\xC8\x03\xA5\xA6\x64\x0E\xD0\xD2\xC4\xC8\x86\x8F\xBF\x68\xEA\xAC\xA1\x82\x3D\x32\x33\x8A\x5E\xE3\x0B\xD9\xB5\xD5\x8E\xBF\xB3\x81\xA6\xB5\x85\x8B\xDC\x39\x3C\x38\xB3\xFA\x90\xBC\xB0\x07\xD0\xDD\xCC\x26\x8E\x2B\x8A\xE0\x86\xDC\xE1\xBB\x79\xA2\xD1\xD3\xC0\xAB\xDE\x81\xDD\x37\xB9\x82\xC8\xA2\x80\xA6\x33\x34\x72\x73\x20\xB5\xE4\x99\x81\xEC\x9D\x02\x2B\xA9\xE0\x8F\x30\x39\xB0\xEB\x01\xD8\xF8\x97\xA9\xA9\x83\x39\x32\x63\x12\xCF\xB0\xA1\x0B\x97\x17\x95\xFD\x6B\x42\x83\x4A\x61\x61\x53\x80\x81\x05\xB1\x47\x80\x42\x09\x8A\x8B\x82\x40\x0D\xA8\x40\x7C\x40\xBB\x49\x1E\x10\x11\x49\x12\x15\x13\x10\x54\x04\x48\x42\x87\x00\x2F\x02\x8B\x7F\x08\xB1\x4A\x55\x41\x27\x98\x8A\x84\x87\xEB\x45\x4D\x8A\x88\x01\x25\x88\x48\x88\x02\x60\x8E\x11\x10\x4D\x05\x15\x07\x4A\x3B\x80\x4B\x15\x18\x2D\x3A\x11\x11\x0B\x5A\x1F\x1D\x17\x8F\x41\x83\x9A\x14\x0C\x2D\x39\x0D\x16\x0A\x2D\x90\x84\x78\x42\xBB\x57\x19\x10\x13\x44\x03\x11\x12\x14\x44\x11\x91\x43\x8B\x2A\x03\x02\x8E\x46\x34\x83\x41\x43\x13\x50\x05\x1E\x12\x97\x00\x6F\x88\x09\x99\x00\x61\x5C\x75\x40\x48\x43\x1C\x13\x13\x53\x05\x1C\x98\x00\x2F\xA9\x03\x9D\x9C\x50\x62\x98\x42\xA0\x00\x18\x1F\x12\x14\x7B\xAF\x8E\x17\x89\x52\xB1\x49\x03\x4A\x8F\x80\x46\x84\x15\x45\x12\x19\x9C\x8B\xEA\x41\x4F\x0A\x0A\x07\x23\x99\x4B\x4A\x48\x55\x1E\x11\x12\x4F\x2B\x99\xA4\x40\x2F\x2B\x03\x84\x00\x61\x51\xA5\x42\xAB\x53\x15\x12\x13\x14\x54\x12\x11\x10\x87\x31\x88\x49\xAC\x00\x2D\x2E\xAD\xA0\x4A\xBE\x81\x4E\xA9\x10\x54\x35\xA9\x12\x10\x55\x14\xAB\xAE\x40\xBB\x80\x1A\x02\xA7\x18\x7F\x9C\x4B\x54\x4F\x37\x9E\x13\xB2\x01\x7B\xAA\x0D\x67\xBF\x9A\x44\xA2\x40\x84\x84\x1F\x10\x15\xD8\x80\x4B\xAE\x0B\xC4\x61\x55\xBB\xB4\x08\x48\x53\x14\x14\xB7\x85\x1F\xB5\x40\x84\xAF\x03\x1F\x0A\x6D\x45\x41\x58\x89\x28\xB5\x7E\x4A\x60\x32\x10\x0B\x4A\xC0\xFF\xA6\x42\x0E\x0B\x52\x2F\x1F\x18\x1D\x53\x34\x13\x48\x1D\xDC\x81\x4D\x64\x10\x20\x24\x0C\x0E\x4E\x32\x3E\x0C\xA1\x40\x27\x98\xC4\x70\x47\x18\xEE\x0D\xC3\xC3\xCF\x88\x45\xC8\x00\x14\xD7\xC0\xC2\x0F\xAB\xBB\x61\x17\x65\x68\x67\xC2\x43\xC9\x2F\xE8\x66\x46\x0B\x31\x15\x2B\x4A\xCE\x00\x57\xC0\xCE\x45\x3E\x3A\x00\x08\x0A\x20\x22\x0F\x0A\x08\x14\xF7\x19\x18\x1D\x68\x20\x0B\x1C\x08\x9F\x4E\x52\x76\x64\x20\x3D\x05\xD0\x11\xE0\x78\x74\x1E\x08\x20\x3D\x10\x09\x0A\x20\x21\x05\xCF\x71\x41\x08\x69\x1B\x5C\x75\x64\x1D\x02\x02\x3E\xF6\xC9\x1D\xD0\x43\xC5\xD2\x88\xD2\x20\x0A\xDC\xD2\xD3\x50\xCC\x52\xD7\x63\xD3\x55\xD5\xD1\x12\x6E\x24\x19\xD7\x18\x5B\xDD\xDF\xD5\xD8\x63\xD8\x65\xD9\x5C\x67\xCA\x64\x19\xCB\x01\x49\xE1\xCF\x4A\x34\xFF\xC9\x1E\x0B\x32\x1F\x0B\x4A\xE6\x3D\xD2\xE0\xD2\xD0\x22\x28\x04\xDE\xD8\x82\x49\xCB\xC1\xD1\x29\x22\x04\xC1\x41\xAB\xDE\xE9\x1E\x11\x72\x21\x17\x19\x5E\x5F\x52\x0B\x4A\xED\x2E\x56\xE0\xEE\xEC\xB4\xF4\x18\xCD\x2A\x2B\x40\xFD\xE6\xEE\xB1\xF3\xEE\x54\x1D\x70\xC4\xD4\xD3\x8D\x39\xA0\x02\xD2\x73\xC1\x75\xDB\xD1\xD3\x4F\xD0\xF0\x75\x63\x7C\xD4\xD6\xD6\x08\x53\x00\x73\x19\x1A\xDF\x65\x14\x18\xD7\x5E\xE0\xDC\x1D\xDC\x22\x2A\x0C\xD6\xDD\xD4\xE0\x06\xF4\x63\x53\xEE\x1E\xDE\x08\x41\x2E\x19\x1C\xF9\x87\xE9\x04\xC7\x16\x45\xEE\x0C\xD4\xF3\x45\x0E\x78\x08\x2D\x3F\x35\xD6\x2E\x0A\x36\xD7\x60\x05\x17\x20\x0D\x20\x10\x16\x72\x27\xAB\x62\x21\xEB\x44\x7C\x77\xE3\x78\x75\x20\x17\x8E\x77\xEE\x46\x7F\x2A\xCC\x42\x7D\x20\x1F\x8D\x6F\x71\x1B\x8D\x77\xE4\x71\x68\x80\x02\x8F\x7D\x5E\x52\x77\x6F\xEA\x7F\x31\x38\xF1\x73\x7D\xF7\x78\x30\x7D\x34\x22\x78\x7F\xE6\x68\x7E\xFA\x2C\x8D\x7C\x15\x98\x7B\x34\xF2\x7B\x79\xFD\x77\x76\x70",
|
|
"\xB0\x7A\x78\x04\xFC\x62\x06\xFF\x20\x08\x84\xA1\x44\x80\x36\x07\x91\x7B\x02\x8D\x8F\x80\xC1\x17\x82\x20\x19\x96\x73\xE2\x09\x39\x6C\x0A\x2B\x26\x8B\xB9\x6E\x6F\x16\x8D\x79\x6C\xCC\x74\x0B\x25\x67\x83\x7A\x18\xE6\x68\x6C\xF1\x70\x68\x69\x74\x7C\x7D\x13\x8C\x8C\x8C\xC5\x09\x83\x81\x22\x1A\x04\xD7\x62\x64\x82\x0E\xB4\x0C\x87\x78\x6F\x2C\xE3\x6D\x87\x7B\x18\x9B\x7B\x86\xDF\x61\x7F\xF8\x5D\x61\x83\x80\x13\x86\x6D\x24\x96\x83\xED\x11\x7D\x8F\xDE\x6E\x03\x06\x1F\x82\x21\x08\x9A\x85\x79\x12\x82\x6A\x79\x4C\x98\x45\x00\xCF\x7F\x85\x04\xAC\x78\x6F\x3E\x86\x91\xD1\x08\x95\x87\x1B\x85\x88\x04\xE7\x64\x69\xFA\x6B\x73\x7A\x54\xA5\x90\x7E\xD9\x61\x89\xD1\x43\x88\x87\xC3\x49\x8E\x7F\x14\x73\x8F\x13\x86\x88\x80\xC6\x0A\x84\x81\x73\x0E\x82\xDB\x10\x83\x60\x4A\x90\x95\x93\xC7\x78\x03\x4A\x52\x91\x8D\x11\x90\x9D\x83\xA6\x74\x0D\x11\x01\x7D\x47\x82\x1D\x9E\x62\x9C\x95\x83\x57\x3E\x00\x04\x20\x17\x89\x20\x59\x8B\x8F\x20\x8E\x70\x8D\x82\x2D\x9E\x75\x63\x8D\x8C\x19\x38\x63\x19\x95\x35\x9A\x8D\x64\x75\x8D\xDA\x70\x6C\x8F\x67\xA2\x9C\x0E\x49\x75\x97\xD3\x02\x9C\x8A\x18\xB9\x93\x7E\xBC\x9D\x6B\xDA\x22\x8A\x70\x7D\xAE\x88\x74\x40\x1C\x6A\x1C\xA2\x92\x80\x82\xA4\x8A\x8A\x45\x7A\x8C\xE2\x15\x97\x79\x80\xAD\x84\x8E\xEB\x95\x2D\x21\x87\xA7\x90\xEF\x6D\x93\x91\x7D\x07\x9C\x40\x69\x99\x9F\x90\xA2\x7D\x9D\x02\x2F\x9E\x16\x8E\xA3\x9E\x1A\x29\x8D\x20\x37\xAC\xA0\x5A\x71\x9E\x71\x37\x91\xA0\x89\xA1\x8D\x7A\xD0\x16\xA4\x90\x63\xB8\x8A\x8F\x14\x7D\x9E\x35\xFF\x90\x91\x81\x8E\xA3\xA4\x40\x92\x86\x49\x8A\x94\x7C\x95\x80\x04\xA5\x0D\xAE\xA4\x19\x30\xA1\x20\x99\xAA\x9D\xA0\xF3\x93\x07\x4D\x82\x29\xA6\x78\xB4\xA6\xA7\x12\xA1\xAB\x28\xA0\xA5\xA1\x3B\x94\x61\x8F\x7B\x81\x9E\x1F\xCD\xAC\xAD\x8B\x90\xAD\x6F\x25\xB4\x84\x55\x8C\x9D\x99\x6A\x98\x31\x92\xB5\x73\x92\x5F\xE8\x20\xB0\xDF\x75\x01\x93\x01\x3B\x90\x47\xE3\x9F\x93\x13\x94\xA4\x94\xCF\x26\x9B\x29\xAE\x81\xB3\xE8\x24\xA3\x95\x53\xB6\x84\x4A\x87\x71\x97\xA2\x7B\x83\xB2\xEE\x77\x96\x65\xD1\xA2\x88\xFB\x7D\x90\x6C\xBF\x9F\x7F\x63\x83\x8E\x34\x28\x85\x9B\x85\x53\x89\x99\x15\xA6\x20\x08\xC8\x43\xB6\x22\x32\x61\x21\xE5\x6E\x67\x92\x5B\x2B\x26\xB7\xF8\x98\x32\x09\xC6\x64\x97\x8F\x91\x69\x34\x97\xA2\x04\xD6\x2D\x34\x71\x5E\x8A\xA9\xAB\x60\xA0\x0B\x42\xAE\x73\xB9\xB9\x74\xAF\xB8\xAA\x82\x04\xE0\x02\x7C\xB9\xC2\x65\x7B\xA3\x5F\xB7\xA0\x19\x52\xBC\x6C\xEA\xA0\x72\x74\x88\x65\x76\xC2\x7F\x82\x05\xD4\x66\x9A\xB0\x00\x06\xAE\x56\x9A\x0B\x24\xFA\xB7\xB1\x0F\x3C\xA5\x8D\x36\xDB\x94\x0D\x0B\x2B\x26\xBF\x00\x20\x9F\x4C\xDA\xA4\x9D\xDA\xA5\x3F\xBE\x8D\x80\x23\x23\xC7\x38\x61\xF5\xBC\xB9\x5F\x02\x39\x5E\x80\xEE\x65\xC1\x8D\x40\x25\x63\x82\x30\x06\x6D\xF1\xB9\xC3\x4B\x91\x0B\x25\x1F\xDD\x71\x86\xF0\x6A\x26\x18\x02\x84\x2B\x06\x9F\x8E\xEB\x02\x87\xB8\x64\xA0\x04\x2A\x44\x3A\x24\x79\xAA\x66\x24\x18\x3C\x9E\x75\x40\x16\xC0\x00\x18\xC5\xC7\x0D\xE5\xC0\x73\x3B\x0B\x25\x90\xA2\xC5\xC6\x12\xD9\xC7\xC4\x5D\x3F\x28\x08\x2B\xC2\x69\x16\xCD\x80\xC6\x56\x22\x31\x8E\xFE\x5C\xC3\x1E\xC7\xC5\xCA\x16\x30\x04\xCE\x43\xC5\x20\x2E\xF4\xC1\xCB\x46\xD5\xC4\x92\xA9\xC4\x62\x26\xF9\x68\x34\x2E\xD0\xC9\x51\x26\x2A\xC6\x1E\xD9\xCC\x39\x05\x30\xCF\x8F\xFB\xB1\x71\x88\x40\x25\x33\xE0\x83\xC5\x39\xED\xC1\x72\xC1\x31\x06\xC7\x7E\xCE\x04\x0D\x3E\x1B\x24\x42\xC4\xCE\x22\x31\x01\xCC\xA2\x82\x8F\x3B\xF0\x2C\xBB\x87\x25\xC2\x83\x7D\x79\x31\x70\x17\xE7\x3A\x30\x74\xAD\x3F\xFC\x00\x75\x2F\xF0\x1A\x6C\x7C\x33\xDA\x25\xA2\xC2\x64\x75\x1A\xE1\xD6\xCF\x8A\xD9\x0D\x0C\x0C\xD0\x3C\xF1\x05\x6E\x0B\x5C\x71\xD2\xD0\x13\xDA\x3E\x4B\xF3\x38\xD3\xA0\xBA\xD3\xF6\x45\x08\x0F\x31\x2C\x0D\x0E\x73\x09\x0E\x1D\x0D\x32\x0E\x50\xFC\xCD\x60\x88\xC0\xD2\x49\x31\x07\x92\x55\x2B\x26\xD9\x87\xCA\xD5\xAA\xAB\xD2\x69\x46\xEE\xD2\x04\xB0\xCB\xCB\x91\xB3\xD8\x3F\x5A\xCD\x87\xD2\xB4\xB9\xD0\x1C\x73\x7C\xD6\x5F\xC0\xDA\xD8\xC4\xC4\x7F\x74\xA8\xD2\x68\x51\xEC\xD6\xD1\x9E\xB1\xD7\xB6\xA0\x04\xD7\x4A\xDF\xDF\xD6\xE1\xD9\xD7\xB8\xDB\x7C\xD3\x8A\x13\xD6\xBB\xC7\xD8\xC9\x1E\x32\x0A\xD8\x8B\x07\x61\x06\xB8\x0B\x25\xC2\xD1\xD9\x62\x52\xE2\xD7\xD4\x06\x69\xD6\x0C\x6F\xD7\xDB\x15\x32\xDB\xD9\x92\xDD\xDA\xBD\xC9\x90\xDC\x8B\x22\xDB\x7E\x55\x0E\x0F\x74\x20\xDB\xDD\x88\xED\xD8\x60\x14\xEC\xBD\x0B\x17\xEB\xD0\x6E",
|
|
"\xD4\xD4\x0C\xB6\xDA\x3A\x49\x1F\xE7\x91\x3A\x22\x0A\x3C\xB1\x6D\xB9\xD7\x53\xC8\x20\x37\xC3\xE5\xE0\x03\xE2\xD0\x29\x2B\x23\xE8\x86\xD2\xE1\xE5\x45\x6B\xE6\xB6\x98\xEE\xE4\x6F\xDC\xE0\xDF\x16\x3E\xA1\xFB\x3A\xDB\x94\x9B\xF8\xE1\x0C\x3A\xFD\x0D\xC9\x86\xE7\xE9\x6A\xED\xD4\xBD\x16\xEB\xE9\xCB\xF4\xDA\xE2\x98\xF7\xDA\xE6\x51\xF4\xE5\xD1\x21\xE3\xE5\xAE\x41\xE2\xD4\x40\xEC\xD9\x0C\x50\xD5\x20\xBA\xDF\xCA\xDA\x27\xEC\xE8\x08\x56\xD0\xA1\x78\xE2\xE9\x0F\x26\xCD\xEB\xC6\xA0\x0D\xE3\x3C\x2A\xEA\xBB\x5F\x3E\xDF\xA7\x8A\xA5\xBC\x76\xFF\xEC\xDA\x7B\xFF\xEB\x5B\xD9\xD2\xD6\xB2\xEF\xE1\xE6\x3A\x27\xF1\xB9\xBF\xD1\xD9\x61\xCF\x0D\xD8\x6E\xF4\xCA\xA8\xF0\xC2\x20\x39\xC1\xD4\xCE\x64\x16\xCC\x00\x78\xC7\xEF\x44\xFB\xCA\xF4\x00\x60\xEB\xC1\x32\x05\xE9\x82\x35\xF7\xEE\x0D\xFF\xEF\xC4\xDE\xEE\xD1\xB7\xA1\xEE\xDD\x82\xE6\xEF\xD3\xE8\xE6\xF0\x7D\xE0\xE2\xE4\x92\x2A\xDD\xE3\xA6\xEA\xF7\x94\xEF\xAA\xE9\xC0\xF6\xF2\xD3\x84\xF0\xEB\xE2\xC2\xA0\x04\x54\xFC\x7A\xD5\xF1\x28\xEA\x80\xF0\xF6\x60\xA4\xE1\x22\xE9\x86\x6D\xC1\x85\x7C\xBA\xF5\xAC\xF8\x61\x81\xC1\x50\x20\x57\x7A\x21\x9B\xE8\xFD\xCE\x49\x59\x98\x67\x6E\x82\x25\x9B\x77\xF9\x9B\x8D\x80\x6C\xE7\x7E\x48\xDA\xD5\x71\x78\x39\x74\x72\x10\x76\x72\x6A\xD3\x68\x74\xD8\x64\x37\x95\x75\x6F\xC2\x74\x7D\xC4\x7A\x79\xBD\x6C\x79\xE8\x6F\x79\xCA\x7D\x7A\x07\x8C\x7B\xD7\x6A\x3E\x65\x63\x6F\x0C\x88\x79\xB8\x67\x7D\xD9\x7D\x6F\x9E\x69\x75\x6F\x71\x7B\x57\x61\x32\x33\x05\x7B\x02\x17\x7B\xEA\x79\x77\x06\x78\x80\x2B\x7B\x81\x7A\x7D\x81\x67\x79\x79\xC6\x75\x73\x37\x7C\x7D\x59\x7B\x75\x03\x7D\x75\x91\x70\x6F\x22\x06\x71\x32\x83\x76\x34\x83\x7C\x36\x80\x82\xFB\x6B\x76\xC8\x7E\x06\xE4\x3C\x7E\x00\x0E\x7E\xEA\x5B\x30\x01\x25\x10\x53\x8F\x7E\xEB\x55\x7E\xDA\x41\x38\xE1\x70\x10\x70\x69\x67\xF3\x7B\x5E\x05\x6E\x63\x96\x39\x5B\x00\x1B\x5B\x0C\x64\x03\x9C\x35\x10\x69\x8A\x53\x9F\x35\x34\xE8\x55\x6A\x16\x19\x4D\x6F\x59\x3A\x4E\x80\x85\x5F\x8B\x30\x86\x15\x10\x79\x86\x85\x0B\x38\x85\x23\x32\x07\x74\x0B\x85\x00\x00\x67\x14\x3E\x85\x71\x80\x86\x75\x82\x7F\x87\x8B\x30\x0F\x0B\x12\x8D\x8F\x7F\xF4\x7F\x87\x74\x00\x61\x01\x19\x2F\x29\x3C\x87\xC8\x32\x86\x6E\x36\x55\x58\x58\x16\x7E\x8E\x30\x80\x84\x89\x00\x16\x89\x15\x3C\x86\x6F\x3A\x89\xC7\x12\x88\x72\x66\x39\x22\x30\x8A\x74\x0F\x31\x01\x17\x89\x96\x3A\x31\xDF\x79\x65\x09\x60\x00\xAD\x3D\x61\xD9\x42\x89\xF1\x70\x10\x85\x87\x77\x36\x65\x82\x35\x60\x8B\xFF\x7A\x65\x92\x84\x86\x00\x07\x32\x97\x83\x62\xC2\x88\x68\xB7\x89\x8B\xCB\x6F\x89\x0F\x3D\x8B\x28\x35\x8A\x06\x8D\x8C\xAA\x64\x8C\x02\x7C\x6C\xC7\x84\x39\xB1\x80\x02\x16\x8F\x8C\xCE\x4B\x54\x7E\x46\x5F\x05\x16\x8E\x72\x56\x49\xBB\x8E\x8A\xF6\x71\x10\xDD\x4F\x8B\xE9\x87\x3C\x3E\x02\x8E\xF7\x55\x58\x16\x0B\x12\xF7\x85\x8F\xD7\x4E\x3B\x92\x8C\x55\x00\x1D\x4E\xB2\x8E\x4F\x7E\x4E\x03\x9C\x83\x8E\xD0\x52\x5E\x1C\x0B\x12\x09\x97\x5F\xF9\x52\x3E\xD2\x80\x88\x00\x65\x10\x11\x90\x8F\x03\x60\x56\x04\x90\x5F\xF2\x50\x56\xD4\x45\x10\x1B\x99\x91\xE2\x5D\x8A\x0F\x39\x8F\x05\x12\x92\x01\x9D\x52\x16\x94\x8F\xF1\x5B\x58\x74\x05\x90\xFA\x8F\x4F\x82\x68\x58\x00\x1A\x58\x02\x9E\x49\x71\x3B\x3C\xAB\x5E\x43\x74\x59\x4A\xC9\x5C\x4A\x7B\x5F\x5D\x9D\x53\x4B\x39\x92\x5A\x3F\x48\x57\xBB\x46\x5A\xAF\x48\x5A\xFD\x3A\x5A\x42\x5C\x5A\x05\x41\x1B\x18\x54\x45\xCB\x42\x65\x2C\x99\x92\xE1\x52\x4F\xFE\x80\x00\x5E\x56\x92\x1F\x95\x03\xF7\x45\x10\x5D\x96\x8A\x0D\x94\x06\x68\x50\x54\x73\x44\x54\x76\x46\x54\x19\x51\x57\x2A\x94\x57\x66\x92\x52\xB8\x44\x5A\x98\x5A\x57\x9A\x54\x72\xE5\x55\x91\xE2\x57\x63\x6B\x90\x5A\x6D\x96\x50\x70\x94\x3F\x46\x9D\x07\x40\x0D\x29\x3D\x75\x8B\x03\x72\x2D\x48\x1A\x13\x0F\x2D\x2D\x19\x19\x88\x90\x8B\x5E\x86\x9A\x88\x79\x02\x20\x21\x00\x2D\xFF\x08\x8A\x98\x1A\x8D\xB3\x56\x11\x02\x23\x02\x94\x98\x8D\x30\x0F\x98\xFF\x72\x20\x25\x0D\x99\x84\x91\x03\xA0\x92\x70\x02\x27\x02\x94\x98\x92\xF1\x8F\x15\x98\x91\x95\x26\x12\x20\x29\x04\x99\x53\x9E\x91\xF2\x4F\x9A\xC7\x18\x98\x2B\x1B\x02\x94\x9F\x01\xF3\x2C\x2A\xEB\x2F\x0F\x02\x2B\x2E\x89\x95\x9C\xC6\x91\x27\xC1\x90\x27\x7C\x27\x9C\x2B\x1A\x9C\xD2\x24\x9C\xC6\x98\x8D\x32\x02\x2D\x28\x0C\x9C\x83\x97\x9D\xDB\x82\x2D\x26\x06\x9D\xFE\x7D\x9D\x25\x6A\x9C\x02\x24\x8D\xD8\x59\x4B\x1B\x6B\x5D\x83\x34\x07\x96\x98\x16",
|
|
"\xFF\x01\x9C\xD2\x2B\x27\xC7\x9E\x9C\x2B\x10\x9D\xC5\x92\x9D\xD4\x9C\x9D\x02\x18\x8D\xA6\x9B\x12\xDB\x96\x9F\x17\x64\x98\x30\x00\x9E\x2B\x12\x9E\x7A\x38\x5C\x40\x41\x70\xCB\x5A\x35\xE9\x9A\x99\xC0\x94\x20\xAB\x2F\x9B\xCC\x9E\xA0\xCF\x9C\x9F\xFD\x98\x9D\x18\x35\x9F\x12\xA8\x9F\xDA\x92\xA1\x3B\x6E\x9F\xC5\x9B\x9E\x04\x2A\x63\x00\xA5\x9C\x10\xA7\x2A\xFC\x99\xA0\x79\x02\x2D\x2C\x0A\xA1\xB5\x96\x97\xF2\x42\x9F\xBC\x17\x65\x3E\x42\x20\xAC\x9A\x92\x1E\xAC\x20\x82\x99\x14\x1A\xAB\x27\xED\x9A\xA1\x26\xA8\xA2\x2A\xA8\x91\x2C\xAE\x38\x0C\x21\x9C\x82\x8A\x63\xC7\x9B\x2E\x3B\xA2\xA1\x26\xA3\xA4\x04\x2A\x9C\xEE\x91\x9D\xA0\x2B\x12\x0E\xA7\x9C\x3D\xAB\x12\x22\x0A\xA1\x8C\x92\x70\xD9\x41\xA1\x17\xA4\x98\xD3\x9B\x12\xD5\x9D\xA5\x14\xAE\x67\x19\xA2\xA6\xDE\x99\x61\x21\xA5\x10\x02\xA0\x1A\xF1\x35\x9E\x81\x37\x9E\x26\xA5\xA3\xFA\x29\xA4\xFC\x9A\x63\xD2\x23\xA5\xC6\x95\xA5\x08\x17\xA5\x12\xA9\xA5\x98\x8C\xA5\x75\xAE\xA5\x16\xA1\xA8\x63\xAB\x6C\x65\xA4\xA8\x67\xA5\x63\x69\xA2\x10\x6B\xAB\x37\x05\xA4\x65\x07\xA4\x38\x4B\xAB\xA0\x0C\x2D\xA0\x1A\xA7\x9A\xE0\x2C\xA3\x27\x86\x39\xD2\x2C\xA7\xFC\x9E\xA7\x51\x84\x07\x80\xA6\x9F\xF4\x90\xA6\x1A\xA8\xA1\xFA\x97\xAA\x1C\xA2\x20\x72\xA0\x21\xEB\x2B\x2A\xC7\x9F\xA4\xC5\x98\x9B\x98\x1A\x9B\x08\x13\xA3\x33\x97\x3C\x8B\xA2\x7E\xCB\x11\x10\x3A\x90\x44\x59\xAC\x93\x9A\x58\xAB\xE4\x8D\x3B\xFF\x0B\x27\xC7\xA0\x29\xCA\xAC\xA4\x1F\x24\xA2\xAE\xA1\xA5\x08\x18\xAC\xAF\xA2\xA5\x04\x2B\x2E\xEB\x29\x86\xCF\xA8\x10\x4E\x82\x8A\x94\xA6\x1B\x08\x1E\x01\xD5\xAB\x1A\xDF\xA1\xAE\x08\x17\xA3\x02\x1D\x01\xE4\xA5\x10\xC8\x88\xAE\xBA\x2B\x12\x29\xAD\x2E\x1A\xA4\xAB\xA9\x12\x18\x32\xAD\x57\x54\x95\xAC\xBA\xA6\x9C\xAA\x8E\xAB\x42\x91\x3F\xC1\xA9\x59\xE2\x34\xAC\x7F\x5B\x8F\x3A\x6F\xAE\xFC\x92\xB0\x84\x5B\x8F\x78\xA2\xA1\x2B\xA5\x95\x8E\x3B\xAB\x00\x19\x87\x02\x19\x87\x7B\x97\x57\x92\x1E\xA0\x84\x23\x44\x0D\xBA\x95\xF2\x49\xAC\xDA\xAB\xAC\xFA\x26\xAD\x9B\x39\xAE\x40\x1B\x12\xE0\xAC\xAC\xAF\x22\xAE\x21\xBA\xB2\x02\x17\xB2\x2B\xB5\xAE\x2B\x1C\xAE\x2F\xBA\xAE\x31\xB4\xB2\x66\x21\xAD\x36\xB0\x10\x74\xA9\xAD\x2F\xA3\x28\xF1\x9E\x8D\xF0\xA2\xA1\xF2\xA9\x1B\x0A\xA7\xAB\xF6\xAD\x9A\x74\x00\xB1\x83\x8D\xAB\xCD\x1D\xAF\xB9\x4F\xAF\x72\x91\xB0\x47\xBA\x92\x3A\x68\x8C\xC7\x98\xB0\x16\x15\x58\x0B\xBC\x9F\x1B\xB7\x90\xF2\x4A\xB4\x12\xB1\x10\x14\xBF\x54\x6F\x93\x1D\x50\xB9\x48\x9A\x5D\xB5\x3B\x54\x53\x89\x9D\xAA\x01\x1F\x0F\xB7\x86\xAE\xD9\x29\xB3\x1B\xA6\x1A\xC6\x9B\x2E\x4A\xBB\xAF\x4D\xB5\x59\x43\x92\x19\x67\xB7\x52\x58\xBF\x3A\xFB\x8D\xAD\x3C\xB7\x1D\x39\xA1\xAF\x95\x10\x00\x99\x91\x99\xF6\xA2\x41\x06\x99\xB0\xFF\x49\xB7\x4C\xB0\x00\xBF\xA3\x1D\x18\xB1\x10\x43\x41\xB8\x85\x5E\xB1\xFA\x2B\x27\x59\xA5\xB8\xC2\x2C\xB2\x6F\xBB\x2E\xDC\xAE\xB2\xA0\xBD\x17\xE3\xA8\xB2\x02\x12\xB7\x00\x12\xB3\xA7\xB9\x8C\x35\xBA\xBA\x73\xB8\x10\x19\x04\xB7\x4E\xA4\xB7\x3B\xB3\xBA\x57\x69\xA9\xED\xA8\x10\x06\xBD\x1D\x88\xB6\xB7\x96\x10\x9B\x45\xBC\x3A\x53\xB9\xAB\x5F\x12\xB9\x08\x10\x67\x95\xB7\xB1\xD4\xA0\x10\x99\xB7\xBC\xF8\xAF\x15\x05\xBA\xA1\x9A\xBA\xB0\x1A\xA2\x20\x6A\xB6\x11\x61\x90\xB6\x85\x11\x10\x15\xB5\xB6\xCE\xBE\xB3\xD0\xB6\x3F\xDB\xB8\x5F\x34\x5C\xB9\x02\x1F\xB9\xBA\xBD\xBB\x05\x1B\x01\x74\xBB\xAD\x74\xB4\x1C\xA6\xBD\xBE\x05\x15\xBA\x74\xBC\xBA\x00\x0E\xBA\xF6\xB3\x33\xB1\xB3\xB3\x35\x2E\xAC\xFD\xB4\x27\x02\xC8\x9C\xBB\xB4\x2F\x3F\xB6\x32\xD0\xAC\x9F\x43\xB8\x1C\xC5\xBE\xB8\x46\xBD\x92\x7E\x4A\xBC\x71\x6C\xAF\x7C\xB1\x3F\x97\xB5\xBE\x79\x07\xBD\xFF\x45\xB5\xD6\xB2\xBD\x03\xBF\x4F\x5B\xB6\x9F\xE7\xBD\xBD\xC6\x91\xB6\x11\xB0\xBE\x64\xB3\x5A\x66\xB0\xB2\xC2\xA2\x3E\x25\xCC\xB6\x0F\x2E\xB6\x71\x21\xB7\x09\xC0\xC0\x1C\x39\xB8\x0F\x28\xB7\xFA\xA3\xB9\xCD\xBE\x06\x19\xC0\x00\xD1\xB1\xC1\xF7\xA1\xC2\x7E\x42\xBB\x71\x2A\x63\xAA\x77\xA4\x37\xCF\x20\xDC\xA9\x2F\xE1\xB9\x17\xDA\xB0\xA4\x0E\xB9\x36\xAC\xA1\x9C\x8F\x84\xB3\xD9\xBD\xB6\xC1\x9A\x63\xC4\x1C\xC4\xEE\xBE\xC4\x2A\xB3\x4C\x4E\x97\x3D\xF5\xA4\xC4\x48\xBB\xC5\x03\xC6\xC0\xCB\xBA\xC6\x38\xC1\x27\x7B\x2C\xAD\xC3\x95\xC0\xCB\x98\x9D\x02\x12\xAB\x89\x91\xC3\x5A\x53\xC2\xDC\x93\xA9\xD6\x94\xC3\xAC\x20\xA2\x87\xB1\xB4\x5A\xCC\xB5\x54\xCC\xB1\x8E\x3E\xA2\x86\xB4\x25\x16\xC1\x1C\x67\xC6\xBC\x12\xC6\xAC\xC1\x9A\xBF\xD2",
|
|
"\x20\xC6\x38\xAA\xC0\x0C\xB7\xC8\x5E\xB2\xA4\x1A\xA0\xC8\xFF\x09\xC5\xFE\xBE\xC6\x6F\xC4\xB8\xF1\x1A\xA1\x8A\xCB\x20\x0D\xC6\xAB\x90\xCB\xCA\x48\xBA\xBE\x6F\xBE\xB9\x77\xBE\xAE\xCD\x91\xBC\xDE\xAA\xB8\xC4\xBC\xB8\x44\xC0\xC1\x45\xC0\xB9\x7E\x45\xBD\x12\xAC\xC1\x7E\x4C\xC7\xD6\x9A\xC7\x60\x5E\xBD\x08\x13\xB6\x2E\x56\xB1\x40\xCF\xBC\x42\xC6\xBE\x9A\xCB\xB6\x5A\x5E\xCA\xED\x71\xCB\x98\xC5\x10\x4A\xB2\x20\xA9\xC4\xAF\x8D\xBE\x48\x8F\xB9\xB5\x04\xB0\xB4\x07\xB0\xC2\xBC\xCD\x3B\xC2\xCC\x9C\xC4\xC2\x5E\xC6\xCA\x87\x2A\xC9\xCC\xE2\xBE\x06\x7F\xBA\x48\xE7\xC2\x4F\xC6\x9E\xC9\xEB\x20\xCA\x6E\xC2\xCD\xAC\x2B\x27\xB7\x83\xC7\x08\x1B\x9F\x2E\x24\x65\x02\x1E\xCF\xF6\x96\xA2\xE5\xC7\x9C\x9E\x98\xCF\x53\x8B\xC3\xF0\x57\xC7\x00\xD8\x4E\x9A\xAC\xC8\xF7\x57\xCA\x3A\xBB\xC0\xC7\x52\x20\x9E\x92\xCA\xFC\x94\xCF\xDF\xB8\xD1\xF9\xC4\x20\x7B\x27\x95\x3A\x60\xC8\xEB\x20\xBF\x48\xCF\x84\xA2\xBC\xC6\xB5\xCD\xB2\x74\xB8\xBF\x25\xDA\xBF\xFC\xB8\xD2\xA1\xC5\x10\x2F\xD0\x00\xEB\x21\xA6\xFF\xC6\xC7\x01\x16\xD3\xA4\xAE\x9F\x05\xD0\xA5\x85\xA8\x68\xF8\xCD\x8E\x13\xA3\xCA\xD7\xA1\xBF\x27\xD4\xCA\xA8\xB5\x10\xF5\xB0\xD3\x95\x86\xB2\xF9\xBF\xBF\xAF\xBB\xAE\x4D\xC1\x10\x33\xDB\x27\x3A\x63\xD3\x06\xDE\x9F\x12\xD5\xB7\xDD\x9C\x80\x16\xD5\x9A\x9E\xCE\xA0\x56\x5E\xA0\x80\xC7\xBB\x25\xD9\xBB\x4C\xD4\x21\xCC\xCF\x20\x7B\x2A\xBF\x02\xDC\x9D\x9E\x9B\xD5\x01\x78\x62\xC7\x3F\xD5\x3F\xD0\x78\x1D\xA1\x9C\xEB\x28\xC2\xCC\x9B\xD5\xD8\xC9\xB8\x6A\x6A\xCA\xF7\x9E\x9F\xF8\xC8\xCF\x20\xD4\xB7\x23\xD6\xD4\x08\x1C\xAD\x80\xC4\xBF\x2B\xDE\xD4\x2D\xD0\xD5\x6B\xC0\xBB\x08\x13\xD3\x35\xDB\xD6\xDC\x9A\x8D\x81\xDA\xCD\x38\xD3\xD4\x25\x6A\x63\x3A\xD0\xD7\x3C\xDC\xD1\x5C\xD3\xD8\xFF\x71\x03\x41\xDD\xD0\x69\xD0\x00\x2C\xD4\xD4\x23\xB5\xD2\xF2\xB5\xD2\x8E\xD1\xD9\x95\xD4\xB7\x52\xD1\xC6\x54\xD8\xD9\xD6\x9A\xD9\x0D\x15\x15\x6B\x6F\xC0\x39\xC7\xD7\x30\x07\xD5\xAA\xA2\xDC\x72\xD4\x65\x5E\xDA\xDA\x5C\xD2\x6A\x61\xDB\xD0\x08\xC5\xD2\x66\xD3\xCA\x68\xD8\xD4\x00\x06\xA9\x22\xA4\xCB\x25\xBB\x10\xBD\xD1\x63\x9C\xDD\x9D\xA6\xD2\x70\x30\x0E\xD6\xC5\xD9\xA8\x59\x67\xDC\xD8\x94\xD7\x5F\x16\xD7\xE4\xD8\xD7\xC7\x9E\xC9\xD1\xD6\x9F\x3A\xAE\xDC\xD6\x9E\x99\x4A\xBD\xA8\x04\xA3\x1D\x6E\xAC\x5D\x08\xAB\xA9\x6E\x3E\xC9\xD3\xD1\xAB\x0B\xC8\x45\xE3\xDF\xDD\xDF\x96\x9C\xF6\xD1\x3F\x06\xA0\xA7\xFC\xD7\x1C\xAB\xD5\x99\xBA\xDD\xD7\x01\xEE\xD0\x66\xA4\xE0\x19\x6A\xC6\x1A\xD4\xBB\xA4\xD5\xD8\x7B\x21\x91\x01\xC5\xD2\x89\xD0\xDB\x47\xDD\xD8\x90\xD3\xCA\xAD\xDC\x2C\x23\xEC\xD0\x9D\xD0\x00\x4B\xDC\x9C\xF8\x96\xDE\x5D\xD5\x76\xEA\xD4\xE1\x06\x38\xCF\x22\x9D\xE1\xAE\xD8\x10\x24\xD3\xCA\xB1\xD3\xCA\xB3\xD4\xE2\x27\xE3\xBB\x05\x1B\x2E\x56\xD3\xD5\xF3\xD5\x9A\x3D\xD3\x9F\x5E\xAD\xDC\x08\x1B\x91\x28\xE3\xCA\x2E\xD6\xDB\x92\xD7\x20\x6D\xD6\xAA\x13\xE1\xDC\xDB\x8B\xD5\xA7\x9C\x77\x31\xE6\xE5\xA2\x69\xD7\x74\xB5\xBB\x1C\xDA\xE1\xFF\x53\xCB\x1E\xEB\x12\x39\xEF\xBA\x3B\xEF\xBA\x3D\xEF\xBA\x25\xE0\xE4\x2A\xD8\xB3\x29\xEB\xE2\x59\xD7\xD7\x31\x0E\xE2\xDF\xD9\xDC\x29\xEE\x73\x32\x04\xE3\x64\xE7\xE3\x6A\x8A\xD8\xF7\xB3\xBF\x3F\xEB\xDA\x6D\xE6\x2E\x44\xE5\xC7\xDE\xDE\xE6\xA2\xD4\xE7\x47\xE9\x98\xD2\x9A\xE4\x1C\x94\xC7\x80\xCF\xE4\x25\xD7\xDB\x89\x93\xE5\x08\x11\xDA\x45\xE4\xE7\x58\xEB\xC0\x5A\xEA\xDC\x3E\x71\x03\x5E\xE5\xD2\x67\xE7\xCF\xC1\x9B\x27\x0B\x97\xD3\x7E\xE2\x10\xD8\xA3\xD9\x69\xEA\xE8\x00\x1E\xA9\x4D\xEF\xDD\x02\x12\xEB\x8B\xEB\xDE\x32\x0D\xE8\x0F\x20\xAA\x77\x80\x16\xC1\x9E\xA0\xE6\x83\xEB\x93\xDB\xE6\x93\xD5\xE8\x03\x28\xE9\x41\xE3\xE0\x5C\xE0\x30\x9D\xE4\xC8\x9F\xE9\xE7\x90\x92\x03\xA3\xE3\xCA\xA5\xE6\xE1\xA7\xEA\x90\x92\xE2\xB2\x08\x1D\xEA\xAB\xDF\xEA\x86\xEB\xA7\x74\xCA\x63\xB6\xEB\xE9\xB8\xEA\xEB\x0B\x2C\xEB\x8B\x8E\xEB\x04\x20\xEC\xD9\xEA\xC3\x01\x1B\xE2\x80\xC6\xEC\x02\x28\xEC\x26\xE5\xE5\x9E\xDC\xEC\xC6\x99\xE5\x5F\x7B\xE5\xF7\xE6\x30\xF6\x9E\xC9\x94\xEC\x9F\x78\xCF\x20\x1B\x65\x78\xFC\xEB\xDC\x7E\x6A\xB4\x89\x21\x10\xED\x19\xA5\x22\x8F\x6F\xF8\x9D\xE0\x96\xE0\xDF\x0F\xDD\xB3\x00\x06\xF0\xA0\xE0\x99\x31\x0A\xF0\x24\xAD\x1E\xD4\x8B\x79\xE7\x6E\x79\x72\x01\xF1\xA4\xD3\xD9\x62\x13\xE8\xCC\x93\xF0\x0B\x25\xF0\xD5\x77\xF0\x7A\xEC\xF1\x70\xE0\x00\xED\x17\x9A\x6C\x72\x19\x8F\xE1\x9C\xF2\xE6\x9C\x2A\xF7\x20\x2C\xF4\x7C\x2E\xF1",
|
|
"\xED\x30\xFA\xEA\x0D\xFE\xC2\xDB\x79\x73\x74\x02\x9D\x19\xDA\xD7\xAF\xD8\xD1\x9E\xCB\x27\x20\x04\xCD\x05\x1E\xA0\x43\xE4\xBE\x9F\xA0\xB2\x98\x86\xEE\x3C\xFB\xE0\x98\x1F\xC7\xC9\x94\xC7\xC7\x93\xA2\xB5\xD6\xEF\x08\xF6\xA8\xA9\xA2\xF6\x3E\x7F\x9F\x06\xE1\xA0\x01\x13\x9E\x40\x49\xDF\x0A\xE0\xD1\xBB\xC0\x13\xEC\x9E\xF5\xC6\x90\xF6\x32\xDA\xEC\xFD\xE8\x68\x87\xAB\xD3\xC2\xD5\xDF\x6A\xF0\x10\x6C\xF3\x1D\x09\xED\x5D\x93\xAE\xC9\xD6\xD2\xF0\x11\xED\xBA\x78\xF3\xF6\x7A\xF5\xF6\x88\xA2\xE3\x59\x63\xC3\x5D\xF1\xF3\xF6\x90\x9F\xA9\xBF\xF8\xCB\xE6\x30\x83\xAC\xF7\xEB\xD9\x9F\xFD\xCB\xF8\x67\xFE\xF7\x9C\x1B\xF6\x03\xAD\xA6\x57\x66\x9E\x84\xFA\xF5\xEA\x93\xF7\x94\xFC\x9D\x96\xFA\xD4\xA0\xF1\xED\x9B\xF7\xEB\x90\xFA\x6A\x7B\xF4\xFB\x99\xF9\x65\xA2\xFA\xA6\xA4\xFC\xA6\xB9\x43\xF8\xFB\xD0\xF7\xAE\x3D\xE0\x87\xF6\x9F\x76\xFF\xE6\x98\xF9\xF7\x85\x94\xE5\xC9\xFC\xF8\xB6\xFE\xF8\x9C\xF5\xFB\x30\x05\xF2\x0D\xEE\xED\x25\xFE\xC9\x02\x23\xEE\xD4\xF2\xF9\x4D\xA4\xF7\xC5\x98\xA9\x01\x1A\xFD\xC7\x98\xEE\x79\x0B\xA5\x87\xE3\xE7\xB8\xE3\xFB\xE4\xE5\xFB\x9E\xF5\x10\x6F\xDB\xFE\xB9\xF0\x78\xBB\xFC\xA8\xBD\xFE\xA8\xF8\xD7\xFA\x6F\xA9\xFA\xC2\xF6\x39\xFE\xDE\xFD\x89\x90\xFE\xB1\x70\x4B\x56\x7B\x50\x53\xAA\x38\x7E\xF2\x7F\x52\x99\x71\xF6\x67\x6D\xDB\x70\xFF\x4A\x7C\xDA\x65\x4E\x07\x77\xF7\x50\x55\xB7\x76\xF1\x43\x7C\x75\x6E\x70\x54\x7D\xF2\x49\x7C\x00\x02\xFE\x46\x4C\xF9\x66\x7F\xB8\x6D\x01\x8E\x7E\x04\x85\x10\x1A\x74\x8B\x65\x4D\x0C\x87\x04\x82\x6F\x2B\x64\x20\x02\x10\x09\x1B\x7E\xCC\x4E\xBD\x7E\x7E\x85\x6D\xAC\x10\x83\xDF\x7E\x0C\xA5\x7C\x3C\x78\x7E\xFD\x62\xA9\x2A\x7E\xDC\x64\x10\xFF\x68\xEA\x76\x71\x07\x11\x01\x8F\x54\x76\x51\x54\xE8\x4E\x07\x8C\x5C\xC3\x7F\xE0\x57\x7D\x70\x42\x10\xEF\x78\x06\x87\x10\x19\x8D\xFA\x56\x4D\x7C\x7F\x7C\x66\x78\x32\x4F\x81\xC4\x45\x04\xF7\x7C\xDC\x68\x7D\xC1\x7D\x02\xBC\x7E\xD6\x7A\xEA\x14\x78\x21\x61\x68\x0A\x80\xBC\x73\x7E\x89\x15\xFF\x77\x6E\xCD\x73\x80\xFA\x7A\x0C\xAE\x1A\xE2\x7D\x04\xC2\x80\x01\x78\x82\xCD\x7F\xEC\x6C\x80\x06\x12\x20\x26\x82\x14\x9B\x83\xFA\x17\xBD\x5C\x4F\xE3\x79\xD3\x69\x82\xA8\x29\x81\xE8\x7A\xFA\x6B\x83\x3B\x3D\x06\xA6\x7F\x17\x99\x7F\x61\x83\x91\x71\x7B\x8B\x04\x06\xC2\x76\x75\x44\x84\x00\x0E\x0F\xBE\x69\xCE\x78\x08\x9B\x86\x22\x89\x7B\xA3\x78\xF0\x79\x80\x23\x8D\x9D\x48\x81\xE1\x61\x4E\xC5\x7C\x3B\x57\x83\x12\x86\x08\xE4\x50\xF4\x66\x80\xCE\x7B\xFA\x74\x5A\xE1\x4B\x12\x2A\x03\x1F\x8D\x6F\x5D\x65\xCF\x76\x4E\x6D\x79\x98\x1B\x31\x8C\x5B\x66\x0A\x35\x9B\x42\x5D\x7F\x20\xF0\x1B\x80\xF5\x78\x7E\xB2\x67\x16\x93\x76\x08\x12\xC8\x12\x53\x2A\x82\x08\xBF\x5C\x3B\x71\x67\x44\x69\xA7\x30\x52\x50\x4F\x64\xBA\x65\x95\x53\x64\x63\x86\x07\x93\x6A\xEF\x5F\x51\x08\x0D\x13\x5C\x5E\x19\x6F\xBA\x7F\x05\x91\x4A\x86\xA2\x60",
|
|
};
|
|
|
|
void GuiIqGetParserBuffer(vl::stream::MemoryStream& stream)
|
|
{
|
|
vl::stream::MemoryStream compressedStream;
|
|
for (vint i = 0; i < parserBufferRows; i++)
|
|
{
|
|
vint size = i == parserBufferRows - 1 ? parserBufferRemain : parserBufferBlock;
|
|
compressedStream.Write((void*)parserBuffer[i], size);
|
|
}
|
|
compressedStream.SeekFromBegin(0);
|
|
vl::stream::LzwDecoder decoder;
|
|
vl::stream::DecoderStream decoderStream(compressedStream, decoder);
|
|
vl::collections::Array<vl::vuint8_t> buffer(65536);
|
|
while (true)
|
|
{
|
|
vl::vint size = decoderStream.Read(&buffer[0], 65536);
|
|
if (size == 0) break;
|
|
stream.Write(&buffer[0], size);
|
|
}
|
|
stream.SeekFromBegin(0);
|
|
}
|
|
/***********************************************************************
|
|
Unescaping Function Foward Declarations
|
|
***********************************************************************/
|
|
|
|
/***********************************************************************
|
|
Parsing Tree Conversion Driver Implementation
|
|
***********************************************************************/
|
|
|
|
class GuiIqTreeConverter : public vl::parsing::ParsingTreeConverter
|
|
{
|
|
public:
|
|
using vl::parsing::ParsingTreeConverter::SetMember;
|
|
|
|
bool SetMember(GuiIqNameOption& member, vl::Ptr<vl::parsing::ParsingTreeNode> node, const TokenList& tokens)
|
|
{
|
|
vl::Ptr<vl::parsing::ParsingTreeToken> token=node.Cast<vl::parsing::ParsingTreeToken>();
|
|
if(token)
|
|
{
|
|
if(token->GetValue()==L"Specified") { member=GuiIqNameOption::Specified; return true; }
|
|
else if(token->GetValue()==L"Any") { member=GuiIqNameOption::Any; return true; }
|
|
else { member=GuiIqNameOption::Specified; return false; }
|
|
}
|
|
member=GuiIqNameOption::Specified;
|
|
return false;
|
|
}
|
|
|
|
bool SetMember(GuiIqChildOption& member, vl::Ptr<vl::parsing::ParsingTreeNode> node, const TokenList& tokens)
|
|
{
|
|
vl::Ptr<vl::parsing::ParsingTreeToken> token=node.Cast<vl::parsing::ParsingTreeToken>();
|
|
if(token)
|
|
{
|
|
if(token->GetValue()==L"Direct") { member=GuiIqChildOption::Direct; return true; }
|
|
else if(token->GetValue()==L"Indirect") { member=GuiIqChildOption::Indirect; return true; }
|
|
else { member=GuiIqChildOption::Direct; return false; }
|
|
}
|
|
member=GuiIqChildOption::Direct;
|
|
return false;
|
|
}
|
|
|
|
bool SetMember(GuiIqBinaryOperator& member, vl::Ptr<vl::parsing::ParsingTreeNode> node, const TokenList& tokens)
|
|
{
|
|
vl::Ptr<vl::parsing::ParsingTreeToken> token=node.Cast<vl::parsing::ParsingTreeToken>();
|
|
if(token)
|
|
{
|
|
if(token->GetValue()==L"ExclusiveOr") { member=GuiIqBinaryOperator::ExclusiveOr; return true; }
|
|
else if(token->GetValue()==L"Intersect") { member=GuiIqBinaryOperator::Intersect; return true; }
|
|
else if(token->GetValue()==L"Union") { member=GuiIqBinaryOperator::Union; return true; }
|
|
else if(token->GetValue()==L"Substract") { member=GuiIqBinaryOperator::Substract; return true; }
|
|
else { member=GuiIqBinaryOperator::ExclusiveOr; return false; }
|
|
}
|
|
member=GuiIqBinaryOperator::ExclusiveOr;
|
|
return false;
|
|
}
|
|
|
|
void Fill(vl::Ptr<GuiIqQuery> tree, vl::Ptr<vl::parsing::ParsingTreeObject> obj, const TokenList& tokens)
|
|
{
|
|
}
|
|
|
|
void Fill(vl::Ptr<GuiIqPrimaryQuery> tree, vl::Ptr<vl::parsing::ParsingTreeObject> obj, const TokenList& tokens)
|
|
{
|
|
SetMember(tree->childOption, obj->GetMember(L"childOption"), tokens);
|
|
SetMember(tree->attributeNameOption, obj->GetMember(L"attributeNameOption"), tokens);
|
|
SetMember(tree->attributeName, obj->GetMember(L"attributeName"), tokens);
|
|
SetMember(tree->typeNameOption, obj->GetMember(L"typeNameOption"), tokens);
|
|
SetMember(tree->typeName, obj->GetMember(L"typeName"), tokens);
|
|
SetMember(tree->referenceName, obj->GetMember(L"referenceName"), tokens);
|
|
}
|
|
|
|
void Fill(vl::Ptr<GuiIqCascadeQuery> tree, vl::Ptr<vl::parsing::ParsingTreeObject> obj, const TokenList& tokens)
|
|
{
|
|
SetMember(tree->parent, obj->GetMember(L"parent"), tokens);
|
|
SetMember(tree->child, obj->GetMember(L"child"), tokens);
|
|
}
|
|
|
|
void Fill(vl::Ptr<GuiIqSetQuery> tree, vl::Ptr<vl::parsing::ParsingTreeObject> obj, const TokenList& tokens)
|
|
{
|
|
SetMember(tree->first, obj->GetMember(L"first"), tokens);
|
|
SetMember(tree->second, obj->GetMember(L"second"), tokens);
|
|
SetMember(tree->op, obj->GetMember(L"op"), tokens);
|
|
}
|
|
|
|
vl::Ptr<vl::parsing::ParsingTreeCustomBase> ConvertClass(vl::Ptr<vl::parsing::ParsingTreeObject> obj, const TokenList& tokens)override
|
|
{
|
|
if(obj->GetType()==L"PrimaryQuery")
|
|
{
|
|
vl::Ptr<GuiIqPrimaryQuery> tree = new GuiIqPrimaryQuery;
|
|
vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules());
|
|
Fill(tree, obj, tokens);
|
|
Fill(tree.Cast<GuiIqQuery>(), obj, tokens);
|
|
return tree;
|
|
}
|
|
else if(obj->GetType()==L"CascadeQuery")
|
|
{
|
|
vl::Ptr<GuiIqCascadeQuery> tree = new GuiIqCascadeQuery;
|
|
vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules());
|
|
Fill(tree, obj, tokens);
|
|
Fill(tree.Cast<GuiIqQuery>(), obj, tokens);
|
|
return tree;
|
|
}
|
|
else if(obj->GetType()==L"SetQuery")
|
|
{
|
|
vl::Ptr<GuiIqSetQuery> tree = new GuiIqSetQuery;
|
|
vl::collections::CopyFrom(tree->creatorRules, obj->GetCreatorRules());
|
|
Fill(tree, obj, tokens);
|
|
Fill(tree.Cast<GuiIqQuery>(), obj, tokens);
|
|
return tree;
|
|
}
|
|
else
|
|
return 0;
|
|
}
|
|
};
|
|
|
|
vl::Ptr<vl::parsing::ParsingTreeCustomBase> GuiIqConvertParsingTreeNode(vl::Ptr<vl::parsing::ParsingTreeNode> node, const vl::collections::List<vl::regex::RegexToken>& tokens)
|
|
{
|
|
GuiIqTreeConverter converter;
|
|
vl::Ptr<vl::parsing::ParsingTreeCustomBase> tree;
|
|
converter.SetMember(tree, node, tokens);
|
|
return tree;
|
|
}
|
|
|
|
/***********************************************************************
|
|
Parsing Tree Conversion Implementation
|
|
***********************************************************************/
|
|
|
|
vl::Ptr<GuiIqPrimaryQuery> GuiIqPrimaryQuery::Convert(vl::Ptr<vl::parsing::ParsingTreeNode> node, const vl::collections::List<vl::regex::RegexToken>& tokens)
|
|
{
|
|
return GuiIqConvertParsingTreeNode(node, tokens).Cast<GuiIqPrimaryQuery>();
|
|
}
|
|
|
|
vl::Ptr<GuiIqCascadeQuery> GuiIqCascadeQuery::Convert(vl::Ptr<vl::parsing::ParsingTreeNode> node, const vl::collections::List<vl::regex::RegexToken>& tokens)
|
|
{
|
|
return GuiIqConvertParsingTreeNode(node, tokens).Cast<GuiIqCascadeQuery>();
|
|
}
|
|
|
|
vl::Ptr<GuiIqSetQuery> GuiIqSetQuery::Convert(vl::Ptr<vl::parsing::ParsingTreeNode> node, const vl::collections::List<vl::regex::RegexToken>& tokens)
|
|
{
|
|
return GuiIqConvertParsingTreeNode(node, tokens).Cast<GuiIqSetQuery>();
|
|
}
|
|
|
|
/***********************************************************************
|
|
Parser Function
|
|
***********************************************************************/
|
|
|
|
vl::Ptr<vl::parsing::ParsingTreeNode> GuiIqParseAsParsingTreeNode(const vl::WString& input, vl::Ptr<vl::parsing::tabling::ParsingTable> table, vl::collections::List<vl::Ptr<vl::parsing::ParsingError>>& errors, vl::vint codeIndex)
|
|
{
|
|
vl::parsing::tabling::ParsingState state(input, table, codeIndex);
|
|
state.Reset(L"QueryRoot");
|
|
vl::Ptr<vl::parsing::tabling::ParsingGeneralParser> parser=vl::parsing::tabling::CreateStrictParser(table);
|
|
vl::Ptr<vl::parsing::ParsingTreeNode> node=parser->Parse(state, errors);
|
|
return node;
|
|
}
|
|
|
|
vl::Ptr<vl::parsing::ParsingTreeNode> GuiIqParseAsParsingTreeNode(const vl::WString& input, vl::Ptr<vl::parsing::tabling::ParsingTable> table, vl::vint codeIndex)
|
|
{
|
|
vl::collections::List<vl::Ptr<vl::parsing::ParsingError>> errors;
|
|
return GuiIqParseAsParsingTreeNode(input, table, errors, codeIndex);
|
|
}
|
|
|
|
vl::Ptr<GuiIqQuery> GuiIqParse(const vl::WString& input, vl::Ptr<vl::parsing::tabling::ParsingTable> table, vl::collections::List<vl::Ptr<vl::parsing::ParsingError>>& errors, vl::vint codeIndex)
|
|
{
|
|
vl::parsing::tabling::ParsingState state(input, table, codeIndex);
|
|
state.Reset(L"QueryRoot");
|
|
vl::Ptr<vl::parsing::tabling::ParsingGeneralParser> parser=vl::parsing::tabling::CreateStrictParser(table);
|
|
vl::Ptr<vl::parsing::ParsingTreeNode> node=parser->Parse(state, errors);
|
|
if(node && errors.Count()==0)
|
|
{
|
|
return GuiIqConvertParsingTreeNode(node, state.GetTokens()).Cast<GuiIqQuery>();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
vl::Ptr<GuiIqQuery> GuiIqParse(const vl::WString& input, vl::Ptr<vl::parsing::tabling::ParsingTable> table, vl::vint codeIndex)
|
|
{
|
|
vl::collections::List<vl::Ptr<vl::parsing::ParsingError>> errors;
|
|
return GuiIqParse(input, table, errors, codeIndex);
|
|
}
|
|
|
|
/***********************************************************************
|
|
Table Generation
|
|
***********************************************************************/
|
|
|
|
vl::Ptr<vl::parsing::tabling::ParsingTable> GuiIqLoadTable()
|
|
{
|
|
vl::stream::MemoryStream stream;
|
|
GuiIqGetParserBuffer(stream);
|
|
vl::Ptr<vl::parsing::tabling::ParsingTable> table=new vl::parsing::tabling::ParsingTable(stream);
|
|
table->Initialize();
|
|
return table;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWCODEGEN.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
using namespace parsing;
|
|
using namespace workflow;
|
|
using namespace workflow::analyzer;
|
|
using namespace workflow::runtime;
|
|
using namespace reflection::description;
|
|
using namespace collections;
|
|
|
|
using namespace controls;
|
|
using namespace compositions;
|
|
|
|
/***********************************************************************
|
|
FindInstanceLoadingSource
|
|
***********************************************************************/
|
|
|
|
InstanceLoadingSource FindInstanceLoadingSource(Ptr<GuiInstanceContext> context, GuiConstructorRepr* ctor)
|
|
{
|
|
vint index = context->namespaces.Keys().IndexOf(ctor->typeNamespace);
|
|
if (index != -1)
|
|
{
|
|
Ptr<GuiInstanceContext::NamespaceInfo> namespaceInfo = context->namespaces.Values()[index];
|
|
FOREACH(Ptr<GuiInstanceNamespace>, ns, namespaceInfo->namespaces)
|
|
{
|
|
auto fullName = GlobalStringKey::Get(ns->prefix + ctor->typeName.ToString() + ns->postfix);
|
|
if (auto loader = GetInstanceLoaderManager()->GetLoader(fullName))
|
|
{
|
|
return InstanceLoadingSource(loader, fullName);
|
|
}
|
|
}
|
|
}
|
|
return InstanceLoadingSource();
|
|
}
|
|
|
|
/***********************************************************************
|
|
Workflow_PrecompileInstanceContext
|
|
***********************************************************************/
|
|
|
|
Ptr<workflow::WfModule> Workflow_PrecompileInstanceContext(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GuiResourceError::List& errors)
|
|
{
|
|
auto module = Workflow_CreateModuleWithUsings(resolvingResult.context);
|
|
{
|
|
auto block = Workflow_InstallCtorClass(resolvingResult, module);
|
|
Workflow_GenerateCreating(precompileContext, resolvingResult, block, errors);
|
|
Workflow_GenerateBindings(precompileContext, resolvingResult, block, errors);
|
|
}
|
|
return module;
|
|
}
|
|
|
|
/***********************************************************************
|
|
WorkflowEventNamesVisitor
|
|
***********************************************************************/
|
|
|
|
class WorkflowEventNamesVisitor : public Object, public GuiValueRepr::IVisitor
|
|
{
|
|
public:
|
|
GuiResourcePrecompileContext& precompileContext;
|
|
types::ResolvingResult& resolvingResult;
|
|
List<types::PropertyResolving>& candidatePropertyTypeInfos;
|
|
Ptr<WfClassDeclaration> instanceClass;
|
|
GuiResourceError::List& errors;
|
|
|
|
IGuiInstanceLoader::TypeInfo resolvedTypeInfo;
|
|
|
|
WorkflowEventNamesVisitor(GuiResourcePrecompileContext& _precompileContext, types::ResolvingResult& _resolvingResult, List<types::PropertyResolving>& _candidatePropertyTypeInfos, Ptr<WfClassDeclaration> _instanceClass, GuiResourceError::List& _errors)
|
|
:precompileContext(_precompileContext)
|
|
, resolvingResult(_resolvingResult)
|
|
, candidatePropertyTypeInfos(_candidatePropertyTypeInfos)
|
|
, instanceClass(_instanceClass)
|
|
, errors(_errors)
|
|
{
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
Ptr<WfDeclaration> ProcessEvent(
|
|
Ptr<GuiAttSetterRepr::EventValue> handler,
|
|
GlobalStringKey propertyName
|
|
)
|
|
{
|
|
if (auto eventInfo = resolvedTypeInfo.typeInfo->GetTypeDescriptor()->GetEventByName(propertyName.ToString(), true))
|
|
{
|
|
auto decl = Workflow_GenerateEventHandler(precompileContext, eventInfo);
|
|
decl->anonymity = WfFunctionAnonymity::Named;
|
|
decl->name.value = handler->value;
|
|
|
|
{
|
|
auto att = MakePtr<WfAttribute>();
|
|
att->category.value = L"cpp";
|
|
att->name.value = L"Protected";
|
|
|
|
decl->attributes.Add(att);
|
|
}
|
|
{
|
|
auto att = MakePtr<WfAttribute>();
|
|
att->category.value = L"cpp";
|
|
att->name.value = L"UserImpl";
|
|
|
|
decl->attributes.Add(att);
|
|
}
|
|
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
decl->statement = block;
|
|
|
|
auto stringExpr = MakePtr<WfStringExpression>();
|
|
stringExpr->value.value = L"Not Implemented: " + handler->value;
|
|
|
|
auto raiseStat = MakePtr<WfRaiseExceptionStatement>();
|
|
raiseStat->expression = stringExpr;
|
|
block->statements.Add(raiseStat);
|
|
}
|
|
|
|
decl->classMember = MakePtr<WfClassMember>();
|
|
decl->classMember->kind = WfClassMemberKind::Normal;
|
|
return decl;
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, handler->attPosition,
|
|
L"Precompile: Event \"" +
|
|
propertyName.ToString() +
|
|
L"\" cannot be found in type \"" +
|
|
resolvedTypeInfo.typeName.ToString() +
|
|
L"\"."));
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void Visit(GuiTextRepr* repr)override
|
|
{
|
|
}
|
|
|
|
void Visit(GuiAttSetterRepr* repr)override
|
|
{
|
|
FOREACH_INDEXER(Ptr<GuiAttSetterRepr::SetterValue>, setter, index, repr->setters.Values())
|
|
{
|
|
auto loader = GetInstanceLoaderManager()->GetLoader(resolvedTypeInfo.typeName);
|
|
List<types::PropertyResolving> possibleInfos;
|
|
auto prop = repr->setters.Keys()[index];
|
|
|
|
WString errorPrefix;
|
|
if (Workflow_GetPropertyTypes(errorPrefix, resolvingResult, loader, resolvedTypeInfo, prop, setter, possibleInfos, errors))
|
|
{
|
|
if (setter->binding == GlobalStringKey::_Set)
|
|
{
|
|
if (possibleInfos[0].info->support == GuiInstancePropertyInfo::SupportSet)
|
|
{
|
|
auto setTarget = dynamic_cast<GuiAttSetterRepr*>(setter->values[0].Obj());
|
|
|
|
List<types::PropertyResolving> infos;
|
|
WorkflowEventNamesVisitor visitor(precompileContext, resolvingResult, infos, instanceClass, errors);
|
|
auto typeInfo = possibleInfos[0].info->acceptableTypes[0];
|
|
visitor.resolvedTypeInfo.typeName = GlobalStringKey::Get(typeInfo->GetTypeDescriptor()->GetTypeName());
|
|
visitor.resolvedTypeInfo.typeInfo = typeInfo;
|
|
setTarget->Accept(&visitor);
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, setter->attPosition, errorPrefix + L" does not support the \"-set\" binding."));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
FOREACH(Ptr<GuiValueRepr>, value, setter->values)
|
|
{
|
|
WorkflowEventNamesVisitor visitor(precompileContext, resolvingResult, possibleInfos, instanceClass, errors);
|
|
value->Accept(&visitor);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
FOREACH_INDEXER(Ptr<GuiAttSetterRepr::EventValue>, handler, index, repr->eventHandlers.Values())
|
|
{
|
|
if (handler->binding == GlobalStringKey::Empty)
|
|
{
|
|
auto propertyName = repr->eventHandlers.Keys()[index];
|
|
if (auto decl = ProcessEvent(handler, propertyName))
|
|
{
|
|
Workflow_RecordScriptPosition(precompileContext, handler->valuePosition, decl);
|
|
instanceClass->declarations.Add(decl);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void Visit(GuiConstructorRepr* repr)override
|
|
{
|
|
auto context = resolvingResult.context;
|
|
|
|
bool inferType = repr->typeNamespace == GlobalStringKey::Empty&&repr->typeName == GlobalStringKey::_InferType;
|
|
|
|
bool noContextToInfer = false;
|
|
if (inferType)
|
|
{
|
|
if (candidatePropertyTypeInfos.Count() == 1)
|
|
{
|
|
auto info = candidatePropertyTypeInfos[0].info;
|
|
if (info->acceptableTypes.Count() == 1)
|
|
{
|
|
auto typeInfo = info->acceptableTypes[0];
|
|
resolvedTypeInfo.typeName = GlobalStringKey::Get(typeInfo->GetTypeDescriptor()->GetTypeName());
|
|
resolvedTypeInfo.typeInfo = typeInfo;
|
|
}
|
|
else if (info->acceptableTypes.Count() == 0)
|
|
{
|
|
noContextToInfer = true;
|
|
}
|
|
}
|
|
else if (candidatePropertyTypeInfos.Count() == 0)
|
|
{
|
|
noContextToInfer = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (repr == context->instance.Obj())
|
|
{
|
|
auto fullName = GlobalStringKey::Get(context->className);
|
|
if (auto reprType = GetInstanceLoaderManager()->GetTypeInfoForType(fullName))
|
|
{
|
|
resolvedTypeInfo.typeName = fullName;
|
|
resolvedTypeInfo.typeInfo = reprType;
|
|
}
|
|
}
|
|
if (!resolvedTypeInfo.typeInfo)
|
|
{
|
|
auto source = FindInstanceLoadingSource(context, repr);
|
|
resolvedTypeInfo.typeName = source.typeName;
|
|
resolvedTypeInfo.typeInfo = GetInstanceLoaderManager()->GetTypeInfoForType(source.typeName);
|
|
}
|
|
}
|
|
|
|
if (resolvedTypeInfo.typeInfo)
|
|
{
|
|
if (repr->setters.Count() == 1 && repr->setters.Keys()[0] == GlobalStringKey::Empty)
|
|
{
|
|
auto setter = repr->setters.Values()[0];
|
|
if (setter->values.Count() == 1)
|
|
{
|
|
if (auto text = setter->values[0].Cast<GuiTextRepr>())
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
Visit((GuiAttSetterRepr*)repr);
|
|
}
|
|
else if (inferType)
|
|
{
|
|
if (noContextToInfer)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->tagPosition,
|
|
L"Precompile: Unable to resolve type \"_\" without any context."));
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->tagPosition,
|
|
L"Precompile: Unable to resolve type \"_\" since the current property accepts multiple types."));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->tagPosition,
|
|
L"Precompile: Failed to find type \"" +
|
|
(repr->typeNamespace == GlobalStringKey::Empty
|
|
? repr->typeName.ToString()
|
|
: repr->typeNamespace.ToString() + L":" + repr->typeName.ToString()
|
|
) +
|
|
L"\"."));
|
|
}
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
Workflow_GenerateInstanceClass
|
|
***********************************************************************/
|
|
|
|
class ReplaceDeclImplVisitor
|
|
: public empty_visitor::DeclarationVisitor
|
|
, public empty_visitor::VirtualDeclarationVisitor
|
|
{
|
|
public:
|
|
Func<Ptr<WfStatement>()> statCtor;
|
|
List<Ptr<WfDeclaration>>& unprocessed;
|
|
|
|
ReplaceDeclImplVisitor(Func<Ptr<WfStatement>()> _statCtor, List<Ptr<WfDeclaration>>& _unprocessed)
|
|
:statCtor(_statCtor)
|
|
, unprocessed(_unprocessed)
|
|
{
|
|
}
|
|
|
|
virtual void Dispatch(WfVirtualDeclaration* node)override
|
|
{
|
|
node->Accept(static_cast<WfVirtualDeclaration::IVisitor*>(this));
|
|
}
|
|
|
|
virtual void Visit(WfFunctionDeclaration* node)override
|
|
{
|
|
node->statement = statCtor();
|
|
}
|
|
|
|
virtual void Visit(WfConstructorDeclaration* node)override
|
|
{
|
|
node->statement = statCtor();
|
|
}
|
|
|
|
virtual void Visit(WfDestructorDeclaration* node)override
|
|
{
|
|
node->statement = statCtor();
|
|
}
|
|
|
|
virtual void Visit(WfClassDeclaration* node)override
|
|
{
|
|
CopyFrom(unprocessed, node->declarations, true);
|
|
}
|
|
};
|
|
|
|
Ptr<workflow::WfModule> Workflow_GenerateInstanceClass(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GuiResourceError::List& errors, vint passIndex)
|
|
{
|
|
bool beforePrecompile = false;
|
|
bool needEventHandler = false;
|
|
switch (passIndex)
|
|
{
|
|
case IGuiResourceTypeResolver_Precompile::Instance_CollectInstanceTypes:
|
|
beforePrecompile = true;
|
|
needEventHandler = false;
|
|
break;
|
|
case IGuiResourceTypeResolver_Precompile::Instance_CollectEventHandlers:
|
|
beforePrecompile = true;
|
|
needEventHandler = true;
|
|
break;
|
|
case IGuiResourceTypeResolver_Precompile::Instance_GenerateInstanceClass:
|
|
beforePrecompile = false;
|
|
needEventHandler = true;
|
|
break;
|
|
}
|
|
|
|
auto context = resolvingResult.context;
|
|
auto source = FindInstanceLoadingSource(context, context->instance.Obj());
|
|
auto baseType = GetInstanceLoaderManager()->GetTypeInfoForType(source.typeName);
|
|
if (!baseType)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, context->instance->tagPosition,
|
|
L"Precompile: Failed to find type \"" +
|
|
(context->instance->typeNamespace == GlobalStringKey::Empty
|
|
? context->instance->typeName.ToString()
|
|
: context->instance->typeNamespace.ToString() + L":" + context->instance->typeName.ToString()
|
|
) +
|
|
L"\"."));
|
|
return nullptr;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
// Instance Class
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
auto module = Workflow_CreateModuleWithUsings(context);
|
|
auto instanceClass = Workflow_InstallClass(context->className, module);
|
|
{
|
|
auto typeInfo = MakePtr<TypeDescriptorTypeInfo>(baseType->GetTypeDescriptor(), TypeInfoHint::Normal);
|
|
auto baseType = GetTypeFromTypeInfo(typeInfo.Obj());
|
|
instanceClass->baseTypes.Add(baseType);
|
|
|
|
if (context->codeBehind)
|
|
{
|
|
auto value = MakePtr<WfStringExpression>();
|
|
value->value.value = instanceClass->name.value;
|
|
|
|
auto att = MakePtr<WfAttribute>();
|
|
att->category.value = L"cpp";
|
|
att->name.value = L"File";
|
|
att->value = value;
|
|
|
|
instanceClass->attributes.Add(att);
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
// Inherit from Constructor Class
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
if (!beforePrecompile)
|
|
{
|
|
auto baseType = MakePtr<WfReferenceType>();
|
|
baseType->name.value = instanceClass->name.value + L"Constructor";
|
|
instanceClass->baseTypes.Add(baseType);
|
|
|
|
{
|
|
auto value = MakePtr<WfTypeOfTypeExpression>();
|
|
value->type = CopyType(baseType);
|
|
|
|
auto att = MakePtr<WfAttribute>();
|
|
att->category.value = L"cpp";
|
|
att->name.value = L"Friend";
|
|
att->value = value;
|
|
|
|
instanceClass->attributes.Add(att);
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
// Helpers
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
auto parseClassMembers = [&](const WString& code, const WString& name, List<Ptr<WfDeclaration>>& memberDecls, GuiResourceTextPos position)
|
|
{
|
|
WString wrappedCode = L"module parse_members; class Class {\r\n" + code + L"\r\n}";
|
|
if(auto module = Workflow_ParseModule(precompileContext, { resolvingResult.resource }, wrappedCode, position, errors, { 1,0 }))
|
|
{
|
|
CopyFrom(memberDecls, module->declarations[0].Cast<WfClassDeclaration>()->declarations);
|
|
}
|
|
};
|
|
|
|
auto addDecl = [=](Ptr<WfDeclaration> decl)
|
|
{
|
|
decl->classMember = MakePtr<WfClassMember>();
|
|
decl->classMember->kind = WfClassMemberKind::Normal;
|
|
instanceClass->declarations.Add(decl);
|
|
};
|
|
|
|
auto notImplemented = []()
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
auto stringExpr = MakePtr<WfStringExpression>();
|
|
stringExpr->value.value = L"Not Implemented";
|
|
|
|
auto raiseStat = MakePtr<WfRaiseExceptionStatement>();
|
|
raiseStat->expression = stringExpr;
|
|
|
|
block->statements.Add(raiseStat);
|
|
return block;
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
// ref.Members
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
if (context->memberScript != L"")
|
|
{
|
|
List<Ptr<WfDeclaration>> memberDecls;
|
|
parseClassMembers(context->memberScript, L"members of instance \"" + context->className + L"\"", memberDecls, context->memberPosition);
|
|
|
|
if (beforePrecompile)
|
|
{
|
|
List<Ptr<WfDeclaration>> unprocessed;
|
|
CopyFrom(unprocessed, memberDecls);
|
|
|
|
ReplaceDeclImplVisitor visitor(notImplemented, unprocessed);
|
|
for (vint i = 0; i < unprocessed.Count(); i++)
|
|
{
|
|
unprocessed[i]->Accept(&visitor);
|
|
}
|
|
}
|
|
|
|
CopyFrom(instanceClass->declarations, memberDecls, true);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
// Constructor Declaration
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
auto ctor = MakePtr<WfConstructorDeclaration>();
|
|
ctor->constructorType = WfConstructorType::RawPtr;
|
|
auto ctorBlock = (beforePrecompile ? notImplemented() : MakePtr<WfBlockStatement>());
|
|
ctor->statement = ctorBlock;
|
|
|
|
if (auto group = baseType->GetTypeDescriptor()->GetConstructorGroup())
|
|
{
|
|
vint count = group->GetMethod(0)->GetParameterCount();
|
|
if (count > 0)
|
|
{
|
|
if (!beforePrecompile)
|
|
{
|
|
if (auto call = resolvingResult.rootLoader->CreateRootInstance(precompileContext, resolvingResult, resolvingResult.rootTypeInfo, resolvingResult.rootCtorArguments, errors))
|
|
{
|
|
ctor->baseConstructorCalls.Add(call);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
auto call = MakePtr<WfBaseConstructorCall>();
|
|
ctor->baseConstructorCalls.Add(call);
|
|
|
|
call->type = CopyType(instanceClass->baseTypes[0]);
|
|
for (vint i = 0; i < count; i++)
|
|
{
|
|
auto nullExpr = MakePtr<WfLiteralExpression>();
|
|
nullExpr->value = WfLiteralValue::Null;
|
|
call->arguments.Add(nullExpr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
// ref.Parameter (Variable, Getter, CtorArgument)
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
FOREACH(Ptr<GuiInstanceParameter>, param, context->parameters)
|
|
{
|
|
if (auto type = Workflow_ParseType(precompileContext, { resolvingResult.resource }, param->className.ToString() + L"^", param->classPosition, errors))
|
|
{
|
|
if (!beforePrecompile)
|
|
{
|
|
auto decl = MakePtr<WfVariableDeclaration>();
|
|
addDecl(decl);
|
|
|
|
decl->name.value = L"<parameter>" + param->name.ToString();
|
|
decl->type = CopyType(type);
|
|
|
|
auto nullExpr = MakePtr<WfLiteralExpression>();
|
|
nullExpr->value = WfLiteralValue::Null;
|
|
decl->expression = nullExpr;
|
|
|
|
Workflow_RecordScriptPosition(precompileContext, param->tagPosition, (Ptr<WfDeclaration>)decl);
|
|
}
|
|
{
|
|
auto decl = MakePtr<WfFunctionDeclaration>();
|
|
addDecl(decl);
|
|
|
|
decl->anonymity = WfFunctionAnonymity::Named;
|
|
decl->name.value = L"Get" + param->name.ToString();
|
|
decl->returnType = CopyType(type);
|
|
if (!beforePrecompile)
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
decl->statement = block;
|
|
|
|
auto ref = MakePtr<WfReferenceExpression>();
|
|
ref->name.value = L"<parameter>" + param->name.ToString();
|
|
|
|
auto returnStat = MakePtr<WfReturnStatement>();
|
|
returnStat->expression = ref;
|
|
block->statements.Add(returnStat);
|
|
}
|
|
else
|
|
{
|
|
decl->statement = notImplemented();
|
|
}
|
|
|
|
Workflow_RecordScriptPosition(precompileContext, param->tagPosition, (Ptr<WfDeclaration>)decl);
|
|
}
|
|
{
|
|
auto decl = MakePtr<WfPropertyDeclaration>();
|
|
addDecl(decl);
|
|
|
|
decl->name.value = param->name.ToString();
|
|
decl->type = type;
|
|
decl->getter.value = L"Get" + param->name.ToString();
|
|
|
|
Workflow_RecordScriptPosition(precompileContext, param->tagPosition, (Ptr<WfDeclaration>)decl);
|
|
}
|
|
{
|
|
auto argument = MakePtr<WfFunctionArgument>();
|
|
argument->name.value = L"<ctor-parameter>" + param->name.ToString();
|
|
argument->type = CopyType(type);
|
|
ctor->arguments.Add(argument);
|
|
}
|
|
if (!beforePrecompile)
|
|
{
|
|
auto refLeft = MakePtr<WfReferenceExpression>();
|
|
refLeft->name.value = L"<parameter>" + param->name.ToString();
|
|
|
|
auto refRight = MakePtr<WfReferenceExpression>();
|
|
refRight->name.value = L"<ctor-parameter>" + param->name.ToString();
|
|
|
|
auto assignExpr = MakePtr<WfBinaryExpression>();
|
|
assignExpr->op = WfBinaryOperator::Assign;
|
|
assignExpr->first = refLeft;
|
|
assignExpr->second = refRight;
|
|
|
|
auto exprStat = MakePtr<WfExpressionStatement>();
|
|
exprStat->expression = assignExpr;
|
|
|
|
ctorBlock->statements.Add(exprStat);
|
|
|
|
Workflow_RecordScriptPosition(precompileContext, param->tagPosition, (Ptr<WfStatement>)exprStat);
|
|
}
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
// Event Handlers
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
if (needEventHandler)
|
|
{
|
|
List<types::PropertyResolving> infos;
|
|
WorkflowEventNamesVisitor visitor(precompileContext, resolvingResult, infos, instanceClass, errors);
|
|
context->instance->Accept(&visitor);
|
|
}
|
|
|
|
addDecl(ctor);
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
// Calling Constructor Class
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
if (!beforePrecompile)
|
|
{
|
|
{
|
|
auto presentationExpr = MakePtr<WfTopQualifiedExpression>();
|
|
presentationExpr->name.value = L"presentation";
|
|
|
|
auto rmExpr = MakePtr<WfChildExpression>();
|
|
rmExpr->parent = presentationExpr;
|
|
rmExpr->name.value = L"IGuiResourceManager";
|
|
|
|
auto getRmExpr = MakePtr<WfChildExpression>();
|
|
getRmExpr->parent = rmExpr;
|
|
getRmExpr->name.value = L"GetResourceManager";
|
|
|
|
auto call1Expr = MakePtr<WfCallExpression>();
|
|
call1Expr->function = getRmExpr;
|
|
|
|
auto getResExpr = MakePtr<WfMemberExpression>();
|
|
getResExpr->parent = call1Expr;
|
|
getResExpr->name.value = L"GetResourceFromClassName";
|
|
|
|
auto classNameExpr = MakePtr<WfStringExpression>();
|
|
classNameExpr->value.value = context->className;
|
|
|
|
auto call2Expr = MakePtr<WfCallExpression>();
|
|
call2Expr->function = getResExpr;
|
|
call2Expr->arguments.Add(classNameExpr);
|
|
|
|
auto varDecl = MakePtr<WfVariableDeclaration>();
|
|
varDecl->name.value = L"<resource>";
|
|
varDecl->expression = call2Expr;
|
|
|
|
auto varStat = MakePtr<WfVariableStatement>();
|
|
varStat->variable = varDecl;
|
|
|
|
ctorBlock->statements.Add(varStat);
|
|
}
|
|
{
|
|
auto resRef = MakePtr<WfReferenceExpression>();
|
|
resRef->name.value = L"<resource>";
|
|
|
|
auto resRef2 = MakePtr<WfReferenceExpression>();
|
|
resRef2->name.value = L"<resource>";
|
|
|
|
auto wdRef = MakePtr<WfMemberExpression>();
|
|
wdRef->parent = resRef2;
|
|
wdRef->name.value = L"WorkingDirectory";
|
|
|
|
auto newClassExpr = MakePtr<WfNewClassExpression>();
|
|
newClassExpr->type = GetTypeFromTypeInfo(TypeInfoRetriver<Ptr<GuiResourcePathResolver>>::CreateTypeInfo().Obj());
|
|
newClassExpr->arguments.Add(resRef);
|
|
newClassExpr->arguments.Add(wdRef);
|
|
|
|
auto varDecl = MakePtr<WfVariableDeclaration>();
|
|
varDecl->name.value = L"<resolver>";
|
|
varDecl->expression = newClassExpr;
|
|
|
|
auto varStat = MakePtr<WfVariableStatement>();
|
|
varStat->variable = varDecl;
|
|
|
|
ctorBlock->statements.Add(varStat);
|
|
}
|
|
{
|
|
auto ctorRef = MakePtr<WfThisExpression>();
|
|
|
|
auto initRef = MakePtr<WfMemberExpression>();
|
|
initRef->parent = ctorRef;
|
|
initRef->name.value = L"<initialize-instance>";
|
|
|
|
auto refThis = MakePtr<WfThisExpression>();
|
|
|
|
auto resolverRef = MakePtr<WfReferenceExpression>();
|
|
resolverRef->name.value = L"<resolver>";
|
|
|
|
auto castExpr = MakePtr<WfTypeCastingExpression>();
|
|
castExpr->strategy = WfTypeCastingStrategy::Strong;
|
|
castExpr->type = GetTypeFromTypeInfo(TypeInfoRetriver<GuiResourcePathResolver*>::CreateTypeInfo().Obj());
|
|
castExpr->expression = resolverRef;
|
|
|
|
auto callExpr = MakePtr<WfCallExpression>();
|
|
callExpr->function = initRef;
|
|
callExpr->arguments.Add(refThis);
|
|
callExpr->arguments.Add(castExpr);
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = callExpr;
|
|
|
|
ctorBlock->statements.Add(stat);
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
// ref.Ctor
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
if (context->ctorScript != L"")
|
|
{
|
|
if (auto stat = Workflow_ParseStatement(precompileContext, { resolvingResult.resource }, context->ctorScript, context->ctorPosition, errors))
|
|
{
|
|
if (!beforePrecompile)
|
|
{
|
|
if (!stat.Cast<WfBlockStatement>())
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
block->statements.Add(stat);
|
|
stat = block;
|
|
}
|
|
|
|
auto decl = MakePtr<WfFunctionDeclaration>();
|
|
decl->anonymity = WfFunctionAnonymity::Named;
|
|
decl->name.value = L"<instance-ctor>";
|
|
decl->returnType = GetTypeFromTypeInfo(TypeInfoRetriver<void>::CreateTypeInfo().Obj());
|
|
decl->statement = stat;
|
|
addDecl(decl);
|
|
|
|
{
|
|
auto refCtor = MakePtr<WfReferenceExpression>();
|
|
refCtor->name.value = L"<instance-ctor>";
|
|
|
|
auto callExpr = MakePtr<WfCallExpression>();
|
|
callExpr->function = refCtor;
|
|
|
|
auto exprStat = MakePtr<WfExpressionStatement>();
|
|
exprStat->expression = callExpr;
|
|
ctorBlock->statements.Add(exprStat);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
// Destructor
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
auto dtor = MakePtr<WfDestructorDeclaration>();
|
|
auto dtorBlock = MakePtr<WfBlockStatement>();
|
|
dtor->statement = dtorBlock;
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
// ref.Dtor
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
if (context->dtorScript != L"")
|
|
{
|
|
if (auto stat = Workflow_ParseStatement(precompileContext, { resolvingResult.resource }, context->dtorScript, context->dtorPosition, errors))
|
|
{
|
|
if (!beforePrecompile)
|
|
{
|
|
if (!stat.Cast<WfBlockStatement>())
|
|
{
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
block->statements.Add(stat);
|
|
stat = block;
|
|
}
|
|
|
|
auto decl = MakePtr<WfFunctionDeclaration>();
|
|
decl->anonymity = WfFunctionAnonymity::Named;
|
|
decl->name.value = L"<instance-dtor>";
|
|
decl->returnType = GetTypeFromTypeInfo(TypeInfoRetriver<void>::CreateTypeInfo().Obj());
|
|
decl->statement = stat;
|
|
addDecl(decl);
|
|
|
|
{
|
|
auto refDtor = MakePtr<WfReferenceExpression>();
|
|
refDtor->name.value = L"<instance-dtor>";
|
|
|
|
auto callExpr = MakePtr<WfCallExpression>();
|
|
callExpr->function = refDtor;
|
|
|
|
auto exprStat = MakePtr<WfExpressionStatement>();
|
|
exprStat->expression = callExpr;
|
|
dtorBlock->statements.Add(exprStat);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////
|
|
// Clear Binding Subscriptions
|
|
///////////////////////////////////////////////////////////////
|
|
|
|
{
|
|
auto ref = MakePtr<WfReferenceExpression>();
|
|
ref->name.value = L"ClearSubscriptions";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = ref;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
dtorBlock->statements.Add(stat);
|
|
}
|
|
|
|
addDecl(dtor);
|
|
|
|
return module;
|
|
}
|
|
|
|
/***********************************************************************
|
|
GuiWorkflowSharedManagerPlugin
|
|
***********************************************************************/
|
|
|
|
#undef ERROR_CODE_PREFIX
|
|
|
|
class GuiWorkflowSharedManagerPlugin;
|
|
GuiWorkflowSharedManagerPlugin* sharedManagerPlugin = 0;
|
|
|
|
class GuiWorkflowSharedManagerPlugin : public Object, public IGuiPlugin
|
|
{
|
|
protected:
|
|
Ptr<WfLexicalScopeManager> workflowManager;
|
|
|
|
public:
|
|
GuiWorkflowSharedManagerPlugin()
|
|
{
|
|
}
|
|
|
|
void Load()override
|
|
{
|
|
}
|
|
|
|
void AfterLoad()override
|
|
{
|
|
sharedManagerPlugin = this;
|
|
}
|
|
|
|
void Unload()override
|
|
{
|
|
sharedManagerPlugin = 0;
|
|
}
|
|
|
|
WfLexicalScopeManager* GetWorkflowManager()
|
|
{
|
|
if (!workflowManager)
|
|
{
|
|
workflowManager = new WfLexicalScopeManager(GetParserManager()->GetParsingTable(L"WORKFLOW"));
|
|
}
|
|
return workflowManager.Obj();
|
|
}
|
|
|
|
Ptr<WfLexicalScopeManager> TransferWorkflowManager()
|
|
{
|
|
auto result = workflowManager;
|
|
workflowManager = nullptr;
|
|
return result;
|
|
}
|
|
};
|
|
GUI_REGISTER_PLUGIN(GuiWorkflowSharedManagerPlugin)
|
|
|
|
WfLexicalScopeManager* Workflow_GetSharedManager()
|
|
{
|
|
return sharedManagerPlugin->GetWorkflowManager();
|
|
}
|
|
|
|
Ptr<WfLexicalScopeManager> Workflow_TransferSharedManager()
|
|
{
|
|
return sharedManagerPlugin->TransferWorkflowManager();
|
|
}
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWCOLLECTREFERENCES.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
using namespace reflection::description;
|
|
using namespace collections;
|
|
using namespace parsing;
|
|
using namespace workflow::analyzer;
|
|
|
|
/***********************************************************************
|
|
Workflow_GetPropertyTypes
|
|
***********************************************************************/
|
|
|
|
bool Workflow_GetPropertyTypes(WString& errorPrefix, types::ResolvingResult& resolvingResult, IGuiInstanceLoader* loader, IGuiInstanceLoader::TypeInfo resolvedTypeInfo, GlobalStringKey prop, Ptr<GuiAttSetterRepr::SetterValue> setter, collections::List<types::PropertyResolving>& possibleInfos, GuiResourceError::List& errors)
|
|
{
|
|
bool reportedNotSupported = false;
|
|
IGuiInstanceLoader::PropertyInfo propertyInfo(resolvedTypeInfo, prop);
|
|
|
|
errorPrefix = L"Precompile: Property \"" + propertyInfo.propertyName.ToString() + L"\" of type \"" + resolvedTypeInfo.typeName.ToString() + L"\"";
|
|
{
|
|
auto currentLoader = loader;
|
|
|
|
while (currentLoader)
|
|
{
|
|
if (auto propertyTypeInfo = currentLoader->GetPropertyType(propertyInfo))
|
|
{
|
|
if (propertyTypeInfo->support == GuiInstancePropertyInfo::NotSupport)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, setter->attPosition, errorPrefix + L" is not supported."));
|
|
reportedNotSupported = true;
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
types::PropertyResolving resolving;
|
|
resolving.loader = currentLoader;
|
|
resolving.propertyInfo = propertyInfo;
|
|
resolving.info = propertyTypeInfo;
|
|
possibleInfos.Add(resolving);
|
|
|
|
if (setter->binding == GlobalStringKey::_Set)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (propertyTypeInfo->mergability == GuiInstancePropertyInfo::NotMerge)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
currentLoader = GetInstanceLoaderManager()->GetParentLoader(currentLoader);
|
|
}
|
|
}
|
|
|
|
if (possibleInfos.Count() == 0)
|
|
{
|
|
if (!reportedNotSupported)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, setter->attPosition, errorPrefix + L" does not exist."));
|
|
}
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
WorkflowReferenceNamesVisitor
|
|
***********************************************************************/
|
|
|
|
class WorkflowReferenceNamesVisitor : public Object, public GuiValueRepr::IVisitor
|
|
{
|
|
public:
|
|
GuiResourcePrecompileContext& precompileContext;
|
|
types::ResolvingResult& resolvingResult;
|
|
vint& generatedNameCount;
|
|
GuiResourceError::List& errors;
|
|
|
|
List<types::PropertyResolving>& candidatePropertyTypeInfos;
|
|
IGuiInstanceLoader::TypeInfo resolvedTypeInfo;
|
|
vint selectedPropertyTypeInfo = -1;
|
|
|
|
WorkflowReferenceNamesVisitor(GuiResourcePrecompileContext& _precompileContext, types::ResolvingResult& _resolvingResult, List<types::PropertyResolving>& _candidatePropertyTypeInfos, vint& _generatedNameCount, GuiResourceError::List& _errors)
|
|
:precompileContext(_precompileContext)
|
|
, resolvingResult(_resolvingResult)
|
|
, candidatePropertyTypeInfos(_candidatePropertyTypeInfos)
|
|
, generatedNameCount(_generatedNameCount)
|
|
, errors(_errors)
|
|
{
|
|
}
|
|
|
|
void Visit(GuiTextRepr* repr)override
|
|
{
|
|
if (selectedPropertyTypeInfo == -1)
|
|
{
|
|
selectedPropertyTypeInfo = 0;
|
|
}
|
|
|
|
auto candidate = candidatePropertyTypeInfos[selectedPropertyTypeInfo];
|
|
auto propertyInfo = candidate.propertyInfo;
|
|
ITypeDescriptor* td = nullptr;
|
|
{
|
|
auto typeInfo = candidate.info->acceptableTypes[0];
|
|
if (auto deserializer = GetInstanceLoaderManager()->GetInstanceDeserializer(typeInfo.Obj()))
|
|
{
|
|
td = deserializer->DeserializeAs(typeInfo.Obj())->GetTypeDescriptor();
|
|
}
|
|
else
|
|
{
|
|
td = typeInfo->GetTypeDescriptor();
|
|
}
|
|
}
|
|
|
|
if (auto st = td->GetSerializableType())
|
|
{
|
|
Value value;
|
|
if (st->Deserialize(repr->text, value))
|
|
{
|
|
resolvingResult.propertyResolvings.Add(repr, candidate);
|
|
}
|
|
else
|
|
{
|
|
auto error
|
|
= L"Precompile: Property \""
|
|
+ propertyInfo.propertyName.ToString()
|
|
+ L"\" of type \""
|
|
+ propertyInfo.typeInfo.typeName.ToString()
|
|
+ L"\" does not accept a value of text \""
|
|
+ repr->text
|
|
+ L"\" because it is not in a correct format of the serializable type \""
|
|
+ td->GetTypeName()
|
|
+ L"\".";
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->tagPosition, error));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
switch (td->GetTypeDescriptorFlags())
|
|
{
|
|
case TypeDescriptorFlags::FlagEnum:
|
|
case TypeDescriptorFlags::NormalEnum:
|
|
case TypeDescriptorFlags::Struct:
|
|
{
|
|
if (auto expression = Workflow_ParseTextValue(precompileContext, td, { resolvingResult.resource }, repr->text, repr->tagPosition, errors))
|
|
{
|
|
resolvingResult.propertyResolvings.Add(repr, candidate);
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
{
|
|
auto error
|
|
= L"Precompile: Property \""
|
|
+ propertyInfo.propertyName.ToString()
|
|
+ L"\" of type \""
|
|
+ propertyInfo.typeInfo.typeName.ToString()
|
|
+ L"\" does not accept a value of text \""
|
|
+ repr->text
|
|
+ L"\" because its type \""
|
|
+ td->GetTypeName()
|
|
+ L"\" is not serializable.";
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->tagPosition, error));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void Visit(GuiAttSetterRepr* repr)override
|
|
{
|
|
if (candidatePropertyTypeInfos.Count() > 0)
|
|
{
|
|
resolvingResult.propertyResolvings.Add(repr, candidatePropertyTypeInfos[selectedPropertyTypeInfo]);
|
|
}
|
|
|
|
bool isReferenceType = (resolvedTypeInfo.typeInfo->GetTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined;
|
|
if (repr->instanceName == GlobalStringKey::Empty)
|
|
{
|
|
if (isReferenceType)
|
|
{
|
|
auto name = GlobalStringKey::Get(L"<precompile>" + itow(generatedNameCount++));
|
|
repr->instanceName = name;
|
|
resolvingResult.typeInfos.Add(name, resolvedTypeInfo);
|
|
}
|
|
}
|
|
else if (resolvingResult.typeInfos.Keys().Contains(repr->instanceName))
|
|
{
|
|
auto error
|
|
= L"Precompile: Referece name \""
|
|
+ repr->instanceName.ToString()
|
|
+ L"\" conflict with an existing named object.";
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->tagPosition, error));
|
|
}
|
|
else if (!isReferenceType)
|
|
{
|
|
auto error
|
|
= L"Precompile: Reference name \""
|
|
+ repr->instanceName.ToString()
|
|
+ L"\" cannot be added to a non-reference instance of type \""
|
|
+ resolvedTypeInfo.typeName.ToString()
|
|
+ L"\".";
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->tagPosition, error));
|
|
}
|
|
else
|
|
{
|
|
resolvingResult.referenceNames.Add(repr->instanceName);
|
|
resolvingResult.typeInfos.Add(repr->instanceName, resolvedTypeInfo);
|
|
}
|
|
|
|
auto loader = GetInstanceLoaderManager()->GetLoader(resolvedTypeInfo.typeName);
|
|
|
|
FOREACH_INDEXER(Ptr<GuiAttSetterRepr::SetterValue>, setter, index, repr->setters.Values())
|
|
{
|
|
List<types::PropertyResolving> possibleInfos;
|
|
auto prop = repr->setters.Keys()[index];
|
|
|
|
WString errorPrefix;
|
|
if (Workflow_GetPropertyTypes(errorPrefix, resolvingResult, loader, resolvedTypeInfo, prop, setter, possibleInfos, errors))
|
|
{
|
|
if (setter->binding == GlobalStringKey::Empty)
|
|
{
|
|
FOREACH(Ptr<GuiValueRepr>, value, setter->values)
|
|
{
|
|
WorkflowReferenceNamesVisitor visitor(precompileContext, resolvingResult, possibleInfos, generatedNameCount, errors);
|
|
value->Accept(&visitor);
|
|
}
|
|
}
|
|
else if (setter->binding == GlobalStringKey::_Set)
|
|
{
|
|
if (possibleInfos[0].info->support == GuiInstancePropertyInfo::SupportSet)
|
|
{
|
|
auto setTarget = dynamic_cast<GuiAttSetterRepr*>(setter->values[0].Obj());
|
|
|
|
WorkflowReferenceNamesVisitor visitor(precompileContext, resolvingResult, possibleInfos, generatedNameCount, errors);
|
|
auto typeInfo = possibleInfos[0].info->acceptableTypes[0];
|
|
visitor.selectedPropertyTypeInfo = 0;
|
|
visitor.resolvedTypeInfo.typeName = GlobalStringKey::Get(typeInfo->GetTypeDescriptor()->GetTypeName());
|
|
visitor.resolvedTypeInfo.typeInfo = typeInfo;
|
|
setTarget->Accept(&visitor);
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, setter->attPosition, L"[INTERNAL-ERROR] " + errorPrefix + L" does not support the \"-set\" binding."));
|
|
}
|
|
}
|
|
else if (setter->binding != GlobalStringKey::Empty)
|
|
{
|
|
auto binder = GetInstanceLoaderManager()->GetInstanceBinder(setter->binding);
|
|
if (binder)
|
|
{
|
|
if (possibleInfos[0].info->usage == GuiInstancePropertyInfo::ConstructorArgument)
|
|
{
|
|
if (possibleInfos[0].info->bindability == GuiInstancePropertyInfo::NotBindable)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, setter->attPosition,
|
|
errorPrefix +
|
|
L" cannot be assigned using binding \"-" +
|
|
setter->binding.ToString() +
|
|
L"\". Because it is a non-bindable constructor argument."));
|
|
}
|
|
else if (!binder->ApplicableToConstructorArgument())
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, setter->attPosition,
|
|
errorPrefix +
|
|
L" cannot be assigned using binding \"-" +
|
|
setter->binding.ToString() +
|
|
L"\". Because it is a constructor argument, and this binding does not apply to any constructor argument."));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, setter->attPosition,
|
|
errorPrefix +
|
|
L" cannot be assigned using an unexisting binding \"-" +
|
|
setter->binding.ToString() +
|
|
L"\"."));
|
|
}
|
|
|
|
if (setter->values.Count() == 1 && setter->values[0].Cast<GuiTextRepr>())
|
|
{
|
|
resolvingResult.propertyResolvings.Add(setter->values[0].Obj(), possibleInfos[0]);
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, setter->attPosition,
|
|
L"Precompile: Binder \"" +
|
|
setter->binding.ToString() +
|
|
L"\" requires the text value of property \"" +
|
|
prop.ToString() +
|
|
L"\"."));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Group<GlobalStringKey, IGuiInstanceLoader*> properties;
|
|
CopyFrom(
|
|
properties,
|
|
From(repr->setters)
|
|
.SelectMany([=](Pair<GlobalStringKey, Ptr<GuiAttSetterRepr::SetterValue>> item)
|
|
{
|
|
return From(item.value->values)
|
|
.Where([=](Ptr<GuiValueRepr> value)
|
|
{
|
|
return resolvingResult.propertyResolvings.Keys().Contains(value.Obj());
|
|
})
|
|
.Select([=](Ptr<GuiValueRepr> value)
|
|
{
|
|
auto loader = resolvingResult.propertyResolvings[value.Obj()].loader;
|
|
return Pair<GlobalStringKey, IGuiInstanceLoader*>(item.key, loader);
|
|
});
|
|
})
|
|
.Distinct()
|
|
);
|
|
|
|
if (resolvingResult.context->instance.Obj() != repr)
|
|
{
|
|
List<GlobalStringKey> requiredProps;
|
|
{
|
|
auto currentLoader = loader;
|
|
while (currentLoader)
|
|
{
|
|
currentLoader->GetRequiredPropertyNames(resolvedTypeInfo, requiredProps);
|
|
currentLoader = GetInstanceLoaderManager()->GetParentLoader(currentLoader);
|
|
}
|
|
}
|
|
FOREACH(GlobalStringKey, prop, From(requiredProps).Distinct())
|
|
{
|
|
if (!properties.Keys().Contains(prop))
|
|
{
|
|
Ptr<GuiInstancePropertyInfo> info;
|
|
{
|
|
auto currentLoader = loader;
|
|
while (currentLoader && !info)
|
|
{
|
|
info = currentLoader->GetPropertyType({ resolvedTypeInfo, prop });
|
|
currentLoader = GetInstanceLoaderManager()->GetParentLoader(currentLoader);
|
|
}
|
|
}
|
|
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->tagPosition,
|
|
L"Precompile: Missing required " +
|
|
WString(info->usage == GuiInstancePropertyInfo::ConstructorArgument ? L"constructor argument" : L"required property") +
|
|
L" \"" +
|
|
prop.ToString() +
|
|
L"\" of type \"" +
|
|
resolvedTypeInfo.typeName.ToString() +
|
|
L"\"."));
|
|
}
|
|
}
|
|
}
|
|
|
|
while (properties.Count() > 0)
|
|
{
|
|
auto prop = properties.Keys()[0];
|
|
auto loader = properties.GetByIndex(0)[0];
|
|
IGuiInstanceLoader::PropertyInfo propertyInfo(resolvedTypeInfo, prop);
|
|
|
|
List<GlobalStringKey> pairProps;
|
|
loader->GetPairedProperties(propertyInfo, pairProps);
|
|
if (pairProps.Count() > 0)
|
|
{
|
|
List<GlobalStringKey> missingProps;
|
|
FOREACH(GlobalStringKey, key, pairProps)
|
|
{
|
|
if (!properties.Contains(key, loader))
|
|
{
|
|
missingProps.Add(key);
|
|
}
|
|
}
|
|
|
|
if (missingProps.Count() > 0)
|
|
{
|
|
WString error
|
|
= L"Precompile: When you assign to property \""
|
|
+ prop.ToString()
|
|
+ L"\" of type \""
|
|
+ resolvedTypeInfo.typeName.ToString()
|
|
+ L"\", the following missing properties are required: ";
|
|
FOREACH_INDEXER(GlobalStringKey, key, index, missingProps)
|
|
{
|
|
if (index > 0)error += L", ";
|
|
error += L"\"" + key.ToString() + L"\"";
|
|
}
|
|
error += L".";
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->setters[prop]->attPosition, error));
|
|
}
|
|
|
|
FOREACH(GlobalStringKey, key, pairProps)
|
|
{
|
|
properties.Remove(key, loader);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
properties.Remove(prop, loader);
|
|
}
|
|
}
|
|
|
|
FOREACH(Ptr<GuiAttSetterRepr::EventValue>, handler, repr->eventHandlers.Values())
|
|
{
|
|
if (handler->binding != GlobalStringKey::Empty)
|
|
{
|
|
auto binder = GetInstanceLoaderManager()->GetInstanceEventBinder(handler->binding);
|
|
if (!binder)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, handler->attPosition,
|
|
L"The appropriate IGuiInstanceEventBinder of binding \"-" +
|
|
handler->binding.ToString() +
|
|
L"\" cannot be found."));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void Visit(GuiConstructorRepr* repr)override
|
|
{
|
|
bool found = false;
|
|
|
|
bool inferType = repr->typeNamespace == GlobalStringKey::Empty && repr->typeName == GlobalStringKey::_InferType;
|
|
if (inferType)
|
|
{
|
|
if (candidatePropertyTypeInfos.Count() == 1)
|
|
{
|
|
auto info = candidatePropertyTypeInfos[0].info;
|
|
if (info->acceptableTypes.Count() == 1)
|
|
{
|
|
auto typeInfo = info->acceptableTypes[0];
|
|
resolvedTypeInfo.typeName = GlobalStringKey::Get(typeInfo->GetTypeDescriptor()->GetTypeName());
|
|
resolvedTypeInfo.typeInfo = typeInfo;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (repr == resolvingResult.context->instance.Obj())
|
|
{
|
|
auto fullName = GlobalStringKey::Get(resolvingResult.context->className);
|
|
if (auto typeInfo = GetInstanceLoaderManager()->GetTypeInfoForType(fullName))
|
|
{
|
|
resolvedTypeInfo.typeName = fullName;
|
|
resolvedTypeInfo.typeInfo = typeInfo;
|
|
found = true;
|
|
}
|
|
}
|
|
|
|
if (!found)
|
|
{
|
|
auto source = FindInstanceLoadingSource(resolvingResult.context, repr);
|
|
resolvedTypeInfo.typeName = source.typeName;
|
|
resolvedTypeInfo.typeInfo = GetInstanceLoaderManager()->GetTypeInfoForType(source.typeName);
|
|
}
|
|
}
|
|
|
|
if (resolvedTypeInfo.typeInfo)
|
|
{
|
|
for (vint i = 0; i < candidatePropertyTypeInfos.Count(); i++)
|
|
{
|
|
const auto& typeInfos = candidatePropertyTypeInfos[i].info->acceptableTypes;
|
|
for (vint j = 0; j < typeInfos.Count(); j++)
|
|
{
|
|
if (resolvedTypeInfo.typeInfo->GetTypeDescriptor()->CanConvertTo(typeInfos[j]->GetTypeDescriptor()))
|
|
{
|
|
selectedPropertyTypeInfo = i;
|
|
goto FINISH_MATCHING;
|
|
}
|
|
}
|
|
}
|
|
FINISH_MATCHING:
|
|
|
|
if (selectedPropertyTypeInfo == -1 && candidatePropertyTypeInfos.Count() > 0)
|
|
{
|
|
auto propertyInfo = candidatePropertyTypeInfos[0].propertyInfo;
|
|
auto error
|
|
= L"Precompile: Property \""
|
|
+ propertyInfo.propertyName.ToString()
|
|
+ L"\" of type \""
|
|
+ propertyInfo.typeInfo.typeName.ToString()
|
|
+ L"\" does not accept a value of type \""
|
|
+ resolvedTypeInfo.typeName.ToString()
|
|
+ L"\" because it only accepts value of the following types: ";
|
|
|
|
for (vint i = 0; i < candidatePropertyTypeInfos.Count(); i++)
|
|
{
|
|
const auto& typeInfos = candidatePropertyTypeInfos[i].info->acceptableTypes;
|
|
for (vint j = 0; j < typeInfos.Count(); j++)
|
|
{
|
|
if (i != 0 || j != 0)
|
|
{
|
|
error += L", ";
|
|
}
|
|
error += L"\"" + typeInfos[j]->GetTypeFriendlyName() + L"\"";
|
|
}
|
|
}
|
|
|
|
error += L".";
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->tagPosition, error));
|
|
}
|
|
else
|
|
{
|
|
if (repr->setters.Count() == 1 && repr->setters.Keys()[0] == GlobalStringKey::Empty)
|
|
{
|
|
auto setter = repr->setters.Values()[0];
|
|
if (setter->values.Count() == 1)
|
|
{
|
|
if (auto text = setter->values[0].Cast<GuiTextRepr>())
|
|
{
|
|
if (candidatePropertyTypeInfos.Count() == 0)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->tagPosition,
|
|
L"Precompile: Type \"" +
|
|
resolvedTypeInfo.typeName.ToString() +
|
|
L"\" cannot be used to create an instance."));
|
|
}
|
|
else
|
|
{
|
|
Visit(text.Obj());
|
|
auto index = resolvingResult.propertyResolvings.Keys().IndexOf(text.Obj());
|
|
if (index != -1)
|
|
{
|
|
auto value = resolvingResult.propertyResolvings.Values()[index];
|
|
resolvingResult.propertyResolvings.Remove(text.Obj());
|
|
resolvingResult.propertyResolvings.Add(repr, value);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (resolvingResult.context->instance.Obj() != repr)
|
|
{
|
|
auto loader = GetInstanceLoaderManager()->GetLoader(resolvedTypeInfo.typeName);
|
|
while (loader)
|
|
{
|
|
if (loader->CanCreate(resolvedTypeInfo))
|
|
{
|
|
break;
|
|
}
|
|
loader = GetInstanceLoaderManager()->GetParentLoader(loader);
|
|
}
|
|
if (loader)
|
|
{
|
|
if (repr == resolvingResult.context->instance.Obj())
|
|
{
|
|
List<GlobalStringKey> propertyNames;
|
|
loader->GetPropertyNames(resolvedTypeInfo, propertyNames);
|
|
for (vint i = propertyNames.Count() - 1; i >= 0; i--)
|
|
{
|
|
auto info = loader->GetPropertyType({ resolvedTypeInfo, propertyNames[i] });
|
|
if (!info || info->usage == GuiInstancePropertyInfo::Property)
|
|
{
|
|
propertyNames.RemoveAt(i);
|
|
}
|
|
}
|
|
|
|
if (propertyNames.Count() == 1)
|
|
{
|
|
if (propertyNames[0] != GlobalStringKey::_ControlTemplate)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->tagPosition,
|
|
L"Precompile: Type \"" +
|
|
resolvedTypeInfo.typeName.ToString() +
|
|
L"\" cannot be used to create a root instance, because its only constructor parameter is not for a the control template."));
|
|
}
|
|
}
|
|
else if (propertyNames.Count() > 1)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->tagPosition,
|
|
L"Precompile: Type \"" +
|
|
resolvedTypeInfo.typeName.ToString() +
|
|
L"\" cannot be used to create a root instance, because it has more than one constructor parameters. A root instance type can only have one constructor parameter, which is for the control template."));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->tagPosition,
|
|
L"Precompile: Type \"" +
|
|
resolvedTypeInfo.typeName.ToString() +
|
|
L"\" cannot be used to create an instance."));
|
|
}
|
|
}
|
|
Visit((GuiAttSetterRepr*)repr);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->tagPosition,
|
|
L"[INTERNAL-ERROR] Precompile: Failed to find type \"" +
|
|
(repr->typeNamespace == GlobalStringKey::Empty
|
|
? repr->typeName.ToString()
|
|
: repr->typeNamespace.ToString() + L":" + repr->typeName.ToString()
|
|
) +
|
|
L"\"."));
|
|
}
|
|
}
|
|
};
|
|
|
|
IGuiInstanceLoader::TypeInfo Workflow_CollectReferences(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GuiResourceError::List& errors)
|
|
{
|
|
FOREACH(Ptr<GuiInstanceParameter>, parameter, resolvingResult.context->parameters)
|
|
{
|
|
auto type = GetTypeDescriptor(parameter->className.ToString());
|
|
if (!type)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, parameter->classPosition,
|
|
L"Precompile: Cannot find type \"" +
|
|
parameter->className.ToString() +
|
|
L"\"."));
|
|
}
|
|
else if (resolvingResult.typeInfos.Keys().Contains(parameter->name))
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, parameter->classPosition,
|
|
L"[INTERNAL-ERROR] Precompile: Parameter \"" +
|
|
parameter->name.ToString() +
|
|
L"\" conflict with an existing named object."));
|
|
}
|
|
else
|
|
{
|
|
auto elementType = MakePtr<TypeDescriptorTypeInfo>(type, TypeInfoHint::Normal);
|
|
auto pointerType = MakePtr<SharedPtrTypeInfo>(elementType);
|
|
resolvingResult.typeInfos.Add(parameter->name, { GlobalStringKey::Get(type->GetTypeName()),pointerType });
|
|
}
|
|
}
|
|
|
|
List<types::PropertyResolving> infos;
|
|
vint generatedNameCount = 0;
|
|
WorkflowReferenceNamesVisitor visitor(precompileContext, resolvingResult, infos, generatedNameCount, errors);
|
|
resolvingResult.context->instance->Accept(&visitor);
|
|
return visitor.resolvedTypeInfo;
|
|
}
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWGENERATEBINDINGS.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
using namespace workflow;
|
|
using namespace collections;
|
|
using namespace reflection::description;
|
|
|
|
/***********************************************************************
|
|
WorkflowGenerateBindingVisitor
|
|
***********************************************************************/
|
|
|
|
class WorkflowGenerateBindingVisitor : public Object, public GuiValueRepr::IVisitor
|
|
{
|
|
public:
|
|
GuiResourcePrecompileContext& precompileContext;
|
|
types::ResolvingResult& resolvingResult;
|
|
Ptr<WfBlockStatement> statements;
|
|
GuiResourceError::List& errors;
|
|
|
|
WorkflowGenerateBindingVisitor(GuiResourcePrecompileContext& _precompileContext, types::ResolvingResult& _resolvingResult, Ptr<WfBlockStatement> _statements, GuiResourceError::List& _errors)
|
|
:precompileContext(_precompileContext)
|
|
, resolvingResult(_resolvingResult)
|
|
, errors(_errors)
|
|
, statements(_statements)
|
|
{
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
Ptr<WfStatement> ProcessPropertyBinding(
|
|
GuiAttSetterRepr* repr,
|
|
IGuiInstanceLoader::TypeInfo reprTypeInfo,
|
|
Ptr<GuiAttSetterRepr::SetterValue> setter,
|
|
GlobalStringKey propertyName
|
|
)
|
|
{
|
|
if (auto binder = GetInstanceLoaderManager()->GetInstanceBinder(setter->binding))
|
|
{
|
|
auto propertyResolving = resolvingResult.propertyResolvings[setter->values[0].Obj()];
|
|
if (propertyResolving.info->usage == GuiInstancePropertyInfo::Property)
|
|
{
|
|
WString expressionCode = setter->values[0].Cast<GuiTextRepr>()->text;
|
|
auto instancePropertyInfo = reprTypeInfo.typeInfo->GetTypeDescriptor()->GetPropertyByName(propertyName.ToString(), true);
|
|
|
|
if (instancePropertyInfo || !binder->RequirePropertyExist())
|
|
{
|
|
if (auto statement = binder->GenerateInstallStatement(
|
|
precompileContext,
|
|
resolvingResult,
|
|
repr->instanceName,
|
|
instancePropertyInfo,
|
|
propertyResolving.loader,
|
|
propertyResolving.propertyInfo,
|
|
propertyResolving.info,
|
|
expressionCode,
|
|
setter->values[0]->tagPosition,
|
|
errors))
|
|
{
|
|
return statement;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, setter->attPosition,
|
|
L"Precompile: Binder \"" +
|
|
setter->binding.ToString() +
|
|
L"\" requires property \"" +
|
|
propertyName.ToString() +
|
|
L"\" to physically appear in type \"" +
|
|
reprTypeInfo.typeName.ToString() +
|
|
L"\"."));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, setter->attPosition,
|
|
L"[INTERNAL ERROR] Precompile: The appropriate IGuiInstanceBinder of binding \"-" +
|
|
setter->binding.ToString() +
|
|
L"\" cannot be found."));
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
Ptr<WfStatement> ProcessEventBinding(
|
|
GuiAttSetterRepr* repr,
|
|
IGuiInstanceLoader::TypeInfo reprTypeInfo,
|
|
Ptr<GuiAttSetterRepr::EventValue> handler,
|
|
GlobalStringKey propertyName
|
|
)
|
|
{
|
|
auto td = reprTypeInfo.typeInfo->GetTypeDescriptor();
|
|
auto eventInfo = td->GetEventByName(propertyName.ToString(), true);
|
|
|
|
if (!eventInfo)
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, handler->attPosition,
|
|
L"[INTERNAL ERROR] Precompile: Event \"" +
|
|
propertyName.ToString() +
|
|
L"\" cannot be found in type \"" +
|
|
reprTypeInfo.typeName.ToString() +
|
|
L"\"."));
|
|
}
|
|
else
|
|
{
|
|
if (handler->binding == GlobalStringKey::Empty)
|
|
{
|
|
return Workflow_InstallEvent(precompileContext, resolvingResult, repr->instanceName, eventInfo, handler->value);
|
|
}
|
|
else
|
|
{
|
|
auto binder = GetInstanceLoaderManager()->GetInstanceEventBinder(handler->binding);
|
|
if (binder)
|
|
{
|
|
return binder->GenerateInstallStatement(precompileContext, resolvingResult, repr->instanceName, eventInfo, handler->value, handler->valuePosition, errors);
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, handler->attPosition,
|
|
L"[INTERNAL ERROR] The appropriate IGuiInstanceEventBinder of binding \"-" +
|
|
handler->binding.ToString() +
|
|
L"\" cannot be found."));
|
|
}
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void Visit(GuiTextRepr* repr)override
|
|
{
|
|
}
|
|
|
|
void Visit(GuiAttSetterRepr* repr)override
|
|
{
|
|
IGuiInstanceLoader::TypeInfo reprTypeInfo;
|
|
if (repr->instanceName != GlobalStringKey::Empty)
|
|
{
|
|
reprTypeInfo = resolvingResult.typeInfos[repr->instanceName];
|
|
}
|
|
|
|
if (reprTypeInfo.typeInfo && (reprTypeInfo.typeInfo->GetTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined)
|
|
{
|
|
WORKFLOW_ENVIRONMENT_VARIABLE_ADD
|
|
|
|
FOREACH_INDEXER(Ptr<GuiAttSetterRepr::SetterValue>, setter, index, repr->setters.Values())
|
|
{
|
|
auto propertyName = repr->setters.Keys()[index];
|
|
if (setter->binding != GlobalStringKey::Empty && setter->binding != GlobalStringKey::_Set)
|
|
{
|
|
if (auto statement = ProcessPropertyBinding(repr, reprTypeInfo, setter, propertyName))
|
|
{
|
|
Workflow_RecordScriptPosition(precompileContext, setter->values[0]->tagPosition, statement);
|
|
statements->statements.Add(statement);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
FOREACH(Ptr<GuiValueRepr>, value, setter->values)
|
|
{
|
|
value->Accept(this);
|
|
}
|
|
}
|
|
}
|
|
|
|
FOREACH_INDEXER(Ptr<GuiAttSetterRepr::EventValue>, handler, index, repr->eventHandlers.Values())
|
|
{
|
|
if (reprTypeInfo.typeInfo)
|
|
{
|
|
GlobalStringKey propertyName = repr->eventHandlers.Keys()[index];
|
|
if (auto statement = ProcessEventBinding(repr, reprTypeInfo, handler, propertyName))
|
|
{
|
|
Workflow_RecordScriptPosition(precompileContext, handler->valuePosition, statement);
|
|
statements->statements.Add(statement);
|
|
}
|
|
}
|
|
}
|
|
|
|
WORKFLOW_ENVIRONMENT_VARIABLE_REMOVE
|
|
}
|
|
}
|
|
|
|
void Visit(GuiConstructorRepr* repr)override
|
|
{
|
|
Visit((GuiAttSetterRepr*)repr);
|
|
}
|
|
};
|
|
|
|
void Workflow_GenerateBindings(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, Ptr<WfBlockStatement> statements, GuiResourceError::List& errors)
|
|
{
|
|
WorkflowGenerateBindingVisitor visitor(precompileContext, resolvingResult, statements, errors);
|
|
resolvingResult.context->instance->Accept(&visitor);
|
|
}
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWGENERATECREATING.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
using namespace collections;
|
|
using namespace parsing;
|
|
using namespace workflow;
|
|
using namespace workflow::analyzer;
|
|
using namespace reflection::description;
|
|
|
|
/***********************************************************************
|
|
WorkflowGenerateCreatingVisitor
|
|
***********************************************************************/
|
|
|
|
class WorkflowGenerateCreatingVisitor : public Object, public GuiValueRepr::IVisitor
|
|
{
|
|
public:
|
|
GuiResourcePrecompileContext& precompileContext;
|
|
types::ResolvingResult& resolvingResult;
|
|
Ptr<WfBlockStatement> statements;
|
|
GuiResourceError::List& errors;
|
|
|
|
WorkflowGenerateCreatingVisitor(GuiResourcePrecompileContext& _precompileContext, types::ResolvingResult& _resolvingResult, Ptr<WfBlockStatement> _statements, GuiResourceError::List& _errors)
|
|
:precompileContext(_precompileContext)
|
|
, resolvingResult(_resolvingResult)
|
|
, errors(_errors)
|
|
, statements(_statements)
|
|
{
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
IGuiInstanceLoader::ArgumentInfo GetArgumentInfo(GuiResourceTextPos attPosition, GuiValueRepr* repr)
|
|
{
|
|
Ptr<ITypeInfo> typeInfo = nullptr;
|
|
bool serializable = false;
|
|
WString textValue;
|
|
GuiResourceTextPos textValuePosition;
|
|
GuiConstructorRepr* ctor = nullptr;
|
|
|
|
if (auto text = dynamic_cast<GuiTextRepr*>(repr))
|
|
{
|
|
typeInfo = resolvingResult.propertyResolvings[repr].info->acceptableTypes[0];
|
|
serializable = true;
|
|
textValue = text->text;
|
|
textValuePosition = text->tagPosition;
|
|
}
|
|
else if ((ctor = dynamic_cast<GuiConstructorRepr*>(repr)))
|
|
{
|
|
if (ctor->instanceName == GlobalStringKey::Empty)
|
|
{
|
|
typeInfo = resolvingResult.propertyResolvings[repr].info->acceptableTypes[0];
|
|
}
|
|
else
|
|
{
|
|
typeInfo = resolvingResult.typeInfos[ctor->instanceName].typeInfo;
|
|
}
|
|
|
|
if ((typeInfo->GetTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::StructType) != TypeDescriptorFlags::Undefined)
|
|
{
|
|
serializable = true;
|
|
auto value = ctor->setters.Values()[0]->values[0].Cast<GuiTextRepr>();
|
|
textValue = value->text;
|
|
textValuePosition = value->tagPosition;
|
|
}
|
|
}
|
|
|
|
IGuiInstanceLoader::ArgumentInfo argumentInfo;
|
|
argumentInfo.typeInfo = typeInfo;
|
|
argumentInfo.attPosition = attPosition;
|
|
|
|
if (serializable)
|
|
{
|
|
if (auto deserializer = GetInstanceLoaderManager()->GetInstanceDeserializer(typeInfo.Obj()))
|
|
{
|
|
auto typeInfoAs = deserializer->DeserializeAs(typeInfo.Obj());
|
|
if (auto expression = Workflow_ParseTextValue(precompileContext, typeInfoAs->GetTypeDescriptor(), { resolvingResult.resource }, textValue, textValuePosition, errors))
|
|
{
|
|
argumentInfo.expression = deserializer->Deserialize(precompileContext, resolvingResult, typeInfo.Obj(), expression, textValuePosition, errors);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
argumentInfo.expression = Workflow_ParseTextValue(precompileContext, typeInfo->GetTypeDescriptor(), { resolvingResult.resource }, textValue, textValuePosition, errors);
|
|
}
|
|
argumentInfo.valuePosition = textValuePosition;
|
|
}
|
|
else
|
|
{
|
|
repr->Accept(this);
|
|
|
|
auto ref = MakePtr<WfReferenceExpression>();
|
|
ref->name.value = ctor->instanceName.ToString();
|
|
argumentInfo.expression = ref;
|
|
}
|
|
|
|
if (argumentInfo.expression)
|
|
{
|
|
Workflow_RecordScriptPosition(precompileContext, repr->tagPosition, argumentInfo.expression);
|
|
}
|
|
return argumentInfo;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
Ptr<WfStatement> ProcessPropertySet(
|
|
IGuiInstanceLoader::PropertyInfo propInfo,
|
|
GuiAttSetterRepr* repr,
|
|
Ptr<GuiAttSetterRepr::SetterValue> setter,
|
|
GuiAttSetterRepr* setTarget
|
|
)
|
|
{
|
|
auto info = resolvingResult.propertyResolvings[setTarget];
|
|
vint errorCount = errors.Count();
|
|
if (auto expr = info.loader->GetParameter(precompileContext, resolvingResult, propInfo, repr->instanceName, setter->attPosition, errors))
|
|
{
|
|
auto refInstance = MakePtr<WfReferenceExpression>();
|
|
refInstance->name.value = setTarget->instanceName.ToString();
|
|
|
|
auto assign = MakePtr<WfBinaryExpression>();
|
|
assign->op = WfBinaryOperator::Assign;
|
|
assign->first = refInstance;
|
|
assign->second = expr;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = assign;
|
|
|
|
return stat;
|
|
}
|
|
else if (errorCount == errors.Count())
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, setTarget->tagPosition,
|
|
L"[INTERNAL ERROR] Precompile: Something is wrong when retriving the property \"" +
|
|
propInfo.propertyName.ToString() +
|
|
L"\" from an instance of type \"" +
|
|
propInfo.typeInfo.typeName.ToString() +
|
|
L"\"."));
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
Ptr<WfStatement> ProcessPropertyCollection(
|
|
IGuiInstanceLoader::PropertyInfo propInfo,
|
|
GuiAttSetterRepr* repr,
|
|
Group<GlobalStringKey, IGuiInstanceLoader*>& usedProps,
|
|
Ptr<GuiAttSetterRepr::SetterValue> setter,
|
|
types::PropertyResolving info,
|
|
Ptr<GuiValueRepr> value
|
|
)
|
|
{
|
|
if (!usedProps.Contains(propInfo.propertyName, info.loader))
|
|
{
|
|
usedProps.Add(propInfo.propertyName, info.loader);
|
|
}
|
|
|
|
vint errorCount = errors.Count();
|
|
IGuiInstanceLoader::ArgumentMap arguments;
|
|
arguments.Add(propInfo.propertyName, GetArgumentInfo(setter->attPosition, value.Obj()));
|
|
if (auto stat = info.loader->AssignParameters(precompileContext, resolvingResult, propInfo.typeInfo, repr->instanceName, arguments, setter->attPosition, errors))
|
|
{
|
|
return stat;
|
|
}
|
|
else if (errorCount == errors.Count())
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, value->tagPosition,
|
|
L"[INTERNAL ERROR] Precompile: Something is wrong when assigning to property " +
|
|
propInfo.propertyName.ToString() +
|
|
L" to an instance of type \"" +
|
|
propInfo.typeInfo.typeName.ToString() +
|
|
L"\"."));
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
Ptr<WfStatement> ProcessPropertyOthers(
|
|
IGuiInstanceLoader::PropertyInfo propInfo,
|
|
GuiAttSetterRepr* repr,
|
|
Group<GlobalStringKey, IGuiInstanceLoader*>& usedProps,
|
|
Ptr<GuiAttSetterRepr::SetterValue> setter,
|
|
types::PropertyResolving info,
|
|
Ptr<GuiValueRepr> value
|
|
)
|
|
{
|
|
List<GlobalStringKey> pairedProps;
|
|
info.loader->GetPairedProperties(propInfo, pairedProps);
|
|
if (pairedProps.Count() == 0)
|
|
{
|
|
pairedProps.Add(propInfo.propertyName);
|
|
}
|
|
|
|
vint errorCount = errors.Count();
|
|
IGuiInstanceLoader::ArgumentMap arguments;
|
|
FOREACH(GlobalStringKey, pairedProp, pairedProps)
|
|
{
|
|
usedProps.Add(pairedProp, info.loader);
|
|
auto pairedSetter = repr->setters[pairedProp];
|
|
FOREACH(Ptr<GuiValueRepr>, pairedValue, pairedSetter->values)
|
|
{
|
|
auto pairedInfo = resolvingResult.propertyResolvings[pairedValue.Obj()];
|
|
if (pairedInfo.loader == info.loader)
|
|
{
|
|
arguments.Add(pairedProp, GetArgumentInfo(pairedSetter->attPosition, pairedValue.Obj()));
|
|
}
|
|
}
|
|
}
|
|
|
|
if (auto stat = info.loader->AssignParameters(precompileContext, resolvingResult, propInfo.typeInfo, repr->instanceName, arguments, setter->attPosition, errors))
|
|
{
|
|
return stat;
|
|
}
|
|
else if (errorCount == errors.Count())
|
|
{
|
|
WString propNames;
|
|
FOREACH_INDEXER(GlobalStringKey, pairedProp, propIndex, pairedProps)
|
|
{
|
|
if (propIndex > 0)propNames += L", ";
|
|
propNames += L"\"" + pairedProp.ToString() + L"\"";
|
|
}
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, value->tagPosition,
|
|
L"[INTERNAL ERROR] Precompile: Something is wrong when assigning to properties " +
|
|
propNames +
|
|
L" to an instance of type \"" +
|
|
propInfo.typeInfo.typeName.ToString() +
|
|
L"\"."));
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void Visit(GuiTextRepr* repr)override
|
|
{
|
|
}
|
|
|
|
void Visit(GuiAttSetterRepr* repr)override
|
|
{
|
|
auto reprTypeInfo = resolvingResult.typeInfos[repr->instanceName];
|
|
|
|
if (reprTypeInfo.typeInfo && (reprTypeInfo.typeInfo->GetTypeDescriptor()->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined)
|
|
{
|
|
WORKFLOW_ENVIRONMENT_VARIABLE_ADD
|
|
|
|
Group<GlobalStringKey, IGuiInstanceLoader*> usedProps;
|
|
FOREACH(GlobalStringKey, prop, From(repr->setters.Keys()).Reverse())
|
|
{
|
|
auto setter = repr->setters[prop];
|
|
IGuiInstanceLoader::PropertyInfo propInfo(reprTypeInfo, prop);
|
|
if (setter->binding == GlobalStringKey::_Set)
|
|
{
|
|
auto setTarget = dynamic_cast<GuiAttSetterRepr*>(setter->values[0].Obj());
|
|
if (auto statement = ProcessPropertySet(propInfo, repr, setter, setTarget))
|
|
{
|
|
Workflow_RecordScriptPosition(precompileContext, setTarget->tagPosition, statement);
|
|
statements->statements.Add(statement);
|
|
}
|
|
setTarget->Accept(this);
|
|
}
|
|
else if (setter->binding == GlobalStringKey::Empty)
|
|
{
|
|
FOREACH(Ptr<GuiValueRepr>, value, setter->values)
|
|
{
|
|
auto info = resolvingResult.propertyResolvings[value.Obj()];
|
|
if (info.info->usage == GuiInstancePropertyInfo::Property)
|
|
{
|
|
if (info.info->support == GuiInstancePropertyInfo::SupportCollection)
|
|
{
|
|
if (auto statement = ProcessPropertyCollection(propInfo, repr, usedProps, setter, info, value))
|
|
{
|
|
Workflow_RecordScriptPosition(precompileContext, value->tagPosition, statement);
|
|
statements->statements.Add(statement);
|
|
}
|
|
}
|
|
else if (!usedProps.Contains(prop, info.loader))
|
|
{
|
|
if (auto statement = ProcessPropertyOthers(propInfo, repr, usedProps, setter, info, value))
|
|
{
|
|
Workflow_RecordScriptPosition(precompileContext, value->tagPosition, statement);
|
|
statements->statements.Add(statement);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
WORKFLOW_ENVIRONMENT_VARIABLE_REMOVE
|
|
}
|
|
}
|
|
|
|
void FillCtorArguments(GuiConstructorRepr* repr, IGuiInstanceLoader* loader, const IGuiInstanceLoader::TypeInfo& typeInfo, IGuiInstanceLoader::ArgumentMap& arguments)
|
|
{
|
|
List<GlobalStringKey> ctorProps;
|
|
loader->GetPropertyNames(typeInfo, ctorProps);
|
|
|
|
WORKFLOW_ENVIRONMENT_VARIABLE_ADD
|
|
|
|
FOREACH(GlobalStringKey, prop, ctorProps)
|
|
{
|
|
auto propInfo = loader->GetPropertyType({ typeInfo,prop });
|
|
if (propInfo->usage != GuiInstancePropertyInfo::ConstructorArgument) continue;
|
|
|
|
auto index = repr->setters.Keys().IndexOf(prop);
|
|
if (index == -1) continue;
|
|
|
|
auto setter = repr->setters.Values()[index];
|
|
if (setter->binding == GlobalStringKey::Empty)
|
|
{
|
|
FOREACH(Ptr<GuiValueRepr>, value, setter->values)
|
|
{
|
|
auto argument = GetArgumentInfo(setter->attPosition, value.Obj());
|
|
if (argument.typeInfo && argument.expression)
|
|
{
|
|
arguments.Add(prop, argument);
|
|
}
|
|
}
|
|
}
|
|
else if (auto binder = GetInstanceLoaderManager()->GetInstanceBinder(setter->binding))
|
|
{
|
|
auto propInfo = IGuiInstanceLoader::PropertyInfo(typeInfo, prop);
|
|
auto resolvedPropInfo = loader->GetPropertyType(propInfo);
|
|
auto value = setter->values[0].Cast<GuiTextRepr>();
|
|
if (auto expression = binder->GenerateConstructorArgument(precompileContext, resolvingResult, loader, propInfo, resolvedPropInfo, value->text, value->tagPosition, errors))
|
|
{
|
|
Workflow_RecordScriptPosition(precompileContext, value->tagPosition, expression);
|
|
|
|
IGuiInstanceLoader::ArgumentInfo argument;
|
|
argument.expression = expression;
|
|
argument.typeInfo = resolvedPropInfo->acceptableTypes[0];
|
|
argument.attPosition = setter->attPosition;
|
|
arguments.Add(prop, argument);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, setter->attPosition,
|
|
L"[INTERNAL ERROR] Precompile: The appropriate IGuiInstanceBinder of binding \"-" +
|
|
setter->binding.ToString() +
|
|
L"\" cannot be found."));
|
|
}
|
|
}
|
|
|
|
WORKFLOW_ENVIRONMENT_VARIABLE_REMOVE
|
|
}
|
|
|
|
void Visit(GuiConstructorRepr* repr)override
|
|
{
|
|
IGuiInstanceLoader::TypeInfo ctorTypeInfo;
|
|
if (resolvingResult.context->instance.Obj() == repr)
|
|
{
|
|
auto source = FindInstanceLoadingSource(resolvingResult.context, repr);
|
|
ctorTypeInfo.typeName = source.typeName;
|
|
|
|
auto typeInfo = GetInstanceLoaderManager()->GetTypeInfoForType(source.typeName);
|
|
ctorTypeInfo.typeInfo = typeInfo;
|
|
}
|
|
else
|
|
{
|
|
ctorTypeInfo = resolvingResult.typeInfos[repr->instanceName];
|
|
}
|
|
|
|
auto ctorLoader = GetInstanceLoaderManager()->GetLoader(ctorTypeInfo.typeName);
|
|
while (ctorLoader)
|
|
{
|
|
if (ctorLoader->CanCreate(ctorTypeInfo))
|
|
{
|
|
break;
|
|
}
|
|
ctorLoader = GetInstanceLoaderManager()->GetParentLoader(ctorLoader);
|
|
}
|
|
|
|
if (resolvingResult.context->instance.Obj() == repr)
|
|
{
|
|
resolvingResult.rootLoader = ctorLoader;
|
|
FillCtorArguments(repr, ctorLoader, ctorTypeInfo, resolvingResult.rootCtorArguments);
|
|
|
|
{
|
|
auto refInstance = MakePtr<WfReferenceExpression>();
|
|
refInstance->name.value = repr->instanceName.ToString();
|
|
|
|
auto refThis = MakePtr<WfReferenceExpression>();
|
|
refThis->name.value = L"<this>";
|
|
|
|
auto assign = MakePtr<WfBinaryExpression>();
|
|
assign->op = WfBinaryOperator::Assign;
|
|
assign->first = refInstance;
|
|
assign->second = refThis;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = assign;
|
|
|
|
statements->statements.Add(stat);
|
|
}
|
|
|
|
if (resolvingResult.rootCtorArguments.Count() > 0)
|
|
{
|
|
if (auto stat = ctorLoader->InitializeRootInstance(precompileContext, resolvingResult, ctorTypeInfo, repr->instanceName, resolvingResult.rootCtorArguments, errors))
|
|
{
|
|
Workflow_RecordScriptPosition(precompileContext, resolvingResult.context->tagPosition, stat);
|
|
statements->statements.Add(stat);
|
|
}
|
|
}
|
|
|
|
FOREACH(Ptr<GuiInstanceParameter>, parameter, resolvingResult.context->parameters)
|
|
{
|
|
auto refInstance = MakePtr<WfReferenceExpression>();
|
|
refInstance->name.value = parameter->name.ToString();
|
|
|
|
auto refThis = MakePtr<WfReferenceExpression>();
|
|
refThis->name.value = L"<this>";
|
|
|
|
auto refParameter = MakePtr<WfMemberExpression>();
|
|
refParameter->parent = refThis;
|
|
refParameter->name.value = parameter->name.ToString();
|
|
|
|
auto assign = MakePtr<WfBinaryExpression>();
|
|
assign->op = WfBinaryOperator::Assign;
|
|
assign->first = refInstance;
|
|
assign->second = refParameter;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = assign;
|
|
|
|
statements->statements.Add(stat);
|
|
Workflow_RecordScriptPosition(precompileContext, parameter->tagPosition, (Ptr<WfStatement>)stat);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
IGuiInstanceLoader::ArgumentMap arguments;
|
|
FillCtorArguments(repr, ctorLoader, ctorTypeInfo, arguments);
|
|
|
|
vint errorCount = errors.Count();
|
|
if (auto ctorStats = ctorLoader->CreateInstance(precompileContext, resolvingResult, ctorTypeInfo, repr->instanceName, arguments, repr->tagPosition, errors))
|
|
{
|
|
Workflow_RecordScriptPosition(precompileContext, resolvingResult.context->tagPosition, ctorStats);
|
|
statements->statements.Add(ctorStats);
|
|
}
|
|
else if (errorCount == errors.Count())
|
|
{
|
|
errors.Add(GuiResourceError({ resolvingResult.resource }, repr->tagPosition,
|
|
L"[INTERNAL ERROR] Precompile: Something is wrong when creating an instance of type \"" +
|
|
ctorTypeInfo.typeName.ToString() +
|
|
L"\"."));
|
|
}
|
|
}
|
|
Visit((GuiAttSetterRepr*)repr);
|
|
}
|
|
};
|
|
|
|
void Workflow_GenerateCreating(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, Ptr<WfBlockStatement> statements, GuiResourceError::List& errors)
|
|
{
|
|
WorkflowGenerateCreatingVisitor visitor(precompileContext, resolvingResult, statements, errors);
|
|
resolvingResult.context->instance->Accept(&visitor);
|
|
}
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWINSTALLBINDINGS.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
using namespace workflow;
|
|
using namespace workflow::analyzer;
|
|
using namespace reflection::description;
|
|
using namespace collections;
|
|
|
|
using namespace controls;
|
|
using namespace compositions;
|
|
|
|
/***********************************************************************
|
|
Workflow_InstallBindProperty
|
|
***********************************************************************/
|
|
|
|
Ptr<workflow::WfStatement> Workflow_InstallUriProperty(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GlobalStringKey variableName, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, const WString& protocol, const WString& path, GuiResourceTextPos attPosition, GuiResourceError::List& errors)
|
|
{
|
|
auto subBlock = MakePtr<WfBlockStatement>();
|
|
{
|
|
auto refResolver = MakePtr<WfReferenceExpression>();
|
|
refResolver->name.value = L"<resolver>";
|
|
|
|
auto member = MakePtr<WfMemberExpression>();
|
|
member->parent = refResolver;
|
|
member->name.value = L"ResolveResource";
|
|
|
|
auto valueProtocol = MakePtr<WfStringExpression>();
|
|
valueProtocol->value.value = protocol;
|
|
|
|
auto valuePath = MakePtr<WfStringExpression>();
|
|
valuePath->value.value = path;
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = member;
|
|
call->arguments.Add(valueProtocol);
|
|
call->arguments.Add(valuePath);
|
|
|
|
auto varDesc = MakePtr<WfVariableDeclaration>();
|
|
varDesc->name.value = L"<resource-item>";
|
|
varDesc->expression = call;
|
|
|
|
auto varStat = MakePtr<WfVariableStatement>();
|
|
varStat->variable = varDesc;
|
|
subBlock->statements.Add(varStat);
|
|
}
|
|
{
|
|
auto refResourceItem = MakePtr<WfReferenceExpression>();
|
|
refResourceItem->name.value = L"<resource-item>";
|
|
|
|
auto isNull = MakePtr<WfTypeTestingExpression>();
|
|
isNull->expression = refResourceItem;
|
|
isNull->test = WfTypeTesting::IsNull;
|
|
|
|
auto valueException = MakePtr<WfStringExpression>();
|
|
valueException->value.value = L"Resource \"" + protocol + L"://" + path + L"\" does not exist.";
|
|
|
|
auto raiseStat = MakePtr<WfRaiseExceptionStatement>();
|
|
raiseStat->expression = valueException;
|
|
|
|
auto ifBlock = MakePtr<WfBlockStatement>();
|
|
ifBlock->statements.Add(raiseStat);
|
|
|
|
auto ifStat = MakePtr<WfIfStatement>();
|
|
ifStat->expression = isNull;
|
|
ifStat->trueBranch = ifBlock;
|
|
subBlock->statements.Add(ifStat);
|
|
}
|
|
|
|
auto td = propInfo->acceptableTypes[0]->GetTypeDescriptor();
|
|
Ptr<ITypeInfo> convertedType;
|
|
if (td->GetSerializableType())
|
|
{
|
|
convertedType = TypeInfoRetriver<Ptr<GuiTextData>>::CreateTypeInfo();
|
|
}
|
|
else if (td == description::GetTypeDescriptor<INativeImage>() || td == description::GetTypeDescriptor<GuiImageData>())
|
|
{
|
|
convertedType = TypeInfoRetriver<Ptr<GuiImageData>>::CreateTypeInfo();
|
|
}
|
|
else
|
|
{
|
|
auto elementType = MakePtr<TypeDescriptorTypeInfo>(td, TypeInfoHint::Normal);
|
|
auto pointerType = MakePtr<SharedPtrTypeInfo>(elementType);
|
|
convertedType = pointerType;
|
|
}
|
|
|
|
{
|
|
auto refResourceItem = MakePtr<WfReferenceExpression>();
|
|
refResourceItem->name.value = L"<resource-item>";
|
|
|
|
auto cast = MakePtr<WfTypeCastingExpression>();
|
|
cast->expression = refResourceItem;
|
|
cast->type = GetTypeFromTypeInfo(convertedType.Obj());
|
|
cast->strategy = WfTypeCastingStrategy::Weak;
|
|
|
|
auto varDesc = MakePtr<WfVariableDeclaration>();
|
|
varDesc->name.value = L"<resource-value>";
|
|
varDesc->expression = cast;
|
|
|
|
auto varStat = MakePtr<WfVariableStatement>();
|
|
varStat->variable = varDesc;
|
|
subBlock->statements.Add(varStat);
|
|
}
|
|
{
|
|
auto refResourceValue = MakePtr<WfReferenceExpression>();
|
|
refResourceValue->name.value = L"<resource-value>";
|
|
|
|
auto isNull = MakePtr<WfTypeTestingExpression>();
|
|
isNull->expression = refResourceValue;
|
|
isNull->test = WfTypeTesting::IsNull;
|
|
|
|
auto valueException = MakePtr<WfStringExpression>();
|
|
valueException->value.value = L"Resource \"" + protocol + L"://" + path + L"\" cannot be read as type \"" + convertedType->GetTypeFriendlyName() + L"\".";
|
|
|
|
auto raiseStat = MakePtr<WfRaiseExceptionStatement>();
|
|
raiseStat->expression = valueException;
|
|
|
|
auto ifBlock = MakePtr<WfBlockStatement>();
|
|
ifBlock->statements.Add(raiseStat);
|
|
|
|
auto ifStat = MakePtr<WfIfStatement>();
|
|
ifStat->expression = isNull;
|
|
ifStat->trueBranch = ifBlock;
|
|
subBlock->statements.Add(ifStat);
|
|
}
|
|
|
|
Ptr<WfExpression> evalExpression;
|
|
if (td->GetSerializableType())
|
|
{
|
|
auto refResourceValue = MakePtr<WfReferenceExpression>();
|
|
refResourceValue->name.value = L"<resource-value>";
|
|
|
|
auto member = MakePtr<WfMemberExpression>();
|
|
member->parent = refResourceValue;
|
|
member->name.value = L"Text";
|
|
|
|
auto elementType = MakePtr<TypeDescriptorTypeInfo>(td, TypeInfoHint::Normal);
|
|
|
|
auto cast = MakePtr<WfTypeCastingExpression>();
|
|
cast->expression = member;
|
|
cast->type = GetTypeFromTypeInfo(elementType.Obj());
|
|
cast->strategy = WfTypeCastingStrategy::Strong;
|
|
|
|
evalExpression = cast;
|
|
}
|
|
else if (td == description::GetTypeDescriptor<INativeImage>())
|
|
{
|
|
auto refResourceValue = MakePtr<WfReferenceExpression>();
|
|
refResourceValue->name.value = L"<resource-value>";
|
|
|
|
auto member = MakePtr<WfMemberExpression>();
|
|
member->parent = refResourceValue;
|
|
member->name.value = L"Image";
|
|
|
|
evalExpression = member;
|
|
}
|
|
else
|
|
{
|
|
auto refResourceValue = MakePtr<WfReferenceExpression>();
|
|
refResourceValue->name.value = L"<resource-value>";
|
|
|
|
evalExpression = refResourceValue;
|
|
}
|
|
|
|
{
|
|
IGuiInstanceLoader::ArgumentMap arguments;
|
|
{
|
|
IGuiInstanceLoader::ArgumentInfo argumentInfo;
|
|
argumentInfo.typeInfo = propInfo->acceptableTypes[0];
|
|
argumentInfo.expression = evalExpression;
|
|
argumentInfo.attPosition = attPosition;
|
|
arguments.Add(prop.propertyName, argumentInfo);
|
|
}
|
|
|
|
if (auto stat = loader->AssignParameters(precompileContext, resolvingResult, prop.typeInfo, variableName, arguments, attPosition, errors))
|
|
{
|
|
subBlock->statements.Add(stat);
|
|
}
|
|
}
|
|
return subBlock;
|
|
}
|
|
|
|
/***********************************************************************
|
|
Workflow_InstallBindProperty
|
|
***********************************************************************/
|
|
|
|
Ptr<workflow::WfStatement> Workflow_InstallBindProperty(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GlobalStringKey variableName, description::IPropertyInfo* propertyInfo, Ptr<workflow::WfExpression> bindExpression)
|
|
{
|
|
auto subBlock = MakePtr<WfBlockStatement>();
|
|
{
|
|
auto refThis = MakePtr<WfReferenceExpression>();
|
|
refThis->name.value = L"<this>";
|
|
|
|
auto member = MakePtr<WfMemberExpression>();
|
|
member->parent = refThis;
|
|
member->name.value = L"AddSubscription";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = member;
|
|
call->arguments.Add(bindExpression);
|
|
|
|
auto var = MakePtr<WfVariableDeclaration>();
|
|
var->name.value = L"<created-subscription>";
|
|
var->expression = call;
|
|
|
|
auto stat = MakePtr<WfVariableStatement>();
|
|
stat->variable = var;
|
|
subBlock->statements.Add(stat);
|
|
}
|
|
{
|
|
auto callback = MakePtr<WfFunctionDeclaration>();
|
|
callback->anonymity = WfFunctionAnonymity::Anonymous;
|
|
callback->returnType = GetTypeFromTypeInfo(TypeInfoRetriver<void>::CreateTypeInfo().Obj());;
|
|
{
|
|
auto arg = MakePtr<WfFunctionArgument>();
|
|
arg->name.value = L"<value>";
|
|
arg->type = GetTypeFromTypeInfo(TypeInfoRetriver<Value>::CreateTypeInfo().Obj());
|
|
callback->arguments.Add(arg);
|
|
}
|
|
auto callbackBlock = MakePtr<WfBlockStatement>();
|
|
callback->statement = callbackBlock;
|
|
{
|
|
auto refSubscribee = MakePtr<WfReferenceExpression>();
|
|
refSubscribee->name.value = variableName.ToString();
|
|
|
|
auto member = MakePtr<WfMemberExpression>();
|
|
member->parent = refSubscribee;
|
|
member->name.value = propertyInfo->GetName();
|
|
|
|
auto var = MakePtr<WfVariableDeclaration>();
|
|
var->name.value = L"<old>";
|
|
var->expression = member;
|
|
|
|
auto stat = MakePtr<WfVariableStatement>();
|
|
stat->variable = var;
|
|
callbackBlock->statements.Add(stat);
|
|
}
|
|
{
|
|
ITypeInfo* propertyType = propertyInfo->GetReturn();
|
|
if (propertyInfo->GetSetter() && propertyInfo->GetSetter()->GetParameterCount() == 1)
|
|
{
|
|
propertyType = propertyInfo->GetSetter()->GetParameter(0)->GetType();
|
|
}
|
|
|
|
auto refValue = MakePtr<WfReferenceExpression>();
|
|
refValue->name.value = L"<value>";
|
|
|
|
auto cast = MakePtr<WfTypeCastingExpression>();
|
|
cast->strategy = WfTypeCastingStrategy::Strong;
|
|
cast->expression = refValue;
|
|
cast->type = GetTypeFromTypeInfo(propertyType);
|
|
|
|
auto var = MakePtr<WfVariableDeclaration>();
|
|
var->name.value = L"<new>";
|
|
var->expression = cast;
|
|
|
|
auto stat = MakePtr<WfVariableStatement>();
|
|
stat->variable = var;
|
|
callbackBlock->statements.Add(stat);
|
|
}
|
|
{
|
|
auto refOld = MakePtr<WfReferenceExpression>();
|
|
refOld->name.value = L"<old>";
|
|
|
|
auto refNew = MakePtr<WfReferenceExpression>();
|
|
refNew->name.value = L"<new>";
|
|
|
|
auto compare = MakePtr<WfBinaryExpression>();
|
|
compare->op = WfBinaryOperator::EQ;
|
|
compare->first = refOld;
|
|
compare->second = refNew;
|
|
|
|
auto ifStat = MakePtr<WfIfStatement>();
|
|
ifStat->expression = compare;
|
|
callbackBlock->statements.Add(ifStat);
|
|
|
|
auto ifBlock = MakePtr<WfBlockStatement>();
|
|
ifStat->trueBranch = ifBlock;
|
|
|
|
auto returnStat = MakePtr<WfReturnStatement>();
|
|
ifBlock->statements.Add(returnStat);
|
|
}
|
|
{
|
|
auto refSubscribee = MakePtr<WfReferenceExpression>();
|
|
refSubscribee->name.value = variableName.ToString();
|
|
|
|
auto member = MakePtr<WfMemberExpression>();
|
|
member->parent = refSubscribee;
|
|
member->name.value = propertyInfo->GetName();
|
|
|
|
auto refNew = MakePtr<WfReferenceExpression>();
|
|
refNew->name.value = L"<new>";
|
|
|
|
auto assign = MakePtr<WfBinaryExpression>();
|
|
assign->op = WfBinaryOperator::Assign;
|
|
assign->first = member;
|
|
assign->second = refNew;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = assign;
|
|
callbackBlock->statements.Add(stat);
|
|
}
|
|
|
|
auto funcExpr = MakePtr<WfFunctionExpression>();
|
|
funcExpr->function = callback;
|
|
|
|
auto refThis = MakePtr<WfReferenceExpression>();
|
|
refThis->name.value = L"<created-subscription>";
|
|
|
|
auto member = MakePtr<WfMemberExpression>();
|
|
member->parent = refThis;
|
|
member->name.value = L"Subscribe";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = member;
|
|
call->arguments.Add(funcExpr);
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
subBlock->statements.Add(stat);
|
|
}
|
|
{
|
|
auto refThis = MakePtr<WfReferenceExpression>();
|
|
refThis->name.value = L"<created-subscription>";
|
|
|
|
auto member = MakePtr<WfMemberExpression>();
|
|
member->parent = refThis;
|
|
member->name.value = L"Update";
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = member;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = call;
|
|
subBlock->statements.Add(stat);
|
|
}
|
|
|
|
return subBlock;
|
|
}
|
|
|
|
/***********************************************************************
|
|
Workflow_InstallEvalProperty
|
|
***********************************************************************/
|
|
|
|
Ptr<workflow::WfStatement> Workflow_InstallEvalProperty(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GlobalStringKey variableName, IGuiInstanceLoader* loader, const IGuiInstanceLoader::PropertyInfo& prop, Ptr<GuiInstancePropertyInfo> propInfo, Ptr<workflow::WfExpression> evalExpression, GuiResourceTextPos attPosition, GuiResourceError::List& errors)
|
|
{
|
|
IGuiInstanceLoader::ArgumentMap arguments;
|
|
{
|
|
IGuiInstanceLoader::ArgumentInfo argumentInfo;
|
|
argumentInfo.typeInfo = propInfo->acceptableTypes[0];
|
|
argumentInfo.expression = evalExpression;
|
|
argumentInfo.attPosition = attPosition;
|
|
arguments.Add(prop.propertyName, argumentInfo);
|
|
}
|
|
|
|
return loader->AssignParameters(precompileContext, resolvingResult, prop.typeInfo, variableName, arguments, attPosition, errors);
|
|
}
|
|
|
|
/***********************************************************************
|
|
Workflow_InstallEvent
|
|
***********************************************************************/
|
|
|
|
Ptr<workflow::WfStatement> Workflow_InstallEvent(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GlobalStringKey variableName, description::IEventInfo* eventInfo, const WString& handlerName)
|
|
{
|
|
vint count = eventInfo->GetHandlerType()->GetElementType()->GetGenericArgumentCount() - 1;
|
|
|
|
auto subBlock = MakePtr<WfBlockStatement>();
|
|
{
|
|
auto var = MakePtr<WfReferenceExpression>();
|
|
var->name.value = variableName.ToString();
|
|
|
|
auto member = MakePtr<WfMemberExpression>();
|
|
member->parent = var;
|
|
member->name.value = eventInfo->GetName();
|
|
|
|
auto refThis = MakePtr<WfReferenceExpression>();
|
|
refThis->name.value = L"<this>";
|
|
|
|
auto handler = MakePtr<WfMemberExpression>();
|
|
handler->parent = refThis;
|
|
handler->name.value = handlerName;
|
|
|
|
auto call = MakePtr<WfCallExpression>();
|
|
call->function = handler;
|
|
for (vint i = 0; i < count; i++)
|
|
{
|
|
auto argument = MakePtr<WfOrderedNameExpression>();
|
|
argument->name.value = L"$" + itow(i + 1);
|
|
call->arguments.Add(argument);
|
|
}
|
|
|
|
auto eventHandler = MakePtr<WfOrderedLambdaExpression>();
|
|
eventHandler->body = call;
|
|
|
|
auto attachEvent = MakePtr<WfAttachEventExpression>();
|
|
attachEvent->event = member;
|
|
attachEvent->function = eventHandler;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = attachEvent;
|
|
subBlock->statements.Add(stat);
|
|
}
|
|
|
|
return subBlock;
|
|
}
|
|
|
|
/***********************************************************************
|
|
Workflow_GenerateEventHandler
|
|
***********************************************************************/
|
|
|
|
Ptr<workflow::WfFunctionDeclaration> Workflow_GenerateEventHandler(GuiResourcePrecompileContext& precompileContext, description::IEventInfo* eventInfo)
|
|
{
|
|
auto func = MakePtr<WfFunctionDeclaration>();
|
|
func->anonymity = WfFunctionAnonymity::Anonymous;
|
|
func->returnType = GetTypeFromTypeInfo(TypeInfoRetriver<void>::CreateTypeInfo().Obj());
|
|
|
|
vint count = eventInfo->GetHandlerType()->GetElementType()->GetGenericArgumentCount() - 1;
|
|
bool standardName = false;
|
|
if (count == 2)
|
|
{
|
|
auto senderType = eventInfo->GetHandlerType()->GetElementType()->GetGenericArgument(1)->GetTypeDescriptor();
|
|
auto argumentType = eventInfo->GetHandlerType()->GetElementType()->GetGenericArgument(2)->GetTypeDescriptor();
|
|
if (senderType == GetTypeDescriptor<GuiGraphicsComposition>())
|
|
{
|
|
auto expectedType = GetTypeDescriptor<GuiEventArgs>();
|
|
List<ITypeDescriptor*> types;
|
|
types.Add(argumentType);
|
|
for (vint i = 0; i < types.Count(); i++)
|
|
{
|
|
auto type = types[i];
|
|
if (type == expectedType)
|
|
{
|
|
standardName = true;
|
|
break;
|
|
}
|
|
vint baseCount = type->GetBaseTypeDescriptorCount();
|
|
for (vint j = 0; j < baseCount; j++)
|
|
{
|
|
auto baseType = type->GetBaseTypeDescriptor(j);
|
|
if (!types.Contains(baseType))
|
|
{
|
|
types.Add(baseType);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (standardName)
|
|
{
|
|
{
|
|
auto arg = MakePtr<WfFunctionArgument>();
|
|
arg->name.value = L"sender";
|
|
arg->type = GetTypeFromTypeInfo(eventInfo->GetHandlerType()->GetElementType()->GetGenericArgument(1));
|
|
func->arguments.Add(arg);
|
|
}
|
|
{
|
|
auto arg = MakePtr<WfFunctionArgument>();
|
|
arg->name.value = L"arguments";
|
|
arg->type = GetTypeFromTypeInfo(eventInfo->GetHandlerType()->GetElementType()->GetGenericArgument(2));
|
|
func->arguments.Add(arg);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
auto type = TypeInfoRetriver<Value>::CreateTypeInfo();
|
|
for (vint i = 0; i < count; i++)
|
|
{
|
|
auto arg = MakePtr<WfFunctionArgument>();
|
|
arg->name.value = L"arg" + itow(i + 1);
|
|
arg->type = GetTypeFromTypeInfo(type.Obj());
|
|
func->arguments.Add(arg);
|
|
}
|
|
}
|
|
|
|
return func;
|
|
}
|
|
|
|
/***********************************************************************
|
|
Workflow_InstallEvalEvent
|
|
***********************************************************************/
|
|
|
|
Ptr<workflow::WfStatement> Workflow_InstallEvalEvent(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GlobalStringKey variableName, description::IEventInfo* eventInfo, Ptr<workflow::WfStatement> evalStatement)
|
|
{
|
|
auto func = Workflow_GenerateEventHandler(precompileContext, eventInfo);
|
|
|
|
if (evalStatement.Cast<WfBlockStatement>())
|
|
{
|
|
func->statement = evalStatement;
|
|
}
|
|
else if (evalStatement.Cast<WfCoProviderStatement>())
|
|
{
|
|
func->statement = evalStatement;
|
|
}
|
|
else
|
|
{
|
|
auto funcBlock = MakePtr<WfBlockStatement>();
|
|
funcBlock->statements.Add(evalStatement);
|
|
func->statement = funcBlock;
|
|
}
|
|
|
|
auto subBlock = MakePtr<WfBlockStatement>();
|
|
|
|
{
|
|
auto eventHandlerLambda = MakePtr<WfFunctionExpression>();
|
|
eventHandlerLambda->function = func;
|
|
|
|
auto eventHandler = MakePtr<WfVariableDeclaration>();
|
|
eventHandler->name.value = L"<event-handler>";
|
|
eventHandler->expression = eventHandlerLambda;
|
|
|
|
auto stat = MakePtr<WfVariableStatement>();
|
|
stat->variable = eventHandler;
|
|
subBlock->statements.Add(stat);
|
|
}
|
|
{
|
|
auto var = MakePtr<WfReferenceExpression>();
|
|
var->name.value = variableName.ToString();
|
|
|
|
auto member = MakePtr<WfMemberExpression>();
|
|
member->parent = var;
|
|
member->name.value = eventInfo->GetName();
|
|
|
|
auto eventHandler = MakePtr<WfReferenceExpression>();
|
|
eventHandler->name.value = L"<event-handler>";
|
|
|
|
auto attachEvent = MakePtr<WfAttachEventExpression>();
|
|
attachEvent->event = member;
|
|
attachEvent->function = eventHandler;
|
|
|
|
auto stat = MakePtr<WfExpressionStatement>();
|
|
stat->expression = attachEvent;
|
|
subBlock->statements.Add(stat);
|
|
}
|
|
|
|
return subBlock;
|
|
}
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWMODULE.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
using namespace workflow;
|
|
using namespace workflow::analyzer;
|
|
using namespace reflection::description;
|
|
using namespace collections;
|
|
|
|
/***********************************************************************
|
|
Workflow_CreateModuleWithUsings
|
|
***********************************************************************/
|
|
|
|
Ptr<workflow::WfModule> Workflow_CreateModuleWithUsings(Ptr<GuiInstanceContext> context)
|
|
{
|
|
auto module = MakePtr<WfModule>();
|
|
module->name.value = L"<auto-generated>";
|
|
|
|
vint index = context->namespaces.Keys().IndexOf(GlobalStringKey());
|
|
if (index != -1)
|
|
{
|
|
auto nss = context->namespaces.Values()[index];
|
|
FOREACH(Ptr<GuiInstanceNamespace>, ns, nss->namespaces)
|
|
{
|
|
auto path = MakePtr<WfModuleUsingPath>();
|
|
module->paths.Add(path);
|
|
|
|
auto pathCode = ns->prefix + L"*" + ns->postfix;
|
|
auto reading = pathCode.Buffer();
|
|
while (reading)
|
|
{
|
|
auto delimiter = wcsstr(reading, L"::");
|
|
auto begin = reading;
|
|
auto end = delimiter ? delimiter : begin + wcslen(reading);
|
|
|
|
auto wildcard = wcschr(reading, L'*');
|
|
if (wildcard >= end)
|
|
{
|
|
wildcard = nullptr;
|
|
}
|
|
|
|
auto item = MakePtr<WfModuleUsingItem>();
|
|
path->items.Add(item);
|
|
if (wildcard)
|
|
{
|
|
if (begin < wildcard)
|
|
{
|
|
auto fragment = MakePtr<WfModuleUsingNameFragment>();
|
|
item->fragments.Add(fragment);
|
|
fragment->name.value = WString(begin, vint(wildcard - begin));
|
|
}
|
|
{
|
|
auto fragment = MakePtr<WfModuleUsingWildCardFragment>();
|
|
item->fragments.Add(fragment);
|
|
}
|
|
if (wildcard + 1 < end)
|
|
{
|
|
auto fragment = MakePtr<WfModuleUsingNameFragment>();
|
|
item->fragments.Add(fragment);
|
|
fragment->name.value = WString(wildcard + 1, vint(end - wildcard - 1));
|
|
}
|
|
}
|
|
else if (begin < end)
|
|
{
|
|
auto fragment = MakePtr<WfModuleUsingNameFragment>();
|
|
item->fragments.Add(fragment);
|
|
fragment->name.value = WString(begin, vint(end - begin));
|
|
}
|
|
|
|
if (delimiter)
|
|
{
|
|
reading = delimiter + 2;
|
|
}
|
|
else
|
|
{
|
|
reading = nullptr;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return module;
|
|
}
|
|
|
|
/***********************************************************************
|
|
Workflow_InstallClass
|
|
***********************************************************************/
|
|
|
|
Ptr<workflow::WfClassDeclaration> Workflow_InstallClass(const WString& className, Ptr<workflow::WfModule> module)
|
|
{
|
|
auto decls = &module->declarations;
|
|
auto reading = className.Buffer();
|
|
while (true)
|
|
{
|
|
auto delimiter = wcsstr(reading, L"::");
|
|
if (delimiter)
|
|
{
|
|
auto ns = MakePtr<WfNamespaceDeclaration>();
|
|
ns->name.value = WString(reading, delimiter - reading);
|
|
decls->Add(ns);
|
|
decls = &ns->declarations;
|
|
}
|
|
else
|
|
{
|
|
auto ctorClass = MakePtr<WfClassDeclaration>();
|
|
ctorClass->kind = WfClassKind::Class;
|
|
ctorClass->constructorType = WfConstructorType::Undefined;
|
|
ctorClass->name.value = reading;
|
|
decls->Add(ctorClass);
|
|
return ctorClass;
|
|
}
|
|
reading = delimiter + 2;
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
Workflow_InstallCtorClass
|
|
***********************************************************************/
|
|
|
|
Ptr<workflow::WfBlockStatement> Workflow_InstallCtorClass(types::ResolvingResult& resolvingResult, Ptr<workflow::WfModule> module)
|
|
{
|
|
auto ctorClass = Workflow_InstallClass(resolvingResult.context->className + L"Constructor", module);
|
|
Workflow_CreateVariablesForReferenceValues(ctorClass, resolvingResult);
|
|
|
|
auto thisParam = MakePtr<WfFunctionArgument>();
|
|
thisParam->name.value = L"<this>";
|
|
thisParam->type = GetTypeFromTypeInfo(resolvingResult.rootTypeInfo.typeInfo.Obj());
|
|
|
|
auto resolverParam = MakePtr<WfFunctionArgument>();
|
|
resolverParam->name.value = L"<resolver>";
|
|
{
|
|
auto elementType = MakePtr<TypeDescriptorTypeInfo>(description::GetTypeDescriptor<GuiResourcePathResolver>(), TypeInfoHint::Normal);
|
|
auto pointerType = MakePtr<RawPtrTypeInfo>(elementType);
|
|
|
|
resolverParam->type = GetTypeFromTypeInfo(pointerType.Obj());
|
|
}
|
|
|
|
auto block = MakePtr<WfBlockStatement>();
|
|
|
|
auto func = MakePtr<WfFunctionDeclaration>();
|
|
func->anonymity = WfFunctionAnonymity::Named;
|
|
func->name.value = L"<initialize-instance>";
|
|
func->arguments.Add(thisParam);
|
|
func->arguments.Add(resolverParam);
|
|
func->returnType = GetTypeFromTypeInfo(TypeInfoRetriver<void>::CreateTypeInfo().Obj());
|
|
func->statement = block;
|
|
|
|
{
|
|
auto att = MakePtr<WfAttribute>();
|
|
att->category.value = L"cpp";
|
|
att->name.value = L"Protected";
|
|
func->attributes.Add(att);
|
|
}
|
|
|
|
func->classMember = MakePtr<WfClassMember>();
|
|
func->classMember->kind = WfClassMemberKind::Normal;
|
|
ctorClass->declarations.Add(func);
|
|
|
|
return block;
|
|
}
|
|
|
|
/***********************************************************************
|
|
Variable
|
|
***********************************************************************/
|
|
|
|
void Workflow_CreatePointerVariable(Ptr<workflow::WfClassDeclaration> ctorClass, GlobalStringKey name, description::ITypeInfo* typeInfo)
|
|
{
|
|
auto var = MakePtr<WfVariableDeclaration>();
|
|
var->name.value = name.ToString();
|
|
var->type = GetTypeFromTypeInfo(typeInfo);
|
|
|
|
{
|
|
auto att = MakePtr<WfAttribute>();
|
|
att->category.value = L"cpp";
|
|
att->name.value = L"Protected";
|
|
var->attributes.Add(att);
|
|
}
|
|
|
|
if (!var->type)
|
|
{
|
|
if (auto ctors = typeInfo->GetTypeDescriptor()->GetConstructorGroup())
|
|
{
|
|
if (ctors->GetMethodCount() > 0)
|
|
{
|
|
auto ctor = ctors->GetMethod(0);
|
|
var->type = GetTypeFromTypeInfo(ctor->GetReturn());
|
|
}
|
|
}
|
|
}
|
|
|
|
auto literal = MakePtr<WfLiteralExpression>();
|
|
literal->value = WfLiteralValue::Null;
|
|
var->expression = literal;
|
|
|
|
var->classMember = MakePtr<WfClassMember>();
|
|
var->classMember->kind = WfClassMemberKind::Normal;
|
|
ctorClass->declarations.Add(var);
|
|
}
|
|
|
|
void Workflow_CreateVariablesForReferenceValues(Ptr<workflow::WfClassDeclaration> ctorClass, types::ResolvingResult& resolvingResult)
|
|
{
|
|
const auto& typeInfos = resolvingResult.typeInfos;
|
|
for (vint i = 0; i < typeInfos.Count(); i++)
|
|
{
|
|
auto key = typeInfos.Keys()[i];
|
|
auto value = typeInfos.Values()[i].typeInfo.Obj();
|
|
Workflow_CreatePointerVariable(ctorClass, key, value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWPARSER.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
using namespace reflection::description;
|
|
using namespace workflow;
|
|
using namespace workflow::analyzer;
|
|
|
|
/***********************************************************************
|
|
Parser
|
|
***********************************************************************/
|
|
|
|
template<typename T>
|
|
Ptr<T> Workflow_Parse(GuiResourcePrecompileContext& precompileContext, const WString& parserName, GuiResourceLocation location, const WString& code, GuiResourceTextPos position, collections::List<GuiResourceError>& errors, parsing::ParsingTextPos availableAfter)
|
|
{
|
|
vint errorCount = errors.Count();
|
|
auto parser = GetParserManager()->GetParser<T>(parserName);
|
|
auto result = parser->Parse(location, code, position, errors);
|
|
|
|
if (availableAfter.row != 0 || availableAfter.column != 0)
|
|
{
|
|
for (vint i = errorCount; i < errors.Count(); i++)
|
|
{
|
|
auto& error = errors[i];
|
|
if (error.position.row > position.row)
|
|
{
|
|
error.position.row -= availableAfter.row;
|
|
}
|
|
else if (error.position.row == position.row && error.position.column >= position.column)
|
|
{
|
|
error.position.column -= availableAfter.column;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (result)
|
|
{
|
|
Workflow_RecordScriptPosition(precompileContext, position, result, availableAfter);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
Ptr<workflow::WfType> Workflow_ParseType(GuiResourcePrecompileContext& precompileContext, GuiResourceLocation location, const WString& code, GuiResourceTextPos position, collections::List<GuiResourceError>& errors, parsing::ParsingTextPos availableAfter)
|
|
{
|
|
return Workflow_Parse<WfType>(precompileContext, L"WORKFLOW-TYPE", location, code, position, errors, availableAfter);
|
|
}
|
|
|
|
Ptr<workflow::WfExpression> Workflow_ParseExpression(GuiResourcePrecompileContext& precompileContext, GuiResourceLocation location, const WString& code, GuiResourceTextPos position, collections::List<GuiResourceError>& errors, parsing::ParsingTextPos availableAfter)
|
|
{
|
|
return Workflow_Parse<WfExpression>(precompileContext, L"WORKFLOW-EXPRESSION", location, code, position, errors, availableAfter);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> Workflow_ParseStatement(GuiResourcePrecompileContext& precompileContext, GuiResourceLocation location, const WString& code, GuiResourceTextPos position, collections::List<GuiResourceError>& errors, parsing::ParsingTextPos availableAfter)
|
|
{
|
|
return Workflow_Parse<WfStatement>(precompileContext, L"WORKFLOW-STATEMENT", location, code, position, errors, availableAfter);
|
|
}
|
|
|
|
Ptr<workflow::WfStatement> Workflow_ParseCoProviderStatement(GuiResourcePrecompileContext& precompileContext, GuiResourceLocation location, const WString& code, GuiResourceTextPos position, collections::List<GuiResourceError>& errors, parsing::ParsingTextPos availableAfter)
|
|
{
|
|
return Workflow_Parse<WfStatement>(precompileContext, L"WORKFLOW-COPROVIDER-STATEMENT", location, code, position, errors, availableAfter);
|
|
}
|
|
|
|
Ptr<workflow::WfModule> Workflow_ParseModule(GuiResourcePrecompileContext& precompileContext, GuiResourceLocation location, const WString& code, GuiResourceTextPos position, collections::List<GuiResourceError>& errors, parsing::ParsingTextPos availableAfter)
|
|
{
|
|
return Workflow_Parse<WfModule>(precompileContext, L"WORKFLOW-MODULE", location, code, position, errors, availableAfter);
|
|
}
|
|
|
|
/***********************************************************************
|
|
Workflow_ModuleToString
|
|
***********************************************************************/
|
|
|
|
WString Workflow_ModuleToString(Ptr<workflow::WfModule> module)
|
|
{
|
|
stream::MemoryStream stream;
|
|
{
|
|
stream::StreamWriter writer(stream);
|
|
WfPrint(module, L"", writer);
|
|
}
|
|
stream.SeekFromBegin(0);
|
|
stream::StreamReader reader(stream);
|
|
return reader.ReadToEnd();
|
|
}
|
|
|
|
/***********************************************************************
|
|
Converter
|
|
***********************************************************************/
|
|
|
|
Ptr<workflow::WfExpression> Workflow_ParseTextValue(GuiResourcePrecompileContext& precompileContext, description::ITypeDescriptor* typeDescriptor, GuiResourceLocation location, const WString& textValue, GuiResourceTextPos position, collections::List<GuiResourceError>& errors)
|
|
{
|
|
if (typeDescriptor == description::GetTypeDescriptor<WString>())
|
|
{
|
|
auto str = MakePtr<WfStringExpression>();
|
|
str->value.value = textValue;
|
|
return str;
|
|
}
|
|
else if (typeDescriptor->GetSerializableType())
|
|
{
|
|
auto str = MakePtr<WfStringExpression>();
|
|
str->value.value = textValue;
|
|
|
|
auto type = MakePtr<TypeDescriptorTypeInfo>(typeDescriptor, TypeInfoHint::Normal);
|
|
|
|
auto cast = MakePtr<WfTypeCastingExpression>();
|
|
cast->type = GetTypeFromTypeInfo(type.Obj());
|
|
cast->strategy = WfTypeCastingStrategy::Strong;
|
|
cast->expression = str;
|
|
|
|
return cast;
|
|
}
|
|
else if (typeDescriptor->GetTypeDescriptorFlags() == TypeDescriptorFlags::Struct)
|
|
{
|
|
if (auto valueExpr = Workflow_ParseExpression(precompileContext, location, L"{" + textValue + L"}", position, errors, { 0,1 })) // {
|
|
{
|
|
auto type = MakePtr<TypeDescriptorTypeInfo>(typeDescriptor, TypeInfoHint::Normal);
|
|
|
|
auto infer = MakePtr<WfInferExpression>();
|
|
infer->type = GetTypeFromTypeInfo(type.Obj());
|
|
infer->expression = valueExpr;
|
|
|
|
return infer;
|
|
}
|
|
return nullptr;
|
|
}
|
|
else if ((typeDescriptor->GetTypeDescriptorFlags() & TypeDescriptorFlags::EnumType) != TypeDescriptorFlags::Undefined)
|
|
{
|
|
if (auto valueExpr = Workflow_ParseExpression(precompileContext, location, L"(" + textValue + L")", position, errors, { 0,1 })) // {
|
|
{
|
|
auto type = MakePtr<TypeDescriptorTypeInfo>(typeDescriptor, TypeInfoHint::Normal);
|
|
|
|
auto infer = MakePtr<WfInferExpression>();
|
|
infer->type = GetTypeFromTypeInfo(type.Obj());
|
|
infer->expression = valueExpr;
|
|
|
|
return infer;
|
|
}
|
|
return nullptr;
|
|
}
|
|
else
|
|
{
|
|
CHECK_FAIL(L"vl::presentation::Workflow_ParseTextValue(ITypeDescriptor*, const WString&, GuiResourceError::List&)#This is not a value type.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
WORKFLOWCODEGEN\GUIINSTANCELOADER_WORKFLOWSCRIPTPOSITION.CPP
|
|
***********************************************************************/
|
|
|
|
namespace vl
|
|
{
|
|
namespace presentation
|
|
{
|
|
using namespace collections;
|
|
using namespace parsing;
|
|
using namespace workflow;
|
|
|
|
/***********************************************************************
|
|
WorkflowScriptPositionVisitor
|
|
***********************************************************************/
|
|
|
|
class WorkflowScriptPositionVisitor : public traverse_visitor::ModuleVisitor
|
|
{
|
|
public:
|
|
GuiResourcePrecompileContext& context;
|
|
GuiResourceTextPos position;
|
|
ParsingTextPos availableAfter;
|
|
Ptr<types::ScriptPosition> sp;
|
|
|
|
WorkflowScriptPositionVisitor(GuiResourcePrecompileContext& _context, GuiResourceTextPos _position, ParsingTextPos _availableAfter)
|
|
:context(_context)
|
|
, position(_position)
|
|
, availableAfter(_availableAfter)
|
|
{
|
|
vint index = context.additionalProperties.Keys().IndexOf(nullptr);
|
|
if (index == -1)
|
|
{
|
|
context.additionalProperties.Add(nullptr, MakePtr<types::ScriptPosition>());
|
|
}
|
|
sp = context.additionalProperties[nullptr].Cast<types::ScriptPosition>();
|
|
}
|
|
|
|
virtual void Traverse(ParsingTreeCustomBase* node)override
|
|
{
|
|
if (!sp->nodePositions.Keys().Contains(node))
|
|
{
|
|
auto pos = node->codeRange.start;
|
|
if (pos.row == availableAfter.row && pos.column > availableAfter.column)
|
|
{
|
|
pos.column -= availableAfter.column;
|
|
}
|
|
else if (pos.row > availableAfter.row)
|
|
{
|
|
pos.row -= availableAfter.row;
|
|
}
|
|
|
|
types::ScriptPositionRecord record;
|
|
record.position = position;
|
|
record.availableAfter = availableAfter;
|
|
if (pos.row < 0 || pos.column < 0)
|
|
{
|
|
record.computedPosition = position;
|
|
}
|
|
else if (pos.row == 0)
|
|
{
|
|
record.computedPosition = { position.originalLocation,{position.row,position.column + pos.column} };
|
|
}
|
|
else
|
|
{
|
|
record.computedPosition = { position.originalLocation,{ position.row + pos.row,pos.column } };
|
|
}
|
|
|
|
sp->nodePositions.Add(node, record);
|
|
}
|
|
}
|
|
};
|
|
|
|
/***********************************************************************
|
|
WorkflowCompiler_ScriptPosition
|
|
***********************************************************************/
|
|
|
|
void Workflow_RecordScriptPosition(GuiResourcePrecompileContext& context, GuiResourceTextPos position, Ptr<workflow::WfType> node, parsing::ParsingTextPos availableAfter)
|
|
{
|
|
WorkflowScriptPositionVisitor(context, position, availableAfter).VisitField(node.Obj());
|
|
}
|
|
|
|
void Workflow_RecordScriptPosition(GuiResourcePrecompileContext& context, GuiResourceTextPos position, Ptr<workflow::WfExpression> node, parsing::ParsingTextPos availableAfter)
|
|
{
|
|
WorkflowScriptPositionVisitor(context, position, availableAfter).VisitField(node.Obj());
|
|
}
|
|
|
|
void Workflow_RecordScriptPosition(GuiResourcePrecompileContext& context, GuiResourceTextPos position, Ptr<workflow::WfStatement> node, parsing::ParsingTextPos availableAfter)
|
|
{
|
|
WorkflowScriptPositionVisitor(context, position, availableAfter).VisitField(node.Obj());
|
|
}
|
|
|
|
void Workflow_RecordScriptPosition(GuiResourcePrecompileContext& context, GuiResourceTextPos position, Ptr<workflow::WfDeclaration> node, parsing::ParsingTextPos availableAfter)
|
|
{
|
|
WorkflowScriptPositionVisitor(context, position, availableAfter).VisitField(node.Obj());
|
|
}
|
|
|
|
void Workflow_RecordScriptPosition(GuiResourcePrecompileContext& context, GuiResourceTextPos position, Ptr<workflow::WfModule> node, parsing::ParsingTextPos availableAfter)
|
|
{
|
|
WorkflowScriptPositionVisitor(context, position, availableAfter).VisitField(node.Obj());
|
|
}
|
|
|
|
Ptr<types::ScriptPosition> Workflow_GetScriptPosition(GuiResourcePrecompileContext& context)
|
|
{
|
|
vint index = context.additionalProperties.Keys().IndexOf(nullptr);
|
|
if (index == -1) return nullptr;
|
|
return context.additionalProperties.Values()[index].Cast<types::ScriptPosition>();
|
|
}
|
|
|
|
void Workflow_ClearScriptPosition(GuiResourcePrecompileContext& context)
|
|
{
|
|
context.additionalProperties.Remove(nullptr);
|
|
}
|
|
}
|
|
}
|