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

C# LuaCSFunction类代码示例

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

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



LuaCSFunction类属于命名空间,在下文中一共展示了LuaCSFunction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ObjectTranslator

        public ObjectTranslator(LuaState interpreter,IntPtr luaState)
        {
            this.interpreter=interpreter;
            typeChecker=new CheckType(this);
            metaFunctions=new MetaFunctions(this);
            assemblies=new List<Assembly>();
            assemblies.Add(Assembly.GetExecutingAssembly());

            importTypeFunction = new LuaCSFunction(ObjectTranslator.importType);
            loadAssemblyFunction = new LuaCSFunction(ObjectTranslator.loadAssembly);
            registerTableFunction = new LuaCSFunction(ObjectTranslator.registerTable);
            unregisterTableFunction = new LuaCSFunction(ObjectTranslator.unregisterTable);
            getMethodSigFunction = new LuaCSFunction(ObjectTranslator.getMethodSignature);
            getConstructorSigFunction = new LuaCSFunction(ObjectTranslator.getConstructorSignature);

            ctypeFunction = new LuaCSFunction(ObjectTranslator.ctype);
            enumFromIntFunction = new LuaCSFunction(ObjectTranslator.enumFromInt);

            createLuaObjectList(luaState);
            createIndexingMetaFunction(luaState);
            createBaseClassMetatable(luaState);
            createClassMetatable(luaState);
            createFunctionMetatable(luaState);
            setGlobalFunctions(luaState);
        }
开发者ID:sysuyedong,项目名称:LuaForUnity,代码行数:25,代码来源:ObjectTranslator.cs


示例2: ObjectTranslator

        public ObjectTranslator(Lua interpreter,IntPtr luaState)
        {
            this.interpreter=interpreter;
            typeChecker=new CheckType(this);
            metaFunctions=new MetaFunctions(this);
            objects=new ArrayList();
            assemblies=new ArrayList();

            importTypeFunction=new LuaCSFunction(this.importType);
            importType__indexFunction=new LuaCSFunction(this.importType__index);
            loadAssemblyFunction=new LuaCSFunction(this.loadAssembly);
            loadAssemblyFromFunction=new LuaCSFunction(this.loadAssemblyFrom);
            registerTableFunction=new LuaCSFunction(this.registerTable);
            unregisterTableFunction=new LuaCSFunction(this.unregisterTable);
            getMethodSigFunction=new LuaCSFunction(this.getMethodSignature);
            getConstructorSigFunction=new LuaCSFunction(this.getConstructorSignature);

            createLuaObjectList(luaState);
            createIndexingMetaFunction(luaState);
            createBaseClassMetatable(luaState);
            createClassMetatable(luaState);
            createFunctionMetatable(luaState);
            setGlobalFunctions(luaState);

            LuaDLL.lua_dostring(luaState, "load_assembly('mscorlib')");
        }
开发者ID:mentaldease,项目名称:bastionlandscape,代码行数:26,代码来源:ObjectTranslator.cs


示例3: LuaFunction

 public LuaFunction(LuaCSFunction function, LuaState interpreter)
 {
     _Reference = 0;
     this.function = function;
     _Interpreter = interpreter;
     L = _Interpreter.L;
     translator = _Interpreter.translator;            
 }
开发者ID:zhangf911,项目名称:hugular_cstolua,代码行数:8,代码来源:LuaFunction.cs


