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()); } }
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)); }
/* * 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"); } } }