本文整理汇总了C#中KopiLua.CharPtr.inc方法的典型用法代码示例。如果您正苦于以下问题:C# CharPtr.inc方法的具体用法?C# CharPtr.inc怎么用?C# CharPtr.inc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KopiLua.CharPtr
的用法示例。
在下文中一共展示了CharPtr.inc方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: luaU_header
/*
* make header
*/
public static void luaU_header(CharPtr h)
{
h = new CharPtr(h);
int x=1;
memcpy(h, LUA_SIGNATURE, LUA_SIGNATURE.Length);
h = h.add(LUA_SIGNATURE.Length);
h[0] = (char)LUAC_VERSION;
h.inc();
h[0] = (char)LUAC_FORMAT;
h.inc();
//*h++=(char)*(char*)&x; /* endianness */
h[0] = (char)x; /* endianness */
h.inc();
h[0] = (char)sizeof(int);
h.inc();
h[0] = (char)sizeof(uint);
h.inc();
h[0] = (char)sizeof(Instruction);
h.inc();
h[0] = (char)sizeof(lua_Number);
h.inc();
//(h++)[0] = ((lua_Number)0.5 == 0) ? 0 : 1; /* is lua_Number integral? */
h[0] = (char)0; // always 0 on this build
}
示例2: os_date
private static int os_date (lua_State L) {
CharPtr s = new CharPtr(luaL_optstring(L, 1, "%c"));
DateTime stm;
if (s[0] == '!') { /* UTC? */
stm = DateTime.UtcNow;
s.inc(); /* skip `!' */
}
else
stm = DateTime.Now;
if (strcmp(s, "*t") == 0) {
lua_createtable(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 {
luaL_error(L, "strftime not implemented yet"); // todo: implement this - mjf
#if false
CharPtr cc = new char[3];
luaL_Buffer b;
cc[0] = '%'; cc[2] = '\0';
luaL_buffinit(L, b);
for (; s[0] != 0; s.inc()) {
if (s[0] != '%' || s[1] == '\0') /* no conversion specifier? */
luaL_addchar(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, buff.Length, cc, stm);
luaL_addlstring(b, buff, reslen);
}
}
luaL_pushresult(b);
#endif // #if 0
}
return 1;
}
示例3: StrFTimeAdd
private static CharPtr StrFTimeAdd(CharPtr str, CharPtr pt, CharPtr ptlim)
{
pt[0] = str[0];
str = str.next();
while (pt < ptlim && pt[0] != 0)
{
pt.inc();
pt[0] = str[0];
str = str.next();
}
return pt;
}
示例4: StrFTimeFmt
private static CharPtr StrFTimeFmt(CharPtr baseFormat, DateTime t, CharPtr pt, CharPtr ptlim)
{
CharPtr format = new CharPtr(baseFormat);
for (; format[0] != 0; format.inc())
{
if (format == '%')
{
format.inc();
if (format == 'E')
{
format.inc(); // Alternate Era is ignored
}
else if (format == 'O')
{
format.inc(); // Alternate numeric symbols is ignored
}
switch (format[0])
{
case '\0':
format.dec();
break;
case 'A': // Full day of week
//pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ? "?" : _days[t->tm_wday], pt, ptlim);
pt = StrFTimeAdd(t.ToString("dddd"), pt, ptlim);
continue;
case 'a': // Abbreviated day of week
//pt = _add((t->tm_wday < 0 || t->tm_wday > 6) ? "?" : _days_abbrev[t->tm_wday], pt, ptlim);
pt = StrFTimeAdd(t.ToString("ddd"), pt, ptlim);
continue;
case 'B': // Full month name
//pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ? "?" : _months[t->tm_mon], pt, ptlim);
pt = StrFTimeAdd(t.ToString("MMMM"), pt, ptlim);
continue;
case 'b': // Abbreviated month name
case 'h': // Abbreviated month name
//pt = _add((t->tm_mon < 0 || t->tm_mon > 11) ? "?" : _months_abbrev[t->tm_mon], pt, ptlim);
pt = StrFTimeAdd(t.ToString("MMM"), pt, ptlim);
continue;
case 'C': // First two digits of year (a.k.a. Year divided by 100 and truncated to integer (00-99))
//pt = _conv((t->tm_year + TM_YEAR_BASE) / 100, "%02d", pt, ptlim);
pt = StrFTimeAdd(t.ToString("yyyy").Substring(0, 2), pt, ptlim);
continue;
case 'c': // Abbreviated date/time representation (e.g. Thu Aug 23 14:55:02 2001)
pt = StrFTimeFmt("%a %b %e %H:%M:%S %Y", t, pt, ptlim);
continue;
case 'D': // Short MM/DD/YY date
pt = StrFTimeFmt("%m/%d/%y", t, pt, ptlim);
continue;
case 'd': // Day of the month, zero-padded (01-31)
//pt = _conv(t->tm_mday, "%02d", pt, ptlim);
pt = StrFTimeAdd(t.ToString("dd"), pt, ptlim);
continue;
case 'e': // Day of the month, space-padded ( 1-31)
//pt = _conv(t->tm_mday, "%2d", pt, ptlim);
pt = StrFTimeAdd(t.Day.ToString().PadLeft(2, ' '), pt, ptlim);
continue;
case 'F': // Short YYYY-MM-DD date
pt = StrFTimeFmt("%Y-%m-%d", t, pt, ptlim);
continue;
case 'H': // Hour in 24h format (00-23)
//pt = _conv(t->tm_hour, "%02d", pt, ptlim);
pt = StrFTimeAdd(t.ToString("HH"), pt, ptlim);
continue;
case 'I': // Hour in 12h format (01-12)
//pt = _conv((t->tm_hour % 12) ? (t->tm_hour % 12) : 12, "%02d", pt, ptlim);
pt = StrFTimeAdd(t.ToString("hh"), pt, ptlim);
continue;
case 'j': // Day of the year (001-366)
pt = StrFTimeAdd(t.DayOfYear.ToString().PadLeft(3, ' '), pt, ptlim);
continue;
case 'k': // (Non-standard) // Hours in 24h format, space-padded ( 1-23)
//pt = _conv(t->tm_hour, "%2d", pt, ptlim);
pt = StrFTimeAdd(t.ToString("%H").PadLeft(2, ' '), pt, ptlim);
continue;
case 'l': // (Non-standard) // Hours in 12h format, space-padded ( 1-12)
//pt = _conv((t->tm_hour % 12) ? (t->tm_hour % 12) : 12, "%2d", pt, ptlim);
pt = StrFTimeAdd(t.ToString("%h").PadLeft(2, ' '), pt, ptlim);
continue;
case 'M': // Minute (00-59)
//.........这里部分代码省略.........
示例5: OSDate
private static int OSDate(LuaState L)
{
CharPtr s = new CharPtr(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;
}