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

C# LuaInterface.ObjectTranslator类代码示例

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

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



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

示例1: CheckType

        public CheckType(ObjectTranslator translator)
        {
            this.translator = translator;

            extractValues.Add(typeof(object).TypeHandle.Value.ToInt64(), new ExtractValue(getAsObject));
            extractValues.Add(typeof(sbyte).TypeHandle.Value.ToInt64(), new ExtractValue(getAsSbyte));
            extractValues.Add(typeof(byte).TypeHandle.Value.ToInt64(), new ExtractValue(getAsByte));
            extractValues.Add(typeof(short).TypeHandle.Value.ToInt64(), new ExtractValue(getAsShort));
            extractValues.Add(typeof(ushort).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUshort));
            extractValues.Add(typeof(int).TypeHandle.Value.ToInt64(), new ExtractValue(getAsInt));
            extractValues.Add(typeof(uint).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUint));
            extractValues.Add(typeof(long).TypeHandle.Value.ToInt64(), new ExtractValue(getAsLong));
            extractValues.Add(typeof(ulong).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUlong));
            extractValues.Add(typeof(double).TypeHandle.Value.ToInt64(), new ExtractValue(getAsDouble));
            extractValues.Add(typeof(char).TypeHandle.Value.ToInt64(), new ExtractValue(getAsChar));
            extractValues.Add(typeof(float).TypeHandle.Value.ToInt64(), new ExtractValue(getAsFloat));
            extractValues.Add(typeof(decimal).TypeHandle.Value.ToInt64(), new ExtractValue(getAsDecimal));
            extractValues.Add(typeof(bool).TypeHandle.Value.ToInt64(), new ExtractValue(getAsBoolean));
            extractValues.Add(typeof(string).TypeHandle.Value.ToInt64(), new ExtractValue(getAsString));
            extractValues.Add(typeof(LuaFunction).TypeHandle.Value.ToInt64(), new ExtractValue(getAsFunction));
            extractValues.Add(typeof(LuaTable).TypeHandle.Value.ToInt64(), new ExtractValue(getAsTable));            

            extractValues.Add(typeof(Vector3).TypeHandle.Value.ToInt64(), new ExtractValue(getAsVector3));

            extractValues.Add(typeof(Vector2).TypeHandle.Value.ToInt64(), new ExtractValue(getAsVector2));
            extractValues.Add(typeof(Quaternion).TypeHandle.Value.ToInt64(), new ExtractValue(getAsQuaternion));
            extractValues.Add(typeof(Color).TypeHandle.Value.ToInt64(), new ExtractValue(getAsColor));
            extractValues.Add(typeof(Vector4).TypeHandle.Value.ToInt64(), new ExtractValue(getAsVector4));
            extractValues.Add(typeof(Ray).TypeHandle.Value.ToInt64(), new ExtractValue(getAsRay));
            extractValues.Add(typeof(Bounds).TypeHandle.Value.ToInt64(), new ExtractValue(getAsBounds));
                    

            extractNetObject = new ExtractValue(getAsNetObject);
        }
开发者ID:neutra,项目名称:uLuaGameFramework,代码行数:34,代码来源:CheckType.cs


示例2: CheckType

        public CheckType(ObjectTranslator translator)
        {
            this.translator = translator;

            extractValues.Add(typeof(object).TypeHandle.Value.ToInt64(), new ExtractValue(getAsObject));
            extractValues.Add(typeof(sbyte).TypeHandle.Value.ToInt64(), new ExtractValue(getAsSbyte));
            extractValues.Add(typeof(byte).TypeHandle.Value.ToInt64(), new ExtractValue(getAsByte));
            extractValues.Add(typeof(short).TypeHandle.Value.ToInt64(), new ExtractValue(getAsShort));
            extractValues.Add(typeof(ushort).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUshort));
            extractValues.Add(typeof(int).TypeHandle.Value.ToInt64(), new ExtractValue(getAsInt));
            extractValues.Add(typeof(uint).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUint));
            extractValues.Add(typeof(long).TypeHandle.Value.ToInt64(), new ExtractValue(getAsLong));
            extractValues.Add(typeof(ulong).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUlong));
            extractValues.Add(typeof(double).TypeHandle.Value.ToInt64(), new ExtractValue(getAsDouble));
            extractValues.Add(typeof(char).TypeHandle.Value.ToInt64(), new ExtractValue(getAsChar));
            extractValues.Add(typeof(float).TypeHandle.Value.ToInt64(), new ExtractValue(getAsFloat));
            extractValues.Add(typeof(decimal).TypeHandle.Value.ToInt64(), new ExtractValue(getAsDecimal));
            extractValues.Add(typeof(bool).TypeHandle.Value.ToInt64(), new ExtractValue(getAsBoolean));
            extractValues.Add(typeof(string).TypeHandle.Value.ToInt64(), new ExtractValue(getAsString));
            extractValues.Add(typeof(LuaFunction).TypeHandle.Value.ToInt64(), new ExtractValue(getAsFunction));
            extractValues.Add(typeof(LuaTable).TypeHandle.Value.ToInt64(), new ExtractValue(getAsTable));
            extractValues.Add(typeof(LuaUserData).TypeHandle.Value.ToInt64(), new ExtractValue(getAsUserdata));

            extractNetObject = new ExtractValue(getAsNetObject);
        }
