예제 #1
0
        /// <summary>
        /// Header type declaration
        /// </summary>
        /// <param name="typeDeclaration">type declaration</param>
        protected override void HeaderTypeDeclaration(TypeDeclaration typeDeclaration)
        {
            HadDefaultConstructor = false;
            HadConstructor        = false;
            IType type = typeDeclaration.Annotation <TypeResolveResult>().Type;

            Formatter.NameSpace = type.Namespace;
            if (!namespaces.ContainsKey(type.Namespace))
            {
                namespaces.Add(type.Namespace, type.Namespace);
            }
            OutputEntityType(typeDeclaration);
            TypeVisitor.FormatType(type);
            OutputParentage(typeDeclaration, type);
            Formatter.AddOpenBrace();
            if (typeDeclaration.ClassType != ClassType.Struct)
            {
                Formatter.AppendIndentedLine("public:");
            }
            foreach (var member in typeDeclaration.Members)
            {
                member.AcceptVisitor(this);
            }
            if (typeDeclaration.ClassType == ClassType.Struct && HadConstructor && !HadDefaultConstructor)
            {
                CreateDefaultConstructor(typeDeclaration);
            }
            Formatter.AddCloseBrace(true);
        }
예제 #2
0
        /// <summary>
        /// Output all values in an enum.
        /// Append the enum name to end to ensure they are unique.
        /// </summary>
        /// <param name="typeDeclaration">enum declaration</param>
        private void OutputEnumValues(TypeDeclaration typeDeclaration)
        {
            EnumName = typeDeclaration.Name;
            Formatter.AddOpenBrace();
            bool first = true;

            foreach (var member in typeDeclaration.Members)
            {
                if (!first)
                {
                    Formatter.AppendLine(",");
                }
                member.AcceptVisitor(this);
                first = false;
            }
            Formatter.AddCloseBrace(true);
        }