From a45b2106549e8b0eb665651b053fba3743d50324 Mon Sep 17 00:00:00 2001 From: Luca Di Sera Date: Fri, 17 Mar 2023 11:13:34 +0100 Subject: QDoc: Remove `CodeParser::commonMetaCommands` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As part of extracting user-provided documentation, QDoc has to parse a variety of source files in a variety of languages. `CodeParser` is the base class of objects that take care of performing this parsing process in QDoc. When extracting the documentation in one of the `CodeParser`s QDoc generally tries to parse the extracted documentation in-place. The documentation has a series of available commands that might depend on the currently used parser. To support this process `CodeParser` provides as part of its interface a series of methods to retrieve the required commands for each parser. One of those methods, `commonMetaCommands`, provides the commands that are common to all parser. `commonMetaCommands` initializes a static member, `commonMetaCommands_` and then returns it, avoiding initialization if the method is called more than once. While this process can be better expressed by the simple use of a `static` there are two probable reason for why it wasn't done in this way. Supposedly, when this code was written, there was no suitable way to initialize a `QSet`, the type of `commonMetaCommands_`, in-place, as similar patterns can be found in other legacy parts of QDoc that are confirmed to have had this issue due to their age. Additionally, the expansion of the `COMMAND_*` macros, which form the content for `commonMetaCommands_`, were, until recently, dependent on certain data being available in another part of the system, so that expanding them in a static context that would be processed before this data was available would incur into a series of errors. This dependency was removed in a recent patch, so that the issue is no more. Hence, the `commonMetaCommands()` method is removed, along with `commonMetaCommands_`, in favor of a public static, `common_meta_commands`, that is initialized in-place, to simplify the related code. `common_meta_commands` is initialized inline under `CodeParser` in "codeparser.h". Its initialization depends on the `COMMAND_*` macros being available. Previously, those macros were defined under `Codeparser` in "codeparser.h" so that they would not be available at the point of initialization. Hence, all definition of the `COMMAND_*` macros were moved higher up in "codeparser.h", to ensure that they would be available when required by `common_meta_commands`. All usages of `commonMetaCommands()` were modified to refer to `CodeParser::common_meta_commands`, keeping an equivalent semantic. Change-Id: If4987e5c1b53e80585e7556e62701690d98954c3 Reviewed-by: Topi Reiniƶ --- src/qdoc/cppcodeparser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/qdoc/cppcodeparser.cpp') diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index 0f0cfe1cf..01434f352 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -77,7 +77,7 @@ CppCodeParser::CppCodeParser() << COMMAND_STRUCT << COMMAND_UNION; } if (metaCommands_.isEmpty()) { - metaCommands_ = commonMetaCommands(); + metaCommands_ = CodeParser::common_meta_commands; metaCommands_ << COMMAND_INHEADERFILE << COMMAND_NEXTPAGE << COMMAND_OVERLOAD << COMMAND_PREVIOUSPAGE << COMMAND_QMLINSTANTIATES << COMMAND_REIMP << COMMAND_RELATES; -- cgit v1.2.1