• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# LuaLBuffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: addfield

 private static void addfield(LuaState L, LuaLBuffer b, int i)
 {
     LuaRawGetI(L, 1, i);
       if (LuaIsString(L, -1)==0)
     LuaLError(L, "invalid value (%s) at index %d in table for " +
                   LUA_QL("concat"), LuaLTypeName(L, -1), i);
     LuaLAddValue(b);
 }
开发者ID:GSharpDevs,项目名称:RunG,代码行数:8,代码来源:ltablib.cs


示例2: str_reverse

		private static int str_reverse (LuaState L) {
		  uint l;
		  LuaLBuffer b = new LuaLBuffer();
		  CharPtr s = LuaLCheckLString(L, 1, out l);
		  LuaLBuffInit(L, b);
		  while ((l--) != 0) LuaLAddChar(b, s[l]);
		  LuaLPushResult(b);
		  return 1;
		}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:9,代码来源:lstrlib.cs


示例3: str_upper

		private static int str_upper (LuaState L) {
		  uint l;
		  uint i;
		  LuaLBuffer b = new LuaLBuffer();
		  CharPtr s = LuaLCheckLString(L, 1, out l);
		  LuaLBuffInit(L, b);
		  for (i=0; i<l; i++)
			  LuaLAddChar(b, toupper(s[i]));
		  LuaLPushResult(b);
		  return 1;
		}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:11,代码来源:lstrlib.cs


示例4: tconcat

		private static int tconcat (LuaState L) {
		  LuaLBuffer b = new LuaLBuffer();
		  uint lsep;
		  int i, last;
		  CharPtr sep = LuaLOptLString(L, 2, "", out lsep);
		  LuaLCheckType(L, 1, LUA_TTABLE);
		  i = LuaLOptInt(L, 3, 1);
		  last = LuaLOptInteger(L, LuaLCheckInt, 4, LuaLGetN(L, 1));
		  LuaLBuffInit(L, b);
		  for (; i < last; i++) {
			addfield(L, b, i);
			LuaLAddLString(b, sep, lsep);
		  }
		  if (i == last)  /* add last value (if interval was not empty) */
			addfield(L, b, i);
		  LuaLPushResult(b);
		  return 1;
		}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:18,代码来源:ltablib.cs


示例5: ReadChars

 private static int ReadChars(LuaState L, Stream f, uint n)
 {
     uint rlen;  /* how much to read */
     uint nr;  /* number of chars actually read */
     LuaLBuffer b = new LuaLBuffer();
     LuaLBuffInit(L, b);
     rlen = LUAL_BUFFERSIZE;  /* try to read that much each time */
     do
     {
         CharPtr p = LuaLPrepBuffer(b);
         if (rlen > n) rlen = n;  /* cannot read more than asked */
         nr = (uint)fread(p, GetUnmanagedSize(typeof(char)), (int)rlen, f);
         LuaLAddSize(b, (int)nr);
         n -= nr;  /* still have to read `n' chars */
     } while (n > 0 && nr == rlen);  /* until end of count or eof */
     LuaLPushResult(b);  /* close buffer */
     return (n == 0 || LuaObjectLen(L, -1) > 0) ? 1 : 0;
 }
开发者ID:arkanoid1,项目名称:FakePacketSender,代码行数:18,代码来源:liolib.cs


示例6: str_gsub

 private static int str_gsub(LuaState L)
 {
     uint srcl;
       CharPtr src = LuaLCheckLString(L, 1, out srcl);
       CharPtr p = LuaLCheckString(L, 2);
       int  tr = LuaType(L, 3);
       int max_s = LuaLOptInt(L, 4, (int)(srcl+1));
       int anchor = 0;
       if (p[0] == '^')
       {
       p = p.next();
       anchor = 1;
       }
       int n = 0;
       MatchState ms = new MatchState();
       LuaLBuffer b = new LuaLBuffer();
       LuaLArgCheck(L, tr == LUA_TNUMBER || tr == LUA_TSTRING ||
                    tr == LUA_TFUNCTION || tr == LUA_TTABLE ||
                    tr == LUA_TUSERDATA, 3,
                       "string/function/table expected");
       LuaLBuffInit(L, b);
       ms.L = L;
       ms.matchdepth = MAXCCALLS;
       ms.src_init = src;
       ms.src_end = src+srcl;
       while (n < max_s) {
     CharPtr e;
     ms.level = 0;
     LuaAssert(ms.matchdepth == MAXCCALLS);
     e = match(ms, src, p);
     if (e != null) {
       n++;
       add_value(ms, b, src, e);
     }
     if ((e!=null) && e>src) /* non empty match? */
       src = e;  /* skip it */
     else if (src < ms.src_end)
     {
         char c = src[0];
         src = src.next();
         LuaLAddChar(b, c);
     }
     else break;
     if (anchor != 0) break;
       }
       LuaLAddLString(b, src, (uint)(ms.src_end-src));
       LuaLPushResult(b);
       LuaPushInteger(L, n);  /* number of substitutions */
       return 2;
 }
