Ejemplo n.º 1
0
        public JObject RunAnReturn(JObject input, VirtualInput @in)
        {
            switch (input["action"].ToString())
            {
            case "static_call":
                return(StaticCall((string)input["target"] as string, input["args"] as JArray));

            case "call":
                return(Call((string)input["target"] as string,
                            input["args"] as JArray, (int)input["owner"]["id"]));

            case "new":
                return(New((string)input["target"] as string, input["args"] as JArray));

            case "destroy":
                Destroy((int)input["obj_id"]);
                goto default;

            case "input":
                @in.Trail.Add((string)input["data"]);
                goto default;

            default:
                return(QueryMaker.Nothing());
            }
        }
Ejemplo n.º 2
0
        private JObject New(string name, JArray arr)
        {
            Type @class = memory.GetClassByName(name);

            object[]        args = serializer.Serialize(arr);
            Type[]          cons = serializer.TypesOf(args);
            ConstructorInfo c    = memory.Constructor(@class, cons);
            var             obj  = c.Invoke(args);
            int             id   = memory.AddRef(obj);

            return(QueryMaker.Return(name, id));
        }
Ejemplo n.º 3
0
        /*
         * public JArray Deserialize(object[] objs)
         * {
         *
         * }
         */

        public JObject MethodReturn(Type x, object ret)
        {
            if (ret == null)
            {
                return(null);
            }
            if (Array.IndexOf(new Type[] { typeof(int), typeof(float), typeof(string), typeof(bool),
                                           typeof(int[]), typeof(float[]), typeof(string[]), typeof(bool[]) }, x) >= 0)
            {
                return(QueryMaker.Return(ret));
            }
            else
            {
                if (Array.IndexOf(memory.SharedClasses, x) > 0)
                {
                    return(QueryMaker.Return(memory.SharedClassInfo(Array.IndexOf(memory.SharedClasses, x)).Name,
                                             Array.IndexOf(memory.SharedClasses, x)));
                }
                else
                {
                    throw new Exception("That type is not shared");
                }
            }
        }