Fixed registration of Ruby automation.

p.s.: embedding ruby on vc++ sucks.

Originally committed to SVN as r1996.
This commit is contained in:
Rodrigo Braz Monteiro 2008-03-09 19:01:54 +00:00
parent a72c3abb3c
commit 825b2f3af0
6 changed files with 90 additions and 31 deletions

View file

@ -34,7 +34,13 @@
// //
#ifdef WITH_RUBY #ifdef WITH_RUBY
#ifdef _MSC_VER
#pragma warning(disable: 4003)
#endif
#include "auto4_ruby.h" #include "auto4_ruby.h"
#include "auto4_ruby_factory.h"
#include "auto4_auto3.h" #include "auto4_auto3.h"
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_style.h" #include "ass_style.h"
@ -625,36 +631,6 @@ namespace Automation4 {
return dlg.RubyReadBack(); 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() RubyObjects::RubyObjects()
{ {
objects = rb_ary_new(); objects = rb_ary_new();
@ -713,6 +689,17 @@ namespace Automation4 {
} }
return backtr; 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 #endif // WITH_RUBY

View file

@ -34,6 +34,11 @@
// //
#ifdef WITH_RUBY #ifdef WITH_RUBY
#ifdef _MSC_VER
#pragma warning(disable: 4003)
#endif
#include "auto4_ruby.h" #include "auto4_ruby.h"
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_style.h" #include "ass_style.h"

View file

@ -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;
};
};

View file

@ -51,6 +51,9 @@
#ifdef WITH_AUTO3 #ifdef WITH_AUTO3
#include "auto4_auto3.h" #include "auto4_auto3.h"
#endif #endif
#ifdef WITH_RUBY
#include "auto4_ruby_factory.h"
#endif
/////////////// ///////////////
@ -86,6 +89,9 @@ void PluginManager::RegisterBuiltInPlugins() {
#endif #endif
#ifdef WITH_AUTO3 #ifdef WITH_AUTO3
new Automation4::Auto3ScriptFactory(); new Automation4::Auto3ScriptFactory();
#endif
#ifdef WITH_RUBY
new Automation4::RubyScriptFactory();
#endif #endif
} }

View file

@ -147,7 +147,7 @@
// Ruby // Ruby
#ifdef WITH_RUBY #ifdef WITH_RUBY
#pragma comment(lib,"ws2_32.lib") #pragma comment(lib,"ws2_32.lib")
#pragma comment(lib,"msvcr80-ruby19-static.lib") #pragma comment(lib,"msvcrt-ruby18-static.lib")
#endif #endif

View file

@ -678,6 +678,10 @@
RelativePath="..\..\aegisub\auto4_ruby_dialog.cpp" RelativePath="..\..\aegisub\auto4_ruby_dialog.cpp"
> >
</File> </File>
<File
RelativePath="..\..\aegisub\auto4_ruby_factory.h"
>
</File>
</Filter> </Filter>
<Filter <Filter
Name="Perl" Name="Perl"