Changed the way that automation factories are registered.

Originally committed to SVN as r1995.
This commit is contained in:
Rodrigo Braz Monteiro 2008-03-09 18:19:15 +00:00
parent 9f5d3e7a6e
commit a72c3abb3c
8 changed files with 105 additions and 87 deletions

View file

@ -736,31 +736,6 @@ namespace Automation4 {
Create(); 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 #endif // WITH_AUTO3

View file

@ -166,6 +166,29 @@ namespace Automation4 {
virtual void Reload(); 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 #endif

View file

@ -898,34 +898,6 @@ namespace Automation4 {
return dlg.LuaReadBack(L); 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 #endif // WITH_AUTO4_LUA

View file

@ -252,6 +252,30 @@ namespace Automation4 {
void ProcessSubs(AssFile *subs, wxWindow *export_dialog); 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 #endif

View file

@ -499,16 +499,7 @@ namespace Automation4 {
} }
/////////////////////// PerlScriptFactory::PerlScriptFactory()
// PerlScriptFactory
//
class PerlScriptFactory : public ScriptFactory {
private:
PerlInterpreter *parser;
bool loaded;
public:
PerlScriptFactory()
{ {
#ifdef WXTRACE_AUTOPERL #ifdef WXTRACE_AUTOPERL
// Add tracing of perl engine operations // Add tracing of perl engine operations
@ -547,7 +538,7 @@ namespace Automation4 {
loaded = true; loaded = true;
} }
~PerlScriptFactory() PerlScriptFactory::~PerlScriptFactory()
{ {
// Perl interpreter deinitialization // Perl interpreter deinitialization
if (loaded) { if (loaded) {
@ -556,21 +547,6 @@ namespace Automation4 {
PERL_SYS_TERM(); 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;
}; };

View file

@ -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;
}
}
};
}; };

View file

@ -42,6 +42,15 @@
#include "audio_player_manager.h" #include "audio_player_manager.h"
#include "subtitles_provider_manager.h" #include "subtitles_provider_manager.h"
#include "spellchecker_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 // Registers all built-in plugins
void PluginManager::RegisterBuiltInPlugins() { void PluginManager::RegisterBuiltInPlugins() {
if (!init) { if (!init) {
// Managers
VideoProviderFactoryManager::RegisterProviders(); VideoProviderFactoryManager::RegisterProviders();
AudioProviderFactoryManager::RegisterProviders(); AudioProviderFactoryManager::RegisterProviders();
AudioPlayerFactoryManager::RegisterProviders(); AudioPlayerFactoryManager::RegisterProviders();
SubtitlesProviderFactoryManager::RegisterProviders(); SubtitlesProviderFactoryManager::RegisterProviders();
SpellCheckerFactoryManager::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 // Done

View file

@ -623,14 +623,6 @@
<Filter <Filter
Name="Automation" Name="Automation"
> >
<File
RelativePath="..\..\aegisub\auto4_auto3.cpp"
>
</File>
<File
RelativePath="..\..\aegisub\auto4_auto3.h"
>
</File>
<File <File
RelativePath="..\..\aegisub\auto4_base.cpp" RelativePath="..\..\aegisub\auto4_base.cpp"
> >
@ -723,6 +715,18 @@
> >
</File> </File>
</Filter> </Filter>
<Filter
Name="Auto 3"
>
<File
RelativePath="..\..\aegisub\auto4_auto3.cpp"
>
</File>
<File
RelativePath="..\..\aegisub\auto4_auto3.h"
>
</File>
</Filter>
</Filter> </Filter>
<Filter <Filter
Name="Wrappers" Name="Wrappers"