Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqml.cpp
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qqml.h"
5
6#include <QtQml/qqmlprivate.h>
7
8#include <private/qjsvalue_p.h>
9#include <private/qqmlengine_p.h>
10#include <private/qqmlmetatype_p.h>
11#include <private/qqmlmetatypedata_p.h>
12#include <private/qqmltype_p_p.h>
13#include <private/qqmltypemodule_p.h>
14#include <private/qqmlcomponent_p.h>
15#include <private/qqmltypewrapper_p.h>
16#include <private/qqmlvaluetypewrapper_p.h>
17#include <private/qv4lookup_p.h>
18#include <private/qv4qobjectwrapper_p.h>
19#include <private/qv4identifiertable_p.h>
20#include <private/qv4errorobject_p.h>
21#include <private/qqmlbuiltinfunctions_p.h>
22#include <private/qqmlfinalizer_p.h>
23#include <private/qqmlloggingcategory_p.h>
24
25#include <QtCore/qmutex.h>
26
28
31
49{
50 QQmlData *data = QQmlData::get(object);
51
52 if (!data
53 || !data->context
54 || !data->context->engine()
55 || data->deferredData.isEmpty()
56 || data->wasDeleted(object)) {
57 return;
58 }
59
60 QQmlEnginePrivate *ep = QQmlEnginePrivate::get(data->context->engine());
61
64
65 // Release the reference for the deferral action (we still have one from construction)
66 data->releaseDeferredData();
67
69}
70
72{
74}
75
77{
79 if (!data || !data->context)
80 return nullptr;
81 return data->context->engine();
82}
83
85 QObject *object, bool create)
86{
87 if (!pf)
88 return nullptr;
89
90 QObject *rv = data->hasExtendedData() ? data->attachedProperties()->value(pf) : 0;
91 if (rv || !create)
92 return rv;
93
94 rv = pf(object);
95
96 if (rv)
97 data->attachedProperties()->insert(pf, rv);
98
99 return rv;
100}
101
103 const QMetaObject *attachedMetaObject)
104{
105 QQmlEngine *engine = object ? qmlEngine(object) : nullptr;
107 attachedMetaObject);
108}
109
111{
112 if (!object)
113 return nullptr;
114
115 QQmlData *data = QQmlData::get(object, create);
116
117 // Attached properties are only on objects created by QML,
118 // unless explicitly requested (create==true)
119 if (!data)
120 return nullptr;
121
122 return resolveAttachedProperties(func, data, object, create);
123}
124
126{
127 return QQmlPrivate::qmlExtendedObject(object, 0);
128}
129
131{
132 if (!object)
133 return nullptr;
134
135 void *result = nullptr;
137 if (!d->metaObject)
138 return nullptr;
139
140 const int id = d->metaObject->metaCall(
144 return nullptr;
145
146 return static_cast<QObject *>(result);
147}
148
151{
152 switch (warning) {
154 qWarning().nospace()
155 << metaType.name()
156 << " is neither a default constructible QObject, nor a default- "
157 << "and copy-constructible Q_GADGET, nor marked as uncreatable.\n"
158 << "You should not use it as a QML type.";
159 break;
161 qWarning()
162 << "Singleton" << metaType.name()
163 << "needs either a default constructor or, when adding a default"
164 << "constructor is infeasible, a public static"
165 << "create(QQmlEngine *, QJSEngine *) method.";
166 break;
168 qWarning()
169 << metaType.name()
170 << "is not a QObject, but has attached properties. This won't work.";
171 break;
172 }
173}
174
176 const char *uri, int versionMajor,
177 int versionMinor, const char *qmlName,
178 const QString& reason)
179{
182 QMetaType(),
183 QMetaType(),
184 0,
185 nullptr,
186 nullptr,
187 reason,
188 nullptr,
189
190 uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName, &staticMetaObject,
191
193 nullptr,
194
195 -1,
196 -1,
197 -1,
198
199 nullptr, nullptr,
200
201 nullptr,
203 -1,
205 };
206
208}
209
210void qmlClearTypeRegistrations() // Declared in qqml.h
211{
213 QQmlEnginePrivate::baseModulesUninitialized = true; //So the engine re-registers its types
215}
216
217//From qqml.h
218bool qmlProtectModule(const char *uri, int majVersion)
219{
222}
223
224//From qqml.h
225void qmlRegisterModule(const char *uri, int versionMajor, int versionMinor)
226{
227 QQmlMetaType::registerModule(uri, QTypeRevision::fromVersion(versionMajor, versionMinor));
228}
229
230static QQmlDirParser::Import resolveImport(const QString &uri, int importMajor, int importMinor)
231{
232 if (importMajor == QQmlModuleImportAuto)
234 else if (importMajor == QQmlModuleImportLatest)
236 else if (importMinor == QQmlModuleImportLatest)
239}
240
241static QTypeRevision resolveModuleVersion(int moduleMajor)
242{
243 return moduleMajor == QQmlModuleImportModuleAny
244 ? QTypeRevision()
245 : QTypeRevision::fromMajorVersion(moduleMajor);
246}
247
308void qmlRegisterModuleImport(const char *uri, int moduleMajor,
309 const char *import, int importMajor, int importMinor)
310{
312 QString::fromUtf8(uri), resolveModuleVersion(moduleMajor),
313 resolveImport(QString::fromUtf8(import), importMajor, importMinor));
314}
315
316
328void qmlUnregisterModuleImport(const char *uri, int moduleMajor,
329 const char *import, int importMajor, int importMinor)
330{
332 QString::fromUtf8(uri), resolveModuleVersion(moduleMajor),
333 resolveImport(QString::fromUtf8(import), importMajor, importMinor));
334}
335
336//From qqml.h
337int qmlTypeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
338{
339 return QQmlMetaType::typeId(uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName);
340}
341
343{
344 if (!instance) {
346 error.setDescription(QStringLiteral("The registered singleton has already been deleted. "
347 "Ensure that it outlives the engine."));
349 return false;
350 }
351
352 if (engine->thread() != instance->thread()) {
354 error.setDescription(QStringLiteral("Registered object must live in the same thread "
355 "as the engine it was registered with"));
357 return false;
358 }
359
360 return true;
361}
362
363// From qqmlprivate.h
364#if QT_DEPRECATED_SINCE(6, 3)
365QObject *QQmlPrivate::SingletonFunctor::operator()(QQmlEngine *qeng, QJSEngine *)
366{
367 if (!checkSingletonInstance(qeng, m_object))
368 return nullptr;
369
370 if (alreadyCalled) {
372 error.setDescription(QStringLiteral("Singleton registered by registerSingletonInstance "
373 "must only be accessed from one engine"));
375 return nullptr;
376 }
377
378 alreadyCalled = true;
380 return m_object;
381};
382#endif
383
385{
387 return nullptr;
388
389 if (!m_engine) {
390 m_engine = qeng;
392 } else if (m_engine != qeng) {
394 error.setDescription(QLatin1String("Singleton registered by registerSingletonInstance must only be accessed from one engine"));
396 return nullptr;
397 }
398
399 return m_object;
400};
401
403{
404 QVector<QTypeRevision> revisions;
405 if (!metaObject)
406 return revisions;
407 const int propertyOffset = metaObject->propertyOffset();
408 const int propertyCount = metaObject->propertyCount();
409 for (int coreIndex = propertyOffset, propertyEnd = propertyOffset + propertyCount;
410 coreIndex < propertyEnd; ++coreIndex) {
411 const QMetaProperty property = metaObject->property(coreIndex);
412 if (int revision = property.revision())
413 revisions.append(QTypeRevision::fromEncodedVersion(revision));
414 }
415 const int methodOffset = metaObject->methodOffset();
416 const int methodCount = metaObject->methodCount();
417 for (int methodIndex = methodOffset, methodEnd = methodOffset + methodCount;
418 methodIndex < methodEnd; ++methodIndex) {
419 const QMetaMethod method = metaObject->method(methodIndex);
420 if (int revision = method.revision())
421 revisions.append(QTypeRevision::fromEncodedVersion(revision));
422 }
423
424 // Need to also check parent meta objects, as their revisions are inherited.
425 if (const QMetaObject *superMeta = metaObject->superClass())
426 revisions += availableRevisions(superMeta);
427
428 return revisions;
429}
430
431template<typename Registration>
432void assignVersions(Registration *registration, QTypeRevision revision,
433 QTypeRevision defaultVersion)
434{
435 const quint8 majorVersion = revision.hasMajorVersion() ? revision.majorVersion()
436 : defaultVersion.majorVersion();
437 registration->version = revision.hasMinorVersion()
438 ? QTypeRevision::fromVersion(majorVersion, revision.minorVersion())
439 : QTypeRevision::fromMajorVersion(majorVersion);
440 registration->revision = revision;
441}
442
444{
445 auto revisions = availableRevisions(metaObject);
446 revisions.append(added);
447 return revisions;
448}
449
450static void uniqueRevisions(QVector<QTypeRevision> *revisions, QTypeRevision defaultVersion,
451 QTypeRevision added)
452{
453 bool revisionsHaveMajorVersions = false;
454 for (QTypeRevision revision : QVector<QTypeRevision>(*revisions)) { // yes, copy
455 // allow any minor version for each explicitly specified past major one
456 if (revision.hasMajorVersion()) {
457 revisionsHaveMajorVersions = true;
458 if (revision.majorVersion() < defaultVersion.majorVersion())
459 revisions->append(QTypeRevision::fromVersion(revision.majorVersion(), 254));
460 }
461 }
462
463 if (revisionsHaveMajorVersions) {
464 if (!added.hasMajorVersion()) {
465 // If added in unspecified major version, assume default one.
466 revisions->append(QTypeRevision::fromVersion(defaultVersion.majorVersion(),
467 added.minorVersion()));
468 } else if (added.majorVersion() < defaultVersion.majorVersion()) {
469 // If added in past major version, add .0 of default version.
470 revisions->append(QTypeRevision::fromVersion(defaultVersion.majorVersion(), 0));
471 }
472 }
473
474 std::sort(revisions->begin(), revisions->end());
475 const auto it = std::unique(revisions->begin(), revisions->end());
476 revisions->erase(it, revisions->end());
477}
478
479/*
480This method is "over generalized" to allow us to (potentially) register more types of things in
481the future without adding exported symbols.
482*/
484{
485 QQmlType dtype;
486 switch (type) {
489 *reinterpret_cast<RegisterAutoParent *>(data));
492 *reinterpret_cast<RegisterQmlUnitCacheHook *>(data));
494 const RegisterTypeAndRevisions &type = *reinterpret_cast<RegisterTypeAndRevisions *>(data);
495 const char *elementName = (type.structVersion > 1 && type.forceAnonymous)
496 ? nullptr
497 : classElementName(type.classInfoMetaObject);
498 const bool isValueType = !(type.typeId.flags() & QMetaType::PointerToQObject);
499 const bool creatable = (elementName != nullptr || isValueType)
500 && boolClassInfo(type.classInfoMetaObject, "QML.Creatable", true);
501
502 QString noCreateReason;
504
505 if (!creatable) {
506 noCreateReason = QString::fromUtf8(
507 classInfo(type.classInfoMetaObject, "QML.UncreatableReason"));
508 if (noCreateReason.isEmpty())
509 noCreateReason = QLatin1String("Type cannot be created in QML.");
510 } else if (isValueType) {
511 const char *method = classInfo(type.classInfoMetaObject, "QML.CreationMethod");
512 if (qstrcmp(method, "structured") == 0)
514 else if (qstrcmp(method, "construct") == 0)
515 creationMethod = ValueTypeCreationMethod::Construct;
516 }
517
518 RegisterType typeRevision = {
520 type.typeId,
521 type.listId,
522 creatable ? type.objectSize : 0,
523 nullptr,
524 nullptr,
525 noCreateReason,
526 type.createValueType,
527 type.uri,
528 type.version,
529 nullptr,
530 type.metaObject,
531 type.attachedPropertiesFunction,
532 type.attachedPropertiesMetaObject,
533 type.parserStatusCast,
534 type.valueSourceCast,
535 type.valueInterceptorCast,
536 type.extensionObjectCreate,
537 type.extensionMetaObject,
538 nullptr,
540 type.structVersion > 0 ? type.finalizerCast : -1,
541 creationMethod
542 };
543
545 0,
546 type.uri,
547 type.version,
548 nullptr,
549 type.listId,
550 type.structVersion > 1 ? type.listMetaSequence : QMetaSequence(),
552 };
553
554 const QTypeRevision added = revisionClassInfo(
555 type.classInfoMetaObject, "QML.AddedInVersion",
556 QTypeRevision::fromVersion(type.version.majorVersion(), 0));
557 const QTypeRevision removed = revisionClassInfo(
558 type.classInfoMetaObject, "QML.RemovedInVersion");
559 const QList<QTypeRevision> furtherRevisions = revisionClassInfos(type.classInfoMetaObject,
560 "QML.ExtraVersion");
561
562 auto revisions = prepareRevisions(type.metaObject, added) + furtherRevisions;
563 if (type.attachedPropertiesMetaObject)
564 revisions += availableRevisions(type.attachedPropertiesMetaObject);
565 uniqueRevisions(&revisions, type.version, added);
566
567 for (QTypeRevision revision : revisions) {
568 if (revision.hasMajorVersion() && revision.majorVersion() > type.version.majorVersion())
569 break;
570
571 assignVersions(&typeRevision, revision, type.version);
572
573 // When removed or before added, we still add revisions, but anonymous ones
574 if (typeRevision.version < added
575 || (removed.isValid() && !(typeRevision.version < removed))) {
576 typeRevision.elementName = nullptr;
577 typeRevision.create = nullptr;
578 typeRevision.userdata = nullptr;
579 } else {
580 typeRevision.elementName = elementName;
581 typeRevision.create = creatable ? type.create : nullptr;
582 typeRevision.userdata = type.userdata;
583 }
584
585 typeRevision.customParser = type.customParserFactory();
586 const int id = qmlregister(TypeRegistration, &typeRevision);
587 if (type.qmlTypeIds)
588 type.qmlTypeIds->append(id);
589
590 if (sequenceRevision.metaSequence != QMetaSequence()) {
591 sequenceRevision.version = typeRevision.version;
592 sequenceRevision.revision = typeRevision.revision;
593 const int id = QQmlPrivate::qmlregister(
595 if (type.qmlTypeIds)
596 type.qmlTypeIds->append(id);
597 }
598 }
599 break;
600 }
603 = *reinterpret_cast<RegisterSingletonTypeAndRevisions *>(data);
604 const char *elementName = classElementName(type.classInfoMetaObject);
605 RegisterSingletonType revisionRegistration = {
606 0,
607 type.uri,
608 type.version,
609 elementName,
610 nullptr,
611 type.qObjectApi,
612 type.instanceMetaObject,
613 type.typeId,
614 type.extensionObjectCreate,
615 type.extensionMetaObject,
617 };
618
619 const QTypeRevision added = revisionClassInfo(
620 type.classInfoMetaObject, "QML.AddedInVersion",
622 const QTypeRevision removed = revisionClassInfo(
623 type.classInfoMetaObject, "QML.RemovedInVersion");
624 const QList<QTypeRevision> furtherRevisions = revisionClassInfos(type.classInfoMetaObject,
625 "QML.ExtraVersion");
626
627 auto revisions = prepareRevisions(type.instanceMetaObject, added) + furtherRevisions;
628 uniqueRevisions(&revisions, type.version, added);
629
630 for (QTypeRevision revision : std::as_const(revisions)) {
631 if (revision.hasMajorVersion() && revision.majorVersion() > type.version.majorVersion())
632 break;
633
634 assignVersions(&revisionRegistration, revision, type.version);
635
636 // When removed or before added, we still add revisions, but anonymous ones
637 if (revisionRegistration.version < added
638 || (removed.isValid() && !(revisionRegistration.version < removed))) {
639 revisionRegistration.typeName = nullptr;
640 revisionRegistration.qObjectApi = nullptr;
641 } else {
642 revisionRegistration.typeName = elementName;
643 revisionRegistration.qObjectApi = type.qObjectApi;
644 }
645
646 const int id = qmlregister(SingletonRegistration, &revisionRegistration);
647 if (type.qmlTypeIds)
648 type.qmlTypeIds->append(id);
649 }
650 break;
651 }
654 = *reinterpret_cast<RegisterSequentialContainerAndRevisions *>(data);
655 RegisterSequentialContainer revisionRegistration = {
656 0,
657 type.uri,
658 type.version,
659 nullptr,
660 type.typeId,
661 type.metaSequence,
663 };
664
665 const QTypeRevision added = revisionClassInfo(
666 type.classInfoMetaObject, "QML.AddedInVersion",
669 type.classInfoMetaObject, "QML.ExtraVersion");
670 revisions.append(added);
671 uniqueRevisions(&revisions, type.version, added);
672
673 for (QTypeRevision revision : std::as_const(revisions)) {
674 if (revision < added)
675 continue;
676 if (revision.hasMajorVersion() && revision.majorVersion() > type.version.majorVersion())
677 break;
678
679 assignVersions(&revisionRegistration, revision, type.version);
680 const int id = qmlregister(SequentialContainerRegistration, &revisionRegistration);
681 if (type.qmlTypeIds)
682 type.qmlTypeIds->append(id);
683 }
684 break;
685 }
686 case TypeRegistration:
687 dtype = QQmlMetaType::registerType(*reinterpret_cast<RegisterType *>(data));
688 break;
690 dtype = QQmlMetaType::registerInterface(*reinterpret_cast<RegisterInterface *>(data));
691 break;
694 break;
697 break;
700 break;
703 break;
704 default:
705 return -1;
706 }
707
708 if (!dtype.isValid())
709 return -1;
710
712 return dtype.index();
713}
714
716{
717 switch (type) {
720 break;
723 reinterpret_cast<QmlUnitCacheLookupFunction>(data));
724 break;
727 break;
728 case TypeRegistration:
734 break;
738 // Currently unnecessary. We'd need a special data structure to hold
739 // URI + majorVersion and then we'd iterate the minor versions, look up the
740 // associated QQmlType objects by uri/elementName/major/minor and qmlunregister
741 // each of them.
742 Q_UNREACHABLE();
743 break;
744 }
745}
746
748 const char *key)
749{
750 QList<QTypeRevision> revisions;
751 for (int index = indexOfOwnClassInfo(metaObject, key); index != -1;
754 QLatin1StringView(metaObject->classInfo(index).value()).toInt()));
755 }
756 return revisions;
757}
758
760 const char *uri, int versionMajor, int versionMinor,
761 const char *qmlName, const QString &message)
762{
763 return qmlRegisterUncreatableType<QQmlTypeNotAvailable>(
764 uri, versionMajor, versionMinor, qmlName, message);
765}
766
767namespace QQmlPrivate {
768template<>
770 const char *uri, int versionMajor, const QMetaObject *classInfoMetaObject,
771 QVector<int> *qmlTypeIds, const QMetaObject *extension, bool)
772{
773 using T = QQmlTypeNotAvailable;
774
776 3,
779 0,
780 nullptr,
781 nullptr,
782 nullptr,
783
784 uri,
786
787 &QQmlTypeNotAvailable::staticMetaObject,
788 classInfoMetaObject,
789
790 attachedPropertiesFunc<T>(),
791 attachedPropertiesMetaObject<T>(),
792
796
797 nullptr,
798 extension,
799 qmlCreateCustomParser<T>,
800 qmlTypeIds,
802 false,
804 };
805
807}
808
810{
812 ->thisObject();
813}
814
816{
817 return qmlContext ? qmlContext->engine() : nullptr;
818}
819
821{
824}
825
827{
828 if (auto *frame = engine->handle()->currentStackFrame)
829 frame->instructionPointer = offset;
830}
831
833{
834 if (auto *frame = engine->handle()->currentStackFrame) {
835 Q_ASSERT(frame->isMetaTypesFrame());
837 }
838}
839
841{
842 if (!qmlContext)
843 return nullptr;
844
848 Q_ASSERT(ep);
849 return ep->propertyCapture;
850}
851
853 QObject *object, int coreIndex, int notifyIndex, bool isConstant,
855{
856 if (isConstant)
857 return;
858
860 capture->captureProperty(object, coreIndex, notifyIndex);
861}
862
864 QObject *object, const QQmlPropertyCache *propertyCache,
866{
867 if (property->isConstant())
868 return;
869
871 capture->captureProperty(object, propertyCache, property);
872}
873
874static bool inherits(const QQmlPropertyCache *descendent, const QQmlPropertyCache *ancestor)
875{
876 for (const QQmlPropertyCache *cache = descendent; cache; cache = cache->parent().data()) {
877 if (cache == ancestor)
878 return true;
879 }
880 return false;
881}
882
884
885template<bool StrictType = false>
888{
889 QQmlData *qmlData = QQmlData::get(object);
890 if (!qmlData)
892 if (qmlData->isQueuedForDeletion)
895 const QQmlPropertyCache *propertyCache = l->qobjectLookup.propertyCache;
896 if (StrictType) {
897 if (qmlData->propertyCache.data() != propertyCache)
899 } else if (!inherits(qmlData->propertyCache.data(), propertyCache)) {
901 }
902 const QQmlPropertyData *property = l->qobjectLookup.propertyData;
903
904 const int coreIndex = property->coreIndex();
905 if (qmlData->hasPendingBindingBit(coreIndex))
906 qmlData->flushPendingBinding(coreIndex);
907
908 captureObjectProperty(object, propertyCache, property, qmlContext);
909 property->readProperty(object, target);
911}
912
915{
916 QQmlData *qmlData = QQmlData::get(object);
917 if (qmlData && qmlData->isQueuedForDeletion)
919
921
923 = reinterpret_cast<const QMetaObject *>(l->qobjectFallbackLookup.metaObject - 1);
924 if (!metaObject || metaObject != object->metaObject())
926
927 const int coreIndex = l->qobjectFallbackLookup.coreIndex;
928 if (qmlData && qmlData->hasPendingBindingBit(coreIndex))
929 qmlData->flushPendingBinding(coreIndex);
930
933
934 void *a[] = { target, nullptr };
935 metaObject->metacall(object, QMetaObject::ReadProperty, coreIndex, a);
936
938}
939
942{
943 QVariant *variant = static_cast<QVariant *>(target);
944 const QMetaType propType = l->qobjectLookup.propertyData->propType();
945 if (propType == QMetaType::fromType<QVariant>())
946 return loadObjectProperty<true>(l, object, variant, qmlContext);
947
948 *variant = QVariant(propType);
949 return loadObjectProperty<true>(l, object, variant->data(), qmlContext);
950}
951
954{
956 = reinterpret_cast<const QMetaObject *>(l->qobjectFallbackLookup.metaObject - 1);
958
959 QVariant *variant = static_cast<QVariant *>(target);
960 const QMetaType propType = metaObject->property(l->qobjectFallbackLookup.coreIndex).metaType();
961 if (propType == QMetaType::fromType<QVariant>())
962 return loadFallbackProperty(l, object, variant, qmlContext);
963
964 *variant = QVariant(propType);
965 return loadFallbackProperty(l, object, variant->data(), qmlContext);
966}
967
968template<bool StrictType, typename Op>
970{
971 const QQmlData *qmlData = QQmlData::get(object);
972 if (!qmlData)
974 if (qmlData->isQueuedForDeletion)
977 if (StrictType) {
978 if (qmlData->propertyCache.data() != l->qobjectLookup.propertyCache)
980 } else if (!inherits(qmlData->propertyCache.data(), l->qobjectLookup.propertyCache)) {
982 }
983 const QQmlPropertyData *property = l->qobjectLookup.propertyData;
985 op(property);
987}
988
989template<bool StrictType = false>
991{
992 return changeObjectProperty<StrictType>(l, object, [&](const QQmlPropertyData *property) {
993 property->resetProperty(object, {});
994 });
995}
996
997template<bool StrictType = false>
999{
1000 return changeObjectProperty<StrictType>(l, object, [&](const QQmlPropertyData *property) {
1001 property->writeProperty(object, value, {});
1002 });
1003}
1004
1005template<typename Op>
1007{
1008 const QQmlData *qmlData = QQmlData::get(object);
1009 if (qmlData && qmlData->isQueuedForDeletion)
1012
1013 const QMetaObject *metaObject
1014 = reinterpret_cast<const QMetaObject *>(l->qobjectFallbackLookup.metaObject - 1);
1015 if (!metaObject || metaObject != object->metaObject())
1017
1018 const int coreIndex = l->qobjectFallbackLookup.coreIndex;
1020
1021 op(metaObject, coreIndex);
1023}
1024
1026{
1027 return changeFallbackProperty(l, object, [&](const QMetaObject *metaObject, int coreIndex) {
1028 void *args[] = { value, nullptr };
1029 metaObject->metacall(object, QMetaObject::WriteProperty, coreIndex, args);
1030 });
1031}
1032
1034{
1035 return changeFallbackProperty(l, object, [&](const QMetaObject *metaObject, int coreIndex) {
1036 void *args[] = { nullptr };
1037 metaObject->metacall(object, QMetaObject::ResetProperty, coreIndex, args);
1038 });
1039}
1040
1041static bool isTypeCompatible(QMetaType lookupType, QMetaType propertyType)
1042{
1043 if (!lookupType.isValid()) {
1044 // If type is invalid, then the calling code depends on the lookup
1045 // to be set up in order to query the type, via lookupResultMetaType.
1046 // We cannot verify the type in this case.
1047 } else if ((lookupType.flags() & QMetaType::IsQmlList)
1048 && (propertyType.flags() & QMetaType::IsQmlList)) {
1049 // We want to check the value types here, but we cannot easily do it.
1050 // Internally those are all QObject* lists, though.
1051 } else if (lookupType.flags() & QMetaType::PointerToQObject) {
1052 // We accept any base class as type, too
1053
1054 const QMetaObject *typeMetaObject = lookupType.metaObject();
1055 const QMetaObject *foundMetaObject = propertyType.metaObject();
1056 if (!foundMetaObject)
1057 foundMetaObject = QQmlMetaType::metaObjectForType(propertyType).metaObject();
1058
1059 while (foundMetaObject && foundMetaObject != typeMetaObject)
1060 foundMetaObject = foundMetaObject->superClass();
1061
1062 if (!foundMetaObject)
1063 return false;
1064 } else if (propertyType.flags() & QMetaType::IsEnumeration) {
1065 if (propertyType == lookupType)
1066 return true;
1067
1068 // You can pass the underlying type of an enum.
1069 // We don't want to check for the actual underlying type because
1070 // moc and qmltyperegistrar are not very precise about it. Especially
1071 // the long and longlong types can be ambiguous.
1072
1073 const bool isUnsigned = propertyType.flags() & QMetaType::IsUnsignedEnumeration;
1074 switch (propertyType.sizeOf()) {
1075 case 1:
1076 return isUnsigned
1077 ? lookupType == QMetaType::fromType<quint8>()
1078 : lookupType == QMetaType::fromType<qint8>();
1079 case 2:
1080 return isUnsigned
1081 ? lookupType == QMetaType::fromType<ushort>()
1082 : lookupType == QMetaType::fromType<short>();
1083 case 4:
1084 // The default type, if moc doesn't know the actual enum type, is int.
1085 // However, the compiler can still decide to encode the enum in uint.
1086 // Therefore, we also accept int for uint enums.
1087 // TODO: This is technically UB.
1088 return isUnsigned
1089 ? (lookupType == QMetaType::fromType<int>()
1090 || lookupType == QMetaType::fromType<uint>())
1091 : lookupType == QMetaType::fromType<int>();
1092 case 8:
1093 return isUnsigned
1094 ? lookupType == QMetaType::fromType<qulonglong>()
1095 : lookupType == QMetaType::fromType<qlonglong>();
1096 }
1097
1098 return false;
1099 } else if (propertyType != lookupType) {
1100 return false;
1101 }
1102 return true;
1103}
1104
1106 QV4::ExecutionEngine *v4, QV4::Lookup *l, QObject *object, void *value)
1107{
1108 QVariant *variant = static_cast<QVariant *>(value);
1109 const QMetaType propType = l->qobjectLookup.propertyData->propType();
1110 if (propType == QMetaType::fromType<QVariant>())
1111 return storeObjectProperty<true>(l, object, variant);
1112
1113 if (!variant->isValid())
1114 return resetObjectProperty<true>(l, object);
1115
1116 if (isTypeCompatible(variant->metaType(), propType))
1117 return storeObjectProperty<true>(l, object, variant->data());
1118
1119 QVariant converted(propType);
1120 v4->metaTypeFromJS(v4->fromVariant(*variant), propType, converted.data());
1121 return storeObjectProperty<true>(l, object, converted.data());
1122}
1123
1125 QV4::ExecutionEngine *v4, QV4::Lookup *l, QObject *object, void *value)
1126{
1127 QVariant *variant = static_cast<QVariant *>(value);
1128
1129 const QMetaObject *metaObject
1130 = reinterpret_cast<const QMetaObject *>(l->qobjectFallbackLookup.metaObject - 1);
1132
1133 const QMetaType propType = metaObject->property(l->qobjectFallbackLookup.coreIndex).metaType();
1134 if (propType == QMetaType::fromType<QVariant>())
1135 return storeFallbackProperty(l, object, variant);
1136
1137 if (!propType.isValid())
1138 return resetFallbackProperty(l, object);
1139
1140 if (isTypeCompatible(variant->metaType(), propType))
1141 return storeFallbackProperty(l, object, variant->data());
1142
1143 QVariant converted(propType);
1144 v4->metaTypeFromJS(v4->fromVariant(*variant), propType, converted.data());
1145 return storeFallbackProperty(l, object, converted.data());
1146}
1147
1149 Failure,
1150 Object,
1151 Fallback,
1154};
1155
1157 const AOTCompiledContext *aotContext, QV4::Lookup *l, QObject *object, QMetaType type)
1158{
1159 QV4::Scope scope(aotContext->engine->handle());
1161 aotContext->compilationUnit->runtimeStrings[l->nameIndex]);
1162
1163 Q_ASSERT(id.isString());
1164
1165 QV4::ScopedString name(scope, id.asStringOrSymbol());
1166
1167 Q_ASSERT(!name->equals(scope.engine->id_toString()));
1168 Q_ASSERT(!name->equals(scope.engine->id_destroy()));
1169
1170 QQmlData *ddata = QQmlData::get(object, true);
1171 Q_ASSERT(ddata);
1172 if (ddata->isQueuedForDeletion)
1174
1176 if (!ddata->propertyCache) {
1177 property = QQmlPropertyCache::property(object, name, aotContext->qmlContext, nullptr);
1178 } else {
1179 property = ddata->propertyCache->property(
1180 name.getPointer(), object, aotContext->qmlContext);
1181 }
1182
1183 const bool doVariantLookup = type == QMetaType::fromType<QVariant>();
1184 if (!property) {
1185 const QMetaObject *metaObject = object->metaObject();
1186 if (!metaObject)
1188
1189 const int coreIndex = metaObject->indexOfProperty(
1190 name->toQStringNoThrow().toUtf8().constData());
1191 if (coreIndex < 0)
1193
1194 const QMetaProperty property = metaObject->property(coreIndex);
1195 if (!doVariantLookup && !isTypeCompatible(type, property.metaType()))
1197
1199 // & 1 to tell the gc that this is not heap allocated; see markObjects in qv4lookup_p.h
1201 l->qobjectFallbackLookup.coreIndex = coreIndex;
1204 l->qobjectFallbackLookup.isConstant = property.isConstant() ? 1 : 0;
1205 return doVariantLookup
1208 }
1209
1210 if (!doVariantLookup && !isTypeCompatible(type, property->propType()))
1212
1213 Q_ASSERT(ddata->propertyCache);
1214
1216
1217 return doVariantLookup
1220}
1221
1224{
1226 const QByteArray name = compilationUnit->runtimeStrings[l->nameIndex]->toQString().toUtf8();
1227 const int coreIndex = metaObject->indexOfProperty(name.constData());
1228 QMetaType lookupType = metaObject->property(coreIndex).metaType();
1229 if (!isTypeCompatible(type, lookupType))
1230 return false;
1232 l->qgadgetLookup.coreIndex = coreIndex;
1233 l->qgadgetLookup.metaType = lookupType.iface();
1234 return true;
1235}
1236
1238{
1239 const int missingLineNumber = engine->currentStackFrame->missingLineNumber();
1240 const int lineNumber = engine->currentStackFrame->lineNumber();
1241 Q_ASSERT(missingLineNumber != lineNumber);
1242
1243 auto amendStackTrace = [&](QV4::StackTrace *stackTrace) {
1244 for (auto it = stackTrace->begin(), end = stackTrace->end(); it != end; ++it) {
1245 if (it->line == missingLineNumber) {
1246 it->line = lineNumber;
1247 break;
1248 }
1249 }
1250 };
1251
1252 amendStackTrace(&engine->exceptionStackTrace);
1253
1254 QV4::Scope scope(engine);
1255 QV4::Scoped<QV4::ErrorObject> error(scope, *engine->exceptionValue);
1256 if (error) // else some other value was thrown
1257 amendStackTrace(error->d()->stackTrace);
1258}
1259
1260
1262{
1263 if (!object)
1264 return false;
1265
1270 const QQmlPropertyData *property = l->qobjectLookup.propertyData;
1271 QQmlData::flushPendingBinding(object, property->coreIndex());
1273 return true;
1274 }
1275
1278 const int coreIndex = l->qobjectFallbackLookup.coreIndex;
1279 QQmlData::flushPendingBinding(object, coreIndex);
1281 object, coreIndex, l->qobjectFallbackLookup.notifyIndex,
1283 return true;
1284 }
1285
1286 return false;
1287}
1288
1290{
1294 const QQmlPropertyData *property = l->qobjectLookup.propertyData;
1297 return true;
1298 }
1299
1301 const int coreIndex = l->qobjectFallbackLookup.coreIndex;
1305 return true;
1306 }
1307
1308 return false;
1309}
1310
1312{
1314 capture->captureTranslation();
1315}
1316
1318{
1319#if QT_CONFIG(translation)
1320 return QV4::GlobalExtensions::currentTranslationContext(engine->handle());
1321#else
1322 return QString();
1323#endif
1324}
1325
1327{
1336 return l->qobjectLookup.propertyData->propType();
1338 return QMetaType(l->qgadgetLookup.metaType);
1340 return QMetaType::fromType<int>();
1345 return QMetaType::fromType<QObject *>();
1346 } else if (l->getter == QV4::Lookup::getterFallback
1352 const QMetaObject *metaObject
1353 = reinterpret_cast<const QMetaObject *>(l->qobjectFallbackLookup.metaObject - 1);
1354 const int coreIndex = l->qobjectFallbackLookup.coreIndex;
1355 return metaObject->property(coreIndex).metaType();
1356 }
1357 return QMetaType();
1358}
1359
1360static bool isUndefined(const void *value, QMetaType type)
1361{
1362 if (type == QMetaType::fromType<QVariant>())
1363 return !static_cast<const QVariant *>(value)->isValid();
1364 if (type == QMetaType::fromType<QJSValue>())
1365 return static_cast<const QJSValue *>(value)->isUndefined();
1366 if (type == QMetaType::fromType<QJSPrimitiveValue>()) {
1367 return static_cast<const QJSPrimitiveValue *>(value)->type()
1369 }
1370 return false;
1371}
1372
1374{
1375 // We don't really use any part of the lookup machinery here.
1376 // The QV4::Lookup is created on the stack to conveniently get the property cache, and through
1377 // the property cache we store a value into the property.
1378
1379 QV4::Lookup l;
1380 l.clear();
1381 l.nameIndex = nameIndex;
1382 l.forCall = false;
1384 switch (initObjectLookup(this, &l, qmlScopeObject, QMetaType())) {
1387 const QMetaType propType = l.qobjectLookup.propertyData->propType();
1388 if (isTypeCompatible(type, propType)) {
1389 storeResult = storeObjectProperty(&l, qmlScopeObject, value);
1390 } else if (isUndefined(value, type)) {
1391 storeResult = resetObjectProperty(&l, qmlScopeObject);
1392 } else {
1393 QVariant var(propType);
1395 v4->metaTypeFromJS(v4->metaTypeToJS(type, value), propType, var.data());
1396 storeResult = storeObjectProperty(&l, qmlScopeObject, var.data());
1397 }
1398
1400 break;
1401 }
1404 const QMetaObject *metaObject
1405 = reinterpret_cast<const QMetaObject *>(l.qobjectFallbackLookup.metaObject - 1);
1406 const QMetaType propType
1407 = metaObject->property(l.qobjectFallbackLookup.coreIndex).metaType();
1408 if (isTypeCompatible(type, propType)) {
1409 storeResult = storeFallbackProperty(&l, qmlScopeObject, value);
1410 } else if (isUndefined(value, type)) {
1411 storeResult = resetFallbackProperty(&l, qmlScopeObject);
1412 } else {
1413 QVariant var(propType);
1415 v4->metaTypeFromJS(v4->metaTypeToJS(type, value), propType, var.data());
1416 storeResult = storeFallbackProperty(&l, qmlScopeObject, var.data());
1417 }
1418 break;
1419 }
1422 return;
1423 }
1424
1425 switch (storeResult) {
1428 break;
1431 QStringLiteral("Value is null and could not be converted to an object"));
1432 break;
1434 break;
1435 }
1436}
1437
1439{
1440 QV4::Scope scope(engine->handle());
1443 return QJSValuePrivate::fromReturnedValue(global->get(name->toPropertyKey()));
1444}
1445
1447{
1448 if (wrapper) {
1449 // We have to check this here because you may pass a plain QObject that only
1450 // turns out to be a QQmlLoggingCategory at run time.
1451 if (QQmlLoggingCategory *qQmlLoggingCategory
1452 = qobject_cast<QQmlLoggingCategory *>(wrapper)) {
1453 QLoggingCategory *loggingCategory = qQmlLoggingCategory->category();
1454 *ok = true;
1455 if (!loggingCategory) {
1457 QStringLiteral("A QmlLoggingCatgory was provided without a valid name"));
1458 }
1459 return loggingCategory;
1460 }
1461 }
1462
1463 *ok = false;
1464 return qmlEngine() ? &lcQml() : &lcJs();
1465}
1466
1468 QtMsgType type, const QString &message, const QLoggingCategory *loggingCategory) const
1469{
1470 Q_ASSERT(loggingCategory->isEnabled(type));
1471
1473 Q_ASSERT(frame);
1474
1475 QMessageLogger logger(qUtf8Printable(frame->source()), frame->lineNumber(),
1476 qUtf8Printable(frame->function()), loggingCategory->categoryName());
1477
1478 switch (type) {
1479 case QtDebugMsg:
1480 logger.debug("%s", qUtf8Printable(message));
1481 break;
1482 case QtInfoMsg:
1483 logger.info("%s", qUtf8Printable(message));
1484 break;
1485 case QtWarningMsg:
1486 logger.warning("%s", qUtf8Printable(message));
1487 break;
1488 case QtCriticalMsg:
1489 logger.critical("%s", qUtf8Printable(message));
1490 break;
1491 default:
1492 break;
1493 }
1494}
1495
1497 QMetaType resultMetaType, const QMetaObject *resultMetaObject,
1498 int ctorIndex, void *ctorArg) const
1499{
1501 resultMetaType, resultMetaObject, ctorIndex, ctorArg);
1502}
1503
1505 uint index, void **args, const QMetaType *types, int argc) const
1506{
1508 QV4::Scope scope(engine->handle());
1511 scope, l->qmlContextPropertyGetter(l, scope.engine, thisObject));
1512 if (!function) {
1513 scope.engine->throwTypeError(
1514 QStringLiteral("Property '%1' of object [null] is not a function").arg(
1516 return false;
1517 }
1518
1519 function->call(qmlScopeObject, args, types, argc);
1520 return !scope.hasException();
1521}
1522
1524{
1525 Q_UNUSED(index);
1528}
1529
1531{
1533 int objectId = -1;
1534 QQmlContextData *context = nullptr;
1536
1538 objectId = l->qmlContextIdObjectLookup.objectId;
1540 } else if (l->qmlContextPropertyGetter
1542 QV4::Scope scope(engine->handle());
1544 for (context = qmlContext; context; context = context->parent().data()) {
1545 objectId = context->propertyIndex(name);
1546 if (objectId != -1 && objectId < context->numIdValues())
1547 break;
1548 }
1549 } else {
1550 return false;
1551 }
1552
1553 Q_ASSERT(objectId >= 0);
1554 Q_ASSERT(context != nullptr);
1556 if (QQmlPropertyCapture *capture = engine->propertyCapture)
1557 capture->captureProperty(context->idValueBindings(objectId));
1558 *static_cast<QObject **>(target) = context->idValue(objectId);
1559 return true;
1560}
1561
1563{
1566 QV4::Scope scope(engine->handle());
1569 for (auto context = ownContext; context; context = context->parent()) {
1570 const int propertyIdx = context->propertyIndex(name);
1571 if (propertyIdx == -1 || propertyIdx >= context->numIdValues())
1572 continue;
1573
1574 if (context.data() == ownContext.data()) {
1575 l->qmlContextIdObjectLookup.objectId = propertyIdx;
1577 } else {
1579 }
1580
1581 return;
1582 }
1583
1584 Q_UNREACHABLE();
1585}
1586
1588 uint index, QObject *object, void **args, const QMetaType *types, int argc) const
1589{
1591 QV4::Scope scope(engine->handle());
1594 if (!function) {
1595 scope.engine->throwTypeError(
1596 QStringLiteral("Property '%1' of object [object Object] is not a function")
1598 return false;
1599 }
1600
1601 function->call(object, args, types, argc);
1602 return !scope.hasException();
1603}
1604
1606{
1607 Q_UNUSED(index);
1610}
1611
1613 uint index, void **args, const QMetaType *types, int argc) const
1614{
1616 QV4::Scope scope(engine->handle());
1618 if (!function) {
1619 scope.engine->throwTypeError(
1620 QStringLiteral("Property '%1' of object [null] is not a function")
1622 return false;
1623 }
1624
1625 function->call(nullptr, args, types, argc);
1626 return true;
1627}
1628
1630{
1631 Q_UNUSED(index);
1634}
1635
1637{
1641 return false;
1642 }
1643 return true;
1644}
1645
1647{
1648 Q_UNUSED(index);
1651}
1652
1654{
1656
1662 else
1663 return false;
1664
1665 switch (result) {
1667 return false;
1670 QStringLiteral("Cannot read property '%1' of null")
1672 return false;
1674 return true;
1675 }
1676
1677 Q_UNREACHABLE_RETURN(false);
1678}
1679
1681{
1684
1685 if (v4->hasException) {
1686 amendException(v4);
1687 return;
1688 }
1689
1690 switch (initObjectLookup(this, l, qmlScopeObject, type)) {
1694 break;
1698 break;
1700 v4->throwTypeError();
1701 break;
1702 }
1703}
1704
1706{
1708 QV4::Scope scope(engine->handle());
1709
1713
1714 // We don't handle non-QObject singletons (as those can't be declared in qmltypes anyway)
1716 *static_cast<QObject **>(target) = wrapper->object();
1717 return true;
1718 }
1719
1720 return false;
1721}
1722
1725
1726template<QmlContextPropertyGetter qmlContextPropertyGetter>
1728 const AOTCompiledContext *context, QV4::Lookup *l, uint importNamespace)
1729{
1730 Q_ASSERT(!context->engine->hasError());
1731 if (importNamespace != AOTCompiledContext::InvalidStringId) {
1732 QV4::Scope scope(context->engine->handle());
1733 QV4::ScopedString import(scope, context->compilationUnit->runtimeStrings[importNamespace]);
1734 if (const QQmlImportRef *importRef
1735 = context->qmlContext->imports()->query(import).importNamespace) {
1738 scope.engine, nullptr, context->qmlContext->imports(), importRef));
1739 wrapper = l->qmlContextPropertyGetter(l, context->engine->handle(), wrapper);
1740 l->qmlContextPropertyGetter = qmlContextPropertyGetter;
1741 if (qmlContextPropertyGetter == QV4::QQmlContextWrapper::lookupSingleton)
1743 else if (qmlContextPropertyGetter == QV4::QQmlContextWrapper::lookupType)
1744 l->qmlTypeLookup.qmlTypeWrapper = wrapper->heapObject();
1745 return;
1746 }
1747 scope.engine->throwTypeError();
1748 } else {
1749 QV4::ExecutionEngine *v4 = context->engine->handle();
1750 l->qmlContextPropertyGetter(l, v4, nullptr);
1751 if (l->qmlContextPropertyGetter != qmlContextPropertyGetter) {
1752 const QString error
1753 = QLatin1String(qmlContextPropertyGetter
1755 ? "%1 was a singleton at compile time, "
1756 "but is not a singleton anymore."
1757 : "%1 was not a singleton at compile time, "
1758 "but is a singleton now.")
1759 .arg(context->compilationUnit->runtimeStrings[l->nameIndex]->toQString());
1760 v4->throwTypeError(error);
1761 }
1762 }
1763}
1764
1766{
1768 initTypeWrapperLookup<QV4::QQmlContextWrapper::lookupSingleton>(this, l, importNamespace);
1769}
1770
1772{
1775 return false;
1776
1777 QV4::Scope scope(engine->handle());
1780 *static_cast<QObject **>(target) = qmlAttachedPropertiesObject(
1781 object, wrapper->d()->type().attachedPropertiesFunction(
1783 return true;
1784}
1785
1787 uint index, uint importNamespace, QObject *object) const
1788{
1790 QV4::Scope scope(engine->handle());
1792
1793 QQmlType type;
1794 if (importNamespace != InvalidStringId) {
1795 QV4::ScopedString import(scope, compilationUnit->runtimeStrings[importNamespace]);
1796 if (const QQmlImportRef *importRef = qmlContext->imports()->query(import).importNamespace)
1797 type = qmlContext->imports()->query(name, importRef).type;
1798 } else {
1800 }
1801
1802 if (!type.isValid()) {
1803 scope.engine->throwTypeError();
1804 return;
1805 }
1806
1808 scope, QV4::QQmlTypeWrapper::create(scope.engine, object, type,
1810
1813}
1814
1816{
1819 return false;
1820
1821 const QV4::Heap::QQmlTypeWrapper *typeWrapper = static_cast<const QV4::Heap::QQmlTypeWrapper *>(
1824
1825 QMetaType metaType = typeWrapper->type().typeId();
1826 if (!metaType.isValid()) {
1827 metaType = ep->typeLoader.getType(typeWrapper->type().sourceUrl())
1829 }
1830
1831 *static_cast<const QMetaObject **>(target)
1833 return true;
1834}
1835
1837{
1839 initTypeWrapperLookup<QV4::QQmlContextWrapper::lookupType>(this, l, importNamespace);
1840}
1841
1843{
1844
1846 const auto doThrow = [&]() {
1848 QStringLiteral("Cannot read property '%1' of null")
1850 return false;
1851 };
1852
1853 if (!object)
1854 return doThrow();
1855
1859 else if (l->getter == QV4::Lookup::getterFallback)
1865 else
1866 return false;
1867
1868 switch (result) {
1870 return doThrow();
1872 return false;
1874 return true;
1875 }
1876
1877 Q_UNREACHABLE_RETURN(false);
1878}
1879
1881{
1883 if (v4->hasException) {
1884 amendException(v4);
1885 } else {
1887 switch (initObjectLookup(this, l, object, type)) {
1890 break;
1893 break;
1896 break;
1899 break;
1902 break;
1903 }
1904 }
1905}
1906
1908{
1909 Q_ASSERT(value);
1910
1913 return false;
1914
1915 const QMetaObject *metaObject
1916 = reinterpret_cast<const QMetaObject *>(l->qgadgetLookup.metaObject - 1);
1918
1919 void *args[] = { target, nullptr };
1920 metaObject->d.static_metacall(
1921 reinterpret_cast<QObject*>(value), QMetaObject::ReadProperty,
1923 return true;
1924}
1925
1928{
1933 else
1935}
1936
1938{
1941 return false;
1942 const bool isUnsigned
1945 switch (l->qmlEnumValueLookup.metaType->size) {
1946 case 1:
1947 if (isUnsigned)
1948 *static_cast<quint8 *>(target) = encoded;
1949 else
1950 *static_cast<qint8 *>(target) = encoded;
1951 return true;
1952 case 2:
1953 if (isUnsigned)
1954 *static_cast<quint16 *>(target) = encoded;
1955 else
1956 *static_cast<qint16 *>(target) = encoded;
1957 return true;
1958 case 4:
1959 if (isUnsigned)
1960 *static_cast<quint32 *>(target) = encoded;
1961 else
1962 *static_cast<qint32 *>(target) = encoded;
1963 return true;
1964 case 8:
1965 if (isUnsigned)
1966 *static_cast<quint64 *>(target) = encoded;
1967 else
1968 *static_cast<qint64 *>(target) = encoded;
1969 return true;
1970 default:
1971 break;
1972 }
1973
1974 return false;
1975}
1976
1979 const char *enumerator, const char *enumValue) const
1980{
1983 if (!metaObject) {
1985 QStringLiteral("Cannot read property '%1' of undefined")
1986 .arg(QString::fromUtf8(enumValue)));
1987 return;
1988 }
1989 const int enumIndex = metaObject->indexOfEnumerator(enumerator);
1990 const QMetaEnum metaEnum = metaObject->enumerator(enumIndex);
1991 l->qmlEnumValueLookup.encodedEnumValue = metaEnum.keyToValue(enumValue);
1992 l->qmlEnumValueLookup.metaType = metaEnum.metaType().iface();
1994}
1995
1997{
1998 const auto doThrow = [&]() {
2000 QStringLiteral("Value is null and could not be converted to an object"));
2001 return false;
2002 };
2003
2004 if (!object)
2005 return doThrow();
2006
2010 result = storeObjectProperty(l, object, value);
2011 else if (l->setter == QV4::Lookup::setterFallback)
2012 result = storeFallbackProperty(l, object, value);
2014 result = storeObjectAsVariant(engine->handle(), l, object, value);
2017 else
2018 return false;
2019
2020 switch (result) {
2022 return doThrow();
2024 return false;
2026 return true;
2027 }
2028
2029 Q_UNREACHABLE_RETURN(false);
2030}
2031
2033{
2035 if (v4->hasException) {
2036 amendException(v4);
2037 } else {
2039 switch (initObjectLookup(this, l, object, type)) {
2042 break;
2045 break;
2048 break;
2051 break;
2054 break;
2055 }
2056 }
2057}
2058
2060 uint index, void *target, void *value) const
2061{
2064 return false;
2065
2066 const QMetaObject *metaObject
2067 = reinterpret_cast<const QMetaObject *>(l->qgadgetLookup.metaObject - 1);
2068
2069 void *args[] = { value, nullptr };
2070 metaObject->d.static_metacall(
2071 reinterpret_cast<QObject*>(target), QMetaObject::WriteProperty,
2073 return true;
2074}
2075
2077 QMetaType type) const
2078{
2083 else
2085}
2086
2087} // namespace QQmlPrivate
2088
\inmodule QtCore
Definition qbytearray.h:57
The QJSEngine class provides an environment for evaluating JavaScript code.
Definition qjsengine.h:26
QV4::ExecutionEngine * handle() const
Definition qjsengine.h:292
bool hasError() const
Returns true if the last JavaScript execution resulted in an exception or if throwError() was called.
static void setObjectOwnership(QObject *, ObjectOwnership)
Sets the ownership of object.
The QJSPrimitiveValue class operates on primitive types in JavaScript semantics.
static QJSValue fromReturnedValue(QV4::ReturnedValue d)
Definition qjsvalue_p.h:189
The QJSValue class acts as a container for Qt/JavaScript data types.
Definition qjsvalue.h:31
bool isUndefined() const
Returns true if this QJSValue is of the primitive type Undefined or if the managed value has been cle...
Definition qjsvalue.cpp:349
int toInt(bool *ok=nullptr, int base=10) const
Definition qlist.h:74
iterator erase(const_iterator begin, const_iterator end)
Definition qlist.h:882
void push_back(parameter_type t)
Definition qlist.h:672
iterator end()
Definition qlist.h:609
iterator begin()
Definition qlist.h:608
void append(parameter_type t)
Definition qlist.h:441
\inmodule QtCore
bool isEnabled(QtMsgType type) const
Returns true if a message of type msgtype for the category should be shown; false otherwise.
const char * categoryName() const
Returns the name of the category.
\inmodule QtCore
Definition qlogging.h:68
void void Q_DECL_COLD_FUNCTION void warning(const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(2
Logs a warning message specified with format msg.
Definition qlogging.cpp:648
void void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void critical(const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(2
Logs a critical message specified with format msg.
Definition qlogging.cpp:764
void void void info(const QLoggingCategory &cat, const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(3
Logs an informational message specified with format msg for the context cat.
Definition qlogging.cpp:548
void debug(const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(2
Logs a debug message specified with format msg.
Definition qlogging.cpp:385
\inmodule QtCore
QMetaType metaType() const
Returns the meta type of the enum.
int keyToValue(const char *key, bool *ok=nullptr) const
Returns the integer value of the given enumeration key, or -1 if key is not defined.
\inmodule QtCore
Definition qmetaobject.h:18
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore
Definition qmetatype.h:320
constexpr TypeFlags flags() const
Definition qmetatype.h:2628
const QtPrivate::QMetaTypeInterface * iface() const
Definition qmetatype.h:750
constexpr qsizetype sizeOf() const
Definition qmetatype.h:2618
bool isValid() const
@ IsUnsignedEnumeration
Definition qmetatype.h:390
@ PointerToQObject
Definition qmetatype.h:385
@ IsEnumeration
Definition qmetatype.h:386
constexpr const QMetaObject * metaObject() const
Definition qmetatype.h:2633
constexpr const char * name() const
Definition qmetatype.h:2650
static QObjectPrivate * get(QObject *o)
Definition qobject_p.h:153
\inmodule QtCore
Definition qobject.h:90
QThread * thread() const
Returns the thread in which the object lives.
Definition qobject.cpp:1561
std::vector< ConstructionState > DeferredState
static void completeDeferred(QQmlEnginePrivate *enginePriv, DeferredState *deferredState)
static void beginDeferred(QQmlEnginePrivate *enginePriv, QObject *object, DeferredState *deferredState)
QQmlRefPointer< QQmlTypeNameCache > imports() const
QQmlEngine * engine() const
The QQmlContext class defines a context within a QML engine.
Definition qqmlcontext.h:25
QQmlEngine * engine() const
Return the context's QQmlEngine, or \nullptr if the context has no QQmlEngine or the QQmlEngine was d...
static void flushPendingBinding(QObject *object, int coreIndex)
Definition qqmldata_p.h:393
QQmlPropertyCache::ConstPtr propertyCache
Definition qqmldata_p.h:195
bool hasPendingBindingBit(int index) const
Definition qqmldata_p.h:371
static bool wasDeleted(const QObject *)
Definition qqmldata_p.h:312
static QQmlData * get(QObjectPrivate *priv, bool create)
Definition qqmldata_p.h:199
quint32 isQueuedForDeletion
Definition qqmldata_p.h:99
QQmlPropertyCapture * propertyCapture
void warning(const QQmlError &)
QQmlTypeLoader typeLoader
static bool baseModulesUninitialized
static QQmlEnginePrivate * get(QQmlEngine *e)
The QQmlEngine class provides an environment for instantiating QML components.
Definition qqmlengine.h:57
static QQmlContext * contextForObject(const QObject *)
Returns the QQmlContext for the object, or nullptr if no context has been set.
void qmlUnregisterModuleImport(const char *uri, int moduleMajor, const char *import, int importMajor, int importMinor)
Removes a module import previously registered with qmlRegisterModuleImport()
Definition qqml.cpp:328
void qmlRegisterModuleImport(const char *uri, int moduleMajor, const char *import, int importMajor, int importMinor)
Registers a qmldir-import for module uri of major version moduleMajor.
Definition qqml.cpp:308
The QQmlError class encapsulates a QML error.
Definition qqmlerror.h:18
const QMetaObject * metaObject() const
static QQmlType registerCompositeSingletonType(const QQmlPrivate::RegisterCompositeSingletonType &type)
static QQmlType registerSequentialContainer(const QQmlPrivate::RegisterSequentialContainer &sequenceRegistration)
static void unregisterType(int type)
static void registerUndeletableType(const QQmlType &dtype)
static void unregisterAutoParentFunction(const QQmlPrivate::AutoParentFunction &function)
static bool protectModule(const QString &uri, QTypeRevision version, bool weakProtectAllVersions=false)
static void removeCachedUnitLookupFunction(QQmlPrivate::QmlUnitCacheLookupFunction handler)
static void registerModule(const char *uri, QTypeRevision version)
static QQmlType registerInterface(const QQmlPrivate::RegisterInterface &type)
static int typeId(const char *uri, QTypeRevision version, const char *qmlName)
static QQmlType registerType(const QQmlPrivate::RegisterType &type)
static QQmlMetaObject metaObjectForType(QMetaType metaType)
static void registerModuleImport(const QString &uri, QTypeRevision version, const QQmlDirParser::Import &import)
static QQmlAttachedPropertiesFunc attachedPropertiesFunc(QQmlEnginePrivate *, const QMetaObject *)
static QQmlType registerCompositeType(const QQmlPrivate::RegisterCompositeType &type)
static int registerAutoParentFunction(const QQmlPrivate::RegisterAutoParent &autoparent)
static void clearTypeRegistrations()
static QQmlType registerSingletonType(const QQmlPrivate::RegisterSingletonType &type)
static void unregisterSequentialContainer(int id)
static int registerUnitCacheHook(const QQmlPrivate::RegisterQmlUnitCacheHook &hookRegistration)
static void unregisterModuleImport(const QString &uri, QTypeRevision version, const QQmlDirParser::Import &import)
const QQmlPropertyData * property(const K &key, QObject *object, const QQmlRefPointer< QQmlContextData > &context) const
QMetaType propType() const
static void removeBinding(const QQmlProperty &that)
static constexpr int extensionObjectId(int id) noexcept
void release() const
T * data() const
QV4::ExecutableCompilationUnit * compilationUnit() const
QQmlRefPointer< QQmlTypeData > getType(const QUrl &unNormalizedUrl, Mode mode=PreferSynchronous)
Returns a QQmlTypeData for the specified url.
Result query(const QHashedStringRef &key) const
QMetaType typeId() const
Definition qqmltype.cpp:643
int index() const
Definition qqmltype.cpp:734
QUrl sourceUrl() const
Definition qqmltype.cpp:743
bool isValid() const
Definition qqmltype_p.h:58
static QVariant constructValueType(QMetaType targetMetaType, const QMetaObject *targetMetaObject, int ctorIndex, void *ctorArg)
iterator begin()
Definition qset.h:136
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5857
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:1083
QByteArray toUtf8() const &
Definition qstring.h:563
\inmodule QtCore
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 bool hasMinorVersion() const
Returns true if the minor version is known, otherwise false.
static constexpr QTypeRevision zero()
Produces a QTypeRevision with major and minor version {0}.
static constexpr QTypeRevision fromMinorVersion(Minor minorVersion)
Produces a QTypeRevision from the given minorVersion with an invalid major version.
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.
static constexpr QTypeRevision fromMajorVersion(Major majorVersion)
Produces a QTypeRevision from the given majorVersion with an invalid minor version.
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.
\inmodule QtCore
Definition qvariant.h:64
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...
Definition qvariant.h:707
QMetaType metaType() const
void extension()
[6]
Definition dialogs.cpp:230
QCache< int, Employee > cache
[0]
QSet< QString >::iterator it
else opt state
[0]
ObjectPropertyResult loadFallbackAsVariant(QV4::Lookup *l, QObject *object, void *target, QQmlContextData *qmlContext)
Definition qqml.cpp:952
static void initTypeWrapperLookup(const AOTCompiledContext *context, QV4::Lookup *l, uint importNamespace)
Definition qqml.cpp:1727
QTypeRevision revisionClassInfo(const QMetaObject *metaObject, const char *key, QTypeRevision defaultValue=QTypeRevision())
void Q_QML_EXPORT qmlunregister(RegistrationType, quintptr)
Definition qqml.cpp:715
static ObjectPropertyResult storeFallbackProperty(QV4::Lookup *l, QObject *object, void *value)
Definition qqml.cpp:1025
static int indexOfOwnClassInfo(const QMetaObject *metaObject, const char *key, int startOffset=-1)
static void captureObjectProperty(QObject *object, const QQmlPropertyCache *propertyCache, const QQmlPropertyData *property, QQmlContextData *qmlContext)
Definition qqml.cpp:863
static QQmlPropertyCapture * propertyCapture(const QQmlContextData *qmlContext)
Definition qqml.cpp:840
static bool initValueLookup(QV4::Lookup *l, QV4::ExecutableCompilationUnit *compilationUnit, const QMetaObject *metaObject, QMetaType type)
Definition qqml.cpp:1222
static ObjectPropertyResult storeObjectAsVariant(QV4::ExecutionEngine *v4, QV4::Lookup *l, QObject *object, void *value)
Definition qqml.cpp:1105
ObjectPropertyResult loadObjectAsVariant(QV4::Lookup *l, QObject *object, void *target, QQmlContextData *qmlContext)
Definition qqml.cpp:940
Q_QML_EXPORT void qmlRegistrationWarning(QmlRegistrationWarning warning, QMetaType type)
Definition qqml.cpp:149
@ CompositeSingletonRegistration
@ SingletonRegistration
@ SequentialContainerRegistration
@ SequentialContainerAndRevisionsRegistration
@ QmlUnitCacheHookRegistration
@ CompositeRegistration
@ SingletonAndRevisionsRegistration
@ InterfaceRegistration
@ AutoParentRegistration
@ TypeAndRevisionsRegistration
QV4::ReturnedValue(*)(QV4::Lookup *l, QV4::ExecutionEngine *engine, QV4::Value *thisObject) QmlContextPropertyGetter
Definition qqml.cpp:1724
static ObjectPropertyResult storeFallbackAsVariant(QV4::ExecutionEngine *v4, QV4::Lookup *l, QObject *object, void *value)
Definition qqml.cpp:1124
static ObjectPropertyResult changeObjectProperty(QV4::Lookup *l, QObject *object, Op op)
Definition qqml.cpp:969
Q_QML_EXPORT QList< QTypeRevision > revisionClassInfos(const QMetaObject *metaObject, const char *key)
Definition qqml.cpp:747
static bool inherits(const QQmlPropertyCache *descendent, const QQmlPropertyCache *ancestor)
Definition qqml.cpp:874
static ObjectLookupResult initObjectLookup(const AOTCompiledContext *aotContext, QV4::Lookup *l, QObject *object, QMetaType type)
Definition qqml.cpp:1156
static ObjectPropertyResult resetObjectProperty(QV4::Lookup *l, QObject *object)
Definition qqml.cpp:990
ObjectPropertyResult loadObjectProperty(QV4::Lookup *l, QObject *object, void *target, QQmlContextData *qmlContext)
Definition qqml.cpp:886
static bool isUndefined(const void *value, QMetaType type)
Definition qqml.cpp:1360
static void amendException(QV4::ExecutionEngine *engine)
Definition qqml.cpp:1237
@ UnconstructibleSingleton
Q_QML_EXPORT QObject * qmlExtendedObject(QObject *, int)
Definition qqml.cpp:130
const CachedQmlUnit *(* QmlUnitCacheLookupFunction)(const QUrl &url)
static ObjectPropertyResult resetFallbackProperty(QV4::Lookup *l, QObject *object)
Definition qqml.cpp:1033
static void captureFallbackProperty(QObject *object, int coreIndex, int notifyIndex, bool isConstant, const QQmlContextData *qmlContext)
Definition qqml.cpp:852
const char * classInfo(const QMetaObject *metaObject, const char *key)
static ObjectPropertyResult loadFallbackProperty(QV4::Lookup *l, QObject *object, void *target, QQmlContextData *qmlContext)
Definition qqml.cpp:913
static bool isTypeCompatible(QMetaType lookupType, QMetaType propertyType)
Definition qqml.cpp:1041
bool boolClassInfo(const QMetaObject *metaObject, const char *key, bool defaultValue=false)
int Q_QML_EXPORT qmlregister(RegistrationType, void *)
Definition qqml.cpp:483
AutoParentResult(* AutoParentFunction)(QObject *object, QObject *parent)
void qmlRegisterTypeAndRevisions< QQmlTypeNotAvailable, void >(const char *uri, int versionMajor, const QMetaObject *classInfoMetaObject, QVector< int > *qmlTypeIds, const QMetaObject *extension, bool)
Definition qqml.cpp:769
static ObjectPropertyResult storeObjectProperty(QV4::Lookup *l, QObject *object, void *value)
Definition qqml.cpp:998
ObjectPropertyResult
Definition qqml.cpp:883
const char * classElementName(const QMetaObject *metaObject)
static ObjectPropertyResult changeFallbackProperty(QV4::Lookup *l, QObject *object, Op op)
Definition qqml.cpp:1006
Combined button and popup list for selecting options.
quint64 ReturnedValue
void setupQObjectLookup(Lookup *lookup, const QQmlData *ddata, const QQmlPropertyData *propertyData)
static void * context
Q_CORE_EXPORT int qstrcmp(const char *str1, const char *str2)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
DBusConnection const char DBusError * error
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
QtMsgType
Definition qlogging.h:29
@ QtCriticalMsg
Definition qlogging.h:32
@ QtInfoMsg
Definition qlogging.h:34
@ QtWarningMsg
Definition qlogging.h:31
@ QtDebugMsg
Definition qlogging.h:30
#define qWarning
Definition qlogging.h:162
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLuint64 key
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint index
[2]
GLuint GLuint end
GLsizei GLenum GLenum * types
GLuint object
[3]
GLenum type
GLenum target
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLuint name
GLhandleARB obj
[2]
GLenum func
Definition qopenglext.h:663
GLuint64EXT * result
[6]
bool qmlProtectModule(const char *uri, int majVersion)
Definition qqml.cpp:218
int qmlTypeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
Definition qqml.cpp:337
void qmlRegisterModule(const char *uri, int versionMajor, int versionMinor)
Definition qqml.cpp:225
QQmlAttachedPropertiesFunc qmlAttachedPropertiesFunction(QObject *object, const QMetaObject *attachedMetaObject)
Definition qqml.cpp:102
int qmlRegisterUncreatableMetaObject(const QMetaObject &staticMetaObject, const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString &reason)
Definition qqml.cpp:175
void qmlExecuteDeferred(QObject *object)
Definition qqml.cpp:48
void assignVersions(Registration *registration, QTypeRevision revision, QTypeRevision defaultVersion)
Definition qqml.cpp:432
QQmlEngine * qmlEngine(const QObject *obj)
Definition qqml.cpp:76
static QVector< QTypeRevision > availableRevisions(const QMetaObject *metaObject)
Definition qqml.cpp:402
int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString &message)
Definition qqml.cpp:759
QQmlContext * qmlContext(const QObject *obj)
Definition qqml.cpp:71
static QObject * resolveAttachedProperties(QQmlAttachedPropertiesFunc pf, QQmlData *data, QObject *object, bool create)
Definition qqml.cpp:84
QObject * qmlAttachedPropertiesObject(QObject *object, QQmlAttachedPropertiesFunc func, bool create)
Definition qqml.cpp:110
static void uniqueRevisions(QVector< QTypeRevision > *revisions, QTypeRevision defaultVersion, QTypeRevision added)
Definition qqml.cpp:450
void qmlClearTypeRegistrations()
Definition qqml.cpp:210
static QQmlDirParser::Import resolveImport(const QString &uri, int importMajor, int importMinor)
Definition qqml.cpp:230
QObject * qmlExtendedObject(QObject *object)
Definition qqml.cpp:125
static bool checkSingletonInstance(QQmlEngine *engine, QObject *instance)
Definition qqml.cpp:342
static QVector< QTypeRevision > prepareRevisions(const QMetaObject *metaObject, QTypeRevision added)
Definition qqml.cpp:443
static QTypeRevision resolveModuleVersion(int moduleMajor)
Definition qqml.cpp:241
@ QQmlModuleImportLatest
Definition qqml.h:649
@ QQmlModuleImportModuleAny
Definition qqml.h:648
@ QQmlModuleImportAuto
Definition qqml.h:650
void qmlClearEnginePlugins()
static const QQmlModuleRegistration registration("QtQml", qml_register_types_QtQml)
QQmlPrivate::QQmlAttachedPropertiesFunc< QObject > QQmlAttachedPropertiesFunc
Definition qqmlprivate.h:62
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
SSL_CTX int(*) void arg)
#define qUtf8Printable(string)
Definition qstring.h:1395
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
#define QStringLiteral(str)
#define Q_UNUSED(x)
unsigned int quint32
Definition qtypes.h:45
short qint16
Definition qtypes.h:42
unsigned short quint16
Definition qtypes.h:43
size_t quintptr
Definition qtypes.h:72
int qint32
Definition qtypes.h:44
unsigned long long quint64
Definition qtypes.h:56
unsigned int uint
Definition qtypes.h:29
long long qint64
Definition qtypes.h:55
QT_BEGIN_NAMESPACE typedef signed char qint8
Definition qtypes.h:40
unsigned char quint8
Definition qtypes.h:41
const char property[13]
Definition qwizard.cpp:101
obj metaObject() -> className()
QVariant variant
[1]
QFrame frame
[0]
view create()
QJSValueList args
QJSValue global
QJSEngine engine
[0]
static Q_CORE_EXPORT int signalIndex(const QMetaMethod &m)
\inmodule QtCore
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or \nullptr if there is no such object.
void initLoadContextIdLookup(uint index) const
Definition qqml.cpp:1562
void initSetObjectLookup(uint index, QObject *object, QMetaType type) const
Definition qqml.cpp:2032
bool loadScopeObjectPropertyLookup(uint index, void *target) const
Definition qqml.cpp:1653
bool callGlobalLookup(uint index, void **args, const QMetaType *types, int argc) const
Definition qqml.cpp:1612
bool captureLookup(uint index, QObject *object) const
Definition qqml.cpp:1261
bool captureQmlContextPropertyLookup(uint index) const
Definition qqml.cpp:1289
void initSetValueLookup(uint index, const QMetaObject *metaObject, QMetaType type) const
Definition qqml.cpp:2076
void initCallObjectPropertyLookup(uint index) const
Definition qqml.cpp:1605
void initLoadScopeObjectPropertyLookup(uint index, QMetaType type) const
Definition qqml.cpp:1680
void initGetEnumLookup(uint index, const QMetaObject *metaObject, const char *enumerator, const char *enumValue) const
Definition qqml.cpp:1977
void setInstructionPointer(int offset) const
Definition qqml.cpp:826
QJSValue jsMetaType(int index) const
Definition qqml.cpp:820
bool loadAttachedLookup(uint index, QObject *object, void *target) const
Definition qqml.cpp:1771
void initLoadGlobalLookup(uint index) const
Definition qqml.cpp:1646
bool setObjectLookup(uint index, QObject *object, void *value) const
Definition qqml.cpp:1996
bool getObjectLookup(uint index, QObject *object, void *target) const
Definition qqml.cpp:1842
bool loadSingletonLookup(uint index, void *target) const
Definition qqml.cpp:1705
void initGetValueLookup(uint index, const QMetaObject *metaObject, QMetaType type) const
Definition qqml.cpp:1926
QVariant constructValueType(QMetaType resultMetaType, const QMetaObject *resultMetaObject, int ctorIndex, void *ctorArg) const
Definition qqml.cpp:1496
void initCallGlobalLookup(uint index) const
Definition qqml.cpp:1629
QMetaType lookupResultMetaType(uint index) const
Definition qqml.cpp:1326
bool callQmlContextPropertyLookup(uint index, void **args, const QMetaType *types, int argc) const
Definition qqml.cpp:1504
bool getEnumLookup(uint index, void *target) const
Definition qqml.cpp:1937
void writeToConsole(QtMsgType type, const QString &message, const QLoggingCategory *loggingCategory) const
Definition qqml.cpp:1467
QString translationContext() const
Definition qqml.cpp:1317
void initLoadSingletonLookup(uint index, uint importNamespace) const
Definition qqml.cpp:1765
void setReturnValueUndefined() const
Definition qqml.cpp:832
QQmlEngine * qmlEngine() const
Definition qqml.cpp:815
bool loadContextIdLookup(uint index, void *target) const
Definition qqml.cpp:1530
const QLoggingCategory * resolveLoggingCategory(QObject *wrapper, bool *ok) const
Definition qqml.cpp:1446
void storeNameSloppy(uint nameIndex, void *value, QMetaType type) const
Definition qqml.cpp:1373
bool callObjectPropertyLookup(uint index, QObject *object, void **args, const QMetaType *types, int argc) const
Definition qqml.cpp:1587
void initGetObjectLookup(uint index, QObject *object, QMetaType type) const
Definition qqml.cpp:1880
void initLoadAttachedLookup(uint index, uint importNamespace, QObject *object) const
Definition qqml.cpp:1786
bool getValueLookup(uint index, void *value, void *target) const
Definition qqml.cpp:1907
QJSValue javaScriptGlobalProperty(uint nameIndex) const
Definition qqml.cpp:1438
QV4::ExecutableCompilationUnit * compilationUnit
QObject * thisObject() const
Definition qqml.cpp:809
bool loadGlobalLookup(uint index, void *target, QMetaType type) const
Definition qqml.cpp:1636
bool setValueLookup(uint index, void *target, void *value) const
Definition qqml.cpp:2059
void initLoadTypeLookup(uint index, uint importNamespace) const
Definition qqml.cpp:1836
void initCallQmlContextPropertyLookup(uint index) const
Definition qqml.cpp:1523
bool loadTypeLookup(uint index, void *target) const
Definition qqml.cpp:1815
static QMetaSequence sequence()
static QMetaType list()
static QMetaType self()
std::function< QObject *(QQmlEngine *, QJSEngine *)> qObjectApi
QQmlCustomParser * customParser
void(* create)(void *, void *)
QObject * operator()(QQmlEngine *, QJSEngine *)
Definition qqml.cpp:384
const QQmlImportRef * importNamespace
IdentifierTable * identifierTable
CppStackFrame * currentStackFrame
static bool metaTypeFromJS(const Value &value, QMetaType type, void *data)
ReturnedValue throwError(const Value &value)
QV4::ReturnedValue fromVariant(const QVariant &)
String * id_destroy() const
String * id_toString() const
QV4::ReturnedValue metaTypeToJS(QMetaType type, const void *data)
ReturnedValue throwTypeError()
ReturnedValue asReturnedValue() const
Definition qv4value_p.h:339
QString toQString() const
Definition qv4string_p.h:92
PropertyKey asPropertyKey(const Heap::String *str)
ReturnedValue(* globalGetter)(Lookup *l, ExecutionEngine *engine)
Definition qv4lookup_p.h:37
const QQmlPropertyData * propertyData
Definition qv4lookup_p.h:96
struct QV4::Lookup::@576::@611 qmlEnumValueLookup
struct QV4::Lookup::@576::@601 qobjectLookup
struct QV4::Lookup::@576::@606 qmlContextSingletonLookup
struct QV4::Lookup::@576::@604 qgadgetLookup
ReturnedValue encodedEnumValue
Heap::Base * qmlTypeWrapper
ReturnedValue(* qmlContextPropertyGetter)(Lookup *l, ExecutionEngine *engine, Value *thisObject)
Definition qv4lookup_p.h:38
static ReturnedValue getterQObject(Lookup *l, ExecutionEngine *engine, const Value &object)
static ReturnedValue getterQObjectAsVariant(Lookup *l, ExecutionEngine *engine, const Value &object)
static bool setterQObjectAsVariant(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value)
static bool setterQObject(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value)
ReturnedValue(* getter)(Lookup *l, ExecutionEngine *engine, const Value &object)
Definition qv4lookup_p.h:36
const QtPrivate::QMetaTypeInterface * metaType
quintptr isConstant
struct QV4::Lookup::@576::@603 qobjectFallbackLookup
Heap::Base * singletonObject
static bool setterFallbackAsVariant(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value)
quintptr metaObject
bool(* setter)(Lookup *l, ExecutionEngine *engine, Value &object, const Value &v)
Definition qv4lookup_p.h:39
static ReturnedValue getterFallback(Lookup *l, ExecutionEngine *engine, const Value &object)
static ReturnedValue getterFallbackAsVariant(Lookup *l, ExecutionEngine *engine, const Value &object)
void releasePropertyCache()
static bool setterFallback(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value)
struct QV4::Lookup::@576::@607 qmlContextIdObjectLookup
struct QV4::Lookup::@576::@609 qmlTypeLookup
const QQmlPropertyCache * propertyCache
Definition qv4lookup_p.h:95
static ReturnedValue lookupAttached(Lookup *l, ExecutionEngine *engine, const Value &object)
static ReturnedValue wrap(ExecutionEngine *engine, QObject *object)
static ReturnedValue lookupSingleton(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupContextObjectProperty(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupIdObjectInParentContext(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupIdObject(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupScopeObjectProperty(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupScopeFallbackProperty(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupType(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue create(ExecutionEngine *, QObject *, const QQmlType &, Heap::QQmlTypeWrapper::TypeNameMode=Heap::QQmlTypeWrapper::IncludeEnums)
static ReturnedValue lookupEnumValue(Lookup *l, ExecutionEngine *engine, const Value &base)
static ReturnedValue lookupSingletonProperty(Lookup *l, ExecutionEngine *engine, const Value &base)
static bool lookupSetter(QV4::Lookup *l, QV4::ExecutionEngine *engine, QV4::Value &object, const QV4::Value &value)
static ReturnedValue lookupGetter(Lookup *lookup, ExecutionEngine *engine, const Value &object)
bool hasException() const
ExecutionEngine * engine
void wrapper()