diff --git a/Import/GacUI.cpp b/Import/GacUI.cpp index e5e9ba79..565d537a 100644 --- a/Import/GacUI.cpp +++ b/Import/GacUI.cpp @@ -518,7 +518,7 @@ GuiApplicationMain ThreadLocalStorage::DisposeStorages(); FinalizeGlobalStorage(); #ifndef VCZH_DEBUG_NO_REFLECTION - DestroyGlobalTypeManager(); + ResetGlobalTypeManager(); #endif } } @@ -33746,6 +33746,232 @@ SharedAsyncService } } +/*********************************************************************** +.\PLATFORMPROVIDERS\GACGEN\GACGENCONTROLLER.CPP +***********************************************************************/ + +using namespace vl; +using namespace vl::stream; +using namespace vl::reflection::description; +using namespace vl::presentation; + +class GacGenNativeController + : public Object + , public INativeController + , protected INativeCallbackService + , protected INativeResourceService + , protected INativeImageService + , protected INativeInputService +{ +public: + INativeCallbackService* CallbackService() override + { + return this; + } + + INativeResourceService* ResourceService() override + { + return this; + } + + INativeAsyncService* AsyncService() override + { + CHECK_FAIL(L"Not implemented!"); + } + + INativeClipboardService* ClipboardService() override + { + CHECK_FAIL(L"Not implemented!"); + } + + INativeImageService* ImageService() override + { + return this; + } + + INativeScreenService* ScreenService() override + { + CHECK_FAIL(L"Not implemented!"); + } + + INativeWindowService* WindowService() override + { + CHECK_FAIL(L"Not implemented!"); + } + + INativeInputService* InputService() override + { + return this; + } + + INativeDialogService* DialogService() override + { + CHECK_FAIL(L"Not implemented!"); + } + + WString GetExecutablePath() override + { + CHECK_FAIL(L"Not implemented!"); + } + + //////////////////////////////////////////////////////////////////// + // INativeCallbackService + //////////////////////////////////////////////////////////////////// + + bool InstallListener(INativeControllerListener* listener) override + { + return true; + } + + bool UninstallListener(INativeControllerListener* listener) override + { + return true; + } + + //////////////////////////////////////////////////////////////////// + // INativeResourceService + //////////////////////////////////////////////////////////////////// + + INativeCursor* GetSystemCursor(INativeCursor::SystemCursorType type) override + { + CHECK_FAIL(L"Not implemented!"); + } + + INativeCursor* GetDefaultSystemCursor() override + { + CHECK_FAIL(L"Not implemented!"); + } + + FontProperties GetDefaultFont() override + { + FontProperties font; + font.fontFamily = L"GacGen"; + font.size = 12; + font.bold = false; + font.italic = false; + font.underline = false; + font.strikeline = false; + font.antialias = false; + font.verticalAntialias = false; + return font; + } + + void SetDefaultFont(const FontProperties& value) override + { + CHECK_FAIL(L"Not implemented!"); + } + + //////////////////////////////////////////////////////////////////// + // INativeImageService + //////////////////////////////////////////////////////////////////// + + class NativeImage : public Object, public INativeImage + { + protected: + INativeImageService* imageService; + MemoryStream memoryStream; + + public: + NativeImage(INativeImageService* _imageService, IStream& inputStream) + : imageService(_imageService) + { + CopyStream(inputStream, memoryStream); + } + + INativeImageService* GetImageService() override + { + return imageService; + } + + FormatType GetFormat() override + { + CHECK_FAIL(L"Not implemented!"); + } + + vint GetFrameCount() override + { + return 0; + } + + INativeImageFrame* GetFrame(vint index) override + { + CHECK_FAIL(L"Not implemented!"); + } + + void SaveToStream(stream::IStream& imageStream, FormatType formatType) override + { + CHECK_ERROR(formatType == FormatType::Unknown, L"Not Implemented!"); + CopyStream(imageStream, memoryStream); + } + }; + + Ptr CreateImageFromFile(const WString& path) override + { + FileStream imageStream(path, FileStream::ReadOnly); + if (!imageStream.IsAvailable()) return nullptr; + return Ptr(new NativeImage(this, imageStream)); + } + + Ptr CreateImageFromMemory(void* buffer, vint length) override + { + MemoryWrapperStream imageStream(buffer, length); + return Ptr(new NativeImage(this, imageStream)); + } + + Ptr CreateImageFromStream(stream::IStream& imageStream) override + { + return Ptr(new NativeImage(this, imageStream)); + } + + //////////////////////////////////////////////////////////////////// + // INativeInputService + //////////////////////////////////////////////////////////////////// + + void StartTimer() override + { + } + + void StopTimer() override + { + } + + bool IsTimerEnabled() override + { + CHECK_FAIL(L"Not implemented!"); + } + + bool IsKeyPressing(VKEY code) override + { + CHECK_FAIL(L"Not implemented!"); + } + + bool IsKeyToggled(VKEY code) override + { + CHECK_FAIL(L"Not implemented!"); + } + + WString GetKeyName(VKEY code) override + { + CHECK_FAIL(L"Not implemented!"); + } + + VKEY GetKey(const WString& name) override + { + CHECK_FAIL(L"Not implemented!"); + } +}; + +extern void GuiApplicationMain(); + +int SetupGacGenNativeController() +{ + GacGenNativeController controller; + SetCurrentController(&controller); + GuiApplicationMain(); + SetCurrentController(nullptr); + return 0; +} + /*********************************************************************** .\PLATFORMPROVIDERS\HOSTED\GUIHOSTEDCONTROLLER.CPP ***********************************************************************/ @@ -41140,23 +41366,39 @@ GuiPluginManager Helpers ***********************************************************************/ - IGuiPluginManager* pluginManager=0; + GuiPluginDescriptor* firstPluginDescriptor = nullptr; + GuiPluginDescriptor** lastPluginDescriptor = &firstPluginDescriptor; + IGuiPluginManager* pluginManager = nullptr; IGuiPluginManager* GetPluginManager() { - if(!pluginManager) + if (!pluginManager) { - pluginManager=new GuiPluginManager; + pluginManager = new GuiPluginManager; + + auto current = firstPluginDescriptor; + while (current) + { + pluginManager->AddPlugin(current->CreatePlugin()); + current = current->next; + } } return pluginManager; } + void RegisterPluginDescriptor(GuiPluginDescriptor* pluginDescriptor) + { + CHECK_ERROR(!pluginManager, L"vl::presentation::RegisterPluginDescriptor(GuiPluginDescriptor*)#This function should be called before calling GetPluginManager."); + *lastPluginDescriptor = pluginDescriptor; + lastPluginDescriptor = &pluginDescriptor->next; + } + void DestroyPluginManager() { - if(pluginManager) + if (pluginManager) { delete pluginManager; - pluginManager=0; + pluginManager = nullptr; } } } @@ -42589,8 +42831,17 @@ GuiResource SaveResourceFolderToBinary(writer, typeNames); } - Ptr GuiResource::Precompile(IGuiResourcePrecompileCallback* callback, GuiResourceError::List& errors) + Ptr GuiResource::Precompile(GuiResourceCpuArchitecture targetCpuArchitecture, IGuiResourcePrecompileCallback* callback, GuiResourceError::List& errors) { + if (targetCpuArchitecture == GuiResourceCpuArchitecture::Unspecified) + { +#ifdef VCZH_64 + targetCpuArchitecture = GuiResourceCpuArchitecture::x64; +#else + targetCpuArchitecture = GuiResourceCpuArchitecture::x86; +#endif + } + if (GetFolder(L"Precompiled")) { errors.Add(GuiResourceError({Ptr(this)}, L"A precompiled resource cannot be compiled again.")); @@ -42598,6 +42849,7 @@ GuiResource } GuiResourcePrecompileContext context; + context.targetCpuArchitecture = targetCpuArchitecture; context.compilerCallback = callback ? callback->GetCompilerCallback() : nullptr; context.rootResource = this; context.resolver = Ptr(new GuiResourcePathResolver(Ptr(this), workingDirectory)); diff --git a/Import/GacUI.h b/Import/GacUI.h index 5ce82582..22ff5ba5 100644 --- a/Import/GacUI.h +++ b/Import/GacUI.h @@ -7785,20 +7785,36 @@ Plugin Plugin Manager ***********************************************************************/ + struct GuiPluginDescriptor + { + GuiPluginDescriptor* next = nullptr; + + virtual Ptr CreatePlugin() = 0; + }; + /// Get the global object. /// The global object. extern IGuiPluginManager* GetPluginManager(); + /// Register a plugin descriptor. Do not call this function directly, use GUI_REGISTER_PLUGIN macro instead. + /// The plugin descriptor. + extern void RegisterPluginDescriptor(GuiPluginDescriptor* pluginDescriptor); + /// Destroy the global object. extern void DestroyPluginManager(); #define GUI_REGISTER_PLUGIN(TYPE)\ - class GuiRegisterPluginClass_##TYPE\ + struct GuiRegisterPluginClass_##TYPE : private vl::presentation::GuiPluginDescriptor\ {\ + private:\ + vl::Ptr CreatePlugin() override\ + {\ + return vl::Ptr(new TYPE);\ + }\ public:\ GuiRegisterPluginClass_##TYPE()\ {\ - vl::presentation::GetPluginManager()->AddPlugin(Ptr(new TYPE));\ + vl::presentation::RegisterPluginDescriptor(this);\ }\ } instance_GuiRegisterPluginClass_##TYPE;\ @@ -7839,6 +7855,7 @@ namespace vl class GuiResourceItem; class GuiResourceFolder; class GuiResource; + class GuiResourcePathResolver; /*********************************************************************** Helper Functions @@ -7950,6 +7967,56 @@ Resource String WString GetText(); }; +/*********************************************************************** +Resource Precompile Context +***********************************************************************/ + + /// + /// CPU architecture + /// + enum class GuiResourceCpuArchitecture + { + x86, + x64, + Unspecified, + }; + + /// + /// Resource usage + /// + enum class GuiResourceUsage + { + DataOnly, + InstanceClass, + }; + + /// Provide a context for resource precompiling + struct GuiResourcePrecompileContext + { + typedef collections::Dictionary, Ptr> PropertyMap; + + /// The target CPU architecture. + GuiResourceCpuArchitecture targetCpuArchitecture = GuiResourceCpuArchitecture::Unspecified; + /// Progress callback. + workflow::IWfCompilerCallback* compilerCallback = nullptr; + /// The folder to contain compiled objects. + Ptr targetFolder; + /// The root resource object. + GuiResource* rootResource = nullptr; + /// Indicate the pass index of this precompiling pass. + vint passIndex = -1; + /// The path resolver. This is only for delay load resource. + Ptr resolver; + /// Additional properties for resource item contents + PropertyMap additionalProperties; + }; + + /// Provide a context for resource initializing + struct GuiResourceInitializeContext : GuiResourcePrecompileContext + { + GuiResourceUsage usage; + }; + /*********************************************************************** Resource Structure ***********************************************************************/ @@ -8039,9 +8106,6 @@ Resource Structure }; class DocumentModel; - class GuiResourcePathResolver; - struct GuiResourcePrecompileContext; - struct GuiResourceInitializeContext; class IGuiResourcePrecompileCallback; /// Resource item. @@ -8183,12 +8247,6 @@ Resource Structure Resource ***********************************************************************/ - enum class GuiResourceUsage - { - DataOnly, - InstanceClass, - }; - /// Resource metadata. class GuiResourceMetadata : public Object { @@ -8261,7 +8319,7 @@ Resource /// The resource folder contains all precompiled result. The folder will be added to the resource if there is no error. /// A callback to receive progress. /// All collected errors during precompiling a resource. - Ptr Precompile(IGuiResourcePrecompileCallback* callback, GuiResourceError::List& errors); + Ptr Precompile(GuiResourceCpuArchitecture targetCpuArchitecture, IGuiResourcePrecompileCallback* callback, GuiResourceError::List& errors); /// Initialize a precompiled resource. /// In which role an application is initializing this resource. @@ -8379,25 +8437,6 @@ Resource Type Resolver virtual IGuiResourceTypeResolver_IndirectLoad* IndirectLoad(){ return 0; } }; - /// Provide a context for resource precompiling - struct GuiResourcePrecompileContext - { - typedef collections::Dictionary, Ptr> PropertyMap; - - /// Progress callback. - workflow::IWfCompilerCallback* compilerCallback = nullptr; - /// The folder to contain compiled objects. - Ptr targetFolder; - /// The root resource object. - GuiResource* rootResource = nullptr; - /// Indicate the pass index of this precompiling pass. - vint passIndex = -1; - /// The path resolver. This is only for delay load resource. - Ptr resolver; - /// Additional properties for resource item contents - PropertyMap additionalProperties; - }; - /// /// Represents a precompiler for resources of a specified type. /// Current resources that needs precompiling: @@ -8463,12 +8502,6 @@ Resource Type Resolver virtual void OnPerResource(vint passIndex, Ptr resource) = 0; }; - /// Provide a context for resource initializing - struct GuiResourceInitializeContext : GuiResourcePrecompileContext - { - GuiResourceUsage usage; - }; - /// /// Represents a precompiler for resources of a specified type. /// Current resources that needs precompiling: @@ -21340,11 +21373,19 @@ using namespace vl::presentation::templates; #endif +// GacUI Compiler +extern int SetupGacGenNativeController(); + +// Windows extern int SetupWindowsGDIRenderer(); extern int SetupWindowsDirect2DRenderer(); extern int SetupHostedWindowsGDIRenderer(); extern int SetupHostedWindowsDirect2DRenderer(); +// Gtk +extern int SetupGtkRenderer(); + +// macOS extern int SetupOSXCoreGraphicsRenderer(); #endif diff --git a/Import/GacUICompiler.cpp b/Import/GacUICompiler.cpp index 8935b90f..4cccc447 100644 --- a/Import/GacUICompiler.cpp +++ b/Import/GacUICompiler.cpp @@ -29,10 +29,11 @@ namespace vl Ptr PrecompileResource( Ptr resource, + GuiResourceCpuArchitecture targetCpuArchitecture, IGuiResourcePrecompileCallback* callback, collections::List& errors) { - auto precompiledFolder = resource->Precompile(callback, errors); + auto precompiledFolder = resource->Precompile(targetCpuArchitecture, callback, errors); return precompiledFolder; } @@ -68,7 +69,7 @@ namespace vl } } - if (File(workflowPath).WriteAllText(text)) + if (File(workflowPath).WriteAllText(text, true, BomEncoder::Utf8)) { return compiled; } @@ -1630,19 +1631,19 @@ IGuiInstanceLoader { } - void IGuiInstanceLoader::GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames) + void IGuiInstanceLoader::GetRequiredPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames) { } - void IGuiInstanceLoader::GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames) + void IGuiInstanceLoader::GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames) { } - void IGuiInstanceLoader::GetPairedProperties(const PropertyInfo& propertyInfo, collections::List& propertyNames) + void IGuiInstanceLoader::GetPairedProperties(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo, collections::List& propertyNames) { } - Ptr IGuiInstanceLoader::GetPropertyType(const PropertyInfo& propertyInfo) + Ptr IGuiInstanceLoader::GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo) { return nullptr; } @@ -1944,7 +1945,7 @@ GuiDefaultInstanceLoader return nullptr; } - void CollectPropertyNames(const TypeInfo& typeInfo, ITypeDescriptor* typeDescriptor, collections::List& propertyNames) + void CollectPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, ITypeDescriptor* typeDescriptor, collections::List& propertyNames) { vint propertyCount = typeDescriptor->GetPropertyCount(); for (vint i = 0; i < propertyCount; i++) @@ -1952,7 +1953,7 @@ GuiDefaultInstanceLoader GlobalStringKey propertyName = GlobalStringKey::Get(typeDescriptor->GetProperty(i)->GetName()); if (!propertyNames.Contains(propertyName)) { - auto info = GetPropertyType(PropertyInfo(typeInfo, propertyName)); + auto info = GetPropertyType(precompileContext, PropertyInfo(typeInfo, propertyName)); if (info && info->support != GuiInstancePropertyInfo::NotSupport) { propertyNames.Add(propertyName); @@ -1963,13 +1964,13 @@ GuiDefaultInstanceLoader vint parentCount = typeDescriptor->GetBaseTypeDescriptorCount(); for (vint i = 0; i < parentCount; i++) { - CollectPropertyNames(typeInfo, typeDescriptor->GetBaseTypeDescriptor(i), propertyNames); + CollectPropertyNames(precompileContext, typeInfo, typeDescriptor->GetBaseTypeDescriptor(i), propertyNames); } } //*********************************************************************************** - void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetRequiredPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { if (CanCreate(typeInfo)) { @@ -1987,10 +1988,10 @@ GuiDefaultInstanceLoader } } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { - GetRequiredPropertyNames(typeInfo, propertyNames); - CollectPropertyNames(typeInfo, typeInfo.typeInfo->GetTypeDescriptor(), propertyNames); + GetRequiredPropertyNames(precompileContext, typeInfo, propertyNames); + CollectPropertyNames(precompileContext, typeInfo, typeInfo.typeInfo->GetTypeDescriptor(), propertyNames); } PropertyType GetPropertyTypeCached(const PropertyInfo& propertyInfo) @@ -2040,7 +2041,7 @@ GuiDefaultInstanceLoader } } - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo)override { return GetPropertyTypeCached(propertyInfo).f0; } @@ -3939,7 +3940,17 @@ GuiDataProcessorDeserializer else { decl->name.value = L"Compare"; - decl->returnType = GetTypeFromTypeInfo(TypeInfoRetriver::CreateTypeInfo().Obj()); + switch (precompileContext.targetCpuArchitecture) + { + case GuiResourceCpuArchitecture::x86: + decl->returnType = GetTypeFromTypeInfo(TypeInfoRetriver::CreateTypeInfo().Obj()); + break; + case GuiResourceCpuArchitecture::x64: + decl->returnType = GetTypeFromTypeInfo(TypeInfoRetriver::CreateTypeInfo().Obj()); + break; + default: + CHECK_FAIL(L"The target CPU architecture is unspecified."); + } argumentNames.Add(L""); argumentNames.Add(L""); } @@ -4150,7 +4161,7 @@ namespace vl if (!compiled->assembly) { List codes; - auto manager = Workflow_GetSharedManager(); + auto manager = Workflow_GetSharedManager(context.targetCpuArchitecture); manager->Clear(false, true); auto addCode = [&codes](TextReader& reader) @@ -6864,7 +6875,7 @@ GuiAxisInstanceLoader return typeName; } - void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetRequiredPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { if (CanCreate(typeInfo)) { @@ -6872,12 +6883,12 @@ GuiAxisInstanceLoader } } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { - GetRequiredPropertyNames(typeInfo, propertyNames); + GetRequiredPropertyNames(precompileContext, typeInfo, propertyNames); } - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo)override { if (propertyInfo.propertyName == _AxisDirection) { @@ -6885,7 +6896,7 @@ GuiAxisInstanceLoader info->usage = GuiInstancePropertyInfo::ConstructorArgument; return info; } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); + return IGuiInstanceLoader::GetPropertyType(precompileContext, propertyInfo); } bool CanCreate(const TypeInfo& typeInfo)override @@ -6941,12 +6952,12 @@ GuiCompositionInstanceLoader return typeName; } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { propertyNames.Add(GlobalStringKey::Empty); } - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo)override { if (propertyInfo.propertyName == GlobalStringKey::Empty) { @@ -6960,7 +6971,7 @@ GuiCompositionInstanceLoader } return info; } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); + return IGuiInstanceLoader::GetPropertyType(precompileContext, propertyInfo); } Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override @@ -7097,13 +7108,13 @@ GuiTableCompositionInstanceLoader return typeName; } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { propertyNames.Add(_Rows); propertyNames.Add(_Columns); } - void GetPairedProperties(const PropertyInfo& propertyInfo, collections::List& propertyNames)override + void GetPairedProperties(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo, collections::List& propertyNames)override { if (propertyInfo.propertyName == _Rows || propertyInfo.propertyName == _Columns) { @@ -7112,13 +7123,13 @@ GuiTableCompositionInstanceLoader } } - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo)override { if (propertyInfo.propertyName == _Rows || propertyInfo.propertyName == _Columns) { return GuiInstancePropertyInfo::Array(TypeInfoRetriver::CreateTypeInfo()); } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); + return IGuiInstanceLoader::GetPropertyType(precompileContext, propertyInfo); } Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override @@ -7236,18 +7247,18 @@ GuiCellCompositionInstanceLoader return typeName; } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { propertyNames.Add(_Site); } - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo)override { if (propertyInfo.propertyName == _Site) { return GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); + return IGuiInstanceLoader::GetPropertyType(precompileContext, propertyInfo); } Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override @@ -7414,7 +7425,7 @@ GuiDocumentItemInstanceLoader return typeName; } - void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetRequiredPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { if (CanCreate(typeInfo)) { @@ -7422,13 +7433,13 @@ GuiDocumentItemInstanceLoader } } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { - GetRequiredPropertyNames(typeInfo, propertyNames); + GetRequiredPropertyNames(precompileContext, typeInfo, propertyNames); propertyNames.Add(GlobalStringKey::Empty); } - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo)override { if (propertyInfo.propertyName == GlobalStringKey::Empty) { @@ -7443,7 +7454,7 @@ GuiDocumentItemInstanceLoader info->usage = GuiInstancePropertyInfo::ConstructorArgument; return info; } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); + return IGuiInstanceLoader::GetPropertyType(precompileContext, propertyInfo); } @@ -7556,19 +7567,19 @@ GuiDocumentInstanceLoaderBase { } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { propertyNames.Add(GlobalStringKey::Empty); - TBaseType::GetPropertyNames(typeInfo, propertyNames); + TBaseType::GetPropertyNames(precompileContext, typeInfo, propertyNames); } - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo)override { if (propertyInfo.propertyName == GlobalStringKey::Empty) { return GuiInstancePropertyInfo::CollectionWithParent(TypeInfoRetriver>::CreateTypeInfo()); } - return TBaseType::GetPropertyType(propertyInfo); + return TBaseType::GetPropertyType(precompileContext, propertyInfo); } Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override @@ -7714,22 +7725,22 @@ GuiComboBoxInstanceLoader _ListControl = GlobalStringKey::Get(L"ListControl"); } - void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetRequiredPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { if (CanCreate(typeInfo)) { propertyNames.Add(_ListControl); } - BASE_TYPE::GetRequiredPropertyNames(typeInfo, propertyNames); + BASE_TYPE::GetRequiredPropertyNames(precompileContext, typeInfo, propertyNames); } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { - GetRequiredPropertyNames(typeInfo, propertyNames); - BASE_TYPE::GetPropertyNames(typeInfo, propertyNames); + GetRequiredPropertyNames(precompileContext, typeInfo, propertyNames); + BASE_TYPE::GetPropertyNames(precompileContext, typeInfo, propertyNames); } - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo)override { if (propertyInfo.propertyName == _ListControl) { @@ -7737,7 +7748,7 @@ GuiComboBoxInstanceLoader info->usage = GuiInstancePropertyInfo::ConstructorArgument; return info; } - return BASE_TYPE::GetPropertyType(propertyInfo); + return BASE_TYPE::GetPropertyType(precompileContext, propertyInfo); } }; #undef BASE_TYPE @@ -7762,16 +7773,16 @@ GuiTreeViewInstanceLoader _Nodes = GlobalStringKey::Get(L"Nodes"); } - void GetPropertyNames(const typename BASE_TYPE::TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const typename BASE_TYPE::TypeInfo& typeInfo, collections::List& propertyNames)override { if (!bindable) { propertyNames.Add(_Nodes); } - BASE_TYPE::GetPropertyNames(typeInfo, propertyNames); + BASE_TYPE::GetPropertyNames(precompileContext, typeInfo, propertyNames); } - Ptr GetPropertyType(const typename BASE_TYPE::PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const typename BASE_TYPE::PropertyInfo& propertyInfo)override { if (propertyInfo.propertyName == _Nodes) { @@ -7780,7 +7791,7 @@ GuiTreeViewInstanceLoader return GuiInstancePropertyInfo::Collection(TypeInfoRetriver>::CreateTypeInfo()); } } - return BASE_TYPE::GetPropertyType(propertyInfo); + return BASE_TYPE::GetPropertyType(precompileContext, propertyInfo); } Ptr 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 @@ -7867,7 +7878,7 @@ GuiTreeNodeInstanceLoader return typeName; } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { propertyNames.Add(_Text); propertyNames.Add(_Image); @@ -7875,7 +7886,7 @@ GuiTreeNodeInstanceLoader propertyNames.Add(GlobalStringKey::Empty); } - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo)override { if (propertyInfo.propertyName == _Text) { @@ -7899,7 +7910,7 @@ GuiTreeNodeInstanceLoader { return GuiInstancePropertyInfo::Collection(TypeInfoRetriver>::CreateTypeInfo()); } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); + return IGuiInstanceLoader::GetPropertyType(precompileContext, propertyInfo); } bool CanCreate(const TypeInfo& typeInfo)override @@ -8170,12 +8181,12 @@ GuiControlInstanceLoader return typeName; } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { propertyNames.Add(GlobalStringKey::Empty); } - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo)override { if (propertyInfo.propertyName == GlobalStringKey::Empty) { @@ -8188,7 +8199,7 @@ GuiControlInstanceLoader } return info; } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); + return IGuiInstanceLoader::GetPropertyType(precompileContext, propertyInfo); } Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override @@ -8473,7 +8484,7 @@ GuiCommonDatePickerLookLoader return typeName; } - void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetRequiredPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { if (CanCreate(typeInfo)) { @@ -8483,12 +8494,12 @@ GuiCommonDatePickerLookLoader } } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { - GetRequiredPropertyNames(typeInfo, propertyNames); + GetRequiredPropertyNames(precompileContext, typeInfo, propertyNames); } - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo)override { if (propertyInfo.propertyName == _BackgroundColor || propertyInfo.propertyName == _PrimaryTextColor || propertyInfo.propertyName == _SecondaryTextColor) { @@ -8496,7 +8507,7 @@ GuiCommonDatePickerLookLoader info->usage = GuiInstancePropertyInfo::ConstructorArgument; return info; } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); + return IGuiInstanceLoader::GetPropertyType(precompileContext, propertyInfo); } bool CanCreate(const TypeInfo& typeInfo)override @@ -8559,7 +8570,7 @@ GuiCommonScrollViewLookLoader return typeName; } - void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetRequiredPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { if (CanCreate(typeInfo)) { @@ -8567,20 +8578,31 @@ GuiCommonScrollViewLookLoader } } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { - GetRequiredPropertyNames(typeInfo, propertyNames); + GetRequiredPropertyNames(precompileContext, typeInfo, propertyNames); } - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo)override { if (propertyInfo.propertyName == _DefaultScrollSize) { - auto info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); + Ptr info; + switch (precompileContext.targetCpuArchitecture) + { + case GuiResourceCpuArchitecture::x86: + info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); + break; + case GuiResourceCpuArchitecture::x64: + info = GuiInstancePropertyInfo::Assign(TypeInfoRetriver::CreateTypeInfo()); + break; + default: + CHECK_FAIL(L"The target CPU architecture is unspecified."); + } info->usage = GuiInstancePropertyInfo::ConstructorArgument; return info; } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); + return IGuiInstanceLoader::GetPropertyType(precompileContext, propertyInfo); } bool CanCreate(const TypeInfo& typeInfo)override @@ -8718,19 +8740,19 @@ GuiToolstripInstanceLoaderBase { } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { propertyNames.Add(GlobalStringKey::Empty); - TBaseType::GetPropertyNames(typeInfo, propertyNames); + TBaseType::GetPropertyNames(precompileContext, typeInfo, propertyNames); } - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo)override { if (propertyInfo.propertyName == GlobalStringKey::Empty) { return GuiInstancePropertyInfo::CollectionWithParent(TypeInfoRetriver::CreateTypeInfo()); } - return TBaseType::GetPropertyType(propertyInfo); + return TBaseType::GetPropertyType(precompileContext, propertyInfo); } Ptr AssignParameters(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, GlobalStringKey variableName, ArgumentMap& arguments, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override @@ -8845,19 +8867,19 @@ GuiToolstripButtonInstanceLoader _SubMenu = GlobalStringKey::Get(L"SubMenu"); } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { propertyNames.Add(_SubMenu); - BASE_TYPE::GetPropertyNames(typeInfo, propertyNames); + BASE_TYPE::GetPropertyNames(precompileContext, typeInfo, propertyNames); } - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo)override { if (propertyInfo.propertyName == _SubMenu) { return GuiInstancePropertyInfo::Set(TypeInfoRetriver::CreateTypeInfo()); } - return BASE_TYPE::GetPropertyType(propertyInfo); + return BASE_TYPE::GetPropertyType(precompileContext, propertyInfo); } Ptr GetParameter(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const PropertyInfo& propertyInfo, GlobalStringKey variableName, GuiResourceTextPos attPosition, GuiResourceError::List& errors)override @@ -8932,7 +8954,7 @@ GuiRibbonButtonsInstanceLoader _MinSize = GlobalStringKey::Get(L"MinSize"); } - void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetRequiredPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { if (CanCreate(typeInfo)) { @@ -8941,12 +8963,12 @@ GuiRibbonButtonsInstanceLoader } } - void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames)override + void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames)override { - GetRequiredPropertyNames(typeInfo, propertyNames); + GetRequiredPropertyNames(precompileContext, typeInfo, propertyNames); } - Ptr GetPropertyType(const PropertyInfo& propertyInfo)override + Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo)override { if (propertyInfo.propertyName == _MaxSize || propertyInfo.propertyName == _MinSize) { @@ -8954,7 +8976,7 @@ GuiRibbonButtonsInstanceLoader info->usage = GuiInstancePropertyInfo::ConstructorArgument; return info; } - return IGuiInstanceLoader::GetPropertyType(propertyInfo); + return IGuiInstanceLoader::GetPropertyType(precompileContext, propertyInfo); } }; #undef BASE_TYPE @@ -10024,7 +10046,7 @@ WorkflowEventNamesVisitor auto prop = repr->setters.Keys()[index]; WString errorPrefix; - if (Workflow_GetPropertyTypes(errorPrefix, resolvingResult, loader, resolvedTypeInfo, prop, setter, possibleInfos, errors)) + if (Workflow_GetPropertyTypes(precompileContext, errorPrefix, resolvingResult, loader, resolvedTypeInfo, prop, setter, possibleInfos, errors)) { if (setter->binding == GlobalStringKey::_Set) { @@ -10384,7 +10406,7 @@ Workflow_GenerateInstanceClass if (paramTd) { - auto typeInfo = Workflow_GetSuggestedParameterType(paramTd); + auto typeInfo = Workflow_GetSuggestedParameterType(precompileContext, paramTd); switch (typeInfo->GetDecorator()) { case ITypeInfo::RawPtr: return { typeInfo,className + L"*" }; @@ -10516,7 +10538,7 @@ Workflow_GenerateInstanceClass prop->functionKind = WfFunctionKind::Normal; prop->name.value = localized->name.ToString(); - prop->type = GetTypeFromTypeInfo(Workflow_GetSuggestedParameterType(lsiTd).Obj()); + prop->type = GetTypeFromTypeInfo(Workflow_GetSuggestedParameterType(precompileContext, lsiTd).Obj()); prop->configConst = WfAPConst::Writable; prop->configObserve = WfAPObserve::Observable; @@ -10946,11 +10968,28 @@ GuiWorkflowSharedManagerPlugin sharedManagerPlugin = 0; } - WfLexicalScopeManager* GetWorkflowManager() + WfLexicalScopeManager* GetWorkflowManager(GuiResourceCpuArchitecture targetCpuArchitecture) { + WfCpuArchitecture wfCpuArchitecture = WfCpuArchitecture::AsExecutable; + switch (targetCpuArchitecture) + { + case GuiResourceCpuArchitecture::x86: + wfCpuArchitecture = WfCpuArchitecture::x86; + break; + case GuiResourceCpuArchitecture::x64: + wfCpuArchitecture = WfCpuArchitecture::x64; + break; + default: + CHECK_FAIL(L"The target CPU architecture is unspecified."); + } + if (!workflowManager) { - workflowManager = Ptr(new WfLexicalScopeManager(workflowParser, WfCpuArchitecture::AsExecutable)); + workflowManager = Ptr(new WfLexicalScopeManager(workflowParser, wfCpuArchitecture)); + } + else + { + CHECK_ERROR(workflowManager->cpuArchitecture == wfCpuArchitecture, L"The target CPU architecture cannot be changed."); } return workflowManager.Obj(); } @@ -10964,9 +11003,9 @@ GuiWorkflowSharedManagerPlugin }; GUI_REGISTER_PLUGIN(GuiWorkflowSharedManagerPlugin) - WfLexicalScopeManager* Workflow_GetSharedManager() + WfLexicalScopeManager* Workflow_GetSharedManager(GuiResourceCpuArchitecture targetCpuArchitecture) { - return sharedManagerPlugin->GetWorkflowManager(); + return sharedManagerPlugin->GetWorkflowManager(targetCpuArchitecture); } Ptr Workflow_TransferSharedManager() @@ -10993,7 +11032,7 @@ namespace vl Workflow_AdjustPropertySearchType ***********************************************************************/ - IGuiInstanceLoader::TypeInfo Workflow_AdjustPropertySearchType(types::ResolvingResult& resolvingResult, IGuiInstanceLoader::TypeInfo resolvedTypeInfo, GlobalStringKey prop) + IGuiInstanceLoader::TypeInfo Workflow_AdjustPropertySearchType(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, IGuiInstanceLoader::TypeInfo resolvedTypeInfo, GlobalStringKey prop) { if (resolvedTypeInfo.typeName.ToString() == resolvingResult.context->className) { @@ -11037,9 +11076,9 @@ Workflow_AdjustPropertySearchType Workflow_GetPropertyTypes ***********************************************************************/ - bool Workflow_GetPropertyTypes(WString& errorPrefix, types::ResolvingResult& resolvingResult, IGuiInstanceLoader* loader, IGuiInstanceLoader::TypeInfo resolvedTypeInfo, GlobalStringKey prop, Ptr setter, collections::List& possibleInfos, GuiResourceError::List& errors) + bool Workflow_GetPropertyTypes(GuiResourcePrecompileContext& precompileContext, WString& errorPrefix, types::ResolvingResult& resolvingResult, IGuiInstanceLoader* loader, IGuiInstanceLoader::TypeInfo resolvedTypeInfo, GlobalStringKey prop, Ptr setter, collections::List& possibleInfos, GuiResourceError::List& errors) { - resolvedTypeInfo = Workflow_AdjustPropertySearchType(resolvingResult, resolvedTypeInfo, prop); + resolvedTypeInfo = Workflow_AdjustPropertySearchType(precompileContext, resolvingResult, resolvedTypeInfo, prop); bool reportedNotSupported = false; IGuiInstanceLoader::PropertyInfo propertyInfo(resolvedTypeInfo, prop); @@ -11049,7 +11088,7 @@ Workflow_GetPropertyTypes while (currentLoader) { - if (auto propertyTypeInfo = currentLoader->GetPropertyType(propertyInfo)) + if (auto propertyTypeInfo = currentLoader->GetPropertyType(precompileContext, propertyInfo)) { if (propertyTypeInfo->support == GuiInstancePropertyInfo::NotSupport) { @@ -11244,7 +11283,7 @@ WorkflowReferenceNamesVisitor auto prop = repr->setters.Keys()[index]; WString errorPrefix; - if (Workflow_GetPropertyTypes(errorPrefix, resolvingResult, loader, resolvedTypeInfo, prop, setter, possibleInfos, errors)) + if (Workflow_GetPropertyTypes(precompileContext, errorPrefix, resolvingResult, loader, resolvedTypeInfo, prop, setter, possibleInfos, errors)) { if (setter->binding == GlobalStringKey::Empty) { @@ -11350,7 +11389,7 @@ WorkflowReferenceNamesVisitor auto currentLoader = loader; while (currentLoader) { - currentLoader->GetRequiredPropertyNames(resolvedTypeInfo, requiredProps); + currentLoader->GetRequiredPropertyNames(precompileContext, resolvedTypeInfo, requiredProps); currentLoader = GetInstanceLoaderManager()->GetParentLoader(currentLoader); } } @@ -11363,7 +11402,7 @@ WorkflowReferenceNamesVisitor auto currentLoader = loader; while (currentLoader && !info) { - info = currentLoader->GetPropertyType({ resolvedTypeInfo, prop }); + info = currentLoader->GetPropertyType(precompileContext, { resolvedTypeInfo, prop }); currentLoader = GetInstanceLoaderManager()->GetParentLoader(currentLoader); } } @@ -11387,7 +11426,7 @@ WorkflowReferenceNamesVisitor IGuiInstanceLoader::PropertyInfo propertyInfo(resolvedTypeInfo, prop); List pairProps; - loader->GetPairedProperties(propertyInfo, pairProps); + loader->GetPairedProperties(precompileContext, propertyInfo, pairProps); if (pairProps.Count() > 0) { List missingProps; @@ -11616,10 +11655,10 @@ WorkflowReferenceNamesVisitor if (repr == resolvingResult.context->instance.Obj()) { List propertyNames; - loader->GetPropertyNames(resolvedTypeInfo, propertyNames); + loader->GetPropertyNames(precompileContext, resolvedTypeInfo, propertyNames); for (vint i = propertyNames.Count() - 1; i >= 0; i--) { - auto info = loader->GetPropertyType({ resolvedTypeInfo, propertyNames[i] }); + auto info = loader->GetPropertyType(precompileContext, { resolvedTypeInfo, propertyNames[i] }); if (!info || info->usage == GuiInstancePropertyInfo::Property) { propertyNames.RemoveAt(i); @@ -11669,7 +11708,7 @@ WorkflowReferenceNamesVisitor } }; - Ptr Workflow_GetSuggestedParameterType(reflection::description::ITypeDescriptor* typeDescriptor) + Ptr Workflow_GetSuggestedParameterType(GuiResourcePrecompileContext& precompileContext, reflection::description::ITypeDescriptor* typeDescriptor) { auto elementType = Ptr(new TypeDescriptorTypeInfo(typeDescriptor, TypeInfoHint::Normal)); if ((typeDescriptor->GetTypeDescriptorFlags() & TypeDescriptorFlags::ReferenceType) != TypeDescriptorFlags::Undefined) @@ -11730,7 +11769,7 @@ WorkflowReferenceNamesVisitor } else { - auto referenceType = Workflow_GetSuggestedParameterType(type); + auto referenceType = Workflow_GetSuggestedParameterType(precompileContext, type); resolvingResult.typeInfos.Add(parameter->name, { GlobalStringKey::Get(type->GetTypeName()),referenceType }); } } @@ -12159,7 +12198,7 @@ WorkflowGenerateCreatingVisitor ) { List pairedProps; - info.loader->GetPairedProperties(propInfo, pairedProps); + info.loader->GetPairedProperties(precompileContext, propInfo, pairedProps); if (pairedProps.Count() == 0) { pairedProps.Add(propInfo.propertyName); diff --git a/Import/GacUICompiler.h b/Import/GacUICompiler.h index aa63970c..d0cf56d6 100644 --- a/Import/GacUICompiler.h +++ b/Import/GacUICompiler.h @@ -39,6 +39,7 @@ namespace vl extern Ptr PrecompileResource( Ptr resource, + GuiResourceCpuArchitecture targetCpuArchitecture, IGuiResourcePrecompileCallback* callback, collections::List& errors); @@ -781,10 +782,10 @@ Instance Loader virtual GlobalStringKey GetTypeName() = 0; virtual void ClearReflectionCache(); - virtual void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames); - virtual void GetPropertyNames(const TypeInfo& typeInfo, collections::List& propertyNames); - virtual void GetPairedProperties(const PropertyInfo& propertyInfo, collections::List& propertyNames); - virtual Ptr GetPropertyType(const PropertyInfo& propertyInfo); + virtual void GetRequiredPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames); + virtual void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List& propertyNames); + virtual void GetPairedProperties(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo, collections::List& propertyNames); + virtual Ptr GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo); virtual bool CanCreate(const TypeInfo& typeInfo); virtual Ptr CreateRootInstance(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, ArgumentMap& arguments, GuiResourceError::List& errors); @@ -1095,7 +1096,7 @@ namespace vl PropertyResolvingMap propertyResolvings; // information of property values which are calling constructors }; } - extern workflow::analyzer::WfLexicalScopeManager* Workflow_GetSharedManager(); + extern workflow::analyzer::WfLexicalScopeManager* Workflow_GetSharedManager(GuiResourceCpuArchitecture targetCpuArchitecture); extern Ptr Workflow_TransferSharedManager(); @@ -1166,9 +1167,9 @@ WorkflowCompiler (Compile) } }; - extern IGuiInstanceLoader::TypeInfo Workflow_AdjustPropertySearchType(types::ResolvingResult& resolvingResult, IGuiInstanceLoader::TypeInfo resolvedTypeInfo, GlobalStringKey prop); - extern bool Workflow_GetPropertyTypes(WString& errorPrefix, types::ResolvingResult& resolvingResult, IGuiInstanceLoader* loader, IGuiInstanceLoader::TypeInfo resolvedTypeInfo, GlobalStringKey prop, Ptr setter, collections::List& possibleInfos, GuiResourceError::List& errors); - extern Ptr Workflow_GetSuggestedParameterType(reflection::description::ITypeDescriptor* typeDescriptor); + extern IGuiInstanceLoader::TypeInfo Workflow_AdjustPropertySearchType(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, IGuiInstanceLoader::TypeInfo resolvedTypeInfo, GlobalStringKey prop); + extern bool Workflow_GetPropertyTypes(GuiResourcePrecompileContext& precompileContext, WString& errorPrefix, types::ResolvingResult& resolvingResult, IGuiInstanceLoader* loader, IGuiInstanceLoader::TypeInfo resolvedTypeInfo, GlobalStringKey prop, Ptr setter, collections::List& possibleInfos, GuiResourceError::List& errors); + extern Ptr Workflow_GetSuggestedParameterType(GuiResourcePrecompileContext& precompileContext, reflection::description::ITypeDescriptor* typeDescriptor); extern IGuiInstanceLoader::TypeInfo Workflow_CollectReferences(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GuiResourceError::List& errors); extern void Workflow_GenerateCreating(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, Ptr statements, GuiResourceError::List& errors); extern void Workflow_GenerateBindings(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, Ptr statements, GuiResourceError::List& errors); diff --git a/Import/Vlpp.cpp b/Import/Vlpp.cpp index 1d0455f3..a6736fcc 100644 --- a/Import/Vlpp.cpp +++ b/Import/Vlpp.cpp @@ -129,72 +129,61 @@ namespace vl { using namespace collections; - class GlobalStorageManager - { - public: - Ptr> storages; +/*********************************************************************** +Helper Functions +***********************************************************************/ - GlobalStorageManager() + GlobalStorageDescriptor* firstGlobalStorageDescriptor = nullptr; + GlobalStorageDescriptor** lastGlobalStorageDescriptor = &firstGlobalStorageDescriptor; + + void RegisterStorageDescriptor(GlobalStorageDescriptor* globalStorageDescriptor) + { + *lastGlobalStorageDescriptor = globalStorageDescriptor; + lastGlobalStorageDescriptor = &globalStorageDescriptor->next; + } + + void FinalizeGlobalStorage() + { + auto current = firstGlobalStorageDescriptor; + while (current) { + current->globalStorage->EnsureFinalized(); + current = current->next; } - }; - - GlobalStorageManager& GetGlobalStorageManager() - { - static GlobalStorageManager globalStorageManager; - return globalStorageManager; } /*********************************************************************** GlobalStorage ***********************************************************************/ - GlobalStorage::GlobalStorage(const wchar_t* key) + GlobalStorage::GlobalStorage() { - InitializeGlobalStorage(); - GetGlobalStorageManager().storages->Add(key, this); } GlobalStorage::~GlobalStorage() { } - bool GlobalStorage::Cleared() + bool GlobalStorage::IsInitialized() { - return cleared; + return initialized; } -/*********************************************************************** -Helper Functions -***********************************************************************/ - - GlobalStorage* GetGlobalStorage(const wchar_t* key) + void GlobalStorage::EnsureInitialized() { - return GetGlobalStorage(WString::Unmanaged(key)); - } - - GlobalStorage* GetGlobalStorage(const WString& key) - { - return GetGlobalStorageManager().storages->Get(key); - } - - void InitializeGlobalStorage() - { - if (!GetGlobalStorageManager().storages) + if (!initialized) { - GetGlobalStorageManager().storages = Ptr(new Dictionary); + initialized = true; + InitializeResource(); } } - void FinalizeGlobalStorage() + void GlobalStorage::EnsureFinalized() { - if (GetGlobalStorageManager().storages) + if (initialized) { - for (vint i = 0; i < GetGlobalStorageManager().storages->Count(); i++) - { - GetGlobalStorageManager().storages->Values().Get(i)->ClearResource(); - } - GetGlobalStorageManager().storages = nullptr; + initialized = false; + FinalizeResource(); } } } diff --git a/Import/Vlpp.h b/Import/Vlpp.h index 7606554b..331284b4 100644 --- a/Import/Vlpp.h +++ b/Import/Vlpp.h @@ -8094,55 +8094,70 @@ namespace vl class GlobalStorage : public Object { private: - bool cleared = false; + bool initialized = false; + + protected: + virtual void InitializeResource() = 0; + virtual void FinalizeResource() = 0; + public: NOT_COPYABLE(GlobalStorage); - GlobalStorage(const wchar_t* key); + GlobalStorage(); ~GlobalStorage(); - bool Cleared(); - virtual void ClearResource() = 0; + bool IsInitialized(); + void EnsureInitialized(); + void EnsureFinalized(); }; - extern GlobalStorage* GetGlobalStorage(const wchar_t* key); - extern GlobalStorage* GetGlobalStorage(const WString& key); + struct GlobalStorageDescriptor + { + GlobalStorage* globalStorage = nullptr; + GlobalStorageDescriptor* next = nullptr; + }; + + extern void RegisterStorageDescriptor(GlobalStorageDescriptor* globalStorageDescriptor); - extern void InitializeGlobalStorage(); /// Free all memories used by global storages. extern void FinalizeGlobalStorage(); } -#define BEGIN_GLOBAL_STORAGE_CLASS(NAME) \ - class NAME : public vl::GlobalStorage \ - { \ - public: \ - NAME() \ - :vl::GlobalStorage(L ## #NAME) \ - { \ - InitializeClearResource(); \ - } \ - ~NAME() \ - { \ - if(!Cleared())ClearResource(); \ - } \ +#define BEGIN_GLOBAL_STORAGE_CLASS(NAME) \ + class NAME \ + : public vl::GlobalStorage \ + , private vl::GlobalStorageDescriptor \ + { \ + public: \ + NAME() \ + { \ + globalStorage = this; \ + vl::RegisterStorageDescriptor(this); \ + } \ + ~NAME() \ + { \ + EnsureFinalized(); \ + } \ -#define INITIALIZE_GLOBAL_STORAGE_CLASS \ - void InitializeClearResource() \ - { \ +#define INITIALIZE_GLOBAL_STORAGE_CLASS \ + protected: \ + void InitializeResource() \ + { \ -#define FINALIZE_GLOBAL_STORAGE_CLASS \ - } \ - void ClearResource() \ - { \ +#define FINALIZE_GLOBAL_STORAGE_CLASS \ + } \ + protected: \ + void FinalizeResource() \ + { \ -#define END_GLOBAL_STORAGE_CLASS(NAME) \ - } \ - }; \ - NAME& Get##NAME() \ - { \ - static NAME __global_storage_##NAME; \ - return __global_storage_##NAME; \ - } \ +#define END_GLOBAL_STORAGE_CLASS(NAME) \ + } \ + }; \ + NAME& Get##NAME() \ + { \ + static NAME __global_storage_##NAME; \ + __global_storage_##NAME.EnsureInitialized(); \ + return __global_storage_##NAME; \ + } \ #define EXTERN_GLOBAL_STORAGE_CLASS(NAME)\ class NAME;\ diff --git a/Tools/CppMerge.exe b/Tools/CppMerge.exe deleted file mode 100644 index 951f7172..00000000 Binary files a/Tools/CppMerge.exe and /dev/null differ diff --git a/Tools/GacCommon.ps1 b/Tools/GacCommon.ps1 index cf8ee3f7..dc1eb137 100644 --- a/Tools/GacCommon.ps1 +++ b/Tools/GacCommon.ps1 @@ -38,7 +38,7 @@ function EnumerateResourceFiles([String] $FileName) { } <# -Call GacGen32.exe to dump metadatas from resource files. +Call GacGen.exe to dump metadatas from resource files. Input files is save in $($FileName).log\ResourceFiles.txt, which is generated by EnumerateResourceFiles function Output files is specified in $ResourceDumpFiles(resource_file_name => dump_file_name) #> @@ -55,7 +55,7 @@ function DumpResourceFiles([String] $FileName, [HashTable]$ResourceDumpFiles) { $ResourceDumpFiles.Keys | ForEach-Object { $input_file = $_ $output_file = $ResourceDumpFiles[$_] - Start-Process-And-Wait (,("$PSScriptRoot\GacGen32.exe", "/D `"$($input_file)`" `"$($output_file)`"")) $true + Start-Process-And-Wait (,("$PSScriptRoot\GacGen.exe", "/D32 `"$($input_file)`" `"$($output_file)`"")) $true if (-not (Test-Path -Path $output_file)) { throw "Failed to dump GacUI Xml Resource File: " + $input_file } @@ -216,8 +216,8 @@ Given all metadata dumps $ResourceDumps(resource_file_name => Xml dump), write all paths of named resource files in the correct build order to $OutputNames, with all "resource_name=>resource_file_path" to $OutputMapping. The $OutputMapping will be consumed - GacGen32.exe /P - GacGen32.exe /P + GacGen.exe /P32 + GacGen.exe /P64 as an optional parameter #> function EnumerateNamedResources([HashTable] $ResourceDumps, [String] $OutputNames, [String] $OutputMapping) { diff --git a/Tools/GacGen.ps1 b/Tools/GacGen.ps1 index 39fa2b4b..1f6c2339 100644 --- a/Tools/GacGen.ps1 +++ b/Tools/GacGen.ps1 @@ -7,8 +7,8 @@ param ( Write-Host "Compiling GacUI Resource: $FileName ..." Remove-Item -Path "$($FileName).log" -Recurse -ErrorAction Ignore | Out-Null -Start-Process-And-Wait (,("$PSScriptRoot\GacGen32.exe", "/P $FileName $MappingFileName")) -Start-Process-And-Wait (,("$PSScriptRoot\GacGen64.exe", "/P $FileName $MappingFileName")) +Start-Process-And-Wait (,("$PSScriptRoot\GacGen.exe", "/P32 $FileName $MappingFileName")) +Start-Process-And-Wait (,("$PSScriptRoot\GacGen.exe", "/P64 $FileName $MappingFileName")) if (Test-Path -Path "$($FileName).log\x32\Errors.txt") { Write-Host (Get-Content "$($FileName).log\x32\Errors.txt") -ForegroundColor Red -Separator "`r`n" diff --git a/Tools/GacGen32.exe b/Tools/GacGen32.exe deleted file mode 100644 index 268125c6..00000000 Binary files a/Tools/GacGen32.exe and /dev/null differ diff --git a/Tools/GacGen64.exe b/Tools/GacGen64.exe deleted file mode 100644 index 67673ac1..00000000 Binary files a/Tools/GacGen64.exe and /dev/null differ diff --git a/Tools/GlrParserGen.exe b/Tools/GlrParserGen.exe deleted file mode 100644 index fa28a1ec..00000000 Binary files a/Tools/GlrParserGen.exe and /dev/null differ diff --git a/Tools/ParserGen.exe b/Tools/ParserGen.exe deleted file mode 100644 index 9786d617..00000000 Binary files a/Tools/ParserGen.exe and /dev/null differ