开发者ID:haiweizhang,项目名称:kopiluainterface,代码行数:25,代码来源:CheckType.cs


示例3: Lua

		public Lua() 
		{
			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 LuaFunctionCallback(PanicCallback);
            LuaDLL.lua_atpanic(luaState, panicCallback);

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


示例4: Lua

 public Lua(long luaState)
 {
     this.luaLock = new object();
     IntPtr ptr = new IntPtr(luaState);
     LuaJIT.lua_pushstring(ptr, "LUAINTERFACE LOADED");
     LuaJIT.lua_gettable(ptr, -10000);
     if ((LuaJIT.lua_toboolean(ptr, -1) == 0 ? false : true))
     {
         LuaJIT.lua_settop(ptr, -2);
         throw new LuaException("There is already a LuaInterface.Lua instance associated with this Lua state");
     }
     LuaJIT.lua_settop(ptr, -2);
     LuaJIT.lua_pushstring(ptr, "LUAINTERFACE LOADED");
     LuaJIT.lua_pushboolean(ptr, 1);
     LuaJIT.lua_settable(ptr, -10000);
     this.luaState = ptr;
     LuaJIT.lua_pushvalue(ptr, -10002);
     LuaJIT.lua_getglobal(ptr, "luanet");
     LuaJIT.lua_pushstring(ptr, "getmetatable");
     LuaJIT.lua_getglobal(ptr, "getmetatable");
     LuaJIT.lua_settable(ptr, -3);
     LuaJIT.lua_replace(ptr, -10002);
     this.translator = new ObjectTranslator(this, this.luaState);
     LuaJIT.lua_replace(ptr, -10002);
     LuaJIT.luaL_dostring(ptr, init_luanet);
     this._StatePassed = true;
 }
开发者ID:Evangileon,项目名称:LuaInterface,代码行数:27,代码来源:Lua.cs


示例5: LuaMethodWrapper

		/*
		 * Constructs the wrapper for a known method name
		 */
		public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType) 
		{
			this.translator=translator;
			this.methodName=methodName;
			this.targetType=targetType;
			if(targetType!=null)
				extractTarget=translator.typeChecker.getExtractor(targetType);
			this.bindingType=bindingType;
			members=targetType.UnderlyingSystemType.GetMember(methodName,MemberTypes.Method,bindingType|BindingFlags.Public|BindingFlags.NonPublic);
		}
开发者ID:viticm,项目名称:pap2,代码行数:13,代码来源:MethodWrapper.cs


示例6: LuaMethodWrapper

 public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType)
 {
     this._LastCalledMethod = new MethodCache();
     this._Translator = translator;
     this._MethodName = methodName;
     this._TargetType = targetType;
     if (targetType != null)
     {
         this._ExtractTarget = translator.typeChecker.getExtractor(targetType);
     }
     this._BindingType = bindingType;
     this._Members = targetType.UnderlyingSystemType.GetMember(methodName, MemberTypes.Method, (bindingType | BindingFlags.Public) | BindingFlags.IgnoreCase);
 }
开发者ID:Evangileon,项目名称:LuaInterface,代码行数:13,代码来源:LuaMethodWrapper.cs


示例7: 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


示例8: dumpStack

 public static void dumpStack(ObjectTranslator translator, IntPtr luaState)
 {
     int num = LuaDLL.lua_gettop(luaState);
     for (int i = 1; i <= num; i++)
     {
         LuaTypes type = LuaDLL.lua_type(luaState, i);
         if (type != LuaTypes.LUA_TTABLE)
         {
             LuaDLL.lua_typename(luaState, type);
         }
         LuaDLL.lua_tostring(luaState, i);
         if (type == LuaTypes.LUA_TUSERDATA)
         {
             translator.getRawNetObject(luaState, i).ToString();
         }
     }
 }
开发者ID:Evangileon,项目名称:LuaInterface,代码行数:17,代码来源:MetaFunctions.cs


