From a72c3abb3c7bbc42cc2a4eb6ef4cfeae7669d8cb Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sun, 9 Mar 2008 18:19:15 +0000 Subject: [PATCH] Changed the way that automation factories are registered. Originally committed to SVN as r1995. --- aegisub/auto4_auto3.cpp | 25 ------------------- aegisub/auto4_auto3.h | 23 ++++++++++++++++++ aegisub/auto4_lua.cpp | 28 ---------------------- aegisub/auto4_lua.h | 24 +++++++++++++++++++ aegisub/auto4_perl.cpp | 28 ++-------------------- aegisub/auto4_perl.h | 23 ++++++++++++++++++ aegisub/plugin_manager.cpp | 21 ++++++++++++++++ build/aegisub_vs2005/aegisub_vs2005.vcproj | 20 +++++++++------- 8 files changed, 105 insertions(+), 87 deletions(-) diff --git a/aegisub/auto4_auto3.cpp b/aegisub/auto4_auto3.cpp index 55c1d2121..4aec05c50 100644 --- a/aegisub/auto4_auto3.cpp +++ b/aegisub/auto4_auto3.cpp @@ -736,31 +736,6 @@ namespace Automation4 { Create(); } - - // Auto3ScriptFactory - - class Auto3ScriptFactory : public ScriptFactory { - public: - Auto3ScriptFactory() - { - engine_name = _T("Legacy Automation 3"); - filename_pattern = _T("*.auto3"); - Register(this); - } - - ~Auto3ScriptFactory() { } - - virtual Script* Produce(const wxString &filename) const - { - if (filename.Right(6).Lower() == _T(".auto3")) { - return new Auto3Script(filename); - } else { - return 0; - } - } - }; - Auto3ScriptFactory _auto3_script_factory; - }; #endif // WITH_AUTO3 diff --git a/aegisub/auto4_auto3.h b/aegisub/auto4_auto3.h index ced63766a..7957db7bd 100644 --- a/aegisub/auto4_auto3.h +++ b/aegisub/auto4_auto3.h @@ -166,6 +166,29 @@ namespace Automation4 { virtual void Reload(); }; + + // Auto3ScriptFactory + class Auto3ScriptFactory : public ScriptFactory { + public: + Auto3ScriptFactory() + { + engine_name = _T("Legacy Automation 3"); + filename_pattern = _T("*.auto3"); + Register(this); + } + + ~Auto3ScriptFactory() { } + + virtual Script* Produce(const wxString &filename) const + { + if (filename.Right(6).Lower() == _T(".auto3")) { + return new Auto3Script(filename); + } else { + return 0; + } + } + }; + }; #endif diff --git a/aegisub/auto4_lua.cpp b/aegisub/auto4_lua.cpp index 9111723c4..84c483cd1 100644 --- a/aegisub/auto4_lua.cpp +++ b/aegisub/auto4_lua.cpp @@ -898,34 +898,6 @@ namespace Automation4 { return dlg.LuaReadBack(L); } - - // Factory class for Lua scripts - // Not declared in header, since it doesn't need to be accessed from outside - // except through polymorphism - class LuaScriptFactory : public ScriptFactory { - public: - LuaScriptFactory() - { - engine_name = _T("Lua"); - filename_pattern = _T("*.lua"); - Register(this); - } - - ~LuaScriptFactory() { } - - virtual Script* Produce(const wxString &filename) const - { - // Just check if file extension is .lua - // Reject anything else - if (filename.Right(4).Lower() == _T(".lua")) { - return new LuaScript(filename); - } else { - return 0; - } - } - }; - LuaScriptFactory _lua_script_factory; - }; #endif // WITH_AUTO4_LUA diff --git a/aegisub/auto4_lua.h b/aegisub/auto4_lua.h index 81b2b7b4b..de2ae1b48 100644 --- a/aegisub/auto4_lua.h +++ b/aegisub/auto4_lua.h @@ -252,6 +252,30 @@ namespace Automation4 { void ProcessSubs(AssFile *subs, wxWindow *export_dialog); }; + // Factory class for Lua scripts + class LuaScriptFactory : public ScriptFactory { + public: + LuaScriptFactory() + { + engine_name = _T("Lua"); + filename_pattern = _T("*.lua"); + Register(this); + } + + ~LuaScriptFactory() { } + + virtual Script* Produce(const wxString &filename) const + { + // Just check if file extension is .lua + // Reject anything else + if (filename.Right(4).Lower() == _T(".lua")) { + return new LuaScript(filename); + } else { + return 0; + } + } + }; + }; #endif diff --git a/aegisub/auto4_perl.cpp b/aegisub/auto4_perl.cpp index 4300563a3..5b2426d1c 100644 --- a/aegisub/auto4_perl.cpp +++ b/aegisub/auto4_perl.cpp @@ -499,16 +499,7 @@ namespace Automation4 { } -/////////////////////// -// PerlScriptFactory -// - class PerlScriptFactory : public ScriptFactory { - private: - PerlInterpreter *parser; - bool loaded; - - public: - PerlScriptFactory() + PerlScriptFactory::PerlScriptFactory() { #ifdef WXTRACE_AUTOPERL // Add tracing of perl engine operations @@ -547,7 +538,7 @@ namespace Automation4 { loaded = true; } - ~PerlScriptFactory() + PerlScriptFactory::~PerlScriptFactory() { // Perl interpreter deinitialization if (loaded) { @@ -556,21 +547,6 @@ namespace Automation4 { PERL_SYS_TERM(); } } - - virtual Script* Produce(const wxString &filename) const - { - if(filename.EndsWith(_T(PERL_SCRIPT_EXTENSION))) { - return new PerlScript(filename); - } - else { - return 0; - } - } - }; - - // The one and only (thank goodness ¬.¬) perl engine!!! - PerlScriptFactory _perl_script_factory; - }; diff --git a/aegisub/auto4_perl.h b/aegisub/auto4_perl.h index cff6d74ca..9d7273bfb 100644 --- a/aegisub/auto4_perl.h +++ b/aegisub/auto4_perl.h @@ -240,6 +240,29 @@ namespace Automation4 { }; +/////////////////////// +// PerlScriptFactory +// + class PerlScriptFactory : public ScriptFactory { + private: + PerlInterpreter *parser; + bool loaded; + + public: + PerlScriptFactory(); + ~PerlScriptFactory(); + + virtual Script* Produce(const wxString &filename) const + { + if(filename.EndsWith(_T(PERL_SCRIPT_EXTENSION))) { + return new PerlScript(filename); + } + else { + return 0; + } + } + }; + }; diff --git a/aegisub/plugin_manager.cpp b/aegisub/plugin_manager.cpp index 2f10ac068..57c56ae01 100644 --- a/aegisub/plugin_manager.cpp +++ b/aegisub/plugin_manager.cpp @@ -42,6 +42,15 @@ #include "audio_player_manager.h" #include "subtitles_provider_manager.h" #include "spellchecker_manager.h" +#ifdef WITH_AUTO4_LUA +#include "auto4_lua.h" +#endif +#ifdef WITH_PERL +#include "auto4_perl.h" +#endif +#ifdef WITH_AUTO3 +#include "auto4_auto3.h" +#endif /////////////// @@ -61,11 +70,23 @@ PluginManager::~PluginManager() { // Registers all built-in plugins void PluginManager::RegisterBuiltInPlugins() { if (!init) { + // Managers VideoProviderFactoryManager::RegisterProviders(); AudioProviderFactoryManager::RegisterProviders(); AudioPlayerFactoryManager::RegisterProviders(); SubtitlesProviderFactoryManager::RegisterProviders(); SpellCheckerFactoryManager::RegisterProviders(); + + // Automation languages +#ifdef WITH_AUTO4_LUA + new Automation4::LuaScriptFactory(); +#endif +#ifdef WITH_PERL + new Automation4::PerlScriptFactory(); +#endif +#ifdef WITH_AUTO3 + new Automation4::Auto3ScriptFactory(); +#endif } // Done diff --git a/build/aegisub_vs2005/aegisub_vs2005.vcproj b/build/aegisub_vs2005/aegisub_vs2005.vcproj index 0bda8fd0f..c853f8bec 100644 --- a/build/aegisub_vs2005/aegisub_vs2005.vcproj +++ b/build/aegisub_vs2005/aegisub_vs2005.vcproj @@ -623,14 +623,6 @@ - - - - @@ -723,6 +715,18 @@ > + + + + + +