4#ifndef QV4FUNCTIONOBJECT_H
5#define QV4FUNCTIONOBJECT_H
21#include <private/qv4mm_p.h>
29struct IndexedBuiltinFunction;
46#define FunctionObjectMembers(class, Member)
49 Index_ProtoConstructor = 0,
51 Index_HasInstance = 1,
54 Q_QML_EXPORT
void init(
QV4::ExecutionEngine *engine,
QV4::String *name =
nullptr);
55 Q_QML_EXPORT
void init(
QV4::ExecutionEngine *engine,
const QString &name);
56 Q_QML_EXPORT
void init();
59#define JavaScriptFunctionObjectMembers(class, Member)
60 Member(class, Pointer, ExecutionContext *, scope)
61 Member(class, NoMark, Function *, function)
64 DECLARE_MARKOBJECTS(JavaScriptFunctionObject)
66 void init(QV4::ExecutionContext *scope, QV4::Function *function, QV4::String *n =
nullptr);
67 Q_QML_EXPORT
void destroy();
69 void setFunction(Function *f);
71 unsigned int formalParameterCount() {
return function ? function->nFormals : 0; }
72 unsigned int varCount() {
return function ? function->compiledFunction->nLocals : 0; }
75#define DynamicFunctionObjectMembers(class, Member)
76 Member(class, NoMark, VTable::Call, jsCall)
82 void init(ExecutionEngine *engine,
QV4::String *name, VTable::Call call);
86 void init(
QV4::ExecutionEngine *engine);
96 inline void init(
QV4::ExecutionEngine *engine, qsizetype index, VTable::Call call);
105 void init(
QV4::ExecutionContext *scope, Function *function,
QV4::String *name =
nullptr);
108#define ScriptFunctionMembers(class, Member)
109 Member(class, Pointer, InternalClass *, cachedClassForConstructor)
112 DECLARE_MARKOBJECTS(ScriptFunction)
113 void init(QV4::ExecutionContext *scope, Function *function);
116#define MemberFunctionMembers(class, Member)
117 Member(class, Pointer, Object *, homeObject)
120 DECLARE_MARKOBJECTS(MemberFunction)
122 void init(QV4::ExecutionContext *scope, Function *function, QV4::String *name =
nullptr) {
123 ArrowFunction::init(scope, function, name);
127#define ConstructorFunctionMembers(class, Member)
128 Member(class, Pointer, Object *, homeObject)
131 DECLARE_MARKOBJECTS(ConstructorFunction)
132 bool isDerivedConstructor;
135#define DefaultClassConstructorFunctionMembers(class, Member)
136 Member(class, Pointer, ExecutionContext *, scope)
139 DECLARE_MARKOBJECTS(DefaultClassConstructorFunction)
141 bool isDerivedConstructor;
143 void init(
QV4::ExecutionContext *scope);
146#define BoundFunctionMembers(class, Member)
147 Member(class, Pointer, FunctionObject *, target)
148 Member(class, HeapValue, HeapValue, boundThis)
149 Member(class, Pointer, MemberData *, boundArgs)
152 DECLARE_MARKOBJECTS(BoundFunction)
154 void init(QV4::FunctionObject *target,
const Value &boundThis, QV4::MemberData *boundArgs);
282 const FunctionObject *f,
const Value *thisObject,
const Value *argv,
int argc);
297 QV4::ExecutionEngine *engine, qsizetype index, VTable::Call call)
299 Heap::FunctionObject::init(engine);
313 void **a,
const QMetaType *types,
int argc);
315 const QV4::Value *argv,
int argc);
372 return v4->hasException ? QV4::Encode::undefined() : result;
DECLARE_HEAP_OBJECT(DynamicFunctionObject, FunctionObject)
DECLARE_HEAP_OBJECT(BoundFunction, JavaScriptFunctionObject)
DECLARE_HEAP_OBJECT(ConstructorFunction, ScriptFunction)
DECLARE_HEAP_OBJECT(FunctionObject, Object)
DECLARE_HEAP_OBJECT(JavaScriptFunctionObject, FunctionObject)
DECLARE_HEAP_OBJECT(MemberFunction, ArrowFunction)
DECLARE_HEAP_OBJECT(ScriptFunction, ArrowFunction)
ReturnedValue checkedResult(QV4::ExecutionEngine *v4, ReturnedValue result)
DEFINE_OBJECT_VTABLE(SharedArrayBufferCtor)
DEFINE_OBJECT_VTABLE(ArrayBufferCtor)
DEFINE_OBJECT_VTABLE(ArrayBuffer)
DEFINE_OBJECT_VTABLE(SharedArrayBuffer)
#define Q_MANAGED_TYPE(type)
#define V4_INTERNALCLASS(c)
#define RETURN_UNDEFINED()
static ReturnedValue method_isView(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_get_byteLength(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_slice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
void init(ExecutionEngine *engine, Object *ctor)
static void virtualCallWithMetaTypes(const FunctionObject *f, QObject *thisObject, void **a, const QMetaType *types, int argc)
static ReturnedValue virtualCall(const QV4::FunctionObject *f, const QV4::Value *thisObject, const QV4::Value *argv, int argc)
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static QQmlRefPointer< ExecutableCompilationUnit > parse(ExecutionEngine *engine, const Value *argv, int argc, Type t=Type_Function)
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 virtualCall(const FunctionObject *f, 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::ExecutionEngine *engine)
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)
void init(QV4::ExecutionEngine *engine)
Heap::InternalClass * classForConstructor() const
static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
void init(ExecutionEngine *engine, Object *ctor)
static ReturnedValue method_get_byteLength(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_slice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue slice(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc, bool shared)