9#include <private/qqmldebugserviceinterfaces_p.h>
10#include <private/qqmldebugconnector_p.h>
12#include <private/qqmlprofiler_p.h>
13#include <private/qqmlexpression_p.h>
14#include <private/qqmlscriptstring_p.h>
15#include <private/qqmlbuiltinfunctions_p.h>
16#include <private/qqmlvmemetaobject_p.h>
17#include <private/qqmlvaluetypewrapper_p.h>
18#include <private/qv4qmlcontext_p.h>
19#include <private/qv4qobjectwrapper_p.h>
20#include <private/qv4variantobject_p.h>
21#include <private/qv4jscall_p.h>
22#include <private/qjsvalue_p.h>
24#include <qtqml_tracepoints_p.h>
27#include <QtCore/qdebug.h>
39 if (ctxt && !ctxt->isValid())
43 if (!ctxt && (!scriptPrivate->context || !scriptPrivate->context->isValid()))
51 if (
engine && ctxtdata && !ctxtdata->urlString().isEmpty() && ctxtdata->typeCompilationUnit()) {
52 url = ctxtdata->urlString();
54 runtimeFunction = ctxtdata->typeCompilationUnit()->runtimeFunctions.at(scriptPrivate->bindingId);
57 b->setNotifyOnValueChanged(
true);
59 b->setScopeObject(
obj ?
obj : scriptPrivate->scope);
62 if (runtimeFunction) {
67 QString code = scriptPrivate->script;
68 b->createQmlBinding(
b->context(),
b->scopeObject(), code,
url, scriptPrivate->lineNumber);
77 return *m_sourceLocation;
84 delete m_sourceLocation;
91 const QQmlRefPointer<QQmlContextData> &ctxt,
const QString &
url,
quint16 lineNumber)
95 b->setNotifyOnValueChanged(
true);
96 b->QQmlJavaScriptExpression::setContext(ctxt);
97 b->setScopeObject(
obj);
99 b->createQmlBinding(ctxt,
obj,
str,
url, lineNumber);
112 const QQmlRefPointer<QQmlContextData> &ctxt,
117 b->setNotifyOnValueChanged(
true);
118 b->QQmlJavaScriptExpression::setContext(ctxt);
119 b->setScopeObject(
obj);
122 b->setupFunction(scope, function);
129 delete m_sourceLocation;
178 QV4::Heap::MemberData *
args =
b->boundArgs();
183 thisObject = &
b->d()->boundThis;
191template<
int StaticPropType>
197 QQmlPropertyData::WriteFlags
flags)
override final
204 if (isUndefined || vpd.isValid())
208 || StaticPropType ==
type.id()) {
219 QQmlPropertyData::WriteFlags
flags)
override final
228 int propertyType = StaticPropType;
232 if (
Q_LIKELY(!isUndefined && !vpd.isValid())) {
233 switch (propertyType) {
234 case QMetaType::Bool:
236 return doStore<bool>(
result.booleanValue(), pd,
flags);
238 return doStore<bool>(
result.toBoolean(), pd,
flags);
241 return doStore<int>(
result.integerValue(), pd,
flags);
242 else if (
result.isNumber()) {
246 case QMetaType::Double:
248 return doStore<double>(
result.asDouble(), pd,
flags);
250 case QMetaType::Float:
252 return doStore<float>(
result.asDouble(), pd,
flags);
254 case QMetaType::QString:
256 return doStore<QString>(
result.toQStringNoThrow(), pd,
flags);
260 if (vtw->d()->metaType() == pd->
propType()) {
271 template <
typename T>
310 if (pd->
propType().
id() == QMetaType::QString) {
327 const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit,
335 return this->m_compilationUnit->bindingValueAsString(m_binding);
354 const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit,
357 m_translationData(translationData),
372 const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit,
374 const QQmlRefPointer<QQmlContextData> &ctxt)
378 b->setNotifyOnValueChanged(
true);
379 b->QQmlJavaScriptExpression::setContext(ctxt);
380 b->setScopeObject(
obj);
381#if QT_CONFIG(translation) && QT_CONFIG(qml_debug)
383 = QQmlDebugConnector::service<QQmlDebugTranslationService>()) {
384 service->foundTranslationBinding(
385 TranslationBindingInformation::create(unit, binding,
b->scopeObject(), ctxt));
392 const QQmlRefPointer<QV4::ExecutableCompilationUnit> &unit,
393 const QQmlRefPointer<QQmlContextData> &ctxt,
const QString &propertyName,
399 b->setNotifyOnValueChanged(
true);
400 b->QQmlJavaScriptExpression::setContext(ctxt);
401 b->setScopeObject(
obj);
403#if QT_CONFIG(translation) && QT_CONFIG(qml_debug)
406 QQmlDebugConnector::service<QQmlDebugTranslationService>()) {
407 service->foundTranslationBinding({ unit,
b->scopeObject(), ctxt,
409 propertyName, translationData,
421 QMetaType resultType,
bool isUndefined, QQmlPropertyData::WriteFlags
flags)
440 void *
args[] = {
nullptr };
442 }
else if (isUndefined && metaType == QMetaType::fromType<QVariant>()) {
445 }
else if (metaType == QMetaType::fromType<QJSValue>()) {
449 }
else if (isUndefined) {
462 handleWriteError(
result, resultType, metaType);
472 bool isUndefined, QQmlPropertyData::WriteFlags
flags)
475 const int type = metaType.
id();
496 }
else if (!isVarProperty && metaType != QMetaType::fromType<QJSValue>()) {
502 }
else if (isVarProperty) {
504 if (
f &&
f->isBinding()) {
514 }
else if (isUndefined
520 }
else if (metaType == QMetaType::fromType<QJSValue>()) {
522 if (
f &&
f->isBinding()) {
530 }
else if (isUndefined) {
546 handleWriteError(
value.constData(),
value.metaType(), metaType);
555 const char *valueType =
nullptr;
556 const char *propertyType =
nullptr;
560 valueType =
o->metaObject()->className();
562 if (!propertyMetaObject.isNull())
563 propertyType = propertyMetaObject.className();
565 }
else if (resultType.isValid()) {
566 if (resultType == QMetaType::fromType<std::nullptr_t>()
567 || resultType == QMetaType::fromType<void *>()) {
570 valueType = resultType.name();
575 valueType =
"undefined";
577 propertyType = metaType.
name();
579 propertyType =
"[unknown property type]";
593 bool isUndefined =
false;
620 if (e && !wasEnabled)
636 if (guard->signalIndex() == -1)
639 QObject *senderObject = guard->senderAsObject();
643 const QMetaObject *senderMeta = senderObject->metaObject();
647 for (
int i = 0;
i < senderMeta->propertyCount();
i++) {
672 ep->referenceScarceResources();
679 if (returnType == QMetaType::fromType<QVariant>()) {
685 const auto size = returnType.sizeOf();
689 returnType.construct(
result);
694 returnType.destruct(
result);
695 }
else if (canWrite()) {
700 bool isUndefined =
false;
720 ep->dereferenceScarceResources();
734 QQmlPropertyData::WriteFlags
flags)
override final
739 if (
Q_UNLIKELY(isUndefined || vtpd.isValid()))
743 QObject *resultObject =
nullptr;
745 const auto typeFlags =
type.flags();
754 resultMo = ddata->propertyCache;
755 if (resultMo.isNull())
756 resultMo = resultObject->metaObject();
757 }
else if (
type == QMetaType::fromType<QVariant>()) {
760 if (resultMo.isNull())
762 resultObject = *
static_cast<QObject *
const *
>(
value.constData());
767 return compareAndSet(resultMo, resultObject, pd,
flags, [&]() {
773 QQmlPropertyData::WriteFlags
flags)
override final
778 if (
Q_UNLIKELY(isUndefined || vtpd.isValid()))
779 return slowWrite(*pd, vtpd,
result, isUndefined,
flags);
782 QObject *resultObject =
nullptr;
788 resultObject =
wrapper->object();
792 resultMo = ddata->propertyCache;
793 if (resultMo.isNull()) {
794 resultMo = resultObject->metaObject();
799 if (resultMo.isNull())
800 return slowWrite(*pd, vtpd,
result, isUndefined,
flags);
801 resultObject = *
static_cast<QObject *
const *
>(
value.constData());
803 return slowWrite(*pd, vtpd,
result, isUndefined,
flags);
806 return compareAndSet(resultMo, resultObject, pd,
flags, [&]() {
807 return slowWrite(*pd, vtpd,
result, isUndefined,
flags);
814 template<
typename SlowWrite>
816 QQmlPropertyData::WriteFlags
flags,
const SlowWrite &slowWrite)
const
841 switch (propertyType.
id()) {
842 case QMetaType::Bool:
843 return new GenericBinding<QMetaType::Bool>;
845 return new GenericBinding<QMetaType::Int>;
846 case QMetaType::Double:
847 return new GenericBinding<QMetaType::Double>;
848 case QMetaType::Float:
849 return new GenericBinding<QMetaType::Float>;
850 case QMetaType::QString:
851 return new GenericBinding<QMetaType::QString>;
853 return new GenericBinding<QMetaType::UnknownType>;
Q_ALWAYS_INLINE bool write(const QV4::Value &result, bool isUndefined, QQmlPropertyData::WriteFlags flags) override final
Q_ALWAYS_INLINE bool write(void *result, QMetaType type, bool isUndefined, QQmlPropertyData::WriteFlags flags) override final
Q_ALWAYS_INLINE bool doStore(T value, const QQmlPropertyData *pd, QQmlPropertyData::WriteFlags flags) const
QV4::ExecutionEngine * handle() const
static QJSValue fromReturnedValue(QV4::ReturnedValue d)
qsizetype size() const noexcept
QObjectPointerBinding(QMetaType propertyType)
Q_ALWAYS_INLINE bool write(const QV4::Value &result, bool isUndefined, QQmlPropertyData::WriteFlags flags) override final
Q_ALWAYS_INLINE bool write(void *result, QMetaType type, bool isUndefined, QQmlPropertyData::WriteFlags flags) override final
QPropertyBindingPrivate * binding
void setSource(const Property &property)
bool updatingFlag() const
bool canUseAccessor() const
void setUpdatingFlag(bool)
static void printBindingLoopError(const QQmlProperty &prop)
QTaggedPointer< QObject, TargetTags > m_target
QObject * targetObject() const
bool isAddedToObject() const
void updateCanUseAccessor()
void setEnabledFlag(bool)
void getPropertyData(const QQmlPropertyData **propertyData, QQmlPropertyData *valueTypeData) const
QVector< QQmlProperty > dependencies() const
virtual bool hasDependencies() const
static QQmlBinding * createTranslationBinding(const QQmlRefPointer< QV4::ExecutableCompilationUnit > &unit, const QV4::CompiledData::Binding *binding, QObject *obj, const QQmlRefPointer< QQmlContextData > &ctxt)
QQmlSourceLocation sourceLocation() const override
void update(QQmlPropertyData::WriteFlags flags=QQmlPropertyData::DontRemoveBinding)
QString expression() const override
void setSourceLocation(const QQmlSourceLocation &location)
void expressionChanged() override
virtual void doUpdate(const DeleteWatcher &watcher, QQmlPropertyData::WriteFlags flags, QV4::Scope &scope)
void setEnabled(bool, QQmlPropertyData::WriteFlags flags=QQmlPropertyData::DontRemoveBinding) override
static QQmlBinding * create(const QQmlPropertyData *, const QQmlScriptString &, QObject *, QQmlContext *)
bool slowWrite(const QQmlPropertyData &core, const QQmlPropertyData &valueTypeData, const QV4::Value &result, bool isUndefined, QQmlPropertyData::WriteFlags flags)
virtual bool write(const QV4::Value &result, bool isUndefined, QQmlPropertyData::WriteFlags flags)=0
bool hasBoundFunction() const
static QQmlRefPointer< QQmlContextData > get(QQmlContext *context)
The QQmlContext class defines a context within a QML engine.
static bool wasDeleted(const QObject *)
static QQmlData * get(QObjectPrivate *priv, bool create)
void setErrorObject(QObject *object)
void setErrorLocation(const QQmlSourceLocation &sourceLocation)
void setErrorDescription(const QString &description)
static QQmlEnginePrivate * get(QQmlEngine *e)
void referenceScarceResources()
void dereferenceScarceResources()
The QQmlEngine class provides an environment for instantiating QML components.
void setNotifyOnValueChanged(bool v)
QV4::Function * function() const
void setCompilationUnit(const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit)
QQmlDelayedError * delayedError()
friend class QQmlTranslationBindingFromBinding
friend class QQmlTranslationBindingFromTranslationInfo
QV4::ReturnedValue evaluate(bool *isUndefined)
QForwardFieldList< QQmlJavaScriptExpressionGuard, &QQmlJavaScriptExpressionGuard::next, GuardTag > activeGuards
QQmlEngine * engine() const
QQmlRefPointer< QQmlContextData > context() const
bool hasValidContext() const
TriggerList * qpropertyChangeTriggers
virtual QQmlSourceLocation sourceLocation() const
bool isResettable() const
bool isVarProperty() const
bool writeProperty(QObject *target, void *value, WriteFlags flags) const
QMetaType propType() const
static bool resolveUrlsOnAssignment()
static QQmlMetaObject rawMetaObjectForType(QMetaType metaType)
static QQmlProperty restore(QObject *, const QQmlPropertyData &, const QQmlPropertyData *, const QQmlRefPointer< QQmlContextData > &)
static QList< QUrl > urlSequence(const QVariant &value)
bool writeValueProperty(const QVariant &, QQmlPropertyData::WriteFlags)
static bool resetValueProperty(QObject *, const QQmlPropertyData &, const QQmlPropertyData &valueTypeData, const QQmlRefPointer< QQmlContextData > &, QQmlPropertyData::WriteFlags flags={})
The QQmlProperty class abstracts accessing properties on objects created from QML.
The QQmlScriptString class encapsulates a script and its context.
QString bindingValue() const override
QQmlSourceLocation sourceLocation() const override final
QQmlTranslationBindingFromBinding(const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit, const QV4::CompiledData::Binding *binding)
QQmlSourceLocation sourceLocation() const override final
QQmlTranslationBindingFromTranslationInfo(const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit, const QQmlTranslation &translationData, quint16 line, quint16 column)
virtual QString bindingValue() const override
QQmlTranslationBinding(const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit)
void doUpdate(const DeleteWatcher &watcher, QQmlPropertyData::WriteFlags flags, QV4::Scope &scope) override final
static void onLanguageChange(QPropertyObserver *observer, QUntypedPropertyData *)
virtual QString bindingValue() const =0
bool hasDependencies() const override final
QString translate() const
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
T * data() const noexcept
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Combined button and popup list for selecting options.
Scoped< String > ScopedString
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLboolean GLboolean GLboolean b
GLuint64 GLenum void * handle
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei void GLsizei void * column
QQmlEngine * qmlEngine(const QObject *obj)
QQmlContext * qmlContext(const QObject *obj)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
#define Q_TRACE_SCOPE(x,...)
#define Q_TRACE_POINT(provider, tracepoint,...)
#define Q_ALLOCA_VAR(type, name, size)
QFutureWatcher< int > watcher
QUrl url("example.com")
[constructor-url-reference]
static constexpr ReturnedValue undefined()
ExecutionContext * rootContext() const
static QVariant toVariant(const QV4::Value &value, QMetaType typeHint, bool createJSValueForObjectsAndSymbols=true)
QV4::ReturnedValue metaTypeToJS(QMetaType type, const void *data)
QVarLengthArray< QMetaType, 4 > types
AOTCompiledFunction aotCompiledFunction
static Heap::QmlContext * create(QV4::ExecutionContext *parent, QQmlRefPointer< QQmlContextData > context, QObject *scopeObject)
uchar data[MaxInternalSize]