Ejemplo n.º 1
0
            public static ReflectParam From(ParameterInfo info)
            {
                ReflectParam m = new ReflectParam();

                m.name = info.Name;
                m.type = MetacallDef.Get(info.ParameterType);
                return(m);
            }
Ejemplo n.º 2
0
        public unsafe static ExecutionResult *CreateExecutionResult(bool failed, type_primitive_id type, object value)
        {
            ExecutionResult *er = CreateExecutionResult(failed, type);

            er->ptr = MetacallDef.GetIntPtr(type, value);

            return(er);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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));
            }
        }
Ejemplo n.º 5
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);
        }