Beispiel #1
0
        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------

        #region Public Methods

        public override void Go()
        {
            string generatedPath =
                Path.Combine(
                    _resourceModel.OutputDirectory,
                    "src\\Graphics\\Include\\Generated"
                    );

            FileCodeSink cppFile = new FileCodeSink(generatedPath, "wgx_render_types_generated.h");;

            Helpers.Style.WriteFileHeader(cppFile);

            foreach (McgEnum e in _resourceModel.Enums)
            {
                if (_resourceModel.ShouldGenerate(CodeSections.NativeMilRenderTypes, e))
                {
                    cppFile.WriteBlock(EnumHelper.FormatNativeEnum(e));
                }
            }

            foreach (McgResource r in _resourceModel.Resources)
            {
                if (_resourceModel.ShouldGenerate(CodeSections.NativeMilRenderTypes, r))
                {
                    cppFile.WriteBlock(StructHelper.FormatNativeStructure(r));
                }
            }

            //
            // MilCompoundStyle is a special case
            //
            McgEnum milCompoundStyleEnum = (McgEnum)_resourceModel.FindType("MilCompoundStyle");

            cppFile.WriteBlock(
        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------

        #region Public Methods

        public override void Go()
        {
            string generatedPath =
                Path.Combine(
                    _resourceModel.OutputDirectory,
                    "src\\Graphics\\Include\\Generated"
                    );

            FileCodeSink cppFile = new FileCodeSink(generatedPath, "wincodec_private_generated.h");;

            Helpers.Style.WriteFileHeader(cppFile);

            foreach (McgEnum e in _resourceModel.Enums)
            {
                if (_resourceModel.ShouldGenerate(CodeSections.NativeWincodecPrivate, e))
                {
                    cppFile.WriteBlock(EnumHelper.FormatNativeEnum(e));
                }
            }

            foreach (McgResource r in _resourceModel.Resources)
            {
                if (_resourceModel.ShouldGenerate(CodeSections.NativeWincodecPrivate, r))
                {
                    cppFile.WriteBlock(StructHelper.FormatNativeStructure(r));
                }
            }

            cppFile.Dispose();
        }
        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------

        public override void Go()
        {
            foreach (CGElement e in CG.Elements)
            {
                string path     = Path.Combine(CG.OutputDirectory, e.ManagedDestinationDir);
                string filename = e.Name + ".cs";

                using (FileCodeSink cs = new FileCodeSink(path, filename, true /* Create dir if necessary */))
                {
                    cs.WriteBlock(Helpers.ManagedStyle.WriteFileHeader(filename));
                    cs.WriteBlock(
Beispiel #4
0
        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------

        #region Public Methods

        public override void Go()
        {
            string generatedPath =
                Path.Combine(
                    _resourceModel.OutputDirectory,
                    "src\\Graphics\\Include\\Generated"
                    );

            FileCodeSink cppFile = new FileCodeSink(generatedPath, "wgx_misc.h");;
            FileCodeSink csFile  = new FileCodeSink(generatedPath, "wgx_misc.cs");

            m_cpp = new StringCodeSink();
            m_cs  = new StringCodeSink();

            //
            // Write the definitions
            //

            WriteEnums();

            WriteStructs();

            //
            // Serialize the C++ header and the C# files for the Avalon commands:
            //

            Helpers.Style.WriteFileHeader(cppFile);
            cppFile.WriteBlock(m_cpp.ToString());

            csFile.WriteBlock(Helpers.ManagedStyle.WriteFileHeader("wgx_misc.cs"));
            csFile.WriteBlock(m_cs.ToString());


            cppFile.Dispose();
            csFile.Dispose();
        }
        //------------------------------------------------------
        //
        //  Public Methods
        //
        //------------------------------------------------------

        #region Public Methods

        public override void Go()
        {
            string generatedPath =
                Path.Combine(
                    _resourceModel.OutputDirectory,
                    "src\\Graphics\\Include\\Generated"
                    );

            FileCodeSink cppFile = new FileCodeSink(generatedPath, "wgx_commands.h");;
            FileCodeSink csFile  = new FileCodeSink(generatedPath, "wgx_commands.cs");

            m_redirection = new StringCodeSink();
            m_dwm         = new StringCodeSink();
            m_cpp         = new StringCodeSink();
            m_cs          = new StringCodeSink();


            //
            // Collect the commands from the resource model and start generation.
            //

            PaddedCommandCollection commands =
                new PaddedCommandCollection(_resourceModel);

            // Contains list of Commands which contain security critical resources
            List <String> commandList = new List <String>();

            foreach (PaddedCommand command in commands.PaddedCommands)
            {
                if (command.Domain == "Redirection")
                {
                    WriteRedirectionCommand(command);
                }
                else if (command.Domain == "DWM")
                {
                    WriteDwmCommand(command);
                }
                else if (command.Origin != PaddedCommandOrigin.RenderDataInstruction)
                {
                    //
                    // Skip the render data instruction, they are emitted by
                    // the RenderData.cs generator...
                    //

                    WriteCommand(command);

                    // IsSecurityCritical does not make sense if the command is only for
                    // unmanaged code since its an attribute in managed code
                    if (command.CommandIsSecurityCritical && !command.CommandIsUnmanagedOnly)
                    {
                        commandList.Add(command.TypeName);
                    }
                }
            }

            // Parses the commands (which are securityCritical) to make switch-case statement.
            StringBuilder switchCaseBlock = MakeSwitchCaseStatement(commandList);

            //
            // Serialize the C++ header and the C# files for the Avalon commands:
            //

            Helpers.Style.WriteFileHeader(cppFile);
            cppFile.WriteBlock(m_cpp.ToString());

            csFile.WriteBlock(
                Helpers.ManagedStyle.WriteFileHeader("wgx_commands.cs"));

            csFile.WriteBlock(