Qt 4.8
Public Functions | Static Public Functions | Properties | List of all members
QScript::DeclarativeObjectDelegate Class Reference

#include <qscriptdeclarativeobject_p.h>

Inheritance diagram for QScript::DeclarativeObjectDelegate:
QScriptObjectDelegate

Public Functions

bool compareToObject (QScriptObject *, JSC::ExecState *, JSC::JSObject *)
 
 DeclarativeObjectDelegate (QScriptDeclarativeClass *c, QScriptDeclarativeClass::Object *o)
 
virtual bool deleteProperty (QScriptObject *, JSC::ExecState *, const JSC::Identifier &propertyName)
 
virtual JSC::CallType getCallData (QScriptObject *, JSC::CallData &)
 
virtual JSC::ConstructType getConstructData (QScriptObject *, JSC::ConstructData &)
 
virtual void getOwnPropertyNames (QScriptObject *, JSC::ExecState *, JSC::PropertyNameArray &, JSC::EnumerationMode mode=JSC::ExcludeDontEnumProperties)
 
virtual bool getOwnPropertySlot (QScriptObject *, JSC::ExecState *, const JSC::Identifier &propertyName, JSC::PropertySlot &)
 
virtual bool hasInstance (QScriptObject *, JSC::ExecState *, JSC::JSValue value, JSC::JSValue proto)
 
QScriptDeclarativeClass::Objectobject () const
 
virtual void put (QScriptObject *, JSC::ExecState *exec, const JSC::Identifier &propertyName, JSC::JSValue, JSC::PutPropertySlot &)
 
QScriptDeclarativeClassscriptClass () const
 
virtual Type type () const
 
 ~DeclarativeObjectDelegate ()
 
- Public Functions inherited from QScriptObjectDelegate
virtual bool getOwnPropertyDescriptor (QScriptObject *, JSC::ExecState *, const JSC::Identifier &propertyName, JSC::PropertyDescriptor &)
 
virtual void markChildren (QScriptObject *, JSC::MarkStack &markStack)
 
 QScriptObjectDelegate ()
 
virtual ~QScriptObjectDelegate ()
 

Static Public Functions

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

Properties

QScriptDeclarativeClassm_class
 
QScriptDeclarativeClass::Objectm_object
 

Additional Inherited Members

- Public Types inherited from QScriptObjectDelegate
enum  Type { QtObject, Variant, ClassObject, DeclarativeClassObject }
 

Detailed Description

Definition at line 66 of file qscriptdeclarativeobject_p.h.

Constructors and Destructors

◆ DeclarativeObjectDelegate()

QScript::DeclarativeObjectDelegate::DeclarativeObjectDelegate ( QScriptDeclarativeClass c,
QScriptDeclarativeClass::Object o 
)

Definition at line 48 of file qscriptdeclarativeobject.cpp.

50 : m_class(c), m_object(o)
51 {
52 }
QScriptDeclarativeClass::Object * m_object

◆ ~DeclarativeObjectDelegate()

QScript::DeclarativeObjectDelegate::~DeclarativeObjectDelegate ( )

Definition at line 54 of file qscriptdeclarativeobject.cpp.

55 {
56  delete m_object;
57 }
QScriptDeclarativeClass::Object * m_object

Functions

◆ call()

JSC::JSValue QScript::DeclarativeObjectDelegate::call ( JSC::ExecState *  exec,
JSC::JSObject *  callee,
JSC::JSValue  thisValue,
const JSC::ArgList &  args 
)
static

Definition at line 135 of file qscriptdeclarativeobject.cpp.

Referenced by getCallData().

137 {
138  if (!callee->inherits(&QScriptObject::info))
139  return JSC::throwError(exec, JSC::TypeError, "callee is not a DeclarativeObject object");
140  QScriptObject *obj = static_cast<QScriptObject*>(callee);
141  QScriptObjectDelegate *delegate = obj->delegate();
142  if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
143  return JSC::throwError(exec, JSC::TypeError, "callee is not a DeclarativeObject object");
144 
147 
148  QScript::SaveFrameHelper saveFrame(eng_p, exec);
149  eng_p->pushContext(exec, thisValue, args, callee);
150  QScriptContext *ctxt = eng_p->contextForFrame(eng_p->currentFrame);
151 
152  QScriptValue scriptObject = eng_p->scriptValueFromJSCValue(obj);
154  scriptClass->call(static_cast<DeclarativeObjectDelegate*>(delegate)->m_object, ctxt);
155 
156  eng_p->popContext();
157  return (JSC::JSValue &)(result);
158 }
The QScriptContext class represents a Qt Script function invocation.
virtual Value call(Object *, QScriptContext *)
QScriptEnginePrivate * scriptEngineFromExec(const JSC::ExecState *exec)
virtual Type type() const =0
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.
QScriptObjectDelegate * delegate() const
static const JSC::ClassInfo info
The QScriptDeclarativeClass::Value class acts as a container for JavaScript data types.
JSC::ExecState * currentFrame
static QScriptContext * contextForFrame(JSC::ExecState *frame)
QScriptValue scriptValueFromJSCValue(JSC::JSValue value)
QScriptDeclarativeClass * scriptClass() const
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
DeclarativeObjectDelegate(QScriptDeclarativeClass *c, QScriptDeclarativeClass::Object *o)
QScriptDeclarativeClass::Object * m_object

