Esempio n. 1
0
 public void CSourceFileConstructorTest3()
 {
     string        FullPathAndFileName = string.Empty;
     Encoding      file_encoding       = Encoding.GetEncoding(866);
     CCodeFragment _Content            = new CCodeFragment();
     CSourceFile   target = new CSourceFile(FullPathAndFileName, file_encoding, _Content);
 }
Esempio n. 2
0
        public void SizeTest()
        {
            string        FullPathAndFileName = "somefile.ext";
            Encoding      file_encoding       = Encoding.GetEncoding(866);
            CCodeFragment _Content            = new CCodeFragment(CreateCollection());
            CSourceFile   target = new CSourceFile(FullPathAndFileName, file_encoding, _Content);

            Assert.AreEqual(3, target.Size());
        }
Esempio n. 3
0
        public void CSourceFileConstructorTest2()
        {
            string        FullPathAndFileName = "somefile.ext";
            Encoding      file_encoding       = Encoding.GetEncoding(866);
            CCodeFragment _Content            = new CCodeFragment();
            CSourceFile   target = new CSourceFile(FullPathAndFileName, file_encoding, _Content);

            Assert.IsNotNull(target);
        }
Esempio n. 4
0
        public void NameTest()
        {
            string        FullPathAndFileName = "sdfsdf\\sdfsdf\\sdfsdf\\somefile.ext";
            Encoding      file_encoding       = Encoding.GetEncoding(866);
            CCodeFragment _Content            = new CCodeFragment();
            CSourceFile   target = new CSourceFile(FullPathAndFileName, file_encoding, _Content);

            Assert.AreEqual("somefile.ext", target.Name);
        }
Esempio n. 5
0
        public void SourceFileIDTest()
        {
            CSourceFileID _FileID             = new CSourceFileID();
            string        FullPathAndFileName = "somefile.ext";
            Encoding      file_encoding       = Encoding.GetEncoding(866);
            CCodeFragment _Content            = new CCodeFragment();
            CSourceFile   target = new CSourceFile(_FileID, FullPathAndFileName, file_encoding, _Content);

            Assert.AreEqual(_FileID.SourceFileID, target.SourceFileID);
        }
Esempio n. 6
0
        public void FileEncodingTest()
        {
            string        FullPathAndFileName = "somefile.ext";
            Encoding      file_encoding       = Encoding.GetEncoding(866);
            CCodeFragment _Content            = new CCodeFragment();
            CSourceFile   target = new CSourceFile(FullPathAndFileName, file_encoding, _Content);

            Encoding expected = Encoding.GetEncoding(866);

            Assert.IsTrue(target.FileEncoding.Equals(expected));
        }
 public void WriteHeaderFile(CSourceFile parsedFile, Stream outStream)
 {
     using (var writer = new StreamWriter(outStream))
     {
         using (var includeGuardWriter = new IncludeGuardWriter(writer, this.IncludeGuard))
         {
             WriteHeaderComment(writer, this.HeaderComment);
             parsedFile.WritePPDefinitions(writer);
             parsedFile.WriteDeclarations(writer, this.IncludeStaticFunctions, this.IncludeExternFunctions);
         }
     }
 }
Esempio n. 8
0
        public void FilePathTest()
        {
            string        FullPath      = "dfgdfgdfg\\dfgdfg\\dfgdfg\\";
            Encoding      file_encoding = Encoding.GetEncoding(866);
            CCodeFragment _Content      = new CCodeFragment();
            CSourceFile   target        = new CSourceFile(FullPath + "somefile.ext", file_encoding, _Content);

            Assert.AreEqual(FullPath, target.FilePath);

            FullPath        = "dfsdfsdfsd\\fgdfgdfg\\tyryrt";
            target.FilePath = FullPath;
            Assert.AreEqual(FullPath, target.FilePath);
        }
Esempio n. 9
0
        /// <summary>
        /// Загрузить один файл
        /// </summary>
        /// <param name="filename"></param>
        protected override void LoadOneFile(string filename)
        {
            CSourceFileID            FileID = new CSourceFileID();
            CTokenizerParms          parms  = new CTokenizerParms(filename, LoadFilesOptions.FileEncoding, FileID);
            ISourceFileContentLoader loader = CSourceFileContentLoaderFactory.Create(parms, m_ext);
            CSourceFile source_file         = new CSourceFile(FileID, filename, LoadFilesOptions.FileEncoding, new CCodeFragment(loader.Load()));

            m_FilesCollection.IncreaseCountOfLinesInOriginFiles(source_file.Size());
            if (LoadFilesOptions.IsPreProcessingFile)
            {
                source_file.Content.Content = new CSimpleCodePreProcessingAlgorithm().PreProcessing(LoadFilesOptions.PreProcessingOptions, source_file.Content.Content);
            }
            m_FilesCollection.Add(source_file.SourceFileID, source_file);
            IncreaseCountOfLinesInModifiedFiles(source_file.Size());
        }
        /// <summary>
        /// Writer the parsed source file to the output file
        /// </summary>
        /// <param name="showIncludeGuard">Whether to surround the header file in an include guard</param>
        /// <param name="codeWriter">The code writer object</param>
        /// <param name="headerFileName">The name of the header file to produce</param>
        /// <param name="c">The parse source file</param>
        private static void WriteToHeaderFile(bool showIncludeGuard, CHeaderFileWriter codeWriter, string headerFileName, CSourceFile c)
        {
            if (showIncludeGuard)
            {
                codeWriter.IncludeGuard = new Regex(@"[^A-Z0-9_]").Replace(string.Format("__{0}__",
                                                                                         Path.GetFileName(headerFileName).ToUpperInvariant()), "_");
            }
            else
            {
                codeWriter.IncludeGuard = null;
            }

            using (var stream = File.Open(headerFileName, FileMode.Create))
            {
                codeWriter.WriteHeaderFile(c, stream);
            }
        }