diff options
author | Dimitri van Heesch <doxygen@gmail.com> | 2020-05-31 17:58:24 (GMT) |
---|---|---|
committer | Dimitri van Heesch <doxygen@gmail.com> | 2020-05-31 17:58:24 (GMT) |
commit | b265433382b93625b75cbc1f10b0509489b0b6b7 (patch) | |
tree | 896cdcd7e1a9f8c696fa7cf3535be906d2ad31d7 /src/parserintf.h | |
parent | 1705a1442dfa83d6c442bb45ed0d6e76f135ee5a (diff) | |
download | Doxygen-b265433382b93625b75cbc1f10b0509489b0b6b7.zip Doxygen-b265433382b93625b75cbc1f10b0509489b0b6b7.tar.gz Doxygen-b265433382b93625b75cbc1f10b0509489b0b6b7.tar.bz2 |
Added experimental multi-thread input processing support.
This is disabled by default. It can be enabled by setting MULTITHREADED_INPUT to 1
in doxygen.h. Still has many data races, so don't use for anything other than development!
Diffstat (limited to 'src/parserintf.h')
-rw-r--r-- | src/parserintf.h | 65 |
1 files changed, 34 insertions, 31 deletions
diff --git a/src/parserintf.h b/src/parserintf.h index 6dc9569..f11352e 100644 --- a/src/parserintf.h +++ b/src/parserintf.h @@ -1,12 +1,12 @@ /****************************************************************************** * - * + * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -20,6 +20,7 @@ #include <qstrlist.h> +#include <functional> #include <memory> #include <map> #include <string> @@ -35,7 +36,7 @@ class Definition; /** \brief Abstract interface for outline parsers. * * By implementing the methods of this interface one can add - * a new language parser to doxygen. The parser implementation can make use of the + * a new language parser to doxygen. The parser implementation can make use of the * comment block parser to parse the contents of special comment blocks. */ class OutlineParserInterface @@ -46,21 +47,21 @@ class OutlineParserInterface /** Starts processing a translation unit (source files + headers). * After this call parseInput() is called with sameTranslationUnit * set to FALSE. If parseInput() returns additional include files, - * these are also processed using parseInput() with + * these are also processed using parseInput() with * sameTranslationUnit set to TRUE. After that * finishTranslationUnit() is called. */ virtual void startTranslationUnit(const char *fileName) = 0; - /** Called after all files in a translation unit have been + /** Called after all files in a translation unit have been * processed. */ virtual void finishTranslationUnit() = 0; - /** Parses a single input file with the goal to build an Entry tree. + /** Parses a single input file with the goal to build an Entry tree. * @param[in] fileName The full name of the file. * @param[in] fileBuf The contents of the file (zero terminated). - * @param[in,out] root The root of the tree of Entry *nodes + * @param[in,out] root The root of the tree of Entry *nodes * representing the information extracted from the file. * @param[in] sameTranslationUnit TRUE if this file was found in the same * translation unit (in the filesInSameTranslationUnit list @@ -80,7 +81,7 @@ class OutlineParserInterface * @see parseInput() */ virtual bool needsPreprocessing(const QCString &extension) const = 0; - + /** Callback function called by the comment block scanner. * It provides a string \a text containing the prototype of a function * or variable. The parser should parse this and store the information @@ -110,14 +111,14 @@ class CodeParserInterface * @param[in] input Actual code in the form of a string * @param[in] isExampleBlock TRUE iff the code is part of an example. * @param[in] exampleName Name of the example. - * @param[in] fileDef File definition to which the code + * @param[in] fileDef File definition to which the code * is associated. - * @param[in] startLine Starting line in case of a code fragment. + * @param[in] startLine Starting line in case of a code fragment. * @param[in] endLine Ending line of the code fragment. - * @param[in] inlineFragment Code fragment that is to be shown inline + * @param[in] inlineFragment Code fragment that is to be shown inline * as part of the documentation. * @param[in] memberDef Member definition to which the code - * is associated (non null in case of an inline fragment + * is associated (non null in case of an inline fragment * for a member). * @param[in] showLineNumbers if set to TRUE and also fileDef is not 0, * line numbers will be added to the source fragment @@ -151,29 +152,31 @@ class CodeParserInterface //----------------------------------------------------------------------------- +using OutlineParserFactory = std::function<std::unique_ptr<OutlineParserInterface>()>; + /** \brief Manages programming language parsers. * - * This class manages the language parsers in the system. One can + * This class manages the language parsers in the system. One can * register parsers, and obtain a parser given a file extension. */ class ParserManager { public: + struct ParserPair { - ParserPair(std::unique_ptr<OutlineParserInterface> oli, - std::unique_ptr<CodeParserInterface> cpi) - : outlineParser(std::move(oli)), codeParser(std::move(cpi)) + ParserPair(OutlineParserFactory opf, std::unique_ptr<CodeParserInterface> cpi) + : outlineParserFactory(opf), codeParserInterface(std::move(cpi)) { } - std::unique_ptr<OutlineParserInterface> outlineParser; - std::unique_ptr<CodeParserInterface> codeParser; + OutlineParserFactory outlineParserFactory; + std::unique_ptr<CodeParserInterface> codeParserInterface; }; - ParserManager(std::unique_ptr<OutlineParserInterface> outlineParser, - std::unique_ptr<CodeParserInterface> codeParser) - : m_defaultParsers(std::move(outlineParser),std::move(codeParser)) + ParserManager(OutlineParserFactory outlineParserFactory, + std::unique_ptr<CodeParserInterface> codeParserInterface) + : m_defaultParsers(outlineParserFactory,std::move(codeParserInterface)) { } @@ -185,14 +188,14 @@ class ParserManager * @param[in] codeParser The code parser that is to be used for the * given name. */ - void registerParser(const char *name,std::unique_ptr<OutlineParserInterface> outlineParser, - std::unique_ptr<CodeParserInterface> codeParser) + void registerParser(const char *name,OutlineParserFactory outlineParserFactory, + std::unique_ptr<CodeParserInterface> codeParserInterface) { m_parsers.emplace(std::string(name), - ParserPair(std::move(outlineParser),std::move(codeParser))); + ParserPair(outlineParserFactory,std::move(codeParserInterface))); } - /** Registers a file \a extension with a parser with name \a parserName. + /** Registers a file \a extension with a parser with name \a parserName. * Returns TRUE if the extension was successfully registered. */ bool registerExtension(const char *extension, const char *parserName) @@ -212,21 +215,21 @@ class ParserManager } /** Gets the interface to the parser associated with given \a extension. - * If there is no parser explicitly registered for the supplied extension, + * If there is no parser explicitly registered for the supplied extension, * the interface to the default parser will be returned. */ - OutlineParserInterface &getOutlineParser(const char *extension) + std::unique_ptr<OutlineParserInterface> getOutlineParser(const char *extension) { - return *getParsers(extension).outlineParser; + return getParsers(extension).outlineParserFactory(); } /** Gets the interface to the parser associated with given \a extension. - * If there is no parser explicitly registered for the supplied extension, + * If there is no parser explicitly registered for the supplied extension, * the interface to the default parser will be returned. */ CodeParserInterface &getCodeParser(const char *extension) { - return *getParsers(extension).codeParser; + return *getParsers(extension).codeParserInterface; } private: |