Qt 4.8
Classes | Public Functions | Static Public Variables | Private Functions | Static Private Functions | Properties | List of all members
QScript::FunctionWrapper Class Reference

#include <qscriptfunction_p.h>

Inheritance diagram for QScript::FunctionWrapper:

Classes

struct  Data
 

Public Functions

virtual const JSC::ClassInfo * classInfo () const
 
QScriptEngine::FunctionSignature function () const
 
 FunctionWrapper (JSC::ExecState *, int length, const JSC::Identifier &, QScriptEngine::FunctionSignature)
 
 ~FunctionWrapper ()
 

Static Public Variables

static const JSC::ClassInfo info = { "QtNativeFunctionWrapper", &PrototypeFunction::info, 0, 0 }
 

Private Functions

virtual JSC::ConstructType getConstructData (JSC::ConstructData &)
 

Static Private Functions

static JSC::JSValue JSC_HOST_CALL proxyCall (JSC::ExecState *, JSC::JSObject *, JSC::JSValue, const JSC::ArgList &)
 
static JSC::JSObject * proxyConstruct (JSC::ExecState *, JSC::JSObject *, const JSC::ArgList &)
 

Properties

Datadata
 

Detailed Description

Definition at line 49 of file qscriptfunction_p.h.

Constructors and Destructors

◆ FunctionWrapper()

QScript::FunctionWrapper::FunctionWrapper ( JSC::ExecState *  exec,
int  length,
const JSC::Identifier &  name,
QScriptEngine::FunctionSignature  function 
)

Definition at line 52 of file qscriptfunction.cpp.

54  : JSC::PrototypeFunction(exec, length, name, proxyCall),
55  data(new Data())
56 {
57  data->function = function;
58 }
QScriptEngine::FunctionSignature function
const char * name
static JSC::JSValue JSC_HOST_CALL proxyCall(JSC::ExecState *, JSC::JSObject *, JSC::JSValue, const JSC::ArgList &)

◆ ~FunctionWrapper()

QScript::FunctionWrapper::~FunctionWrapper ( )

Definition at line 60 of file qscriptfunction.cpp.

61 {
62  delete data;
63 }

Functions

◆ classInfo()

virtual const JSC::ClassInfo* QScript::FunctionWrapper::classInfo ( ) const
inlinevirtual

Definition at line 62 of file qscriptfunction_p.h.

62 { return &info; }
static const JSC::ClassInfo info

◆ function()

QScriptEngine::FunctionSignature QScript::FunctionWrapper::function ( ) const
inline

Definition at line 65 of file qscriptfunction_p.h.

66  { return data->function; }
QScriptEngine::FunctionSignature function

◆ getConstructData()

JSC::ConstructType QScript::FunctionWrapper::getConstructData ( JSC::ConstructData &  consData)
privatevirtual

Definition at line 65 of file qscriptfunction.cpp.

Referenced by QScript::FunctionWithArgWrapper::arg(), and function().

66 {
67  consData.native.function = proxyConstruct;
68  consData.native.function.doNotCallDebuggerFunctionExit();
69  return JSC::ConstructTypeHost;
70 }
static JSC::JSObject * proxyConstruct(JSC::ExecState *, JSC::JSObject *, const JSC::ArgList &)

◆ proxyCall()

JSC::JSValue QScript::FunctionWrapper::proxyCall ( JSC::ExecState *  exec,
JSC::JSObject *  callee,
JSC::JSValue  thisObject,
const JSC::ArgList &  args 
)
staticprivate

Definition at line 72 of file qscriptfunction.cpp.

Referenced by QScript::FunctionWithArgWrapper::arg(), and function().

