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


C# CallbackArguments类代码示例

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


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

示例1: create

		public static DynValue create(ScriptExecutionContext executionContext, CallbackArguments args)
		{
			if (args[0].Type != DataType.Function && args[0].Type != DataType.ClrFunction)
				args.AsType(0, "create", DataType.Function); // this throws

			return executionContext.GetScript().CreateCoroutine(args[0]);
		}
开发者ID:RainsSoft,项目名称:moonsharp,代码行数:7,代码来源:CoroutineModule.cs

示例2: type

		public static DynValue type(ScriptExecutionContext executionContext, CallbackArguments args)
		{
			if (args.Count < 1) throw ScriptRuntimeException.BadArgumentValueExpected(0, "type");

			DynValue v = args[0];
			return DynValue.NewString(v.Type.ToLuaTypeString());
		}
开发者ID:eddy5641,项目名称:LuaSharp,代码行数:7,代码来源:BasicModule.cs

示例3: setuservalue

        public static DynValue setuservalue(ScriptExecutionContext executionContext, CallbackArguments args)
        {
            var v = args.AsType(0, "setuservalue", DataType.UserData, false);
            var t = args.AsType(0, "setuservalue", DataType.Table, true);

            return v.UserData.UserValue = t;
        }
开发者ID:eddy5641,项目名称:moonsharp,代码行数:7,代码来源:DebugModule.cs

示例4: StringBuilder

        public static DynValue @char(ScriptExecutionContext executionContext, CallbackArguments args)
        {
            var sb = new StringBuilder(args.Count);

            for (var i = 0; i < args.Count; i++)
            {
                var v = args[i];
                var d = 0d;

                if (v.Type == DataType.String)
                {
                    var nd = v.CastToNumber();
                    if (nd == null)
                        args.AsType(i, "char", DataType.Number, false);
                    else
                        d = nd.Value;
                }
                else
                {
                    args.AsType(i, "char", DataType.Number, false);
                    d = v.Number;
                }

                sb.Append((char) (d));
            }

            return DynValue.NewString(sb.ToString());
        }
开发者ID:eddy5641,项目名称:moonsharp,代码行数:28,代码来源:StringModule.cs

示例5: rawget

		public static DynValue rawget(ScriptExecutionContext executionContext, CallbackArguments args)  
		{
			DynValue table = args.AsType(0, "rawget", DataType.Table);
			DynValue index = args[1];

			return table.Table.Get(index);
		}
开发者ID:eddy5641,项目名称:LuaSharp,代码行数:7,代码来源:MetaTableModule.cs

示例6: eval

		public static DynValue eval(ScriptExecutionContext executionContext, CallbackArguments args)
		{
			try
			{
				if (args[0].Type == DataType.UserData)
				{
					UserData ud = args[0].UserData;
					if (ud.Object is DynamicExprWrapper)
					{
						return ((DynamicExprWrapper)ud.Object).Expr.Evaluate(executionContext);
					}
					else
					{
						throw ScriptRuntimeException.BadArgument(0, "dynamic.eval", "A userdata was passed, but was not a previously prepared expression.");
					}
				}
				else
				{
					DynValue vs = args.AsType(0, "dynamic.eval", DataType.String, false);
					DynamicExpression expr = executionContext.GetScript().CreateDynamicExpression(vs.String);
					return expr.Evaluate(executionContext);
				}
			}
			catch (SyntaxErrorException ex)
			{ 
				throw new ScriptRuntimeException(ex);
			}
		}
开发者ID:cyecp,项目名称:moonsharp,代码行数:28,代码来源:DynamicModule.cs

示例7: debug

        public static DynValue debug(ScriptExecutionContext executionContext, CallbackArguments args)
        {
            var script = executionContext.GetScript();

            if (script.Options.DebugInput == null)
                throw new ScriptRuntimeException("debug.debug not supported on this platform/configuration");

            var interpreter = new ReplInterpreter(script)
            {
                HandleDynamicExprs = false,
                HandleClassicExprsSyntax = true
            };

            while (true)
            {
                var s = script.Options.DebugInput(interpreter.ClassicPrompt + " ");

                try
                {
                    var result = interpreter.Evaluate(s);

                    if (result != null && result.Type != DataType.Void)
                        script.Options.DebugPrint(string.Format("{0}", result));
                }
                catch (InterpreterException ex)
                {
                    script.Options.DebugPrint(string.Format("{0}", ex.DecoratedMessage ?? ex.Message));
                }
                catch (Exception ex)
                {
                    script.Options.DebugPrint(string.Format("{0}", ex.Message));
                }
            }
        }
开发者ID:eddy5641,项目名称:moonsharp,代码行数:34,代码来源:DebugModule.cs

示例8: sort

        public static DynValue sort(ScriptExecutionContext executionContext, CallbackArguments args)
        {
            var vlist = args.AsType(0, "sort", DataType.Table, false);
            var lt = args[1];

            if (lt.Type != DataType.Function && lt.Type != DataType.ClrFunction && lt.IsNotNil())
                args.AsType(1, "sort", DataType.Function, true); // this throws

            var end = GetTableLength(executionContext, vlist);

            var values = new List<DynValue>();

            for (var i = 1; i <= end; i++)
                values.Add(vlist.Table.Get(i));

            try
            {
                values.Sort((a, b) => SortComparer(executionContext, a, b, lt));
            }
            catch (InvalidOperationException ex)
            {
                if (ex.InnerException is ScriptRuntimeException)
                    throw ex.InnerException;
            }

            for (var i = 0; i < values.Count; i++)
            {
                vlist.Table.Set(i + 1, values[i]);
            }

            return vlist;
        }
