Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qv4jscall_p.h
Go to the documentation of this file.
1// Copyright (C) 2017 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// Qt-Security score:significant
4#ifndef QV4JSCALL_H
5#define QV4JSCALL_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qqmllistwrapper_p.h>
19#include <private/qqmlvaluetypewrapper_p.h>
20
21#include <private/qv4alloca_p.h>
22#include <private/qv4dateobject_p.h>
23#include <private/qv4function_p.h>
24#include <private/qv4functionobject_p.h>
25#include <private/qv4qobjectwrapper_p.h>
26#include <private/qv4regexpobject_p.h>
27#include <private/qv4scopedvalue_p.h>
28#include <private/qv4sequenceobject_p.h>
29#include <private/qv4urlobject_p.h>
30#include <private/qv4variantobject_p.h>
31
32#if QT_CONFIG(regularexpression)
33#include <QtCore/qregularexpression.h>
34#endif
35
37
38namespace QV4 {
39
40template<typename Args>
41CallData *callDatafromJS(const Scope &scope, const Args *args, const FunctionObject *f)
42{
43 int size = int(offsetof(QV4::CallData, args)/sizeof(QV4::Value)) + args->argc;
44 CallData *ptr = reinterpret_cast<CallData *>(scope.alloc(size));
45 ptr->function = Encode::undefined();
46 ptr->context = Encode::undefined();
47 ptr->accumulator = Encode::undefined();
48 ptr->thisObject = args->thisObject ? args->thisObject->asReturnedValue() : Encode::undefined();
49 ptr->newTarget = Encode::undefined();
50 ptr->setArgc(args->argc);
51 if (args->argc)
52 memcpy(ptr->args, args->args, args->argc*sizeof(Value));
53 if (f)
54 ptr->function = f->asReturnedValue();
55 return ptr;
56}
57
59{
60 JSCallArguments(const Scope &scope, int argc = 0)
61 : thisObject(scope.constructUndefined(1)), args(scope.constructUndefined (argc)), argc(argc)
62 {
63 }
64
65 CallData *callData(const Scope &scope, const FunctionObject *f = nullptr) const
66 {
67 return callDatafromJS(scope, this, f);
68 }
69
70 Value *thisObject;
71 Value *args;
72 const int argc;
73};
74
76{
77 JSCallData(const Value *thisObject, const Value *argv, int argc)
78 : thisObject(thisObject), args(argv), argc(argc)
79 {
80 }
81
86
87 CallData *callData(const Scope &scope, const FunctionObject *f = nullptr) const
88 {
89 return callDatafromJS(scope, this, f);
90 }
91
92 const Value *thisObject;
93 const Value *args;
94 const int argc;
95};
96
97inline
102
103inline
108
109void populateJSCallArguments(ExecutionEngine *v4, JSCallArguments &jsCall, int argc,
110 void **args, const QMetaType *types);
111
112inline QObject *cppThisObject(const Value *thisObject)
113{
114 if (!thisObject)
115 return nullptr;
116 if (const QV4::QObjectWrapper *wrapper = thisObject->as<QV4::QObjectWrapper>())
117 return wrapper->object();
118 return nullptr;
119}
120
121inline void defaultConstructReturnValue(QMetaType returnType, void *returnValue)
122{
123 if (returnType.flags() & QMetaType::NeedsConstruction)
124 returnType.construct(returnValue);
125}
126
128 ExecutionEngine *engine, QMetaType returnType, void *returnValue)
129{
130 const ReturnedValue result = engine->metaTypeToJS(returnType, returnValue);
131 if (returnType.flags() & QMetaType::NeedsDestruction)
132 returnType.destruct(returnValue);
133 return result;
134}
135
136inline bool defaultConversionErrorHandler(QMetaType argumentType, void *argument, qsizetype i)
137{
138 Q_UNUSED(i);
139
140 // If we can't convert the argument, we need to default-construct it even if it
141 // doesn't formally need construction. For example:
142 // - An int doesn't need construction, but we still want it to be 0.
143 // - A QObject* should be nullptr by default, rather than some random value.
144 if (!(argumentType.flags() & QMetaType::NeedsConstruction))
145 argumentType.construct(argument);
146 return true;
147}
148
149template<typename Callable,
150 typename ConstructReturnValue = decltype(defaultConstructReturnValue),
151 typename ConvertReturnValue = decltype(defaultConvertReturnValue),
152 typename ConversionErrorHandler = decltype(defaultConversionErrorHandler)>
154 ExecutionEngine *engine, const QMetaType *types, int numTypes,
155 const Value *argv, int argc, Callable &&call,
156 ConstructReturnValue &&constructReturnValue = defaultConstructReturnValue,
157 ConvertReturnValue &&convertReturnValue = defaultConvertReturnValue,
158 ConversionErrorHandler &&errorHandler = defaultConversionErrorHandler)
159{
160 Q_ALLOCA_INIT();
161 Q_ALLOCA_VAR(void *, values, numTypes * sizeof(void *));
162
163 for (qsizetype i = 1; i < numTypes; ++i) {
164 const auto failConversion = [&]() {
165 for (qsizetype j = 1; j < i; ++j) {
166 if (types[j].flags() & QMetaType::NeedsDestruction)
167 types[j].destruct(values[j]);
168 }
169 return Encode::undefined();
170 };
171
172 const int argIndex = i - 1;
173
174 const QMetaType argumentType = types[i];
175 if (const qsizetype argumentSize = argumentType.sizeOf()) {
176 Q_ALLOCA_VAR(void, argument, argumentSize);
177
178 // Missing arguments are undefined and get coerced like any other undefined.
179 const Value &arg = argIndex < argc ? argv[argIndex] : Value::undefinedValue();
180
181 if (argumentType == QMetaType::fromType<QVariant>()) {
182 // When the argument type is QVariant, JS objects are to be passed as
183 // QJSValue wrapped in QVariant. metaTypeFromJS unwraps them, unfortunately.
184 new (argument) QVariant(ExecutionEngine::toVariant(arg, QMetaType()));
185 } else {
186 if (argumentType.flags() & QMetaType::NeedsConstruction)
187 argumentType.construct(argument);
188 if (!ExecutionEngine::metaTypeFromJS(arg, argumentType, argument)
189 && !errorHandler(argumentType, argument, argIndex)) {
190 return failConversion();
191 }
192 }
193
194 values[i] = argument;
195 } else {
196 values[i] = nullptr;
197 }
198 }
199
200 Q_ALLOCA_DECLARE(void, returnValue);
201 if (const qsizetype returnSize = types[0].sizeOf()) {
202 Q_ALLOCA_ASSIGN(void, returnValue, returnSize);
203 constructReturnValue(types[0], returnValue);
204 values[0] = returnValue;
205 } else {
206 values[0] = nullptr;
207 }
208
209 call(values, types, argc);
210
211 const ReturnedValue result = values[0]
212 ? convertReturnValue(engine, types[0], returnValue)
213 : Encode::undefined();
214
215 for (qsizetype i = 1; i < numTypes; ++i) {
216 if (types[i].flags() & QMetaType::NeedsDestruction)
217 types[i].destruct(values[i]);
218 }
219
220 return result;
221}
222
223template<typename Callable>
224bool convertAndCall(ExecutionEngine *engine, QObject *thisObject,
225 void **a, const QMetaType *types, int argc, Callable call)
226{
227 Scope scope(engine);
228 QV4::JSCallArguments jsCallData(scope, argc);
229
230 for (int ii = 0; ii < argc; ++ii)
231 jsCallData.args[ii] = engine->metaTypeToJS(types[ii + 1], a[ii + 1]);
232
233 ScopedObject jsThisObject(scope);
234 if (thisObject) {
235 // The result of wrap() can only be null, undefined, or an object.
236 jsThisObject = QV4::QObjectWrapper::wrap(engine, thisObject);
237 if (!jsThisObject)
238 jsThisObject = engine->globalObject;
239 } else {
240 jsThisObject = engine->globalObject;
241 }
242
243 ScopedValue jsResult(scope, call(jsThisObject, jsCallData.args, argc));
244 void *result = a[0];
245 if (!result)
246 return !jsResult->isUndefined();
247
248 const QMetaType resultType = types[0];
249 if (scope.hasException()) {
250 // Clear the return value
251 resultType.destruct(result);
252 resultType.construct(result);
253 } else if (resultType == QMetaType::fromType<QVariant>()) {
254 // When the return type is QVariant, JS objects are to be returned as
255 // QJSValue wrapped in QVariant. metaTypeFromJS unwraps them, unfortunately.
256 *static_cast<QVariant *>(result) = ExecutionEngine::toVariant(jsResult, QMetaType {});
257 } else if (!ExecutionEngine::metaTypeFromJS(jsResult, resultType, result)) {
258 // If we cannot convert, also clear the return value.
259 // The caller may have given us an uninitialized QObject*, expecting it to be overwritten.
260 resultType.destruct(result);
261 resultType.construct(result);
262 }
263 return !jsResult->isUndefined();
264}
265
266inline ReturnedValue coerce(
267 ExecutionEngine *engine, const Value &value, const QQmlType &qmlType, bool isList);
268
269inline QObject *coerceQObject(const Value &value, const QQmlType &qmlType)
270{
271 QObject *o;
272 if (const QV4::QObjectWrapper *wrapper = value.as<QV4::QObjectWrapper>())
273 o = wrapper->object();
274 else if (const QV4::QQmlTypeWrapper *wrapper = value.as<QQmlTypeWrapper>())
275 o = wrapper->object();
276 else
277 return nullptr;
278
279 return (o && qmlobject_can_qml_cast(o, qmlType)) ? o : nullptr;
280}
281
287
288Q_QML_EXPORT void warnAboutCoercionToVoid(
289 ExecutionEngine *engine, const Value &value, CoercionProblem problem);
290
292 ExecutionEngine *engine, const Value &value, const QQmlType &qmlType)
293{
294 QMetaType type = qmlType.qListTypeId();
295 const auto metaSequence = [&]() {
296 // TODO: We should really add the metasequence to the same QQmlType that holds
297 // all the other type information. Then we can get rid of the extra
298 // QQmlMetaType::qmlListType() here.
299 return qmlType.isSequentialContainer()
300 ? qmlType.listMetaSequence()
301 : QQmlMetaType::qmlListType(type).listMetaSequence();
302 };
303
304 if (const QV4::Sequence *sequence = value.as<QV4::Sequence>()) {
305 if (sequence->d()->listType() == type)
306 return value.asReturnedValue();
307 }
308
309 if (const QmlListWrapper *list = value.as<QmlListWrapper>()) {
310 if (list->d()->propertyType() == type)
311 return value.asReturnedValue();
312 }
313
314 QMetaType listValueType = qmlType.typeId();
315 if (!listValueType.isValid()) {
316 warnAboutCoercionToVoid(engine, value, InvalidListType);
317 return value.asReturnedValue();
318 }
319
320 QV4::Scope scope(engine);
321
322 const ArrayObject *array = value.as<ArrayObject>();
323 if (!array) {
324 return (listValueType.flags() & QMetaType::PointerToQObject)
325 ? QmlListWrapper::create(engine, listValueType)
326 : SequencePrototype::fromData(engine, type, metaSequence(), nullptr);
327 }
328
329 if (listValueType.flags() & QMetaType::PointerToQObject) {
330 QV4::Scoped<QmlListWrapper> newList(scope, QmlListWrapper::create(engine, type));
331 QQmlListProperty<QObject> *listProperty = newList->d()->property();
332
333 const qsizetype length = array->getLength();
334 qsizetype i = 0;
335 ScopedValue v(scope);
336 for (; i < length; ++i) {
337 v = array->get(i);
338 listProperty->append(listProperty, coerceQObject(v, qmlType));
339 }
340
341 return newList->asReturnedValue();
342 }
343
344 QV4::Scoped<Sequence> sequence(
345 scope, SequencePrototype::fromData(engine, type, metaSequence(), nullptr));
346 const qsizetype length = array->getLength();
347 ScopedValue v(scope);
348 for (qsizetype i = 0; i < length; ++i) {
349 v = array->get(i);
350 sequence->put(PropertyKey::fromArrayIndex(i), v);
351 }
352 return sequence->asReturnedValue();
353}
354
356 ExecutionEngine *engine, const Value &value, const QQmlType &qmlType, bool isList)
357{
358 // These are all the named non-list, non-QObject builtins. Only those need special handling.
359 // Some of them may be wrapped in VariantObject because that is how they are stored in VME
360 // properties.
361 if (isList)
362 return coerceListType(engine, value, qmlType);
363
364 const QMetaType metaType = qmlType.typeId();
365 if (!metaType.isValid()) {
366 if (!value.isUndefined())
367 warnAboutCoercionToVoid(engine, value, InsufficientAnnotation);
368 return value.asReturnedValue();
369 }
370
371 switch (metaType.id()) {
372 case QMetaType::Void:
373 return Encode::undefined();
374 case QMetaType::QVariant:
375 return value.asReturnedValue();
376 case QMetaType::Int:
377 return Encode(value.toInt32());
378 case QMetaType::Double:
379 return value.convertedToNumber();
380 case QMetaType::QString:
381 return value.toString(engine)->asReturnedValue();
382 case QMetaType::Bool:
383 return Encode(value.toBoolean());
384 case QMetaType::QDateTime:
385 if (value.as<DateObject>())
386 return value.asReturnedValue();
387 if (const VariantObject *varObject = value.as<VariantObject>()) {
388 const QVariant &var = varObject->d()->data();
389 switch (var.metaType().id()) {
390 case QMetaType::QDateTime:
391 return engine->newDateObject(var.value<QDateTime>())->asReturnedValue();
392 case QMetaType::QTime:
393 return engine->newDateObject(var.value<QTime>(), nullptr, -1, 0)->asReturnedValue();
394 case QMetaType::QDate:
395 return engine->newDateObject(var.value<QDate>(), nullptr, -1, 0)->asReturnedValue();
396 default:
397 break;
398 }
399 }
400 return engine->newDateObject(QDateTime())->asReturnedValue();
401 case QMetaType::QUrl:
402 if (value.as<UrlObject>())
403 return value.asReturnedValue();
404 if (const VariantObject *varObject = value.as<VariantObject>()) {
405 const QVariant &var = varObject->d()->data();
406 return var.metaType() == QMetaType::fromType<QUrl>()
407 ? engine->newUrlObject(var.value<QUrl>())->asReturnedValue()
408 : engine->newUrlObject()->asReturnedValue();
409 }
410 // Since URL properties are stored as string, we need to support the string conversion here.
411 if (const String *string = value.stringValue())
412 return engine->newUrlObject(QUrl(string->toQString()))->asReturnedValue();
413 return engine->newUrlObject()->asReturnedValue();
414#if QT_CONFIG(regularexpression)
415 case QMetaType::QRegularExpression:
416 if (value.as<RegExpObject>())
417 return value.asReturnedValue();
418 if (const VariantObject *varObject = value.as<VariantObject>()) {
419 const QVariant &var = varObject->d()->data();
420 if (var.metaType() == QMetaType::fromType<QRegularExpression>())
421 return engine->newRegExpObject(var.value<QRegularExpression>())->asReturnedValue();
422 }
423 return engine->newRegExpObject(QString(), 0)->asReturnedValue();
424#endif
425 default:
426 break;
427 }
428
429 if (metaType.flags() & QMetaType::PointerToQObject) {
430 return coerceQObject(value, qmlType)
431 ? value.asReturnedValue()
432 : Encode::null();
433 }
434
435 if (const QQmlValueTypeWrapper *wrapper = value.as<QQmlValueTypeWrapper>()) {
436 if (wrapper->type() == metaType)
437 return value.asReturnedValue();
438 }
439
440 if (void *target = QQmlValueTypeProvider::heapCreateValueType(qmlType, value, engine)) {
441 Heap::QQmlValueTypeWrapper *wrapper = engine->memoryManager->allocate<QQmlValueTypeWrapper>(
442 nullptr, metaType, qmlType.metaObjectForValueType(),
443 nullptr, -1, Heap::ReferenceObject::NoFlag);
444 Q_ASSERT(!wrapper->gadgetPtr());
445 wrapper->setGadgetPtr(target);
446 return wrapper->asReturnedValue();
447 }
448
449 return Encode::undefined();
450}
451
452// Missing arguments are undefined. Coerce them like any explicitly passed undefined.
453inline void constructFromUndefined(QMetaType type, void *data)
454{
455 type.construct(data);
456 if (type != QMetaType::fromType<QVariant>())
457 ExecutionEngine::metaTypeFromJS(Value::undefinedValue(), type, data);
458}
459
460template<typename Callable>
462 ExecutionEngine *engine,
463 const Function::JSTypedFunction *typedFunction, const CompiledData::Function *compiledFunction,
464 const Value *argv, int argc, Callable call)
465{
466 Scope scope(engine);
467
468 QV4::JSCallArguments jsCallData(scope, typedFunction->types.size() - 1);
469 const CompiledData::Parameter *formals = compiledFunction->formalsTable();
470 for (qsizetype i = 0; i < jsCallData.argc; ++i) {
471 jsCallData.args[i] = coerce(
472 engine, i < argc ? argv[i] : QV4::Value::fromReturnedValue(Encode::undefined()),
473 typedFunction->types[i + 1], formals[i].type.isList());
474 }
475
476 ScopedValue result(scope, call(jsCallData.args, jsCallData.argc));
477 return coerce(engine, result, typedFunction->types[0], compiledFunction->returnType.isList());
478}
479
480// Note: \a to is unininitialized here! This is in contrast to most other related functions.
481inline void coerce(
482 ExecutionEngine *engine, QMetaType fromType, const void *from, QMetaType toType, void *to)
483{
484 if ((fromType.flags() & QMetaType::PointerToQObject)
485 && (toType.flags() & QMetaType::PointerToQObject)) {
486 QObject *fromObj = *static_cast<QObject * const*>(from);
487 *static_cast<QObject **>(to)
488 = (fromObj && fromObj->metaObject()->inherits(toType.metaObject()))
489 ? fromObj
490 : nullptr;
491 return;
492 }
493
494 if (toType == QMetaType::fromType<QVariant>()) {
495 new (to) QVariant(fromType, from);
496 return;
497 }
498
499 if (toType == QMetaType::fromType<QJSPrimitiveValue>()) {
500 new (to) QJSPrimitiveValue(fromType, from);
501 return;
502 }
503
504 if (fromType == QMetaType::fromType<QVariant>()) {
505 const QVariant *fromVariant = static_cast<const QVariant *>(from);
506 if (fromVariant->metaType() == toType)
507 toType.construct(to, fromVariant->data());
508 else
509 coerce(engine, fromVariant->metaType(), fromVariant->data(), toType, to);
510 return;
511 }
512
513 if (fromType == QMetaType::fromType<QJSPrimitiveValue>()) {
514 const QJSPrimitiveValue *fromPrimitive = static_cast<const QJSPrimitiveValue *>(from);
515 if (fromPrimitive->metaType() == toType)
516 toType.construct(to, fromPrimitive->data());
517 else
518 coerce(engine, fromPrimitive->metaType(), fromPrimitive->data(), toType, to);
519 return;
520 }
521
522 // TODO: This is expensive. We might establish a direct C++-to-C++ type coercion, like we have
523 // for JS-to-JS. However, we shouldn't need this very often. Most of the time the compiler
524 // will generate code that passes the right arguments.
525 if (toType.flags() & QMetaType::NeedsConstruction)
526 toType.construct(to);
527 QV4::Scope scope(engine);
528 QV4::ScopedValue value(scope, engine->fromData(fromType, from));
529 if (!ExecutionEngine::metaTypeFromJS(value, toType, to))
530 QMetaType::convert(fromType, from, toType, to);
531}
532
533template<typename TypedFunction, typename Callable>
535 ExecutionEngine *engine, const TypedFunction *typedFunction,
536 void **argv, const QMetaType *types, int argc, Callable call)
537{
538 Q_ALLOCA_INIT();
539 const qsizetype numFunctionArguments = typedFunction->parameterCount();
540
541 Q_ALLOCA_DECLARE(void *, transformedArguments);
542 Q_ALLOCA_DECLARE(void, transformedResult);
543
544 const QMetaType returnType = typedFunction->returnMetaType();
545 const QMetaType frameReturn = types[0];
546 bool returnsQVariantWrapper = false;
547 if (argv[0] && returnType != frameReturn) {
548 Q_ALLOCA_ASSIGN(void *, transformedArguments, (numFunctionArguments + 1) * sizeof(void *));
549 memcpy(transformedArguments, argv, (argc + 1) * sizeof(void *));
550
551 if (frameReturn == QMetaType::fromType<QVariant>()) {
552 QVariant *returnValue = static_cast<QVariant *>(argv[0]);
553 *returnValue = QVariant(returnType);
554 transformedResult = transformedArguments[0] = returnValue->data();
555 returnsQVariantWrapper = true;
556 } else if (returnType.sizeOf() > 0) {
557 Q_ALLOCA_ASSIGN(void, transformedResult, returnType.sizeOf());
558 transformedArguments[0] = transformedResult;
559 if (returnType.flags() & QMetaType::NeedsConstruction)
560 returnType.construct(transformedResult);
561 } else {
562 transformedResult = transformedArguments[0] = &argc; // Some non-null marker value
563 }
564 }
565
566 for (qsizetype i = 0; i < numFunctionArguments; ++i) {
567 const bool isValid = argc > i;
568 const QMetaType frameType = isValid ? types[i + 1] : QMetaType();
569
570 const QMetaType argumentType = typedFunction->parameterMetaType(i);
571 if (isValid && argumentType == frameType)
572 continue;
573
574 if (transformedArguments == nullptr) {
575 Q_ALLOCA_ASSIGN(void *, transformedArguments, (numFunctionArguments + 1) * sizeof(void *));
576 memcpy(transformedArguments, argv, (argc + 1) * sizeof(void *));
577 }
578
579 if (argumentType.sizeOf() == 0) {
580 transformedArguments[i + 1] = nullptr;
581 continue;
582 }
583
584 void *frameVal = isValid ? argv[i + 1] : nullptr;
585 if (isValid && frameType == QMetaType::fromType<QVariant>()) {
586 QVariant *variant = static_cast<QVariant *>(frameVal);
587
588 const QMetaType variantType = variant->metaType();
589 if (variantType == argumentType) {
590 // Slightly nasty, but we're allowed to do this.
591 // We don't want to destruct() the QVariant's data() below.
592 transformedArguments[i + 1] = argv[i + 1] = variant->data();
593 } else {
594 Q_ALLOCA_VAR(void, arg, argumentType.sizeOf());
595 coerce(engine, variantType, variant->constData(), argumentType, arg);
596 transformedArguments[i + 1] = arg;
597 }
598 continue;
599 }
600
601 Q_ALLOCA_VAR(void, arg, argumentType.sizeOf());
602
603 if (isValid)
604 coerce(engine, frameType, frameVal, argumentType, arg);
605 else
606 constructFromUndefined(argumentType, arg);
607
608 transformedArguments[i + 1] = arg;
609 }
610
611 if (!transformedArguments) {
612 call(argv, numFunctionArguments);
613 return;
614 }
615
616 call(transformedArguments, numFunctionArguments);
617
618 if (transformedResult && !returnsQVariantWrapper) {
619 if (frameReturn.sizeOf() > 0) {
620 if (frameReturn.flags() & QMetaType::NeedsDestruction)
621 frameReturn.destruct(argv[0]);
622 coerce(engine, returnType, transformedResult, frameReturn, argv[0]);
623 }
624 if (returnType.flags() & QMetaType::NeedsDestruction)
625 returnType.destruct(transformedResult);
626 }
627
628 for (qsizetype i = 0; i < numFunctionArguments; ++i) {
629 void *arg = transformedArguments[i + 1];
630 if (arg == nullptr)
631 continue;
632 if (i >= argc || arg != argv[i + 1]) {
633 const QMetaType argumentType = typedFunction->parameterMetaType(i);
634 if (argumentType.flags() & QMetaType::NeedsDestruction)
635 argumentType.destruct(arg);
636 }
637 }
638}
639
640} // namespace QV4
641
642QT_END_NAMESPACE
643
644#endif // QV4JSCALL_H
Combined button and popup list for selecting options.
Definition qjsvalue.h:24
QObject * cppThisObject(const Value *thisObject)
ReturnedValue coerceListType(ExecutionEngine *engine, const Value &value, const QQmlType &qmlType)
void coerce(ExecutionEngine *engine, QMetaType fromType, const void *from, QMetaType toType, void *to)
@ STRING_HINT
@ PREFERREDTYPE_HINT
@ NUMBER_HINT
CoercionProblem
@ InvalidListType
@ InsufficientAnnotation
ReturnedValue coerce(ExecutionEngine *engine, const Value &value, const QQmlType &qmlType, bool isList)
void constructFromUndefined(QMetaType type, void *data)
void populateJSCallArguments(ExecutionEngine *v4, JSCallArguments &jsCall, int argc, void **args, const QMetaType *types)
Definition qv4jscall.cpp:19
uint Bool
ReturnedValue defaultConvertReturnValue(ExecutionEngine *engine, QMetaType returnType, void *returnValue)
Scoped< Object > ScopedObject
QObject * coerceQObject(const Value &value, const QQmlType &qmlType)
bool convertAndCall(ExecutionEngine *engine, QObject *thisObject, void **a, const QMetaType *types, int argc, Callable call)
void coerceAndCall(ExecutionEngine *engine, const TypedFunction *typedFunction, void **argv, const QMetaType *types, int argc, Callable call)
ReturnedValue coerceAndCall(ExecutionEngine *engine, const Function::JSTypedFunction *typedFunction, const CompiledData::Function *compiledFunction, const Value *argv, int argc, Callable call)
bool defaultConversionErrorHandler(QMetaType argumentType, void *argument, qsizetype i)
ReturnedValue convertAndCall(ExecutionEngine *engine, const QMetaType *types, int numTypes, const Value *argv, int argc, Callable &&call, ConstructReturnValue &&constructReturnValue=defaultConstructReturnValue, ConvertReturnValue &&convertReturnValue=defaultConvertReturnValue, ConversionErrorHandler &&errorHandler=defaultConversionErrorHandler)
Q_QML_EXPORT void warnAboutCoercionToVoid(ExecutionEngine *engine, const Value &value, CoercionProblem problem)
Definition qv4jscall.cpp:26
CallData * callDatafromJS(const Scope &scope, const Args *args, const FunctionObject *f)
Definition qv4jscall_p.h:41
void defaultConstructReturnValue(QMetaType returnType, void *returnValue)
Q_STATIC_ASSERT(sizeof(SharedImageHeader) % 4==0)
DEFINE_MANAGED_VTABLE(ArrayData)
JSCallArguments(const Scope &scope, int argc=0)
Definition qv4jscall_p.h:60
CallData * callData(const Scope &scope, const FunctionObject *f=nullptr) const
Definition qv4jscall_p.h:65
const int argc
Definition qv4jscall_p.h:94
CallData * callData(const Scope &scope, const FunctionObject *f=nullptr) const
Definition qv4jscall_p.h:87
const Value * thisObject
Definition qv4jscall_p.h:92
JSCallData(const Value *thisObject, const Value *argv, int argc)
Definition qv4jscall_p.h:77
const Value * args
Definition qv4jscall_p.h:93
static PropertyKey fromArrayIndex(uint idx)
Scope(ExecutionEngine *e)
ScopedValue(const Scope &scope)