本文整理汇总了C#中lua_State类的典型用法代码示例。如果您正苦于以下问题:C# lua_State类的具体用法?C# lua_State怎么用?C# lua_State使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
lua_State类属于命名空间,在下文中一共展示了lua_State类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: db_getmetatable
private static int db_getmetatable (lua_State L) {
luaL_checkany(L, 1);
if (lua_getmetatable(L, 1) == 0) {
lua_pushnil(L); /* no metatable */
}
return 1;
}
示例2: luaH_free
public static void luaH_free(lua_State L, Table t)
{
if (t.node[0] != dummynode)
luaM_freearray(L, t.node);
luaM_freearray(L, t.array);
luaM_free(L, t);
}
示例3: luaF_freeclosure
// we have a gc, so nothing to do
public static void luaF_freeclosure(lua_State L, Closure c)
{
int size = (c.c.isC != 0) ? sizeCclosure(c.c.nupvalues) :
sizeLclosure(c.l.nupvalues);
//luaM_freemem(L, c, size);
SubtractTotalBytes(L, size);
}
示例4: inc_ci
public static CallInfo inc_ci(lua_State L)
{
if (L.ci == L.end_ci) return growCI(L);
// (condhardstacktests(luaD_reallocCI(L, L.size_ci)), ++L.ci))
CallInfo.inc(ref L.ci);
return L.ci;
}
示例5: luaS_resize
public static void luaS_resize (lua_State L, int newsize) {
GCObject[] newhash;
stringtable tb;
int i;
if (G(L).gcstate == GCSsweepstring)
return; /* cannot resize during GC traverse */
newhash = new GCObject[newsize];
AddTotalBytes(L, newsize * GetUnmanagedSize(typeof(GCObjectRef)));
tb = G(L).strt;
for (i=0; i<newsize; i++) newhash[i] = null;
/* rehash */
for (i=0; i<tb.size; i++) {
GCObject p = tb.hash[i];
while (p != null) { /* for each node in the list */
GCObject next = p.gch.next; /* save next */
uint h = gco2ts(p).hash;
int h1 = (int)lmod(h, newsize); /* new position */
lua_assert((int)(h%newsize) == lmod(h, newsize));
p.gch.next = newhash[h1]; /* chain it */
newhash[h1] = p;
p = next;
}
}
//luaM_freearray(L, tb.hash);
if (tb.hash != null)
SubtractTotalBytes(L, tb.hash.Length * GetUnmanagedSize(typeof(GCObjectRef)));
tb.size = newsize;
tb.hash = newhash;
}
示例6: luaF_findupval
public static UpVal luaF_findupval(lua_State L, StkId level)
{
global_State g = G(L);
GCObjectRef pp = new OpenValRef(L);
UpVal p;
UpVal uv;
while (pp.get() != null && (p = ngcotouv(pp.get())).v >= level) {
lua_assert(p.v != p.u.value);
if (p.v == level) { /* found a corresponding upvalue? */
if (isdead(g, obj2gco(p))) /* is it dead? */
changewhite(obj2gco(p)); /* ressurect it */
return p;
}
pp = new NextRef(p);
}
uv = luaM_new<UpVal>(L); /* not found: create a new one */
uv.tt = LUA_TUPVAL;
uv.marked = luaC_white(g);
uv.v = level; /* current value lives in the stack */
uv.next = pp.get(); /* chain it in the proper position */
pp.set( obj2gco(uv) );
uv.u.l.prev = g.uvhead; /* double link it in `uvhead' list */
uv.u.l.next = g.uvhead.u.l.next;
uv.u.l.next.u.l.prev = uv;
g.uvhead.u.l.next = uv;
lua_assert(uv.u.l.next.u.l.prev == uv && uv.u.l.prev.u.l.next == uv);
return uv;
}
示例7: luaG_aritherror
public static void luaG_aritherror(lua_State L, TValue p1, TValue p2)
{
TValue temp = new TValue();
if (luaV_tonumber(p1, temp) == null)
p2 = p1; /* first operand is wrong */
luaG_typeerror(L, p2, "perform arithmetic on");
}
示例8: os_clock
private static int os_clock(lua_State L)
{
TimeSpan elapsed = DateTime.Now - start_time;
long ticks = elapsed.Ticks / TimeSpan.TicksPerMillisecond;
lua_pushnumber(L, ((lua_Number)ticks)/(lua_Number)1000);
return 1;
}
示例9: 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;
}
示例10: 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);
}
示例11: db_setmetatable
private static int db_setmetatable (lua_State L) {
int t = lua_type(L, 2);
luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
"nil or table expected");
lua_settop(L, 2);
lua_pushboolean(L, lua_setmetatable(L, 1));
return 1;
}
示例12: db_setfenv
private static int db_setfenv (lua_State L) {
luaL_checktype(L, 2, LUA_TTABLE);
lua_settop(L, 2);
if (lua_setfenv(L, 1) == 0)
luaL_error(L, LUA_QL("setfenv") +
" cannot change environment of given object");
return 1;
}
示例13: os_tmpname
private static int os_tmpname (lua_State L) {
#if XBOX
luaL_error(L, "os_tmpname not supported on Xbox360");
#else
lua_pushstring(L, Path.GetTempFileName());
#endif
return 1;
}
示例14: luaZ_init
public static void luaZ_init(lua_State L, ZIO z, lua_Reader reader, object data)
{
z.L = L;
z.reader = reader;
z.data = data;
z.n = 0;
z.p = null;
}
示例15: 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;
}