Exemple #1
0
        public static int luaD_rawrunprotected(lua_State L, Pfunc f, object ud)
        {
            ushort      oldnCcalls = L.nCcalls;
            lua_longjmp lj         = new lua_longjmp();

            lj.status   = LUA_OK;
            lj.previous = L.errorJmp;        /* chain new error handler */
            L.errorJmp  = lj;

            /*
             * LUAI_TRY(L, lj,
             * f(L, ud)
             * );
             * */
#if CATCH_EXCEPTIONS
            try
#endif
            {
                f(L, ud);
            }
#if CATCH_EXCEPTIONS
            catch (Exception e)
            {
                Debug.Assert(e is LuaException, "Exception isn't LuaException");
                Debug.WriteLine(e);   //FIXME:added for debug
                if (lj.status == 0)
                {
                    lj.status = -1;
                }
            }
#endif
            L.errorJmp = lj.previous;        /* restore old error handler */
            L.nCcalls  = oldnCcalls;
            return(lj.status);
        }
Exemple #2
0
 //#define LUAI_TRY(L,c,a) \
 //	try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; }
 //FIXME:added:
 public static void LUAI_TRY(lua_State L, lua_longjmp c, object a)
 {
     if (c.status == 0)
     {
         c.status = -1;
     }
 }
Exemple #3
0
        public static int luaD_rawrunprotected(lua_State L, Pfunc f, object ud)
        {
            lua_longjmp lj = new lua_longjmp();

            lj.status   = 0;
            lj.previous = L.errorJmp;              /* chain new error handler */
            L.errorJmp  = lj;

            /*
             * LUAI_TRY(L, lj,
             * f(L, ud)
             * );
             * */
            try
            {
                f(L, ud);
            }
            catch
            {
                if (lj.status == 0)
                {
                    lj.status = -1;
                }
            }

            L.errorJmp = lj.previous;              /* restore old error handler */
            return(lj.status);
        }
Exemple #4
0
        public static int luaD_rawrunprotected(lua_State L, Pfunc f, object ud)
        {
            lua_longjmp lj = new lua_longjmp();

            lj.status   = 0;
            lj.previous = L.errorJmp;        /* chain new error handler */
            L.errorJmp  = lj;

            /*
             * LUAI_TRY(L, lj,
             * f(L, ud)
             * );
             * */
#if CATCH_EXCEPTIONS
            try
#endif
            {
                f(L, ud);
            }
#if CATCH_EXCEPTIONS
            catch (LuaException)
            {
                if (lj.status == 0)
                {
                    lj.status = -1;
                }
            }
#endif
            L.errorJmp = lj.previous;        /* restore old error handler */
            return(lj.status);
        }
Exemple #5
0
    static int luaD_rawrunprotected(lua_State L, Pfunc f, object ud)
    {
        ushort      oldnCcalls = L.nCcalls;
        lua_longjmp lj         = new lua_longjmp();

        lj.status   = lua.LUA_OK;
        lj.previous = L.errorJmp;          /* chain new error handler */
        L.errorJmp  = lj;
        try {
            f(L, ud);
        } catch (Exception e) {
            Console.WriteLine("luaD_rawrunprotected Exception: {0}", e.Message);
        }
        L.errorJmp = lj.previous;          /* restore old error handler */
        L.nCcalls  = oldnCcalls;
        return(lj.status);
    }
Exemple #6
0
        public static int luaD_rawrunprotected(LuaState L, Pfunc f, object ud)
        {
            lua_longjmp lj = new lua_longjmp();

            lj.status   = 0;
            lj.previous = L.errorJmp;  /* chain new error handler */
            L.errorJmp  = lj;

            /*
             *    LUAI_TRY(L, lj,
             *          f(L, ud)
             *    );
             * */
#if CATCH_EXCEPTIONS
            try
#endif
            {
                f(L, ud);
            }
#if CATCH_EXCEPTIONS
            catch (LuaException ex)
            {
                Debug.WriteLine("Caught exception: " + ex.ToString());
                Debug.WriteLine("Status: " + ex.c.status);

                if (lj.status == 0)
                {
                    lj.status = -1;
                }
            }

            /*catch (Exception ex)
             * {
             *  Debug.WriteLine("Caught exception: " + ex.ToString());
             *
             *  throw ex;
             *  //if (lj.status == 0)
             *  //    lj.status = -1;
             * }*/
#endif
            L.errorJmp = lj.previous;  /* restore old error handler */
            return(lj.status);
        }