开发者ID:GSharpDevs,项目名称:RunG,代码行数:50,代码来源:lstrlib.cs


示例7: str_dump

 private static int str_dump(LuaState L)
 {
     LuaLBuffer b = new LuaLBuffer();
       LuaLCheckType(L, 1, LUA_TFUNCTION);
       LuaSetTop(L, 1);
       LuaLBuffInit(L,b);
       if (LuaDump(L, writer, b) != 0)
     LuaLError(L, "unable to dump given function");
       LuaLPushResult(b);
       return 1;
 }
开发者ID:GSharpDevs,项目名称:RunG,代码行数:11,代码来源:lstrlib.cs


示例8: add_value

 private static void add_value(MatchState ms, LuaLBuffer b, CharPtr s,
     CharPtr e)
 {
     LuaState L = ms.L;
       switch (LuaType(L, 3)) {
     case LUA_TNUMBER:
     case LUA_TSTRING: {
       add_s(ms, b, s, e);
       return;
     }
     case LUA_TUSERDATA:
     case LUA_TFUNCTION: {
       int n;
       LuaPushValue(L, 3);
       n = push_captures(ms, s, e);
       LuaCall(L, n, 1);
       break;
     }
     case LUA_TTABLE: {
       push_onecapture(ms, 0, s, e);
       LuaGetTable(L, 3);
       break;
     }
       }
       if (LuaToBoolean(L, -1)==0) {  /* nil or false? */
     LuaPop(L, 1);
     LuaPushLString(L, s, (uint)(e - s));  /* keep original text */
       }
       else if (LuaIsString(L, -1)==0)
     LuaLError(L, "invalid replacement value (a %s)", LuaLTypeName(L, -1));
       LuaLAddValue(b);  /* add result to accumulator */
 }
开发者ID:GSharpDevs,项目名称:RunG,代码行数:32,代码来源:lstrlib.cs


示例9: addquoted

 private static void addquoted(LuaState L, LuaLBuffer b, int arg)
 {
     uint l;
       CharPtr s = LuaLCheckLString(L, arg, out l);
       LuaLAddChar(b, '"');
       while ((l--) != 0) {
     switch (s[0]) {
       case '"': case '\\': case '\n': {
         LuaLAddChar(b, '\\');
         LuaLAddChar(b, s[0]);
         break;
       }
       case '\r': {
         LuaLAddLString(b, "\\r", 2);
         break;
       }
       case '\0': {
         LuaLAddLString(b, "\\000", 4);
         break;
       }
       default: {
         LuaLAddChar(b, s[0]);
         break;
       }
     }
     s = s.next();
       }
       LuaLAddChar(b, '"');
 }
开发者ID:GSharpDevs,项目名称:RunG,代码行数:29,代码来源:lstrlib.cs


示例10: OSDate

		private static int OSDate (LuaState L) {
		  CharPtr s = LuaLOptString(L, 1, "%c");
		  DateTime stm;
		  if (s[0] == '!') {  /* UTC? */
			stm = DateTime.UtcNow;
			s.inc();  /* skip `!' */
		  }
		  else
			  stm = DateTime.Now;
		  if (strcmp(s, "*t") == 0) {
			LuaCreateTable(L, 0, 9);  /* 9 = number of fields */
			SetField(L, "sec", stm.Second);
			SetField(L, "min", stm.Minute);
			SetField(L, "hour", stm.Hour);
			SetField(L, "day", stm.Day);
			SetField(L, "month", stm.Month);
			SetField(L, "year", stm.Year);
			SetField(L, "wday", (int)stm.DayOfWeek);
			SetField(L, "yday", stm.DayOfYear);
			SetBoolField(L, "isdst", stm.IsDaylightSavingTime() ? 1 : 0);
		  }
		  else {
			CharPtr cc = new char[3];
			LuaLBuffer b = new LuaLBuffer();
			cc[0] = '%'; cc[2] = '\0';
			LuaLBuffInit(L, b);
			for (; s[0] != 0; s.inc()) {
			  if (s[0] != '%' || s[1] == '\0')  /* no conversion specifier? */
			    LuaLAddChar(b, s[0]);
			  else {
			    uint reslen;
			    CharPtr buff = new char[200];  /* should be big enough for any conversion result */
			    s.inc();
			    cc[1] = s[0];
			    reslen = strftime(buff, (uint)buff.chars.Length, cc, stm);
			    buff.index = 0;
			    LuaLAddLString(b, buff, reslen);
			  }
			}
			LuaLPushResult(b);
		  }
			return 1;
		}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:43,代码来源:loslib.cs


示例11: BufferLen

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


		private static int BufferLen(LuaLBuffer B)	{return B.p;}
开发者ID:oathx,项目名称:Six,代码行数:8,代码来源:lauxlib.cs


