本文整理汇总了C#中KopiLua.LuaState类的典型用法代码示例。如果您正苦于以下问题:C# LuaState类的具体用法?C# LuaState怎么用?C# LuaState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LuaState类属于KopiLua命名空间,在下文中一共展示了LuaState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Push
/*
* Pushes the function into the Lua stack
*/
internal void Push(LuaState luaState)
{
if (_Reference != 0)
LuaLib.LuaGetRef(luaState, _Reference);
else
_Interpreter.PushCSFunction(function);
}
示例2: LuaFFreeClosure
// we have a gc, so nothing to do
public static void LuaFFreeClosure(LuaState 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);
}
示例3: luaT_init
public static void luaT_init (LuaState L) {
int i;
for (i=0; i<(int)TMS.TM_N; i++) {
G(L).tmname[i] = luaS_new(L, luaT_eventname[i]);
luaS_fix(G(L).tmname[i]); /* never collect these names */
}
}
示例4: SetProgDir
//public static void setprogdir(LuaState L) { }
public static void SetProgDir(LuaState L)
{
#if WINDOWS_PHONE
// On Windows Phone, the current directory is the root of the
// Isolated Storage directory, which is "/".
CharPtr buff = "/";
#elif SILVERLIGHT
// Not all versions of Silverlight support this method.
// So, if it is unsupported, rollback to the Isolated
// Storage root (a.k.a. the leap of faith).
CharPtr buff;
try
{
buff = Directory.GetCurrentDirectory();
}
catch (MethodAccessException)
{
buff = "/";
}
#else
CharPtr buff = Directory.GetCurrentDirectory();
#endif
LuaLGSub(L, LuaToString(L, -1), LUA_EXECDIR, buff);
LuaRemove(L, -2); /* remove original string */
}
示例5: LuaNetGetMainState
public static LuaState LuaNetGetMainState(LuaState L1)
{
LuaGetField (L1, LUA_REGISTRYINDEX, "main_state");
LuaState main = LuaToThread (L1, -1);
LuaPop (L1, 1);
return main;
}
示例6: Find
public ObjectTranslator Find(LuaState luaState)
{
if (!translators.ContainsKey(luaState))
return null;
return translators[luaState];
}
示例7: LuaNetToNetObject
public static int LuaNetToNetObject (LuaState luaState, int index)
{
byte[] udata;
if (LuaType (luaState, index) == LUA_TUSERDATA) {
if (LuaLCheckMetatable (luaState, index)) {
udata = LuaToUserData (luaState, index) as byte[];
if (udata != null)
return FourBytesToInt (udata);
}
udata = CheckUserDataRaw (luaState, index, "luaNet_class") as byte[];
if (udata != null)
return FourBytesToInt (udata);
udata = CheckUserDataRaw (luaState, index, "luaNet_searchbase") as byte[];
if (udata != null)
return FourBytesToInt (udata);
udata = CheckUserDataRaw (luaState, index, "luaNet_function") as byte[];
if (udata != null)
return FourBytesToInt (udata);
}
return -1;
}
示例8: LuaFindUpVal
public static UpVal LuaFindUpVal (LuaState L, StkId level) {
GlobalState g = G(L);
GCObjectRef pp = new OpenValRef(L);
UpVal p;
UpVal uv;
while (pp.get() != null && (p = ngcotouv(pp.get())).v >= level) {
LuaAssert(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 = LuaMNew<UpVal>(L); /* not found: create a new one */
uv.tt = LUATUPVAL;
uv.marked = LuaCWhite(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;
LuaAssert(uv.u.l.next.u.l.prev == uv && uv.u.l.prev.u.l.next == uv);
return uv;
}
示例9: LuaFNewUpVal
public static UpVal LuaFNewUpVal (LuaState L) {
UpVal uv = LuaMNew<UpVal>(L);
LuaCLink(L, obj2gco(uv), LUATUPVAL);
uv.v = uv.u.value;
SetNilValue(uv.v);
return uv;
}
示例10: DBGetMetatable
private static int DBGetMetatable (LuaState L) {
LuaLCheckAny(L, 1);
if (LuaGetMetatable(L, 1) == 0) {
LuaPushNil(L); /* no metatable */
}
return 1;
}
示例11: LuaGArithError
public static void LuaGArithError(LuaState L, TValue p1, TValue p2)
{
TValue temp = new LuaTypeValue();
if (luaV_tonumber(p1, temp) == null)
p2 = p1; /* first operand is wrong */
LuaGTypeError(L, p2, "perform arithmetic on");
}
示例12: Index2Address
static TValue Index2Address (LuaState L, int idx) {
if (idx > 0) {
TValue o = L.base_ + (idx - 1);
ApiCheck(L, idx <= L.ci.top - L.base_);
if (o >= L.top) return LuaONilObject;
else return o;
}
else if (idx > LUA_REGISTRYINDEX) {
ApiCheck(L, idx != 0 && -idx <= L.top - L.base_);
return L.top + idx;
}
else switch (idx) { /* pseudo-indices */
case LUA_REGISTRYINDEX: return Registry(L);
case LUA_ENVIRONINDEX: {
Closure func = CurrFunc(L);
SetHValue(L, L.env, func.c.env);
return L.env;
}
case LUA_GLOBALSINDEX: return Gt(L);
default: {
Closure func = CurrFunc(L);
idx = LUA_GLOBALSINDEX - idx;
return (idx <= func.c.nupvalues)
? func.c.upvalue[idx-1]
: (TValue)LuaONilObject;
}
}
}
示例13: Remove
public void Remove(LuaState luaState)
{
if (!translators.ContainsKey(luaState))
return;
translators.Remove(luaState);
}
示例14: CheckUserDataRaw
// Starting with 5.1 the auxlib version of checkudata throws an exception if the type isn't right
// Instead, we want to run our own version that checks the type and just returns null for failure
private static object CheckUserDataRaw (LuaState L, int ud, string tname)
{
object p = LuaToUserData (L, ud);
if (p != null) {
/* value is a userdata? */
if (LuaGetMetatable (L, ud) != 0) {
bool isEqual;
/* does it have a metatable? */
LuaGetField (L, LUA_REGISTRYINDEX, tname); /* get correct metatable */
isEqual = LuaRawEqual (L, -1, -2) != 0;
// NASTY - we need our own version of the lua_pop macro
// lua_pop(L, 2); /* remove both metatables */
LuaSetTop (L, -(2) - 1);
if (isEqual) /* does it have the correct mt? */
return p;
}
}
return null;
}
示例15: luaH_free
public static void luaH_free(LuaState L, Table t)
{
if (t.node[0] != dummynode)
LuaMFreeArray(L, t.node);
LuaMFreeArray(L, t.array);
LuaMFree(L, t);
}