示例9: dumpStack

        /// <summary>
        /// Debug tool to dump the lua stack
        /// </summary>
        /// FIXME, move somewhere else
        public static void dumpStack(ObjectTranslator translator, IntPtr 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:jreese,项目名称:gammadraconis,代码行数:25,代码来源:Metatables.cs


示例10: CheckType

 public CheckType(ObjectTranslator translator)
 {
     this.translator=translator;
     extractSbyte=new ExtractValue(this.getAsSbyte);
     extractByte=new ExtractValue(this.getAsByte);
     extractShort=new ExtractValue(this.getAsShort);
     extractUshort=new ExtractValue(this.getAsUshort);
     extractInt=new ExtractValue(this.getAsInt);
     extractUint=new ExtractValue(this.getAsUint);
     extractLong=new ExtractValue(this.getAsLong);
     extractUlong=new ExtractValue(this.getAsUlong);
     extractDouble=new ExtractValue(this.getAsDouble);
     extractChar=new ExtractValue(this.getAsChar);
     extractFloat=new ExtractValue(this.getAsFloat);
     extractDecimal=new ExtractValue(this.getAsDecimal);
     extractBoolean=new ExtractValue(this.getAsBoolean);
     extractString=new ExtractValue(this.getAsString);
     extractFunction=new ExtractValue(this.getAsFunction);
     extractTable=new ExtractValue(this.getAsTable);
     extractUserdata=new ExtractValue(this.getAsUserdata);
     extractObject=new ExtractValue(this.getAsObject);
 }
开发者ID:mentaldease,项目名称:bastionlandscape,代码行数:22,代码来源:CheckType.cs


示例11: LuaState

        public LuaState()
        {
            // Create State
			//Creates a new Lua state. 
			//It calls lua_newstate with an allocator based on the standard C realloc function and then sets a panic function (see §4.6) that prints an error message to the standard error output in case of fatal errors.
			//Returns the new state, or NULL if there is a memory allocation error.
            L = LuaDLL.luaL_newstate();

            // Create LuaInterface library
			//Opens all standard Lua libraries into the given state.
            LuaDLL.luaL_openlibs(L);  

            LuaDLL.lua_pushstring(L, "LUAINTERFACE LOADED");
            LuaDLL.lua_pushboolean(L, true);
			//Does the equivalent to t[k] = v, where t is the value at the given index, v is the value at the top of the stack, and k is the value just below the top.
			//This function pops both the key and the value from the stack. As in Lua, this function may trigger a metamethod for the "newindex" event (see §2.4).
            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);  //压入了_G表
            LuaDLL.lua_getglobal(L, "luanet");
            LuaDLL.lua_pushstring(L, "getmetatable");
            LuaDLL.lua_getglobal(L, "getmetatable");
            LuaDLL.lua_settable(L, -3);
            LuaDLL.lua_pushstring(L, "rawget");
            LuaDLL.lua_getglobal(L, "rawget");
            LuaDLL.lua_settable(L, -3);
            LuaDLL.lua_pushstring(L, "rawset");
            LuaDLL.lua_getglobal(L, "rawset");
            LuaDLL.lua_settable(L, -3);

            // Set luanet as global for object translator                          
            LuaDLL.lua_replace(L, (int)LuaIndexes.LUA_GLOBALSINDEX); //用luanet替换_G表           
            translator = new ObjectTranslator(this, L);            
            LuaDLL.lua_replace(L, (int)LuaIndexes.LUA_GLOBALSINDEX); //恢复_G表                    

            translator.PushTranslator(L);                      

            // 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:chasing2moro,项目名称:U3D-Lua-Learning,代码行数:77,代码来源:Lua.cs


示例12: LuaMethodWrapper

 /*
  * Constructs the wrapper for a known MethodBase instance
  */
 public LuaMethodWrapper(ObjectTranslator translator, object target, Type targetType, MethodBase method)
 {
     this.translator=translator;
     this.target=target;
     this.targetType=targetType;
     this.method=method;
     this.methodName=method.Name;
     if(method.IsStatic) { bindingType=BindingFlags.Static; }
     else { bindingType=BindingFlags.Instance; }
 }
开发者ID:mentaldease,项目名称:bastionlandscape,代码行数:13,代码来源:MethodWrapper.cs


示例13: Lua

 public Lua(IntPtr _luaState)
 {
     luaState = _luaState;
     translator=new ObjectTranslator(this,luaState);
 }
开发者ID:mentaldease,项目名称:bastionlandscape,代码行数:5,代码来源:Lua.cs


示例14: DelegateGenerator

 public DelegateGenerator(ObjectTranslator translator,Type delegateType)
 {
     this.translator=translator;
     this.delegateType=delegateType;
 }
开发者ID:drawcode,项目名称:unityluainterface,代码行数:5,代码来源:GenerateEventAssembly.cs


示例15: ClassGenerator

 public ClassGenerator(ObjectTranslator translator,Type klass)
 {
     this.translator=translator;
     this.klass=klass;
 }
开发者ID:drawcode,项目名称:unityluainterface,代码行数:5,代码来源:GenerateEventAssembly.cs


示例16: 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(LuaStatic.traceback);

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

            panicCallback = new LuaCSFunction(LuaStatic.panic);
            LuaDLL.lua_atpanic(L, panicCallback);

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

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

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


            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");

			LuaDLL.lua_pushstdcallcfunction(L, LuaStatic.errorFunc_traceback);
			errorFuncRef = LuaDLL.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX);

			if (LuaStatic.loadbuffer(L, mtindex2, "mtindex2") != 0 || LuaDLL.lua_pcall(L, 0, -1, 0) != 0)
			{
				Debug.Log("Init mtindex error");
				return;
			}

			Debug_funcs = new LuaL_Reg[] 
			{ 
				new LuaL_Reg("GetObjectCount",new  LuaCSFunction(LuaStatic.Debug_GetObjectCount)),
				new LuaL_Reg("LogError",new  LuaCSFunction(LuaStatic.Debug_LogError)),
				new LuaL_Reg("LogWarning",new  LuaCSFunction(LuaStatic.Debug_LogWarning)),
			};
			LuaL_Reg.LuaL_SetFuncs(L, "Debug",Debug_funcs);

			//Vector3_funcs = new LuaL_Reg[] 
			//{ 
			//	new LuaL_Reg("__add",new  LuaCSFunction(LuaStatic.Vector3_add)),
			//	new LuaL_Reg("__sub",new  LuaCSFunction(LuaStatic.Vector3_sub)),
			//	new LuaL_Reg("__mul",new  LuaCSFunction(LuaStatic.Vector3_mul)),
			//	new LuaL_Reg("__div",new  LuaCSFunction(LuaStatic.Vector3_div)),
			//	new LuaL_Reg("__eq",new  LuaCSFunction(LuaStatic.Vector3_eq)),
			//	new LuaL_Reg("__tostring",new  LuaCSFunction(LuaStatic.Vector3_tostring)),
			//};
			//LuaL_Reg.LuaL_SetFuncs(L, "Vector3", Vector3_funcs);


			//-------------------------------------------------------------
            // 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);

			//LuaStatic.InitObjsWeakTable(L);
		}