示例12: LuaLGSub

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



		public static CharPtr LuaLGSub (LuaState L, CharPtr s, CharPtr p,
																	   CharPtr r) {
		  CharPtr wild;
		  uint l = (uint)strlen(p);
		  LuaLBuffer b = new LuaLBuffer();
		  LuaLBuffInit(L, b);
		  while ((wild = strstr(s, p)) != null) {
			LuaLAddLString(b, s, (uint)(wild - s));  /* push prefix */
			LuaLAddString(b, r);  /* push replacement in place of pattern */
			s = wild + l;  /* continue after `p' */
		  }
		  LuaLAddString(b, s);  /* push last suffix */
		  LuaLPushResult(b);
		  return LuaToString(L, -1);
		}
开发者ID:oathx,项目名称:Six,代码行数:19,代码来源:lauxlib.cs


示例13: LuaLAddSize

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


示例14: LuaLPutChar

		///* compatibility only */
		public static void LuaLPutChar(LuaLBuffer B, char c)	{LuaLAddChar(B,c);}
开发者ID:oathx,项目名称:Six,代码行数:2,代码来源:lauxlib.cs


示例15: LuaLAddChar

		public static void LuaLAddChar(LuaLBuffer B, char c) {
			if (B.p >= LUAL_BUFFERSIZE)
				LuaLPrepBuffer(B);
			B.buffer[B.p++] = c;
		}
开发者ID:oathx,项目名称:Six,代码行数:5,代码来源:lauxlib.cs


示例16: LuaLAddValue

		public static void LuaLAddValue (LuaLBuffer B) {
		  LuaState L = B.L;
		  uint vl;
		  CharPtr s = LuaToLString(L, -1, out vl);
		  if (vl <= BufferFree(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;
			LuaPop(L, 1);  /* remove from stack */
		  }
		  else {
			if (EmptyBuffer(B) != 0)
			  LuaInsert(L, -2);  /* put buffer before new value */
			B.lvl++;  /* add new value into B stack */
			AdjustStack(B);
		  }
		}
开发者ID:oathx,项目名称:Six,代码行数:19,代码来源:lauxlib.cs


示例17: LuaLBuffInit

		public static void LuaLBuffInit (LuaState L, LuaLBuffer B) {
		  B.L = L;
		  B.p = /*B.buffer*/ 0;
		  B.lvl = 0;
		}
开发者ID:oathx,项目名称:Six,代码行数:5,代码来源:lauxlib.cs


示例18: BufferFree

		private static int BufferFree(LuaLBuffer B)	{return LUAL_BUFFERSIZE - BufferLen(B);}
开发者ID:oathx,项目名称:Six,代码行数:1,代码来源:lauxlib.cs


示例19: OSDate

        private static int OSDate(LuaState L)
        {
            CharPtr s = LuaLOptString(L, 1, "%c");
              DateTime stm;

            // Parses the second argument if there's one. If not, uses Now as time.
            if (LuaIsNoneOrNil(L, 2)) {
              stm = DateTime.Now;
            }
            else
            {
              LuaLCheckType(L, 2, LUA_TNUMBER);
              double seconds = LuaToNumber(L, 2);
              stm = new DateTime((long)seconds * TimeSpan.TicksPerSecond);
            }

              if (s[0] == '!') {  /* UTC? */
            stm = stm.ToUniversalTime();
            s.inc();  /* skip `!' */
              }
              if (strcmp(s, "*t") == 0) {
            LuaCreateTable(L, 0, 9);  /* 9 = number of fields */
            SetField(L, "sec", stm.Second);
            SetField(L, "min", stm.Minute);
            SetField(L, "hour", stm.Hour);
            SetField(L, "day", stm.Day);
            SetField(L, "month", stm.Month);
            SetField(L, "year", stm.Year);
            SetField(L, "wday", (int)stm.DayOfWeek + 1);
            SetField(L, "yday", stm.DayOfYear);
            SetBoolField(L, "isdst", stm.IsDaylightSavingTime() ? 1 : 0);
              }
              else {
            CharPtr cc = new char[3];
            LuaLBuffer b = new LuaLBuffer();
            cc[0] = '%'; cc[2] = '\0';
            LuaLBuffInit(L, b);
            for (; s[0] != 0; s.inc()) {
              if (s[0] != '%' || s[1] == '\0')  /* no conversion specifier? */
                LuaLAddChar(b, s[0]);
              else {
                uint reslen;
                CharPtr buff = new char[200];  /* should be big enough for any conversion result */
                s.inc();
                cc[1] = s[0];
                reslen = strftime(buff, (uint)buff.chars.Length, cc, stm);
                buff.index = 0;
                LuaLAddLString(b, buff, reslen);
              }
            }
            LuaLPushResult(b);
              }
            return 1;
        }
开发者ID:GSharpDevs,项目名称:RunG,代码行数:54,代码来源:loslib.cs


示例20: EmptyBuffer

		private static int EmptyBuffer (LuaLBuffer B) {
		  uint l = (uint)BufferLen(B);
		  if (l == 0) return 0;  /* put nothing on stack */
		  else {
			LuaPushLString(B.L, B.buffer, l);
			B.p = 0;
			B.lvl++;
			return 1;
		  }
		}
开发者ID:oathx,项目名称:Six,代码行数:10,代码来源:lauxlib.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LuaMethod类代码示例发布时间:2022-05-24
下一篇:
C# LuaField类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap