10#include <QtCore/qset.h>
11#include <QtCore/qcborarray.h>
12#include <QtCore/qcbormap.h>
13#include <QtCore/qsavefile.h>
14#include <QtCore/qfile.h>
15#include <QtCore/qversionnumber.h>
17#include <QtCore/private/qstringalgorithms_p.h>
32 return s.toString().replace(
"::d_func()"_L1,
"Private"_L1);
69 <<
"JavaScript extension type for" << collector.
className
75 <<
"Extension type for" << collector.
className
76 <<
"cannot be both a JavaScript type and a namespace";
88 <<
"Extension namespace for" << collector.
className <<
"does not exist";
105 warning(collector.
file) <<
"Ignoring names of sequential container:";
109 <<
"Sequential containers are anonymous. Use QML_ANONYMOUS to register them.";
125 for (
const QAnyStringView &elementName :
std::as_const(collector.elementNames)) {
128 elementName.visit([&](
auto view) {
133 : m_version.majorVersion());
136 exports.append(exportEntry);
141 QList<QAnyStringView> exportStrings;
142 exportStrings.reserve(exports.length());
167 if (resolved.type.isEmpty())
173 if (resolved.isPointer)
175 if (resolved.isConstant)
179void QmlTypesCreator::writeProperties(
const Property::Container &
properties)
185 if (
obj.revision.isValid())
190 const auto bindable =
obj.bindable;
191 if (!bindable.isEmpty())
197 if (!
write.isEmpty())
200 if (!
reset.isEmpty())
202 const auto notify =
obj.notify;
203 if (!notify.isEmpty())
209 const auto privateClass =
obj.privateClass;
210 if (!privateClass.isEmpty()) {
215 if (
obj.write.isEmpty() &&
obj.member.isEmpty())
238 const auto revision =
obj.revision;
243 writeType(
obj.returnType);
247 if (
obj.isConstructor)
249 if (
obj.isJavaScriptFunction)
266void QmlTypesCreator::writeEnums(
267 const Enum::Container &enums, QmlTypesCreator::EnumClassesMode enumClassesMode)
269 for (
const Enum &
obj : enums) {
272 if (!
obj.alias.isEmpty())
277 if (enumClassesMode == EnumClassesMode::Scoped) {
288template<
typename Member>
293 || memberRevision.majorVersion() <= maxMajorVersion.majorVersion();
296template<
typename Members,
typename Postprocess>
299 Members classDefMembers;
301 for (
const auto &member : candidates) {
303 classDefMembers.push_back(process(member));
306 return classDefMembers;
309template<
typename Members>
312 return members(candidates, maxMajorVersion, [](
const auto &member) {
return member; });
315template<
typename Members>
318 return members(candidates, maxMajorVersion, [](
const auto &member) {
320 ctor.isConstructor =
true;
325void QmlTypesCreator::writeRootMethods(
const MetaType &classDef)
329 for (
auto it = componentSignals.
begin();
it != componentSignals.
end();) {
330 if (
it->name ==
"destroyed"_L1)
335 writeMethods(componentSignals,
S_SIGNAL);
339 for (
auto it = componentMethods.
begin();
it != componentMethods.
end();) {
340 if (
it->name ==
"deleteLater"_L1)
348 toStringMethod.
name =
"toString"_L1;
350 toStringMethod.returnType =
"QString"_L1;
351 componentMethods.push_back(std::move(toStringMethod));
354 Method destroyMethodWithArgument;
355 destroyMethodWithArgument.
name =
"destroy"_L1;
358 delayArgument.
name =
"delay"_L1;
359 delayArgument.type =
"int"_L1;
360 destroyMethodWithArgument.arguments.push_back(std::move(delayArgument));
361 componentMethods.push_back(std::move(destroyMethodWithArgument));
365 destroyMethod.
name =
"destroy"_L1;
367 destroyMethod.isCloned =
true;
368 componentMethods.push_back(std::move(destroyMethod));
370 writeMethods(componentMethods,
S_METHOD);
377 writeClassProperties(collector);
383 ? EnumClassesMode::Scoped
384 : EnumClassesMode::Unscoped);
386 writeProperties(
members(classDef.properties(), m_version));
389 writeRootMethods(classDef);
400void QmlTypesCreator::writeComponents()
407 writeComponent(collector);
410 && std::binary_search(
411 m_referencedTypes.
begin(), m_referencedTypes.
end(),
422 writeComponent(collector);
432 "\n// This file describes the plugin-supplied types contained in the library."
433 "\n// It is used for QML tooling purposes only."
435 "\n// This file was auto-generated by qmltyperegistrar.\n\n");
442 QSaveFile
file(outFileName);
449 return file.commit();
static JNINativeMethod methods[]
constexpr QChar back() const
Returns the last character in the string view.
constexpr bool isEmpty() const noexcept
Returns whether this string view is empty - that is, whether {size() == 0}.
constexpr QAnyStringView chopped(qsizetype n) const
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
static QByteArray number(int, int base=10)
Returns a byte-array representing the whole number n as text.
QFILE_MAYBE_NODISCARD bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
qsizetype size() const noexcept
bool isEmpty() const noexcept
void writeStringListBinding(QByteArrayView name, const QList< QAnyStringView > &elements)
void write(QByteArrayView data)
void writeLibraryImport(QByteArrayView uri, int majorVersion, int minorVersion, QByteArrayView as={})
void writeArrayBinding(QByteArrayView name, const QByteArrayList &elements)
void writeStartDocument()
void writeStartObject(QByteArrayView component)
void writeBooleanBinding(QByteArrayView name, bool value)
void writeStringBinding(QByteArrayView name, QAnyStringView value)
void writeNumberBinding(QByteArrayView name, qint64 value)
iterator erase(const_iterator i)
\macro QT_RESTRICTED_CAST_FROM_ASCII
constexpr bool hasMajorVersion() const
Returns true if the major version is known, otherwise false.
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 Integer toEncodedVersion() const
Transforms the revision into an integer value, encoding the minor version into the least significant ...
constexpr quint8 majorVersion() const
Returns the major version encoded in the revision.
bool generate(const QString &outFileName)
list append(new Employee("Blackpool", "Stephen"))
QSet< QString >::iterator it
QList< QVariant > arguments
static constexpr QLatin1StringView S_FILE
static constexpr QLatin1StringView S_EXTENSION_IS_JAVA_SCRIPT
static constexpr QLatin1StringView S_NOTIFY
static constexpr QLatin1StringView S_SIGNAL
static constexpr QLatin1StringView S_IS_SINGLETON
static constexpr QLatin1StringView S_IS_CONSTRUCTOR
static constexpr QLatin1StringView S_ACCESS_SEMANTICS
static constexpr QLatin1StringView S_IS_READONLY
static constexpr QLatin1StringView S_ENUM
static constexpr QLatin1StringView S_READ
static constexpr QLatin1StringView S_VALUE_TYPE
static constexpr QLatin1StringView S_PROPERTY
static constexpr QLatin1StringView S_INDEX
static constexpr QLatin1StringView S_IS_CREATABLE
static constexpr QLatin1StringView S_RESET
static constexpr QLatin1StringView S_TYPE
static constexpr QLatin1StringView S_MODULE
static constexpr QLatin1StringView S_PARAMETER
static constexpr QLatin1StringView S_IS_LIST
static constexpr QLatin1StringView S_IS_CLONED
static constexpr QLatin1StringView S_IS_REQUIRED
static constexpr QLatin1StringView S_IMMEDIATE_NAMES
static constexpr QLatin1StringView S_WRITE
static constexpr QLatin1StringView S_IS_JAVASCRIPT_FUNCTION
static constexpr QLatin1StringView S_EXPORTS
static constexpr QLatin1StringView S_REVISION
static constexpr QLatin1StringView S_DEFAULT_PROPERTY
static constexpr QLatin1StringView S_DEFERRED_NAMES
static constexpr QLatin1StringView S_METHOD
static constexpr QLatin1StringView S_IS_POINTER
static constexpr QLatin1StringView S_ALIAS
static constexpr QLatin1StringView S_VALUES
static constexpr QLatin1StringView S_IS_FLAG
static constexpr QLatin1StringView S_ALIASES
static constexpr QLatin1StringView S_COMPONENT
static constexpr QLatin1StringView S_PROTOTYPE
static constexpr QLatin1StringView S_EXPORT_META_OBJECT_REVISIONS
static constexpr QLatin1StringView S_ATTACHED_TYPE
static constexpr QLatin1StringView S_IS_FINAL
static constexpr QLatin1StringView S_HAS_CUSTOM_PARSER
static constexpr QLatin1StringView S_PARENT_PROPERTY
static constexpr QLatin1StringView S_IS_CONSTANT
static constexpr QLatin1StringView S_PRIVATE_CLASS
static constexpr QLatin1StringView S_EXTENSION_IS_NAMESPACE
static constexpr QLatin1StringView S_IS_SCOPED
static constexpr QLatin1StringView S_BINDABLE
static constexpr QLatin1StringView S_EXTENSION
static constexpr QLatin1StringView S_IS_STRUCTURED
static constexpr QLatin1StringView S_NAME
static constexpr QLatin1StringView S_INTERFACES
auto processAsUtf8(StringView string, Handler &&handler)
Combined button and popup list for selecting options.
static const QCssKnownValue properties[NumProperties - 1]
static qreal component(const QPointF &point, unsigned int i)
QDebug warning(QAnyStringView fileName, int lineNumber)
Members members(const Members &candidates, QTypeRevision maxMajorVersion, Postprocess &&process)
bool isAllowedInMajorVersion(const Member &memberObject, QTypeRevision maxMajorVersion)
static QString convertPrivateClassToUsableForm(QAnyStringView s)
Members constructors(const Members &candidates, QTypeRevision maxMajorVersion)
ReturnedValue read(const char *data)
gzip write("uncompressed data")
char * toString(const MyType &t)
[31]
std::vector< Argument > Container
std::vector< Enum > Container
std::vector< Method > Container
QAnyStringView javaScriptExtensionType
QAnyStringView parentProp
QList< QAnyStringView > implementsInterfaces
QList< QAnyStringView > primitiveAliases
QTypeRevision addedInRevision
void collect(const MetaType &classDef, const QVector< MetaType > &types, const QVector< MetaType > &foreign, CollectMode mode, QTypeRevision defaultRevision)
QList< QAnyStringView > immediateNames
QAnyStringView sequenceValueType
QTypeRevision removedInRevision
QAnyStringView defaultProp
bool registerEnumClassesScoped
QList< QTypeRevision > revisions
bool extensionIsNamespace
QList< QAnyStringView > elementNames
QAnyStringView attachedType
bool extensionIsJavaScript
QList< QAnyStringView > deferredNames
void collectLocalAnonymous(const MetaType &classDef, const QVector< MetaType > &types, const QVector< MetaType > &foreign, QTypeRevision defaultRevision)
QAnyStringView accessSemantics
QAnyStringView superClass
QAnyStringView nativeExtensionType