Beispiel #1
0
        public override bool VisitClassDecl(Class @class)
        {
            if (@class.IsIncomplete)
            {
                return(true);
            }

            PushBlock(BlockKind.InternalsClass, @class);
            var callbacks = new NAPIInvokes(Context);

            @class.Visit(callbacks);
            Write(callbacks.Generate());
            PopBlock(NewLineKind.BeforeNextBlock);

            PushBlock(BlockKind.Class, @class);
            Write($"static napi_value register_class_{GetCIdentifier(Context, @class)}");
            WriteLine("(napi_env env)");
            WriteOpenBraceAndIndent();

            var sources = new NAPIRegisterImpl(Context);

            sources.Indent(CurrentIndentation);
            @class.Visit(sources);
            Write(sources.Generate());

            UnindentAndWriteCloseBrace();
            PopBlock(NewLineKind.BeforeNextBlock);
            return(false);
        }
Beispiel #2
0
        public override bool VisitEnumDecl(Enumeration @enum)
        {
            if (@enum.IsIncomplete)
            {
                return(false);
            }

            PushBlock(BlockKind.Enum);

            Write($"static napi_value register_enum_{GetCIdentifier(Context, @enum)}");
            WriteLine("(napi_env env, napi_value exports)");
            WriteOpenBraceAndIndent();

            var sources = new NAPIRegisterImpl(Context);

            sources.Indent(CurrentIndentation);
            @enum.Visit(sources);
            Write(sources.Generate());

            UnindentAndWriteCloseBrace();
            PopBlock(NewLineKind.BeforeNextBlock);
            return(true);
        }