◆ compareToObject()

bool QScript::DeclarativeObjectDelegate::compareToObject ( QScriptObject o,
JSC::ExecState *  exec,
JSC::JSObject *  o2 
)
virtual

Reimplemented from QScriptObjectDelegate.

Definition at line 171 of file qscriptdeclarativeobject.cpp.

172 {
173  if (!o2->inherits(&QScriptObject::info))
174  return false;
175 
176  QScriptObject *scriptObject = static_cast<QScriptObject*>(o2);
177  QScriptObjectDelegate *delegate = scriptObject->delegate();
178  if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
179  return false;
180 
181  DeclarativeObjectDelegate *other = static_cast<DeclarativeObjectDelegate*>(delegate);
182  if (m_class != other->m_class)
183  return false;
184  else
185  return m_class->compare(m_object, other->m_object);
186 }
virtual Type type() const =0
QScriptObjectDelegate * delegate() const
static const JSC::ClassInfo info
virtual bool compare(Object *, Object *)
DeclarativeObjectDelegate(QScriptDeclarativeClass *c, QScriptDeclarativeClass::Object *o)
QScriptDeclarativeClass::Object * m_object

◆ deleteProperty()

bool QScript::DeclarativeObjectDelegate::deleteProperty ( QScriptObject object,
JSC::ExecState *  exec,
const JSC::Identifier &  propertyName 
)
virtual

Reimplemented from QScriptObjectDelegate.

Definition at line 108 of file qscriptdeclarativeobject.cpp.

110 {
111  return QScriptObjectDelegate::deleteProperty(object, exec, propertyName);
112 }
virtual bool deleteProperty(QScriptObject *, JSC::ExecState *, const JSC::Identifier &propertyName)

◆ getCallData()

JSC::CallType QScript::DeclarativeObjectDelegate::getCallData ( QScriptObject object,
JSC::CallData &  callData 
)
virtual

Reimplemented from QScriptObjectDelegate.

Definition at line 127 of file qscriptdeclarativeobject.cpp.

128 {
129  if (!QScriptDeclarativeClassPrivate::get(m_class)->supportsCall)
130  return JSC::CallTypeNone;
131  callData.native.function = call;
132  return JSC::CallTypeHost;
133 }
static QScriptDeclarativeClassPrivate * get(QScriptDeclarativeClass *c)
static JSC::JSValue JSC_HOST_CALL call(JSC::ExecState *, JSC::JSObject *, JSC::JSValue, const JSC::ArgList &)

◆ getConstructData()

JSC::ConstructType QScript::DeclarativeObjectDelegate::getConstructData ( QScriptObject object,
JSC::ConstructData &  constructData 
)
virtual

Reimplemented from QScriptObjectDelegate.

Definition at line 160 of file qscriptdeclarativeobject.cpp.

161 {
162  return QScriptObjectDelegate::getConstructData(object, constructData);
163 }
virtual JSC::ConstructType getConstructData(QScriptObject *, JSC::ConstructData &)

◆ getOwnPropertyNames()

void QScript::DeclarativeObjectDelegate::getOwnPropertyNames ( QScriptObject object,
JSC::ExecState *  exec,
JSC::PropertyNameArray &  propertyNames,
JSC::EnumerationMode  mode = JSC::ExcludeDontEnumProperties 
)
virtual

Reimplemented from QScriptObjectDelegate.

Definition at line 114 of file qscriptdeclarativeobject.cpp.

117 {
119  for (int ii = 0; ii < properties.count(); ++ii) {
120  const QString &name = properties.at(ii);
121  propertyNames.add(JSC::Identifier(exec, name));
122  }
123 
124  QScriptObjectDelegate::getOwnPropertyNames(object, exec, propertyNames, mode);
125 }
virtual void getOwnPropertyNames(QScriptObject *, JSC::ExecState *, JSC::PropertyNameArray &, JSC::EnumerationMode mode=JSC::ExcludeDontEnumProperties)
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
The QString class provides a Unicode character string.
Definition: qstring.h:83
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static const QCssKnownValue properties[NumProperties - 1]
Definition: qcssparser.cpp:67
virtual QStringList propertyNames(Object *)
QScriptDeclarativeClass::Object * m_object

