Separate Auto3 lib seems to work on Windows now... changed the GNU build system a bit so it shouldn't try to build Auto3 yet. (Still some decisions to be made about where the lib should be placed and how it should be loaded.) Building on POSIX might break now...

Originally committed to SVN as r1159.
This commit is contained in:
Niels Martin Hansen 2007-05-03 17:57:21 +00:00
parent 9aceffb576
commit e659a5d12f
8 changed files with 333 additions and 1158 deletions

View File

@ -10,18 +10,13 @@ SUBDIRS = bitmaps posix
bin_PROGRAMS = aegisub
## My automake complains about these not being portable
## Perhaps it should somehow be moved to a shell script that generates an
## include, which is then included in source tarball?
## Similar to what the make-svn-rev-header.py scripts do currently.
## --jfs
SVNREV := $(shell svnversion | sed 's/[^0-9]//')
DARCSREV := $(strip $(shell head -n 1 ../_darcs/inventory 2>/dev/null))
REVISION := $(if $(SVNREV),-DBUILD_SVN_REVISION=$(SVNREV)) $(if $(DARCSREV),-DBUILD_DARCS)
BUILDINFO := -DBUILD_CREDIT="\"$(shell whoami)\"" $(REVISION)
AM_CPPFLAGST = -DAEGISUB -Iposix -include posix/defines.h $(BUILDINFO)
aegisub_LDADD = posix/libposix.a ../lua51/src/liblua.a ../FexTrackerSource/libfex.a ../csri/lib/.libs/libcsri.a
aegisub_LDADD = posix/libposix.a ../FexTrackerSource/libfex.a ../csri/lib/.libs/libcsri.a
aegisub_LDFLAGS =
if USE_LIBASS
@ -44,12 +39,18 @@ AUDIO_PLAYER += audio_player_pulse.cpp
aegisub_LDFLAGS += -lpulse
endif
if HAVE_RUBY
AUTO4RUBY=auto4_ruby_assfile.cpp auto4_ruby.cpp auto4_ruby_dialog.cpp
AUTOMATION = auto4_base.cpp
if WITH_AUTO4_LUA
AUTOMATION += auto4_lua.cpp auto4_lua_assfile.cpp auto4_lua_dialog.cpp auto4_lua_scriptreader.cpp
aegisub_LDADD += ../lua51/src/liblua.a
endif
if WITH_AUTO3
AUTOMATION += auto4_auto3.cpp
## FIXME: also link to whatever lib here
endif
if WITH_AUTO4_RUBY
AUTOMATION += auto4_ruby_assfile.cpp auto4_ruby.cpp auto4_ruby_dialog.cpp
AM_CPPFLAGS = $(shell ruby -r rbconfig -e "p '-I' + Config::CONFIG['rubylibdir'] + '/' + Config::CONFIG['arch'] ") $(AM_CPPFLAGST)
else
AUTO4RUBY=
AM_CPPFLAGS = $(AM_CPPFLAGST)
endif
if HAVE_HUNSPELL
@ -74,6 +75,11 @@ EXTRA_aegisub_SOURCES = \
audio_player_pulse.cpp \
audio_provider_avs.cpp \
audio_provider_lavc.cpp \
auto4_lua.cpp \
auto4_lua_assfile.cpp \
auto4_lua_dialog.cpp \
auto4_lua_scriptreader.cpp \
auto4_auto3.cpp \
auto4_ruby.cpp \
auto4_ruby_assfile.cpp \
auto4_ruby_dialog.cpp \
@ -101,7 +107,7 @@ EXTRA_aegisub_SOURCES = \
aegisub_SOURCES = \
$(AUDIO_PLAYER) \
$(AUTO4RUBY) \
$(AUTOMATION) \
$(HUNSPELL) \
$(LIBASS) \
$(FFMPEG) \
@ -124,12 +130,6 @@ aegisub_SOURCES = \
audio_provider_ram.cpp \
audio_provider_stream.cpp \
audio_spectrum.cpp \
auto4_base.cpp \
auto4_lua.cpp \
auto4_lua_assfile.cpp \
auto4_lua_dialog.cpp \
auto4_lua_scriptreader.cpp \
auto4_auto3.cpp \
avisynth_wrap.cpp \
base_grid.cpp \
browse_button.cpp \

