当前位置: 首页>>代码示例>>C#>>正文


C# LuaCSFunction类代码示例

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


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


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