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())
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);
62 if (runtimeFunction) {
68 b->createQmlBinding(
b->context(),
b->scopeObject(), code,
url, scriptPrivate->
lineNumber);
77 return *m_sourceLocation;
84 delete m_sourceLocation;
95 b->setNotifyOnValueChanged(
true);
96 b->QQmlJavaScriptExpression::setContext(ctxt);
97 b->setScopeObject(
obj);
99 b->createQmlBinding(ctxt,
obj,
str,
url, lineNumber);
117 b->setNotifyOnValueChanged(
true);
118 b->QQmlJavaScriptExpression::setContext(ctxt);
119 b->setScopeObject(
obj);
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;
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) {
335 return this->m_compilationUnit->bindingValueAsString(m_binding);
357 m_translationData(translationData),
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));
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,
419 QMetaType resultType,
bool isUndefined, QQmlPropertyData::WriteFlags
flags)
438 void *
args[] = {
nullptr };
440 }
else if (isUndefined && metaType == QMetaType::fromType<QVariant>()) {
443 }
else if (metaType == QMetaType::fromType<QJSValue>()) {
447 }
else if (isUndefined) {
460 handleWriteError(
result, resultType, metaType);
470 bool isUndefined, QQmlPropertyData::WriteFlags
flags)
473 const int type = metaType.
id();
494 }
else if (!isVarProperty && metaType != QMetaType::fromType<QJSValue>()) {
500 }
else if (isVarProperty) {
502 if (
f &&
f->isBinding()) {
512 }
else if (isUndefined
518 }
else if (metaType == QMetaType::fromType<QJSValue>()) {
520 if (
f &&
f->isBinding()) {
528 }
else if (isUndefined) {
544 handleWriteError(
value.constData(),
value.metaType(), metaType);
553 const char *valueType =
nullptr;
554 const char *propertyType =
nullptr;
558 valueType =
o->metaObject()->className();
560 if (!propertyMetaObject.
isNull())
561 propertyType = propertyMetaObject.
className();
563 }
else if (resultType.
isValid()) {
564 if (resultType == QMetaType::fromType<std::nullptr_t>()
565 || resultType == QMetaType::fromType<void *>()) {
568 valueType = resultType.
name();
573 valueType =
"undefined";
575 propertyType = metaType.
name();
577 propertyType =
"[unknown property type]";
591 bool isUndefined =
false;
618 if (
e && !wasEnabled)
634 if (guard->signalIndex() == -1)
637 QObject *senderObject = guard->senderAsObject();
641 const QMetaObject *senderMeta = senderObject->metaObject();
670 ep->referenceScarceResources();
677 if (returnType == QMetaType::fromType<QVariant>()) {
685 const auto size = returnType.sizeOf();
691 returnType.destruct(
result);
692 }
else if (canWrite()) {
697 bool isUndefined =
false;
717 ep->dereferenceScarceResources();
731 QQmlPropertyData::WriteFlags
flags)
override final
740 QObject *resultObject =
nullptr;
742 const auto typeFlags =
type.flags();
751 resultMo = ddata->propertyCache;
753 resultMo = resultObject->metaObject();
754 }
else if (
type == QMetaType::fromType<QVariant>()) {
759 resultObject = *
static_cast<QObject *
const *
>(
value.constData());
764 return compareAndSet(resultMo, resultObject, pd,
flags, [&]() {
770 QQmlPropertyData::WriteFlags
flags)
override final
776 return slowWrite(*pd, vtpd,
result, isUndefined,
flags);
779 QObject *resultObject =
nullptr;
785 resultObject =
wrapper->object();
789 resultMo = ddata->propertyCache;
791 resultMo = resultObject->metaObject();
797 return slowWrite(*pd, vtpd,
result, isUndefined,
flags);
798 resultObject = *
static_cast<QObject *
const *
>(
value.constData());
800 return slowWrite(*pd, vtpd,
result, isUndefined,
flags);
803 return compareAndSet(resultMo, resultObject, pd,
flags, [&]() {
804 return slowWrite(*pd, vtpd,
result, isUndefined,
flags);
811 template<
typename SlowWrite>
813 QQmlPropertyData::WriteFlags
flags,
const SlowWrite &slowWrite)
const
838 switch (propertyType.
id()) {
839 case QMetaType::Bool:
843 case QMetaType::Double:
845 case QMetaType::Float:
847 case QMetaType::QString:
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.
bool isValid() const
Returns whether the context is valid.
QQmlEngine * engine() const
Return the context's QQmlEngine, or \nullptr if the context has no QQmlEngine or the QQmlEngine was d...
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.
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)
const QQmlPrivate::AOTCompiledFunction * aotCompiledFunction
CallData * callData(const Scope &scope, const FunctionObject *f=nullptr) const
static Heap::QmlContext * create(QV4::ExecutionContext *parent, QQmlRefPointer< QQmlContextData > context, QObject *scopeObject)
uchar data[MaxInternalSize]