开发者ID:eddy5641,项目名称:moonsharp,代码行数:32,代码来源:TableModule.cs

示例9: execute

		public static DynValue execute(ScriptExecutionContext executionContext, CallbackArguments args)
		{
			DynValue v = args.AsType(0, "execute", DataType.String, true);

			if (v.IsNil())
			{
				return DynValue.NewBoolean(true);
			}
			else
			{
				try
				{
					int exitCode = Script.GlobalOptions.Platform.OS_Execute(v.String);

					return DynValue.NewTuple(
						DynValue.Nil,
						DynValue.NewString("exit"),
						DynValue.NewNumber(exitCode));
				}
				catch (Exception)
				{
					// +++ bad to swallow.. 
					return DynValue.Nil;
				}
			}
		}
开发者ID:cyecp,项目名称:moonsharp,代码行数:26,代码来源:OsSystemModule.cs

示例10: SetErrorHandlerStrategy

        private static DynValue SetErrorHandlerStrategy(string funcName,
            ScriptExecutionContext executionContext,
            CallbackArguments args,
            DynValue handlerBeforeUnwind)
        {
            var v = args[0];
            var a = new DynValue[args.Count - 1];

            for (var i = 1; i < args.Count; i++)
                a[i - 1] = args[i];

            if (args[0].Type == DataType.ClrFunction)
            {
                try
                {
                    var ret = args[0].Callback.Invoke(executionContext, a);
                    if (ret.Type == DataType.TailCallRequest)
                    {
                        if (ret.TailCallData.Continuation != null || ret.TailCallData.ErrorHandler != null)
                            throw new ScriptRuntimeException(
                                "the function passed to {0} cannot be called directly by {0}. wrap in a script function instead.",
                                funcName);

                        return DynValue.NewTailCallReq(new TailCallData
                        {
                            Args = ret.TailCallData.Args,
                            Function = ret.TailCallData.Function,
                            Continuation = new CallbackFunction(pcall_continuation, funcName),
                            ErrorHandler = new CallbackFunction(pcall_onerror, funcName),
                            ErrorHandlerBeforeUnwind = handlerBeforeUnwind
                        });
                    }
                    if (ret.Type == DataType.YieldRequest)
                    {
                        throw new ScriptRuntimeException(
                            "the function passed to {0} cannot be called directly by {0}. wrap in a script function instead.",
                            funcName);
                    }
                    return DynValue.NewTupleNested(DynValue.True, ret);
                }
                catch (ScriptRuntimeException ex)
                {
                    executionContext.PerformMessageDecorationBeforeUnwind(handlerBeforeUnwind, ex);
                    return DynValue.NewTupleNested(DynValue.False, DynValue.NewString(ex.DecoratedMessage));
                }
            }
            if (args[0].Type != DataType.Function)
            {
                return DynValue.NewTupleNested(DynValue.False,
                    DynValue.NewString("attempt to " + funcName + " a non-function"));
            }
            return DynValue.NewTailCallReq(new TailCallData
            {
                Args = a,
                Function = v,
                Continuation = new CallbackFunction(pcall_continuation, funcName),
                ErrorHandler = new CallbackFunction(pcall_onerror, funcName),
                ErrorHandlerBeforeUnwind = handlerBeforeUnwind
            });
        }
开发者ID:eddy5641,项目名称:moonsharp,代码行数:60,代码来源:ErrorHandlingModule.cs

示例11: exec2n

		private static DynValue exec2n(CallbackArguments args, string funcName, double defVal, Func<double, double, double> func)
		{
			DynValue arg = args.AsType(0, funcName, DataType.Number, false);
			DynValue arg2 = args.AsType(1, funcName, DataType.Number, true);

			return DynValue.NewNumber(func(arg.Number, arg2.IsNil() ? defVal : arg2.Number));
		}
开发者ID:cyecp,项目名称:moonsharp,代码行数:7,代码来源:MathModule.cs

示例12: pairs

		public static DynValue pairs(ScriptExecutionContext executionContext, CallbackArguments args) 
		{
			DynValue table = args[0];

			DynValue meta = executionContext.GetMetamethodTailCall(table, "__pairs", args.GetArray());

			return meta ?? DynValue.NewTuple(DynValue.NewCallback(next), table);
		}
开发者ID:eddy5641,项目名称:LuaSharp,代码行数:8,代码来源:TableIteratorsModule.cs

示例13: ipairs

        public static DynValue ipairs(ScriptExecutionContext executionContext, CallbackArguments args)
        {
            var table = args[0];

            var meta = executionContext.GetMetamethodTailCall(table, "__ipairs", args.GetArray());

            return meta ?? DynValue.NewTuple(DynValue.NewCallback(__next_i), table, DynValue.NewNumber(0));
        }
开发者ID:eddy5641,项目名称:moonsharp,代码行数:8,代码来源:TableIteratorsModule.cs

示例14: BuildArrayIndices

		private static int[] BuildArrayIndices(CallbackArguments args, int count)
		{
			int[] indices = new int[count];

			for (int i = 0; i < count; i++)
				indices[i] = args.AsInt(i, "userdata_array_indexer");

			return indices;
		}
开发者ID:eddy5641,项目名称:LuaSharp,代码行数:9,代码来源:ArrayMemberDescriptor.cs

示例15: rawset

        public static DynValue rawset(ScriptExecutionContext executionContext, CallbackArguments args)
        {
            var table = args.AsType(0, "rawset", DataType.Table);
            var index = args[1];

            table.Table.Set(index, args[2]);

            return table;
        }
开发者ID:eddy5641,项目名称:moonsharp,代码行数:9,代码来源:MetaTableModule.cs


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