public override string ToString() { var sb = new StringBuilder(); sb.AppendLine($"interface {Name}"); sb.AppendLine(); sb.AppendJoin('\n', Typedefs.Select(td => $"type {td.Name} {td}")); sb.AppendLine(); sb.AppendJoin('\n', Errors); sb.AppendLine(); sb.AppendJoin('\n', Methods); sb.AppendLine(); return(sb.ToString()); }
public void Dump(IndentedTextWriter writer, bool forInline) { if (forInline && Typedefs.Count > 0) { writer.Write(string.Join(", ", Typedefs.Select(_ => _.Value.AsCode(_.Key, true)))); return; } string cType; switch (_size) { case 1: cType = "char"; break; case 2: cType = "short"; break; case 4: cType = "int"; break; default: throw new Exception($"Cannot determine primitive type for size {_size}"); } writer.WriteLine(forInline ? $"enum : {cType} {{" : $"enum {Name} : {cType} {{"); ++writer.Indent; foreach (var(key, value) in _members) { writer.WriteLine($"{key} = {value},"); } --writer.Indent; if (forInline) { writer.Write("}"); } else { writer.WriteLine("};"); } }
public void Dump(IndentedTextWriter writer, bool forInline) { if (forInline && Typedefs.Count > 0) { writer.Write(string.Join(", ", Typedefs.Select(_ => _.Value.AsCode(_.Key, true)))); return; } writer.WriteLine(forInline ? "struct {" : $"struct {Name} {{"); ++writer.Indent; foreach (var m in _members) { writer.WriteLine(m); } --writer.Indent; if (forInline) { writer.Write("}"); } else { writer.WriteLine("};"); } }