Esempio n. 1
0
        private void generateButton_Click(object sender, System.EventArgs e)
        {
            DirectoryInfo outputDir = new DirectoryInfo(outputPathTextBox.Text);

            if (outputDir.Exists == false)
            {
                MessageBox.Show(this, "Output Path is invalid", "Code Generator");
                return;
            }

            // POSIX, Windows, PocketPC Code Generation
            LibraryGenerator libgen = new LibraryGenerator();

            genOutputTextBox.Clear();

            switch (platformComboBox.SelectedIndex)
            {
            case 0:
                libgen.Platform  = LibraryGenerator.PLATFORMS.POSIX;
                libgen.SubTarget = LibraryGenerator.SUBTARGETS.NONE;
                break;

            case 1:
                libgen.Platform  = LibraryGenerator.PLATFORMS.WINDOWS;
                libgen.SubTarget = LibraryGenerator.SUBTARGETS.NONE;
                libgen.WinSock   = 1;
                break;

            case 2:
                libgen.Platform  = LibraryGenerator.PLATFORMS.WINDOWS;
                libgen.SubTarget = LibraryGenerator.SUBTARGETS.NONE;
                libgen.WinSock   = 2;
                break;

            case 3:
                libgen.Platform  = LibraryGenerator.PLATFORMS.WINDOWS;
                libgen.SubTarget = LibraryGenerator.SUBTARGETS.PPC2003;
                libgen.WinSock   = 1;
                break;
            }

            switch (languageComboBox.SelectedIndex)
            {
            case 0:
                libgen.Language = LibraryGenerator.LANGUAGES.C;
                break;

            case 1:
                libgen.Language = LibraryGenerator.LANGUAGES.CPP;
                break;
            }

            switch (newLineComboBox.SelectedIndex)
            {
            case 0:
                libgen.CodeNewLine = "\r\n";
                break;

            case 1:
                libgen.CodeNewLine = "\n";
                break;
            }

            switch (callConventionComboBox.SelectedIndex)
            {
            case 0:
                libgen.CallingConvention = ""; break;

            case 1:
                libgen.CallingConvention = "_stdcall "; break;

            case 2:
                libgen.CallingConvention = "_fastcall "; break;
            }

            switch (indentComboBox.SelectedIndex)
            {
            case 0:
                libgen.CodeTab = "\t"; break;

            case 1:
                libgen.CodeTab = " "; break;

            case 2:
                libgen.CodeTab = "  "; break;

            case 3:
                libgen.CodeTab = "   "; break;

            case 4:
                libgen.CodeTab = "    "; break;

            case 5:
                libgen.CodeTab = "     "; break;

            case 6:
                libgen.CodeTab = "      "; break;
            }

            libgen.CallPrefix    = libPrefixTextBox.Text;
            libgen.CallLibPrefix = libPrefixTextBox.Text;
            libgen.VersionString = "Intel DeviceBuilder Build#" + Application.ProductVersion;
            libgen.ClassName     = classNameTextBox.Text;

            // Setup License
            string license = licenseTextBox.Text;

            license        = license.Replace("<AUTHOR>", "Intel Corporation, Intel Device Builder");
            license        = license.Replace("<REVISION>", "#" + Application.ProductVersion);
            license        = license.Replace("<DATE>", DateTime.Now.ToLongDateString());
            libgen.License = license;

            string lib;

            if (modulesCheckedListBox.GetItemCheckState(3) == CheckState.Checked)
            {
                SourceCodeRepository.Generate_AsyncSocket(libPrefixTextBox.Text, outputDir);
            }
            if (modulesCheckedListBox.GetItemCheckState(4) == CheckState.Checked)
            {
                SourceCodeRepository.Generate_AsyncServerSocket(libPrefixTextBox.Text, outputDir);
            }
            if (modulesCheckedListBox.GetItemCheckState(5) == CheckState.Checked)
            {
                SourceCodeRepository.Generate_WebClient(libPrefixTextBox.Text, outputDir, false);
            }
            if (modulesCheckedListBox.GetItemCheckState(6) == CheckState.Checked)
            {
                SourceCodeRepository.Generate_WebServer(libPrefixTextBox.Text, outputDir, false);
            }

            libgen.OnLogOutput += new LibraryGenerator.LogOutputHandler(Log);
            try
            {
                if (modulesCheckedListBox.GetItemCheckState(0) == CheckState.Checked)
                {
                    SourceCodeRepository.Generate_Parsers(libPrefixTextBox.Text, outputDir);
                }
                if (modulesCheckedListBox.GetItemCheckState(1) == CheckState.Checked)
                {
                    libgen.Build_UPnPHTTPClient(outputDir);
                }
                if (modulesCheckedListBox.GetItemCheckState(2) == CheckState.Checked)
                {
                    SourceCodeRepository.Generate_SSDPClient(libPrefixTextBox.Text, outputDir, true);
                }
            }
            catch
            {
                MessageBox.Show(this, "Error Generating Code", "Code Generator");
            }

            libgen.OnLogOutput -= new LibraryGenerator.LogOutputHandler(Log);
        }
        public void generateButton_Click(object sender, System.EventArgs e)
        {
            DirectoryInfo outputDir = new DirectoryInfo(outputPathTextBox.Text);

            if (outputDir.Exists == false)
            {
                MessageBox.Show(this, "Output Path is invalid", "Code Generator");
                return;
            }

            string buttonText = generateButton.Text;

            generateButton.Text    = "Generating Stack...";
            generateButton.Enabled = false;

            if (UPnP1dot1Enabled.Checked == true)
            {
                device.ArchitectureVersion = "1.1";
            }
            else
            {
                device.ArchitectureVersion = "1.0";
            }

            if (platformComboBox.SelectedIndex == 4)
            {
                // .net
                CPDotNetGenerator gen = new CPDotNetGenerator(classNameTextBox.Text);
                genOutputTextBox.Clear();

                gen.VersionString = "Intel StackBuilder Build#" + Application.ProductVersion;
                gen.StartupPath   = Application.StartupPath;
                gen.OnLogOutput  += new CPDotNetGenerator.LogOutputHandler(Log);
                try
                {
                    gen.Generate(device, outputDir, serviceNames);
                }
                catch
                {
                    MessageBox.Show(this, "Error Generating Code", "Code Generator");
                }
                gen.OnLogOutput -= new CPDotNetGenerator.LogOutputHandler(Log);
            }
            else
            {
                CPEmbeddedCGenerator gen    = new CPEmbeddedCGenerator();
                LibraryGenerator     libgen = new LibraryGenerator();

                genOutputTextBox.Clear();

                gen.EnableDefaultIPAddressMonitor = IPAddressMonitor.Checked;

                switch (platformComboBox.SelectedIndex)
                {
                case 0:
                    gen.Platform     = CPEmbeddedCGenerator.PLATFORMS.POSIX;
                    gen.SubTarget    = CPEmbeddedCGenerator.SUBTARGETS.NONE;
                    libgen.Platform  = LibraryGenerator.PLATFORMS.POSIX;
                    libgen.SubTarget = LibraryGenerator.SUBTARGETS.NONE;
                    break;

                case 1:
                    gen.Platform     = CPEmbeddedCGenerator.PLATFORMS.WINDOWS;
                    gen.SubTarget    = CPEmbeddedCGenerator.SUBTARGETS.NONE;
                    gen.WinSock      = 1;
                    libgen.Platform  = LibraryGenerator.PLATFORMS.WINDOWS;
                    libgen.SubTarget = LibraryGenerator.SUBTARGETS.NONE;
                    libgen.WinSock   = 1;
                    break;

                case 2:
                    gen.Platform     = CPEmbeddedCGenerator.PLATFORMS.WINDOWS;
                    gen.SubTarget    = CPEmbeddedCGenerator.SUBTARGETS.NONE;
                    gen.WinSock      = 2;
                    libgen.Platform  = LibraryGenerator.PLATFORMS.WINDOWS;
                    libgen.SubTarget = LibraryGenerator.SUBTARGETS.NONE;
                    libgen.WinSock   = 2;
                    break;

                case 3:
                    gen.Platform     = CPEmbeddedCGenerator.PLATFORMS.WINDOWS;
                    gen.SubTarget    = CPEmbeddedCGenerator.SUBTARGETS.PPC2003;
                    gen.WinSock      = 1;
                    libgen.Platform  = LibraryGenerator.PLATFORMS.WINDOWS;
                    libgen.SubTarget = LibraryGenerator.SUBTARGETS.PPC2003;
                    libgen.WinSock   = 1;
                    break;

                case 4:
                    gen.Platform     = CPEmbeddedCGenerator.PLATFORMS.POSIX;
                    gen.SubTarget    = CPEmbeddedCGenerator.SUBTARGETS.NUCLEUS;
                    gen.WinSock      = 1;
                    libgen.Platform  = LibraryGenerator.PLATFORMS.POSIX;
                    libgen.SubTarget = LibraryGenerator.SUBTARGETS.NUCLEUS;
                    libgen.WinSock   = 1;
                    break;
                }

                switch (languageComboBox.SelectedIndex)
                {
                case 0:
                    gen.Language    = CPEmbeddedCGenerator.LANGUAGES.C;
                    libgen.Language = LibraryGenerator.LANGUAGES.C;
                    break;

                case 1:
                    gen.Language    = CPEmbeddedCGenerator.LANGUAGES.CPP;
                    libgen.Language = LibraryGenerator.LANGUAGES.CPP;
                    break;
                }

                switch (newLineComboBox.SelectedIndex)
                {
                case 0:
                    gen.CodeNewLine = "\r\n"; break;

                case 1:
                    gen.CodeNewLine = "\n"; break;
                }

                switch (callConventionComboBox.SelectedIndex)
                {
                case 0:
                    gen.CallingConvention = ""; break;

                case 1:
                    gen.CallingConvention = "_stdcall "; break;

                case 2:
                    gen.CallingConvention = "_fastcall "; break;
                }

                switch (indentComboBox.SelectedIndex)
                {
                case 0:
                    gen.CodeTab = "\t"; break;

                case 1:
                    gen.CodeTab = " "; break;

                case 2:
                    gen.CodeTab = "  "; break;

                case 3:
                    gen.CodeTab = "   "; break;

                case 4:
                    gen.CodeTab = "    "; break;

                case 5:
                    gen.CodeTab = "     "; break;

                case 6:
                    gen.CodeTab = "      "; break;
                }

                gen.CallPrefix          = prefixTextBox.Text;
                gen.CallLibPrefix       = libPrefixTextBox.Text;
                gen.Settings            = Settings;
                gen.FragResponseActions = FragResponseActions;
                gen.EscapeActions       = EscapeActions;
                gen.VersionString       = "Intel DeviceBuilder Build#" + Application.ProductVersion;
                gen.ClassName           = classNameTextBox.Text;
                gen.UseVersion          = Application.ProductVersion.Substring(0, Application.ProductVersion.LastIndexOf("."));
                gen.BasicHTTP           = !(HTTP.Checked);

                libgen.CodeNewLine       = gen.CodeNewLine;
                libgen.CallingConvention = gen.CallingConvention;
                libgen.CodeTab           = gen.CodeTab;
                libgen.CodeNewLine       = gen.CodeNewLine;
                libgen.CallPrefix        = libPrefixTextBox.Text;
                libgen.VersionString     = gen.VersionString;
                libgen.ClassName         = gen.ClassName;

                foreach (System.Data.DataRow r in dataSet1.Tables[0].Rows)
                {
                    gen.CustomTagList.Add(new object[2] {
                        (string)r.ItemArray[0], (string)r.ItemArray[1]
                    });
                }


                // Setup License
                string license = licenseTextBox.Text;
                license        = license.Replace("<AUTHOR>", "Intel Corporation, Intel Device Builder");
                license        = license.Replace("<REVISION>", "#" + Application.ProductVersion);
                license        = license.Replace("<DATE>", DateTime.Now.ToLongDateString());
                gen.License    = license;
                libgen.License = license;

                gen.OnLogOutput    += new CPEmbeddedCGenerator.LogOutputHandler(Log);
                libgen.OnLogOutput += new LibraryGenerator.LogOutputHandler(Log);

                try
                {
                    SourceCodeRepository.Generate_UPnPControlPointStructs(libPrefixTextBox.Text, outputDir);
                    SourceCodeRepository.Generate_Parsers(this.libPrefixTextBox.Text, outputDir);
                    SourceCodeRepository.Generate_SSDPClient(this.libPrefixTextBox.Text, outputDir, UPnP1dot1Enabled.Checked);

                    SourceCodeRepository.Generate_AsyncSocket(this.libPrefixTextBox.Text, outputDir);
                    SourceCodeRepository.Generate_AsyncServerSocket(this.libPrefixTextBox.Text, outputDir);
                    SourceCodeRepository.Generate_WebClient(this.libPrefixTextBox.Text, outputDir, !HTTP.Checked);
                    SourceCodeRepository.Generate_WebServer(this.libPrefixTextBox.Text, outputDir, !HTTP.Checked);

                    gen.Generate(device, outputDir, serviceNames, !(bool)gen.Settings["SupressSample"]);
                }
                catch (Exception ddd)
                {
                    MessageBox.Show(this, "Error Generating Code", "Code Generator");
                }

                libgen.OnLogOutput -= new LibraryGenerator.LogOutputHandler(Log);
                gen.OnLogOutput    -= new CPEmbeddedCGenerator.LogOutputHandler(Log);
            }

            generateButton.Enabled = true;
            generateButton.Text    = buttonText;
        }