Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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/qqmlbuiltinfunctions_p.h>
10#include <private/qqmlcomponent_p.h>
11#include <private/qqmlengine_p.h>
12#include <private/qqmlfinalizer_p.h>
13#include <private/qqmlloggingcategorybase_p.h>
14#include <private/qqmlmetatype_p.h>
15#include <private/qqmlmetatypedata_p.h>
16#include <private/qqmltype_p_p.h>
17#include <private/qqmltypemodule_p.h>
18#include <private/qqmltypewrapper_p.h>
19#include <private/qqmlvaluetypewrapper_p.h>
20#include <private/qv4dateobject_p.h>
21#include <private/qv4errorobject_p.h>
22#include <private/qv4identifiertable_p.h>
23#include <private/qv4lookup_p.h>
24#include <private/qv4qobjectwrapper_p.h>
25
26#include <QtCore/qmutex.h>
27
29
47{
48 QQmlData *data = QQmlData::get(object);
49
50 if (!data
51 || !data->context
52 || !data->context->engine()
53 || data->deferredData.isEmpty()
54 || data->wasDeleted(object)) {
55 return;
56 }
57
58 if (!data->propertyCache)
59 data->propertyCache = QQmlMetaType::propertyCache(object->metaObject());
60
61 QQmlEnginePrivate *ep = QQmlEnginePrivate::get(data->context->engine());
62
65
66 // Release the reference for the deferral action (we still have one from construction)
67 data->releaseDeferredData();
68
70}
71
76
78{
80 if (!data || !data->context)
81 return nullptr;
82 return data->context->engine();
83}
84
86 QObject *object, bool create)
87{
88 if (!pf)
89 return nullptr;
90
91 QObject *rv = data->hasExtendedData() ? data->attachedProperties()->value(pf) : 0;
92 if (rv || !create)
93 return rv;
94
95 rv = pf(object);
96
97 if (rv)
98 data->attachedProperties()->insert(pf, rv);
99
100 return rv;
101}
102
104 const QMetaObject *attachedMetaObject)
105{
106 QQmlEngine *engine = object ? qmlEngine(object) : nullptr;
108 attachedMetaObject);
109}
110
112{
113 if (!object)
114 return nullptr;
115
116 QQmlData *data = QQmlData::get(object, create);
117
118 // Attached properties are only on objects created by QML,
119 // unless explicitly requested (create==true)
120 if (!data)
121 return nullptr;
122
123 return resolveAttachedProperties(func, data, object, create);
124}
125
127{
128 return QQmlPrivate::qmlExtendedObject(object, 0);
129}
130
132{
133 if (!object)
134 return nullptr;
135
136 void *result = nullptr;
138 if (!d->metaObject)
139 return nullptr;
140
141 const int id = d->metaObject->metaCall(
145 return nullptr;
146
147 return static_cast<QObject *>(result);
148}
149
152{
153 switch (warning) {
155 qWarning().nospace()
156 << metaType.name()
157 << " is neither a default constructible QObject, nor a default- "
158 << "and copy-constructible Q_GADGET, nor marked as uncreatable.\n"
159 << "You should not use it as a QML type.";
160 break;
162 qWarning()
163 << "Singleton" << metaType.name()
164 << "needs to be a concrete class with either a default constructor"
165 << "or, when adding a default constructor is infeasible, a public static"
166 << "create(QQmlEngine *, QJSEngine *) method.";
167 break;
169 qWarning()
170 << metaType.name()
171 << "is not a QObject, but has attached properties. This won't work.";
172 break;
173 }
174}
175
177 QV4::ExecutableCompilationUnit *unit, const QString &elementName)
178{
180 unit->baseCompilationUnit(), unit->engine->typeLoader(), elementName)
181 .typeId();
182}
183
185 QV4::ExecutableCompilationUnit *unit, const QString &elementName)
186{
188 unit->baseCompilationUnit(), unit->engine->typeLoader(), elementName)
189 .qListTypeId();
190}
191
193 const char *uri, int versionMajor,
194 int versionMinor, const char *qmlName,
195 const QString& reason)
196{
199 QMetaType(),
200 QMetaType(),
201 0,
202 nullptr,
203 nullptr,
204 reason,
205 nullptr,
206
207 uri, QTypeRevision::fromVersion(versionMajor, versionMinor), qmlName, &staticMetaObject,
208
210 nullptr,
211
212 -1,
213 -1,
214 -1,
215
216 nullptr, nullptr,
217
218 nullptr,
220 -1,
222 };
223
225}
226
227void qmlClearTypeRegistrations() // Declared in qqml.h
228{
230 QQmlEnginePrivate::baseModulesUninitialized = true; //So the engine re-registers its types
232}
233
234//From qqml.h
235bool qmlProtectModule(const char *uri, int majVersion)
236{
239}
240
241//From qqml.h
242void qmlRegisterModule(const char *uri, int versionMajor, int versionMinor)
243{
244 QQmlMetaType::registerModule(uri, QTypeRevision::fromVersion(versionMajor, versionMinor));
245}
246
247static QQmlDirParser::Import resolveImport(const QString &uri, int importMajor, int importMinor)
248{
249 if (importMajor == QQmlModuleImportAuto)
251 else if (importMajor == QQmlModuleImportLatest)
253 else if (importMinor == QQmlModuleImportLatest)
256}
257
258static QTypeRevision resolveModuleVersion(int moduleMajor)
259{
260 return moduleMajor == QQmlModuleImportModuleAny
261 ? QTypeRevision()
262 : QTypeRevision::fromMajorVersion(moduleMajor);
263}
264
325void qmlRegisterModuleImport(const char *uri, int moduleMajor,
326 const char *import, int importMajor, int importMinor)
327{
329 QString::fromUtf8(uri), resolveModuleVersion(moduleMajor),
330 resolveImport(QString::fromUtf8(import), importMajor, importMinor));
331}
332
333
345void qmlUnregisterModuleImport(const char *uri, int moduleMajor,
346 const char *import, int importMajor, int importMinor)
347{
349 QString::fromUtf8(uri), resolveModuleVersion(moduleMajor),
350 resolveImport(QString::fromUtf8(import), importMajor, importMinor));
351}
352
353//From qqml.h
354int qmlTypeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
355{
356 auto revision = QTypeRevision::fromVersion(versionMajor, versionMinor);
357 int id = QQmlMetaType::typeId(uri, revision, qmlName);
358 if (id != -1)
359 return id;
360 /* If the module hasn't been imported yet, we might not have the id of a
361 singleton at this point. To obtain it, we need an engine in order to
362 to do the resolution steps.
363 This is expensive, but we assume that users don't constantly query invalid
364 Types; internal code should use QQmlMetaType API.
365 */
367 auto *enginePriv = QQmlEnginePrivate::get(&engine);
368 auto loadHelper = QQml::makeRefPointer<LoadHelper>(&enginePriv->typeLoader, uri);
369 auto type = loadHelper->resolveType(qmlName).type;
370 if (type.availableInVersion(revision))
371 return type.index();
372 else
373 return -1;
374}
375
377{
378 if (!instance) {
380 error.setDescription(QStringLiteral("The registered singleton has already been deleted. "
381 "Ensure that it outlives the engine."));
383 return false;
384 }
385
386 if (engine->thread() != instance->thread()) {
388 error.setDescription(QStringLiteral("Registered object must live in the same thread "
389 "as the engine it was registered with"));
391 return false;
392 }
393
394 return true;
395}
396
397// From qqmlprivate.h
398#if QT_DEPRECATED_SINCE(6, 3)
399QObject *QQmlPrivate::SingletonFunctor::operator()(QQmlEngine *qeng, QJSEngine *)
400{
401 if (!checkSingletonInstance(qeng, m_object))
402 return nullptr;
403
404 if (alreadyCalled) {
406 error.setDescription(QStringLiteral("Singleton registered by registerSingletonInstance "
407 "must only be accessed from one engine"));
408 QQmlEnginePrivate::get(qeng)->warning(qeng, error);
409 return nullptr;
410 }
411
412 alreadyCalled = true;
414 return m_object;
415};
416#endif
417
419{
421 return nullptr;
422
423 if (!m_engine) {
424 m_engine = qeng;
426 } else if (m_engine != qeng) {
428 error.setDescription(QLatin1String("Singleton registered by registerSingletonInstance must only be accessed from one engine"));
429 QQmlEnginePrivate::get(qeng)->warning(qeng, error);
430 return nullptr;
431 }
432
433 return m_object;
434};
435
436static QVector<QTypeRevision> availableRevisions(const QMetaObject *metaObject)
437{
438 QVector<QTypeRevision> revisions;
439 if (!metaObject)
440 return revisions;
441 const int propertyOffset = metaObject->propertyOffset();
442 const int propertyCount = metaObject->propertyCount();
443 for (int coreIndex = propertyOffset, propertyEnd = propertyOffset + propertyCount;
444 coreIndex < propertyEnd; ++coreIndex) {
445 const QMetaProperty property = metaObject->property(coreIndex);
446 if (int revision = property.revision())
447 revisions.append(QTypeRevision::fromEncodedVersion(revision));
448 }
449 const int methodOffset = metaObject->methodOffset();
450 const int methodCount = metaObject->methodCount();
451 for (int methodIndex = methodOffset, methodEnd = methodOffset + methodCount;
452 methodIndex < methodEnd; ++methodIndex) {
453 const QMetaMethod method = metaObject->method(methodIndex);
454 if (int revision = method.revision())
455 revisions.append(QTypeRevision::fromEncodedVersion(revision));
456 }
457
458 // Need to also check parent meta objects, as their revisions are inherited.
459 if (const QMetaObject *superMeta = metaObject->superClass())
460 revisions += availableRevisions(superMeta);
461
462 return revisions;
463}
464
465template<typename Registration>
466void assignVersions(Registration *registration, QTypeRevision revision,
467 QTypeRevision defaultVersion)
468{
469 const quint8 majorVersion = revision.hasMajorVersion() ? revision.majorVersion()
470 : defaultVersion.majorVersion();
471 registration->version = revision.hasMinorVersion()
472 ? QTypeRevision::fromVersion(majorVersion, revision.minorVersion())
473 : QTypeRevision::fromMajorVersion(majorVersion);
474 registration->revision = revision;
475}
476
477static QVector<QTypeRevision> prepareRevisions(const QMetaObject *metaObject, QTypeRevision added)
478{
479 auto revisions = availableRevisions(metaObject);
480 revisions.append(added);
481 return revisions;
482}
483
484static void uniqueRevisions(QVector<QTypeRevision> *revisions, QTypeRevision defaultVersion,
485 QTypeRevision added)
486{
487 bool revisionsHaveMajorVersions = false;
488 for (QTypeRevision revision : QVector<QTypeRevision>(*revisions)) { // yes, copy
489 // allow any minor version for each explicitly specified past major one
490 if (revision.hasMajorVersion()) {
491 revisionsHaveMajorVersions = true;
492 if (revision.majorVersion() < defaultVersion.majorVersion())
493 revisions->append(QTypeRevision::fromVersion(revision.majorVersion(), 254));
494 }
495 }
496
497 if (revisionsHaveMajorVersions) {
498 if (!added.hasMajorVersion()) {
499 // If added in unspecified major version, assume default one.
500 revisions->append(QTypeRevision::fromVersion(defaultVersion.majorVersion(),
501 added.minorVersion()));
502 } else if (added.majorVersion() < defaultVersion.majorVersion()) {
503 // If added in past major version, add .0 of default version.
504 revisions->append(QTypeRevision::fromVersion(defaultVersion.majorVersion(), 0));
505 }
506 }
507
508 std::sort(revisions->begin(), revisions->end());
509 const auto it = std::unique(revisions->begin(), revisions->end());
510 revisions->erase(it, revisions->end());
511}
512
515{
517 siinfo->scriptCallback = type.scriptApi;
518 siinfo->qobjectCallback = type.qObjectApi;
519 siinfo->typeName = type.typeName;
522}
523
533
534static int finalizeType(const QQmlType &dtype)
535{
536 if (!dtype.isValid())
537 return -1;
538
540 return dtype.index();
541}
542
543using ElementNames = QVarLengthArray<const char *, 8>;
545{
547 const char *key = "QML.Element";
548
549 const int offset = metaObject->classInfoOffset();
550 const int start = metaObject->classInfoCount() + offset - 1;
551
552 ElementNames elementNames;
553
554 for (int i = start; i >= offset; --i) {
555 const QMetaClassInfo classInfo = metaObject->classInfo(i);
556 if (qstrcmp(key, classInfo.name()) == 0) {
557 const char *elementName = classInfo.value();
558
559 if (qstrcmp(elementName, "auto") == 0) {
560 const char *strippedClassName = metaObject->className();
561 for (const char *c = strippedClassName; *c != '\0'; c++) {
562 if (*c == ':')
563 strippedClassName = c + 1;
564 }
565 elementName = strippedClassName;
566 } else if (qstrcmp(elementName, "anonymous") == 0) {
567 if (elementNames.isEmpty())
568 elementNames.push_back(nullptr);
569 else if (elementNames[0] != nullptr)
570 qWarning() << metaObject->className() << "is both anonymous and named";
571 continue;
572 }
573
574 if (!elementNames.isEmpty() && elementNames[0] == nullptr) {
575 qWarning() << metaObject->className() << "is both anonymous and named";
576 elementNames[0] = elementName;
577 } else {
578 elementNames.push_back(elementName);
579 }
580 }
581 }
582
583 return elementNames;
584}
585
587{
588 AliasRegistrar(const ElementNames *elementNames) : elementNames(elementNames) {}
589
590 void registerAliases(int typeId)
591 {
592 if (elementNames) {
593 for (int i = 1, end = elementNames->length(); i < end; ++i)
594 otherNames.append(QString::fromUtf8(elementNames->at(i)));
595 elementNames = nullptr;
596 }
597
598 for (const QString &otherName : std::as_const(otherNames))
599 QQmlMetaType::registerTypeAlias(typeId, otherName);
600 }
601
602private:
603 const ElementNames *elementNames;
604 QVarLengthArray<QString, 8> otherNames;
605};
606
607
610 const ElementNames &elementNames)
611{
612 using namespace QQmlPrivate;
613
614 const bool isValueType = !(type.typeId.flags() & QMetaType::PointerToQObject);
615 const bool creatable = (elementNames[0] != nullptr || isValueType)
616 && boolClassInfo(type.classInfoMetaObject, "QML.Creatable", true);
617
618 QString noCreateReason;
620
621 if (!creatable) {
622 noCreateReason = QString::fromUtf8(
623 classInfo(type.classInfoMetaObject, "QML.UncreatableReason"));
624 if (noCreateReason.isEmpty())
625 noCreateReason = QLatin1String("Type cannot be created in QML.");
626 } else if (isValueType) {
627 const char *method = classInfo(type.classInfoMetaObject, "QML.CreationMethod");
628 if (qstrcmp(method, "structured") == 0)
630 else if (qstrcmp(method, "construct") == 0)
631 creationMethod = ValueTypeCreationMethod::Construct;
632 }
633
634 RegisterType typeRevision = {
636 type.typeId,
637 type.listId,
638 creatable ? type.objectSize : 0,
639 nullptr,
640 nullptr,
641 noCreateReason,
642 type.createValueType,
643 type.uri,
644 type.version,
645 nullptr,
647 type.attachedPropertiesFunction,
648 type.attachedPropertiesMetaObject,
649 type.parserStatusCast,
650 type.valueSourceCast,
651 type.valueInterceptorCast,
652 type.extensionObjectCreate,
653 type.extensionMetaObject,
654 nullptr,
656 type.structVersion > 0 ? type.finalizerCast : -1,
657 creationMethod
658 };
659
661 0,
662 type.uri,
663 type.version,
664 nullptr,
665 type.listId,
666 type.structVersion > 1 ? type.listMetaSequence : QMetaSequence(),
668 };
669
670 const QTypeRevision added = revisionClassInfo(
671 type.classInfoMetaObject, "QML.AddedInVersion",
672 QTypeRevision::fromVersion(type.version.majorVersion(), 0));
673 const QTypeRevision removed = revisionClassInfo(
674 type.classInfoMetaObject, "QML.RemovedInVersion");
675 const QList<QTypeRevision> furtherRevisions = revisionClassInfos(type.classInfoMetaObject,
676 "QML.ExtraVersion");
677
678 auto revisions = prepareRevisions(type.metaObject, added) + furtherRevisions;
679 if (type.attachedPropertiesMetaObject)
680 revisions += availableRevisions(type.attachedPropertiesMetaObject);
681 uniqueRevisions(&revisions, type.version, added);
682
683 AliasRegistrar aliasRegistrar(&elementNames);
684 for (QTypeRevision revision : revisions) {
685 if (revision.hasMajorVersion() && revision.majorVersion() > type.version.majorVersion())
686 break;
687
688 assignVersions(&typeRevision, revision, type.version);
689
690 // When removed or before added, we still add revisions, but anonymous ones
691 if (typeRevision.version < added
692 || (removed.isValid() && !(typeRevision.version < removed))) {
693 typeRevision.elementName = nullptr;
694 typeRevision.create = nullptr;
695 typeRevision.userdata = nullptr;
696 } else {
697 typeRevision.elementName = elementNames[0];
698 typeRevision.create = creatable ? type.create : nullptr;
699 typeRevision.userdata = type.userdata;
700 }
701
702 typeRevision.customParser = type.customParserFactory();
703 const int id = qmlregister(TypeRegistration, &typeRevision);
704 if (type.qmlTypeIds)
705 type.qmlTypeIds->append(id);
706
707 if (typeRevision.elementName)
708 aliasRegistrar.registerAliases(id);
709
710 if (sequenceRevision.metaSequence != QMetaSequence()) {
711 sequenceRevision.version = typeRevision.version;
712 sequenceRevision.revision = typeRevision.revision;
713 const int id = QQmlPrivate::qmlregister(
715 if (type.qmlTypeIds)
716 type.qmlTypeIds->append(id);
717 }
718 }
719}
720
723 const ElementNames &elementNames)
724{
725 using namespace QQmlPrivate;
726
727 RegisterSingletonType revisionRegistration = {
728 0,
729 type.uri,
730 type.version,
731 elementNames[0],
732 nullptr,
733 type.qObjectApi,
734 type.instanceMetaObject,
735 type.typeId,
736 type.extensionObjectCreate,
737 type.extensionMetaObject,
739 };
741 = singletonInstanceInfo(revisionRegistration);
742
743 const QTypeRevision added = revisionClassInfo(
744 type.classInfoMetaObject, "QML.AddedInVersion",
745 QTypeRevision::fromVersion(type.version.majorVersion(), 0));
746 const QTypeRevision removed = revisionClassInfo(
747 type.classInfoMetaObject, "QML.RemovedInVersion");
748 const QList<QTypeRevision> furtherRevisions = revisionClassInfos(type.classInfoMetaObject,
749 "QML.ExtraVersion");
750
751 auto revisions = prepareRevisions(type.instanceMetaObject, added) + furtherRevisions;
752 uniqueRevisions(&revisions, type.version, added);
753
754 AliasRegistrar aliasRegistrar(&elementNames);
755 for (QTypeRevision revision : std::as_const(revisions)) {
756 if (revision.hasMajorVersion() && revision.majorVersion() > type.version.majorVersion())
757 break;
758
759 assignVersions(&revisionRegistration, revision, type.version);
760
761 // When removed or before added, we still add revisions, but anonymous ones
762 if (revisionRegistration.version < added
763 || (removed.isValid() && !(revisionRegistration.version < removed))) {
764 revisionRegistration.typeName = nullptr;
765 revisionRegistration.qObjectApi = nullptr;
766 } else {
767 revisionRegistration.typeName = elementNames[0];
768 revisionRegistration.qObjectApi = type.qObjectApi;
769 }
770
771 const int id = finalizeType(
772 QQmlMetaType::registerSingletonType(revisionRegistration, siinfo));
773 if (type.qmlTypeIds)
774 type.qmlTypeIds->append(id);
775
776 if (revisionRegistration.typeName)
777 aliasRegistrar.registerAliases(id);
778 }
779}
780
781/*
782This method is "over generalized" to allow us to (potentially) register more types of things in
783the future without adding exported symbols.
784*/
786{
787 switch (type) {
790 *reinterpret_cast<RegisterAutoParent *>(data));
793 *reinterpret_cast<RegisterQmlUnitCacheHook *>(data));
795 const RegisterTypeAndRevisions &type = *reinterpret_cast<RegisterTypeAndRevisions *>(data);
796 if (type.structVersion > 1 && type.forceAnonymous) {
798 } else {
799 const ElementNames names = classElementNames(type.classInfoMetaObject);
800 if (names.isEmpty()) {
801 qWarning().nospace() << "Missing QML.Element class info for "
802 << type.classInfoMetaObject->className();
803 } else {
805 }
806
807 }
808 break;
809 }
812 = *reinterpret_cast<RegisterSingletonTypeAndRevisions *>(data);
813 const ElementNames names = classElementNames(type.classInfoMetaObject);
814 if (names.isEmpty()) {
815 qWarning().nospace() << "Missing QML.Element class info for "
816 << type.classInfoMetaObject->className();
817 } else {
819 }
820 break;
821 }
824 = *reinterpret_cast<RegisterSequentialContainerAndRevisions *>(data);
825 RegisterSequentialContainer revisionRegistration = {
826 0,
827 type.uri,
828 type.version,
829 nullptr,
830 type.typeId,
831 type.metaSequence,
833 };
834
835 const QTypeRevision added = revisionClassInfo(
836 type.classInfoMetaObject, "QML.AddedInVersion",
838 QList<QTypeRevision> revisions = revisionClassInfos(
839 type.classInfoMetaObject, "QML.ExtraVersion");
840 revisions.append(added);
841 uniqueRevisions(&revisions, type.version, added);
842
843 for (QTypeRevision revision : std::as_const(revisions)) {
844 if (revision < added)
845 continue;
846 if (revision.hasMajorVersion() && revision.majorVersion() > type.version.majorVersion())
847 break;
848
849 assignVersions(&revisionRegistration, revision, type.version);
850 const int id = qmlregister(SequentialContainerRegistration, &revisionRegistration);
851 if (type.qmlTypeIds)
852 type.qmlTypeIds->append(id);
853 }
854 break;
855 }
856 case TypeRegistration:
857 return finalizeType(
858 QQmlMetaType::registerType(*reinterpret_cast<RegisterType *>(data)));
860 return finalizeType(
864 *reinterpret_cast<RegisterSingletonType *>(data),
865 singletonInstanceInfo(*reinterpret_cast<RegisterSingletonType *>(data))));
868 *reinterpret_cast<RegisterCompositeType *>(data)));
871 *reinterpret_cast<RegisterCompositeSingletonType *>(data),
875 *reinterpret_cast<RegisterSequentialContainer *>(data)));
876 default:
877 return -1;
878 }
879
880 return -1;
881}
882
884{
885 switch (type) {
888 break;
891 reinterpret_cast<QmlUnitCacheLookupFunction>(data));
892 break;
895 break;
896 case TypeRegistration:
902 break;
906 // Currently unnecessary. We'd need a special data structure to hold
907 // URI + majorVersion and then we'd iterate the minor versions, look up the
908 // associated QQmlType objects by uri/elementName/major/minor and qmlunregister
909 // each of them.
910 Q_UNREACHABLE();
911 break;
912 }
913}
914
916 const char *key)
917{
918 QList<QTypeRevision> revisions;
919 for (int index = indexOfOwnClassInfo(metaObject, key); index != -1;
921 revisions.push_back(QTypeRevision::fromEncodedVersion(
922 QLatin1StringView(metaObject->classInfo(index).value()).toInt()));
923 }
924 return revisions;
925}
926
928 const char *uri, int versionMajor, int versionMinor,
929 const char *qmlName, const QString &message)
930{
931 return qmlRegisterUncreatableType<QQmlTypeNotAvailable>(
932 uri, versionMajor, versionMinor, qmlName, message);
933}
934
935namespace QQmlPrivate {
936template<>
938 const char *uri, int versionMajor, const QMetaObject *classInfoMetaObject,
939 QVector<int> *qmlTypeIds, const QMetaObject *extension, bool)
940{
941 using T = QQmlTypeNotAvailable;
942
944 3,
947 0,
948 nullptr,
949 nullptr,
950 nullptr,
951
952 uri,
954
955 &QQmlTypeNotAvailable::staticMetaObject,
956 classInfoMetaObject,
957
958 attachedPropertiesFunc<T>(),
959 attachedPropertiesMetaObject<T>(),
960
964
965 nullptr,
966 extension,
967 qmlCreateCustomParser<T>,
968 qmlTypeIds,
970 false,
972 };
973
975}
976
982
987
989{
990 QQmlEngine *engine = aotContext->qmlEngine();
991 return engine ? QQmlEnginePrivate::get(aotContext->qmlEngine())->propertyCapture : nullptr;
992}
993
999
1001{
1002 if (auto *frame = engine->handle()->currentStackFrame)
1003 frame->instructionPointer = offset;
1004}
1005
1007{
1008 if (auto *frame = engine->handle()->currentStackFrame) {
1009 Q_ASSERT(frame->isMetaTypesFrame());
1011 }
1012}
1013
1015 QObject *object, int coreIndex, int notifyIndex, bool isConstant,
1016 const AOTCompiledContext *aotContext)
1017{
1018 if (isConstant)
1019 return;
1020
1021 if (QQmlPropertyCapture *capture = propertyCapture(aotContext))
1022 capture->captureProperty(object, coreIndex, notifyIndex);
1023}
1024
1026 QObject *object, const QQmlPropertyCache *propertyCache,
1027 const QQmlPropertyData *property, const AOTCompiledContext *aotContext)
1028{
1029 if (property->isConstant())
1030 return;
1031
1032 if (QQmlPropertyCapture *capture = propertyCapture(aotContext))
1033 capture->captureProperty(object, propertyCache, property);
1034}
1035
1036static bool inherits(const QQmlPropertyCache *descendent, const QQmlPropertyCache *ancestor)
1037{
1038 for (const QQmlPropertyCache *cache = descendent; cache; cache = cache->parent().data()) {
1039 if (cache == ancestor)
1040 return true;
1041 }
1042 return false;
1043}
1044
1046
1052
1053template<bool StrictType>
1055{
1056 QQmlData *qmlData = QQmlData::get(object);
1057 if (!qmlData)
1058 return {qmlData, ObjectPropertyResult::NeedsInit};
1059 if (qmlData->isQueuedForDeletion)
1060 return {qmlData, ObjectPropertyResult::Deleted};
1062 const QQmlPropertyCache *propertyCache = l->qobjectLookup.propertyCache;
1063 if (StrictType) {
1064 if (qmlData->propertyCache.data() != propertyCache)
1065 return {qmlData, ObjectPropertyResult::NeedsInit};
1066 } else if (!inherits(qmlData->propertyCache.data(), propertyCache)) {
1067 return {qmlData, ObjectPropertyResult::NeedsInit};
1068 }
1069 return {qmlData, ObjectPropertyResult::OK};
1070}
1071
1072template<bool StrictType = false>
1074 QV4::Lookup *l, QObject *object, void *target, const AOTCompiledContext *aotContext)
1075{
1076 const ObjectPropertyQmlData data = findObjectPropertyQmlData<StrictType>(l, object);
1077 if (data.result != ObjectPropertyResult::OK)
1078 return data.result;
1079
1080 const QQmlPropertyData *propertyData = l->qobjectLookup.propertyData;
1081 const int coreIndex = propertyData->coreIndex();
1082 if (data.qmlData->hasPendingBindingBit(coreIndex))
1083 data.qmlData->flushPendingBinding(coreIndex);
1084
1085 captureObjectProperty(object, l->qobjectLookup.propertyCache, propertyData, aotContext);
1086 propertyData->readProperty(object, target);
1088}
1089
1090template<bool StrictType = false>
1092{
1093 const ObjectPropertyQmlData data = findObjectPropertyQmlData<StrictType>(l, object);
1094 if (data.result != ObjectPropertyResult::OK)
1095 return data.result;
1096
1097 l->qobjectLookup.propertyData->writeProperty(object, source, {});
1099}
1100
1107
1109{
1110 QQmlData *qmlData = QQmlData::get(object);
1111 if (qmlData && qmlData->isQueuedForDeletion)
1112 return {qmlData, nullptr, ObjectPropertyResult::Deleted};
1113
1115
1116 const QMetaObject *metaObject
1117 = reinterpret_cast<const QMetaObject *>(l->qobjectFallbackLookup.metaObject - 1);
1118 if (!metaObject || metaObject != object->metaObject())
1119 return {qmlData, nullptr, ObjectPropertyResult::NeedsInit};
1120
1121 return {qmlData, metaObject, ObjectPropertyResult::OK};
1122}
1123
1125 QV4::Lookup *l, QObject *object, void *target, const AOTCompiledContext *aotContext)
1126{
1128 if (data.result != ObjectPropertyResult::OK)
1129 return data.result;
1130
1131 const int coreIndex = l->qobjectFallbackLookup.coreIndex;
1132 if (data.qmlData && data.qmlData->hasPendingBindingBit(coreIndex))
1133 data.qmlData->flushPendingBinding(coreIndex);
1134
1135 captureFallbackProperty(object, coreIndex, l->qobjectFallbackLookup.notifyIndex,
1136 l->qobjectFallbackLookup.isConstant, aotContext);
1137
1138 void *a[] = { target, nullptr };
1139 data.metaObject->metacall(object, QMetaObject::ReadProperty, coreIndex, a);
1140
1142}
1143
1145{
1147 if (data.result != ObjectPropertyResult::OK)
1148 return data.result;
1149
1150 void *a[] = { source, nullptr };
1151 data.metaObject->metacall(
1152 object, QMetaObject::WriteProperty, l->qobjectFallbackLookup.coreIndex, a);
1153
1155}
1156
1158 QV4::Lookup *l, QObject *object, void *target, const AOTCompiledContext *aotContext)
1159{
1160 QVariant *variant = static_cast<QVariant *>(target);
1161 const QMetaType propType = l->qobjectLookup.propertyData->propType();
1162 if (propType == QMetaType::fromType<QVariant>())
1163 return loadObjectProperty<true>(l, object, variant, aotContext);
1164
1165 *variant = QVariant(propType);
1166 return loadObjectProperty<true>(l, object, variant->data(), aotContext);
1167}
1168
1170{
1171 QVariant *variant = static_cast<QVariant *>(source);
1172 const QMetaType propType = l->qobjectLookup.propertyData->propType();
1173 if (propType == QMetaType::fromType<QVariant>())
1174 return writeBackObjectProperty<true>(l, object, variant);
1175
1176 Q_ASSERT(variant->metaType() == propType);
1177 return writeBackObjectProperty<true>(l, object, variant->data());
1178}
1179
1181 QV4::Lookup *l, QObject *object, void *target, const AOTCompiledContext *aotContext)
1182{
1183 const QMetaObject *metaObject
1184 = reinterpret_cast<const QMetaObject *>(l->qobjectFallbackLookup.metaObject - 1);
1186
1187 QVariant *variant = static_cast<QVariant *>(target);
1188 const QMetaType propType = metaObject->property(l->qobjectFallbackLookup.coreIndex).metaType();
1189 if (propType == QMetaType::fromType<QVariant>())
1190 return loadFallbackProperty(l, object, variant, aotContext);
1191
1192 *variant = QVariant(propType);
1193 return loadFallbackProperty(l, object, variant->data(), aotContext);
1194}
1195
1197{
1198 const QMetaObject *metaObject
1199 = reinterpret_cast<const QMetaObject *>(l->qobjectFallbackLookup.metaObject - 1);
1201
1202 QVariant *variant = static_cast<QVariant *>(source);
1203 const QMetaType propType = metaObject->property(l->qobjectFallbackLookup.coreIndex).metaType();
1204 if (propType == QMetaType::fromType<QVariant>())
1205 return writeBackFallbackProperty(l, object, variant);
1206
1207 Q_ASSERT(variant->metaType() == propType);
1208 return writeBackFallbackProperty(l, object, variant->data());
1209}
1210
1211template<bool StrictType, typename Op>
1213{
1214 const ObjectPropertyQmlData data = findObjectPropertyQmlData<StrictType>(l, object);
1215 if (data.result != ObjectPropertyResult::OK)
1216 return data.result;
1217
1218 const QQmlPropertyData *property = l->qobjectLookup.propertyData;
1220 op(property);
1222}
1223
1224template<bool StrictType = false>
1226 QV4::Lookup *l, QObject *object, QV4::ExecutionEngine *v4)
1227{
1228 return changeObjectProperty<StrictType>(l, object, [&](const QQmlPropertyData *property) {
1229 if (property->isResettable()) {
1230 property->resetProperty(object, {});
1231 } else {
1232 v4->throwError(
1233 QLatin1String("Cannot assign [undefined] to ") +
1234 QLatin1String(property->propType().name()));
1235 }
1236 });
1237}
1238
1239template<bool StrictType = false>
1241{
1242 return changeObjectProperty<StrictType>(l, object, [&](const QQmlPropertyData *property) {
1243 property->writeProperty(object, value, {});
1244 });
1245}
1246
1247template<typename Op>
1249{
1251 if (data.result != ObjectPropertyResult::OK)
1252 return data.result;
1253
1254 const int coreIndex = l->qobjectFallbackLookup.coreIndex;
1256
1257 op(data.metaObject, coreIndex);
1258 return ObjectPropertyResult::OK;
1259}
1260
1262{
1263 return changeFallbackProperty(l, object, [&](const QMetaObject *metaObject, int coreIndex) {
1264 void *args[] = { value, nullptr };
1265 metaObject->metacall(object, QMetaObject::WriteProperty, coreIndex, args);
1266 });
1267}
1268
1271{
1272 return changeFallbackProperty(l, object, [&](const QMetaObject *metaObject, int coreIndex) {
1273 if (property->isResettable()) {
1274 void *args[] = { nullptr };
1275 metaObject->metacall(object, QMetaObject::ResetProperty, coreIndex, args);
1276 } else {
1277 v4->throwError(
1278 QLatin1String("Cannot assign [undefined] to ") +
1279 QLatin1String(property->typeName()));
1280 }
1281 });
1282}
1283
1284static bool isTypeCompatible(QMetaType lookupType, QMetaType propertyType)
1285{
1286 if (!lookupType.isValid()) {
1287 // If type is invalid, then the calling code depends on the lookup
1288 // to be set up in order to query the type, via lookupResultMetaType.
1289 // We cannot verify the type in this case.
1290 } else if ((lookupType.flags() & QMetaType::IsQmlList)
1291 && (propertyType.flags() & QMetaType::IsQmlList)) {
1292 // We want to check the value types here, but we cannot easily do it.
1293 // Internally those are all QObject* lists, though.
1294 } else if (lookupType.flags() & QMetaType::PointerToQObject) {
1295 // We accept any base class as type, too
1296
1297 const QMetaObject *typeMetaObject = lookupType.metaObject();
1298 const QMetaObject *foundMetaObject = propertyType.metaObject();
1299 if (!foundMetaObject)
1300 foundMetaObject = QQmlMetaType::metaObjectForType(propertyType).metaObject();
1301
1302 while (foundMetaObject && foundMetaObject != typeMetaObject)
1303 foundMetaObject = foundMetaObject->superClass();
1304
1305 if (!foundMetaObject)
1306 return false;
1307 } else if (propertyType.flags() & QMetaType::IsEnumeration) {
1308 if (propertyType == lookupType)
1309 return true;
1310
1311 // You can pass the underlying type of an enum.
1312 // We don't want to check for the actual underlying type because
1313 // moc and qmltyperegistrar are not very precise about it. Especially
1314 // the long and longlong types can be ambiguous.
1315
1316 const bool isUnsigned = propertyType.flags() & QMetaType::IsUnsignedEnumeration;
1317 switch (propertyType.sizeOf()) {
1318 case 1:
1319 return isUnsigned
1320 ? lookupType == QMetaType::fromType<quint8>()
1321 : lookupType == QMetaType::fromType<qint8>();
1322 case 2:
1323 return isUnsigned
1324 ? lookupType == QMetaType::fromType<ushort>()
1325 : lookupType == QMetaType::fromType<short>();
1326 case 4:
1327 // The default type, if moc doesn't know the actual enum type, is int.
1328 // However, the compiler can still decide to encode the enum in uint.
1329 // Therefore, we also accept int for uint enums.
1330 // TODO: This is technically UB.
1331 return isUnsigned
1332 ? (lookupType == QMetaType::fromType<int>()
1333 || lookupType == QMetaType::fromType<uint>())
1334 : lookupType == QMetaType::fromType<int>();
1335 case 8:
1336 return isUnsigned
1337 ? lookupType == QMetaType::fromType<qulonglong>()
1338 : lookupType == QMetaType::fromType<qlonglong>();
1339 }
1340
1341 return false;
1342 } else if (propertyType != lookupType) {
1343 return false;
1344 }
1345 return true;
1346}
1347
1349 QV4::ExecutionEngine *v4, QV4::Lookup *l, QObject *object, void *value)
1350{
1351 QVariant *variant = static_cast<QVariant *>(value);
1352 const QMetaType propType = l->qobjectLookup.propertyData->propType();
1353 if (propType == QMetaType::fromType<QVariant>())
1354 return storeObjectProperty<true>(l, object, variant);
1355
1356 if (!variant->isValid())
1357 return resetObjectProperty<true>(l, object, v4);
1358
1359 if (isTypeCompatible(variant->metaType(), propType))
1360 return storeObjectProperty<true>(l, object, variant->data());
1361
1362 QVariant converted(propType);
1363 v4->metaTypeFromJS(v4->fromVariant(*variant), propType, converted.data());
1364 return storeObjectProperty<true>(l, object, converted.data());
1365}
1366
1368 QV4::ExecutionEngine *v4, QV4::Lookup *l, QObject *object, void *value)
1369{
1370 QVariant *variant = static_cast<QVariant *>(value);
1371
1372 const QMetaObject *metaObject
1373 = reinterpret_cast<const QMetaObject *>(l->qobjectFallbackLookup.metaObject - 1);
1375
1376 const QMetaProperty property = metaObject->property(l->qobjectFallbackLookup.coreIndex);
1377 const QMetaType propType = property.metaType();
1378 if (propType == QMetaType::fromType<QVariant>())
1379 return storeFallbackProperty(l, object, variant);
1380
1381 if (!variant->isValid())
1382 return resetFallbackProperty(l, object, &property, v4);
1383
1384 if (isTypeCompatible(variant->metaType(), propType))
1385 return storeFallbackProperty(l, object, variant->data());
1386
1387 QVariant converted(propType);
1388 v4->metaTypeFromJS(v4->fromVariant(*variant), propType, converted.data());
1389 return storeFallbackProperty(l, object, converted.data());
1390}
1391
1393 Failure,
1394 Object,
1395 Fallback,
1398};
1399
1401 const AOTCompiledContext *aotContext, QV4::Lookup *l, QObject *object, QMetaType type)
1402{
1403 QV4::Scope scope(aotContext->engine->handle());
1405 aotContext->compilationUnit->runtimeStrings[l->nameIndex]);
1406
1407 Q_ASSERT(id.isString());
1408
1409 QV4::ScopedString name(scope, id.asStringOrSymbol());
1410
1411 Q_ASSERT(!name->equals(scope.engine->id_toString()));
1412 Q_ASSERT(!name->equals(scope.engine->id_destroy()));
1413
1414 QQmlData *ddata = QQmlData::get(object, true);
1415 Q_ASSERT(ddata);
1416 if (ddata->isQueuedForDeletion)
1417 return ObjectLookupResult::Failure;
1418
1420 if (!ddata->propertyCache) {
1421 property = QQmlPropertyCache::property(object, name, aotContext->qmlContext, nullptr);
1422 } else {
1423 property = ddata->propertyCache->property(
1424 name.getPointer(), object, aotContext->qmlContext);
1425 }
1426
1427 const bool doVariantLookup = type == QMetaType::fromType<QVariant>();
1428 if (!property) {
1429 const QMetaObject *metaObject = object->metaObject();
1430 if (!metaObject)
1431 return ObjectLookupResult::Failure;
1432
1433 const int coreIndex = metaObject->indexOfProperty(
1434 name->toQStringNoThrow().toUtf8().constData());
1435 if (coreIndex < 0)
1436 return ObjectLookupResult::Failure;
1437
1438 const QMetaProperty property = metaObject->property(coreIndex);
1439 if (!doVariantLookup && !isTypeCompatible(type, property.metaType()))
1440 return ObjectLookupResult::Failure;
1441
1443 // & 1 to tell the gc that this is not heap allocated; see markObjects in qv4lookup_p.h
1444 l->qobjectFallbackLookup.metaObject = quintptr(metaObject) + 1;
1445 l->qobjectFallbackLookup.coreIndex = coreIndex;
1446 l->qobjectFallbackLookup.notifyIndex =
1448 l->qobjectFallbackLookup.isConstant = property.isConstant() ? 1 : 0;
1449 return doVariantLookup
1450 ? ObjectLookupResult::FallbackAsVariant
1451 : ObjectLookupResult::Fallback;
1452 }
1453
1454 if (!doVariantLookup && !isTypeCompatible(type, property->propType()))
1455 return ObjectLookupResult::Failure;
1456
1457 Q_ASSERT(ddata->propertyCache);
1458
1460
1461 return doVariantLookup
1462 ? ObjectLookupResult::ObjectAsVariant
1463 : ObjectLookupResult::Object;
1464}
1465
1468{
1470 const QByteArray name = compilationUnit->runtimeStrings[l->nameIndex]->toQString().toUtf8();
1471 const int coreIndex = metaObject->indexOfProperty(name.constData());
1472 QMetaType lookupType = metaObject->property(coreIndex).metaType();
1473 if (!isTypeCompatible(type, lookupType))
1474 return false;
1475 l->qgadgetLookup.metaObject = quintptr(metaObject) + 1;
1476 l->qgadgetLookup.coreIndex = coreIndex;
1477 l->qgadgetLookup.metaType = lookupType.iface();
1478 return true;
1479}
1480
1482{
1483 const int missingLineNumber = engine->currentStackFrame->missingLineNumber();
1484 const int lineNumber = engine->currentStackFrame->lineNumber();
1485 Q_ASSERT(missingLineNumber != lineNumber);
1486
1487 auto amendStackTrace = [&](QV4::StackTrace *stackTrace) {
1488 for (auto it = stackTrace->begin(), end = stackTrace->end(); it != end; ++it) {
1489 if (it->line == missingLineNumber) {
1490 it->line = lineNumber;
1491 break;
1492 }
1493 }
1494 };
1495
1496 amendStackTrace(&engine->exceptionStackTrace);
1497
1498 QV4::Scope scope(engine);
1499 QV4::Scoped<QV4::ErrorObject> error(scope, *engine->exceptionValue);
1500 if (error) // else some other value was thrown
1501 amendStackTrace(error->d()->stackTrace);
1502}
1503
1504
1505bool AOTCompiledContext::captureLookup(uint index, QObject *object) const
1506{
1507 if (!object)
1508 return false;
1509
1510 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
1514 const QQmlPropertyData *property = l->qobjectLookup.propertyData;
1515 QQmlData::flushPendingBinding(object, property->coreIndex());
1516 captureObjectProperty(object, l->qobjectLookup.propertyCache, property, this);
1517 return true;
1518 }
1519
1522 const int coreIndex = l->qobjectFallbackLookup.coreIndex;
1523 QQmlData::flushPendingBinding(object, coreIndex);
1525 object, coreIndex, l->qobjectFallbackLookup.notifyIndex,
1526 l->qobjectFallbackLookup.isConstant, this);
1527 return true;
1528 }
1529
1530 return false;
1531}
1532
1533bool AOTCompiledContext::captureQmlContextPropertyLookup(uint index) const
1534{
1535 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
1538 const QQmlPropertyData *property = l->qobjectLookup.propertyData;
1539 QQmlData::flushPendingBinding(qmlScopeObject, property->coreIndex());
1540 captureObjectProperty(qmlScopeObject, l->qobjectLookup.propertyCache, property, this);
1541 return true;
1542 }
1543
1545 const int coreIndex = l->qobjectFallbackLookup.coreIndex;
1546 QQmlData::flushPendingBinding(qmlScopeObject, coreIndex);
1547 captureFallbackProperty(qmlScopeObject, coreIndex, l->qobjectFallbackLookup.notifyIndex,
1548 l->qobjectFallbackLookup.isConstant, this);
1549 return true;
1550 }
1551
1552 return false;
1553}
1554
1555void AOTCompiledContext::captureTranslation() const
1556{
1557 if (QQmlPropertyCapture *capture = propertyCapture(this))
1558 capture->captureTranslation();
1559}
1560
1561QString AOTCompiledContext::translationContext() const
1562{
1563#if QT_CONFIG(translation)
1564 return QV4::GlobalExtensions::currentTranslationContext(engine->handle());
1565#else
1566 return QString();
1567#endif
1568}
1569
1570QMetaType AOTCompiledContext::lookupResultMetaType(uint index) const
1571{
1572 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
1580 return l->qobjectLookup.propertyData->propType();
1582 return QMetaType(l->qgadgetLookup.metaType);
1584 return QMetaType::fromType<int>();
1589 return QMetaType::fromType<QObject *>();
1590 } else if (l->getter == QV4::Lookup::getterFallback
1596 const QMetaObject *metaObject
1597 = reinterpret_cast<const QMetaObject *>(l->qobjectFallbackLookup.metaObject - 1);
1598 const int coreIndex = l->qobjectFallbackLookup.coreIndex;
1599 return metaObject->property(coreIndex).metaType();
1600 }
1601 return QMetaType();
1602}
1603
1604static bool isUndefined(const void *value, QMetaType type)
1605{
1606 if (type == QMetaType::fromType<QVariant>())
1607 return !static_cast<const QVariant *>(value)->isValid();
1608 if (type == QMetaType::fromType<QJSValue>())
1609 return static_cast<const QJSValue *>(value)->isUndefined();
1610 if (type == QMetaType::fromType<QJSPrimitiveValue>()) {
1611 return static_cast<const QJSPrimitiveValue *>(value)->type()
1613 }
1614 return false;
1615}
1616
1617void AOTCompiledContext::storeNameSloppy(uint nameIndex, void *value, QMetaType type) const
1618{
1619 // We don't really use any part of the lookup machinery here.
1620 // The QV4::Lookup is created on the stack to conveniently get the property cache, and through
1621 // the property cache we store a value into the property.
1622
1623 QV4::Lookup l;
1624 memset(&l, 0, sizeof(QV4::Lookup));
1625 l.nameIndex = nameIndex;
1626 l.forCall = false;
1627 ObjectPropertyResult storeResult = ObjectPropertyResult::NeedsInit;
1628 switch (initObjectLookup(this, &l, qmlScopeObject, QMetaType())) {
1629 case ObjectLookupResult::ObjectAsVariant:
1630 case ObjectLookupResult::Object: {
1631 const QMetaType propType = l.qobjectLookup.propertyData->propType();
1632 if (isTypeCompatible(type, propType)) {
1633 storeResult = storeObjectProperty(&l, qmlScopeObject, value);
1634 } else if (isUndefined(value, type)) {
1635 storeResult = resetObjectProperty(&l, qmlScopeObject, engine->handle());
1636 } else {
1637 QVariant var(propType);
1639 v4->metaTypeFromJS(v4->metaTypeToJS(type, value), propType, var.data());
1640 storeResult = storeObjectProperty(&l, qmlScopeObject, var.data());
1641 }
1642
1643 l.qobjectLookup.propertyCache->release();
1644 break;
1645 }
1646 case ObjectLookupResult::FallbackAsVariant:
1647 case ObjectLookupResult::Fallback: {
1648 const QMetaObject *metaObject
1649 = reinterpret_cast<const QMetaObject *>(l.qobjectFallbackLookup.metaObject - 1);
1650 const QMetaProperty property = metaObject->property(l.qobjectFallbackLookup.coreIndex);
1651 const QMetaType propType = property.metaType();
1652 if (isTypeCompatible(type, propType)) {
1653 storeResult = storeFallbackProperty(&l, qmlScopeObject, value);
1654 } else if (isUndefined(value, type)) {
1655 storeResult = resetFallbackProperty(&l, qmlScopeObject, &property, engine->handle());
1656 } else {
1657 QVariant var(propType);
1659 v4->metaTypeFromJS(v4->metaTypeToJS(type, value), propType, var.data());
1660 storeResult = storeFallbackProperty(&l, qmlScopeObject, var.data());
1661 }
1662 break;
1663 }
1664 case ObjectLookupResult::Failure:
1666 return;
1667 }
1668
1669 switch (storeResult) {
1670 case ObjectPropertyResult::NeedsInit:
1672 break;
1673 case ObjectPropertyResult::Deleted:
1675 QStringLiteral("Value is null and could not be converted to an object"));
1676 break;
1677 case ObjectPropertyResult::OK:
1678 break;
1679 }
1680}
1681
1682QJSValue AOTCompiledContext::javaScriptGlobalProperty(uint nameIndex) const
1683{
1684 QV4::Scope scope(engine->handle());
1685 QV4::ScopedString name(scope, compilationUnit->runtimeStrings[nameIndex]);
1687 return QJSValuePrivate::fromReturnedValue(global->get(name->toPropertyKey()));
1688}
1689
1690const QLoggingCategory *AOTCompiledContext::resolveLoggingCategory(QObject *wrapper, bool *ok) const
1691{
1692 if (wrapper) {
1693 // We have to check this here because you may pass a plain QObject that only
1694 // turns out to be a QQmlLoggingCategoryBase at run time.
1695 if (QQmlLoggingCategoryBase *qQmlLoggingCategory
1696 = qobject_cast<QQmlLoggingCategoryBase *>(wrapper)) {
1697 const QLoggingCategory *loggingCategory = qQmlLoggingCategory->category();
1698 *ok = true;
1699 if (!loggingCategory) {
1701 QStringLiteral("A QmlLoggingCatgory was provided without a valid name"));
1702 }
1703 return loggingCategory;
1704 }
1705 }
1706
1707 *ok = false;
1708 return qmlEngine() ? &lcQml() : &lcJs();
1709}
1710
1711void AOTCompiledContext::writeToConsole(
1712 QtMsgType type, const QString &message, const QLoggingCategory *loggingCategory) const
1713{
1714 Q_ASSERT(loggingCategory->isEnabled(type));
1715
1717 Q_ASSERT(frame);
1718
1719 const QByteArray source(frame->source().toUtf8());
1720 const QByteArray function(frame->function().toUtf8());
1721 QMessageLogger logger(source.constData(), frame->lineNumber(),
1722 function.constData(), loggingCategory->categoryName());
1723
1724 switch (type) {
1725 case QtDebugMsg:
1726 logger.debug("%s", qUtf8Printable(message));
1727 break;
1728 case QtInfoMsg:
1729 logger.info("%s", qUtf8Printable(message));
1730 break;
1731 case QtWarningMsg:
1732 logger.warning("%s", qUtf8Printable(message));
1733 break;
1734 case QtCriticalMsg:
1735 logger.critical("%s", qUtf8Printable(message));
1736 break;
1737 default:
1738 break;
1739 }
1740}
1741
1742QVariant AOTCompiledContext::constructValueType(
1743 QMetaType resultMetaType, const QMetaObject *resultMetaObject,
1744 int ctorIndex, void *ctorArg) const
1745{
1747 resultMetaType, resultMetaObject, ctorIndex, ctorArg);
1748}
1749
1750QDateTime AOTCompiledContext::constructDateTime(double timestamp) const
1751{
1752 return QV4::DateObject::timestampToDateTime(timestamp);
1753}
1754
1755QDateTime AOTCompiledContext::constructDateTime(const QString &string) const
1756{
1758}
1759
1760QDateTime AOTCompiledContext::constructDateTime(
1761 double year, double month, double day, double hours,
1762 double minutes, double seconds, double msecs) const
1763{
1764 return constructDateTime(QV4::DateObject::componentsToTimestamp(
1765 year, month, day, hours, minutes, seconds, msecs, engine->handle()));
1766}
1767
1768bool AOTCompiledContext::callQmlContextPropertyLookup(
1769 uint index, void **args, const QMetaType *types, int argc) const
1770{
1771 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
1772 QV4::Scope scope(engine->handle());
1773 QV4::ScopedValue thisObject(scope);
1775 scope, l->qmlContextPropertyGetter(l, scope.engine, thisObject));
1776 if (!function) {
1777 scope.engine->throwTypeError(
1778 QStringLiteral("Property '%1' of object [null] is not a function").arg(
1779 compilationUnit->runtimeStrings[l->nameIndex]->toQString()));
1780 return false;
1781 }
1782
1783 function->call(qmlScopeObject, args, types, argc);
1784 return !scope.hasException();
1785}
1786
1787void AOTCompiledContext::initCallQmlContextPropertyLookup(uint index) const
1788{
1789 Q_UNUSED(index);
1792}
1793
1794bool AOTCompiledContext::loadContextIdLookup(uint index, void *target) const
1795{
1796 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
1797 int objectId = -1;
1798 QQmlContextData *context = nullptr;
1800
1802 objectId = l->qmlContextIdObjectLookup.objectId;
1803 context = qmlContext;
1804 } else if (l->qmlContextPropertyGetter
1806 QV4::Scope scope(engine->handle());
1807 QV4::ScopedString name(scope, compilationUnit->runtimeStrings[l->nameIndex]);
1808 for (context = qmlContext; context; context = context->parent().data()) {
1809 objectId = context->propertyIndex(name);
1810 if (objectId != -1 && objectId < context->numIdValues())
1811 break;
1812 }
1813 } else {
1814 return false;
1815 }
1816
1817 Q_ASSERT(objectId >= 0);
1818 Q_ASSERT(context != nullptr);
1820 if (QQmlPropertyCapture *capture = engine->propertyCapture)
1821 capture->captureProperty(context->idValueBindings(objectId));
1822 *static_cast<QObject **>(target) = context->idValue(objectId);
1823 return true;
1824}
1825
1826void AOTCompiledContext::initLoadContextIdLookup(uint index) const
1827{
1829 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
1830 QV4::Scope scope(engine->handle());
1831 QV4::ScopedString name(scope, compilationUnit->runtimeStrings[l->nameIndex]);
1832 const QQmlRefPointer<QQmlContextData> ownContext = qmlContext;
1833 for (auto context = ownContext; context; context = context->parent()) {
1834 const int propertyIdx = context->propertyIndex(name);
1835 if (propertyIdx == -1 || propertyIdx >= context->numIdValues())
1836 continue;
1837
1838 if (context.data() == ownContext.data()) {
1839 l->qmlContextIdObjectLookup.objectId = propertyIdx;
1841 } else {
1843 }
1844
1845 return;
1846 }
1847
1848 Q_UNREACHABLE();
1849}
1850
1851bool AOTCompiledContext::callObjectPropertyLookup(
1852 uint index, QObject *object, void **args, const QMetaType *types, int argc) const
1853{
1854 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
1855 QV4::Scope scope(engine->handle());
1856 QV4::ScopedValue thisObject(scope, QV4::QObjectWrapper::wrap(scope.engine, object));
1857 QV4::ScopedFunctionObject function(scope, l->getter(l, engine->handle(), thisObject));
1858 if (!function) {
1859 scope.engine->throwTypeError(
1860 QStringLiteral("Property '%1' of object [object Object] is not a function")
1861 .arg(compilationUnit->runtimeStrings[l->nameIndex]->toQString()));
1862 return false;
1863 }
1864
1865 function->call(object, args, types, argc);
1866 return !scope.hasException();
1867}
1868
1869void AOTCompiledContext::initCallObjectPropertyLookup(uint index) const
1870{
1871 Q_UNUSED(index);
1874}
1875
1876bool AOTCompiledContext::callGlobalLookup(
1877 uint index, void **args, const QMetaType *types, int argc) const
1878{
1879 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
1880 QV4::Scope scope(engine->handle());
1882 if (!function) {
1883 scope.engine->throwTypeError(
1884 QStringLiteral("Property '%1' of object [null] is not a function")
1885 .arg(compilationUnit->runtimeStrings[l->nameIndex]->toQString()));
1886 return false;
1887 }
1888
1889 function->call(nullptr, args, types, argc);
1890 return true;
1891}
1892
1893void AOTCompiledContext::initCallGlobalLookup(uint index) const
1894{
1895 Q_UNUSED(index);
1898}
1899
1900bool AOTCompiledContext::loadGlobalLookup(uint index, void *target, QMetaType type) const
1901{
1902 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
1905 return false;
1906 }
1907 return true;
1908}
1909
1910void AOTCompiledContext::initLoadGlobalLookup(uint index) const
1911{
1912 Q_UNUSED(index);
1915}
1916
1917bool AOTCompiledContext::loadScopeObjectPropertyLookup(uint index, void *target) const
1918{
1919 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
1920
1921 if (!qmlScopeObject) {
1923 compilationUnit->runtimeStrings[l->nameIndex]->toQString());
1924 return false;
1925 }
1926
1927 ObjectPropertyResult result = ObjectPropertyResult::NeedsInit;
1929 result = loadObjectProperty(l, qmlScopeObject, target, this);
1931 result = loadFallbackProperty(l, qmlScopeObject, target, this);
1932 else
1933 return false;
1934
1935 switch (result) {
1936 case ObjectPropertyResult::NeedsInit:
1937 return false;
1938 case ObjectPropertyResult::Deleted:
1940 QStringLiteral("Cannot read property '%1' of null")
1941 .arg(compilationUnit->runtimeStrings[l->nameIndex]->toQString()));
1942 return false;
1943 case ObjectPropertyResult::OK:
1944 return true;
1945 }
1946
1947 Q_UNREACHABLE_RETURN(false);
1948}
1949
1950bool AOTCompiledContext::writeBackScopeObjectPropertyLookup(uint index, void *source) const
1951{
1952 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
1953
1954 ObjectPropertyResult result = ObjectPropertyResult::NeedsInit;
1956 result = writeBackObjectProperty(l, qmlScopeObject, source);
1958 result = writeBackFallbackProperty(l, qmlScopeObject, source);
1959 else
1960 return false;
1961
1962 switch (result) {
1963 case ObjectPropertyResult::NeedsInit:
1964 return false;
1965 case ObjectPropertyResult::Deleted: // Silently omit the write back. Same as interpreter
1966 case ObjectPropertyResult::OK:
1967 return true;
1968 }
1969
1970 Q_UNREACHABLE_RETURN(false);
1971}
1972
1973void AOTCompiledContext::initLoadScopeObjectPropertyLookup(uint index, QMetaType type) const
1974{
1976 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
1977
1978 if (v4->hasException) {
1979 amendException(v4);
1980 return;
1981 }
1982
1983 switch (initObjectLookup(this, l, qmlScopeObject, type)) {
1984 case ObjectLookupResult::ObjectAsVariant:
1985 case ObjectLookupResult::Object:
1987 break;
1988 case ObjectLookupResult::FallbackAsVariant:
1989 case ObjectLookupResult::Fallback:
1991 break;
1992 case ObjectLookupResult::Failure:
1993 v4->throwTypeError();
1994 break;
1995 }
1996}
1997
1998bool AOTCompiledContext::loadSingletonLookup(uint index, void *target) const
1999{
2000 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2001 QV4::Scope scope(engine->handle());
2002
2005 scope, l->qmlContextSingletonLookup.singletonObject);
2006
2007 // We don't handle non-QObject singletons (as those can't be declared in qmltypes anyway)
2009 *static_cast<QObject **>(target) = wrapper->object();
2010 return true;
2011 }
2012
2013 return false;
2014}
2015
2018
2019template<QmlContextPropertyGetter qmlContextPropertyGetter>
2020static void initTypeWrapperLookup(
2021 const AOTCompiledContext *context, QV4::Lookup *l, uint importNamespace)
2022{
2023 Q_ASSERT(!context->engine->hasError());
2024 if (importNamespace != AOTCompiledContext::InvalidStringId) {
2025 QV4::Scope scope(context->engine->handle());
2026 QV4::ScopedString import(scope, context->compilationUnit->runtimeStrings[importNamespace]);
2027
2028 QQmlTypeLoader *typeLoader = scope.engine->typeLoader();
2029 Q_ASSERT(typeLoader);
2030 if (const QQmlImportRef *importRef
2031 = context->qmlContext->imports()->query(import, typeLoader).importNamespace) {
2032
2035 scope.engine, nullptr, context->qmlContext->imports(), importRef));
2036 wrapper = l->qmlContextPropertyGetter(l, context->engine->handle(), wrapper);
2037 l->qmlContextPropertyGetter = qmlContextPropertyGetter;
2038 if (qmlContextPropertyGetter == QV4::QQmlContextWrapper::lookupSingleton)
2039 l->qmlContextSingletonLookup.singletonObject.set(scope.engine, wrapper->heapObject());
2040 else if (qmlContextPropertyGetter == QV4::QQmlContextWrapper::lookupType)
2041 l->qmlTypeLookup.qmlTypeWrapper.set(scope.engine, wrapper->heapObject());
2042 return;
2043 }
2044 scope.engine->throwTypeError();
2045 } else {
2046 QV4::ExecutionEngine *v4 = context->engine->handle();
2047 l->qmlContextPropertyGetter(l, v4, nullptr);
2048 if (l->qmlContextPropertyGetter != qmlContextPropertyGetter) {
2049 const QString error
2050 = QLatin1String(qmlContextPropertyGetter
2052 ? "%1 was a singleton at compile time, "
2053 "but is not a singleton anymore."
2054 : "%1 was not a singleton at compile time, "
2055 "but is a singleton now.")
2056 .arg(context->compilationUnit->runtimeStrings[l->nameIndex]->toQString());
2057 v4->throwTypeError(error);
2058 }
2059 }
2060}
2062void AOTCompiledContext::initLoadSingletonLookup(uint index, uint importNamespace) const
2063{
2064 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2065 initTypeWrapperLookup<QV4::QQmlContextWrapper::lookupSingleton>(this, l, importNamespace);
2066}
2068bool AOTCompiledContext::loadAttachedLookup(uint index, QObject *object, void *target) const
2069{
2070 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2072 return false;
2073
2074 QV4::Scope scope(engine->handle());
2077 *static_cast<QObject **>(target) = qmlAttachedPropertiesObject(
2078 object, wrapper->d()->type().attachedPropertiesFunction(
2080 return true;
2081}
2083void AOTCompiledContext::initLoadAttachedLookup(
2084 uint index, uint importNamespace, QObject *object) const
2085{
2086 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2087 QV4::Scope scope(engine->handle());
2088 QV4::ScopedString name(scope, compilationUnit->runtimeStrings[l->nameIndex]);
2089
2090 QQmlType type;
2091 QQmlTypeLoader *typeLoader = scope.engine->typeLoader();
2092 Q_ASSERT(typeLoader);
2093 if (importNamespace != InvalidStringId) {
2094 QV4::ScopedString import(scope, compilationUnit->runtimeStrings[importNamespace]);
2095 if (const QQmlImportRef *importRef
2096 = qmlContext->imports()->query(import, typeLoader).importNamespace) {
2097 type = qmlContext->imports()->query(name, importRef, typeLoader).type;
2098 }
2099 } else {
2100 type = qmlContext->imports()->query<QQmlImport::AllowRecursion>(name, typeLoader).type;
2101 }
2102
2103 if (!type.isValid()) {
2104 scope.engine->throwTypeError();
2105 return;
2106 }
2107
2109 scope, QV4::QQmlTypeWrapper::create(scope.engine, object, type,
2111
2112 l->qmlTypeLookup.qmlTypeWrapper.set(scope.engine, wrapper->d());
2114}
2116bool AOTCompiledContext::loadTypeLookup(uint index, void *target) const
2117{
2118 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2120 return false;
2121
2122 const QV4::Heap::QQmlTypeWrapper *typeWrapper = static_cast<const QV4::Heap::QQmlTypeWrapper *>(
2123 l->qmlTypeLookup.qmlTypeWrapper.get());
2124
2125 QMetaType metaType = typeWrapper->type().typeId();
2126 *static_cast<const QMetaObject **>(target)
2127 = QQmlMetaType::metaObjectForType(metaType).metaObject();
2128 return true;
2129}
2131void AOTCompiledContext::initLoadTypeLookup(uint index, uint importNamespace) const
2132{
2133 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2134 initTypeWrapperLookup<QV4::QQmlContextWrapper::lookupType>(this, l, importNamespace);
2135}
2137bool AOTCompiledContext::getObjectLookup(uint index, QObject *object, void *target) const
2138{
2139 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2140 const auto doThrow = [&]() {
2142 QStringLiteral("Cannot read property '%1' of null")
2143 .arg(compilationUnit->runtimeStrings[l->nameIndex]->toQString()));
2144 return false;
2145 };
2146
2147 if (!object)
2148 return doThrow();
2149
2150 ObjectPropertyResult result = ObjectPropertyResult::NeedsInit;
2152 result = loadObjectProperty(l, object, target, this);
2153 else if (l->getter == QV4::Lookup::getterFallback)
2154 result = loadFallbackProperty(l, object, target, this);
2156 result = loadObjectAsVariant(l, object, target, this);
2158 result = loadFallbackAsVariant(l, object, target, this);
2159 else
2160 return false;
2161
2162 switch (result) {
2163 case ObjectPropertyResult::Deleted:
2164 return doThrow();
2165 case ObjectPropertyResult::NeedsInit:
2166 return false;
2167 case ObjectPropertyResult::OK:
2168 return true;
2169 }
2170
2171 Q_UNREACHABLE_RETURN(false);
2172}
2174bool AOTCompiledContext::writeBackObjectLookup(uint index, QObject *object, void *source) const
2175{
2176 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2177 if (!object)
2178 return true;
2179
2180 ObjectPropertyResult result = ObjectPropertyResult::NeedsInit;
2183 else if (l->getter == QV4::Lookup::getterFallback)
2189 else
2190 return false;
2191
2192 switch (result) {
2193 case ObjectPropertyResult::NeedsInit:
2194 return false;
2195 case ObjectPropertyResult::Deleted: // Silently omit the write back
2196 case ObjectPropertyResult::OK:
2197 return true;
2198 }
2199
2200 Q_UNREACHABLE_RETURN(false);
2201}
2203void AOTCompiledContext::initGetObjectLookup(uint index, QObject *object, QMetaType type) const
2204{
2206 if (v4->hasException) {
2207 amendException(v4);
2208 } else {
2209 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2210 switch (initObjectLookup(this, l, object, type)) {
2211 case ObjectLookupResult::Object:
2213 break;
2214 case ObjectLookupResult::ObjectAsVariant:
2216 break;
2217 case ObjectLookupResult::Fallback:
2219 break;
2220 case ObjectLookupResult::FallbackAsVariant:
2222 break;
2223 case ObjectLookupResult::Failure:
2225 break;
2226 }
2227 }
2228}
2230bool AOTCompiledContext::getValueLookup(uint index, void *value, void *target) const
2231{
2232 Q_ASSERT(value);
2233
2234 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2236 return false;
2237
2238 const QMetaObject *metaObject
2239 = reinterpret_cast<const QMetaObject *>(l->qgadgetLookup.metaObject - 1);
2241
2242 void *args[] = { target, nullptr };
2243 metaObject->d.static_metacall(
2244 reinterpret_cast<QObject*>(value), QMetaObject::ReadProperty,
2245 l->qgadgetLookup.coreIndex, args);
2246 return true;
2247}
2249bool AOTCompiledContext::writeBackValueLookup(uint index, void *value, void *source) const
2250{
2251 Q_ASSERT(value);
2252
2253 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2255 return false;
2256
2257 const QMetaObject *metaObject
2258 = reinterpret_cast<const QMetaObject *>(l->qgadgetLookup.metaObject - 1);
2260
2261 void *args[] = { source, nullptr };
2262 metaObject->d.static_metacall(
2263 reinterpret_cast<QObject*>(value), QMetaObject::WriteProperty,
2264 l->qgadgetLookup.coreIndex, args);
2265 return true;
2266}
2268void AOTCompiledContext::initGetValueLookup(
2270{
2272 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2273 if (initValueLookup(l, compilationUnit, metaObject, type))
2275 else
2277}
2279bool AOTCompiledContext::getEnumLookup(uint index, void *target) const
2280{
2281 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2283 return false;
2284 const bool isUnsigned
2286 const QV4::ReturnedValue encoded = l->qmlEnumValueLookup.encodedEnumValue;
2287 switch (l->qmlEnumValueLookup.metaType->size) {
2288 case 1:
2289 if (isUnsigned)
2290 *static_cast<quint8 *>(target) = encoded;
2291 else
2292 *static_cast<qint8 *>(target) = encoded;
2293 return true;
2294 case 2:
2295 if (isUnsigned)
2296 *static_cast<quint16 *>(target) = encoded;
2297 else
2298 *static_cast<qint16 *>(target) = encoded;
2299 return true;
2300 case 4:
2301 if (isUnsigned)
2302 *static_cast<quint32 *>(target) = encoded;
2303 else
2304 *static_cast<qint32 *>(target) = encoded;
2305 return true;
2306 case 8:
2307 if (isUnsigned)
2308 *static_cast<quint64 *>(target) = encoded;
2309 else
2310 *static_cast<qint64 *>(target) = encoded;
2311 return true;
2312 default:
2313 break;
2314 }
2315
2316 return false;
2317}
2319void AOTCompiledContext::initGetEnumLookup(
2321 const char *enumerator, const char *enumValue) const
2322{
2324 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2325 if (!metaObject) {
2327 QStringLiteral("Cannot read property '%1' of undefined")
2328 .arg(QString::fromUtf8(enumValue)));
2329 return;
2330 }
2331 const int enumIndex = metaObject->indexOfEnumerator(enumerator);
2332 const QMetaEnum metaEnum = metaObject->enumerator(enumIndex);
2333 l->qmlEnumValueLookup.encodedEnumValue = metaEnum.keyToValue(enumValue);
2334 l->qmlEnumValueLookup.metaType = metaEnum.metaType().iface();
2336}
2338bool AOTCompiledContext::setObjectLookup(uint index, QObject *object, void *value) const
2339{
2340 const auto doThrow = [&]() {
2342 QStringLiteral("Value is null and could not be converted to an object"));
2343 return false;
2344 };
2345
2346 if (!object)
2347 return doThrow();
2348
2349 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2350 ObjectPropertyResult result = ObjectPropertyResult::NeedsInit;
2352 result = storeObjectProperty(l, object, value);
2353 else if (l->setter == QV4::Lookup::setterFallback)
2354 result = storeFallbackProperty(l, object, value);
2356 result = storeObjectAsVariant(engine->handle(), l, object, value);
2359 else
2360 return false;
2361
2362 switch (result) {
2363 case ObjectPropertyResult::Deleted:
2364 return doThrow();
2365 case ObjectPropertyResult::NeedsInit:
2366 return false;
2367 case ObjectPropertyResult::OK:
2368 return true;
2369 }
2370
2371 Q_UNREACHABLE_RETURN(false);
2372}
2374void AOTCompiledContext::initSetObjectLookup(uint index, QObject *object, QMetaType type) const
2375{
2377 if (v4->hasException) {
2378 amendException(v4);
2379 } else {
2380 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2381 switch (initObjectLookup(this, l, object, type)) {
2382 case ObjectLookupResult::Object:
2384 break;
2385 case ObjectLookupResult::ObjectAsVariant:
2387 break;
2388 case ObjectLookupResult::Fallback:
2390 break;
2391 case ObjectLookupResult::FallbackAsVariant:
2393 break;
2394 case ObjectLookupResult::Failure:
2396 break;
2397 }
2398 }
2399}
2401bool AOTCompiledContext::setValueLookup(
2402 uint index, void *target, void *value) const
2403{
2404 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2406 return false;
2407
2408 const QMetaObject *metaObject
2409 = reinterpret_cast<const QMetaObject *>(l->qgadgetLookup.metaObject - 1);
2410
2411 void *args[] = { value, nullptr };
2412 metaObject->d.static_metacall(
2413 reinterpret_cast<QObject*>(target), QMetaObject::WriteProperty,
2414 l->qgadgetLookup.coreIndex, args);
2415 return true;
2416}
2418void AOTCompiledContext::initSetValueLookup(uint index, const QMetaObject *metaObject,
2419 QMetaType type) const
2420{
2422 QV4::Lookup *l = compilationUnit->runtimeLookups + index;
2423 if (initValueLookup(l, compilationUnit, metaObject, type))
2425 else
2427}
2428
2429} // namespace QQmlPrivate
2430
Definition main.cpp:8
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore\reentrant
Definition qdatetime.h:292
The QJSEngine class provides an environment for evaluating JavaScript code.
Definition qjsengine.h:26
QV4::ExecutionEngine * handle() const
Definition qjsengine.h:298
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:197
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:351
int toInt(bool *ok=nullptr, int base=10) const
Definition qlist.h:76
\inmodule QtCore
\inmodule QtCore
Definition qlogging.h:73
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:625
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:727
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:536
void debug(const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(2
Logs a debug message specified with format msg.
Definition qlogging.cpp:389
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore
Definition qmetaobject.h:19
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore
Definition qmetatype.h:342
constexpr TypeFlags flags() const
Definition qmetatype.h:2659
const QtPrivate::QMetaTypeInterface * iface() const
Definition qmetatype.h:772
constexpr qsizetype sizeOf() const
Definition qmetatype.h:2649
bool isValid() const
@ IsUnsignedEnumeration
Definition qmetatype.h:412
@ PointerToQObject
Definition qmetatype.h:407
@ IsEnumeration
Definition qmetatype.h:408
constexpr const QMetaObject * metaObject() const
Definition qmetatype.h:2664
constexpr const char * name() const
Definition qmetatype.h:2681
static QObjectPrivate * get(QObject *o)
Definition qobject_p.h:150
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
QThread * thread() const
Returns the thread in which the object lives.
Definition qobject.cpp:1598
std::vector< ConstructionState > DeferredState
static void completeDeferred(QQmlEnginePrivate *enginePriv, DeferredState *deferredState)
static void beginDeferred(QQmlEnginePrivate *enginePriv, QObject *object, DeferredState *deferredState)
The QQmlContext class defines a context within a QML engine.
Definition qqmlcontext.h:25
static void flushPendingBinding(QObject *object, int coreIndex)
Definition qqmldata_p.h:413
QQmlPropertyCache::ConstPtr propertyCache
Definition qqmldata_p.h:195
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
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:345
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:325
The QQmlError class encapsulates a QML error.
Definition qqmlerror.h:18
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 QQmlType registerCompositeSingletonType(const QQmlPrivate::RegisterCompositeSingletonType &type, const QQmlType::SingletonInstanceInfo::ConstPtr &siinfo)
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 void registerTypeAlias(int typeId, const QString &name)
static QQmlType registerCompositeType(const QQmlPrivate::RegisterCompositeType &type)
static int registerAutoParentFunction(const QQmlPrivate::RegisterAutoParent &autoparent)
static void clearTypeRegistrations()
static QQmlPropertyCache::ConstPtr propertyCache(QObject *object, QTypeRevision version=QTypeRevision())
Returns a QQmlPropertyCache for obj if one is available.
static QQmlType registerSingletonType(const QQmlPrivate::RegisterSingletonType &type, const QQmlType::SingletonInstanceInfo::ConstPtr &siinfo)
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
void readProperty(QObject *target, void *property) const
static void removeBinding(const QQmlProperty &that)
static constexpr int extensionObjectId(int id) noexcept
T * data() const
The QQmlTypeLoader class abstracts loading files and their dependencies over the network.
static QUrl normalize(const QUrl &unNormalizedUrl)
static QQmlType compositeQmlType(const QQmlRefPointer< QV4::CompiledData::CompilationUnit > &unit, QQmlTypeLoader *typeLoader, const QString &type)
static QVariant constructValueType(QMetaType targetMetaType, const QMetaObject *targetMetaObject, int ctorIndex, void *ctorArg)
iterator begin()
Definition qset.h:137
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:6028
QByteArray toUtf8() const &
Definition qstring.h:634
\inmodule QtCore
static constexpr QTypeRevision fromMajorVersion(Major majorVersion)
Produces a QTypeRevision from the given majorVersion with an invalid minor version.
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 fromMinorVersion(Minor minorVersion)
Produces a QTypeRevision from the given minorVersion with an invalid major version.
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}.
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.
static constexpr QTypeRevision fromEncodedVersion(Integer value)
Produces a QTypeRevision from the given value.
constexpr quint8 majorVersion() const
Returns the major version encoded in the revision.
const QQmlRefPointer< QV4::CompiledData::CompilationUnit > & baseCompilationUnit() const
\inmodule QtCore
Definition qvariant.h:65
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:715
QMetaType metaType() const
void extension()
[6]
Definition dialogs.cpp:230
QCache< int, Employee > cache
[0]
QSet< QString >::iterator it
else opt state
[0]
static void initTypeWrapperLookup(const AOTCompiledContext *context, QV4::Lookup *l, uint importNamespace)
Definition qqml.cpp:2019
QTypeRevision revisionClassInfo(const QMetaObject *metaObject, const char *key, QTypeRevision defaultValue=QTypeRevision())
void Q_QML_EXPORT qmlunregister(RegistrationType, quintptr)
Definition qqml.cpp:883
QV4::ReturnedValue(*)(QV4::Lookup *l, QV4::ExecutionEngine *engine, QV4::Value *thisObject) QmlContextPropertyGetter
Definition qqml.cpp:2016
static FallbackPropertyQmlData findFallbackPropertyQmlData(QV4::Lookup *l, QObject *object)
Definition qqml.cpp:1108
ObjectPropertyResult loadObjectProperty(QV4::Lookup *l, QObject *object, void *target, const AOTCompiledContext *aotContext)
Definition qqml.cpp:1073
static ObjectPropertyResult storeFallbackProperty(QV4::Lookup *l, QObject *object, void *value)
Definition qqml.cpp:1261
static int indexOfOwnClassInfo(const QMetaObject *metaObject, const char *key, int startOffset=-1)
static ObjectPropertyResult resetFallbackProperty(QV4::Lookup *l, QObject *object, const QMetaProperty *property, QV4::ExecutionEngine *v4)
Definition qqml.cpp:1269
static bool initValueLookup(QV4::Lookup *l, QV4::ExecutableCompilationUnit *compilationUnit, const QMetaObject *metaObject, QMetaType type)
Definition qqml.cpp:1466
static ObjectPropertyResult storeObjectAsVariant(QV4::ExecutionEngine *v4, QV4::Lookup *l, QObject *object, void *value)
Definition qqml.cpp:1348
ObjectPropertyResult writeBackObjectAsVariant(QV4::Lookup *l, QObject *object, void *source)
Definition qqml.cpp:1169
Q_QML_EXPORT void qmlRegistrationWarning(QmlRegistrationWarning warning, QMetaType type)
Definition qqml.cpp:150
static void captureFallbackProperty(QObject *object, int coreIndex, int notifyIndex, bool isConstant, const AOTCompiledContext *aotContext)
Definition qqml.cpp:1014
@ CompositeSingletonRegistration
@ SingletonRegistration
@ SequentialContainerRegistration
@ SequentialContainerAndRevisionsRegistration
@ QmlUnitCacheHookRegistration
@ CompositeRegistration
@ SingletonAndRevisionsRegistration
@ InterfaceRegistration
@ AutoParentRegistration
@ TypeAndRevisionsRegistration
static ObjectPropertyResult storeFallbackAsVariant(QV4::ExecutionEngine *v4, QV4::Lookup *l, QObject *object, void *value)
Definition qqml.cpp:1367
static ObjectPropertyResult changeObjectProperty(QV4::Lookup *l, QObject *object, Op op)
Definition qqml.cpp:1212
Q_QML_EXPORT QList< QTypeRevision > revisionClassInfos(const QMetaObject *metaObject, const char *key)
Definition qqml.cpp:915
static bool inherits(const QQmlPropertyCache *descendent, const QQmlPropertyCache *ancestor)
Definition qqml.cpp:1036
ObjectPropertyQmlData findObjectPropertyQmlData(QV4::Lookup *l, QObject *object)
Definition qqml.cpp:1054
static ObjectLookupResult initObjectLookup(const AOTCompiledContext *aotContext, QV4::Lookup *l, QObject *object, QMetaType type)
Definition qqml.cpp:1400
static void captureObjectProperty(QObject *object, const QQmlPropertyCache *propertyCache, const QQmlPropertyData *property, const AOTCompiledContext *aotContext)
Definition qqml.cpp:1025
static bool isUndefined(const void *value, QMetaType type)
Definition qqml.cpp:1604
static void amendException(QV4::ExecutionEngine *engine)
Definition qqml.cpp:1481
@ UnconstructibleSingleton
Q_QML_EXPORT QObject * qmlExtendedObject(QObject *, int)
Definition qqml.cpp:131
ObjectPropertyResult writeBackObjectProperty(QV4::Lookup *l, QObject *object, void *source)
Definition qqml.cpp:1091
static ObjectPropertyResult loadFallbackProperty(QV4::Lookup *l, QObject *object, void *target, const AOTCompiledContext *aotContext)
Definition qqml.cpp:1124
const CachedQmlUnit *(* QmlUnitCacheLookupFunction)(const QUrl &url)
const char * classInfo(const QMetaObject *metaObject, const char *key)
ObjectPropertyResult loadFallbackAsVariant(QV4::Lookup *l, QObject *object, void *target, const AOTCompiledContext *aotContext)
Definition qqml.cpp:1180
ObjectPropertyResult loadObjectAsVariant(QV4::Lookup *l, QObject *object, void *target, const AOTCompiledContext *aotContext)
Definition qqml.cpp:1157
static bool isTypeCompatible(QMetaType lookupType, QMetaType propertyType)
Definition qqml.cpp:1284
bool boolClassInfo(const QMetaObject *metaObject, const char *key, bool defaultValue=false)
int Q_QML_EXPORT qmlregister(RegistrationType, void *)
Definition qqml.cpp:785
AutoParentResult(* AutoParentFunction)(QObject *object, QObject *parent)
Q_QML_EXPORT QMetaType compositeListMetaType(QV4::ExecutableCompilationUnit *unit, const QString &elementName)
Definition qqml.cpp:184
Q_QML_EXPORT QMetaType compositeMetaType(QV4::ExecutableCompilationUnit *unit, const QString &elementName)
Definition qqml.cpp:176
void qmlRegisterTypeAndRevisions< QQmlTypeNotAvailable, void >(const char *uri, int versionMajor, const QMetaObject *classInfoMetaObject, QVector< int > *qmlTypeIds, const QMetaObject *extension, bool)
Definition qqml.cpp:937
static ObjectPropertyResult writeBackFallbackProperty(QV4::Lookup *l, QObject *object, void *source)
Definition qqml.cpp:1144
static ObjectPropertyResult resetObjectProperty(QV4::Lookup *l, QObject *object, QV4::ExecutionEngine *v4)
Definition qqml.cpp:1225
static QQmlPropertyCapture * propertyCapture(const AOTCompiledContext *aotContext)
Definition qqml.cpp:988
static ObjectPropertyResult storeObjectProperty(QV4::Lookup *l, QObject *object, void *value)
Definition qqml.cpp:1240
ObjectPropertyResult
Definition qqml.cpp:1045
ObjectPropertyResult writeBackFallbackAsVariant(QV4::Lookup *l, QObject *object, void *source)
Definition qqml.cpp:1196
static ObjectPropertyResult changeFallbackProperty(QV4::Lookup *l, QObject *object, Op op)
Definition qqml.cpp:1248
Combined button and popup list for selecting options.
Scoped< FunctionObject > ScopedFunctionObject
quint64 ReturnedValue
void setupQObjectLookup(Lookup *lookup, const QQmlData *ddata, const QQmlPropertyData *propertyData)
Scoped< String > ScopedString
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:33
@ QtWarningMsg
Definition qlogging.h:32
@ QtDebugMsg
Definition qlogging.h:30
#define qWarning
Definition qlogging.h:167
GLuint64 key
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint index
[2]
GLuint GLuint end
GLsizei GLenum GLenum * types
GLenum GLuint id
[7]
GLuint object
[3]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum type
GLenum target
GLuint GLsizei const GLchar * message
GLuint start
GLenum GLuint GLintptr offset
GLuint name
GLsizei GLsizei GLchar * source
GLhandleARB obj
[2]
GLenum func
Definition qopenglext.h:663
const GLubyte * c
GLuint GLuint * names
GLuint64EXT * result
[6]
bool qmlProtectModule(const char *uri, int majVersion)
Definition qqml.cpp:235
int qmlTypeId(const char *uri, int versionMajor, int versionMinor, const char *qmlName)
Definition qqml.cpp:354
void qmlRegisterModule(const char *uri, int versionMajor, int versionMinor)
Definition qqml.cpp:242
QQmlAttachedPropertiesFunc qmlAttachedPropertiesFunction(QObject *object, const QMetaObject *attachedMetaObject)
Definition qqml.cpp:103
QVarLengthArray< const char *, 8 > ElementNames
Definition qqml.cpp:543
int qmlRegisterUncreatableMetaObject(const QMetaObject &staticMetaObject, const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString &reason)
Definition qqml.cpp:192
static void doRegisterSingletonAndRevisions(const QQmlPrivate::RegisterSingletonTypeAndRevisions &type, const ElementNames &elementNames)
Definition qqml.cpp:721
static ElementNames classElementNames(const QMetaObject *metaObject)
Definition qqml.cpp:544
void assignVersions(Registration *registration, QTypeRevision revision, QTypeRevision defaultVersion)
Definition qqml.cpp:466
static int finalizeType(const QQmlType &dtype)
Definition qqml.cpp:534
QQmlEngine * qmlEngine(const QObject *obj)
Definition qqml.cpp:77
static QVector< QTypeRevision > availableRevisions(const QMetaObject *metaObject)
Definition qqml.cpp:436
int qmlRegisterTypeNotAvailable(const char *uri, int versionMajor, int versionMinor, const char *qmlName, const QString &message)
Definition qqml.cpp:927
QQmlContext * qmlContext(const QObject *obj)
Definition qqml.cpp:72
static QObject * resolveAttachedProperties(QQmlAttachedPropertiesFunc pf, QQmlData *data, QObject *object, bool create)
Definition qqml.cpp:85
QObject * qmlAttachedPropertiesObject(QObject *object, QQmlAttachedPropertiesFunc func, bool create)
Definition qqml.cpp:111
static void uniqueRevisions(QVector< QTypeRevision > *revisions, QTypeRevision defaultVersion, QTypeRevision added)
Definition qqml.cpp:484
void qmlClearTypeRegistrations()
Definition qqml.cpp:227
QT_BEGIN_NAMESPACE void qmlExecuteDeferred(QObject *object)
Definition qqml.cpp:46
static QQmlDirParser::Import resolveImport(const QString &uri, int importMajor, int importMinor)
Definition qqml.cpp:247
QObject * qmlExtendedObject(QObject *object)
Definition qqml.cpp:126
static bool checkSingletonInstance(QQmlEngine *engine, QObject *instance)
Definition qqml.cpp:376
static void doRegisterTypeAndRevisions(const QQmlPrivate::RegisterTypeAndRevisions &type, const ElementNames &elementNames)
Definition qqml.cpp:608
static QVector< QTypeRevision > prepareRevisions(const QMetaObject *metaObject, QTypeRevision added)
Definition qqml.cpp:477
static QTypeRevision resolveModuleVersion(int moduleMajor)
Definition qqml.cpp:258
static QQmlType::SingletonInstanceInfo::ConstPtr singletonInstanceInfo(const QQmlPrivate::RegisterSingletonType &type)
Definition qqml.cpp:513
@ QQmlModuleImportLatest
Definition qqml.h:649
@ QQmlModuleImportModuleAny
Definition qqml.h:648
@ QQmlModuleImportAuto
Definition qqml.h:650
void qmlClearEnginePlugins()
QQmlPrivate::QQmlAttachedPropertiesFunc< QObject > QQmlAttachedPropertiesFunc
Definition qqmlprivate.h:63
QDebug warning(QAnyStringView fileName, int lineNumber)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
SSL_CTX int void * arg
#define qUtf8Printable(string)
Definition qstring.h:1535
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
#define QStringLiteral(str)
#define Q_UNUSED(x)
unsigned int quint32
Definition qtypes.h:50
short qint16
Definition qtypes.h:47
unsigned short quint16
Definition qtypes.h:48
size_t quintptr
Definition qtypes.h:167
int qint32
Definition qtypes.h:49
unsigned long long quint64
Definition qtypes.h:61
unsigned int uint
Definition qtypes.h:34
long long qint64
Definition qtypes.h:60
QT_BEGIN_NAMESPACE typedef signed char qint8
Definition qtypes.h:45
unsigned char quint8
Definition qtypes.h:46
const char property[13]
Definition qwizard.cpp:100
obj metaObject() -> className()
QVariant variant
[1]
QFrame frame
[0]
view create()
QJSValueList args
QJSValue global
QJSEngine engine
[0]
AliasRegistrar(const ElementNames *elementNames)
Definition qqml.cpp:588
void registerAliases(int typeId)
Definition qqml.cpp:590
static Q_CORE_EXPORT int signalIndex(const QMetaMethod &m)
\inmodule QtCore
int indexOfProperty(const char *name) const
Finds property name and returns its index; otherwise returns -1.
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or \nullptr if there is no such object.
void setInstructionPointer(int offset) const
Definition qqml.cpp:1000
QJSValue jsMetaType(int index) const
Definition qqml.cpp:994
void setReturnValueUndefined() const
Definition qqml.cpp:1006
QQmlEngine * qmlEngine() const
Definition qqml.cpp:983
QV4::ExecutableCompilationUnit * compilationUnit
QObject * thisObject() const
Definition qqml.cpp:977
const QMetaObject * metaObject
Definition qqml.cpp:1104
ObjectPropertyResult result
Definition qqml.cpp:1105
ObjectPropertyResult result
Definition qqml.cpp:1050
static constexpr QMetaType list()
static constexpr QMetaSequence sequence()
static constexpr QMetaType self()
QObject * operator()(QQmlEngine *, QJSEngine *)
Definition qqml.cpp:418
QQmlRefPointer< const SingletonInstanceInfo > ConstPtr
Definition qqmltype_p.h:127
QQmlRefPointer< SingletonInstanceInfo > Ptr
Definition qqmltype_p.h:126
static QDateTime timestampToDateTime(double timestamp, QTimeZone zone=QTimeZone::LocalTime)
static QDateTime stringToDateTime(const QString &string, ExecutionEngine *engine)
static double componentsToTimestamp(double year, double month, double day, double hours, double mins, double secs, double ms, ExecutionEngine *v4)
IdentifierTable * identifierTable
CppStackFrame * currentStackFrame
static bool metaTypeFromJS(const Value &value, QMetaType type, void *data)
ReturnedValue throwError(const Value &value)
ReturnedValue throwReferenceError(const Value &value)
QV4::ReturnedValue fromVariant(const QVariant &)
String * id_destroy() const
String * id_toString() const
QV4::ReturnedValue metaTypeToJS(QMetaType type, const void *data)
QQmlEngine * qmlEngine() const
TypeLoader * typeLoader()
ReturnedValue throwTypeError()
ReturnedValue asReturnedValue() const
Definition qv4value_p.h:342
QString toQString() const
Definition qv4string_p.h:92
PropertyKey asPropertyKey(const Heap::String *str)
ReturnedValue(* globalGetter)(Lookup *l, ExecutionEngine *engine)
Definition qv4lookup_p.h:41
struct QV4::Lookup::@586::@600 qobjectFallbackLookup
ReturnedValue(* qmlContextPropertyGetter)(Lookup *l, ExecutionEngine *engine, Value *thisObject)
Definition qv4lookup_p.h:42
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:40
struct QV4::Lookup::@586::@607 qmlEnumValueLookup
struct QV4::Lookup::@586::@598 qobjectLookup
struct QV4::Lookup::@586::@603 qmlContextSingletonLookup
struct QV4::Lookup::@586::@606 qmlTypeLookup
static bool setterFallbackAsVariant(Lookup *l, ExecutionEngine *engine, Value &object, const Value &value)
bool(* setter)(Lookup *l, ExecutionEngine *engine, Value &object, const Value &v)
Definition qv4lookup_p.h:43
struct QV4::Lookup::@586::@604 qmlContextIdObjectLookup
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::@586::@601 qgadgetLookup
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()