public void WhenParsingUnsignedInt_TheUnsignedQualifierIsApplied()
        {
            var parser = new HeaderParser(CHeaderLexer.Lex(
                                              "unsigned int foo;"));
            var declaration = parser.ParseHeader().Single();

            Assert.That(declaration.CType.Qualifiers, Is.EqualTo(new[] { "unsigned" }));
        }
        public void WhenParsingInt_TheUnsignedQualifierIsNotApplied()
        {
            var parser = new HeaderParser(CHeaderLexer.Lex(
                                              "int foo;"));
            var declaration = parser.ParseHeader().Single();

            Assert.That(declaration.CType.Qualifiers, Is.Empty);
        }
        public void Parse()
        {
            var parser = new HeaderParser(CHeaderLexer.Lex(
                                              "/** Some function */\n" +
                                              "void frob_widgets(widget *widgets, int num_widgets);"));

            iDeclarations = parser.ParseHeader().ToArray();
        }
        public void WhenParsingConstIntStarConst_TheConstQualifierIsAppliedToBoth()
        {
            var parser = new HeaderParser(CHeaderLexer.Lex(
                                              "const int * const foo;"));
            var declaration = parser.ParseHeader().Single();
            var ptrType     = (PointerCType)declaration.CType;

            Assert.That(ptrType.Qualifiers, Is.EqualTo(new[] { "const" }));
            Assert.That(ptrType.BaseType.Qualifiers, Is.EqualTo(new[] { "const" }));
        }
        public void WhenParsingIntConstStar_TheConstQualifierIsAppliedToTheInt()
        {
            var parser = new HeaderParser(CHeaderLexer.Lex(
                                              "int const *foo;"));
            var declaration = parser.ParseHeader().Single();
            var ptrType     = (PointerCType)declaration.CType;

            Assert.That(ptrType.BaseType.Qualifiers, Is.EqualTo(new[] { "const" }));
            Assert.That(ptrType.Qualifiers, Is.Empty);
        }
        private static IReplay ParseReplay(UnpackResult result)
        {
            HeaderParser headerParser = new HeaderParser(result.Header);
            Header header = headerParser.ParseHeader();

            ActionParser actionsParser = new ActionParser(result.Actions, header.Players.ToList<IPlayer>());
            List<IAction> actions = actionsParser.ParseActions();

            IReplay replay = new Replay(header, actions);

            return replay;
        }
Exemple #7
0
        private static IReplay ParseReplay(UnpackResult result)
        {
            HeaderParser headerParser = new HeaderParser(result.Header);
            Header       header       = headerParser.ParseHeader();

            ActionParser   actionsParser = new ActionParser(result.Actions, header.Players.ToList <IPlayer>());
            List <IAction> actions       = actionsParser.ParseActions();

            IReplay replay = new Replay(header, actions);

            return(replay);
        }
        public void Parse()
        {
            var parser = new HeaderParser(CHeaderLexer.Lex(
                                              "/** Brave explorer */\n" +
                                              "typedef struct tagexplorer {\n" +
                                              "    int x;                           ///< X coordinate\n" +
                                              "    int y;                           ///< Y coordinate\n" +
                                              "    char name[32];                   ///< Name\n" +
                                              "    struct taghero * bestfriend;     ///< Friend\n" +
                                              "} explorer;\n"
                                              ));

            iDeclarations = parser.ParseHeader().ToArray();
        }
        public void Parse()
        {
            var parser = new HeaderParser(CHeaderLexer.Lex(
                                              "/** Flavors of food */\n" +
                                              "typedef enum tagflavor {\n" +
                                              "    FLAVOR_VANILLA = 0,      ///< Universally popular\n" +
                                              "    FLAVOR_CHEESE_AND_ONION,\n" +
                                              "    FLAVOR_SPEARMINT,        ///< Soothing\n" +
                                              "    FLAVOR_COFFEE=99,        ///< Stimulating\n" +
                                              "    FLAVOR_SMOKY_BACON       ///< Controversial\n" +
                                              "} flavor;\n"
                                              ));

            iDeclarations = parser.ParseHeader().ToArray();
        }
Exemple #10
0
        private void ReDownload(Downloader d)
        {
            Downloadable file = new Downloadable()
            {
                URL = d.File.URL,
                DegreeOfParallelism = (uint)SettingsWindow.GeneralSettings.MaxConnection,
                FilePath            = SettingsWindow.GeneralSettings.StoragePath
            };

            DownloaderList.Remove(d);
            HeaderParser parser = new HeaderParser(file);

            parser.OnParseSuccess += parser_Redownload;
            parser.OnError        += Down_OnError;
            parser.ParseHeader();
        }
Exemple #11
0
        private void ReDownload(string directURL = null, string FileName = null)
        {
            if (dataGridView1.Rows.Count <= 0 && directURL == null)
            {
                return;
            }

            int ind = -1;

            if (dataGridView1.Rows.Count > 0)
            {
                ind = dataGridView1.Rows.IndexOf(dataGridView1.SelectedRows[0]);
            }
            if (ind >= 0 || directURL != null)
            {
                if (ind >= 0)
                {
                    DownloaderList[ind].Pause();
                }

                Downloadable file = new Downloadable()
                {
                    URL                 = directURL == null?DownloaderList[ind].File.URL:directURL,
                    FileName            = FileName == null?DownloaderList[ind].File.FileName:FileName,
                    DegreeOfParallelism = (uint)SettingsWindow.GeneralSettings.MaxConnection,
                    FilePath            = SettingsWindow.GeneralSettings.StoragePath
                };
                if (FileName != null)
                {
                    file.FileName = FileName;
                }

                if (directURL == null)
                {
                    DownloaderList.Remove(DownloaderList[ind]);
                }
                HeaderParser parser = new HeaderParser(file);
                parser.OnParseSuccess += parser_Redownload;
                parser.OnError        += Down_OnError;
                parser.ParseHeader();
            }
        }
Exemple #12
0
        private void AddURL(string URL = null)
        {
            AddURLWindow auw = new AddURLWindow();

            if (URL != null)
            {
                auw.URL = URL;
            }
            DialogResult res = auw.ShowDialog();

            if (res == DialogResult.OK)
            {
                Downloadable file = new Downloadable()
                {
                    URL = auw.URL,
                    DegreeOfParallelism = (uint)SettingsWindow.GeneralSettings.MaxConnection,
                    FilePath            = SettingsWindow.GeneralSettings.StoragePath
                };
                HeaderParser parser = new HeaderParser(file);
                parser.OnParseSuccess += Parser_OnParseSuccess;
                parser.OnError        += Down_OnError;
                parser.ParseHeader();
            }
        }
        public void Parse()
        {
            var parser = new HeaderParser(CHeaderLexer.Lex("typedef struct tagname typename; ///< This is the comment\n"));

            iDeclarations = parser.ParseHeader().ToArray();
        }