public virtual void Format(CodeFile file, Tabulator tabulator) { foreach (var ns in file.Namespaces) { if (!string.IsNullOrEmpty(ns.Name)) { BeginCodeBlock(tabulator, FormatPatterns.PatternNamespace, ns.Name); } BeforeFillNamespace(tabulator, ns); foreach (var item in ns.Enums) { Format(tabulator, item); } foreach (var item in ns.Structs) { Format(tabulator, item); } foreach (var item in ns.Classes) { Format(tabulator, item); } foreach (var item in ns.RootMethods) { Format(tabulator, item); } if (!string.IsNullOrEmpty(ns.Name)) { EndCodeBlock(tabulator); } } }
private void Format(Tabulator tabulator, Method value) { var parameters = ""; for (int i = 0; i < value.Parameters.Count; i++) { var p = value.Parameters[i]; parameters += string.Format(FormatPatterns.PatternParameter, p.FullTypeName, p.Name); if (i < (value.Parameters.Count - 1)) { parameters += ", "; } } var pattern = value.IsPrivate ? FormatPatterns.PatternPrivateMethod : FormatPatterns.PatternMethod; if (value.Body != null) { BeginCodeBlock(tabulator, (value.IsStatic ? "static " : "") + (value.IsExtern ? "extern " : "") + pattern, value.ResulTypeFullName, value.Name, parameters); if (value.Body != null) { tabulator.AppendLine(value.Body); } EndCodeBlock(tabulator); } else { BeforeAppendStaticMethod(tabulator, value); tabulator.AppendFormatLine((value.IsStatic ? "static " : "") + (value.IsExtern ? "extern " : "") + pattern + ";", value.ResulTypeFullName, value.Name, parameters); } }
public string Format(CodeFile file) { var tabulator = new Tabulator(); _provider.Format(file, tabulator); return(tabulator.Build()); }
public override void Format(CodeFile file, Tabulator tabulator) { tabulator.AppendFormatLine("#include <jni.h>"); tabulator.AppendFormatLine("#include \"{0}\"", Path.GetFileName(file.FileName)); tabulator.AppendLine(""); base.Format(file, tabulator); }
protected void Format(Tabulator tabulator, Field value) { tabulator.AppendFormatLine( value.IsPrivate ? FormatPatterns.PatternPrivateFiled : FormatPatterns.PatternFiled, value.TypeName, value.Name); }
private void Format(Tabulator tabulator, Struct value) { BeforeAppendStruct(tabulator, value); BeginCodeBlock(tabulator, FormatPatterns.PatternStruct, value.Name); Format(tabulator, value.Fields); EndCodeBlock(tabulator); }
protected void Format(Tabulator tabulator, Fields value) { foreach (var field in value.Items) { Format(tabulator, field); } }
private void Format(Tabulator tabulator, Methods methods) { foreach (var method in methods.Items) { Format(tabulator, method); } }
private void Format(Tabulator tabulator, Class value) { BeginCodeBlock(tabulator, FormatPatterns.PatternClass, value.Name); Format(tabulator, value.Fields); Format(tabulator, value.Methods); EndCodeBlock(tabulator); }
private void Format(Tabulator tabulator, List <EnumItem> items) { foreach (var item in items) { Format(tabulator, item); } }
public override void Format(CodeFile file, Tabulator tabulator) { base.Format(file, tabulator); }
protected void EndCodeBlock(Tabulator tabulator) { tabulator.EndBlock(); tabulator.AppendLine("}"); tabulator.AppendLine(""); }
protected void BeginCodeBlock(Tabulator tabulator, string format, params object[] parameters) { tabulator.AppendFormatLine(format, parameters); tabulator.AppendLine("{"); tabulator.BeginBlock(); }
protected virtual void BeforeAppendStruct(Tabulator tabulator, Struct value) { }
protected virtual void BeforeFillNamespace(Tabulator tabulator, Namespace value) { }
protected virtual void BeforeAppendStaticMethod(Tabulator tabulator, Method value) { }
private void Format(Tabulator tabulator, EnumItem item) { tabulator.AppendFormatLine("{0} = {1},", item.Name, item.Value); }
private void Format(Tabulator tabulator, Enum value) { BeginCodeBlock(tabulator, FormatPatterns.PatternEnum, value.Name); Format(tabulator, value.Items); EndCodeBlock(tabulator); }