Update release and remove executable in tools

This commit is contained in:
vczh
2023-01-21 03:44:28 -08:00
parent 86987d84e8
commit 6c5ec673e1
13 changed files with 571 additions and 234 deletions
+259 -7
View File
@@ -518,7 +518,7 @@ GuiApplicationMain
ThreadLocalStorage::DisposeStorages(); ThreadLocalStorage::DisposeStorages();
FinalizeGlobalStorage(); FinalizeGlobalStorage();
#ifndef VCZH_DEBUG_NO_REFLECTION #ifndef VCZH_DEBUG_NO_REFLECTION
DestroyGlobalTypeManager(); ResetGlobalTypeManager();
#endif #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<INativeImage> CreateImageFromFile(const WString& path) override
{
FileStream imageStream(path, FileStream::ReadOnly);
if (!imageStream.IsAvailable()) return nullptr;
return Ptr(new NativeImage(this, imageStream));
}
Ptr<INativeImage> CreateImageFromMemory(void* buffer, vint length) override
{
MemoryWrapperStream imageStream(buffer, length);
return Ptr(new NativeImage(this, imageStream));
}
Ptr<INativeImage> 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 .\PLATFORMPROVIDERS\HOSTED\GUIHOSTEDCONTROLLER.CPP
***********************************************************************/ ***********************************************************************/
@@ -41140,23 +41366,39 @@ GuiPluginManager
Helpers Helpers
***********************************************************************/ ***********************************************************************/
IGuiPluginManager* pluginManager=0; GuiPluginDescriptor* firstPluginDescriptor = nullptr;
GuiPluginDescriptor** lastPluginDescriptor = &firstPluginDescriptor;
IGuiPluginManager* pluginManager = nullptr;
IGuiPluginManager* GetPluginManager() 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; 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() void DestroyPluginManager()
{ {
if(pluginManager) if (pluginManager)
{ {
delete pluginManager; delete pluginManager;
pluginManager=0; pluginManager = nullptr;
} }
} }
} }
@@ -42589,8 +42831,17 @@ GuiResource
SaveResourceFolderToBinary(writer, typeNames); SaveResourceFolderToBinary(writer, typeNames);
} }
Ptr<GuiResourceFolder> GuiResource::Precompile(IGuiResourcePrecompileCallback* callback, GuiResourceError::List& errors) Ptr<GuiResourceFolder> 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")) if (GetFolder(L"Precompiled"))
{ {
errors.Add(GuiResourceError({Ptr(this)}, L"A precompiled resource cannot be compiled again.")); errors.Add(GuiResourceError({Ptr(this)}, L"A precompiled resource cannot be compiled again."));
@@ -42598,6 +42849,7 @@ GuiResource
} }
GuiResourcePrecompileContext context; GuiResourcePrecompileContext context;
context.targetCpuArchitecture = targetCpuArchitecture;
context.compilerCallback = callback ? callback->GetCompilerCallback() : nullptr; context.compilerCallback = callback ? callback->GetCompilerCallback() : nullptr;
context.rootResource = this; context.rootResource = this;
context.resolver = Ptr(new GuiResourcePathResolver(Ptr(this), workingDirectory)); context.resolver = Ptr(new GuiResourcePathResolver(Ptr(this), workingDirectory));
+78 -37
View File
@@ -7785,20 +7785,36 @@ Plugin
Plugin Manager Plugin Manager
***********************************************************************/ ***********************************************************************/
struct GuiPluginDescriptor
{
GuiPluginDescriptor* next = nullptr;
virtual Ptr<IGuiPlugin> CreatePlugin() = 0;
};
/// <summary>Get the global <see cref="IGuiPluginManager"/> object.</summary> /// <summary>Get the global <see cref="IGuiPluginManager"/> object.</summary>
/// <returns>The global <see cref="IGuiPluginManager"/> object.</returns> /// <returns>The global <see cref="IGuiPluginManager"/> object.</returns>
extern IGuiPluginManager* GetPluginManager(); extern IGuiPluginManager* GetPluginManager();
/// <summary>Register a plugin descriptor. Do not call this function directly, use GUI_REGISTER_PLUGIN macro instead.</summary>
/// <param name="pluginDescriptor">The plugin descriptor.</param>
extern void RegisterPluginDescriptor(GuiPluginDescriptor* pluginDescriptor);
/// <summary>Destroy the global <see cref="IGuiPluginManager"/> object.</summary> /// <summary>Destroy the global <see cref="IGuiPluginManager"/> object.</summary>
extern void DestroyPluginManager(); extern void DestroyPluginManager();
#define GUI_REGISTER_PLUGIN(TYPE)\ #define GUI_REGISTER_PLUGIN(TYPE)\
class GuiRegisterPluginClass_##TYPE\ struct GuiRegisterPluginClass_##TYPE : private vl::presentation::GuiPluginDescriptor\
{\ {\
private:\
vl::Ptr<vl::presentation::IGuiPlugin> CreatePlugin() override\
{\
return vl::Ptr(new TYPE);\
}\
public:\ public:\
GuiRegisterPluginClass_##TYPE()\ GuiRegisterPluginClass_##TYPE()\
{\ {\
vl::presentation::GetPluginManager()->AddPlugin(Ptr(new TYPE));\ vl::presentation::RegisterPluginDescriptor(this);\
}\ }\
} instance_GuiRegisterPluginClass_##TYPE;\ } instance_GuiRegisterPluginClass_##TYPE;\
@@ -7839,6 +7855,7 @@ namespace vl
class GuiResourceItem; class GuiResourceItem;
class GuiResourceFolder; class GuiResourceFolder;
class GuiResource; class GuiResource;
class GuiResourcePathResolver;
/*********************************************************************** /***********************************************************************
Helper Functions Helper Functions
@@ -7950,6 +7967,56 @@ Resource String
WString GetText(); WString GetText();
}; };
/***********************************************************************
Resource Precompile Context
***********************************************************************/
/// <summary>
/// CPU architecture
/// </summary>
enum class GuiResourceCpuArchitecture
{
x86,
x64,
Unspecified,
};
/// <summary>
/// Resource usage
/// </summary>
enum class GuiResourceUsage
{
DataOnly,
InstanceClass,
};
/// <summary>Provide a context for resource precompiling</summary>
struct GuiResourcePrecompileContext
{
typedef collections::Dictionary<Ptr<DescriptableObject>, Ptr<DescriptableObject>> PropertyMap;
/// <summary>The target CPU architecture.</summary>
GuiResourceCpuArchitecture targetCpuArchitecture = GuiResourceCpuArchitecture::Unspecified;
/// <summary>Progress callback.</summary>
workflow::IWfCompilerCallback* compilerCallback = nullptr;
/// <summary>The folder to contain compiled objects.</summary>
Ptr<GuiResourceFolder> targetFolder;
/// <summary>The root resource object.</summary>
GuiResource* rootResource = nullptr;
/// <summary>Indicate the pass index of this precompiling pass.</summary>
vint passIndex = -1;
/// <summary>The path resolver. This is only for delay load resource.</summary>
Ptr<GuiResourcePathResolver> resolver;
/// <summary>Additional properties for resource item contents</summary>
PropertyMap additionalProperties;
};
/// <summary>Provide a context for resource initializing</summary>
struct GuiResourceInitializeContext : GuiResourcePrecompileContext
{
GuiResourceUsage usage;
};
/*********************************************************************** /***********************************************************************
Resource Structure Resource Structure
***********************************************************************/ ***********************************************************************/
@@ -8039,9 +8106,6 @@ Resource Structure
}; };
class DocumentModel; class DocumentModel;
class GuiResourcePathResolver;
struct GuiResourcePrecompileContext;
struct GuiResourceInitializeContext;
class IGuiResourcePrecompileCallback; class IGuiResourcePrecompileCallback;
/// <summary>Resource item.</summary> /// <summary>Resource item.</summary>
@@ -8183,12 +8247,6 @@ Resource Structure
Resource Resource
***********************************************************************/ ***********************************************************************/
enum class GuiResourceUsage
{
DataOnly,
InstanceClass,
};
/// <summary>Resource metadata.</summary> /// <summary>Resource metadata.</summary>
class GuiResourceMetadata : public Object class GuiResourceMetadata : public Object
{ {
@@ -8261,7 +8319,7 @@ Resource
/// <returns>The resource folder contains all precompiled result. The folder will be added to the resource if there is no error.</returns> /// <returns>The resource folder contains all precompiled result. The folder will be added to the resource if there is no error.</returns>
/// <param name="callback">A callback to receive progress.</param> /// <param name="callback">A callback to receive progress.</param>
/// <param name="errors">All collected errors during precompiling a resource.</param> /// <param name="errors">All collected errors during precompiling a resource.</param>
Ptr<GuiResourceFolder> Precompile(IGuiResourcePrecompileCallback* callback, GuiResourceError::List& errors); Ptr<GuiResourceFolder> Precompile(GuiResourceCpuArchitecture targetCpuArchitecture, IGuiResourcePrecompileCallback* callback, GuiResourceError::List& errors);
/// <summary>Initialize a precompiled resource.</summary> /// <summary>Initialize a precompiled resource.</summary>
/// <param name="usage">In which role an application is initializing this resource.</param> /// <param name="usage">In which role an application is initializing this resource.</param>
@@ -8379,25 +8437,6 @@ Resource Type Resolver
virtual IGuiResourceTypeResolver_IndirectLoad* IndirectLoad(){ return 0; } virtual IGuiResourceTypeResolver_IndirectLoad* IndirectLoad(){ return 0; }
}; };
/// <summary>Provide a context for resource precompiling</summary>
struct GuiResourcePrecompileContext
{
typedef collections::Dictionary<Ptr<DescriptableObject>, Ptr<DescriptableObject>> PropertyMap;
/// <summary>Progress callback.</summary>
workflow::IWfCompilerCallback* compilerCallback = nullptr;
/// <summary>The folder to contain compiled objects.</summary>
Ptr<GuiResourceFolder> targetFolder;
/// <summary>The root resource object.</summary>
GuiResource* rootResource = nullptr;
/// <summary>Indicate the pass index of this precompiling pass.</summary>
vint passIndex = -1;
/// <summary>The path resolver. This is only for delay load resource.</summary>
Ptr<GuiResourcePathResolver> resolver;
/// <summary>Additional properties for resource item contents</summary>
PropertyMap additionalProperties;
};
/// <summary> /// <summary>
/// Represents a precompiler for resources of a specified type. /// Represents a precompiler for resources of a specified type.
/// Current resources that needs precompiling: /// Current resources that needs precompiling:
@@ -8463,12 +8502,6 @@ Resource Type Resolver
virtual void OnPerResource(vint passIndex, Ptr<GuiResourceItem> resource) = 0; virtual void OnPerResource(vint passIndex, Ptr<GuiResourceItem> resource) = 0;
}; };
/// <summary>Provide a context for resource initializing</summary>
struct GuiResourceInitializeContext : GuiResourcePrecompileContext
{
GuiResourceUsage usage;
};
/// <summary> /// <summary>
/// Represents a precompiler for resources of a specified type. /// Represents a precompiler for resources of a specified type.
/// Current resources that needs precompiling: /// Current resources that needs precompiling:
@@ -21340,11 +21373,19 @@ using namespace vl::presentation::templates;
#endif #endif
// GacUI Compiler
extern int SetupGacGenNativeController();
// Windows
extern int SetupWindowsGDIRenderer(); extern int SetupWindowsGDIRenderer();
extern int SetupWindowsDirect2DRenderer(); extern int SetupWindowsDirect2DRenderer();
extern int SetupHostedWindowsGDIRenderer(); extern int SetupHostedWindowsGDIRenderer();
extern int SetupHostedWindowsDirect2DRenderer(); extern int SetupHostedWindowsDirect2DRenderer();
// Gtk
extern int SetupGtkRenderer();
// macOS
extern int SetupOSXCoreGraphicsRenderer(); extern int SetupOSXCoreGraphicsRenderer();
#endif #endif
+140 -101
View File
File diff suppressed because it is too large Load Diff
+9 -8
View File
@@ -39,6 +39,7 @@ namespace vl
extern Ptr<GuiResourceFolder> PrecompileResource( extern Ptr<GuiResourceFolder> PrecompileResource(
Ptr<GuiResource> resource, Ptr<GuiResource> resource,
GuiResourceCpuArchitecture targetCpuArchitecture,
IGuiResourcePrecompileCallback* callback, IGuiResourcePrecompileCallback* callback,
collections::List<GuiResourceError>& errors); collections::List<GuiResourceError>& errors);
@@ -781,10 +782,10 @@ Instance Loader
virtual GlobalStringKey GetTypeName() = 0; virtual GlobalStringKey GetTypeName() = 0;
virtual void ClearReflectionCache(); virtual void ClearReflectionCache();
virtual void GetRequiredPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames); virtual void GetRequiredPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames);
virtual void GetPropertyNames(const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames); virtual void GetPropertyNames(GuiResourcePrecompileContext& precompileContext, const TypeInfo& typeInfo, collections::List<GlobalStringKey>& propertyNames);
virtual void GetPairedProperties(const PropertyInfo& propertyInfo, collections::List<GlobalStringKey>& propertyNames); virtual void GetPairedProperties(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo, collections::List<GlobalStringKey>& propertyNames);
virtual Ptr<GuiInstancePropertyInfo> GetPropertyType(const PropertyInfo& propertyInfo); virtual Ptr<GuiInstancePropertyInfo> GetPropertyType(GuiResourcePrecompileContext& precompileContext, const PropertyInfo& propertyInfo);
virtual bool CanCreate(const TypeInfo& typeInfo); virtual bool CanCreate(const TypeInfo& typeInfo);
virtual Ptr<workflow::WfBaseConstructorCall> CreateRootInstance(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, const TypeInfo& typeInfo, ArgumentMap& arguments, GuiResourceError::List& errors); virtual Ptr<workflow::WfBaseConstructorCall> 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 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::analyzer::WfLexicalScopeManager> Workflow_TransferSharedManager(); extern Ptr<workflow::analyzer::WfLexicalScopeManager> Workflow_TransferSharedManager();
@@ -1166,9 +1167,9 @@ WorkflowCompiler (Compile)
} }
}; };
extern IGuiInstanceLoader::TypeInfo Workflow_AdjustPropertySearchType(types::ResolvingResult& resolvingResult, IGuiInstanceLoader::TypeInfo resolvedTypeInfo, GlobalStringKey prop); extern IGuiInstanceLoader::TypeInfo Workflow_AdjustPropertySearchType(GuiResourcePrecompileContext& precompileContext, 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<GuiAttSetterRepr::SetterValue> setter, collections::List<types::PropertyResolving>& possibleInfos, GuiResourceError::List& errors); extern bool Workflow_GetPropertyTypes(GuiResourcePrecompileContext& precompileContext, WString& errorPrefix, types::ResolvingResult& resolvingResult, IGuiInstanceLoader* loader, IGuiInstanceLoader::TypeInfo resolvedTypeInfo, GlobalStringKey prop, Ptr<GuiAttSetterRepr::SetterValue> setter, collections::List<types::PropertyResolving>& possibleInfos, GuiResourceError::List& errors);
extern Ptr<reflection::description::ITypeInfo> Workflow_GetSuggestedParameterType(reflection::description::ITypeDescriptor* typeDescriptor); extern Ptr<reflection::description::ITypeInfo> Workflow_GetSuggestedParameterType(GuiResourcePrecompileContext& precompileContext, reflection::description::ITypeDescriptor* typeDescriptor);
extern IGuiInstanceLoader::TypeInfo Workflow_CollectReferences(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GuiResourceError::List& errors); extern IGuiInstanceLoader::TypeInfo Workflow_CollectReferences(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GuiResourceError::List& errors);
extern void Workflow_GenerateCreating(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, Ptr<workflow::WfBlockStatement> statements, GuiResourceError::List& errors); extern void Workflow_GenerateCreating(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, Ptr<workflow::WfBlockStatement> statements, GuiResourceError::List& errors);
extern void Workflow_GenerateBindings(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, Ptr<workflow::WfBlockStatement> statements, GuiResourceError::List& errors); extern void Workflow_GenerateBindings(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, Ptr<workflow::WfBlockStatement> statements, GuiResourceError::List& errors);
+29 -40
View File
@@ -129,72 +129,61 @@ namespace vl
{ {
using namespace collections; using namespace collections;
class GlobalStorageManager /***********************************************************************
{ Helper Functions
public: ***********************************************************************/
Ptr<Dictionary<WString, GlobalStorage*>> storages;
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::GlobalStorage(const wchar_t* key) GlobalStorage::GlobalStorage()
{ {
InitializeGlobalStorage();
GetGlobalStorageManager().storages->Add(key, this);
} }
GlobalStorage::~GlobalStorage() GlobalStorage::~GlobalStorage()
{ {
} }
bool GlobalStorage::Cleared() bool GlobalStorage::IsInitialized()
{ {
return cleared; return initialized;
} }
/*********************************************************************** void GlobalStorage::EnsureInitialized()
Helper Functions
***********************************************************************/
GlobalStorage* GetGlobalStorage(const wchar_t* key)
{ {
return GetGlobalStorage(WString::Unmanaged(key)); if (!initialized)
}
GlobalStorage* GetGlobalStorage(const WString& key)
{
return GetGlobalStorageManager().storages->Get(key);
}
void InitializeGlobalStorage()
{
if (!GetGlobalStorageManager().storages)
{ {
GetGlobalStorageManager().storages = Ptr(new Dictionary<WString, GlobalStorage*>); initialized = true;
InitializeResource();
} }
} }
void FinalizeGlobalStorage() void GlobalStorage::EnsureFinalized()
{ {
if (GetGlobalStorageManager().storages) if (initialized)
{ {
for (vint i = 0; i < GetGlobalStorageManager().storages->Count(); i++) initialized = false;
{ FinalizeResource();
GetGlobalStorageManager().storages->Values().Get(i)->ClearResource();
}
GetGlobalStorageManager().storages = nullptr;
} }
} }
} }
+50 -35
View File
@@ -8094,55 +8094,70 @@ namespace vl
class GlobalStorage : public Object class GlobalStorage : public Object
{ {
private: private:
bool cleared = false; bool initialized = false;
protected:
virtual void InitializeResource() = 0;
virtual void FinalizeResource() = 0;
public: public:
NOT_COPYABLE(GlobalStorage); NOT_COPYABLE(GlobalStorage);
GlobalStorage(const wchar_t* key); GlobalStorage();
~GlobalStorage(); ~GlobalStorage();
bool Cleared(); bool IsInitialized();
virtual void ClearResource() = 0; void EnsureInitialized();
void EnsureFinalized();
}; };
extern GlobalStorage* GetGlobalStorage(const wchar_t* key); struct GlobalStorageDescriptor
extern GlobalStorage* GetGlobalStorage(const WString& key); {
GlobalStorage* globalStorage = nullptr;
GlobalStorageDescriptor* next = nullptr;
};
extern void RegisterStorageDescriptor(GlobalStorageDescriptor* globalStorageDescriptor);
extern void InitializeGlobalStorage();
/// <summary>Free all memories used by global storages.</summary> /// <summary>Free all memories used by global storages.</summary>
extern void FinalizeGlobalStorage(); extern void FinalizeGlobalStorage();
} }
#define BEGIN_GLOBAL_STORAGE_CLASS(NAME) \ #define BEGIN_GLOBAL_STORAGE_CLASS(NAME) \
class NAME : public vl::GlobalStorage \ class NAME \
{ \ : public vl::GlobalStorage \
public: \ , private vl::GlobalStorageDescriptor \
NAME() \ { \
:vl::GlobalStorage(L ## #NAME) \ public: \
{ \ NAME() \
InitializeClearResource(); \ { \
} \ globalStorage = this; \
~NAME() \ vl::RegisterStorageDescriptor(this); \
{ \ } \
if(!Cleared())ClearResource(); \ ~NAME() \
} \ { \
EnsureFinalized(); \
} \
#define INITIALIZE_GLOBAL_STORAGE_CLASS \ #define INITIALIZE_GLOBAL_STORAGE_CLASS \
void InitializeClearResource() \ protected: \
{ \ void InitializeResource() \
{ \
#define FINALIZE_GLOBAL_STORAGE_CLASS \ #define FINALIZE_GLOBAL_STORAGE_CLASS \
} \ } \
void ClearResource() \ protected: \
{ \ void FinalizeResource() \
{ \
#define END_GLOBAL_STORAGE_CLASS(NAME) \ #define END_GLOBAL_STORAGE_CLASS(NAME) \
} \ } \
}; \ }; \
NAME& Get##NAME() \ NAME& Get##NAME() \
{ \ { \
static NAME __global_storage_##NAME; \ static NAME __global_storage_##NAME; \
return __global_storage_##NAME; \ __global_storage_##NAME.EnsureInitialized(); \
} \ return __global_storage_##NAME; \
} \
#define EXTERN_GLOBAL_STORAGE_CLASS(NAME)\ #define EXTERN_GLOBAL_STORAGE_CLASS(NAME)\
class NAME;\ class NAME;\
Binary file not shown.
+4 -4
View File
@@ -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 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) 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 { $ResourceDumpFiles.Keys | ForEach-Object {
$input_file = $_ $input_file = $_
$output_file = $ResourceDumpFiles[$_] $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)) { if (-not (Test-Path -Path $output_file)) {
throw "Failed to dump GacUI Xml Resource File: " + $input_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, write all paths of named resource files in the correct build order to $OutputNames,
with all "resource_name=>resource_file_path" to $OutputMapping. with all "resource_name=>resource_file_path" to $OutputMapping.
The $OutputMapping will be consumed The $OutputMapping will be consumed
GacGen32.exe /P <resource-xml> <HERE> GacGen.exe /P32 <resource-xml> <HERE>
GacGen32.exe /P <resource-xml> <HERE> GacGen.exe /P64 <resource-xml> <HERE>
as an optional parameter as an optional parameter
#> #>
function EnumerateNamedResources([HashTable] $ResourceDumps, [String] $OutputNames, [String] $OutputMapping) { function EnumerateNamedResources([HashTable] $ResourceDumps, [String] $OutputNames, [String] $OutputMapping) {
+2 -2
View File
@@ -7,8 +7,8 @@ param (
Write-Host "Compiling GacUI Resource: $FileName ..." Write-Host "Compiling GacUI Resource: $FileName ..."
Remove-Item -Path "$($FileName).log" -Recurse -ErrorAction Ignore | Out-Null 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\GacGen.exe", "/P32 $FileName $MappingFileName"))
Start-Process-And-Wait (,("$PSScriptRoot\GacGen64.exe", "/P $FileName $MappingFileName")) Start-Process-And-Wait (,("$PSScriptRoot\GacGen.exe", "/P64 $FileName $MappingFileName"))
if (Test-Path -Path "$($FileName).log\x32\Errors.txt") { if (Test-Path -Path "$($FileName).log\x32\Errors.txt") {
Write-Host (Get-Content "$($FileName).log\x32\Errors.txt") -ForegroundColor Red -Separator "`r`n" Write-Host (Get-Content "$($FileName).log\x32\Errors.txt") -ForegroundColor Red -Separator "`r`n"
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.