74 {
75  FunctionWrapper *self = static_cast<FunctionWrapper*>(callee);
77 
78  JSC::ExecState *oldFrame = eng_p->currentFrame;
79  eng_p->pushContext(exec, thisObject, args, callee);
81 
82  QScriptValue result = self->data->function(ctx, QScriptEnginePrivate::get(eng_p));
83  if (!result.isValid())
85 
86  eng_p->popContext();
87  eng_p->currentFrame = oldFrame;
88 
89  return eng_p->scriptValueToJSCValue(result);
90 }
The QScriptContext class represents a Qt Script function invocation.
QScriptEnginePrivate * scriptEngineFromExec(const JSC::ExecState *exec)
static QScriptEnginePrivate * get(QScriptEngine *q)
FunctionWrapper(JSC::ExecState *, int length, const JSC::Identifier &, QScriptEngine::FunctionSignature)
JSC::CallFrame * pushContext(JSC::CallFrame *exec, JSC::JSValue thisObject, const JSC::ArgList &args, JSC::JSObject *callee, bool calledAsConstructor=false, bool clearScopeChain=false)
JSC native function doesn&#39;t have different stackframe or context.
JSC::ExecState * currentFrame
JSC::JSValue scriptValueToJSCValue(const QScriptValue &value)
static QScriptContext * contextForFrame(JSC::ExecState *frame)
QScriptValue data() const
Returns the internal data of this QScriptValue object.
#define ctx
Definition: qgl.cpp:6094
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
bool isValid() const
Returns true if this QScriptValue is valid; otherwise returns false.

◆ proxyConstruct()

JSC::JSObject * QScript::FunctionWrapper::proxyConstruct ( JSC::ExecState *  exec,
JSC::JSObject *  callee,
const JSC::ArgList &  args 
)
staticprivate

Definition at line 92 of file qscriptfunction.cpp.

Referenced by QScript::FunctionWithArgWrapper::arg(), function(), and getConstructData().

94 {
95  FunctionWrapper *self = static_cast<FunctionWrapper*>(callee);
97 
98  JSC::ExecState *oldFrame = eng_p->currentFrame;
99  eng_p->pushContext(exec, JSC::JSValue(), args, callee, true);
101 
102  QScriptValue result = self->data->function(ctx, QScriptEnginePrivate::get(eng_p));
103 
104  if (JSC::Debugger* debugger = eng_p->originalGlobalObject()->debugger())
105  debugger->functionExit(QScriptValuePrivate::get(result)->jscValue, -1);
106 
107  if (!result.isObject())
108  result = ctx->thisObject();
109 
110  eng_p->popContext();
111  eng_p->currentFrame = oldFrame;
112 
113  return JSC::asObject(eng_p->scriptValueToJSCValue(result));
114 }
The QScriptContext class represents a Qt Script function invocation.
QScriptEnginePrivate * scriptEngineFromExec(const JSC::ExecState *exec)
static QScriptEnginePrivate * get(QScriptEngine *q)
FunctionWrapper(JSC::ExecState *, int length, const JSC::Identifier &, QScriptEngine::FunctionSignature)
JSC::CallFrame * pushContext(JSC::CallFrame *exec, JSC::JSValue thisObject, const JSC::ArgList &args, JSC::JSObject *callee, bool calledAsConstructor=false, bool clearScopeChain=false)
JSC native function doesn&#39;t have different stackframe or context.
static QScriptValuePrivate * get(const QScriptValue &q)
JSC::ExecState * currentFrame
JSC::JSValue scriptValueToJSCValue(const QScriptValue &value)
static QScriptContext * contextForFrame(JSC::ExecState *frame)
JSC::JSGlobalObject * originalGlobalObject() const
QScriptValue data() const
Returns the internal data of this QScriptValue object.
#define ctx
Definition: qgl.cpp:6094
JSC::JSValue jscValue
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
bool isObject() const
Returns true if this QScriptValue is of the Object type; otherwise returns false. ...

Properties

◆ data

Data* QScript::FunctionWrapper::data
private

◆ info

const JSC::ClassInfo QScript::FunctionWrapper::info = { "QtNativeFunctionWrapper", &PrototypeFunction::info, 0, 0 }
static

The documentation for this class was generated from the following files: