AndreArpin <ar...@...> writes:

> 
> The following changes allow Lua programs to use the ... construct instead of 
> using the obsolete arg variable.
> 
int wxLuaState::RunFile(const wxString &filename, int nresults)
{
        lua_State* L = M_WXLSTATEDATA->m_lua_State;
    wxCHECK_MSG(Ok(), LUA_ERRRUN, wxT("Lua interpreter not created"));
    wxCHECK_MSG(!M_WXLSTATEDATA->m_wxlStateData->m_is_running, LUA_ERRRUN, 
wxT("Lua interpreter is already running"));

    M_WXLSTATEDATA->m_wxlStateData->m_debug_hook_break = false;
    M_WXLSTATEDATA->m_wxlStateData->m_is_running = true;

    int top = lua_GetTop();
    int status = luaL_LoadFile(wx2lua(filename));
    if (status == 0)
        {
                int narg = 0;
                lua_getglobal(L, "arg");
                if (lua_istable(L, -1)) {
                        for( ; ;narg++)
                        {
                                lua_pushinteger(L, narg + 1);
                                lua_gettable(L, -2);
                                if (lua_isnil(L, -1))
                                {
                                        lua_pop(L, 1);
                                        break;
                                }
                                lua_insert(L, -2);
                        }
                }
                lua_pop(L, 1);

        status = LuaPCall(narg, nresults); // no args and nresults
        }
    else
        SendLuaErrorEvent(status, top); // compilation error

    if (nresults == 0)
        lua_SetTop(top); // restore original top (removes err msg)

    M_WXLSTATEDATA->m_wxlStateData->m_debug_hook_break = false;
    M_WXLSTATEDATA->m_wxlStateData->m_is_running = false;

    return status;
}

This works. Sorry about the trial and errors.

Andre


------------------------------------------------------------------------------
Sell apps to millions through the Intel(R) Atom(Tm) Developer Program
Be part of this innovative community and reach millions of netbook users 
worldwide. Take advantage of special opportunities to increase revenue and 
speed time-to-market. Join now, and jumpstart your future.
http://p.sf.net/sfu/intel-atom-d2d
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to