本文整理汇总了C#中KopiLua.LuaState类的典型用法代码示例。如果您正苦于以下问题:C# LuaState类的具体用法?C# LuaState怎么用?C# LuaState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LuaState类属于KopiLua命名空间,在下文中一共展示了LuaState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:arkanoid1,项目名称:FakePacketSender,代码行数:10,代码来源:LuaFunction.cs
示例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);
}
开发者ID:arkanoid1,项目名称:FakePacketSender,代码行数:8,代码来源:lfunc.cs
示例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 */
}
}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:7,代码来源:ltm.cs
示例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 */
}
开发者ID:wuzhangwuzhang,项目名称:BWM,代码行数:31,代码来源:loadlib.cs
示例5: LuaNetGetMainState
public static LuaState LuaNetGetMainState(LuaState L1)
{
LuaGetField (L1, LUA_REGISTRYINDEX, "main_state");
LuaState main = LuaToThread (L1, -1);
LuaPop (L1, 1);
return main;
}
开发者ID:WondermSwift,项目名称:KopiLua,代码行数:7,代码来源:lnet.cs
示例6: Find
public ObjectTranslator Find(LuaState luaState)
{
if (!translators.ContainsKey(luaState))
return null;
return translators[luaState];
}
开发者ID:arkanoid1,项目名称:FakePacketSender,代码行数:7,代码来源:ObjectTranslatorPool.cs
示例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;
}
开发者ID:hanbim520,项目名称:UFLua,代码行数:26,代码来源:lnet.cs
示例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;
}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:27,代码来源:lfunc.cs
示例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;
}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:7,代码来源:lfunc.cs
示例10: DBGetMetatable
private static int DBGetMetatable (LuaState L) {
LuaLCheckAny(L, 1);
if (LuaGetMetatable(L, 1) == 0) {
LuaPushNil(L); /* no metatable */
}
return 1;
}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:7,代码来源:ldblib.cs
示例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");
}
开发者ID:arkanoid1,项目名称:FakePacketSender,代码行数:7,代码来源:ldebug.cs
示例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;
}
}
}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:28,代码来源:lapi.cs
示例13: Remove
public void Remove(LuaState luaState)
{
if (!translators.ContainsKey(luaState))
return;
translators.Remove(luaState);
}
开发者ID:arkanoid1,项目名称:FakePacketSender,代码行数:7,代码来源:ObjectTranslatorPool.cs
示例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;
}
开发者ID:hanbim520,项目名称:UFLua,代码行数:27,代码来源:lnet.cs
示例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);
}
开发者ID:WondermSwift,项目名称:KopiLua,代码行数:7,代码来源:ltable.cs
示例16: CurrentLine
private static int CurrentLine (LuaState L, CallInfo ci) {
int pc = CurrentPC(L, ci);
if (pc < 0)
return -1; /* only active lua functions have current-line information */
else
return GetLine(CIFunc(ci).l.p, pc);
}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:7,代码来源:ldebug.cs
示例17: IncCI
public static CallInfo IncCI(LuaState 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;
}
开发者ID:arkanoid1,项目名称:FakePacketSender,代码行数:7,代码来源:ldo.cs
示例18: LuaDCallHook
public static void LuaDCallHook(LuaState L, int event_, int line)
{
LuaHook hook = L.hook;
if ((hook != null) && (L.allowhook != 0))
{
ptrdiff_t top = SaveStack(L, L.top);
ptrdiff_t ci_top = SaveStack(L, L.ci.top);
LuaDebug ar = new LuaDebug();
ar.event_ = event_;
ar.currentline = line;
if (event_ == LUA_HOOKTAILRET)
ar.i_ci = 0; /* tail call; no debug information about it */
else
ar.i_ci = L.ci - L.base_ci;
LuaDCheckStack(L, LUA_MINSTACK); /* ensure minimum stack size */
L.ci.top = L.top + LUA_MINSTACK;
LuaAssert(L.ci.top <= L.stack_last);
L.allowhook = 0; /* cannot call hooks inside a hook */
LuaUnlock(L);
hook(L, ar);
LuaLock(L);
LuaAssert(L.allowhook == 0);
L.allowhook = 1;
L.ci.top = RestoreStack(L, ci_top);
L.top = RestoreStack(L, top);
}
}
开发者ID:arkanoid1,项目名称:FakePacketSender,代码行数:27,代码来源:ldo.cs
示例19: luaS_resize
public static void luaS_resize (LuaState 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 */
LuaAssert((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;
}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:30,代码来源:lstring.cs
示例20: newlstr
public static TString newlstr (LuaState L, CharPtr str, uint l,
uint h) {
TString ts;
stringtable tb;
if (l+1 > MAXSIZET /GetUnmanagedSize(typeof(char)))
LuaMTooBig(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 = LuaCWhite(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 <= MAXINT/2))
luaS_resize(L, tb.size*2); /* too crowded */
return ts;
}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:25,代码来源:lstring.cs
注:本文中的KopiLua.LuaState类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论