示例4: LuaState

        public LuaState() {
            // Create State
            L = LuaDLL.luaL_newstate();

            // Create LuaInterface library
            LuaDLL.luaL_openlibs(L);
            LuaDLL.lua_pushstring(L, "LUAINTERFACE LOADED");
            LuaDLL.lua_pushboolean(L, true);
            LuaDLL.lua_settable(L, (int)LuaIndexes.LUA_REGISTRYINDEX);

            tracebackFunction = new LuaCSFunction(error_traceback);

            // We need to keep this in a managed reference so the delegate doesn't get garbage collected
            panicCallback = new LuaCSFunction(panic);
            LuaDLL.lua_atpanic(L, panicCallback);
            printFunction = new LuaCSFunction(print);
            LuaDLL.lua_pushstdcallcfunction(L, printFunction);
            LuaDLL.lua_setfield(L, LuaIndexes.LUA_GLOBALSINDEX, "print");

            loadfileFunction = new LuaCSFunction(loadfile);
            LuaDLL.lua_pushstdcallcfunction(L, loadfileFunction);
            LuaDLL.lua_setfield(L, LuaIndexes.LUA_GLOBALSINDEX, "loadfile");

            dofileFunction = new LuaCSFunction(dofile);
            LuaDLL.lua_pushstdcallcfunction(L, dofileFunction);
            LuaDLL.lua_setfield(L, LuaIndexes.LUA_GLOBALSINDEX, "dofile");
            LuaDLL.lua_pushstdcallcfunction(L, dofileFunction);
            LuaDLL.lua_setfield(L, LuaIndexes.LUA_GLOBALSINDEX, "require");

            LuaDLL.lua_newtable(L);
            LuaDLL.lua_newtable(L);
            LuaDLL.lua_pushstring(L, "v");
            LuaDLL.lua_setfield(L, -2, "__mode");
            LuaDLL.lua_setmetatable(L, -2);
            LuaDLL.lua_setfield(L, LuaIndexes.LUA_REGISTRYINDEX, LuaStatic.CACHE_CSHARP_OBJECT_TABLE);

            // Insert our loader FIRST
            loaderFunction = new LuaCSFunction(loader);
            LuaDLL.lua_pushstdcallcfunction(L, loaderFunction);
            int loaderFunc = LuaDLL.lua_gettop(L);

            LuaDLL.lua_getfield(L, LuaIndexes.LUA_GLOBALSINDEX, "package");
            LuaDLL.lua_getfield(L, -1, "loaders");
            int loaderTable = LuaDLL.lua_gettop(L);

            // Shift table elements right
            for (int e = LuaDLL.luaL_getn(L, loaderTable) + 1; e > 1; e--) {
                LuaDLL.lua_rawgeti(L, loaderTable, e - 1);
                LuaDLL.lua_rawseti(L, loaderTable, e);
            }
            LuaDLL.lua_pushvalue(L, loaderFunc);
            LuaDLL.lua_rawseti(L, loaderTable, 1);
            LuaDLL.lua_settop(L, 0);
        }
开发者ID:musicseli,项目名称:emoji,代码行数:54,代码来源:LuaState.cs


示例5: MetaFunctions

 public MetaFunctions(ObjectTranslator translator)
 {
     this.translator = translator;
     gcFunction = new LuaCSFunction(this.collectObject);
     toStringFunction = new LuaCSFunction(this.toString);
     indexFunction = new LuaCSFunction(this.getMethod);
     newindexFunction = new LuaCSFunction(this.setFieldOrProperty);
     baseIndexFunction = new LuaCSFunction(this.getBaseMethod);
     callConstructorFunction = new LuaCSFunction(this.callConstructor);
     classIndexFunction = new LuaCSFunction(this.getClassMethod);
     classNewindexFunction = new LuaCSFunction(this.setClassFieldOrProperty);
     execDelegateFunction = new LuaCSFunction(this.runFunctionDelegate);
 }
开发者ID:cupsster,项目名称:vongott-unity,代码行数:13,代码来源:Metatables.cs


示例6: ObjectTranslator

 public ObjectTranslator(Lua interpreter, IntPtr luaState)
 {
     this.interpreter = interpreter;
     this.typeChecker = new CheckType(this);
     this.metaFunctions = new MetaFunctions(this);
     this.assemblies = new List<Assembly>();
     this.importTypeFunction = new LuaCSFunction(this.importType);
     this.loadAssemblyFunction = new LuaCSFunction(this.loadAssembly);
     this.registerTableFunction = new LuaCSFunction(this.registerTable);
     this.unregisterTableFunction = new LuaCSFunction(this.unregisterTable);
     this.getMethodSigFunction = new LuaCSFunction(this.getMethodSignature);
     this.getConstructorSigFunction = new LuaCSFunction(this.getConstructorSignature);
     this.createLuaObjectList(luaState);
     this.createIndexingMetaFunction(luaState);
     this.createBaseClassMetatable(luaState);
     this.createClassMetatable(luaState);
     this.createFunctionMetatable(luaState);
     this.setGlobalFunctions(luaState);
 }
