Beispiel #1
0
        private CSharpConverter(CSharpConverterOptions options)
        {
            Options               = options ?? throw new ArgumentNullException(nameof(options));
            _mapCppToCSharp       = new Dictionary <CppElement, CSharpElement>(CppElementReferenceEqualityComparer.Default);
            _cppElementsToDiscard = new HashSet <CppElement>(CppElementReferenceEqualityComparer.Default);
            _csTempWriter         = new CodeWriter(new CodeWriterOptions(null));
            Tags = new Dictionary <string, object>();

            _currentContainers = new Stack <ICSharpContainer>();

            _pipeline = new CSharpConverterPipeline(options);
            _pipeline.RegisterPlugins(this);
        }
Beispiel #2
0
        public static CSharpCompilation Convert(string text, CSharpConverterOptions options)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var converter = new CSharpConverter(options);

            return(converter.Run(parserOptions => CppParser.Parse(text, parserOptions)));
        }
Beispiel #3
0
        public static CSharpCompilation Convert(List <string> files, CSharpConverterOptions options)
        {
            if (files == null)
            {
                throw new ArgumentNullException(nameof(files));
            }
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var converter = new CSharpConverter(options);

            return(converter.Run(parserOptions => CppParser.ParseFiles(files, parserOptions)));
        }
Beispiel #4
0
 public CSharpConverterPipeline(CSharpConverterOptions options)
 {
     Options                     = options ?? throw new ArgumentNullException(nameof(options));
     ConvertBegin                = new List <GlobalProcessingDelegate>();
     GetCSharpNameResolvers      = new List <GetCSharpNameDelegate>();
     GetCSharpTypeResolvers      = new List <GetCSharpTypeDelegate>();
     GetCSharpContainerResolvers = new List <GetCSharpContainerDelegate>();
     AfterPreprocessing          = new List <AfterPreprocessingDelegate>();
     CompilationConverters       = new List <ConvertCompilationDelegate>();
     CommentConverters           = new List <ConvertCommentDelegate>();
     EnumConverters              = new List <ConvertEnumDelegate>();
     EnumItemConverters          = new List <ConvertEnumItemDelegate>();
     ClassConverters             = new List <ConvertClassDelegate>();
     FieldConverters             = new List <ConvertFieldDelegate>();
     FunctionConverters          = new List <ConvertFunctionDelegate>();
     FunctionTypeConverters      = new List <ConvertFunctionTypeDelegate>();
     ParameterConverters         = new List <ConvertParameterDelegate>();
     TypedefConverters           = new List <ConvertTypedefDelegate>();
     Converting                  = new List <ProcessBeforeConvertDelegate>();
     Converted                   = new List <ProcessAfterConvertDelegate>();
     ConvertEnd                  = new List <GlobalProcessingDelegate>();
     RegisteredPlugins           = new List <ICSharpConverterPlugin>();
 }