forked from mia/Aegisub
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:
parent
d793010a6b
commit
7cff10cf5b
3 changed files with 20 additions and 21 deletions
|
@ -57,8 +57,8 @@ namespace Automation4 {
|
||||||
// Perl -> C++ interface (XSUBS)
|
// Perl -> C++ interface (XSUBS)
|
||||||
//
|
//
|
||||||
|
|
||||||
/* Aegisub */
|
/* package Aegisub */
|
||||||
XS(perl_log) // Aegisub::log()
|
XS(perl_log)
|
||||||
{
|
{
|
||||||
wxTRACE_FUNC(Aegisub::log);
|
wxTRACE_FUNC(Aegisub::log);
|
||||||
dXSARGS;
|
dXSARGS;
|
||||||
|
@ -74,7 +74,7 @@ namespace Automation4 {
|
||||||
PerlLog(level, msg);
|
PerlLog(level, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
XS(perl_warning) // Aegisub::warn()
|
XS(perl_warning)
|
||||||
{
|
{
|
||||||
wxTRACE_FUNC(Aegisub::warn);
|
wxTRACE_FUNC(Aegisub::warn);
|
||||||
dXSARGS;
|
dXSARGS;
|
||||||
|
@ -87,7 +87,7 @@ namespace Automation4 {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XS(perl_text_extents) // Aegisub::text_extents
|
XS(perl_text_extents)
|
||||||
{
|
{
|
||||||
wxTRACE_FUNC(Aegisub::text_extents);
|
wxTRACE_FUNC(Aegisub::text_extents);
|
||||||
dXSARGS;
|
dXSARGS;
|
||||||
|
|
|
@ -85,15 +85,13 @@ namespace Automation4 {
|
||||||
default:
|
default:
|
||||||
case ENTRY_BASE:
|
case ENTRY_BASE:
|
||||||
wxString data(entry->GetEntryData());
|
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");
|
|
||||||
|
|
||||||
if(data.Trim(left).StartsWith(_T(";"))) return _T("comment");
|
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
|
// Fallback
|
||||||
|
|
|
@ -109,6 +109,7 @@ namespace Automation4 {
|
||||||
|
|
||||||
// 'Enclose' the script into its package
|
// 'Enclose' the script into its package
|
||||||
wxString _script = _T("package ") + package + _T(";\n")
|
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_reload, $_script_path, $_script_package);\n") // Internal vars
|
||||||
_T("our ($script_name, $script_description, $script_author, $script_version);\n") // Package info
|
_T("our ($script_name, $script_description, $script_author, $script_version);\n") // Package info
|
||||||
_T("open SCRIPT, $_script_path;\n") // Open the script file
|
_T("open SCRIPT, $_script_path;\n") // Open the script file
|
||||||
|
@ -118,19 +119,19 @@ namespace Automation4 {
|
||||||
|
|
||||||
// Let's eval the 'boxed' script
|
// Let's eval the 'boxed' script
|
||||||
eval_pv(_script.mb_str(wx2pl), 0);
|
eval_pv(_script.mb_str(wx2pl), 0);
|
||||||
|
SV *_err = newSVsv(ERRSV); // We need this later
|
||||||
|
// Done running
|
||||||
|
deactivate();
|
||||||
// and check on errors
|
// and check on errors
|
||||||
if(SvTRUE(ERRSV)) {
|
if(SvTRUE(_err)) {
|
||||||
description = wxString(SvPV_nolen(ERRSV), pl2wx);
|
description = wxString(SvPV_nolen(_err), pl2wx);
|
||||||
wxLogError(description); // Remove?
|
//wxLogError(description); // Remove?
|
||||||
loaded = false;
|
loaded = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The script has done loading (running)
|
|
||||||
deactivate();
|
|
||||||
|
|
||||||
wxTRACE_RET(load);
|
wxTRACE_RET(load);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,8 +201,8 @@ namespace Automation4 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Require the core modules
|
// Require the core modules
|
||||||
load_module(PERL_LOADMOD_NOIMPORT, newSVpvn("Aegisub", 7), 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::Progress", 17), NULL);
|
||||||
//load_module(PERL_LOADMOD_NOIMPORT, newSVpvn("Aegisub::Script", 15), NULL);
|
//load_module(PERL_LOADMOD_NOIMPORT, newSVpvn("Aegisub::Script", 15), NULL);
|
||||||
|
|
||||||
// Set the values of script vars
|
// Set the values of script vars
|
||||||
|
|
Loading…
Reference in a new issue