diff options
author | Luca Di Sera <luca.disera@qt.io> | 2023-03-17 11:13:34 +0100 |
---|---|---|
committer | Luca Di Sera <luca.disera@qt.io> | 2023-03-19 15:04:28 +0000 |
commit | a45b2106549e8b0eb665651b053fba3743d50324 (patch) | |
tree | ad47fe375ae24b86e4565423e4cf4ad122cd7650 /src/qdoc/cppcodeparser.cpp | |
parent | b3630c567cf2ed22a4b200b4aa72eeb23ba08dfb (diff) | |
download | qttools-a45b2106549e8b0eb665651b053fba3743d50324.tar.gz |
QDoc: Remove `CodeParser::commonMetaCommands`
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<QString>`, 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ƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/cppcodeparser.cpp')
-rw-r--r-- | src/qdoc/cppcodeparser.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
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; |