本文整理汇总了C#中KopiLua类的典型用法代码示例。如果您正苦于以下问题:C# KopiLua类的具体用法?C# KopiLua怎么用?C# KopiLua使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KopiLua类属于命名空间,在下文中一共展示了KopiLua类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createIndexingMetaFunction
/*
* Registers the indexing function of CLR objects
* passed to Lua
*/
private void createIndexingMetaFunction(KopiLua.Lua.lua_State luaState)
{
LuaDll.lua_pushstring(luaState,"luaNet_indexfunction");
LuaDll.luaL_dostring(luaState,MetaFunctions.luaIndexFunction); // steffenj: lua_dostring renamed to luaL_dostring
//LuaDLL.lua_pushstdcallcfunction(luaState,indexFunction);
LuaDll.lua_rawset(luaState, (int) LuaIndexes.LUA_REGISTRYINDEX);
}
示例2: createLuaObjectList
/*
* Sets up the list of objects in the Lua side
*/
private void createLuaObjectList(KopiLua.Lua.lua_State luaState)
{
LuaDll.lua_pushstring(luaState,"luaNet_objects");
LuaDll.lua_newtable(luaState);
LuaDll.lua_newtable(luaState);
LuaDll.lua_pushstring(luaState,"__mode");
LuaDll.lua_pushstring(luaState,"v");
LuaDll.lua_settable(luaState,-3);
LuaDll.lua_setmetatable(luaState,-2);
LuaDll.lua_settable(luaState, (int) LuaIndexes.LUA_REGISTRYINDEX);
}
示例3: createBaseClassMetatable
/*
* Creates the metatable for superclasses (the base
* field of registered tables)
*/
private void createBaseClassMetatable(KopiLua.Lua.lua_State luaState)
{
LuaDll.luaL_newmetatable(luaState,"luaNet_searchbase");
LuaDll.lua_pushstring(luaState,"__gc");
LuaDll.lua_pushstdcallcfunction(luaState,metaFunctions.gcFunction);
LuaDll.lua_settable(luaState,-3);
LuaDll.lua_pushstring(luaState,"__tostring");
LuaDll.lua_pushstdcallcfunction(luaState,metaFunctions.toStringFunction);
LuaDll.lua_settable(luaState,-3);
LuaDll.lua_pushstring(luaState,"__index");
LuaDll.lua_pushstdcallcfunction(luaState,metaFunctions.baseIndexFunction);
LuaDll.lua_settable(luaState,-3);
LuaDll.lua_pushstring(luaState,"__newindex");
LuaDll.lua_pushstdcallcfunction(luaState,metaFunctions.newindexFunction);
LuaDll.lua_settable(luaState,-3);
LuaDll.lua_settop(luaState,-2);
}
示例4: getAsObject
public object getAsObject(KopiLua.Lua.lua_State luaState,int stackPos)
{
if(LuaDLL.lua_type(luaState,stackPos)==LuaTypes.LUA_TTABLE)
{
if(LuaDLL.luaL_getmetafield(luaState,stackPos,"__index"))
{
if(LuaDLL.luaL_checkmetatable(luaState,-1))
{
LuaDLL.lua_insert(luaState,stackPos);
LuaDLL.lua_remove(luaState,stackPos+1);
}
else
{
LuaDLL.lua_settop(luaState,-2);
}
}
}
object obj=translator.getObject(luaState,stackPos);
return obj;
}
示例5: ObjectTranslator
public ObjectTranslator(Lua interpreter,KopiLua.Lua.lua_State luaState)
{
this.interpreter=interpreter;
typeChecker=new CheckType(this);
metaFunctions=new MetaFunctions(this);
assemblies=new List<Assembly>();
importTypeFunction=new KopiLua.Lua.lua_CFunction(this.importType);
loadAssemblyFunction=new KopiLua.Lua.lua_CFunction(this.loadAssembly);
registerTableFunction=new KopiLua.Lua.lua_CFunction(this.registerTable);
unregisterTableFunction=new KopiLua.Lua.lua_CFunction(this.unregisterTable);
getMethodSigFunction=new KopiLua.Lua.lua_CFunction(this.getMethodSignature);
getConstructorSigFunction=new KopiLua.Lua.lua_CFunction(this.getConstructorSignature);
createLuaObjectList(luaState);
createIndexingMetaFunction(luaState);
createBaseClassMetatable(luaState);
createClassMetatable(luaState);
createFunctionMetatable(luaState);
setGlobalFunctions(luaState);
}
示例6: dumpStack
/// <summary>
/// Debug tool to dump the lua stack
/// </summary>
/// FIXME, move somewhere else
public static void dumpStack(ObjectTranslator translator, KopiLua.Lua.lua_State luaState)
{
int depth = LuaDll.lua_gettop(luaState);
Debug.WriteLine("lua stack depth: " + depth);
for (int i = 1; i <= depth; i++)
{
LuaTypes type = LuaDll.lua_type(luaState, i);
// we dump stacks when deep in calls, calling typename while the stack is in flux can fail sometimes, so manually check for key types
string typestr = (type == LuaTypes.LUA_TTABLE) ? "table" : LuaDll.lua_typename(luaState, type);
string strrep = LuaDll.lua_tostring(luaState, i);
if (type == LuaTypes.LUA_TUSERDATA)
{
object obj = translator.getRawNetObject(luaState, i);
strrep = obj.ToString();
}
Debug.Print("{0}: ({1}) {2}", i, typestr, strrep);
}
}
示例7: traceback
private int traceback(KopiLua.Lua.lua_State luaState)
{
LuaDLL.lua_getglobal(luaState,"debug");
LuaDLL.lua_getfield(luaState,-1,"traceback");
LuaDLL.lua_pushvalue(luaState,1);
LuaDLL.lua_pushnumber(luaState,2);
LuaDLL.lua_call (luaState,2,1);
return 1;
}
示例8: PanicCallback
static int PanicCallback(KopiLua.Lua.lua_State luaState)
{
// string desc = LuaDLL.lua_tostring(luaState, 1);
// string desc = LuaDLL.lua_tostring(luaState, 1);
string reason = String.Format("unprotected error in call to Lua API ({0})", LuaDLL.lua_tostring(luaState, -1));
// lua_tostring(L, -1);
throw new LuaException(reason);
}
示例9: Lua
/*
* CAUTION: LuaInterface.Lua instances can't share the same lua state!
*/
public Lua(KopiLua.Lua.lua_State lState)
{
//IntPtr lState = new IntPtr(luaState);
LuaDLL.lua_pushstring(lState, "LUAINTERFACE LOADED");
LuaDLL.lua_gettable(lState, (int)LuaIndexes.LUA_REGISTRYINDEX);
if(LuaDLL.lua_toboolean(lState,-1))
{
LuaDLL.lua_settop(lState,-2);
throw new LuaException("There is already a LuaInterface.Lua instance associated with this Lua state");
}
else
{
LuaDLL.lua_settop(lState,-2);
LuaDLL.lua_pushstring(lState, "LUAINTERFACE LOADED");
LuaDLL.lua_pushboolean(lState, true);
LuaDLL.lua_settable(lState, (int)LuaIndexes.LUA_REGISTRYINDEX);
this.luaState=lState;
LuaDLL.lua_pushvalue(lState, (int)LuaIndexes.LUA_GLOBALSINDEX);
LuaDLL.lua_getglobal(lState, "luanet");
LuaDLL.lua_pushstring(lState, "getmetatable");
LuaDLL.lua_getglobal(lState, "getmetatable");
LuaDLL.lua_settable(lState, -3);
LuaDLL.lua_replace(lState, (int)LuaIndexes.LUA_GLOBALSINDEX);
translator=new ObjectTranslator(this, this.luaState);
LuaDLL.lua_replace(lState, (int)LuaIndexes.LUA_GLOBALSINDEX);
LuaDLL.luaL_dostring(lState, Lua.init_luanet); // steffenj: lua_dostring renamed to luaL_dostring
}
_StatePassed = true;
}
示例10: getAsUserdata
private object getAsUserdata(KopiLua.Lua.lua_State luaState,int stackPos)
{
return translator.getUserData(luaState,stackPos);
}
示例11: getAsString
private object getAsString(KopiLua.Lua.lua_State luaState,int stackPos)
{
string retVal=LuaDLL.lua_tostring(luaState,stackPos);
if(retVal=="" && !LuaDLL.lua_isstring(luaState,stackPos)) return null;
return retVal;
}
示例12: luaL_getmetatable
internal static void luaL_getmetatable(KopiLua.LuaState state, string n)
{
Lua.LuaLGetMetatable(state, n);
}
示例13: abs_index
internal static int abs_index(KopiLua.LuaState state, int i)
{
return Lua.AbsIndex(state, i);
}
示例14: lua_type
internal static LuaType lua_type(KopiLua.LuaState state, int idx)
{
return (LuaType)Lua.LuaType(state, idx);
}
示例15: lua_touserdata
internal static object lua_touserdata(KopiLua.LuaState state, int idx)
{
return Lua.LuaToUserData(state, idx);
}