当前位置: 首页>>代码示例>>C#>>正文


C# luaL_Buffer类代码示例

本文整理汇总了C#中luaL_Buffer的典型用法代码示例。如果您正苦于以下问题:C# luaL_Buffer类的具体用法?C# luaL_Buffer怎么用?C# luaL_Buffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


luaL_Buffer类属于命名空间,在下文中一共展示了luaL_Buffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: addfield

 private static void addfield(lua_State L, luaL_Buffer b, int i)
 {
     lua_rawgeti(L, 1, i);
       if (lua_isstring(L, -1)==0)
     luaL_error(L, "invalid value (%s) at index %d in table for " +
                   LUA_QL("concat"), luaL_typename(L, -1), i);
     luaL_addvalue(b);
 }
开发者ID:lenzener,项目名称:LuaInterface,代码行数:8,代码来源:ltablib.cs

示例2: str_reverse

 private static int str_reverse (lua_State L) {
     uint l;
     luaL_Buffer b = new luaL_Buffer();
     CharPtr s = luaL_checklstring(L, 1, out l);
     luaL_buffinit(L, b);
     while ((l--) != 0) luaL_addchar(b, s[l]);
     luaL_pushresult(b);
     return 1;
 }
开发者ID:mlnlover11,项目名称:KopiLua-v5.1.5,代码行数:9,代码来源:lstrlib.cs

示例3: str_upper

 private static int str_upper (lua_State L) {
     uint l;
     uint i;
     luaL_Buffer b = new luaL_Buffer();
     CharPtr s = luaL_checklstring(L, 1, out l);
     luaL_buffinit(L, b);
     for (i=0; i<l; i++)
         luaL_addchar(b, toupper(s[i]));
     luaL_pushresult(b);
     return 1;
 }
开发者ID:mlnlover11,项目名称:KopiLua-v5.1.5,代码行数:11,代码来源:lstrlib.cs

示例4: luaL_buffinit

 public static extern void luaL_buffinit(lua_State L, ref luaL_Buffer B);
开发者ID:vhotur,项目名称:tao,代码行数:1,代码来源:Lua.cs

示例5: read_line

 private static int read_line (lua_State L, Stream f) {
     luaL_Buffer b = new luaL_Buffer();
     luaL_buffinit(L, b);
     for (;;) {
         uint l;
         CharPtr p = luaL_prepbuffer(b);
         if (fgets(p, f) == null) {  /* eof? */
             luaL_pushresult(b);  /* close buffer */
             return (lua_objlen(L, -1) > 0) ? 1 : 0;  /* check whether read something */
         }
         l = (uint)strlen(p);
         if (l == 0 || p[l-1] != '\n')
             luaL_addsize(b, (int)l);
         else {
             luaL_addsize(b, (int)(l - 1));  /* do not include `eol' */
             luaL_pushresult(b);  /* close buffer */
             return 1;  /* read at least an `eol' */
         }
     }
 }
开发者ID:mlnlover11,项目名称:KopiLua-v5.1.5,代码行数:20,代码来源:liolib.cs

