From ed7a434a9e6c2a677a36c802f8ab08a2f5c0aab7 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sun, 9 Mar 2008 21:49:46 +0000 Subject: [PATCH] More messing around with Lua. Originally committed to SVN as r2001. --- aegisub/auto4_lua.cpp | 23 +++++++++ aegisub/auto4_lua.h | 26 ---------- aegisub/auto4_lua_factory.h | 56 ++++++++++++++++++++++ aegisub/plugin_manager.cpp | 2 +- build/aegisub_vs2005/aegisub_vs2005.vcproj | 4 ++ 5 files changed, 84 insertions(+), 27 deletions(-) create mode 100644 aegisub/auto4_lua_factory.h diff --git a/aegisub/auto4_lua.cpp b/aegisub/auto4_lua.cpp index b7e55a591..47c1056c9 100644 --- a/aegisub/auto4_lua.cpp +++ b/aegisub/auto4_lua.cpp @@ -36,6 +36,7 @@ #ifdef WITH_AUTO4_LUA #include "auto4_lua.h" +#include "auto4_lua_factory.h" #include "auto4_lua_scriptreader.h" #include "ass_dialogue.h" #include "ass_style.h" @@ -898,6 +899,28 @@ namespace Automation4 { return dlg.LuaReadBack(L); } + // Factory methods + LuaScriptFactory::LuaScriptFactory() {} + LuaScriptFactory::~LuaScriptFactory() {} + + void LuaScriptFactory::RegisterFactory () + { + engine_name = _T("Lua"); + filename_pattern = _T("*.lua"); + Register(this); + } + + Script* LuaScriptFactory::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 // WITH_AUTO4_LUA diff --git a/aegisub/auto4_lua.h b/aegisub/auto4_lua.h index 0e4ecfd62..81b2b7b4b 100644 --- a/aegisub/auto4_lua.h +++ b/aegisub/auto4_lua.h @@ -252,32 +252,6 @@ namespace Automation4 { void ProcessSubs(AssFile *subs, wxWindow *export_dialog); }; - // Factory class for Lua scripts - class LuaScriptFactory : public ScriptFactory { - public: - LuaScriptFactory() { } - - ~LuaScriptFactory() { } - - void RegisterFactory () - { - engine_name = _T("Lua"); - filename_pattern = _T("*.lua"); - Register(this); - } - - 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_lua_factory.h b/aegisub/auto4_lua_factory.h new file mode 100644 index 000000000..d640502e5 --- /dev/null +++ b/aegisub/auto4_lua_factory.h @@ -0,0 +1,56 @@ +// Copyright (c) 2006, Niels Martin Hansen +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// * Neither the name of the Aegisub Group nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// ----------------------------------------------------------------------------- +// +// AEGISUB +// +// Website: http://aegisub.cellosoft.com +// Contact: mailto:jiifurusu@gmail.com +// + +#pragma once + +#ifndef _AUTO4_LUA_FACTORY_H +#define _AUTO4_LUA_FACTORY_H + +#include "auto4_base.h" + +namespace Automation4 { + + // Factory class for Lua scripts + class LuaScriptFactory : public ScriptFactory { + public: + LuaScriptFactory(); + ~LuaScriptFactory(); + void RegisterFactory (); + Script* Produce(const wxString &filename) const; + }; + +}; + +#endif diff --git a/aegisub/plugin_manager.cpp b/aegisub/plugin_manager.cpp index 23fa2632c..61292e0e8 100644 --- a/aegisub/plugin_manager.cpp +++ b/aegisub/plugin_manager.cpp @@ -43,7 +43,7 @@ #include "subtitles_provider_manager.h" #include "spellchecker_manager.h" #ifdef WITH_AUTO4_LUA -#include "auto4_lua.h" +#include "auto4_lua_factory.h" #endif #ifdef WITH_PERL #include "auto4_perl.h" diff --git a/build/aegisub_vs2005/aegisub_vs2005.vcproj b/build/aegisub_vs2005/aegisub_vs2005.vcproj index 8f399f869..f70a4abc1 100644 --- a/build/aegisub_vs2005/aegisub_vs2005.vcproj +++ b/build/aegisub_vs2005/aegisub_vs2005.vcproj @@ -650,6 +650,10 @@ RelativePath="..\..\aegisub\auto4_lua_dialog.cpp" > + +