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


C# LuaLBuffer类代码示例

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


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


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