From 825b2f3af0f6969fc3c77ae45d1e61af3b5568c0 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sun, 9 Mar 2008 19:01:54 +0000 Subject: [PATCH] Fixed registration of Ruby automation. p.s.: embedding ruby on vc++ sucks. Originally committed to SVN as r1996. --- aegisub/auto4_ruby.cpp | 47 +++++++----------- aegisub/auto4_ruby_assfile.cpp | 5 ++ aegisub/auto4_ruby_factory.h | 57 ++++++++++++++++++++++ aegisub/plugin_manager.cpp | 6 +++ aegisub/setup.cpp | 2 +- build/aegisub_vs2005/aegisub_vs2005.vcproj | 4 ++ 6 files changed, 90 insertions(+), 31 deletions(-) create mode 100644 aegisub/auto4_ruby_factory.h diff --git a/aegisub/auto4_ruby.cpp b/aegisub/auto4_ruby.cpp index df01b3c64..699c8fc45 100644 --- a/aegisub/auto4_ruby.cpp +++ b/aegisub/auto4_ruby.cpp @@ -34,7 +34,13 @@ // #ifdef WITH_RUBY + +#ifdef _MSC_VER +#pragma warning(disable: 4003) +#endif + #include "auto4_ruby.h" +#include "auto4_ruby_factory.h" #include "auto4_auto3.h" #include "ass_dialogue.h" #include "ass_style.h" @@ -625,36 +631,6 @@ namespace Automation4 { return dlg.RubyReadBack(); } - - // Factory class for Ruby scripts - // Not declared in header, since it doesn't need to be accessed from outside - // except through polymorphism - class RubyScriptFactory : public ScriptFactory { - public: - RubyScriptFactory() - { - engine_name = _T("Ruby"); - filename_pattern = _T("*.rb"); - Register(this); - } - - ~RubyScriptFactory() - { - } - - virtual Script* Produce(const wxString &filename) const - { - // Just check if file extension is .rb - // Reject anything else - if (filename.Right(3).Lower() == _T(".rb")) { - return new RubyScript(filename); - } else { - return 0; - } - } - }; - RubyScriptFactory _ruby_script_factory; - RubyObjects::RubyObjects() { objects = rb_ary_new(); @@ -713,6 +689,17 @@ namespace Automation4 { } return backtr; } + + Script* RubyScriptFactory::Produce(const wxString &filename) const + { + // Just check if file extension is .rb + // Reject anything else + if (filename.Right(3).Lower() == _T(".rb")) { + return new RubyScript(filename); + } else { + return 0; + } + } }; #endif // WITH_RUBY diff --git a/aegisub/auto4_ruby_assfile.cpp b/aegisub/auto4_ruby_assfile.cpp index fd2062527..b404a7bab 100644 --- a/aegisub/auto4_ruby_assfile.cpp +++ b/aegisub/auto4_ruby_assfile.cpp @@ -34,6 +34,11 @@ // #ifdef WITH_RUBY + +#ifdef _MSC_VER +#pragma warning(disable: 4003) +#endif + #include "auto4_ruby.h" #include "ass_dialogue.h" #include "ass_style.h" diff --git a/aegisub/auto4_ruby_factory.h b/aegisub/auto4_ruby_factory.h new file mode 100644 index 000000000..60614bd6f --- /dev/null +++ b/aegisub/auto4_ruby_factory.h @@ -0,0 +1,57 @@ +// Copyright (c) 2007, Patryk Pomykalski +// 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:pomyk@go2.pl +// + +#pragma once + +#include "auto4_base.h" + +namespace Automation4 { + // Factory class for Ruby scripts + class RubyScriptFactory : public ScriptFactory { + public: + RubyScriptFactory() + { + engine_name = _T("Ruby"); + filename_pattern = _T("*.rb"); + Register(this); + } + + ~RubyScriptFactory() + { + } + + Script* Produce(const wxString &filename) const; + }; +}; diff --git a/aegisub/plugin_manager.cpp b/aegisub/plugin_manager.cpp index 57c56ae01..32ac76c8b 100644 --- a/aegisub/plugin_manager.cpp +++ b/aegisub/plugin_manager.cpp @@ -51,6 +51,9 @@ #ifdef WITH_AUTO3 #include "auto4_auto3.h" #endif +#ifdef WITH_RUBY +#include "auto4_ruby_factory.h" +#endif /////////////// @@ -86,6 +89,9 @@ void PluginManager::RegisterBuiltInPlugins() { #endif #ifdef WITH_AUTO3 new Automation4::Auto3ScriptFactory(); +#endif +#ifdef WITH_RUBY + new Automation4::RubyScriptFactory(); #endif } diff --git a/aegisub/setup.cpp b/aegisub/setup.cpp index 1472f3b52..99fcf6566 100644 --- a/aegisub/setup.cpp +++ b/aegisub/setup.cpp @@ -147,7 +147,7 @@ // Ruby #ifdef WITH_RUBY #pragma comment(lib,"ws2_32.lib") -#pragma comment(lib,"msvcr80-ruby19-static.lib") +#pragma comment(lib,"msvcrt-ruby18-static.lib") #endif diff --git a/build/aegisub_vs2005/aegisub_vs2005.vcproj b/build/aegisub_vs2005/aegisub_vs2005.vcproj index c853f8bec..8f399f869 100644 --- a/build/aegisub_vs2005/aegisub_vs2005.vcproj +++ b/build/aegisub_vs2005/aegisub_vs2005.vcproj @@ -678,6 +678,10 @@ RelativePath="..\..\aegisub\auto4_ruby_dialog.cpp" > + +