开发者ID:fengqk,项目名称:Art,代码行数:95,代码来源:Lua.cs


示例17: 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


示例18: 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


示例19: Lua

        /*
            * CAUTION: LuaInterface.Lua instances can't share the same lua state!
            */
        public Lua(LuaCore.lua_State lState)
        {
            LuaLib.lua_pushstring(lState, "LUAINTERFACE LOADED");
            LuaLib.lua_gettable(lState, (int)LuaIndexes.Registry);

            if(LuaLib.lua_toboolean(lState, -1))
            {
                LuaLib.lua_settop(lState, -2);
                throw new LuaException("There is already a LuaInterface.Lua instance associated with this Lua state");
            }
            else
            {
                LuaLib.lua_settop(lState, -2);
                LuaLib.lua_pushstring(lState, "LUAINTERFACE LOADED");
                LuaLib.lua_pushboolean(lState, true);
                LuaLib.lua_settable(lState, (int)LuaIndexes.Registry);
                luaState = lState;
                LuaLib.lua_pushvalue(lState, (int)LuaIndexes.Globals);
                LuaLib.lua_getglobal(lState, "luanet");
                LuaLib.lua_pushstring(lState, "getmetatable");
                LuaLib.lua_getglobal(lState, "getmetatable");
                LuaLib.lua_settable(lState, -3);
                LuaLib.lua_replace(lState, (int)LuaIndexes.Globals);
                translator = new ObjectTranslator(this, luaState);
                LuaLib.lua_replace(lState, (int)LuaIndexes.Globals);
                LuaLib.luaL_dostring(lState, Lua.init_luanet);	// steffenj: lua_dostring renamed to luaL_dostring
            }

            _StatePassed = true;
        }
开发者ID:rumkex,项目名称:LuaInterface,代码行数:33,代码来源:Lua.cs


示例20: LuaMethodWrapper

        /*
         * Constructs the wrapper for a known method name
         */
        public LuaMethodWrapper(ObjectTranslator translator, IReflect targetType, string methodName, BindingFlags bindingType)
        {
            _Translator = translator;
            _MethodName = methodName;
            _TargetType = targetType;

            if (targetType != null)
                _ExtractTarget = translator.typeChecker.getExtractor(targetType);

            _BindingType = bindingType;

            //CP: Removed NonPublic binding search and added IgnoreCase
            _Members = targetType.UnderlyingSystemType.GetMember(methodName, MemberTypes.Method, bindingType | BindingFlags.Public | BindingFlags.IgnoreCase/*|BindingFlags.NonPublic*/);
        }
开发者ID:neutra,项目名称:uLuaGameFramework,代码行数:17,代码来源:MethodWrapper.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Analysis.Analyzer类代码示例发布时间:2022-05-26
下一篇:
C# LuaInterface.LuaTable类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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