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());
        }
示例#4
0
 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);
 }
示例#10
0
 private void Format(Tabulator tabulator, List <EnumItem> items)
 {
     foreach (var item in items)
     {
         Format(tabulator, item);
     }
 }
示例#11
0
 public override void Format(CodeFile file, Tabulator tabulator)
 {
     base.Format(file, tabulator);
 }
示例#12
0
 protected void EndCodeBlock(Tabulator tabulator)
 {
     tabulator.EndBlock();
     tabulator.AppendLine("}");
     tabulator.AppendLine("");
 }
示例#13
0
 protected void BeginCodeBlock(Tabulator tabulator, string format, params object[] parameters)
 {
     tabulator.AppendFormatLine(format, parameters);
     tabulator.AppendLine("{");
     tabulator.BeginBlock();
 }
示例#14
0
 protected virtual void BeforeAppendStruct(Tabulator tabulator, Struct value)
 {
 }
示例#15
0
 protected virtual void BeforeFillNamespace(Tabulator tabulator, Namespace value)
 {
 }
示例#16
0
 protected virtual void BeforeAppendStaticMethod(Tabulator tabulator, Method value)
 {
 }
示例#17
0
 private void Format(Tabulator tabulator, EnumItem item)
 {
     tabulator.AppendFormatLine("{0} = {1},", item.Name, item.Value);
 }
示例#18
0
 private void Format(Tabulator tabulator, Enum value)
 {
     BeginCodeBlock(tabulator, FormatPatterns.PatternEnum, value.Name);
     Format(tabulator, value.Items);
     EndCodeBlock(tabulator);
 }