2007-01-15 23:19:50 +01:00
|
|
|
// Copyright (c) 2006, 2007, Niels Martin Hansen
|
2006-12-28 22:18:35 +01:00
|
|
|
// 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.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
2006-12-28 22:18:35 +01:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file auto4_lua.cpp
|
|
|
|
/// @brief Lua 5.1-based scripting engine
|
|
|
|
/// @ingroup scripting
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2008-03-05 00:17:07 +01:00
|
|
|
#ifdef WITH_AUTO4_LUA
|
2007-12-31 07:46:22 +01:00
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#ifndef AGI_PRE
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include <wx/filefn.h>
|
|
|
|
#include <wx/filename.h>
|
|
|
|
#include <wx/log.h>
|
|
|
|
#include <wx/msgdlg.h>
|
|
|
|
#include <wx/window.h>
|
|
|
|
#endif
|
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
#include "ass_dialogue.h"
|
|
|
|
#include "ass_file.h"
|
|
|
|
#include "ass_override.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "ass_style.h"
|
|
|
|
#include "auto4_lua.h"
|
|
|
|
#include "auto4_lua_factory.h"
|
|
|
|
#include "auto4_lua_scriptreader.h"
|
2007-01-10 03:51:11 +01:00
|
|
|
#include "options.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "text_file_reader.h"
|
2007-02-15 14:02:36 +01:00
|
|
|
#include "vfr.h"
|
2008-09-10 18:53:23 +02:00
|
|
|
#include "video_context.h"
|
2008-03-05 05:10:20 +01:00
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
// This must be below the headers above.
|
2008-03-05 05:10:20 +01:00
|
|
|
#ifdef __WINDOWS__
|
2009-03-14 21:52:01 +01:00
|
|
|
#include "../../contrib/lua51/src/lualib.h"
|
|
|
|
#include "../../contrib/lua51/src/lauxlib.h"
|
2008-03-05 05:10:20 +01:00
|
|
|
#else
|
2009-09-10 15:06:40 +02:00
|
|
|
#include <lualib.h>
|
|
|
|
#include <lauxlib.h>
|
2008-03-05 05:10:20 +01:00
|
|
|
#endif
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2006-12-28 22:18:35 +01:00
|
|
|
namespace Automation4 {
|
|
|
|
|
|
|
|
// LuaStackcheck
|
|
|
|
|
2007-02-20 03:50:40 +01:00
|
|
|
//#ifdef _DEBUG
|
|
|
|
#if 0
|
2006-12-28 22:18:35 +01:00
|
|
|
struct LuaStackcheck {
|
|
|
|
lua_State *L;
|
|
|
|
int startstack;
|
2008-03-09 22:09:51 +01:00
|
|
|
void check_stack(int additional)
|
2006-12-28 22:18:35 +01:00
|
|
|
{
|
|
|
|
int top = lua_gettop(L);
|
|
|
|
if (top - additional != startstack) {
|
|
|
|
wxLogDebug(_T("Lua stack size mismatch."));
|
|
|
|
dump();
|
|
|
|
assert(top - additional == startstack);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void dump()
|
|
|
|
{
|
|
|
|
int top = lua_gettop(L);
|
|
|
|
wxLogDebug(_T("Dumping Lua stack..."));
|
|
|
|
for (int i = top; i > 0; i--) {
|
|
|
|
lua_pushvalue(L, i);
|
|
|
|
wxString type(lua_typename(L, lua_type(L, -1)), wxConvUTF8);
|
|
|
|
if (lua_isstring(L, i)) {
|
|
|
|
wxLogDebug(type + _T(": ") + wxString(lua_tostring(L, -1), wxConvUTF8));
|
|
|
|
} else {
|
|
|
|
wxLogDebug(type);
|
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
wxLogDebug(_T("--- end dump"));
|
|
|
|
}
|
|
|
|
LuaStackcheck(lua_State *_L) : L(_L) { startstack = lua_gettop(L); }
|
2008-03-09 22:09:51 +01:00
|
|
|
~LuaStackcheck() { check_stack(0); }
|
2006-12-28 22:18:35 +01:00
|
|
|
};
|
|
|
|
#else
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2006-12-28 22:18:35 +01:00
|
|
|
struct LuaStackcheck {
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param additional
|
|
|
|
///
|
2008-03-09 22:09:51 +01:00
|
|
|
void check_stack(int additional) { }
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
void dump() { }
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
LuaStackcheck(lua_State *L) { }
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
~LuaStackcheck() { }
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// LuaScript
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param filename
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
LuaScript::LuaScript(const wxString &filename)
|
|
|
|
: Script(filename)
|
|
|
|
, L(0)
|
|
|
|
{
|
2007-02-14 01:43:01 +01:00
|
|
|
Create();
|
2006-12-28 22:18:35 +01:00
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
LuaScript::~LuaScript()
|
|
|
|
{
|
|
|
|
if (L) Destroy();
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
void LuaScript::Create()
|
|
|
|
{
|
|
|
|
Destroy();
|
|
|
|
|
|
|
|
loaded = true;
|
|
|
|
|
|
|
|
try {
|
|
|
|
// create lua environment
|
|
|
|
L = lua_open();
|
|
|
|
LuaStackcheck _stackcheck(L);
|
|
|
|
|
|
|
|
// register standard libs
|
|
|
|
lua_pushcfunction(L, luaopen_base); lua_call(L, 0, 0);
|
|
|
|
lua_pushcfunction(L, luaopen_package); lua_call(L, 0, 0);
|
|
|
|
lua_pushcfunction(L, luaopen_string); lua_call(L, 0, 0);
|
|
|
|
lua_pushcfunction(L, luaopen_table); lua_call(L, 0, 0);
|
|
|
|
lua_pushcfunction(L, luaopen_math); lua_call(L, 0, 0);
|
2007-01-19 12:47:37 +01:00
|
|
|
lua_pushcfunction(L, luaopen_io); lua_call(L, 0, 0);
|
|
|
|
lua_pushcfunction(L, luaopen_os); lua_call(L, 0, 0);
|
2008-03-09 22:09:51 +01:00
|
|
|
_stackcheck.check_stack(0);
|
2006-12-28 22:18:35 +01:00
|
|
|
// dofile and loadfile are replaced with include
|
|
|
|
lua_pushnil(L);
|
|
|
|
lua_setglobal(L, "dofile");
|
|
|
|
lua_pushnil(L);
|
|
|
|
lua_setglobal(L, "loadfile");
|
|
|
|
lua_pushcfunction(L, LuaInclude);
|
|
|
|
lua_setglobal(L, "include");
|
|
|
|
|
|
|
|
// prepare stuff in the registry
|
|
|
|
// reference to the script object
|
|
|
|
lua_pushlightuserdata(L, this);
|
|
|
|
lua_setfield(L, LUA_REGISTRYINDEX, "aegisub");
|
|
|
|
// the "feature" table
|
|
|
|
// integer indexed, using same indexes as "features" vector in the base Script class
|
|
|
|
lua_newtable(L);
|
|
|
|
lua_setfield(L, LUA_REGISTRYINDEX, "features");
|
2008-03-09 22:09:51 +01:00
|
|
|
_stackcheck.check_stack(0);
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
// make "aegisub" table
|
|
|
|
lua_pushstring(L, "aegisub");
|
|
|
|
lua_newtable(L);
|
|
|
|
// aegisub.register_macro
|
|
|
|
lua_pushcfunction(L, LuaFeatureMacro::LuaRegister);
|
|
|
|
lua_setfield(L, -2, "register_macro");
|
|
|
|
// aegisub.register_filter
|
|
|
|
lua_pushcfunction(L, LuaFeatureFilter::LuaRegister);
|
|
|
|
lua_setfield(L, -2, "register_filter");
|
|
|
|
// aegisub.text_extents
|
|
|
|
lua_pushcfunction(L, LuaTextExtents);
|
|
|
|
lua_setfield(L, -2, "text_extents");
|
2007-02-15 13:56:36 +01:00
|
|
|
// VFR handling
|
|
|
|
lua_pushcfunction(L, LuaFrameFromMs);
|
|
|
|
lua_setfield(L, -2, "frame_from_ms");
|
|
|
|
lua_pushcfunction(L, LuaMsFromFrame);
|
|
|
|
lua_setfield(L, -2, "ms_from_frame");
|
2008-09-10 18:53:23 +02:00
|
|
|
lua_pushcfunction(L, LuaVideoSize);
|
|
|
|
lua_setfield(L, -2, "video_size");
|
2007-01-18 09:15:02 +01:00
|
|
|
// aegisub.lua_automation_version
|
|
|
|
lua_pushinteger(L, 4);
|
|
|
|
lua_setfield(L, -2, "lua_automation_version");
|
2006-12-28 22:18:35 +01:00
|
|
|
// store aegisub table to globals
|
|
|
|
lua_settable(L, LUA_GLOBALSINDEX);
|
2008-03-09 22:09:51 +01:00
|
|
|
_stackcheck.check_stack(0);
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
// load user script
|
2007-01-03 04:39:15 +01:00
|
|
|
LuaScriptReader script_reader(GetFilename());
|
2007-02-20 03:50:40 +01:00
|
|
|
if (lua_load(L, script_reader.reader_func, &script_reader, GetPrettyFilename().mb_str(wxConvUTF8))) {
|
2006-12-28 22:18:35 +01:00
|
|
|
wxString *err = new wxString(lua_tostring(L, -1), wxConvUTF8);
|
2007-02-14 01:43:01 +01:00
|
|
|
err->Prepend(_T("Error loading Lua script \"") + GetPrettyFilename() + _T("\":\n\n"));
|
2009-11-21 14:24:12 +01:00
|
|
|
throw err->wx_str();
|
2006-12-28 22:18:35 +01:00
|
|
|
}
|
2008-03-09 22:09:51 +01:00
|
|
|
_stackcheck.check_stack(1);
|
2006-12-28 22:18:35 +01:00
|
|
|
// and execute it
|
|
|
|
// this is where features are registered
|
2007-04-22 17:45:29 +02:00
|
|
|
// don't thread this, as there's no point in it and it seems to break on wx 2.8.3, for some reason
|
|
|
|
if (lua_pcall(L, 0, 0, 0)) {
|
|
|
|
// error occurred, assumed to be on top of Lua stack
|
|
|
|
wxString *err = new wxString(lua_tostring(L, -1), wxConvUTF8);
|
|
|
|
err->Prepend(_T("Error initialising Lua script \"") + GetPrettyFilename() + _T("\":\n\n"));
|
2009-11-21 14:24:12 +01:00
|
|
|
throw err->wx_str();
|
2006-12-28 22:18:35 +01:00
|
|
|
}
|
2008-03-09 22:09:51 +01:00
|
|
|
_stackcheck.check_stack(0);
|
2006-12-28 23:55:41 +01:00
|
|
|
lua_getglobal(L, "version");
|
|
|
|
if (lua_isnumber(L, -1)) {
|
|
|
|
if (lua_tointeger(L, -1) == 3) {
|
|
|
|
lua_pop(L, 1); // just to avoid tripping the stackcheck in debug
|
2007-01-15 23:19:50 +01:00
|
|
|
// 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
|
2007-08-17 04:16:41 +02:00
|
|
|
throw _T("Attempted to load an Automation 3 script as an Automation 4 Lua script. Automation 3 is no longer supported.");
|
2006-12-28 23:55:41 +01:00
|
|
|
}
|
|
|
|
}
|
2006-12-28 22:18:35 +01:00
|
|
|
lua_getglobal(L, "script_name");
|
|
|
|
if (lua_isstring(L, -1)) {
|
|
|
|
name = wxString(lua_tostring(L, -1), wxConvUTF8);
|
|
|
|
} else {
|
2007-02-14 01:43:01 +01:00
|
|
|
name = GetPrettyFilename();
|
2006-12-28 22:18:35 +01:00
|
|
|
}
|
|
|
|
lua_getglobal(L, "script_description");
|
|
|
|
if (lua_isstring(L, -1)) {
|
|
|
|
description = wxString(lua_tostring(L, -1), wxConvUTF8);
|
|
|
|
}
|
|
|
|
lua_getglobal(L, "script_author");
|
|
|
|
if (lua_isstring(L, -1)) {
|
|
|
|
author = wxString(lua_tostring(L, -1), wxConvUTF8);
|
|
|
|
}
|
|
|
|
lua_getglobal(L, "script_version");
|
|
|
|
if (lua_isstring(L, -1)) {
|
|
|
|
version = wxString(lua_tostring(L, -1), wxConvUTF8);
|
|
|
|
}
|
2006-12-28 23:55:41 +01:00
|
|
|
lua_pop(L, 5);
|
2006-12-28 22:18:35 +01:00
|
|
|
// if we got this far, the script should be ready
|
2008-03-09 22:09:51 +01:00
|
|
|
_stackcheck.check_stack(0);
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
}
|
2007-02-14 01:43:01 +01:00
|
|
|
catch (const char *e) {
|
|
|
|
Destroy();
|
|
|
|
loaded = false;
|
|
|
|
name = GetPrettyFilename();
|
|
|
|
description = wxString(e, wxConvUTF8);
|
|
|
|
}
|
|
|
|
catch (const wchar_t *e) {
|
|
|
|
Destroy();
|
|
|
|
loaded = false;
|
|
|
|
name = GetPrettyFilename();
|
|
|
|
description = e;
|
|
|
|
}
|
2007-04-29 02:59:19 +02:00
|
|
|
catch (Script *s) {
|
2007-05-03 19:57:21 +02:00
|
|
|
// Be sure to properly propagate any scripts throw
|
|
|
|
throw s;
|
2007-04-29 02:59:19 +02:00
|
|
|
}
|
2006-12-28 22:18:35 +01:00
|
|
|
catch (...) {
|
|
|
|
Destroy();
|
|
|
|
loaded = false;
|
2007-02-14 01:43:01 +01:00
|
|
|
name = GetPrettyFilename();
|
|
|
|
description = _T("Unknown error initialising Lua script");
|
2006-12-28 22:18:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @return
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
void LuaScript::Destroy()
|
|
|
|
{
|
|
|
|
// Assume the script object is clean if there's no Lua state
|
|
|
|
if (!L) return;
|
|
|
|
|
|
|
|
// remove features
|
|
|
|
for (int i = 0; i < (int)features.size(); i++) {
|
|
|
|
Feature *f = features[i];
|
|
|
|
delete f;
|
|
|
|
}
|
|
|
|
features.clear();
|
|
|
|
|
|
|
|
// delete environment
|
|
|
|
lua_close(L);
|
|
|
|
L = 0;
|
|
|
|
|
|
|
|
loaded = false;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
void LuaScript::Reload()
|
|
|
|
{
|
|
|
|
Destroy();
|
|
|
|
Create();
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
/// @return
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
LuaScript* LuaScript::GetScriptObject(lua_State *L)
|
|
|
|
{
|
|
|
|
lua_getfield(L, LUA_REGISTRYINDEX, "aegisub");
|
|
|
|
void *ptr = lua_touserdata(L, -1);
|
|
|
|
lua_pop(L, 1);
|
|
|
|
return (LuaScript*)ptr;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
/// @return
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
int LuaScript::LuaTextExtents(lua_State *L)
|
|
|
|
{
|
|
|
|
if (!lua_istable(L, 1)) {
|
|
|
|
lua_pushstring(L, "First argument to text_extents must be a table");
|
|
|
|
lua_error(L);
|
|
|
|
}
|
|
|
|
if (!lua_isstring(L, 2)) {
|
|
|
|
lua_pushstring(L, "Second argument to text_extents must be a string");
|
|
|
|
lua_error(L);
|
|
|
|
}
|
|
|
|
|
|
|
|
lua_pushvalue(L, 1);
|
|
|
|
AssEntry *et = LuaAssFile::LuaToAssEntry(L);
|
|
|
|
AssStyle *st = dynamic_cast<AssStyle*>(et);
|
|
|
|
lua_pop(L, 1);
|
|
|
|
if (!st) {
|
|
|
|
delete et; // Make sure to delete the "live" pointer
|
|
|
|
lua_pushstring(L, "Not a style entry");
|
|
|
|
lua_error(L);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString text(lua_tostring(L, 2), wxConvUTF8);
|
|
|
|
|
2007-01-15 18:02:39 +01:00
|
|
|
double width, height, descent, extlead;
|
2006-12-28 22:18:35 +01:00
|
|
|
if (!CalculateTextExtents(st, text, width, height, descent, extlead)) {
|
|
|
|
delete st;
|
|
|
|
lua_pushstring(L, "Some internal error occurred calculating text_extents");
|
|
|
|
lua_error(L);
|
|
|
|
}
|
|
|
|
delete st;
|
|
|
|
|
|
|
|
lua_pushnumber(L, width);
|
|
|
|
lua_pushnumber(L, height);
|
|
|
|
lua_pushnumber(L, descent);
|
|
|
|
lua_pushnumber(L, extlead);
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
/// @return
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
int LuaScript::LuaInclude(lua_State *L)
|
|
|
|
{
|
|
|
|
LuaScript *s = GetScriptObject(L);
|
|
|
|
|
|
|
|
if (!lua_isstring(L, 1)) {
|
|
|
|
lua_pushstring(L, "Argument to include must be a string");
|
|
|
|
lua_error(L);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
wxString fnames(lua_tostring(L, 1), wxConvUTF8);
|
|
|
|
|
|
|
|
wxFileName fname(fnames);
|
|
|
|
if (fname.GetDirCount() == 0) {
|
|
|
|
// filename only
|
|
|
|
fname = s->include_path.FindAbsoluteValidPath(fnames);
|
|
|
|
} else if (fname.IsRelative()) {
|
|
|
|
// relative path
|
|
|
|
wxFileName sfname(s->GetFilename());
|
|
|
|
fname.MakeAbsolute(sfname.GetPath(true));
|
|
|
|
} else {
|
|
|
|
// absolute path, do nothing
|
|
|
|
}
|
|
|
|
if (!fname.IsOk() || !fname.FileExists()) {
|
2007-02-14 01:43:01 +01:00
|
|
|
lua_pushfstring(L, "Lua include not found: %s", fnames.mb_str(wxConvUTF8).data());
|
2006-12-28 22:18:35 +01:00
|
|
|
lua_error(L);
|
|
|
|
}
|
|
|
|
|
2007-01-15 23:19:50 +01:00
|
|
|
LuaScriptReader script_reader(fname.GetFullPath());
|
2007-02-20 03:50:40 +01:00
|
|
|
if (lua_load(L, script_reader.reader_func, &script_reader, fname.GetFullName().mb_str(wxConvUTF8))) {
|
2007-02-14 01:43:01 +01:00
|
|
|
lua_pushfstring(L, "Error loading Lua include \"%s\":\n\n%s", fname.GetFullPath().mb_str(wxConvUTF8).data(), lua_tostring(L, -1));
|
2006-12-28 22:18:35 +01:00
|
|
|
lua_error(L);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
int pretop = lua_gettop(L) - 1; // don't count the function value itself
|
|
|
|
lua_call(L, 0, LUA_MULTRET);
|
|
|
|
return lua_gettop(L) - pretop;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
/// @return
|
|
|
|
///
|
2007-02-15 13:56:36 +01:00
|
|
|
int LuaScript::LuaFrameFromMs(lua_State *L)
|
|
|
|
{
|
|
|
|
int ms = (int)lua_tonumber(L, -1);
|
|
|
|
lua_pop(L, 1);
|
|
|
|
if (VFR_Output.IsLoaded()) {
|
|
|
|
lua_pushnumber(L, VFR_Output.GetFrameAtTime(ms, true));
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
lua_pushnil(L);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
/// @return
|
|
|
|
///
|
2007-02-15 13:56:36 +01:00
|
|
|
int LuaScript::LuaMsFromFrame(lua_State *L)
|
|
|
|
{
|
|
|
|
int frame = (int)lua_tonumber(L, -1);
|
|
|
|
lua_pop(L, 1);
|
|
|
|
if (VFR_Output.IsLoaded()) {
|
|
|
|
lua_pushnumber(L, VFR_Output.GetTimeAtFrame(frame, true));
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
lua_pushnil(L);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
/// @return
|
|
|
|
///
|
2008-09-10 18:53:23 +02:00
|
|
|
int LuaScript::LuaVideoSize(lua_State *L)
|
|
|
|
{
|
|
|
|
VideoContext *ctx = VideoContext::Get();
|
|
|
|
if (ctx->IsLoaded()) {
|
|
|
|
lua_pushnumber(L, ctx->GetWidth());
|
|
|
|
lua_pushnumber(L, ctx->GetHeight());
|
|
|
|
lua_pushnumber(L, ctx->GetAspectRatioValue());
|
|
|
|
lua_pushnumber(L, ctx->GetAspectRatioType());
|
|
|
|
return 4;
|
|
|
|
} else {
|
|
|
|
lua_pushnil(L);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
// LuaThreadedCall
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param _L
|
|
|
|
/// @param _nargs
|
|
|
|
/// @param _nresults
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
LuaThreadedCall::LuaThreadedCall(lua_State *_L, int _nargs, int _nresults)
|
|
|
|
: wxThread(wxTHREAD_JOINABLE)
|
|
|
|
, L(_L)
|
|
|
|
, nargs(_nargs)
|
|
|
|
, nresults(_nresults)
|
|
|
|
{
|
2007-01-10 03:51:11 +01:00
|
|
|
int prio = Options.AsInt(_T("Automation Thread Priority"));
|
|
|
|
if (prio == 0) prio = 50; // normal
|
|
|
|
else if (prio == 1) prio = 30; // below normal
|
|
|
|
else if (prio == 2) prio = 10; // lowest
|
|
|
|
else prio = 50; // fallback normal
|
2006-12-28 22:18:35 +01:00
|
|
|
Create();
|
2007-01-10 03:51:11 +01:00
|
|
|
SetPriority(prio);
|
2006-12-28 22:18:35 +01:00
|
|
|
Run();
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @return
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
wxThread::ExitCode LuaThreadedCall::Entry()
|
|
|
|
{
|
|
|
|
int result = lua_pcall(L, nargs, nresults, 0);
|
|
|
|
|
|
|
|
// see if there's a progress sink window to close
|
|
|
|
lua_getfield(L, LUA_REGISTRYINDEX, "progress_sink");
|
|
|
|
if (lua_isuserdata(L, -1)) {
|
|
|
|
LuaProgressSink *ps = LuaProgressSink::GetObjPointer(L, -1);
|
2007-02-20 03:50:40 +01:00
|
|
|
|
|
|
|
if (result) {
|
|
|
|
// if the call failed, log the error here
|
|
|
|
wxString errmsg(lua_tostring(L, -2), wxConvUTF8);
|
|
|
|
ps->AddDebugOutput(_T("\n\nLua reported a runtime error:\n"));
|
|
|
|
ps->AddDebugOutput(errmsg);
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
// don't bother protecting this with a mutex, it should be safe enough like this
|
|
|
|
ps->script_finished = true;
|
|
|
|
// tell wx to run its idle-events now, just to make the progress window notice earlier that we're done
|
|
|
|
wxWakeUpIdle();
|
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
|
|
|
|
lua_gc(L, LUA_GCCOLLECT, 0);
|
2008-01-20 23:38:07 +01:00
|
|
|
if (result) return (wxThread::ExitCode) 1;
|
|
|
|
else return 0;
|
2006-12-28 22:18:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// LuaFeature
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param _L
|
|
|
|
/// @param _featureclass
|
|
|
|
/// @param _name
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
LuaFeature::LuaFeature(lua_State *_L, ScriptFeatureClass _featureclass, const wxString &_name)
|
|
|
|
: Feature(_featureclass, _name)
|
|
|
|
, L(_L)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
void LuaFeature::RegisterFeature()
|
|
|
|
{
|
|
|
|
// get the LuaScript objects
|
|
|
|
lua_getfield(L, LUA_REGISTRYINDEX, "aegisub");
|
|
|
|
LuaScript *s = (LuaScript*)lua_touserdata(L, -1);
|
|
|
|
lua_pop(L, 1);
|
|
|
|
|
|
|
|
// add the Feature object
|
|
|
|
s->features.push_back(this);
|
|
|
|
|
|
|
|
// get the index+1 it was pushed into
|
|
|
|
myid = (int)s->features.size()-1;
|
|
|
|
|
|
|
|
// create table with the functions
|
|
|
|
// get features table
|
|
|
|
lua_getfield(L, LUA_REGISTRYINDEX, "features");
|
|
|
|
lua_pushvalue(L, -2);
|
|
|
|
lua_rawseti(L, -2, myid);
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param functionid
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
void LuaFeature::GetFeatureFunction(int functionid)
|
|
|
|
{
|
|
|
|
// get feature table
|
|
|
|
lua_getfield(L, LUA_REGISTRYINDEX, "features");
|
|
|
|
// get this feature's function pointers
|
|
|
|
lua_rawgeti(L, -1, myid);
|
|
|
|
// get pointer for validation function
|
|
|
|
lua_rawgeti(L, -1, functionid);
|
|
|
|
lua_remove(L, -2);
|
|
|
|
lua_remove(L, -2);
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param ints
|
|
|
|
///
|
2007-01-03 22:18:19 +01:00
|
|
|
void LuaFeature::CreateIntegerArray(const std::vector<int> &ints)
|
2006-12-28 22:18:35 +01:00
|
|
|
{
|
|
|
|
// create an array-style table with an integer vector in it
|
|
|
|
// leave the new table on top of the stack
|
|
|
|
lua_newtable(L);
|
2007-01-24 04:54:32 +01:00
|
|
|
for (size_t i = 0; i != ints.size(); ++i) {
|
2006-12-28 22:18:35 +01:00
|
|
|
lua_pushinteger(L, ints[i]+1);
|
2007-05-03 19:57:21 +02:00
|
|
|
lua_rawseti(L, -2, (int)i+1);
|
2006-12-28 22:18:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
void LuaFeature::ThrowError()
|
|
|
|
{
|
|
|
|
wxString err(lua_tostring(L, -1), wxConvUTF8);
|
|
|
|
lua_pop(L, 1);
|
|
|
|
wxLogError(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// LuaFeatureMacro
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
/// @return
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
int LuaFeatureMacro::LuaRegister(lua_State *L)
|
|
|
|
{
|
|
|
|
wxString _name(lua_tostring(L, 1), wxConvUTF8);
|
|
|
|
wxString _description(lua_tostring(L, 2), wxConvUTF8);
|
|
|
|
|
2007-01-03 05:31:17 +01:00
|
|
|
LuaFeatureMacro *macro = new LuaFeatureMacro(_name, _description, L);
|
2007-01-24 04:54:32 +01:00
|
|
|
(void)macro;
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param _name
|
|
|
|
/// @param _description
|
|
|
|
/// @param _L
|
|
|
|
///
|
2007-01-03 05:31:17 +01:00
|
|
|
LuaFeatureMacro::LuaFeatureMacro(const wxString &_name, const wxString &_description, lua_State *_L)
|
2007-01-15 16:27:13 +01:00
|
|
|
: Feature(SCRIPTFEATURE_MACRO, _name)
|
2007-01-03 05:31:17 +01:00
|
|
|
, FeatureMacro(_name, _description)
|
2007-01-15 16:27:13 +01:00
|
|
|
, LuaFeature(_L, SCRIPTFEATURE_MACRO, _name)
|
2006-12-28 22:18:35 +01:00
|
|
|
{
|
|
|
|
// new table for containing the functions for this feature
|
|
|
|
lua_newtable(L);
|
|
|
|
// store processing function
|
2007-01-03 05:31:17 +01:00
|
|
|
if (!lua_isfunction(L, 3)) {
|
2006-12-28 22:18:35 +01:00
|
|
|
lua_pushstring(L, "The macro processing function must be a function");
|
|
|
|
lua_error(L);
|
|
|
|
}
|
2007-01-03 05:31:17 +01:00
|
|
|
lua_pushvalue(L, 3);
|
2006-12-28 22:18:35 +01:00
|
|
|
lua_rawseti(L, -2, 1);
|
|
|
|
// and validation function
|
2007-01-03 05:31:17 +01:00
|
|
|
lua_pushvalue(L, 4);
|
2006-12-28 22:18:35 +01:00
|
|
|
no_validate = !lua_isfunction(L, -1);
|
|
|
|
lua_rawseti(L, -2, 2);
|
|
|
|
// make the feature known
|
|
|
|
RegisterFeature();
|
|
|
|
// and remove the feature function table again
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param subs
|
|
|
|
/// @param selected
|
|
|
|
/// @param active
|
|
|
|
/// @return
|
|
|
|
///
|
2007-01-03 22:18:19 +01:00
|
|
|
bool LuaFeatureMacro::Validate(AssFile *subs, const std::vector<int> &selected, int active)
|
2006-12-28 22:18:35 +01:00
|
|
|
{
|
|
|
|
if (no_validate)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
GetFeatureFunction(2); // 2 = validation function
|
|
|
|
|
|
|
|
// prepare function call
|
|
|
|
LuaAssFile *subsobj = new LuaAssFile(L, subs, false, false);
|
2007-01-24 04:54:32 +01:00
|
|
|
(void) subsobj;
|
2006-12-28 22:18:35 +01:00
|
|
|
CreateIntegerArray(selected); // selected items
|
|
|
|
lua_pushinteger(L, -1); // active line
|
|
|
|
|
|
|
|
// do call
|
2009-07-23 01:07:46 +02:00
|
|
|
int err = lua_pcall(L, 3, 1, 0);
|
|
|
|
bool result;
|
|
|
|
if (err) {
|
|
|
|
wxString errmsg(lua_tostring(L, -1), wxConvUTF8);
|
|
|
|
wxLogWarning(_T("Runtime error in Lua macro validation function:\n%s"), errmsg.c_str());
|
|
|
|
result = false;
|
|
|
|
} else {
|
|
|
|
result = !!lua_toboolean(L, -1);
|
|
|
|
}
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2009-07-23 01:07:46 +02:00
|
|
|
// clean up stack (result or error message)
|
2006-12-28 22:18:35 +01:00
|
|
|
lua_pop(L, 1);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param subs
|
|
|
|
/// @param selected
|
|
|
|
/// @param active
|
|
|
|
/// @param progress_parent
|
|
|
|
/// @return
|
|
|
|
///
|
2007-07-06 16:26:04 +02:00
|
|
|
void LuaFeatureMacro::Process(AssFile *subs, std::vector<int> &selected, int active, wxWindow * const progress_parent)
|
2006-12-28 22:18:35 +01:00
|
|
|
{
|
|
|
|
GetFeatureFunction(1); // 1 = processing function
|
|
|
|
|
|
|
|
// prepare function call
|
|
|
|
LuaAssFile *subsobj = new LuaAssFile(L, subs, true, true);
|
2007-01-24 04:54:32 +01:00
|
|
|
(void) subsobj;
|
2006-12-28 22:18:35 +01:00
|
|
|
CreateIntegerArray(selected); // selected items
|
|
|
|
lua_pushinteger(L, -1); // active line
|
|
|
|
|
|
|
|
LuaProgressSink *ps = new LuaProgressSink(L, progress_parent);
|
|
|
|
ps->SetTitle(GetName());
|
|
|
|
|
|
|
|
// do call
|
2007-07-06 16:26:04 +02:00
|
|
|
// 3 args: subtitles, selected lines, active line
|
|
|
|
// 1 result: new selected lines
|
|
|
|
LuaThreadedCall call(L, 3, 1);
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
ps->ShowModal();
|
|
|
|
wxThread::ExitCode code = call.Wait();
|
2007-07-06 16:26:04 +02:00
|
|
|
(void) code; // ignore
|
2007-02-20 03:50:40 +01:00
|
|
|
//if (code) ThrowError();
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2007-07-06 16:26:04 +02:00
|
|
|
// top of stack will be selected lines array, if any was returned
|
|
|
|
if (lua_istable(L, -1)) {
|
|
|
|
selected.clear();
|
|
|
|
selected.reserve(lua_objlen(L, -1));
|
|
|
|
lua_pushnil(L);
|
|
|
|
while (lua_next(L, -2)) {
|
|
|
|
if (lua_isnumber(L, -1)) {
|
|
|
|
selected.push_back(lua_tointeger(L, -1));
|
|
|
|
}
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
std::sort(selected.begin(), selected.end());
|
|
|
|
}
|
|
|
|
// either way, there will be something on the stack
|
|
|
|
lua_pop(L, 1);
|
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
delete ps;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// LuaFeatureFilter
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param _name
|
|
|
|
/// @param _description
|
|
|
|
/// @param merit
|
|
|
|
/// @param _L
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
LuaFeatureFilter::LuaFeatureFilter(const wxString &_name, const wxString &_description, int merit, lua_State *_L)
|
2007-01-15 16:27:13 +01:00
|
|
|
: Feature(SCRIPTFEATURE_FILTER, _name)
|
2006-12-28 22:18:35 +01:00
|
|
|
, FeatureFilter(_name, _description, merit)
|
2007-01-15 16:27:13 +01:00
|
|
|
, LuaFeature(_L, SCRIPTFEATURE_FILTER, _name)
|
2006-12-28 22:18:35 +01:00
|
|
|
{
|
|
|
|
// Works the same as in LuaFeatureMacro
|
|
|
|
lua_newtable(L);
|
|
|
|
if (!lua_isfunction(L, 4)) {
|
|
|
|
lua_pushstring(L, "The filter processing function must be a function");
|
|
|
|
lua_error(L);
|
|
|
|
}
|
|
|
|
lua_pushvalue(L, 4);
|
|
|
|
lua_rawseti(L, -2, 1);
|
|
|
|
lua_pushvalue(L, 5);
|
|
|
|
has_config = lua_isfunction(L, -1);
|
|
|
|
lua_rawseti(L, -2, 2);
|
|
|
|
RegisterFeature();
|
|
|
|
lua_pop(L, 1);
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
void LuaFeatureFilter::Init()
|
|
|
|
{
|
|
|
|
// Don't think there's anything to do here... (empty in auto3)
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
/// @return
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
int LuaFeatureFilter::LuaRegister(lua_State *L)
|
|
|
|
{
|
|
|
|
wxString _name(lua_tostring(L, 1), wxConvUTF8);
|
|
|
|
wxString _description(lua_tostring(L, 2), wxConvUTF8);
|
|
|
|
int _merit = lua_tointeger(L, 3);
|
|
|
|
|
|
|
|
LuaFeatureFilter *filter = new LuaFeatureFilter(_name, _description, _merit, L);
|
2007-01-24 04:54:32 +01:00
|
|
|
(void) filter;
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param subs
|
|
|
|
/// @param export_dialog
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
void LuaFeatureFilter::ProcessSubs(AssFile *subs, wxWindow *export_dialog)
|
|
|
|
{
|
2008-01-24 00:02:26 +01:00
|
|
|
LuaStackcheck stackcheck(L);
|
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
GetFeatureFunction(1); // 1 = processing function
|
2007-02-20 03:50:40 +01:00
|
|
|
assert(lua_isfunction(L, -1));
|
2008-03-09 22:09:51 +01:00
|
|
|
stackcheck.check_stack(1);
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
// prepare function call
|
|
|
|
// subtitles (undo doesn't make sense in exported subs, in fact it'll totally break the undo system)
|
|
|
|
LuaAssFile *subsobj = new LuaAssFile(L, subs, true/*allow modifications*/, false/*disallow undo*/);
|
2008-01-24 00:02:26 +01:00
|
|
|
assert(lua_isuserdata(L, -1));
|
2008-03-09 22:09:51 +01:00
|
|
|
stackcheck.check_stack(2);
|
2006-12-28 22:18:35 +01:00
|
|
|
// config
|
|
|
|
if (has_config && config_dialog) {
|
2008-01-24 00:02:26 +01:00
|
|
|
int results_produced = config_dialog->LuaReadBack(L);
|
|
|
|
assert(results_produced == 1);
|
2008-03-13 20:12:55 +01:00
|
|
|
(void) results_produced; // avoid warning on release builds
|
2006-12-28 22:18:35 +01:00
|
|
|
// TODO, write back stored options here
|
2007-02-20 03:50:40 +01:00
|
|
|
} else {
|
|
|
|
// no config so put an empty table instead
|
|
|
|
lua_newtable(L);
|
2006-12-28 22:18:35 +01:00
|
|
|
}
|
2008-01-24 00:02:26 +01:00
|
|
|
assert(lua_istable(L, -1));
|
2008-03-09 22:09:51 +01:00
|
|
|
stackcheck.check_stack(3);
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
LuaProgressSink *ps = new LuaProgressSink(L, export_dialog, false);
|
|
|
|
ps->SetTitle(GetName());
|
2008-03-09 22:09:51 +01:00
|
|
|
stackcheck.check_stack(3);
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
// do call
|
|
|
|
LuaThreadedCall call(L, 2, 0);
|
|
|
|
|
|
|
|
ps->ShowModal();
|
|
|
|
wxThread::ExitCode code = call.Wait();
|
2007-04-04 22:42:44 +02:00
|
|
|
(void) code;
|
2007-02-20 03:50:40 +01:00
|
|
|
//if (code) ThrowError();
|
2006-12-28 22:18:35 +01:00
|
|
|
|
2008-03-09 22:09:51 +01:00
|
|
|
stackcheck.check_stack(0);
|
2008-01-24 00:02:26 +01:00
|
|
|
|
|
|
|
// Just ensure that subsobj survives until here
|
|
|
|
(void) subsobj;
|
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
delete ps;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param parent
|
|
|
|
/// @return
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
ScriptConfigDialog* LuaFeatureFilter::GenerateConfigDialog(wxWindow *parent)
|
|
|
|
{
|
|
|
|
if (!has_config)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
GetFeatureFunction(2); // 2 = config dialog function
|
|
|
|
|
|
|
|
// prepare function call
|
|
|
|
// subtitles (don't allow any modifications during dialog creation, ideally the subs aren't even accessed)
|
|
|
|
LuaAssFile *subsobj = new LuaAssFile(L, AssFile::top, false/*allow modifications*/, false/*disallow undo*/);
|
2007-01-24 04:54:32 +01:00
|
|
|
(void) subsobj;
|
2006-12-28 22:18:35 +01:00
|
|
|
// stored options
|
|
|
|
lua_newtable(L); // TODO, nothing for now
|
|
|
|
|
|
|
|
// do call
|
2009-07-28 17:39:52 +02:00
|
|
|
int err = lua_pcall(L, 2, 1, 0);
|
|
|
|
if (err) {
|
|
|
|
wxString errmsg(lua_tostring(L, -1), wxConvUTF8);
|
|
|
|
wxLogWarning(_T("Runtime error in Lua macro validation function:\n%s"), errmsg.c_str());
|
|
|
|
lua_pop(L, 1); // remove error message
|
2007-02-20 03:50:40 +01:00
|
|
|
return config_dialog = 0;
|
2009-07-28 17:39:52 +02:00
|
|
|
} else {
|
|
|
|
// Create config dialogue from table on top of stack
|
|
|
|
return config_dialog = new LuaConfigDialog(L, false);
|
2007-02-20 03:50:40 +01:00
|
|
|
}
|
2006-12-28 22:18:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// LuaProgressSink
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param _L
|
|
|
|
/// @param parent
|
|
|
|
/// @param allow_config_dialog
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
LuaProgressSink::LuaProgressSink(lua_State *_L, wxWindow *parent, bool allow_config_dialog)
|
|
|
|
: ProgressSink(parent)
|
|
|
|
, L(_L)
|
|
|
|
{
|
|
|
|
LuaProgressSink **ud = (LuaProgressSink**)lua_newuserdata(L, sizeof(LuaProgressSink*));
|
|
|
|
*ud = this;
|
|
|
|
|
|
|
|
// register progress reporting stuff
|
|
|
|
lua_getglobal(L, "aegisub");
|
|
|
|
lua_newtable(L);
|
|
|
|
|
|
|
|
lua_pushvalue(L, -3);
|
|
|
|
lua_pushcclosure(L, LuaSetProgress, 1);
|
|
|
|
lua_setfield(L, -2, "set");
|
|
|
|
|
|
|
|
lua_pushvalue(L, -3);
|
|
|
|
lua_pushcclosure(L, LuaSetTask, 1);
|
|
|
|
lua_setfield(L, -2, "task");
|
|
|
|
|
|
|
|
lua_pushvalue(L, -3);
|
|
|
|
lua_pushcclosure(L, LuaSetTitle, 1);
|
|
|
|
lua_setfield(L, -2, "title");
|
|
|
|
|
|
|
|
lua_pushvalue(L, -3);
|
|
|
|
lua_pushcclosure(L, LuaGetCancelled, 1);
|
|
|
|
lua_setfield(L, -2, "is_cancelled");
|
|
|
|
|
|
|
|
lua_setfield(L, -2, "progress");
|
|
|
|
|
|
|
|
lua_newtable(L);
|
|
|
|
lua_pushvalue(L, -3);
|
|
|
|
lua_pushcclosure(L, LuaDebugOut, 1);
|
|
|
|
lua_setfield(L, -2, "out");
|
|
|
|
lua_setfield(L, -2, "debug");
|
2007-01-18 21:55:40 +01:00
|
|
|
lua_pushvalue(L, -2);
|
|
|
|
lua_pushcclosure(L, LuaDebugOut, 1);
|
|
|
|
lua_setfield(L, -2, "log");
|
2006-12-28 22:18:35 +01:00
|
|
|
|
|
|
|
if (allow_config_dialog) {
|
|
|
|
lua_newtable(L);
|
|
|
|
lua_pushvalue(L, -3);
|
|
|
|
lua_pushcclosure(L, LuaDisplayDialog, 1);
|
|
|
|
lua_setfield(L, -2, "display");
|
|
|
|
lua_setfield(L, -2, "dialog");
|
|
|
|
}
|
|
|
|
|
|
|
|
// reference so other objects can also find the progress sink
|
|
|
|
lua_pushvalue(L, -2);
|
|
|
|
lua_setfield(L, LUA_REGISTRYINDEX, "progress_sink");
|
|
|
|
|
|
|
|
lua_pop(L, 2);
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
LuaProgressSink::~LuaProgressSink()
|
|
|
|
{
|
|
|
|
// remove progress reporting stuff
|
|
|
|
lua_getglobal(L, "aegisub");
|
|
|
|
lua_pushnil(L);
|
|
|
|
lua_setfield(L, -2, "progress");
|
|
|
|
lua_pushnil(L);
|
|
|
|
lua_setfield(L, -2, "debug");
|
|
|
|
lua_pop(L, 1);
|
|
|
|
lua_pushnil(L);
|
|
|
|
lua_setfield(L, LUA_REGISTRYINDEX, "progress_sink");
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
/// @param idx
|
|
|
|
/// @return
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
LuaProgressSink* LuaProgressSink::GetObjPointer(lua_State *L, int idx)
|
|
|
|
{
|
|
|
|
assert(lua_type(L, idx) == LUA_TUSERDATA);
|
|
|
|
void *ud = lua_touserdata(L, idx);
|
|
|
|
return *((LuaProgressSink**)ud);
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
/// @return
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
int LuaProgressSink::LuaSetProgress(lua_State *L)
|
|
|
|
{
|
|
|
|
LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1));
|
|
|
|
float progress = lua_tonumber(L, 1);
|
|
|
|
ps->SetProgress(progress);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
/// @return
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
int LuaProgressSink::LuaSetTask(lua_State *L)
|
|
|
|
{
|
|
|
|
LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1));
|
|
|
|
wxString task(lua_tostring(L, 1), wxConvUTF8);
|
|
|
|
ps->SetTask(task);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
/// @return
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
int LuaProgressSink::LuaSetTitle(lua_State *L)
|
|
|
|
{
|
|
|
|
LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1));
|
|
|
|
wxString title(lua_tostring(L, 1), wxConvUTF8);
|
|
|
|
ps->SetTitle(title);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
/// @return
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
int LuaProgressSink::LuaGetCancelled(lua_State *L)
|
|
|
|
{
|
|
|
|
LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1));
|
|
|
|
lua_pushboolean(L, ps->cancelled);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
/// @return
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
int LuaProgressSink::LuaDebugOut(lua_State *L)
|
|
|
|
{
|
|
|
|
LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1));
|
2007-01-18 21:47:56 +01:00
|
|
|
|
|
|
|
// Check trace level
|
|
|
|
if (lua_isnumber(L, 1)) {
|
|
|
|
int level = lua_tointeger(L, 1);
|
|
|
|
if (level > ps->trace_level)
|
|
|
|
return 0;
|
|
|
|
// remove trace level
|
|
|
|
lua_remove(L, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only do format-string handling if there's more than one argument left
|
|
|
|
// (If there's more than one argument left, assume first is a format string and rest are format arguments)
|
|
|
|
if (lua_gettop(L) > 1) {
|
|
|
|
// Format the string
|
|
|
|
lua_getglobal(L, "string");
|
|
|
|
lua_getfield(L, -1, "format");
|
|
|
|
// Here stack contains format string, format arguments, 'string' table, format function
|
|
|
|
// remove 'string' table
|
|
|
|
lua_remove(L, -2);
|
|
|
|
// put the format function into place
|
|
|
|
lua_insert(L, 1);
|
|
|
|
// call format function
|
|
|
|
lua_call(L, lua_gettop(L)-1, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Top of stack is now a string to output
|
2006-12-28 22:18:35 +01:00
|
|
|
wxString msg(lua_tostring(L, 1), wxConvUTF8);
|
|
|
|
ps->AddDebugOutput(msg);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param L
|
|
|
|
/// @return
|
|
|
|
///
|
2006-12-28 22:18:35 +01:00
|
|
|
int LuaProgressSink::LuaDisplayDialog(lua_State *L)
|
|
|
|
{
|
|
|
|
LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1));
|
|
|
|
|
|
|
|
// Check that two arguments were actually given
|
|
|
|
// If only one, add another empty table for buttons
|
|
|
|
if (lua_gettop(L) == 1) {
|
|
|
|
lua_newtable(L);
|
|
|
|
}
|
|
|
|
// If more than two, remove the excess
|
|
|
|
if (lua_gettop(L) > 2) {
|
|
|
|
lua_settop(L, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send the "show dialog" event
|
|
|
|
// See comments in auto4_base.h for more info on this synchronisation
|
|
|
|
ShowConfigDialogEvent evt;
|
|
|
|
|
|
|
|
LuaConfigDialog dlg(L, true); // magically creates the config dialog structure etc
|
|
|
|
evt.config_dialog = &dlg;
|
|
|
|
|
|
|
|
wxSemaphore sema(0, 1);
|
|
|
|
evt.sync_sema = &sema;
|
|
|
|
|
|
|
|
ps->AddPendingEvent(evt);
|
|
|
|
|
|
|
|
sema.Wait();
|
|
|
|
|
|
|
|
// more magic: puts two values on stack: button pushed and table with control results
|
|
|
|
return dlg.LuaReadBack(L);
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief // Factory methods
|
|
|
|
///
|
2008-03-09 22:49:46 +01:00
|
|
|
LuaScriptFactory::LuaScriptFactory() {}
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
///
|
2008-03-09 22:49:46 +01:00
|
|
|
LuaScriptFactory::~LuaScriptFactory() {}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
///
|
2008-03-09 22:49:46 +01:00
|
|
|
void LuaScriptFactory::RegisterFactory ()
|
|
|
|
{
|
|
|
|
engine_name = _T("Lua");
|
|
|
|
filename_pattern = _T("*.lua");
|
|
|
|
Register(this);
|
|
|
|
}
|
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief DOCME
|
|
|
|
/// @param filename
|
|
|
|
///
|
2008-03-09 22:49:46 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-28 22:18:35 +01:00
|
|
|
};
|
2007-12-31 07:46:22 +01:00
|
|
|
|
2008-03-05 00:17:07 +01:00
|
|
|
#endif // WITH_AUTO4_LUA
|
2009-07-29 07:43:02 +02:00
|
|
|
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|