开发者ID:Evangileon,项目名称:LuaInterface,代码行数:19,代码来源:ObjectTranslator.cs


示例7: Lua

 public Lua()
 {
     this.luaLock = new object();
     this.luaState = LuaJIT.luaL_newstate();
     LuaJIT.luaL_openlibs(this.luaState);
     LuaJIT.lua_pushstring(this.luaState, "LUAINTERFACE LOADED");
     LuaJIT.lua_pushboolean(this.luaState, 1);
     LuaJIT.lua_settable(this.luaState, -10000);
     LuaJIT.lua_newtable(this.luaState);
     LuaJIT.lua_setglobal(this.luaState, "luanet");
     LuaJIT.lua_pushvalue(this.luaState, -10002);
     LuaJIT.lua_getglobal(this.luaState, "luanet");
     LuaJIT.lua_pushstring(this.luaState, "getmetatable");
     LuaJIT.lua_getglobal(this.luaState, "getmetatable");
     LuaJIT.lua_settable(this.luaState, -3);
     LuaJIT.lua_replace(this.luaState, -10002);
     this.translator = new ObjectTranslator(this, this.luaState);
     LuaJIT.lua_replace(this.luaState, -10002);
     LuaJIT.luaL_dostring(this.luaState, init_luanet);
     this.panicCallback = new LuaCSFunction(Lua.PanicCallback);
     LuaJIT.lua_atpanic(this.luaState, this.panicCallback);
 }
开发者ID:Evangileon,项目名称:LuaInterface,代码行数:22,代码来源:Lua.cs


示例8: lua_register

 public static void lua_register(IntPtr luaState, string name, LuaCSFunction func)
 {
     lua_pushcfunction(luaState, func);
     lua_setglobal(luaState, name);
 }
开发者ID:youxibuhaowana,项目名称:LuaFramework_UGUI,代码行数:5,代码来源:LuaDLL.cs


示例9: lua_pushcfunction

 public static void lua_pushcfunction(IntPtr luaState, LuaCSFunction func)
 {
     IntPtr fn = Marshal.GetFunctionPointerForDelegate(func);
     lua_pushcclosure(luaState, fn, 0);
 }
开发者ID:youxibuhaowana,项目名称:LuaFramework_UGUI,代码行数:5,代码来源:LuaDLL.cs


示例10: lua_pushcclosure

 public static void lua_pushcclosure(IntPtr l, LuaCSFunction f, int nup)
 {
     IntPtr fn = Marshal.GetFunctionPointerForDelegate(f);
     lua_pushcclosure(l, fn, nup);
 }
开发者ID:nottvlike,项目名称:OpenWorldGame,代码行数:5,代码来源:LuaDLL.cs


示例11: lua_atpanic

 public static extern IntPtr lua_atpanic(IntPtr luaState, LuaCSFunction panicf);
开发者ID:nottvlike,项目名称:OpenWorldGame,代码行数:1,代码来源:LuaDLL.cs


示例12: lua_pushstdcallcfunction

		public static void lua_pushstdcallcfunction(IntPtr luaState, LuaCSFunction function, int n = 0)
		{
			IntPtr fn = Marshal.GetFunctionPointerForDelegate(function);			
            lua_pushcclosure(luaState, fn, n);           
		}        
开发者ID:wangwuyi,项目名称:SimpleFramework_NGUI,代码行数:5,代码来源:LuaDLL.cs


示例13: pushCSFunction

 internal void pushCSFunction(LuaCSFunction function)
 {
     this.translator.pushFunction(this.luaState, function);
 }
开发者ID:Evangileon,项目名称:LuaInterface,代码行数:4,代码来源:Lua.cs


