コード例 #1
0
        public JavaGenerator(BindingContext context) : base(context)
        {
            TypePrinter = new JavaTypePrinter(Context);

            Passes = new PassBuilder <TranslationUnitPass>(Context);
            CGenerator.SetupPasses(Passes);
        }
コード例 #2
0
        public void GenerateNativeDeclarations(TranslationUnit unit)
        {
            // Since the native declarations are targetting the generated C bindings,
            // we need to modify the AST to match the one generated by the C target.

            var passes = new PassBuilder <TranslationUnitPass>(Context);

            CGenerator.SetupPasses(passes);

            Context.Options.GeneratorKind = GeneratorKind.C;

            passes.RunPasses(pass =>
            {
                pass.Context = Context;
                pass.VisitASTContext(Context.ASTContext);
            });

            Context.Options.GeneratorKind = GeneratorKind.Java;

            var nativeGen = new JavaNative(Context, unit);

            Generators.Add(nativeGen);
        }