protected static void AddEnum(Class cl, Json.Object mem, string name) { Enum e = new Enum(name); Json.Array members = (Json.Array)mem.GetValue("members"); Json.Object val; Json.Value v; string key; int idx; for (int i = 0; i < members.GetCount(); ++i) { idx = i; val = (Json.Object)members.GetValue(i); key = ((Json.String)val.GetValue("key")).GetValue(); if ((v = val.GetValue("value")) != null) { idx = Int32.Parse(((Json.String)v).GetValue()); } e.values.Add(key, idx); } cl.enums.Add(e); }
protected static void AddFunction(Class cl, Json.Object mem, string name) { Function f = new Function(name, ((Json.Object)mem.GetValue("returnType"))); Json.Value meta; if ((meta = mem.GetValue("meta")) != null) { Dictionary <string, Json.Value> .KeyCollection keys = ((Json.Object)meta).GetKeys(); if (keys.Contains("static") == true) { f.is_static = true; } } Json.Array args = (Json.Array)mem.GetValue("arguments"); Json.Object arg; Function.Arg farg; for (int i = 0; i < args.GetCount(); ++i) { arg = (Json.Object)args.GetValue(i); farg = new Function.Arg( ((Json.String)arg.GetValue("name")).GetValue(), ((Json.Object)arg.GetValue("type"))); f.args.Add(farg); } cl.funcs.Add(f); }
public Function(string n, Json.Object ret_type) { name = n; return_type = new TypeDefinition(ret_type); args = new List <Arg>(); is_static = false; }
protected static bool AddLuaName(Class cl, Json.Object mem) { Json.Object meta = (Json.Object)mem.GetValue("meta"); if (meta == null) { return(false); } cl.lua_name = meta.GetKeys().First(); return(true); }
protected static void CheckMacro(Class cl, Json.Object mem) { string name = ((Json.String)mem.GetValue("name")).GetValue(); if (name == "SCRIPT_NAME") { AddLuaName(cl, mem); } else if (name == "SCRIPT_COMPONENT") { cl.is_component = true; } }
public static void ParseValue(JsonTextReader reader, Json.Value root, bool in_object) { string last_key = ""; Json.Value new_object = null; while (reader.Read() == true) { if (reader.TokenType == JsonToken.EndObject || reader.TokenType == JsonToken.EndArray) { break; } switch (reader.TokenType) { case JsonToken.StartObject: new_object = new Json.Object(); ParseValue(reader, new_object, true); break; case JsonToken.StartArray: new_object = new Json.Array(); ParseValue(reader, new_object, false); break; case JsonToken.PropertyName: last_key = (string)reader.Value; continue; case JsonToken.String: case JsonToken.Integer: case JsonToken.Null: object v = reader.Value; new_object = new Json.String(v == null ? "null" : v.ToString()); break; } if (root == null) { root = new_object; } if (in_object == true) { ((Json.Object)root).Add(last_key, new_object); continue; } ((Json.Array)root).Add(new_object); } }
public TypeDefinition(Json.Object from) { if (from.GetValue("name") != null) { name = ((Json.String)from.GetValue("name")).GetValue(); ref_type = RefType.kNormal; } else { string r = ((Json.String)from.GetValue("type")).GetValue(); switch (r) { case "pointer": ref_type = RefType.kPointer; break; case "reference": ref_type = RefType.kReference; break; default: ref_type = RefType.kNormal; break; } name = ((Json.String)((Json.Object)from.GetValue("baseType")).GetValue("name")).GetValue(); } unqualified_name = name; type = StringToType(name); switch (ref_type) { case RefType.kPointer: name += "*"; break; case RefType.kReference: name += "&"; break; } }
public static Json.Value ParseValue(JsonTextReader reader) { reader.Read(); // Read first opening bracket Json.Value root = null; bool in_object = false; if (reader.TokenType == JsonToken.StartArray) { root = new Json.Array(); in_object = false; } else { root = new Json.Object(); in_object = true; } ParseValue(reader, root, in_object); return(root); }
public Arg(string n, Json.Object typedef) { name = n; type = new TypeDefinition(typedef); }