34 if (
x.removedIn.isValid())
35 return y.addedIn.isValid() ?
x.removedIn <=
y.addedIn :
true;
47 return !(
x <
y) && !(
y <
x);
60 fprintf(stderr,
"The @ option requires an input file");
65 fprintf(stderr,
"Cannot open options file specified with @");
82 if (processor.
types().isEmpty()) {
83 fprintf(stderr,
"Error: No types to register found in library\n");
86 QFile headerFile(baseName + u
".h");
89 fprintf(stderr,
"Error: Cannot open %s for writing\n",
qPrintable(headerFile.
fileName()));
95 "#include <QtQml/qqml.h>\n"
96 "#include <QtQml/qqmlmoduleregistration.h>\n").
arg(baseName.
toUpper());
98 for (
const QString &include: includes)
99 prefix += u
"\n#include <%1>"_s.arg(include);
102 QFile sourceFile(baseName + u
".cpp");
105 fprintf(stderr,
"Error: Cannot open %s for writing\n",
qPrintable(sourceFile.
fileName()));
109 QString code = u
"#include \"%1.h\"\n#include "_s.
arg(baseName);
110 code += uR
"("moc_%1.cpp")"_s.arg(baseName);
140 if (
r.addedIn.isValid()) {
141 s += u
" (added in %1.%2)"_s.
arg(
r.addedIn.majorVersion()).
arg(
r.addedIn.minorVersion());
143 if (
r.removedIn.isValid()) {
144 s += u
" (removed in %1.%2)"_s.
arg(
r.removedIn.majorVersion())
145 .
arg(
r.removedIn.minorVersion());
152 output << uR
"(/****************************************************************************
153** Generated QML type registration code
155** WARNING! All changes made in this file will be lost!
156*****************************************************************************/
160 output << u"#include <QtQml/qqml.h>\n"_s;
161 output << u
"#include <QtQml/qqmlmoduleregistration.h>\n"_s;
163 for (
const QString &include : m_includes)
164 output << u
"\n#include <%1>"_s.arg(include);
169 QString moduleAsSymbol = m_module;
173 QString underscoredModuleAsSymbol = m_module;
176 if (underscoredModuleAsSymbol != moduleAsSymbol
177 || underscoredModuleAsSymbol.
isEmpty()
179 qWarning() << m_module <<
"is an invalid QML module URI. You cannot import this.";
184#if !defined(QT_STATIC)
185#define Q_QMLTYPE_EXPORT Q_DECL_EXPORT
187#define Q_QMLTYPE_EXPORT
191 if (!m_targetNamespace.
isEmpty())
192 output << u
"namespace "_s << m_targetNamespace << u
" {\n"_s;
194 output << u
"Q_QMLTYPE_EXPORT void "_s << functionName << u
"()\n{"_s;
198 for (
const auto &version : m_pastMajorVersions) {
200 qmlRegisterModule("%1", %2, 0);
201 qmlRegisterModule("%1", %2, 254);)"_s.arg(m_module)
205 if (minorVersion != 0) {
207 qmlRegisterModule("%1", %2, 0);)"_s.arg(m_module)
214 for (
const QCborMap &classDef : m_types) {
219 bool seenQmlElement =
false;
229 seenQmlElement =
true;
230 qmlElementName =
v[
S_VALUE].toString();
244 if (seenQmlElement && qmlElementName !=
S_ANONYMOUS) {
245 if (qmlElementName ==
S_AUTO)
247 qmlElementInfos[qmlElementName].append({
className, addedIn, removedIn });
257 QString targetTypeName = targetName;
258 const auto targetIsNamespace = [&]() {
266 m_types, m_foreignTypes, targetName, namespaces);
280 if (targetIsNamespace()) {
283 Q_CONSTINIT static auto metaType = QQmlPrivate::metaTypeForNamespace(
284 [](const QtPrivate::QMetaTypeInterface *) {return &%1::staticMetaObject;},
286 QMetaType(&metaType).id();
287 })"_s.arg(targetName, targetTypeName);
289 output << u
"\n QMetaType::fromType<%1>().id();"_s.arg(targetTypeName);
298 result.append(staticMetaObject);
302 if (seenQmlElement) {
304 qmlRegisterNamespaceAndRevisions(%1, "%2", %3, nullptr, %4, %5);)"_s
305 .arg(metaObjectPointer(targetName), m_module)
309 : metaObjectPointer(extendedName));
312 if (seenQmlElement) {
315 auto object =
it->toMap();
321 if (m_moduleVersion < revision) {
323 <<
"Warning:" <<
className <<
"is trying to register" <<
type
324 <<
object[
S_NAME].toString()
325 <<
"with future version" << revision
326 <<
"when module version is only" << m_moduleVersion;
334 if (m_moduleVersion.
isValid()) {
340 qmlRegisterTypesAndRevisions<%1>("%2", %3);)"_s.arg(className, m_module).arg(majorVersion);
345 for (
const QCborValueRef
entry : superClasses.
toArray()) {
362 const auto typeAsMap =
type.toMap();
364 bool foundRevisionEntry =
false;
365 for (
const QCborValueRef
entry : typeAsMap[section].toArray()) {
367 foundRevisionEntry =
true;
371 if (foundRevisionEntry) {
377 if (m_followForeignVersioning) {
379 qmlRegisterAnonymousTypesAndRevisions<%1>("%2", %3);)"_s.arg(typeName.toString(), m_module)
384 for (
const auto &version : m_pastMajorVersions
385 +
decltype(m_pastMajorVersions){
388 qmlRegisterAnonymousType<%1, 254>("%2", %3);)"_s.arg(typeName.toString(), m_module)
399 for (
const QCborValueRef
entry : superClasses.
toArray()) {
408 checkForRevisions(superClassName);
410 while (!classesToCheck.
isEmpty())
411 checkForRevisions(classesToCheck.
takeFirst());
416 QMetaType::fromType<%1%2>().id();)"_s.arg(
422 for (
const auto [qmlName, exportsForSameQmlName] : qmlElementInfos.
asKeyValueRange()) {
425 if (exportsForSameQmlName.size() < 2)
429 std::sort(exportsForSameQmlName.begin(), exportsForSameQmlName.end());
430 auto conflictingExportStartIt = exportsForSameQmlName.cbegin();
433 conflictingExportStartIt =
434 std::adjacent_find(conflictingExportStartIt, exportsForSameQmlName.cend());
435 if (conflictingExportStartIt == exportsForSameQmlName.cend())
438 auto conflictingExportEndIt = std::find_if_not(
439 conflictingExportStartIt, exportsForSameQmlName.cend(),
440 [=](
const auto &
x) ->
bool { return x == *conflictingExportStartIt; });
441 QString registeringCppClasses = conflictingExportStartIt->claimerName;
442 std::for_each(std::next(conflictingExportStartIt), conflictingExportEndIt,
446 qWarning().noquote() <<
"Warning:" << qmlName
447 <<
"was registered multiple times by following Cpp classes: "
448 << registeringCppClasses;
449 conflictingExportStartIt = conflictingExportEndIt;
453 qmlRegisterModule("%1", %2, %3);
456static const QQmlModuleRegistration registration("%1", %4);
462 if (!m_targetNamespace.
isEmpty())
463 output << u
"} // namespace %1\n"_s.arg(m_targetNamespace);
470 creator.setForeignTypes(m_foreignTypes);
471 creator.setReferencedTypes(m_referencedTypes);
475 return creator.generate(pluginTypesFile);
479 const QString &targetNamespace)
482 m_targetNamespace = targetNamespace;
486 bool followForeignVersioning)
488 m_moduleVersion = moduleVersion;
489 m_pastMajorVersions = pastMajorVersions;
490 m_followForeignVersioning = followForeignVersioning;
494 m_includes = includes;
500 m_foreignTypes = foreignTypes;
504 m_referencedTypes = referencedTypes;
static JNINativeMethod methods[]
constexpr bool isEmpty() const noexcept
Returns whether this string view is empty - that is, whether {size() == 0}.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
QCborArray toArray() const
bool isArray() const
Returns true if this QCborValue is of the array type.
constexpr bool isDigit() const noexcept
Returns true if the character is a decimal digit (Number_DecimalDigit); otherwise returns false.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
QString fileName() const override
Returns the name set by setFileName() or to the QFile constructors.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
constexpr qsizetype length() const noexcept
qsizetype size() const noexcept
bool isEmpty() const noexcept
void append(parameter_type t)
\inmodule QtCore \reentrant
const_iterator constBegin() const noexcept
const_iterator constEnd() const noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString & replace(qsizetype i, qsizetype len, QChar after)
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
QByteArray toUtf8() const &
QString toUpper() const &
static constexpr QTypeRevision fromVersion(Major majorVersion, Minor minorVersion)
Produces a QTypeRevision from the given majorVersion and minorVersion, both of which need to be a val...
static constexpr QTypeRevision fromEncodedVersion(Integer value)
Produces a QTypeRevision from the given value.
constexpr quint8 minorVersion() const
Returns the minor version encoded in the revision.
constexpr bool isValid() const
Returns true if the major version or the minor version is known, otherwise false.
constexpr quint8 majorVersion() const
Returns the major version encoded in the revision.
void setModuleNameAndNamespace(const QString &module, const QString &targetNamespace)
void setTypes(const QVector< QCborMap > &types, const QVector< QCborMap > &foreignTypes)
static bool argumentsFromCommandLineAndFile(QStringList &allArguments, const QStringList &arguments)
void setIncludes(const QList< QString > &includes)
void write(QTextStream &os)
void setModuleVersions(QTypeRevision moduleVersion, const QList< quint8 > &pastMajorVersions, bool followForeignVersioning)
bool generatePluginTypes(const QString &pluginTypesFile)
void setReferencedTypes(const QList< QAnyStringView > &referencedTypes)
static int runExtract(const QString &baseName, const MetaTypesJsonProcessor &processor)
QSet< QString >::iterator it
QList< QVariant > arguments
QAnyStringView toStringView(const QCborValue &value)
Combined button and popup list for selecting options.
static const QCssKnownValue properties[NumProperties - 1]
static bool contains(const QJsonArray &haystack, unsigned needle)
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLsizei GLenum GLenum * types
GLdouble GLdouble GLdouble GLdouble q
bool operator<(const ExclusiveVersionRange &x, const ExclusiveVersionRange &y)
True if x was removed before y was introduced.
QString conflictingVersionToString(const ExclusiveVersionRange &r)
bool operator==(const ExclusiveVersionRange &x, const ExclusiveVersionRange &y)
True when x and y share a common version.
#define qPrintable(string)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
static int toInt(const QChar &qc, int R)
QT_BEGIN_NAMESPACE typedef uchar * output
const char className[16]
[1]
QFileInfo info(fileName)
[8]
QItemEditorCreatorBase * creator
\inmodule QtCore \reentrant
bool contains(const AT &t) const noexcept
static const QCborMap * findType(const QVector< QCborMap > &types, const QVector< QCborMap > &foreign, const QAnyStringView &name, const QList< QAnyStringView > &namespaces)