Blackmire.CppHeaderWalker.VisitFieldDeclaration C# (CSharp) Method

VisitFieldDeclaration() public method

public VisitFieldDeclaration ( Microsoft.CodeAnalysis.CSharp.Syntax.FieldDeclarationSyntax node ) : void
node Microsoft.CodeAnalysis.CSharp.Syntax.FieldDeclarationSyntax
return void
        public override void VisitFieldDeclaration(FieldDeclarationSyntax node)
        {
            foreach (var v in node.Declaration.Variables)
              {
            var z = model.GetDeclaredSymbol(v) as IFieldSymbol;
            if (z != null)
            {
              var builder = tcb.GetBuilderFor(z.DeclaredAccessibility);
              var cppType = z.Type.ToCppType();
              builder.AppendIndent();
              if (z.IsConst || z.IsReadOnly) builder.Append("const ");
              if (z.IsStatic) builder.Append("static ");
              builder.Append(cppType).Append(" ").Append(v.Identifier.ToString());

              // since this is C++11, we can add init for primitive numeric types
              var defType = z.Type.GetDefaultValue();
              if (defType != null)
              {
            builder.Append(" = ").Append(z.Type.GetDefaultValue());
              }

              builder.AppendLine(";");
            }
              }
        }