◆ getOwnPropertySlot()

bool QScript::DeclarativeObjectDelegate::getOwnPropertySlot ( QScriptObject object,
JSC::ExecState *  exec,
const JSC::Identifier &  propertyName,
JSC::PropertySlot &  slot 
)
virtual

Reimplemented from QScriptObjectDelegate.

Definition at line 64 of file qscriptdeclarativeobject.cpp.

68 {
69  QScriptDeclarativeClass::Identifier identifier = (void *)propertyName.ustring().rep();
70 
72  p->context = reinterpret_cast<QScriptContext *>(exec);
73  QScriptClass::QueryFlags flags =
75  if (flags & QScriptClass::HandlesReadAccess) {
77  p->context = 0;
78  slot.setValue((const JSC::JSValue &)val);
79  return true;
80  }
81  p->context = 0;
82 
83  return QScriptObjectDelegate::getOwnPropertySlot(object, exec, propertyName, slot);
84 }
The QScriptContext class represents a Qt Script function invocation.
The QScriptDeclarativeClass::Value class acts as a container for JavaScript data types.
virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags)
static QScriptDeclarativeClassPrivate * get(QScriptDeclarativeClass *c)
virtual bool getOwnPropertySlot(QScriptObject *, JSC::ExecState *, const JSC::Identifier &propertyName, JSC::PropertySlot &)
static QScriptValue property(const QScriptValue &, const Identifier &)
QScriptDeclarativeClass::Object * m_object

◆ hasInstance()

bool QScript::DeclarativeObjectDelegate::hasInstance ( QScriptObject object,
JSC::ExecState *  exec,
JSC::JSValue  value,
JSC::JSValue  proto 
)
virtual

Reimplemented from QScriptObjectDelegate.

Definition at line 165 of file qscriptdeclarativeobject.cpp.

167 {
168  return QScriptObjectDelegate::hasInstance(object, exec, value, proto);
169 }
virtual bool hasInstance(QScriptObject *, JSC::ExecState *, JSC::JSValue value, JSC::JSValue proto)

◆ object()

QScriptDeclarativeClass::Object* QScript::DeclarativeObjectDelegate::object ( ) const
inline

Definition at line 75 of file qscriptdeclarativeobject_p.h.

75 { return m_object; }
QScriptDeclarativeClass::Object * m_object

◆ put()

void QScript::DeclarativeObjectDelegate::put ( QScriptObject object,
JSC::ExecState *  exec,
const JSC::Identifier &  propertyName,
JSC::JSValue  value,
JSC::PutPropertySlot &  slot 
)
virtual

Reimplemented from QScriptObjectDelegate.

Definition at line 86 of file qscriptdeclarativeobject.cpp.

89 {
91  QScript::SaveFrameHelper saveFrame(engine, exec);
92  QScriptDeclarativeClass::Identifier identifier = (void *)propertyName.ustring().rep();
93 
95  p->context = reinterpret_cast<QScriptContext *>(exec);
96  QScriptClass::QueryFlags flags =
99  m_class->setProperty(m_object, identifier, engine->scriptValueFromJSCValue(value));
100  p->context = 0;
101  return;
102  }
103  p->context = 0;
104 
105  QScriptObjectDelegate::put(object, exec, propertyName, value, slot);
106 }
The QScriptContext class represents a Qt Script function invocation.
QScriptEnginePrivate * scriptEngineFromExec(const JSC::ExecState *exec)
virtual void put(QScriptObject *, JSC::ExecState *exec, const JSC::Identifier &propertyName, JSC::JSValue, JSC::PutPropertySlot &)
virtual void setProperty(Object *, const Identifier &name, const QScriptValue &)
virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags)
static QScriptDeclarativeClassPrivate * get(QScriptDeclarativeClass *c)
QScriptValue scriptValueFromJSCValue(JSC::JSValue value)
QScriptDeclarativeClass::Object * m_object

◆ scriptClass()

QScriptDeclarativeClass* QScript::DeclarativeObjectDelegate::scriptClass ( ) const
inline

Definition at line 74 of file qscriptdeclarativeobject_p.h.

Referenced by call().

74 { return m_class; }

◆ type()

QScriptObjectDelegate::Type QScript::DeclarativeObjectDelegate::type ( ) const
virtual

Properties

◆ m_class

QScriptDeclarativeClass* QScript::DeclarativeObjectDelegate::m_class
private

◆ m_object

QScriptDeclarativeClass::Object* QScript::DeclarativeObjectDelegate::m_object
private

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