• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# KopiLua类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中KopiLua的典型用法代码示例。如果您正苦于以下问题:C# KopiLua类的具体用法?C# KopiLua怎么用?C# KopiLua使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



KopiLua类属于命名空间,在下文中一共展示了KopiLua类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
		}
开发者ID:Henry-T,项目名称:UnityPG,代码行数:11,代码来源:ObjectTranslator.cs


示例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);
		}
开发者ID:Henry-T,项目名称:UnityPG,代码行数:14,代码来源:ObjectTranslator.cs


示例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);
		}
开发者ID:Henry-T,项目名称:UnityPG,代码行数:21,代码来源:ObjectTranslator.cs


示例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;
 }
开发者ID:haiweizhang,项目名称:kopiluainterface,代码行数:20,代码来源:CheckType.cs


示例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);
        }
开发者ID:haiweizhang,项目名称:kopiluainterface,代码行数:21,代码来源:ObjectTranslator.cs


示例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);
            }
        }
开发者ID:niuniuzhu,项目名称:kopiluainterface,代码行数:25,代码来源:Metatables.cs


示例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;
 }
开发者ID:huxia,项目名称:kopiluainterface,代码行数:9,代码来源:Lua.cs


示例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);
        }
开发者ID:huxia,项目名称:kopiluainterface,代码行数:11,代码来源:Lua.cs


示例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;
        }
开发者ID:huxia,项目名称:kopiluainterface,代码行数:34,代码来源:Lua.cs


示例10: getAsUserdata

 private object getAsUserdata(KopiLua.Lua.lua_State luaState,int stackPos)
 {
     return translator.getUserData(luaState,stackPos);
 }
开发者ID:haiweizhang,项目名称:kopiluainterface,代码行数:4,代码来源:CheckType.cs


示例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;
 }
开发者ID:haiweizhang,项目名称:kopiluainterface,代码行数:6,代码来源:CheckType.cs


示例12: luaL_getmetatable

 internal static void luaL_getmetatable(KopiLua.LuaState state, string n)
 {
     Lua.LuaLGetMetatable(state, n);
 }
开发者ID:WFoundation,项目名称:Eluant,代码行数:4,代码来源:LuaApi.cs


示例13: abs_index

 internal static int abs_index(KopiLua.LuaState state, int i)
 {
     return Lua.AbsIndex(state, i);
 }
开发者ID:WFoundation,项目名称:Eluant,代码行数:4,代码来源:LuaApi.cs


示例14: lua_type

 internal static LuaType lua_type(KopiLua.LuaState state, int idx)
 {
     return (LuaType)Lua.LuaType(state, idx);
 }
开发者ID:WFoundation,项目名称:Eluant,代码行数:4,代码来源:LuaApi.cs


示例15: lua_touserdata

 internal static object lua_touserdata(KopiLua.LuaState state, int idx)
 {
     return Lua.LuaToUserData(state, idx);
 }
开发者ID:WFoundation,项目名称:Eluant,代码行数:4,代码来源:LuaApi.cs


示例16: getAsLong

 private object getAsLong(KopiLua.Lua.lua_State luaState,int stackPos)
 {
     long retVal=(long)LuaDLL.lua_tonumber(luaState,stackPos);
     if(retVal==0 && !LuaDLL.lua_isnumber(luaState,stackPos)) return null;
     return retVal;
 }
开发者ID:haiweizhang,项目名称:kopiluainterface,代码行数:6,代码来源:CheckType.cs


示例17: getAsSbyte

 /*
  * The following functions return the value in the Lua stack
  * index stackPos as the desired type if it can, or null
  * otherwise.
  */
 private object getAsSbyte(KopiLua.Lua.lua_State luaState,int stackPos)
 {
     sbyte retVal=(sbyte)LuaDLL.lua_tonumber(luaState,stackPos);
     if(retVal==0 && !LuaDLL.lua_isnumber(luaState,stackPos)) return null;
     return retVal;
 }
开发者ID:haiweizhang,项目名称:kopiluainterface,代码行数:11,代码来源:CheckType.cs


示例18: luaL_loadbuffer

 internal static int luaL_loadbuffer(KopiLua.LuaState state, byte[] bytes, int size, string name)
 {
     return Lua.LuaLLoadBuffer(state, bytes, (uint)size, name);
 }
开发者ID:WFoundation,项目名称:Eluant,代码行数:4,代码来源:LuaApi.cs


示例19: getAsTable

 private object getAsTable(KopiLua.Lua.lua_State luaState,int stackPos)
 {
     return translator.getTable(luaState,stackPos);
 }
开发者ID:haiweizhang,项目名称:kopiluainterface,代码行数:4,代码来源:CheckType.cs


示例20: Func

 static int Func(KopiLua.Lua.lua_State L)
 {
     int n = KopiLua.Lua.lua_gettop(L);
     KopiLua.Lua.lua_pushnumber(L, n * 2);
     return 1;
 }
开发者ID:niuniuzhu,项目名称:kopiluainterface,代码行数:6,代码来源:Program.cs



注:本文中的KopiLua类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# KopiLua.Lua类代码示例发布时间:2022-05-24
下一篇:
C# KnownTypeCode类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap