Ejemplo n.º 1
0
        static int loadline(LuaState L)
        {
            int status;

            Lua.LuaSetTop(L, 0);
            if (pushline(L, 1) == 0)
            {
                return(-1);                 /* no input */
            }
            for (; ;)
            {              /* repeat until gets a complete line */
                status = Lua.LuaLLoadBuffer(L, Lua.LuaToString(L, 1), Lua.LuaStrLen(L, 1), "=stdin");
                if (incomplete(L, status) == 0)
                {
                    break;                              /* cannot try to add lines? */
                }
                if (pushline(L, 0) == 0)                /* no more input? */
                {
                    return(-1);
                }
                Lua.LuaPushLiteral(L, "\n");          /* add a new line... */
                Lua.LuaInsert(L, -2);                 /* ...between the two lines */
                Lua.LuaConcat(L, 3);                  /* join them */
            }
            Lua.lua_saveline(L, 1);
            Lua.LuaRemove(L, 1);              /* remove line */
            return(status);
        }
Ejemplo n.º 2
0
        static int docall(LuaState L, int narg, int clear)
        {
            int status;
            int base_ = Lua.LuaGetTop(L) - narg;  /* function index */

            Lua.LuaPushCFunction(L, traceback);   /* push traceback function */
            Lua.LuaInsert(L, base_);              /* put it under chunk and args */
            //signal(SIGINT, laction);
            status = Lua.LuaPCall(L, narg, ((clear != 0) ? 0 : Lua.LUA_MULTRET), base_);
            //signal(SIGINT, SIG_DFL);
            Lua.LuaRemove(L, base_);              /* remove traceback function */
            /* force a complete garbage collection in case of errors */
            if (status != 0)
            {
                Lua.LuaGC(L, Lua.LUA_GCCOLLECT, 0);
            }
            return(status);
        }