本文整理汇总了C#中KopiLua.Lua类的典型用法代码示例。如果您正苦于以下问题:C# Lua类的具体用法?C# Lua怎么用?C# Lua使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Lua类属于KopiLua命名空间,在下文中一共展示了Lua类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUsedMem
/// <summary>
/// Get the amount of memory used, according to the Lua memory manager
/// </summary>
/// <returns>Number of bytes used</returns>
public static uint GetUsedMem(Lua.lua_State L)
{
// Perform a full GC pass first
Lua.luaC_fullgc(L);
return L.l_G.totalbytes;
}
示例2: combine
static Lua.Proto combine(Lua.lua_State L, int n)
{
if (n==1)
return toproto(L,-1);
else
{
int i,pc;
Lua.Proto f=Lua.luaF_newproto(L);
Lua.setptvalue2s(L,L.top,f); Lua.incr_top(L);
f.source=Lua.luaS_newliteral(L,"=(" + PROGNAME + ")");
f.maxstacksize=1;
pc=2*n+1;
f.code = (Instruction[])Lua.luaM_newvector<Instruction>(L, pc);
f.sizecode=pc;
f.p = Lua.luaM_newvector<Lua.Proto>(L, n);
f.sizep=n;
pc=0;
for (i=0; i<n; i++)
{
f.p[i]=toproto(L,i-n-1);
f.code[pc++]=(uint)Lua.CREATE_ABx(Lua.OpCode.OP_CLOSURE,0,i);
f.code[pc++]=(uint)Lua.CREATE_ABC(Lua.OpCode.OP_CALL,0,1,1);
}
f.code[pc++]=(uint)Lua.CREATE_ABC(Lua.OpCode.OP_RETURN,0,1,0);
return f;
}
}
示例3: To
public override object To(Lua.lua_State State, int Index)
{
if (Lua.lua_isnumber(State, Index) > 0)
return (int)Lua.lua_tonumber(State, Index);
else
throw new Exception(String.Format("Expected integer (Got {0}).", Lua.lua_typename(State, Index).ToString()));
}
示例4: AssertLuaResult
public void AssertLuaResult(Lua.lua_State L, int result)
{
if (result != 0)
{
Utils.DumpStack(L);
Assert.Fail(GetLuaError(L));
}
}
示例5: GetLuaError
public string GetLuaError(Lua.lua_State L)
{
if (Lua.lua_gettop(L) == 0)
return "(no error message)";
var s = Lua.lua_tostring(L, -1);
if (s == null)
return "(null error message)";
return s.ToString();
}
示例6: report
static int report(Lua.lua_State L, int status)
{
if ((status!=0) && !Lua.lua_isnil(L, -1))
{
Lua.CharPtr msg = Lua.lua_tostring(L, -1);
if (msg == null) msg = "(error object is not a string)";
l_message(progname, msg);
Lua.lua_pop(L, 1);
}
return status;
}
示例7: DumpStack
public static void DumpStack(Lua.lua_State L)
{
for (int i = -Lua.lua_gettop(L); i < 0; ++i)
{
string s = "?";
int t = Lua.lua_type(L, i);
switch (t)
{
case Lua.LUA_TSTRING:
s = Lua.lua_tostring(L, i).ToString();
break;
case Lua.LUA_TBOOLEAN:
s = Lua.lua_toboolean(L, i) != 0 ? "true" : "false";
break;
case Lua.LUA_TNUMBER:
s = Lua.lua_tonumber(L, i).ToString();
break;
}
Debug.WriteLine(string.Format("{0}: {1} {2}", i, Lua.lua_typename(L, t), s));
}
}
示例8: Node
public Node(Lua.LuaTypeValue i_val, TKey i_key)
{
this.values = new Node[] { this };
this.index = 0;
this.i_val = i_val;
this.i_key = i_key;
}
示例9: IsCollectable
internal static bool IsCollectable(Lua.LuaTypeValue o) { return (TType(o) >= LUA_TSTRING); }
示例10: SetSValue2N
//#define setsvalue2n setsvalue
internal static void SetSValue2N(LuaState L, Lua.LuaTypeValue obj, TString x) { SetSValue(L, obj, x); }
示例11: SetPTValue2S
//#define setptvalue2s setptvalue
internal static void SetPTValue2S(LuaState L, Lua.LuaTypeValue obj, Proto x) { SetPTValue(L, obj, x); }
示例12: SetObj
internal static void SetObj(LuaState L, Lua.LuaTypeValue obj1, Lua.LuaTypeValue obj2) {
obj1.value.Copy(obj2.value);
obj1.tt = obj2.tt;
CheckLiveness(G(L), obj1);
}
示例13: SetHValue
internal static void SetHValue(LuaState L, Lua.LuaTypeValue obj, Table x) {
obj.value.gc = x;
obj.tt = LUA_TTABLE;
CheckLiveness(G(L), obj);
}
示例14: THValue
internal static LuaState THValue(Lua.LuaTypeValue o) { return (LuaState)CheckExp(TTIsThread(o), o.value.gc.th); }
示例15: BValue
internal static int BValue(Lua.LuaTypeValue o) { return o.value.b; }