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


C# ObjectTranslator.GetRawNetObject方法代码示例

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


在下文中一共展示了ObjectTranslator.GetRawNetObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DumpStack

		/// <summary>
		/// Debug tool to dump the lua stack
		/// </summary>
		/// FIXME, move somewhere else
		public static void DumpStack (ObjectTranslator translator, LuaState luaState)
		{
			int depth = LuaLib.LuaGetTop (luaState);

#if WINDOWS_PHONE
			Debug.WriteLine("lua stack depth: {0}", depth);
#elif UNITY_3D
			UnityEngine.Debug.Log(string.Format("lua stack depth: {0}", depth));
#elif !SILVERLIGHT
			Debug.Print ("lua stack depth: {0}", depth);
#endif

			for (int i = 1; i <= depth; i++) {
				var type = LuaLib.LuaType (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.Table) ? "table" : LuaLib.LuaTypeName (luaState, type);
				string strrep = LuaLib.LuaToString (luaState, i).ToString ();

				if (type == LuaTypes.UserData) {
					object obj = translator.GetRawNetObject (luaState, i);
					strrep = obj.ToString ();
				}

#if WINDOWS_PHONE
                Debug.WriteLine("{0}: ({1}) {2}", i, typestr, strrep);
#elif UNITY_3D
				UnityEngine.Debug.Log(string.Format("{0}: ({1}) {2}", i, typestr, strrep));
#elif !SILVERLIGHT
				Debug.Print ("{0}: ({1}) {2}", i, typestr, strrep);
#endif
			}
		}
开发者ID:hanbim520,项目名称:UFLua,代码行数:36,代码来源:Metatables.cs

示例2: UnaryNegationLua

		static int UnaryNegationLua (LuaState luaState, ObjectTranslator translator)
		{
			object obj1 = translator.GetRawNetObject (luaState, 1);

			if (obj1 == null) {
				translator.ThrowError (luaState, "Cannot negate a nil object");
				LuaLib.LuaPushNil (luaState);
				return 1;
			}

			Type type = obj1.GetType ();
			MethodInfo opUnaryNegation = type.GetMethod ("op_UnaryNegation");

			if (opUnaryNegation == null) {
				translator.ThrowError (luaState, "Cannot negate object (" + type.Name + " does not overload the operator -)");
				LuaLib.LuaPushNil (luaState);
				return 1;
			}
			obj1 = opUnaryNegation.Invoke (obj1, new object [] { obj1 });
			translator.Push (luaState, obj1);
			return 1;
		}
开发者ID:hanbim520,项目名称:UFLua,代码行数:22,代码来源:Metatables.cs

示例3: ToStringLua

		private static int ToStringLua (LuaState luaState, ObjectTranslator translator)
		{
			object obj = translator.GetRawNetObject (luaState, 1);

			if (obj != null)
				translator.Push (luaState, obj.ToString () + ": " + obj.GetHashCode ().ToString());
			else
				LuaLib.LuaPushNil (luaState);

			return 1;
		}
开发者ID:hanbim520,项目名称:UFLua,代码行数:11,代码来源:Metatables.cs

示例4: RunFunctionDelegate

		private static int RunFunctionDelegate (LuaState luaState, ObjectTranslator translator)
		{
			LuaNativeFunction func = (LuaNativeFunction)translator.GetRawNetObject (luaState, 1);
			LuaLib.LuaRemove (luaState, 1);
			return func (luaState);
		}
开发者ID:hanbim520,项目名称:UFLua,代码行数:6,代码来源:Metatables.cs

示例5: GetTargetObject

		static object GetTargetObject (LuaState luaState, string operation, ObjectTranslator translator)
		{
			Type t;
			object target = translator.GetRawNetObject (luaState, 1);
			if (target != null) {
				t = target.GetType ();
				if (t.HasMethod (operation))
					return target;
			}
			target = translator.GetRawNetObject (luaState, 2);
			if (target != null) {
				t = target.GetType ();
				if (t.HasMethod (operation))
					return target;
			}
			return null;
		}
开发者ID:hanbim520,项目名称:UFLua,代码行数:17,代码来源:Metatables.cs

示例6: AddLua

		static int AddLua (LuaState luaState, ObjectTranslator translator)
		{
			object obj1 = translator.GetRawNetObject (luaState, 1);
			object obj2 = translator.GetRawNetObject (luaState, 2);

			if (obj1 == null || obj2 == null) {
				translator.ThrowError (luaState, "Cannot add a nil object");
				LuaLib.LuaPushNil (luaState);
				return 1;
			}

			Type type = obj1.GetType ();
			MethodInfo opAddition = type.GetMethod ("op_Addition");

			if (opAddition == null) {
				translator.ThrowError (luaState, "Cannot add object (" + type.Name+ " does not overload the operator +)");
				LuaLib.LuaPushNil (luaState);
				return 1;
			}
			obj1 = opAddition.Invoke (obj1, new object[] { obj1, obj2 });
			translator.Push (luaState, obj1);
			return 1;
		}
开发者ID:BlackNecro,项目名称:NLua,代码行数:23,代码来源:Metatables.cs


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