コード例 #1
0
        public override TypePrinterResult VisitClassDecl(Class @class)
        {
            if (ContextKind == TypePrinterContextKind.Native)
            {
                return($"UnsafeMutablePointer<{CGenerator.QualifiedName(@class)}>!");
            }

            return(VisitDeclaration(@class));
        }
コード例 #2
0
        public override bool VisitEnumDecl(Enumeration @enum)
        {
            if (!VisitDeclaration(@enum))
            {
                return(false);
            }

            PushBlock();

            var enumName = Options.GeneratorKind != GeneratorKind.CPlusPlus ?
                           CGenerator.QualifiedName(@enum) : @enum.Name;

            Write($"typedef enum {enumName}");

            if (Options.GeneratorKind == GeneratorKind.CPlusPlus)
            {
                var typeName = CTypePrinter.VisitPrimitiveType(
                    @enum.BuiltinType.Type, new TypeQualifiers());

                if (@enum.BuiltinType.Type != PrimitiveType.Int)
                {
                    Write($" : {typeName}");
                }
            }

            NewLine();
            WriteStartBraceIndent();

            foreach (var item in @enum.Items)
            {
                var enumItemName = Options.GeneratorKind != GeneratorKind.CPlusPlus ?
                                   $"{@enum.QualifiedName}_{item.Name}" : item.Name;

                Write(enumItemName);

                if (item.ExplicitValue)
                {
                    Write($" = {@enum.GetItemValueAsString(item)}");
                }

                if (item != @enum.Items.Last())
                {
                    WriteLine(",");
                }
            }

            NewLine();
            PopIndent();
            WriteLine($"}} {enumName};");

            PopBlock(NewLineKind.BeforeNextBlock);

            return(true);
        }
コード例 #3
0
        public override string VisitDeclaration(Declaration decl)
        {
            var name = base.VisitDeclaration(decl);

            return(CGenerator.QualifiedName(decl));
        }