Exemplo n.º 1
0
            /// <summary>
            /// Execute
            /// </summary>
            /// <param name="setting">Translation Unit Parse Setting</param>
            /// <returns>Translation Unit Map</returns>
            public TranslationUnitMap Execute(TranslationUnitParseSetting setting)
            {
                this.Setting = setting;

                var display_diag = setting.DisplayDiag;

                var src_path_list = setting.Sources;

                var command_line_args = setting.CommandLineArgs.ToArray();

                var options = setting.ParseOptions;

                using (var index = Clang.CreateIndex(false, display_diag))
                {
                    foreach (var src_path in src_path_list)
                    {
                        if (File.Exists(src_path))
                        {
                            using (var tu = index.ParseTranslationUnit(src_path, command_line_args, new ClangUnsavedFile[0], options))
                            {
                                this.ExecuteCore(index, tu);
                            }
                        }
                        else
                        {
                            throw new InvalidOperationException($"Source File Not Found :{src_path}");
                        }
                    }
                }

                return(this.TranslationUnitMap);
            }
Exemplo n.º 2
0
        /// <summary>
        /// Execute Translation Unit Handler
        /// </summary>
        /// <param name="src_path">Source Path</param>
        /// <param name="command_line_args">Command Line Arguments</param>
        /// <param name="options">Parse Options</param>
        /// <param name="display_diag">Display Diagnostics Flag</param>
        public void Execute(string src_path, string[] command_line_args, TranslationUnitFlags options = TranslationUnitFlags.None, bool display_diag = false)
        {
            this.SourcePath = src_path;

            this.CommandLineArgs = command_line_args;

            this.ParseOptions = options;

            this.DisplayDiagnostic = display_diag;

            using (var index = Clang.CreateIndex(false, display_diag))
            {
                using (var tu = index.ParseTranslationUnit(src_path, command_line_args, new ClangUnsavedFile[0], options))
                {
                    this.ExecuteCore(index, tu);
                }
            }
        }