示例#1
0
        ///*
        //** {======================================================
        //** Generic Buffer manipulation
        //** =======================================================
        //*/

        //typedef struct luaL_Buffer {
        //  char *b;  /* buffer address */
        //  size_t size;  /* buffer size */
        //  size_t n;  /* number of characters in buffer */
        //  lua_State *L;
        //  char initb[LUAL_BUFFERSIZE];  /* initial buffer */
        //} luaL_Buffer;


        //#define luaL_addchar(B,c) \
        //  ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \
        //   ((B)->b[(B)->n++] = (c)))

        //#define luaL_addsize(B,s)	((B)->n += (s))

        //LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
        //LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz);
        //LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
        //LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
        //LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
        //LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
        //LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz);
        //LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz);

        //#define luaL_prepbuffer(B)	luaL_prepbuffsize(B, LUAL_BUFFERSIZE)

        ///* }====================================================== */



        ///*
        //** {======================================================
        //** File handles for IO library
        //** =======================================================
        //*/

        ///*
        //** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and
        //** initial structure 'luaL_Stream' (it may contain other fields
        //** after that initial structure).
        //*/

        //#define LUA_FILEHANDLE          "FILE*"


        //typedef struct luaL_Stream {
        //  FILE *f;  /* stream (NULL for incompletely created streams) */
        //  lua_CFunction closef;  /* to close stream (NULL for closed streams) */
        //} luaL_Stream;

        ///* }====================================================== */



        ///* compatibility with old module system */
        //#if defined(LUA_COMPAT_MODULE)

        //LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
        //                                   int sizehint);
        //LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
        //                                const luaL_Reg *l, int nup);

        //#define luaL_register(L,n,l)	(luaL_openlib(L,(n),(l),0))

        //#endif

        /*
        ** {==================================================================
        ** "Abstraction Layer" for basic report of messages and errors
        ** ===================================================================
        */

        /// <summary>
        /// Process write
        /// </summary>
        static void ProcessWrite(String s, EventHandler <LuaWriteEventArgs> h, System.IO.TextWriter w)
        {
            LuaWriteEventArgs e = new LuaWriteEventArgs(s);

            if (h != null)
            {
                h(null, e);
            }
            if (!e.Handled)
            {
                w.Write(e.Text);
                w.Flush();
            }
        }
示例#2
0
 ///*
 //** {======================================================
 //** Generic Buffer manipulation
 //** =======================================================
 //*/
 //typedef struct luaL_Buffer {
 //  char *b;  /* buffer address */
 //  size_t size;  /* buffer size */
 //  size_t n;  /* number of characters in buffer */
 //  lua_State *L;
 //  char initb[LUAL_BUFFERSIZE];  /* initial buffer */
 //} luaL_Buffer;
 //#define luaL_addchar(B,c) \
 //  ((void)((B)->n < (B)->size || luaL_prepbuffsize((B), 1)), \
 //   ((B)->b[(B)->n++] = (c)))
 //#define luaL_addsize(B,s)	((B)->n += (s))
 //LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
 //LUALIB_API char *(luaL_prepbuffsize) (luaL_Buffer *B, size_t sz);
 //LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
 //LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
 //LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
 //LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
 //LUALIB_API void (luaL_pushresultsize) (luaL_Buffer *B, size_t sz);
 //LUALIB_API char *(luaL_buffinitsize) (lua_State *L, luaL_Buffer *B, size_t sz);
 //#define luaL_prepbuffer(B)	luaL_prepbuffsize(B, LUAL_BUFFERSIZE)
 ///* }====================================================== */
 ///*
 //** {======================================================
 //** File handles for IO library
 //** =======================================================
 //*/
 ///*
 //** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and
 //** initial structure 'luaL_Stream' (it may contain other fields
 //** after that initial structure).
 //*/
 //#define LUA_FILEHANDLE          "FILE*"
 //typedef struct luaL_Stream {
 //  FILE *f;  /* stream (NULL for incompletely created streams) */
 //  lua_CFunction closef;  /* to close stream (NULL for closed streams) */
 //} luaL_Stream;
 ///* }====================================================== */
 ///* compatibility with old module system */
 //#if defined(LUA_COMPAT_MODULE)
 //LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname,
 //                                   int sizehint);
 //LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname,
 //                                const luaL_Reg *l, int nup);
 //#define luaL_register(L,n,l)	(luaL_openlib(L,(n),(l),0))
 //#endif
 /*
 ** {==================================================================
 ** "Abstraction Layer" for basic report of messages and errors
 ** ===================================================================
 */
 /// <summary>
 /// Process write
 /// </summary>
 static void ProcessWrite(String s, EventHandler<LuaWriteEventArgs> h, System.IO.TextWriter w)
 {
     LuaWriteEventArgs e = new LuaWriteEventArgs(s);
     if (h != null) h(null, e);
     if (!e.Handled)
     {
         w.Write(e.Text);
         w.Flush();
     }
 }