本文整理汇总了C#中KopiLua.CharPtr类的典型用法代码示例。如果您正苦于以下问题:C# CharPtr类的具体用法?C# CharPtr怎么用?C# CharPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CharPtr类属于KopiLua命名空间,在下文中一共展示了CharPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: newlstr
public static TString newlstr (lua_State L, CharPtr str, uint l,
uint h) {
TString ts;
stringtable tb;
if (l+1 > MAX_SIZET /GetUnmanagedSize(typeof(char)))
luaM_toobig(L);
ts = new TString(new char[l+1]);
AddTotalBytes(L, (int)(l + 1) * GetUnmanagedSize(typeof(char)) + GetUnmanagedSize(typeof(TString)));
ts.tsv.len = l;
ts.tsv.hash = h;
ts.tsv.marked = luaC_white(G(L));
ts.tsv.tt = LUA_TSTRING;
ts.tsv.reserved = 0;
//memcpy(ts+1, str, l*GetUnmanagedSize(typeof(char)));
memcpy(ts.str.chars, str.chars, str.index, (int)l);
ts.str[l] = '\0'; /* ending 0 */
tb = G(L).strt;
h = (uint)lmod(h, tb.size);
ts.tsv.next = tb.hash[h]; /* chain new entry */
tb.hash[h] = obj2gco(ts);
tb.nuse++;
if ((tb.nuse > (int)tb.size) && (tb.size <= MAX_INT/2))
luaS_resize(L, tb.size*2); /* too crowded */
return ts;
}
示例2: GetBoolField
private static int GetBoolField(LuaState L, CharPtr key)
{
int res;
LuaGetField(L, -1, key);
res = LuaIsNil(L, -1) ? -1 : LuaToBoolean(L, -1);
LuaPop(L, 1);
return res;
}
示例3: getboolfield
private static int getboolfield(lua_State L, CharPtr key)
{
int res;
lua_getfield(L, -1, key);
res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1);
lua_pop(L, 1);
return res;
}
示例4: DumpBlock
private static void DumpBlock(CharPtr b, uint size, DumpState D)
{
if (D.status==0)
{
LuaUnlock(D.L);
D.status=D.writer(D.L,b,size,D.data);
LuaLock(D.L);
}
}
示例5: TreatStackOption
private static void TreatStackOption (LuaState L, LuaState L1, CharPtr fname) {
if (L == L1) {
LuaPushValue(L, -2);
LuaRemove(L, -3);
}
else
LuaXMove(L1, L, 1);
LuaSetField(L, -2, fname);
}
示例6: treatstackoption
private static void treatstackoption (lua_State L, lua_State L1, CharPtr fname) {
if (L == L1) {
lua_pushvalue(L, -2);
lua_remove(L, -3);
}
else
lua_xmove(L1, L, 1);
lua_setfield(L, -2, fname);
}
示例7: LuaXLexError
public static void LuaXLexError(LexState ls, CharPtr msg, int token)
{
CharPtr buff = new char[MAXSRC];
LuaOChunkID(buff, GetStr(ls.source), MAXSRC);
msg = LuaOPushFString(ls.L, "%s:%d: %s", buff, ls.linenumber, msg);
if (token != 0)
LuaOPushFString(ls.L, "%s near " + LUA_QS, msg, TextToken(ls, token));
LuaDThrow(ls.L, LUA_ERRSYNTAX);
}
示例8: OSPushResult
private static int OSPushResult (LuaState L, int i, CharPtr filename) {
int en = errno(); /* calls to Lua API may change this value */
if (i != 0) {
LuaPushBoolean(L, 1);
return 1;
}
else {
LuaPushNil(L);
LuaPushFString(L, "%s: %s", filename, strerror(en));
LuaPushInteger(L, en);
return 3;
}
}
示例9: os_pushresult
private static int os_pushresult (lua_State L, int i, CharPtr filename) {
int en = errno(); /* calls to Lua API may change this value */
if (i != 0) {
lua_pushboolean(L, 1);
return 1;
}
else {
lua_pushnil(L);
lua_pushfstring(L, "%s: %s", filename, strerror(en));
lua_pushinteger(L, en);
return 3;
}
}
示例10: GetField
private static int GetField(LuaState L, CharPtr key, int d)
{
int res;
LuaGetField(L, -1, key);
if (LuaIsNumber(L, -1) != 0)
res = (int)LuaToInteger(L, -1);
else {
if (d < 0)
return LuaLError(L, "field " + LUA_QS + " missing in date table", key);
res = d;
}
LuaPop(L, 1);
return res;
}
示例11: getfield
private static int getfield(lua_State L, CharPtr key, int d)
{
int res;
lua_getfield(L, -1, key);
if (lua_isnumber(L, -1) != 0)
res = (int)lua_tointeger(L, -1);
else {
if (d < 0)
return luaL_error(L, "field " + LUA_QS + " missing in date table", key);
res = d;
}
lua_pop(L, 1);
return res;
}
示例12: luaS_newlstr
public static TString luaS_newlstr(lua_State L, CharPtr str, uint l)
{
GCObject o;
uint h = (uint)l; /* seed */
uint step = (l>>5)+1; /* if string is too long, don't hash all its chars */
uint l1;
for (l1=l; l1>=step; l1-=step) /* compute hash */
h = h ^ ((h<<5)+(h>>2)+(byte)str[l1-1]);
for (o = G(L).strt.hash[lmod(h, G(L).strt.size)];
o != null;
o = o.gch.next) {
TString ts = rawgco2ts(o);
if (ts.tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) {
/* string may be dead */
if (isdead(G(L), o)) changewhite(o);
return ts;
}
}
//return newlstr(L, str, l, h); /* not found */
TString res = newlstr(L, str, l, h);
return res;
}
示例13: lua_getfield
public static void lua_getfield(lua_State L, int idx, CharPtr k)
{
StkId t;
TValue key = new TValue();
lua_lock(L);
t = index2adr(L, idx);
api_checkvalidindex(L, t);
setsvalue(L, key, luaS_new(L, k));
luaV_gettable(L, t, key, L.top);
api_incr_top(L);
lua_unlock(L);
}
示例14: luaZ_read
public static uint luaZ_read(ZIO z, CharPtr b, uint n)
{
b = new CharPtr(b);
while (n != 0)
{
uint m;
if (luaZ_lookahead(z) == EOZ)
return n; // return number of missing bytes
m = (n <= z.n) ? n : z.n; // min. between n and z.n
memcpy(b, z.p, m);
z.n -= m;
z.p += m;
b = b + m;
n -= m;
}
return 0;
}
示例15: luaS_newliteral
public static TString luaS_newliteral(lua_State L, CharPtr s) { return luaS_newlstr(L, s, (uint)strlen(s)); }