Update of /cvsroot/wxlua/wxLua/apps/wxluafreeze/src
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv3556/wxLua/apps/wxluafreeze/src
Modified Files:
wxluafreeze.cpp
Log Message:
* Changed wxLuaState_Type enum for wxLuaState(lua_State*, wxLuaState_Type)
Removed wxLUASTATE_USESTATE and you now | together wxLUASTATE_SETSTATE with
wxLUASTATE_OPENBINDINGS if you want the bindings opened.
Cleans up the creation of the wxLuaState so a precreated lua_State
should be able to be used easier.
- Remove poorly named wxLuaState::LuaError() and CheckRunError() and
replaced them with the C functions wxlua_errorinfo() and wxlua_LUA_ERR_msg()
respectively.
- Added wxlua_pushargs(wxChar**, int) for a standard way to push args
into Lua.
- Copy Lua's print() function to print_lua() instead of simply
overwriting it in case someone really wants to use it.
Index: wxluafreeze.cpp
===================================================================
RCS file: /cvsroot/wxlua/wxLua/apps/wxluafreeze/src/wxluafreeze.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** wxluafreeze.cpp 17 Jul 2007 23:09:16 -0000 1.13
--- wxluafreeze.cpp 15 Jan 2008 01:04:04 -0000 1.14
***************
*** 70,76 ****
int OnExit();
- // Push the program args into lua starting at arg start_n
- int PushArgs(wxChar **argv, int argc, int start_n);
-
// load the script from the end of this file
// if only_check then return LOADSCRIPT_MISSING if no script
--- 70,73 ----
***************
*** 148,152 ****
if (argc > 1)
{
! PushArgs(argv, argc, 1);
// just run it, lua gives a nice error message on failure
m_wxlState.RunFile(argv[1]);
--- 145,149 ----
if (argc > 1)
{
! wxlua_pushargs(m_wxlState.GetLuaState(), argv, argc, 1);
// just run it, lua gives a nice error message on failure
m_wxlState.RunFile(argv[1]);
***************
*** 167,171 ****
if (!script.IsEmpty())
{
! PushArgs(argv, argc, 0);
m_wxlState.RunString(script);
}
--- 164,168 ----
if (!script.IsEmpty())
{
! wxlua_pushargs(m_wxlState.GetLuaState(), argv, argc, 0);
m_wxlState.RunString(script);
}
***************
*** 186,213 ****
}
- // Push the program args into lua, see lua.c function
- // static int getargs (lua_State *L, char **argv, int n)
- int wxLuaFreezeApp::PushArgs(wxChar **argv, int argc, int start_n)
- {
- lua_State* L = m_wxlState.GetLuaState();
- int i = 0;
- int narg = argc - (start_n + 1); // number of arguments to the script
- luaL_checkstack(L, narg + 3, "too many arguments to script");
- for (i = start_n+1; i < argc; i++)
- lua_pushstring(L, wx2lua(argv[i]));
-
- lua_createtable(L, narg, start_n + 1);
-
- for (i = 0; i < argc; i++)
- {
- lua_pushstring(L, wx2lua(argv[i]));
- lua_rawseti(L, -2, i - start_n);
- }
-
- lua_setglobal(L, "arg");
-
- return narg;
- }
-
wxString wxLuaFreezeApp::LoadScript(const wxString& filename, bool only_check)
{
--- 183,186 ----
|