File diff suppressed because it is too large Load Diff

View File

@ -40,11 +40,10 @@
#ifndef _AUTO4_AUTO3_H
#define _AUTO4_AUTO3_H
#include "auto4_base.h"
#include <wx/thread.h>
#include <wx/event.h>
#include "../lua51/src/lua.h"
#include "../lua51/src/lauxlib.h"
#include "auto4_base.h"
#include "../auto3/auto3.h"
#include "ass_file.h"
#include "ass_entry.h"
#include "ass_dialogue.h"
@ -54,61 +53,26 @@ namespace Automation4 {
class Auto3ProgressSink : public ProgressSink {
private:
lua_State *L;
Auto3Interpreter *script;
static int LuaSetStatus(lua_State *L);
static int LuaOutputDebug(lua_State *L);
static int LuaReportProgress(lua_State *L);
static void SetStatus(void *cbdata, const char *msg);
static void OutputDebug(void *cbdata, const char *msg);
static void ReportProgress(void *cbdata, float progress);
public:
Auto3ProgressSink(lua_State *_L, wxWindow *parent);
Auto3ProgressSink(Auto3Interpreter *_script, wxWindow *parent);
virtual ~Auto3ProgressSink();
static Auto3ProgressSink* GetObjPointer(lua_State *L, int idx);
};
enum Auto3ScriptConfigurationOptionKind {
COK_INVALID = 0,
COK_LABEL,
COK_TEXT,
COK_INT,
COK_FLOAT,
COK_BOOL,
COK_COLOUR,
COK_STYLE
};
struct Auto3ScriptConfigurationOption {
wxString name;
Auto3ScriptConfigurationOptionKind kind;
wxString label;
wxString hint;
union {
bool isset;
int intval;
double floatval;
} min, max;
struct {
wxString stringval;
int intval;
double floatval;
bool boolval;
AssColor colourval;
} default_val, value;
};
class Auto3ConfigDialog : public ScriptConfigDialog {
// copypasta
private:
bool present; // is there any configuration option set at all?
std::vector<Auto3ScriptConfigurationOption> options;
Auto3ConfigOption *options;
struct Control {
wxStaticText *label;
wxControl *control;
Auto3ScriptConfigurationOption *option;
Auto3ConfigOption *option;
Control() : label(0), control(0), option(0) {}
};
std::vector<Control> controls;
@ -117,9 +81,8 @@ namespace Automation4 {
wxWindow* CreateWindow(wxWindow *parent);
public:
Auto3ConfigDialog(lua_State *L);
Auto3ConfigDialog(Auto3Interpreter *script);
virtual ~Auto3ConfigDialog();
int LuaReadBack(lua_State *L); // read back internal structure to lua structures
void ReadBack(); // from auto4 base
@ -132,14 +95,14 @@ namespace Automation4 {
private:
Auto3ConfigDialog *config;
AssFile *_file;
lua_State *L;
Auto3Interpreter *script;
protected:
ScriptConfigDialog* GenerateConfigDialog(wxWindow *parent);
void Init();
public:
Auto3Filter(const wxString &_name, const wxString &_description, lua_State *_L);
Auto3Filter(const wxString &_name, const wxString &_description, Auto3Interpreter *_script);
void ProcessSubs(AssFile *subs, wxWindow *export_dialog);
};
@ -147,13 +110,29 @@ namespace Automation4 {
class Auto3ThreadedProcessor : public wxThread {
private:
lua_State *L;
Auto3Interpreter *script;
AssFile *file;
Auto3ConfigDialog *config;
Auto3ProgressSink *sink;
std::list<AssEntry*>::iterator style_pointer;
std::list<AssEntry*>::iterator subs_pointer;
static void ResetStylePointer(void *cbdata);
static void ResetSubsPointer(void *cbdata);
static void GetMetaInfo(void *cbdata, int *res_x, int *res_y);
static int GetNextStyle(
void *cbdata, char **name, char **fontname, int *fontsize, char **color1, char **color2, char **color3, char **color4,
int *bold, int *italic, int *underline, int *strikeout, float *scale_x, float *scale_y, float *spacing, float *angle,
int *borderstyle, float *outline, float *shadow, int *align, int *margin_l, int *margin_r, int *margin_v, int *encoding);
static int GetNextSub(void *cbdata, int *layer, int *start_time, int *end_time, char **style, char **actor,
int *margin_l, int *margin_r, int *margin_v, char **effect, char **text, int *comment);
static void StartSubsWrite(void *cbdata);
static void WriteSub(void *cbdata, int layer, int start_time, int end_time, const char *style, const char *actor,
int margin_l, int margin_r, int margin_v, const char *effect, const char *text, int comment);
public:
Auto3ThreadedProcessor(lua_State *_L, AssFile *_file, Auto3ConfigDialog *_config, Auto3ProgressSink *_sink);
Auto3ThreadedProcessor(Auto3Interpreter *_script, AssFile *_file, Auto3ConfigDialog *_config, Auto3ProgressSink *_sink);
virtual ExitCode Entry();
};
@ -161,19 +140,18 @@ namespace Automation4 {
class Auto3Script : public Script {
private:
Auto3Filter *filter;
lua_State *L;
Auto3Interpreter *script;
static int LuaTextExtents(lua_State *L);
static int LuaInclude(lua_State *L);
static int LuaColorstringToRGB(lua_State *L);
static int LuaFrameFromMs(lua_State *L);
static int LuaMsFromFrame(lua_State *L);
static filename_t ResolveInclude(void *cbdata, const char *incname);
static void TextExtents(void *cbdata, char *text, char *fontname, int fontsize, int bold, int italic,
int spacing, float scale_x, float scale_y, int encoding,
float *out_width, float *out_height, float *out_descent, float *out_extlead);
static int FrameFromMs(void *cbdata, int ms);
static int MsFromFrame(void *cbdata, int frame);
void Create();
void Destroy();
static Auto3Script* GetScriptObject(lua_State *L);
public:
Auto3Script(const wxString &filename);
virtual ~Auto3Script();

View File

@ -35,7 +35,9 @@
#include "auto4_lua.h"
#include "auto4_lua_scriptreader.h"
#if WITH_AUTO3 == 1
#include "auto4_auto3.h"
#endif
#include "ass_dialogue.h"
#include "ass_style.h"
#include "ass_file.h"
@ -199,7 +201,11 @@ namespace Automation4 {
lua_pop(L, 1); // just to avoid tripping the stackcheck in debug
// So this is an auto3 script...
// Throw it as an exception, the script factory manager will catch this and use the auto3 script instead of this script object
#if WITH_AUTO3 == 1
throw new Auto3Script(GetFilename());
#else
throw _T("Attempted loading an Automation 3 script, but Automation 3 support is not available");
#endif
}
}
lua_getglobal(L, "script_name");
@ -238,7 +244,8 @@ namespace Automation4 {
description = e;
}
catch (Script *s) {
throw;
// Be sure to properly propagate any scripts throw
throw s;
}
catch (...) {
Destroy();
@ -427,7 +434,7 @@ namespace Automation4 {
lua_pop(L, 1);
lua_gc(L, LUA_GCCOLLECT, 0);
return (wxThread::ExitCode)result;
return (wxThread::ExitCode)result; // works no matter what MSVC says
}
@ -479,7 +486,7 @@ namespace Automation4 {
lua_newtable(L);
for (size_t i = 0; i != ints.size(); ++i) {
lua_pushinteger(L, ints[i]+1);
lua_rawseti(L, -2, i+1);
lua_rawseti(L, -2, (int)i+1);
}
}

View File

@ -344,7 +344,7 @@ static int Auto3ParseConfigData(lua_State *L, struct Auto3Interpreter *script, c
// Create a new interpreter
AUTO3_API struct Auto3Interpreter *CreateAuto3Script(filename_t filename, char *prettyname, struct Auto3Callbacks *cb, char **error)
AUTO3_API struct Auto3Interpreter *CreateAuto3Script(const filename_t filename, const char *prettyname, struct Auto3Callbacks *cb, char **error)
{
struct Auto3Interpreter *script;
lua_State *L;
@ -521,6 +521,12 @@ AUTO3_API void *Auto3Malloc(size_t amount)
return malloc(amount);
}
// Convenience function, use this for duplicating strings this lib should own
AUTO3_API char *Auto3Strdup(const char *str)
{
return strdup(str);
}
// Our "free" function, free generated error messages with this
AUTO3_API void Auto3Free(void *ptr)
{

View File

@ -185,13 +185,15 @@ struct Auto3Interpreter {
// cb should point to an Auto3Callbacks struct filled in; a copy of this struct will be made
// error will be filled with any error message on fail, the application is responsible for freeing this string (use Auto3Free)
// Returns pointer to interpreter object if successful, otherwise NULL
AUTO3_API struct Auto3Interpreter *CreateAuto3Script(filename_t filename, char *prettyname, struct Auto3Callbacks *cb, char **error);
AUTO3_API struct Auto3Interpreter *CreateAuto3Script(const filename_t filename, const char *prettyname, struct Auto3Callbacks *cb, char **error);
// Release an interpreter
AUTO3_API void DestroyAuto3Script(struct Auto3Interpreter *script);
// Our "malloc" function, allocate memory for strings with this
AUTO3_API void *Auto3Malloc(size_t amount);
// Our "free" function, free generated error messages with this
// Convenience function, use this for duplicating strings this lib should own
AUTO3_API char *Auto3Strdup(const char *str);
// Our "free" function, free strings with this
AUTO3_API void Auto3Free(void *ptr);
// Start the script execution

View File

@ -62,11 +62,13 @@ static int LuaInclude(lua_State *L)
if (filename) {
// Load include
if (Auto3LuaLoad(L, filename, incname, &error)) {
free(filename);
lua_pushfstring(L, "Failed to include file '%s', error: %s", incname, error);
lua_error(L);
}
// Run include (don't protect, we're already in a protected environment, we'd just propagate it anyway)
lua_call(L, 0, 0);
free(filename);
} else {
lua_pushfstring(L, "Failed to resolve include file '%s'", incname);
lua_error(L);

View File

@ -206,8 +206,14 @@ AM_CONDITIONAL([HAVE_ALSA], [test "$with_alsa" != "no"])
AM_CONDITIONAL([HAVE_PORTAUDIO], [test "$with_portaudio" != "no"])
AM_CONDITIONAL([HAVE_PULSEAUDIO], [test "$with_pulseaudio" != "no"])
AM_CONDITIONAL([HAVE_HUNSPELL], [test "$with_hunspell" != "no"])
AM_CONDITIONAL([HAVE_RUBY], [test "$with_ruby" != "no"])
AM_CONDITIONAL([HAVE_FFMPEG], [test "$with_ffmpeg" != "no"])
dnl FIXME: These three should probably get proper --with flags,
dnl and Ruby also keep its detection (warn/fail if you have --with-ruby
dnl but the lib isn't detected.)
AM_CONDITIONAL([WITH_AUTO4_RUBY], [test "$with_ruby" != "no"])
AM_CONDITIONAL([WITH_AUTO4_LUA], [true])
dnl TODO: Make the auto3 lib build on non-Win32 so this can be true
AM_CONDITIONAL([WITH_AUTO3], [false])
AC_OUTPUT([
Makefile