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); }
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); }
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; } }
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; } }