Changed Automation's autoload to ignore files of unknown extensions, instead of complaining about being unable to load them. This is necessary for the optional Perl support.

Originally committed to SVN as r1762.
This commit is contained in:
Rodrigo Braz Monteiro 2008-01-18 03:45:43 +00:00
parent 7ffc21cc7e
commit 85e100c4f7
4 changed files with 33 additions and 8 deletions

View File

@ -674,9 +674,12 @@ namespace Automation4 {
while (more) {
script_path.SetName(fn);
try {
Script *s = ScriptFactory::CreateFromFile(script_path.GetFullPath(), true);
Add(s);
if (!s->GetLoadedState()) error_count++;
wxString fullpath = script_path.GetFullPath();
if (ScriptFactory::CanHandleScriptFormat(fullpath)) {
Script *s = ScriptFactory::CreateFromFile(fullpath, true);
Add(s);
if (!s->GetLoadedState()) error_count++;
}
}
catch (const wchar_t *e) {
error_count++;
@ -764,6 +767,21 @@ namespace Automation4 {
return new UnknownScript(filename);
}
bool ScriptFactory::CanHandleScriptFormat(const wxString &filename)
{
// Just make this always return true to bitch about unknown script formats in autoload
if (!factories)
factories = new std::vector<ScriptFactory*>();
for (std::vector<ScriptFactory*>::iterator i = factories->begin(); i != factories->end(); ++i) {
wxString pattern = (*i)->GetFilenamePattern();
if (filename.Matches(pattern)) return true;
}
return false;
}
const std::vector<ScriptFactory*>& ScriptFactory::GetFactories()
{
if (!factories)

View File

@ -352,6 +352,7 @@ namespace Automation4 {
static void Register(ScriptFactory *factory);
static void Unregister(ScriptFactory *factory);
static Script* CreateFromFile(const wxString &filename, bool log_errors);
static bool CanHandleScriptFormat(const wxString &filename);
static const std::vector<ScriptFactory*>& GetFactories();
};

View File

@ -69,11 +69,13 @@ namespace Automation4 {
class PerlScriptFactory : public ScriptFactory {
private:
PerlInterpreter *parser;
bool loaded;
public:
PerlScriptFactory()
{
// Script engine properties
loaded = false;
engine_name = _T("Perl");
filename_pattern = _T("*") _T(PERL_SCRIPT_EXTENSION);
@ -103,16 +105,19 @@ namespace Automation4 {
// Let's register the perl script factory \o/
Register(this);
loaded = true;
}
~PerlScriptFactory()
{
// Perl interpreter deinitialization
perl_destruct(parser);
perl_free(parser);
if (loaded) {
perl_destruct(parser);
perl_free(parser);
#ifdef __VISUALC__
PERL_SYS_TERM();
PERL_SYS_TERM();
#endif
}
}
virtual Script* Produce(const wxString &filename) const

View File

@ -33,7 +33,7 @@
;
#define MyAppName "Aegisub"
#define MyAppVerName "Aegisub 2.00 alpha r1760"
#define MyAppVerName "Aegisub 2.00 alpha r1762"
#define MyAppPublisher "Aegisub Team"
#define MyAppURL "http://aegisub.net/"
#define MyAppExeName "Aegisub.exe"
@ -68,7 +68,7 @@ PrivilegesRequired=poweruser
DisableProgramGroupPage=true
UsePreviousGroup=false
AlwaysShowComponentsList=true
AppVersion=2.00 alpha r1760
AppVersion=2.00 alpha r1762
AppID={{24BC8B57-716C-444F-B46B-A3349B9164C5}
UninstallDisplayIcon={app}\Aegisub.exe
@ -115,6 +115,7 @@ DestDir: {app}\automation\autoload; Source: ..\automation\autoload\cleantags-aut
; perl
#if IncludePerl != 0
DestDir: {app}\automation\docs; Source: ..\automation\v4-docs\perl-api.txt; Flags: ignoreversion overwritereadonly uninsremovereadonly; Components: auto/perl; Attribs: readonly
DestDir: {app}\automation\include; Source: ..\automation\include\Aegisub.pm; Flags: ignoreversion overwritereadonly uninsremovereadonly; Components: auto/perl; Attribs: readonly
DestDir: {app}\automation\include; Source: ..\automation\include\Auto4Utils.pm; Flags: ignoreversion overwritereadonly uninsremovereadonly; Components: auto/perl; Attribs: readonly
DestDir: {app}\automation\include\Aegisub; Source: ..\automation\include\Aegisub\PerlConsole.pm; Flags: ignoreversion overwritereadonly uninsremovereadonly; Components: auto/perl; Attribs: readonly
DestDir: {app}\automation\include\Aegisub; Source: ..\automation\include\Aegisub\Script.pm; Flags: ignoreversion overwritereadonly uninsremovereadonly; Components: auto/perl; Attribs: readonly