3#ifndef QV4FUNCTIONOBJECT_H
4#define QV4FUNCTIONOBJECT_H
20#include <private/qv4mm_p.h>
28struct IndexedBuiltinFunction;
45#define FunctionObjectMembers(class, Member)
48 Index_ProtoConstructor = 0,
50 Index_HasInstance = 1,
55 Q_QML_EXPORT
void init();
58#define JavaScriptFunctionObjectMembers(class, Member) \
59 Member(class, Pointer, ExecutionContext *, scope) \
60 Member(class, NoMark, Function *, function)
66 Q_QML_EXPORT
void destroy();
70 unsigned int formalParameterCount() {
return function ? function->nFormals : 0; }
71 unsigned int varCount() {
return function ? function->compiledFunction->nLocals : 0; }
74#define DynamicFunctionObjectMembers(class, Member) \
75 Member(class, NoMark, VTable::Call, jsCall)
107#define ScriptFunctionMembers(class, Member) \
108 Member(class, Pointer, InternalClass *, cachedClassForConstructor)
115#define MemberFunctionMembers(class, Member) \
116 Member(class, Pointer, Object *, homeObject)
126#define ConstructorFunctionMembers(class, Member) \
127 Member(class, Pointer, Object *, homeObject)
131 bool isDerivedConstructor;
134#define DefaultClassConstructorFunctionMembers(class, Member) \
135 Member(class, Pointer, ExecutionContext *, scope)
140 bool isDerivedConstructor;
145#define BoundFunctionMembers(class, Member) \
146 Member(class, Pointer, FunctionObject *, target) \
147 Member(class, HeapValue, HeapValue, boundThis) \
148 Member(class, Pointer, MemberData *, boundArgs)
165 enum { NInlineProperties = 1 };
172 defineReadonlyConfigurableProperty(
engine()->id_name(), *
name);
174 void createDefaultPrototypeProperty(
uint protoConstructorSlot);
177 const Value *argv,
int argc,
const Value *newTarget =
nullptr)
const
179 if (
const auto callAsConstructor = vtable()->callAsConstructor)
180 return callAsConstructor(
this, argv, argc, newTarget ? newTarget :
this);
181 return failCallAsConstructor();
186 if (
const auto call = vtable()->call)
187 return call(
this, thisObject, argv, argc);
193 if (
const auto callWithMetaTypes = vtable()->callWithMetaTypes)
194 callWithMetaTypes(
this, thisObject, argv,
types, argc);
204 static void virtualConvertAndCall(
209 static Heap::FunctionObject *createConstructorFunction(
ExecutionContext *scope,
Function *function,
Object *homeObject,
bool isDerivedConstructor);
213 bool isBinding()
const;
214 bool isBoundFunction()
const;
220 return getValueByIndex(Heap::FunctionObject::Index_Prototype);
223 return !internalClass()->propertyData.at(Heap::FunctionObject::Index_HasInstance).isEmpty();
232 const VTable *vtable =
m()->internalClass->vtable;
243 Heap::ExecutionContext *
scope()
const {
return d()->scope; }
247 unsigned int varCount()
const {
return d()->varCount(); }
248 bool strictMode()
const {
return d()->function ?
d()->function->isStrict() :
false; }
298 Heap::FunctionObject::init(
engine);
351 Heap::MemberData *
boundArgs()
const {
return d()->boundArgs; }
365 const VTable *vtable =
d()->vtable();
366 return vtable == BoundFunction::staticVTable() || vtable == BoundConstructor::staticVTable();
\macro QT_RESTRICTED_CAST_FROM_ASCII
type name READ getFunction WRITE setFunction
[0]
Combined button and popup list for selecting options.
ReturnedValue checkedResult(QV4::ExecutionEngine *v4, ReturnedValue result)
GLboolean GLboolean GLboolean GLboolean a
[7]
GLsizei GLenum GLenum * types
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
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::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
void call(QObject *thisObject, void **argv, const QMetaType *types, int argc) const
ReturnedValue callAsConstructor(const Value *argv, int argc, const Value *newTarget=nullptr) const
bool hasHasInstanceProperty() const
bool isBoundFunction() const
bool canBeTailCalled() const
ReturnedValue call(const Value *thisObject, const Value *argv, int argc) 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)
void init(QV4::ExecutionEngine *engine)
void init(QV4::ExecutionEngine *engine, qsizetype index, VTable::Call call)
unsigned int formalParameterCount() const
unsigned int varCount() const
V4_NEEDS_DESTROY Heap::ExecutionContext * scope() const
Function * function() const
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)
CallAsConstructor callAsConstructor