Exemple #7
0
        public static int luaD_rawrunprotected(lua_State L, Pfunc f, object ud)
        {
            lua_longjmp lj = new lua_longjmp();

            lj.status   = 0;
            lj.previous = L.errorJmp;        /* chain new error handler */
            L.errorJmp  = lj;

            /*
             * LUAI_TRY(L, lj,
             * f(L, ud)
             * );
             * */
#if CATCH_EXCEPTIONS
            try
#endif
            {
                f(L, ud);
            }
#if CATCH_EXCEPTIONS
            catch (Exception e)
            {
                Logger.Log(LogType.CONSOLE, LogLevel.ERROR, e.Message);
                if (e.StackTrace != null)
                {
                    String[] arr = e.StackTrace.Split(new String[] { Environment.NewLine }, StringSplitOptions.None);
                    foreach (String s in arr)
                    {
                        Logger.Log(LogType.CONSOLE, LogLevel.ERROR, s);
                    }
                }

                if (lj.status == 0)
                {
                    lj.status = -1;
                }
            }
#endif
            L.errorJmp = lj.previous;        /* restore old error handler */
            return(lj.status);
        }
 /*
  * @@ LUAI_THROW/LUAI_TRY define how Lua does exception handling.
  ** CHANGE them if you prefer to use longjmp/setjmp even with C++
  ** or if want/don't to use _longjmp/_setjmp instead of regular
  ** longjmp/setjmp. By default, Lua handles errors with exceptions when
  ** compiling as C++ code, with _longjmp/_setjmp when asked to use them,
  ** and with longjmp/setjmp otherwise.
  */
 //#if defined(__cplusplus)
 ///* C++ exceptions */
 public static void LUAI_THROW(lua_State L, lua_longjmp c)
 {
     throw new LuaException(L, c);
 }
 public LuaException(lua_State L, lua_longjmp c)
 {
     this.L = L; this.c = c;
 }
Exemple #10
0
        public static int luaD_rawrunprotected (lua_State L, Pfunc f, object ud) {
            lua_longjmp lj = new lua_longjmp();
            lj.status = 0;
            lj.previous = L.errorJmp;  /* chain new error handler */
            L.errorJmp = lj;
            /*
		  LUAI_TRY(L, lj,
			f(L, ud)
		  );
             * */
            #if CATCH_EXCEPTIONS
            try
                #endif
            {
                f(L, ud);
            }
            #if CATCH_EXCEPTIONS
            catch
            {
                if (lj.status == 0)
                    lj.status = -1;
            }
            #endif
            L.errorJmp = lj.previous;  /* restore old error handler */
            return lj.status;
        }
Exemple #11
0
        public static int luaD_rawrunprotected(LuaState L, Pfunc f, object ud)
        {
            lua_longjmp lj = new lua_longjmp();
            lj.status = 0;
            lj.previous = L.errorJmp;  /* chain new error handler */
            L.errorJmp = lj;
            /*
		  LUAI_TRY(L, lj,
			f(L, ud)
		  );
             * */
#if CATCH_EXCEPTIONS
            try
#endif
            {
                f(L, ud);
            }
#if CATCH_EXCEPTIONS
            catch (LuaException ex)
            {
                Debug.WriteLine("Caught exception: " + ex.ToString());
                Debug.WriteLine("Status: " + ex.c.status);
                
                if (lj.status == 0)
                    lj.status = -1;
            }
            /*catch (Exception ex)
            {
                Debug.WriteLine("Caught exception: " + ex.ToString());

                throw ex;
                //if (lj.status == 0)
                //    lj.status = -1;
            }*/
#endif
            L.errorJmp = lj.previous;  /* restore old error handler */
            return lj.status;
        }
 public static int luaD_rawrunprotected(lua_State L, Pfunc f, object ud)
 {
     lua_longjmp lj = new lua_longjmp();
       lj.status = 0;
       lj.previous = L.errorJmp;  /* chain new error handler */
       L.errorJmp = lj;
     /*
       LUAI_TRY(L, lj,
     f(L, ud)
       );
      * */
     #if CATCH_EXCEPTIONS
       try
     #endif
       {
       f(L, ud);
       }
     #if CATCH_EXCEPTIONS
       catch(LuaException e)
       {
       if (lj.status == 0)
           lj.status = -1;
       }
       catch(Exception e) {
         Console.WriteLine("uncaught {0}",e);
         Console.WriteLine("at {0} {1}",c_lexstate.source,c_lexstate.linenumber);
     }
     #endif
       L.errorJmp = lj.previous;  /* restore old error handler */
       return lj.status;
 }