LuaPop() public static method

public static LuaPop ( LuaState L, int n ) : void
L LuaState
n int
return void
コード例 #1
0
        static CharPtr get_prompt(LuaState L, int firstline)
        {
            CharPtr p;

            Lua.LuaGetField(L, Lua.LUA_GLOBALSINDEX, (firstline != 0) ? "_PROMPT" : "_PROMPT2");
            p = Lua.LuaToString(L, -1);
            if (p == null)
            {
                p = ((firstline != 0) ? Lua.LUA_PROMPT : Lua.LUA_PROMPT2);
            }
            Lua.LuaPop(L, 1);              /* remove global */
            return(p);
        }
コード例 #2
0
 static int report(LuaState L, int status)
 {
     if ((status != 0) && !Lua.LuaIsNil(L, -1))
     {
         CharPtr msg = Lua.LuaToString(L, -1);
         if (msg == null)
         {
             msg = "(error object is not a string)";
         }
         l_message(progname, msg);
         Lua.LuaPop(L, 1);
     }
     return(status);
 }
コード例 #3
0
 static int incomplete(LuaState L, int status)
 {
     if (status == Lua.LUA_ERRSYNTAX)
     {
         uint    lmsg;
         CharPtr msg = Lua.LuaToLString(L, -1, out lmsg);
         CharPtr tp  = msg + lmsg - (Lua.strlen(Lua.LUA_QL("<eof>")));
         if (Lua.strstr(msg, Lua.LUA_QL("<eof>")) == tp)
         {
             Lua.LuaPop(L, 1);
             return(1);
         }
     }
     return(0);             /* else... */
 }
コード例 #4
0
 static int traceback(LuaState L)
 {
     if (Lua.LuaIsString(L, 1) == 0) /* 'message' not a string? */
     {
         return(1);                  /* keep it intact */
     }
     Lua.LuaGetField(L, Lua.LUA_GLOBALSINDEX, "debug");
     if (!Lua.LuaIsTable(L, -1))
     {
         Lua.LuaPop(L, 1);
         return(1);
     }
     Lua.LuaGetField(L, -1, "traceback");
     if (!Lua.LuaIsFunction(L, -1))
     {
         Lua.LuaPop(L, 2);
         return(1);
     }
     Lua.LuaPushValue(L, 1);            /* pass error message */
     Lua.LuaPushInteger(L, 2);          /* skip this function and traceback */
     Lua.LuaCall(L, 2, 1);              /* call debug.traceback */
     return(1);
 }
コード例 #5
0
        static int handle_script(LuaState L, string[] argv, int n)
        {
            int     status;
            CharPtr fname;
            int     narg = getargs(L, argv, n);          /* collect arguments */

            Lua.LuaSetGlobal(L, "arg");
            fname = argv[n];
            if (Lua.strcmp(fname, "-") == 0 && Lua.strcmp(argv[n - 1], "--") != 0)
            {
                fname = null;                  /* stdin */
            }
            status = Lua.LuaLLoadFile(L, fname);
            Lua.LuaInsert(L, -(narg + 1));
            if (status == 0)
            {
                status = docall(L, narg, 0);
            }
            else
            {
                Lua.LuaPop(L, narg);
            }
            return(report(L, status));
        }