6#include <private/qjsvalue_p.h>
7#include <private/qqmlcontext_p.h>
8#include <private/qqmlengine_p.h>
9#include <private/qqmlglobal_p.h>
10#include <private/qqmljavascriptexpression_p.h>
11#include <private/qqmllistwrapper_p.h>
12#include <private/qqmltypewrapper_p.h>
13#include <private/qv4compileddata_p.h>
14#include <private/qv4engine_p.h>
15#include <private/qv4function_p.h>
16#include <private/qv4identifiertable_p.h>
17#include <private/qv4lookup_p.h>
18#include <private/qv4mm_p.h>
19#include <private/qv4module_p.h>
20#include <private/qv4objectproto_p.h>
21#include <private/qv4qobjectwrapper_p.h>
22#include <private/qv4stackframe_p.h>
23#include <private/qv4value_p.h>
25#include <QtCore/qloggingcategory.h>
36void Heap::QQmlContextWrapper::init(QQmlRefPointer<QQmlContextData>
context,
QObject *scopeObject)
40 this->scopeObject.init(scopeObject);
43void Heap::QQmlContextWrapper::destroy()
47 scopeObject.destroy();
56 const int propertyIdx =
context->propertyIndex(
name);
58 if (propertyIdx == -1)
61 if (propertyIdx < context->numIdValues()) {
69 }
else if (originalLookup) {
87 QQmlListProperty<QObject> prop(
context->asQQmlContext(), (
void*)
qintptr(propertyIdx),
95template<
typename Lookup>
98 *
result = lookup(&hasProp);
101 *hasProperty = hasProp;
123 if (resource->d()->module) {
124 Scoped<Module> module(scope, resource->d()->module);
125 bool hasProp =
false;
130 return value->asReturnedValue();
142 QQmlRefPointer<QQmlContextData> expressionContext =
context;
147 return result->asReturnedValue();
162 const auto globalLookup = [v4, &
name](
bool *hasProp) {
166 const auto jsLookup = [resource, &
id, receiver](
bool *hasProp) {
170 const bool isJSContext =
context->isJSContext();
174 return result->asReturnedValue();
197 return result->asReturnedValue();
201 if (
context->imports() && (
name->startsWithUpper() ||
context->valueTypesAreAddressable())) {
209 if (
r.scriptIndex != -1) {
217 return scripts->
get(
r.scriptIndex);
219 }
else if (
r.type.isValid()) {
221 bool isValueSingleton =
false;
222 if (
r.type.isSingleton()) {
224 if (
r.type.isQObjectSingleton() ||
r.type.isCompositeSingleton()) {
241 isValueSingleton =
true;
250 }
else if (
r.importNamespace) {
257 return result->asReturnedValue();
263 Lookup *
const originalLookup = lookup;
268 if (scopeObject ==
context->contextObject()) {
269 scopeObject =
nullptr;
273 QQmlRefPointer<QQmlContextData> outer =
context;
281 outer = outer->parent();
283 if (
const auto cu =
context->typeCompilationUnit(); cu && cu->componentsAreBound()) {
290 outer && outer->typeCompilationUnit() == cu;
291 outer = outer->parent()) {
294 nullptr, originalLookup, ep)) {
303 bool hasProp =
false;
319 if (ddata && ddata->propertyCache) {
339 return result->asReturnedValue();
342 scopeObject =
nullptr;
347 bool hasProp =
false;
362 if (ddata && ddata->propertyCache
382 }
else if (originalLookup) {
387 return result->asReturnedValue();
401 return result->asReturnedValue();
405 if (originalLookup) {
409 lookup = originalLookup;
416 return result->asReturnedValue();
421 return result->asReturnedValue();
424 expressionContext->setUnresolvedNames(
true);
440 if (
id.
isSymbol() ||
id.isArrayIndex())
450 auto member =
wrapper->internalClass()->findValueOrSetter(
id);
451 if (member.index < UINT_MAX)
452 return wrapper->putValue(member.index, member.attrs,
value);
457 QQmlRefPointer<QQmlContextData> expressionContext =
context;
469 if (
const int propertyIndex =
context->propertyIndex(
name); propertyIndex != -1) {
470 if (propertyIndex < context->numIdValues()) {
481 scopeObject =
nullptr;
484 if (
context->contextObject() &&
492 expressionContext->setUnresolvedNames(
true);
512 if (
ctx->type == Heap::ExecutionContext::Type_CallContext) {
514 if (
index < std::numeric_limits<uint>::max()) {
515 if (!
func->detectedInjectedParameters) {
517 qCWarning(lcQmlContext).nospace().noquote()
519 <<
" Parameter \"" <<
name->toQString() <<
"\" is not declared."
520 <<
" Injection of parameters into signal handlers is deprecated."
521 <<
" Use JavaScript functions with formal parameters instead.";
524 func->detectedInjectedParameters =
true;
533 if (
ctx->type != Heap::ExecutionContext::Type_BlockContext &&
ctx->type != Heap::ExecutionContext::Type_CallContext)
541 if (callingQmlContext) {
542 Scoped<QQmlContextWrapper> qmlContextWrapper(scope, callingQmlContext->d()->qml());
556 return result->asReturnedValue();
637template<
typename Call>
684template<
typename Call>
765 QQmlRefPointer<QQmlContextData> expressionContext =
context;
781 bool hasProp =
false;
790 return result->asReturnedValue();
795 bool hasProp =
false;
798 return result->asReturnedValue();
800 expressionContext->setUnresolvedNames(
true);
828 Heap::ExecutionContext::init(Heap::ExecutionContext::Type_QmlContext);
829 outer.set(internalClass->engine, outerContext->d());
831 this->activation.set(internalClass->engine, qml->d());
840 Scoped<QQmlContextWrapper> qml(
842 std::move(
context), scopeObject));
static QV4::Value * takeManagedValue(QJSValue *jsval)
static QV4::ReturnedValue asReturnedValue(const QJSValue *jsval)
static const QString * asQString(const QJSValue *jsval)
The QJSValue class acts as a container for Qt/JavaScript data types.
static qsizetype context_count(QQmlListProperty< QObject > *)
QVariant propertyValue(int index) const
static QObject * context_at(QQmlListProperty< QObject > *, qsizetype)
static bool wasDeleted(const QObject *)
static QQmlData * get(QObjectPrivate *priv, bool create)
QQmlPropertyCapture * propertyCapture
static QQmlEnginePrivate * get(QQmlEngine *e)
T singletonInstance(const QQmlType &type)
void captureProperty(QObject *object, const QMetaProperty &property) const
void captureProperty(QQmlNotifier *)
static QQmlTypeLoader * get(Engine *engine)
\macro QT_RESTRICTED_CAST_FROM_ASCII
ObjectType::Data * allocate(Args &&... args)
ManagedType::Data * alloc(Args &&... args)
Combined button and popup list for selecting options.
void setupQObjectMethodLookup(Lookup *lookup, const QQmlData *ddata, const QQmlPropertyData *propertyData, const Object *self, QObjectMethod *method)
void setupQObjectLookup(Lookup *lookup, const QQmlData *ddata, const QQmlPropertyData *propertyData)
Scoped< String > ScopedString
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]
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
QQmlEngine * qmlEngine(const QObject *obj)
QQmlContext * qmlContext(const QObject *obj)
QLatin1StringView QLatin1String
static ReturnedValue revertObjectMethodLookup(Lookup *l, ExecutionEngine *engine, Value *base)
static QV4::QObjectWrapper::Flags getQmlPropertyFlags(const Lookup *l)
static ReturnedValue revertObjectPropertyLookup(Lookup *l, ExecutionEngine *engine, Value *base)
static OptionalReturnedValue searchContextProperties(QV4::ExecutionEngine *v4, const QQmlRefPointer< QQmlContextData > &context, String *name, bool *hasProperty, Value *base, QV4::Lookup *lookup, QV4::Lookup *originalLookup, QQmlEnginePrivate *ep)
ReturnedValue callWithScopeObject(ExecutionEngine *engine, Value *base, Call c)
ReturnedValue callWithContextObject(ExecutionEngine *engine, Value *base, Call c)
bool performLookup(ScopedValue *result, bool *hasProperty, const Lookup &lookup)
#define DEFINE_OBJECT_VTABLE(classname)
#define DEFINE_MANAGED_VTABLE(classname)
\inmodule QtCore \reentrant
static constexpr ReturnedValue undefined()
static constexpr ReturnedValue null()
IdentifierTable * identifierTable
MemoryManager * memoryManager
CppStackFrame * currentStackFrame
QQmlRefPointer< QQmlContextData > callingQmlContext() const
ReturnedValue throwError(const Value &value)
ReturnedValue throwReferenceError(const Value &value)
QV4::ReturnedValue fromVariant(const QVariant &)
QQmlEngine * qmlEngine() const
static Heap::ExecutionContext * qmlContext(Heap::ExecutionContext *ctx)
ExecutionContext * currentContext() const
WriteBarrier::HeapObjectWrapper< CompilationUnitRuntimeData, 1 > compilationUnit
PropertyKey asPropertyKey(const Heap::String *str)
ReturnedValue(* globalGetter)(Lookup *l, ExecutionEngine *engine)
ReturnedValue resolveGlobalGetter(ExecutionEngine *engine)
ReturnedValue(* qmlContextPropertyGetter)(Lookup *l, ExecutionEngine *engine, Value *thisObject)
struct QV4::Lookup::@583::@604 qmlContextIdObjectLookup
struct QV4::Lookup::@583::@599 qobjectMethodLookup
static ReturnedValue globalGetterGeneric(Lookup *l, ExecutionEngine *engine)
struct QV4::Lookup::@583::@606 qmlTypeLookup
struct QV4::Lookup::@583::@598 qobjectLookup
struct QV4::Lookup::@583::@605 qmlContextGlobalLookup
struct QV4::Lookup::@583::@602 qmlContextScriptLookup
struct QV4::Lookup::@583::@603 qmlContextSingletonLookup
Q_ALWAYS_INLINE Heap::Base * heapObject() const
ExecutionEngine * engine() const
const Value * propertyData(uint index) const
bool hasProperty(PropertyKey id) const
ReturnedValue get(StringOrSymbol *name, bool *hasProperty=nullptr, const Value *receiver=nullptr) const
static bool setQmlProperty(ExecutionEngine *engine, const QQmlRefPointer< QQmlContextData > &qmlContext, QObject *object, String *name, Flags flags, const Value &value)
ReturnedValue getQmlProperty(const QQmlRefPointer< QQmlContextData > &qmlContext, String *name, Flags flags, bool *hasProperty=nullptr) const
static ReturnedValue lookupPropertyGetterImpl(Lookup *l, ExecutionEngine *engine, const Value &object, Flags flags, ReversalFunctor revert)
static ReturnedValue wrap(ExecutionEngine *engine, QObject *object)
static ReturnedValue lookupMethodGetterImpl(Lookup *l, ExecutionEngine *engine, const Value &object, Flags flags, ReversalFunctor revert)
static ReturnedValue lookupScopeObjectMethod(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupSingleton(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupInParentContextHierarchy(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupContextObjectMethod(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue getPropertyAndBase(const QQmlContextWrapper *resource, PropertyKey id, const Value *receiver, bool *hasProperty, Value *base, Lookup *lookup=nullptr)
QQmlRefPointer< QQmlContextData > getContext() const
static ReturnedValue lookupContextObjectProperty(Lookup *l, ExecutionEngine *engine, Value *base)
V4_NEEDS_DESTROY QObject * getScopeObject() const
static ReturnedValue lookupIdObjectInParentContext(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupIdObject(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue resolveQmlContextPropertyLookupGetter(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupScopeObjectProperty(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupValueSingleton(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupScopeFallbackProperty(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupInGlobalObject(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupType(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue lookupScript(Lookup *l, ExecutionEngine *engine, Value *base)
static ReturnedValue create(ExecutionEngine *, QObject *, const QQmlType &, Heap::QQmlTypeWrapper::TypeNameMode=Heap::QQmlTypeWrapper::IncludeEnums)
static Heap::QmlContext * create(QV4::ExecutionContext *parent, QQmlRefPointer< QQmlContextData > context, QObject *scopeObject)
static V4_NEEDS_DESTROY ReturnedValue create(ExecutionEngine *engine, QObject *object, int propId, QMetaType propType)
bool hasException() const
constexpr ReturnedValue asReturnedValue() const
static constexpr VTable::Get virtualGet
static constexpr VTable::Put virtualPut
QML_NEARLY_ALWAYS_INLINE Object * objectValue() const
static Value fromHeapObject(HeapBasePtr m)
static constexpr Value fromReturnedValue(ReturnedValue val)