示例6: luaL_addvalue

 public static void luaL_addvalue(luaL_Buffer B)
 {
     LuaState L = B.L;
     uint vl;
     CharPtr s = lua_tolstring(L, -1, out vl);
     if (vl <= bufffree(B))
     {  /* fit into buffer? */
         CharPtr dst = new CharPtr(B.buffer.chars, B.buffer.index + B.p);
         CharPtr src = new CharPtr(s.chars, s.index);
         for (uint i = 0; i < vl; i++)
             dst[i] = src[i];
         B.p += (int)vl;
         lua_pop(L, 1);  /* remove from stack */
     }
     else
     {
         if (emptybuffer(B) != 0)
             lua_insert(L, -2);  /* put buffer before new value */
         B.lvl++;  /* add new value into B stack */
         adjuststack(B);
     }
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:22,代码来源:lauxlib.cs

示例7: luaL_addstring

 public static void luaL_addstring(luaL_Buffer B, CharPtr s)
 {
     luaL_addlstring(B, s, (uint)strlen(s));
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:4,代码来源:lauxlib.cs

示例8: luaL_prepbuffer

 public static CharPtr luaL_prepbuffer(luaL_Buffer B)
 {
     if (emptybuffer(B) != 0)
         adjuststack(B);
     return new CharPtr(B.buffer, B.p);
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:6,代码来源:lauxlib.cs

示例9: emptybuffer

 private static int emptybuffer(luaL_Buffer B)
 {
     uint l = (uint)bufflen(B);
     if (l == 0) return 0;  /* put nothing on stack */
     else
     {
         lua_pushlstring(B.L, B.buffer, l);
         B.p = 0;
         B.lvl++;
         return 1;
     }
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:12,代码来源:lauxlib.cs

示例10: bufflen

        /*
        ** {======================================================
        ** Generic Buffer manipulation
        ** =======================================================
        */

        private static int bufflen(luaL_Buffer B) { return B.p; }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:7,代码来源:lauxlib.cs

示例11: add_value

        private static void add_value(MatchState ms, luaL_Buffer b, CharPtr s,
															   CharPtr e)
        {
            lua_State L = ms.L;
              switch (lua_type(L, 3)) {
            case LUA_TNUMBER:
            case LUA_TSTRING: {
              add_s(ms, b, s, e);
              return;
            }
            case LUA_TUSERDATA:
            case LUA_TFUNCTION: {
              int n;
              lua_pushvalue(L, 3);
              n = push_captures(ms, s, e);
              lua_call(L, n, 1);
              break;
            }
            case LUA_TTABLE: {
              push_onecapture(ms, 0, s, e);
              lua_gettable(L, 3);
              break;
            }
              }
              if (lua_toboolean(L, -1)==0) {  /* nil or false? */
            lua_pop(L, 1);
            lua_pushlstring(L, s, (uint)(e - s));  /* keep original text */
              }
              else if (lua_isstring(L, -1)==0)
            luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1));
              luaL_addvalue(b);  /* add result to accumulator */
        }
开发者ID:WondermSwift,项目名称:kopilua-1,代码行数:32,代码来源:lstrlib.cs

示例12: add_s

        private static void add_s(MatchState ms, luaL_Buffer b, CharPtr s,
														   CharPtr e)
        {
            uint l, i;
              CharPtr news = lua_tolstring(ms.L, 3, out l);
              for (i = 0; i < l; i++) {
            if (news[i] != L_ESC)
              luaL_addchar(b, news[i]);
            else {
              i++;  /* skip ESC */
              if (!isdigit((byte)(news[i])))
                luaL_addchar(b, news[i]);
              else if (news[i] == '0')
                  luaL_addlstring(b, s, (uint)(e - s));
              else {
                push_onecapture(ms, news[i] - '1', s, e);
                luaL_addvalue(b);  /* add capture to accumulated result */
              }
            }
              }
        }
开发者ID:WondermSwift,项目名称:kopilua-1,代码行数:21,代码来源:lstrlib.cs

示例13: addquoted

 private static void addquoted(lua_State L, luaL_Buffer b, int arg)
 {
     uint l;
       CharPtr s = luaL_checklstring(L, arg, out l);
       luaL_addchar(b, '"');
       while ((l--) != 0) {
     switch (s[0]) {
       case '"': case '\\': case '\n': {
         luaL_addchar(b, '\\');
         luaL_addchar(b, s[0]);
         break;
       }
       case '\r': {
         luaL_addlstring(b, "\\r", 2);
         break;
       }
       case '\0': {
         luaL_addlstring(b, "\\000", 4);
         break;
       }
       default: {
         luaL_addchar(b, s[0]);
         break;
       }
     }
     s = s.next();
       }
       luaL_addchar(b, '"');
 }
开发者ID:WondermSwift,项目名称:kopilua-1,代码行数:29,代码来源:lstrlib.cs

示例14: tconcat

 private static int tconcat(LuaState L)
 {
     luaL_Buffer b = new luaL_Buffer();
     uint lsep;
     int i, last;
     CharPtr sep = luaL_optlstring(L, 2, "", out lsep);
     luaL_checktype(L, 1, LUA_TTABLE);
     i = luaL_optint(L, 3, 1);
     last = luaL_opt_integer(L, luaL_checkint, 4, luaL_getn(L, 1));
     luaL_buffinit(L, b);
     for (; i < last; i++)
     {
         addfield(L, b, i);
         luaL_addlstring(b, sep, lsep);
     }
     if (i == last)  /* add last value (if interval was not empty) */
         addfield(L, b, i);
     luaL_pushresult(b);
     return 1;
 }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:20,代码来源:ltablib.cs

示例15: luaL_addsize

 public static void luaL_addsize(luaL_Buffer B, int n) { B.p += n; }
开发者ID:chenzuo,项目名称:SharpLua,代码行数:1,代码来源:lauxlib.cs


注:本文中的luaL_Buffer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。