3#ifndef QV4FUNCTIONOBJECT_H
4#define QV4FUNCTIONOBJECT_H
20#include <private/qv4mm_p.h>
28struct IndexedBuiltinFunction;
34#define FunctionObjectMembers(class, Member) \
35 Member(class, Pointer, ExecutionContext *, scope) \
36 Member(class, NoMark, Function *, function) \
37 Member(class, NoMark, VTable::Call, jsCall) \
38 Member(class, NoMark, VTable::CallAsConstructor, jsConstruct) \
39 Member(class, NoMark, VTable::CallWithMetaTypes, jsCallWithMetaTypes) \
40 Member(class, NoMark, bool, canBeTailCalled)
45 Index_ProtoConstructor = 0,
47 Index_HasInstance = 1,
50 bool isConstructor()
const {
51 return jsConstruct !=
nullptr;
54 Q_QML_PRIVATE_EXPORT
void init(
60 Q_QML_PRIVATE_EXPORT
void init();
61 Q_QML_PRIVATE_EXPORT
void destroy();
65 unsigned int formalParameterCount() {
return function ?
function->nFormals : 0; }
66 unsigned int varCount() {
return function ?
function->compiledFunction->nLocals : 0; }
92#define ScriptFunctionMembers(class, Member) \
93 Member(class, Pointer, InternalClass *, cachedClassForConstructor)
100#define MemberFunctionMembers(class, Member) \
101 Member(class, Pointer, Object *, homeObject)
111#define ConstructorFunctionMembers(class, Member) \
112 Member(class, Pointer, Object *, homeObject)
116 bool isDerivedConstructor;
124#define BoundFunctionMembers(class, Member) \
125 Member(class, Pointer, FunctionObject *, target) \
126 Member(class, HeapValue, HeapValue, boundThis) \
127 Member(class, Pointer, MemberData *, boundArgs)
139 IsFunctionObject =
true
146 enum { NInlineProperties = 1 };
149 Heap::ExecutionContext *
scope()
const {
return d()->scope; }
154 unsigned int varCount()
const {
return d()->varCount(); }
157 defineReadonlyConfigurableProperty(
engine()->id_name(), *
name);
159 void createDefaultPrototypeProperty(
uint protoConstructorSlot);
163 if (!
d()->jsConstruct)
165 return d()->jsConstruct(
this, argv, argc, newTarget ? newTarget :
this);
171 return d()->jsCall(
this, thisObject, argv, argc);
179 static Heap::FunctionObject *createConstructorFunction(
ExecutionContext *scope,
Function *function,
Object *homeObject,
bool isDerivedConstructor);
183 bool strictMode()
const {
return d()->function ?
d()->function->isStrict() :
false; }
184 bool isBinding()
const;
185 bool isBoundFunction()
const;
187 return d()->isConstructor();
193 return getValueByIndex(Heap::FunctionObject::Index_Prototype);
196 return !internalClass()->propertyData.at(Heap::FunctionObject::Index_HasInstance).isEmpty();
203inline const FunctionObject *
Value::as()
const {
204 return isManaged() &&
m()->internalClass->vtable->isFunctionObject ?
reinterpret_cast<const FunctionObject *
>(
this) :
nullptr;
243 Heap::FunctionObject::init(
scope);
291 return scope->engine()->memoryManager->allocate<
BoundFunction>(scope,
target, boundThis, boundArgs);
294 Heap::FunctionObject *
target()
const {
return d()->target; }
296 Heap::MemberData *
boundArgs()
const {
return d()->boundArgs; }
304 return d()->vtable() == BoundFunction::staticVTable();
\macro QT_RESTRICTED_CAST_FROM_ASCII
type name READ getFunction WRITE setFunction
[0]
Combined button and popup list for selecting options.
\qmltype Particle \inqmlmodule QtQuick.Particles
ReturnedValue checkedResult(QV4::ExecutionEngine *v4, ReturnedValue result)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
GLboolean GLboolean GLboolean GLboolean a
[7]
GLsizei GLenum GLenum * types
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
#define QStringLiteral(str)
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
#define Q_MANAGED_TYPE(type)
#define V4_INTERNALCLASS(c)
#define DECLARE_HEAP_OBJECT(name, base)
#define DECLARE_MARKOBJECTS(class)
#define V4_OBJECT2(DataClass, superClass)
Heap::FunctionObject * target() const
Heap::MemberData * boundArgs() const
static constexpr ReturnedValue undefined()
static QQmlRefPointer< ExecutableCompilationUnit > parse(ExecutionEngine *engine, const Value *argv, int argc, Type t=Type_Function)
bool isConstructor() const
ReturnedValue protoProperty() const
unsigned int varCount() const
unsigned int formalParameterCount() const
ReturnedValue callAsConstructor(const Value *argv, int argc, const Value *newTarget=nullptr) const
ReturnedValue call(const JSCallData &data) const
bool hasHasInstanceProperty() const
Function * function() const
bool isBoundFunction() const
bool canBeTailCalled() const
ReturnedValue call(const Value *thisObject, const Value *argv, int argc) const
Heap::ExecutionContext * scope() const
void setName(String *name)
void init(ExecutionEngine *engine, Object *ctor)
static ReturnedValue method_bind(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_call(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_hasInstance(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_apply(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
void init(QV4::ExecutionContext *scope, Function *function, QV4::String *name=nullptr)
bool isDerivedConstructor
void init(QV4::ExecutionContext *scope)
void init(QV4::ExecutionContext *scope, qsizetype index, VTable::Call call)
ExecutionEngine * engine() const
static constexpr VTable::CallAsConstructor virtualCallAsConstructor
static constexpr VTable::Call virtualCall
static constexpr VTable::CallWithMetaTypes virtualCallWithMetaTypes
ReturnedValue(* Call)(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
void(* CallWithMetaTypes)(const FunctionObject *, QObject *, void **, const QMetaType *, int)