示例14: lua_atpanic

 public static extern LuaCSFunction lua_atpanic(IntPtr l, LuaCSFunction f);
开发者ID:huiguochen,项目名称:Lua4Net,代码行数:1,代码来源:Lua.cs


示例15: LuaState

        public LuaState()
        {
            // Create State
            L = LuaDLL.luaL_newstate();

            // Create LuaInterface library
            LuaDLL.luaL_openlibs(L);
            LuaDLL.lua_pushstring(L, "LUAINTERFACE LOADED");
            LuaDLL.lua_pushboolean(L, true);
            LuaDLL.lua_settable(L, (int) LuaIndexes.LUA_REGISTRYINDEX);
            LuaDLL.lua_newtable(L);
            LuaDLL.lua_setglobal(L, "luanet");
            LuaDLL.lua_pushvalue(L, (int)LuaIndexes.LUA_GLOBALSINDEX);
            LuaDLL.lua_getglobal(L, "luanet");
            LuaDLL.lua_pushstring(L, "getmetatable");
            LuaDLL.lua_getglobal(L, "getmetatable");
            LuaDLL.lua_settable(L, -3);

            // Set luanet as global for object translator
            LuaDLL.lua_replace(L, (int)LuaIndexes.LUA_GLOBALSINDEX);
            translator = new ObjectTranslator(this,L);
            LuaDLL.lua_replace(L, (int)LuaIndexes.LUA_GLOBALSINDEX);

            translator.PushTranslator(L);
            //GCHandle handle = GCHandle.Alloc(translator, GCHandleType.Pinned);
            //IntPtr thisptr = GCHandle.ToIntPtr(handle);
            //LuaDLL.lua_pushlightuserdata(L, thisptr);
            //LuaDLL.lua_setglobal(L, "_translator");            

            // We need to keep this in a managed reference so the delegate doesn't get garbage collected
			panicCallback = new LuaCSFunction(LuaStatic.panic);
            LuaDLL.lua_atpanic(L, panicCallback);

            printFunction = new LuaCSFunction(LuaStatic.print);
            LuaDLL.lua_pushstdcallcfunction(L, printFunction);
            LuaDLL.lua_setfield(L, LuaIndexes.LUA_GLOBALSINDEX, "print");

            loadfileFunction = new LuaCSFunction(LuaStatic.loadfile);
            LuaDLL.lua_pushstdcallcfunction(L, loadfileFunction);
            LuaDLL.lua_setfield(L, LuaIndexes.LUA_GLOBALSINDEX, "loadfile");

            dofileFunction = new LuaCSFunction(LuaStatic.dofile);
            LuaDLL.lua_pushstdcallcfunction(L, dofileFunction);
            LuaDLL.lua_setfield(L, LuaIndexes.LUA_GLOBALSINDEX, "dofile");

            // Insert our loader FIRST
            loaderFunction = new LuaCSFunction(LuaStatic.loader);
            LuaDLL.lua_pushstdcallcfunction(L, loaderFunction);
            int loaderFunc = LuaDLL.lua_gettop( L );

            LuaDLL.lua_getfield( L, LuaIndexes.LUA_GLOBALSINDEX, "package" );
            LuaDLL.lua_getfield( L, -1, "loaders" );
            int loaderTable = LuaDLL.lua_gettop( L );

            // Shift table elements right
            for( int e = LuaDLL.luaL_getn( L, loaderTable ) + 1; e > 1; e-- ) 
            {
                LuaDLL.lua_rawgeti( L, loaderTable, e-1 );
                LuaDLL.lua_rawseti( L, loaderTable, e );
            }
            LuaDLL.lua_pushvalue( L, loaderFunc );
            LuaDLL.lua_rawseti( L, loaderTable, 1 );
            LuaDLL.lua_settop( L, 0 );

            DoString(LuaStatic.init_luanet);            
            tracebackFunction = new LuaCSFunction(LuaStatic.traceback);
        }
开发者ID:ylyking,项目名称:UnityHotUpdate,代码行数:67,代码来源:Lua.cs


