4#include <QtQml/private/qjsvalue_p.h>
5#include <QtQml/private/qqmlglobal_p.h>
6#include <QtQml/private/qqmlmetatype_p.h>
7#include <QtQml/qqmlengine.h>
9#include <QtCore/private/qvariant_p.h>
10#include <QtCore/qcoreapplication.h>
11#include <QtCore/qdebug.h>
12#include <QtCore/qstringlist.h>
19 switch (metaType.
id()) {
22 case QMetaType::Nullptr:
26 case QMetaType::LongLong:
27 case QMetaType::ULongLong:
28 case QMetaType::Float:
29 case QMetaType::Double:
31 case QMetaType::ULong:
32 case QMetaType::Short:
33 case QMetaType::UShort:
35 case QMetaType::SChar:
36 case QMetaType::UChar:
37 case QMetaType::QChar:
38 case QMetaType::QString:
40 case QMetaType::QDateTime:
41 case QMetaType::QDate:
42 case QMetaType::QTime:
44 case QMetaType::QRegularExpression:
45 case QMetaType::QByteArray:
46 case QMetaType::QLocale:
53 if (metaType == QMetaType::fromType<QJSValue>())
57 if (metaType.
flags() &
86 return d->data.shared->data();
96template<
typename Allocate>
98 const QMetaObject *targetMetaObject,
int ctorIndex,
void *
source, Allocate &&allocate)
102 "Value type constructor must take exactly one argument");
107template<
typename Allocate,
typename Retrieve>
109 const QMetaObject *targetMetaObject, Allocate &&allocate, Retrieve &&retrieve)
118 if (retrieve(parameterType, [&](
QMetaType sourceMetaType,
void *sourceData) {
119 if (sourceMetaType == parameterType) {
126 sourceMetaObject && sourceMetaObject->inherits(parameterMetaObject)) {
152template<
typename Allocate>
157 targetMetaObject, std::forward<Allocate>(allocate),
158 [&](
QMetaType parameterType,
auto callback) {
164template<
typename Allocate>
174template<
typename Allocate>
177 for (
int i = 0,
end =
mo->constructorCount();
i <
end; ++
i) {
191template<
typename Get,
typename Convert>
197 if (
property.metaType() == propertyType) {
210 propertyType, converted.
data())) {
247 if (
property.metaType() == propertyType) {
260 propertyType, converted.
data())) {
266 <<
QLatin1String(
"Could not convert %1 to %2 for property %3")
275 if (!
source.isObject() || !targetMetaObject)
283template<
typename Read>
295 if (sourceProperty == -1)
299 QVariant property =
read(sourceMetaObject, sourceProperty);
300 if (
property.metaType() == propertyType) {
313 propertyType, converted.
data())) {
319 <<
QLatin1String(
"Could not convert %1 to %2 for property %3")
331 return sourceMetaObject->property(sourceProperty).read(source);
338 if (!
source || !targetMetaObject)
350 if (!
source || !sourceMetaObject || !targetMetaObject)
355 targetMetaObject,
result.data(), sourceMetaObject,
357 return sourceMetaObject->property(sourceProperty).readOnGadget(source);
362template<
typename Map>
376 if (
property.metaType() == propertyType) {
389 propertyType, converted.
data())) {
395 <<
QLatin1String(
"Could not convert %1 to %2 for property %3")
401template<
typename Map>
413 if (!targetMetaObject)
416 if (
source.metaType() == QMetaType::fromType<QJSValue>()) {
422 if (
source.metaType() == QMetaType::fromType<QVariantMap>()) {
424 targetMetaObject, targetMetaType,
428 if (
source.metaType() == QMetaType::fromType<QVariantHash>()) {
430 targetMetaObject, targetMetaType,
438 return byProperties(targetMetaObject, targetMetaType, sourceMeta,
source.constData());
443template<
typename Allocate,
typename DefaultConstruct>
446 Allocate &&allocate, DefaultConstruct &&defaultConstruct)
449 const auto warn = [&]() {
451 <<
"Could not find any constructor for value type"
452 << targetMetaObject->className() <<
"to call with value"
453 <<
source.toQStringNoThrow();
457 if (
source.isObject() && targetMetaObject) {
478 if (resultType == targetType.
typeId()) {
487template<
typename Allocate,
typename DefaultConstruct>
490 Allocate &&allocate, DefaultConstruct &&defaultConstruct)
493 const auto warn = [&]() {
495 <<
"Could not find any constructor for value type"
496 << targetMetaObject->className() <<
"to call with value" <<
source;
504 targetMetaObject, defaultConstruct(), sourceMetaObject,
506 return sourceMetaObject->
property(sourceProperty).readOnGadget(
source);
511 if (sourceMetaType == QMetaType::fromType<QVariantMap>()) {
513 targetMetaObject, defaultConstruct(),
518 if (sourceMetaType == QMetaType::fromType<QVariantHash>()) {
520 targetMetaObject, defaultConstruct(),
527 targetMetaObject, defaultConstruct(),
536 return callback(sourceMetaType,
source);
558 if (sourceMetaType == QMetaType::fromType<QJSValue>()) {
569 [targetMetaType,
target]() {
609 targetType,
source, [&]() {
612 target = align > __STDCPP_DEFAULT_NEW_ALIGNMENT__
613 ?
operator new(metaType.
sizeOf(), std::align_val_t(align))
614 :
operator new(metaType.
sizeOf());
628 int ctorIndex,
void *ctorArg)
638 if (
const auto valueTypeFunction =
type.createValueTypeFunction()) {
640 if (
result.metaType() == metaType)
660 if (
mo &&
type.canConstructValueType()) {
675 const auto warn = [&]() {
677 <<
"Could not find any constructor for value type"
678 <<
mo->className() <<
"to call with value" <<
s.toQStringNoThrow();
681 if (
type.canPopulateValueType()) {
685 if (
type.canConstructValueType()) {
690 }
else if (
type.canConstructValueType()) {
712 const auto warn = [&]() {
714 <<
"Could not find any constructor for value type"
715 <<
mo->className() <<
"to call with value" <<
s;
718 if (
type.canPopulateValueType()) {
722 if (
type.canConstructValueType()) {
727 }
else if (
type.canConstructValueType()) {
764 qWarning() <<
"Warning: QQml_colorProvider: no color provider has been set!";
916 return (ddata && ddata->propertyCache) ? ddata :
nullptr;
923 return ddata->propertyCache->firstCppMetaObject()->inherits(
mo);
924 return object->metaObject()->inherits(
mo);
938 for (
const QQmlPropertyCache *propertyCache = ddata->propertyCache.data(); propertyCache;
939 propertyCache = propertyCache->parent().data()) {
941 if (typeMetaObject) {
948 if (
const QMetaObject *objectMetaObject = propertyCache->metaObject())
949 return objectMetaObject->inherits(typeMetaObject);
955 if (propertyCache == typePropertyCache.
data())
963 return object->metaObject()->inherits(typeMetaObject
965 : (typePropertyCache ? typePropertyCache->createMetaObject() :
nullptr));
970#include "moc_qqmlglobal_p.cpp"
static void setOrganizationDomain(const QString &orgDomain)
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
QString applicationVersion
the version of this application
QString organizationName
the name of the organization that wrote this application
static void setOrganizationName(const QString &orgName)
[11]
static void setApplicationName(const QString &application)
static void setApplicationVersion(const QString &version)
static QStringList arguments()
QString applicationName
the name of this application
QString organizationDomain
the Internet domain of the organization that wrote this application
static void setObjectOwnership(QObject *, ObjectOwnership)
Sets the ownership of object.
static QJSValue fromReturnedValue(QV4::ReturnedValue d)
static QV4::ReturnedValue asReturnedValue(const QJSValue *jsval)
The QJSValue class acts as a container for Qt/JavaScript data types.
QString arg(Args &&...args) const
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void setDomain(const QString &arg)
void setOrganization(const QString &arg)
void setVersion(const QString &arg)
void setName(const QString &arg)
void organizationChanged()
QQmlApplication(QObject *parent=nullptr)
virtual QVariant colorFromString(const QString &, bool *)
virtual QVariant lighter(const QVariant &, qreal)
virtual QVariant tint(const QVariant &, const QVariant &)
virtual QVariant fromRgbF(double, double, double, double)
virtual unsigned rgbaFromString(const QString &, bool *)
virtual QVariant fromHsvF(double, double, double, double)
virtual QVariant fromHslF(double, double, double, double)
virtual ~QQmlColorProvider()
virtual QVariant darker(const QVariant &, qreal)
virtual QVariant alpha(const QVariant &, qreal)
static QQmlData * get(QObjectPrivate *priv, bool create)
virtual ~QQmlGuiProvider()
virtual bool openUrlExternally(const QUrl &)
virtual QStringList fontFamilies()
virtual QQmlApplication * application(QObject *parent)
virtual QObject * styleHints()
virtual QString pluginName() const
virtual QObject * inputMethod()
bool canPopulateValueType() const
CreateValueTypeFunc createValueTypeFunction() const
bool canConstructValueType() const
static bool populateValueType(QMetaType targetMetaType, void *target, const QV4::Value &source)
static Q_QML_PRIVATE_EXPORT void * heapCreateValueType(const QQmlType &targetType, const QV4::Value &source)
static QVariant constructValueType(QMetaType targetMetaType, const QMetaObject *targetMetaObject, int ctorIndex, void *ctorArg)
static QVariant createValueType(const QJSValue &, QMetaType)
const_iterator constEnd() const noexcept
const_iterator constFind(const T &value) const
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void * data()
Returns a pointer to the contained object as a generic void* that can be written to.
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
QMetaType metaType() const
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static QDBusError::ErrorType get(const char *name)
GLsizei GLsizei GLchar * source
static QQmlGuiProvider ** getGuiProvider(void)
Q_AUTOTEST_EXPORT QQmlGuiProvider * QQml_guiProvider(void)
static void callConstructor(const QMetaObject *targetMetaObject, int i, void *source, void *target)
static QQmlGuiProvider * guiProvider
static void fromVerifiedType(const QMetaObject *targetMetaObject, int ctorIndex, void *source, Allocate &&allocate)
Q_QML_PRIVATE_EXPORT QQmlColorProvider * QQml_setColorProvider(QQmlColorProvider *newProvider)
static void doWriteProperties(const QMetaObject *targetMetaObject, void *target, const QV4::Value &source)
static QVariant fromJSValue(const QQmlType &type, const QJSValue &s, QMetaType metaType)
static bool doWriteProperty(const QMetaProperty &metaProperty, void *target, Get &&get, Convert &&convert)
static bool fromString(const QMetaObject *mo, QString s, Allocate &&allocate)
static QQmlColorProvider * colorProvider
static QVariant byProperties(const QMetaObject *targetMetaObject, QMetaType metaType, const QV4::Value &source)
Q_QML_PRIVATE_EXPORT QQmlGuiProvider * QQml_setGuiProvider(QQmlGuiProvider *newProvider)
Q_AUTOTEST_EXPORT QQmlColorProvider * QQml_colorProvider(void)
static QQmlColorProvider ** getColorProvider(void)
static bool fromMatchingType(const QMetaObject *targetMetaObject, Allocate &&allocate, Retrieve &&retrieve)
bool qmlobject_can_cpp_cast(QObject *object, const QMetaObject *mo)
static const QQmlData * ddata_for_cast(QObject *object)
bool qmlobject_can_qml_cast(QObject *object, const QQmlType &type)
bool createOrConstructValueType(const QQmlType &targetType, const QV4::Value &source, Allocate &&allocate, DefaultConstruct &&defaultConstruct)
static void * createVariantData(QMetaType type, QVariant *variant)
static QT_BEGIN_NAMESPACE bool isConstructibleMetaType(const QMetaType metaType)
#define Q_ASSERT_X(cond, x, msg)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
#define Q_AUTOTEST_EXPORT
ReturnedValue read(const char *data)
Heap::String * newString(const QString &s=QString())
static QVariant toVariant(const QV4::Value &value, QMetaType typeHint, bool createJSValueForObjectsAndSymbols=true)
QString toQStringNoThrow() const
static PrivateShared * create(size_t size, size_t align)
static constexpr bool canUseInternalSpace(const QtPrivate::QMetaTypeInterface *type)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent