Rename Automation4::LuaStackcheck::check() to avoid clash with some define somewhere.

Originally committed to SVN as r1998.
This commit is contained in:
Niels Martin Hansen 2008-03-09 21:09:51 +00:00
parent f20fc57d22
commit d7ad931526
1 changed files with 14 additions and 14 deletions

View File

@ -69,7 +69,7 @@ namespace Automation4 {
struct LuaStackcheck { struct LuaStackcheck {
lua_State *L; lua_State *L;
int startstack; int startstack;
void check(int additional) void check_stack(int additional)
{ {
int top = lua_gettop(L); int top = lua_gettop(L);
if (top - additional != startstack) { if (top - additional != startstack) {
@ -95,11 +95,11 @@ namespace Automation4 {
wxLogDebug(_T("--- end dump")); wxLogDebug(_T("--- end dump"));
} }
LuaStackcheck(lua_State *_L) : L(_L) { startstack = lua_gettop(L); } LuaStackcheck(lua_State *_L) : L(_L) { startstack = lua_gettop(L); }
~LuaStackcheck() { check(0); } ~LuaStackcheck() { check_stack(0); }
}; };
#else #else
struct LuaStackcheck { struct LuaStackcheck {
void check(int additional) { } void check_stack(int additional) { }
void dump() { } void dump() { }
LuaStackcheck(lua_State *L) { } LuaStackcheck(lua_State *L) { }
~LuaStackcheck() { } ~LuaStackcheck() { }
@ -140,7 +140,7 @@ namespace Automation4 {
lua_pushcfunction(L, luaopen_math); lua_call(L, 0, 0); lua_pushcfunction(L, luaopen_math); lua_call(L, 0, 0);
lua_pushcfunction(L, luaopen_io); lua_call(L, 0, 0); lua_pushcfunction(L, luaopen_io); lua_call(L, 0, 0);
lua_pushcfunction(L, luaopen_os); lua_call(L, 0, 0); lua_pushcfunction(L, luaopen_os); lua_call(L, 0, 0);
_stackcheck.check(0); _stackcheck.check_stack(0);
// dofile and loadfile are replaced with include // dofile and loadfile are replaced with include
lua_pushnil(L); lua_pushnil(L);
lua_setglobal(L, "dofile"); lua_setglobal(L, "dofile");
@ -157,7 +157,7 @@ namespace Automation4 {
// integer indexed, using same indexes as "features" vector in the base Script class // integer indexed, using same indexes as "features" vector in the base Script class
lua_newtable(L); lua_newtable(L);
lua_setfield(L, LUA_REGISTRYINDEX, "features"); lua_setfield(L, LUA_REGISTRYINDEX, "features");
_stackcheck.check(0); _stackcheck.check_stack(0);
// make "aegisub" table // make "aegisub" table
lua_pushstring(L, "aegisub"); lua_pushstring(L, "aegisub");
@ -181,7 +181,7 @@ namespace Automation4 {
lua_setfield(L, -2, "lua_automation_version"); lua_setfield(L, -2, "lua_automation_version");
// store aegisub table to globals // store aegisub table to globals
lua_settable(L, LUA_GLOBALSINDEX); lua_settable(L, LUA_GLOBALSINDEX);
_stackcheck.check(0); _stackcheck.check_stack(0);
// load user script // load user script
LuaScriptReader script_reader(GetFilename()); LuaScriptReader script_reader(GetFilename());
@ -190,7 +190,7 @@ namespace Automation4 {
err->Prepend(_T("Error loading Lua script \"") + GetPrettyFilename() + _T("\":\n\n")); err->Prepend(_T("Error loading Lua script \"") + GetPrettyFilename() + _T("\":\n\n"));
throw err->c_str(); throw err->c_str();
} }
_stackcheck.check(1); _stackcheck.check_stack(1);
// and execute it // and execute it
// this is where features are registered // this is where features are registered
// don't thread this, as there's no point in it and it seems to break on wx 2.8.3, for some reason // don't thread this, as there's no point in it and it seems to break on wx 2.8.3, for some reason
@ -200,7 +200,7 @@ namespace Automation4 {
err->Prepend(_T("Error initialising Lua script \"") + GetPrettyFilename() + _T("\":\n\n")); err->Prepend(_T("Error initialising Lua script \"") + GetPrettyFilename() + _T("\":\n\n"));
throw err->c_str(); throw err->c_str();
} }
_stackcheck.check(0); _stackcheck.check_stack(0);
lua_getglobal(L, "version"); lua_getglobal(L, "version");
if (lua_isnumber(L, -1)) { if (lua_isnumber(L, -1)) {
if (lua_tointeger(L, -1) == 3) { if (lua_tointeger(L, -1) == 3) {
@ -230,7 +230,7 @@ namespace Automation4 {
} }
lua_pop(L, 5); lua_pop(L, 5);
// if we got this far, the script should be ready // if we got this far, the script should be ready
_stackcheck.check(0); _stackcheck.check_stack(0);
} }
catch (const char *e) { catch (const char *e) {
@ -652,13 +652,13 @@ namespace Automation4 {
GetFeatureFunction(1); // 1 = processing function GetFeatureFunction(1); // 1 = processing function
assert(lua_isfunction(L, -1)); assert(lua_isfunction(L, -1));
stackcheck.check(1); stackcheck.check_stack(1);
// prepare function call // prepare function call
// subtitles (undo doesn't make sense in exported subs, in fact it'll totally break the undo system) // 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*/); LuaAssFile *subsobj = new LuaAssFile(L, subs, true/*allow modifications*/, false/*disallow undo*/);
assert(lua_isuserdata(L, -1)); assert(lua_isuserdata(L, -1));
stackcheck.check(2); stackcheck.check_stack(2);
// config // config
if (has_config && config_dialog) { if (has_config && config_dialog) {
int results_produced = config_dialog->LuaReadBack(L); int results_produced = config_dialog->LuaReadBack(L);
@ -669,11 +669,11 @@ namespace Automation4 {
lua_newtable(L); lua_newtable(L);
} }
assert(lua_istable(L, -1)); assert(lua_istable(L, -1));
stackcheck.check(3); stackcheck.check_stack(3);
LuaProgressSink *ps = new LuaProgressSink(L, export_dialog, false); LuaProgressSink *ps = new LuaProgressSink(L, export_dialog, false);
ps->SetTitle(GetName()); ps->SetTitle(GetName());
stackcheck.check(3); stackcheck.check_stack(3);
// do call // do call
LuaThreadedCall call(L, 2, 0); LuaThreadedCall call(L, 2, 0);
@ -683,7 +683,7 @@ namespace Automation4 {
(void) code; (void) code;
//if (code) ThrowError(); //if (code) ThrowError();
stackcheck.check(0); stackcheck.check_stack(0);
// Just ensure that subsobj survives until here // Just ensure that subsobj survives until here
(void) subsobj; (void) subsobj;