Example #1
0
            public static ReflectParam From(ParameterInfo info)
            {
                ReflectParam m = new ReflectParam();

                m.name = info.Name;
                m.type = MetacallDef.Get(info.ParameterType);
                return(m);
            }
Example #2
0
        public ReflectFunction GetReflectFunction()
        {
            ReflectFunction r = new ReflectFunction();

            r.name       = this.FunctionName;
            r.returnType = MetacallDef.Get(this.RetunType);
            r.paramcount = this.Parameters.Length;
            r.pars       = new ReflectParam[10];

            for (int i = 0; i < r.paramcount; i++)
            {
                r.pars[i] = ReflectParam.From(this.Parameters[i]);
            }

            return(r);
        }
Example #3
0
        public unsafe ExecutionResult *Execute(string function, Parameters[] parameters)
        {
            var objs = new object[parameters.Length];

            var con = this.functions[function];

            for (int i = 0; i < con.Parameters.Length; i++)
            {
                objs[i] = MetacallDef.GetValue(parameters[i].type, parameters[i].ptr);
            }

            var result = con.Method.Invoke(null, objs.Take(con.Parameters.Length).ToArray());

            if (result == null)
            {
                return(CreateExecutionResult(false, MetacallDef.Get(con.RetunType)));
            }
            else
            {
                return(CreateExecutionResult(false, MetacallDef.Get(con.RetunType), result));
            }
        }
Example #4
0
        public unsafe ExecutionResult *Execute(string function)
        {
            var con = this.functions[function];

            try
            {
                var result = con.Method.Invoke(null, null);

                if (result == null)
                {
                    return(CreateExecutionResult(false, MetacallDef.Get(con.RetunType)));
                }
                else
                {
                    return(CreateExecutionResult(false, MetacallDef.Get(con.RetunType), result));
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
            }

            return(null);
        }