diff options
author | Sami Shalayel <sami.shalayel@qt.io> | 2022-10-17 15:27:12 +0200 |
---|---|---|
committer | Sami Shalayel <sami.shalayel@qt.io> | 2022-10-28 17:34:03 +0200 |
commit | 19b3c6ec7f82383c2062c529bae2967e16a075b6 (patch) | |
tree | 5cad721265df8c85e3512698066a8a275738c8bc /tools | |
parent | f9defaf2676aaaa75e826f1b40afd95f9720384b (diff) |
qmltc: extend QmltcMethod with optional comments
The methods generated with Qmltc are facing the user:
therefore add the possibility to add internal comments
before generating the method call such that the user
can be warned or informed about certain unclear behaviors.
For example, the methods asked for in QTBUG-107570 needs to
warn the user about ownership issues on the arguments to
avoid dangling pointer references.
Task-number: QTBUG-107570
Change-Id: Id04ff7f9a36daad1da836bb421901b9b706a05e7
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmltc/qmltccodewriter.cpp | 8 | ||||
-rw-r--r-- | tools/qmltc/qmltcoutputir.h | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/tools/qmltc/qmltccodewriter.cpp b/tools/qmltc/qmltccodewriter.cpp index b2722d1e37..7820af5ed8 100644 --- a/tools/qmltc/qmltccodewriter.cpp +++ b/tools/qmltc/qmltccodewriter.cpp @@ -389,7 +389,13 @@ void QmltcCodeWriter::write(QmltcOutputWrapper &code, const QmltcMethod &method) // do not generate method implementation if it is a signal const auto methodType = method.type; if (methodType != QQmlJSMetaMethod::Signal) { - code.rawAppendToCpp(u""); // blank line + code.rawAppendToCpp(u""_s); // blank line + if (method.comments.size() > 0) { + code.rawAppendToCpp(u"/*! \\internal"_s); + for (const auto &comment : method.comments) + code.rawAppendToCpp(comment, 1); + code.rawAppendToCpp(u"*/"_s); + } code.rawAppendToCpp(method.returnType); code.rawAppendSignatureToCpp(cppSignature); code.rawAppendToCpp(u"{"); diff --git a/tools/qmltc/qmltcoutputir.h b/tools/qmltc/qmltcoutputir.h index 6e49636980..46f8e46ee8 100644 --- a/tools/qmltc/qmltcoutputir.h +++ b/tools/qmltc/qmltcoutputir.h @@ -62,6 +62,7 @@ struct QmltcEnum struct QmltcMethodBase { + QStringList comments; // C++ comments QString name; // C++ function name QList<QmltcVariable> parameterList; // C++ function parameter list QStringList body; // C++ function code |