Fixed bugs in autoperl: entry's class recognition misreading comments as key:value; crash if core modules are not found; description not set after script loading failure.

Originally committed to SVN as r1841.
This commit is contained in:
shb 2008-01-26 01:24:52 +00:00
parent d793010a6b
commit 7cff10cf5b
3 changed files with 20 additions and 21 deletions

View File

@ -57,8 +57,8 @@ namespace Automation4 {
// Perl -> C++ interface (XSUBS)
//
/* Aegisub */
XS(perl_log) // Aegisub::log()
/* package Aegisub */
XS(perl_log)
{
wxTRACE_FUNC(Aegisub::log);
dXSARGS;
@ -74,7 +74,7 @@ namespace Automation4 {
PerlLog(level, msg);
}
XS(perl_warning) // Aegisub::warn()
XS(perl_warning)
{
wxTRACE_FUNC(Aegisub::warn);
dXSARGS;
@ -87,7 +87,7 @@ namespace Automation4 {
}
XS(perl_text_extents) // Aegisub::text_extents
XS(perl_text_extents)
{
wxTRACE_FUNC(Aegisub::text_extents);
dXSARGS;

View File

@ -84,16 +84,14 @@ namespace Automation4 {
case ENTRY_ATTACHMENT: return _T("attachment");
default:
case ENTRY_BASE:
wxString data(entry->GetEntryData());
if(entry->group == _T("[Script Info]") && data.Matches(_T("*:*"))) return _T("info");
if(data == entry->group) return _T("head");
if(data.StartsWith(_T("Format:"))) return _T("format");
if(data.IsEmpty()) return _T("clear");
wxString data(entry->GetEntryData());
if(data.Trim(left).StartsWith(_T(";"))) return _T("comment");
else {
if(entry->group == _T("[Script Info]") && data.Matches(_T("*:*"))) return _T("info");
if(data == entry->group) return _T("head");
if(data.StartsWith(_T("Format:"))) return _T("format");
if(data.IsEmpty()) return _T("clear");
}
}
// Fallback

View File

@ -109,6 +109,7 @@ namespace Automation4 {
// 'Enclose' the script into its package
wxString _script = _T("package ") + package + _T(";\n")
_T("require Aegisub; require Aegisub::Script; require Aegisub::Progress;") // Core modules
_T("our ($_script_reload, $_script_path, $_script_package);\n") // Internal vars
_T("our ($script_name, $script_description, $script_author, $script_version);\n") // Package info
_T("open SCRIPT, $_script_path;\n") // Open the script file
@ -118,19 +119,19 @@ namespace Automation4 {
// Let's eval the 'boxed' script
eval_pv(_script.mb_str(wx2pl), 0);
SV *_err = newSVsv(ERRSV); // We need this later
// Done running
deactivate();
// and check on errors
if(SvTRUE(ERRSV)) {
description = wxString(SvPV_nolen(ERRSV), pl2wx);
wxLogError(description); // Remove?
if(SvTRUE(_err)) {
description = wxString(SvPV_nolen(_err), pl2wx);
//wxLogError(description); // Remove?
loaded = false;
}
else {
loaded = true;
}
// The script has done loading (running)
deactivate();
wxTRACE_RET(load);
}
@ -200,8 +201,8 @@ namespace Automation4 {
}
// Require the core modules
load_module(PERL_LOADMOD_NOIMPORT, newSVpvn("Aegisub", 7), NULL);
load_module(PERL_LOADMOD_NOIMPORT, newSVpvn("Aegisub::Progress", 17), NULL);
//load_module(PERL_LOADMOD_NOIMPORT, newSVpvn("Aegisub", 7), NULL);
//load_module(PERL_LOADMOD_NOIMPORT, newSVpvn("Aegisub::Progress", 17), NULL);
//load_module(PERL_LOADMOD_NOIMPORT, newSVpvn("Aegisub::Script", 15), NULL);
// Set the values of script vars