void processEnum(TypeDeclaration td, TNamespace ns) { Debug.Assert(td.ClassType == ClassType.Enum); TEnum te = new TEnum(); te.name = td.Name; var blist = td.BaseTypes; foreach (var item in blist) { te.bases.Add(item.GetText()); } var mlist = td.Descendants.OfType <EnumMemberDeclaration>().ToList(); foreach (var item in mlist) { var member = new TEnumMember(); var text = item.GetText(); var split = text.Split('='); member.name = split[0]; if (split.Count() >= 2) { member.init = split[1]; } te.members.Add(member); } ns.classes.Add(te); }
void WriteEnum(TEnum te) { output.WriteLine("enum " + te.name + "{"); foreach (var item in te.members) { output.WriteLine("\t" + item.name + (item.init == null ? "" : "= " + item.init)); } output.WriteLine("}"); }