コード例 #1
0
ファイル: ldo.c.cs プロジェクト: weimingtom/KopiLuaCompare
        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);
        }
コード例 #2
0
ファイル: ldo.c.cs プロジェクト: weimingtom/KopiLuaCompare
 //#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;
     }
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #5
0
ファイル: ldo.cs プロジェクト: Joky8926/Lua5_3ForCSharp
    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);
    }
コード例 #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);
        }
コード例 #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);
        }
コード例 #8
0
 /*
  * @@ 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);
 }
コード例 #9
0
 public LuaException(lua_State L, lua_longjmp c)
 {
     this.L = L; this.c = c;
 }
コード例 #10
0
ファイル: ldo.cs プロジェクト: mlnlover11/KopiLua-v5.1.5
        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;
        }
コード例 #11
0
ファイル: ldo.cs プロジェクト: chenzuo/SharpLua
        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;
        }
コード例 #12
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 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;
 }