示例16: init

		void init()
		{
			luaState = LuaDLL.luaL_newstate();	// steffenj: Lua 5.1.1 API change (lua_open is gone)
			//LuaDLL.luaopen_base(luaState);	// steffenj: luaopen_* no longer used
			LuaDLL.luaL_openlibs(luaState);		// steffenj: Lua 5.1.1 API change (luaopen_base is gone, just open all libs right here)
		    LuaDLL.lua_pushstring(luaState, "LUAINTERFACE LOADED");
            LuaDLL.lua_pushboolean(luaState, true);
            LuaDLL.lua_settable(luaState, (int) LuaIndexes.LUA_REGISTRYINDEX);
			LuaDLL.lua_newtable(luaState);
			LuaDLL.lua_setglobal(luaState, "luanet");
            LuaDLL.lua_pushvalue(luaState, (int)LuaIndexes.LUA_GLOBALSINDEX);
			LuaDLL.lua_getglobal(luaState, "luanet");
			LuaDLL.lua_pushstring(luaState, "getmetatable");
			LuaDLL.lua_getglobal(luaState, "getmetatable");
			LuaDLL.lua_settable(luaState, -3);
            LuaDLL.lua_replace(luaState, (int)LuaIndexes.LUA_GLOBALSINDEX);
			translator=new ObjectTranslator(this,luaState);
            LuaDLL.lua_replace(luaState, (int)LuaIndexes.LUA_GLOBALSINDEX);
			LuaDLL.luaL_dostring(luaState, Lua.init_luanet);	// steffenj: lua_dostring renamed to luaL_dostring

            // We need to keep this in a managed reference so the delegate doesn't get garbage collected
            panicCallback = new LuaCSFunction(PanicCallback);
            LuaDLL.lua_atpanic(luaState, panicCallback);

            //LuaDLL.lua_atlock(luaState, lockCallback = new LuaCSFunction(LockCallback));
            //LuaDLL.lua_atunlock(luaState, unlockCallback = new LuaCSFunction(UnlockCallback));
        }
开发者ID:CadeLaRen,项目名称:BizHawk,代码行数:27,代码来源:Lua.cs


示例17: SetOutMethods

        static void SetOutMethods(IntPtr L, string table, LuaCSFunction getOutFunc = null)
        {
            LuaDLL.lua_getglobal(L, table);
            IntPtr get = Marshal.GetFunctionPointerForDelegate(getOutFunc);
            LuaDLL.tolua_variable(L, "out", get, IntPtr.Zero);

            LuaDLL.lua_pop(L, 1);
        }
开发者ID:RuYi51,项目名称:LuaFramework_NGUI,代码行数:8,代码来源:LuaUnityLibs.cs


示例18: lua_pushcclosure

        public static void lua_pushcclosure(IntPtr l, LuaCSFunction f, int nup)
        {
#if SLUA_STANDALONE
            // Add all LuaCSFunction£¬ or they will be GC collected!  (problem at windows, .net framework 4.5, `CallbackOnCollectedDelegated` exception)
            GCHandle.Alloc(f);
#endif
            IntPtr fn = Marshal.GetFunctionPointerForDelegate(f);
            lua_pushcclosure(l, fn, nup);
        }
开发者ID:yonglehou,项目名称:KSFramework,代码行数:9,代码来源:LuaDLL.cs


示例19: lua_atunlock

 public static void lua_atunlock(Lua.lua_State luaState, LuaCSFunction^ unlockf);
开发者ID:haiweizhang,项目名称:kopiluainterface,代码行数:1,代码来源:LuaDLL.cs


示例20: lua_atlock

		// not yet implemented
        public static void lua_atlock(Lua.lua_State luaState, LuaCSFunction^ lockf)
		{
			IntPtr p = Marshal::GetFunctionPointerForDelegate(lockf);
			Lua.lua_atlock(luaState, (lua_CFunction) p.ToPointer());
		}
开发者ID:haiweizhang,项目名称:kopiluainterface,代码行数:6,代码来源:LuaDLL.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# LuaEventArgs类代码示例发布时间:2022-05-24
下一篇:
C# Lua类代码示例发布时间: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