Qt 4.8
Classes | Public Types | Public Functions | Static Public Functions | Protected Variables | Friends | List of all members
QScriptDeclarativeClass Class Reference

#include <qscriptdeclarativeclass_p.h>

Inheritance diagram for QScriptDeclarativeClass:
FlatListScriptClass QDeclarativeContextScriptClass QDeclarativeListScriptClass QDeclarativeObjectMethodScriptClass QDeclarativeObjectScriptClass QDeclarativeTypeNameScriptClass QDeclarativeValueTypeScriptClass

Classes

struct  Object
 
class  PersistentIdentifier
 
class  Value
 The QScriptDeclarativeClass::Value class acts as a container for JavaScript data types. More...
 

Public Types

typedef void * Identifier
 

Public Functions

virtual Value call (Object *, QScriptContext *)
 
virtual bool compare (Object *, Object *)
 
QScriptContextcontext () const
 
PersistentIdentifier createPersistentIdentifier (const QString &)
 
PersistentIdentifier createPersistentIdentifier (const Identifier &)
 
QScriptEngineengine () const
 
virtual bool isQObject () const
 
virtual Value property (Object *, const Identifier &)
 
virtual QScriptValue::PropertyFlags propertyFlags (Object *, const Identifier &)
 
virtual QStringList propertyNames (Object *)
 
 QScriptDeclarativeClass (QScriptEngine *engine)
 
virtual QScriptClass::QueryFlags queryProperty (Object *, const Identifier &, QScriptClass::QueryFlags flags)
 
virtual void setProperty (Object *, const Identifier &name, const QScriptValue &)
 
void setSupportsCall (bool)
 
bool startsWithUpper (const Identifier &)
 
bool supportsCall () const
 
quint32 toArrayIndex (const Identifier &, bool *ok)
 
virtual QObjecttoQObject (Object *, bool *ok=0)
 
QString toString (const Identifier &)
 
virtual QVariant toVariant (Object *, bool *ok=0)
 
virtual ~QScriptDeclarativeClass ()
 

Static Public Functions

static QScriptValue function (const QScriptValue &, const Identifier &)
 
static Value functionValue (const QScriptValue &, const Identifier &)
 
static QScriptValue newObject (QScriptEngine *, QScriptDeclarativeClass *, Object *)
 
static Value newObjectValue (QScriptEngine *, QScriptDeclarativeClass *, Object *)
 
static QScriptValue newStaticScopeObject (QScriptEngine *, int propertyCount, const QString *names, const QScriptValue *values, const QScriptValue::PropertyFlags *flags)
 Creates a scope object with a fixed set of undeletable properties. More...
 
static QScriptValue newStaticScopeObject (QScriptEngine *)
 Creates a static scope object that's initially empty, but to which new properties can be added. More...
 
static Objectobject (const QScriptValue &)
 
static QScriptValue property (const QScriptValue &, const Identifier &)
 
static Value propertyValue (const QScriptValue &, const Identifier &)
 
static QScriptContextpushCleanContext (QScriptEngine *)
 Enters a new execution context and returns the associated QScriptContext object. More...
 
static QScriptValue scopeChainValue (QScriptContext *, int index)
 
static QScriptDeclarativeClassscriptClass (const QScriptValue &)
 

Protected Variables

QScopedPointer< QScriptDeclarativeClassPrivated_ptr
 

Friends

class QScriptDeclarativeClassPrivate
 

Detailed Description

Definition at line 47 of file qscriptdeclarativeclass_p.h.

Typedefs

◆ Identifier

Definition at line 78 of file qscriptdeclarativeclass_p.h.

Constructors and Destructors

◆ QScriptDeclarativeClass()

QScriptDeclarativeClass::QScriptDeclarativeClass ( QScriptEngine engine)

Definition at line 190 of file qscriptdeclarativeclass.cpp.

192 {
193  Q_ASSERT(sizeof(void*) == sizeof(JSC::Identifier));
194  d_ptr->q_ptr = this;
195  d_ptr->engine = engine;
196 }
QScopedPointer< QScriptDeclarativeClassPrivate > d_ptr
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QScriptEngine * engine() const

◆ ~QScriptDeclarativeClass()

QScriptDeclarativeClass::~QScriptDeclarativeClass ( )
virtual

Definition at line 426 of file qscriptdeclarativeclass.cpp.

427 {
428 }

Functions

◆ call()

QScriptDeclarativeClass::Value QScriptDeclarativeClass::call ( Object object,
QScriptContext ctxt 
)
virtual

Reimplemented in QDeclarativeObjectMethodScriptClass.

Definition at line 528 of file qscriptdeclarativeclass.cpp.

Referenced by QScript::DeclarativeObjectDelegate::call().

530 {
531  Q_UNUSED(object);
532  Q_UNUSED(ctxt);
533  return Value();
534 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ compare()

bool QScriptDeclarativeClass::compare ( Object o,
Object o2 
)
virtual

Reimplemented in QDeclarativeObjectScriptClass, and FlatListScriptClass.

Definition at line 536 of file qscriptdeclarativeclass.cpp.

Referenced by QScript::DeclarativeObjectDelegate::compareToObject().

537 {
538  return o == o2;
539 }

◆ context()

QScriptContext * QScriptDeclarativeClass::context ( ) const

◆ createPersistentIdentifier() [1/2]

QScriptDeclarativeClass::PersistentIdentifier QScriptDeclarativeClass::createPersistentIdentifier ( const QString str)

Definition at line 446 of file qscriptdeclarativeclass.cpp.

Referenced by QDeclarativeTypeNameCache::add(), QDeclarativePropertyCache::append(), QDeclarativeListScriptClass::QDeclarativeListScriptClass(), QDeclarativeObjectMethodScriptClass::QDeclarativeObjectMethodScriptClass(), QDeclarativeObjectScriptClass::QDeclarativeObjectScriptClass(), and QDeclarativeCompiledBindingsPrivate::run().

447 {
450  QScript::APIShim shim(p);
451  JSC::ExecState* exec = p->currentFrame;
452 
453  PersistentIdentifier rv(p);
454  new (&rv.d) JSC::Identifier(exec, (UChar *)str.constData(), str.size());
455  rv.identifier = (void *)((JSC::Identifier &)rv.d).ustring().rep();
456  return rv;
457 }
QScopedPointer< QScriptDeclarativeClassPrivate > d_ptr
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
JSC::ExecState * currentFrame
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712

◆ createPersistentIdentifier() [2/2]

QScriptDeclarativeClass::PersistentIdentifier QScriptDeclarativeClass::createPersistentIdentifier ( const Identifier id)

Definition at line 460 of file qscriptdeclarativeclass.cpp.

461 {
464  QScript::APIShim shim(p);
465  JSC::ExecState* exec = p->currentFrame;
466 
467  PersistentIdentifier rv(p);
468  new (&rv.d) JSC::Identifier(exec, (JSC::UString::Rep *)id);
469  rv.identifier = (void *)((JSC::Identifier &)rv.d).ustring().rep();
470  return rv;
471 }
QScopedPointer< QScriptDeclarativeClassPrivate > d_ptr
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
JSC::ExecState * currentFrame

◆ engine()

QScriptEngine * QScriptDeclarativeClass::engine ( ) const

Definition at line 430 of file qscriptdeclarativeclass.cpp.

Referenced by QDeclarativeContextScriptClass::contextFromValue(), QDeclarativeContextScriptClass::newContext(), QDeclarativeListScriptClass::newList(), QDeclarativeObjectMethodScriptClass::newMethod(), QDeclarativeValueTypeScriptClass::newObject(), QDeclarativeTypeNameScriptClass::newObject(), QDeclarativeObjectScriptClass::newQObject(), QDeclarativeContextScriptClass::newSharedContext(), QDeclarativeContextScriptClass::newUrlContext(), QDeclarativeListScriptClass::property(), QDeclarativeValueTypeScriptClass::property(), QDeclarativeTypeNameScriptClass::property(), QDeclarativeObjectMethodScriptClass::property(), QDeclarativeContextScriptClass::property(), QDeclarativeObjectScriptClass::property(), FlatListScriptClass::property(), QDeclarativeObjectScriptClass::propertyNames(), QDeclarativeListScriptClass::QDeclarativeListScriptClass(), QDeclarativeObjectMethodScriptClass::QDeclarativeObjectMethodScriptClass(), QDeclarativeObjectScriptClass::QDeclarativeObjectScriptClass(), QScriptDeclarativeClass(), QDeclarativeTypeNameScriptClass::queryProperty(), QDeclarativeContextScriptClass::queryProperty(), QDeclarativeObjectScriptClass::queryProperty(), scopeChainValue(), QDeclarativeValueTypeScriptClass::setProperty(), QDeclarativeTypeNameScriptClass::setProperty(), QDeclarativeContextScriptClass::setProperty(), QDeclarativeObjectScriptClass::setProperty(), and QDeclarativeListScriptClass::toVariant().

431 {
432  return d_ptr->engine;
433 }
QScopedPointer< QScriptDeclarativeClassPrivate > d_ptr

◆ function()

QScriptValue QScriptDeclarativeClass::function ( const QScriptValue v,
const Identifier name 
)
static

Definition at line 247 of file qscriptdeclarativeclass.cpp.

248 {
250 
251  if (!d->isObject())
252  return QScriptValue();
253 
254  QScript::APIShim shim(d->engine);
255  JSC::ExecState *exec = d->engine->currentFrame;
256  JSC::JSObject *object = d->jscValue.getObject();
257  JSC::PropertySlot slot(const_cast<JSC::JSObject*>(object));
258  JSC::JSValue result;
259 
260  JSC::Identifier id(exec, (JSC::UString::Rep *)name);
261 
262  if (const_cast<JSC::JSObject*>(object)->getOwnPropertySlot(exec, id, slot)) {
263  result = slot.getValue(exec, id);
264  if (QScript::isFunction(result))
265  return d->engine->scriptValueFromJSCValue(result);
266  }
267 
268  return QScriptValue();
269 }
double d
Definition: qnumeric_p.h:62
static QScriptValuePrivate * get(const QScriptValue &q)
JSC::ExecState * currentFrame
const char * name
bool isFunction(JSC::JSValue value)
bool isObject() const
JSC::JSValue jscValue
QScriptValue scriptValueFromJSCValue(JSC::JSValue value)
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptEnginePrivate * engine

◆ functionValue()

QScriptDeclarativeClass::Value QScriptDeclarativeClass::functionValue ( const QScriptValue v,
const Identifier name 
)
static

Definition at line 295 of file qscriptdeclarativeclass.cpp.

296 {
298 
299  if (!d->isObject())
300  return Value();
301 
302  QScript::APIShim shim(d->engine);
303  JSC::ExecState *exec = d->engine->currentFrame;
304  JSC::JSObject *object = d->jscValue.getObject();
305  JSC::PropertySlot slot(const_cast<JSC::JSObject*>(object));
306  JSC::JSValue result;
307 
308  JSC::Identifier id(exec, (JSC::UString::Rep *)name);
309 
310  if (const_cast<JSC::JSObject*>(object)->getOwnPropertySlot(exec, id, slot)) {
311  result = slot.getValue(exec, id);
312  if (QScript::isFunction(result))
313  return jscToValue(result);
314  }
315 
316  return Value();
317 }
double d
Definition: qnumeric_p.h:62
static QScriptValuePrivate * get(const QScriptValue &q)
static QScriptDeclarativeClass::Value jscToValue(const JSC::JSValue &val)
JSC::ExecState * currentFrame
const char * name
bool isFunction(JSC::JSValue value)
bool isObject() const
JSC::JSValue jscValue
QScriptEnginePrivate * engine

◆ isQObject()

bool QScriptDeclarativeClass::isQObject ( ) const
virtual

Reimplemented in QDeclarativeObjectScriptClass.

Definition at line 547 of file qscriptdeclarativeclass.cpp.

548 {
549  return false;
550 }

◆ newObject()

QScriptValue QScriptDeclarativeClass::newObject ( QScriptEngine engine,
QScriptDeclarativeClass scriptClass,
Object object 
)
static

Definition at line 198 of file qscriptdeclarativeclass.cpp.

Referenced by FlatListModel::get(), QDeclarativeContextScriptClass::newContext(), QDeclarativeListScriptClass::newList(), QDeclarativeObjectMethodScriptClass::newMethod(), QDeclarativeValueTypeScriptClass::newObject(), QDeclarativeTypeNameScriptClass::newObject(), QDeclarativeObjectScriptClass::newQObject(), QDeclarativeContextScriptClass::newSharedContext(), and QDeclarativeContextScriptClass::newUrlContext().

201 {
202  Q_ASSERT(engine);
203  Q_ASSERT(scriptClass);
204 
206  QScript::APIShim shim(p);
207 
208  JSC::ExecState* exec = p->currentFrame;
209  QScriptObject *result = new (exec) QScriptObject(p->scriptObjectStructure);
210  result->setDelegate(new QScript::DeclarativeObjectDelegate(scriptClass, object));
211  return p->scriptValueFromJSCValue(result);
212 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
JSC::ExecState * currentFrame
WTF::RefPtr< JSC::Structure > scriptObjectStructure
void setDelegate(QScriptObjectDelegate *delegate)
QScriptValue scriptValueFromJSCValue(JSC::JSValue value)

◆ newObjectValue()

QScriptDeclarativeClass::Value QScriptDeclarativeClass::newObjectValue ( QScriptEngine engine,
QScriptDeclarativeClass scriptClass,
Object object 
)
static

Definition at line 215 of file qscriptdeclarativeclass.cpp.

218 {
219  Q_ASSERT(engine);
220  Q_ASSERT(scriptClass);
221 
222  QScriptEnginePrivate *p = static_cast<QScriptEnginePrivate *>(QObjectPrivate::get(engine));
223  QScript::APIShim shim(p);
224 
225  JSC::ExecState* exec = p->currentFrame;
226  QScriptObject *result = new (exec) QScriptObject(p->scriptObjectStructure);
227  result->setDelegate(new QScript::DeclarativeObjectDelegate(scriptClass, object));
228  return jscToValue(JSC::JSValue(result));
229 }
static QScriptDeclarativeClass::Value jscToValue(const JSC::JSValue &val)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
JSC::ExecState * currentFrame
WTF::RefPtr< JSC::Structure > scriptObjectStructure
void setDelegate(QScriptObjectDelegate *delegate)

◆ newStaticScopeObject() [1/2]

QScriptValue QScriptDeclarativeClass::newStaticScopeObject ( QScriptEngine engine,
int  propertyCount,
const QString names,
const QScriptValue values,
const QScriptValue::PropertyFlags flags 
)
static

Creates a scope object with a fixed set of undeletable properties.

Definition at line 572 of file qscriptdeclarativeclass.cpp.

Referenced by QDeclarativeContextData::addImportedScript(), and QDeclarativeGlobalScriptClass::QDeclarativeGlobalScriptClass().

575 {
577  QScript::APIShim shim(eng_p);
578  JSC::ExecState *exec = eng_p->currentFrame;
580  for (int i = 0; i < propertyCount; ++i) {
581  unsigned attribs = QScriptEnginePrivate::propertyFlagsToJSCAttributes(flags[i]);
582  Q_ASSERT_X(attribs & JSC::DontDelete, Q_FUNC_INFO, "All properties must be undeletable");
583  JSC::Identifier id = JSC::Identifier(exec, names[i]);
584  JSC::JSValue jsval = eng_p->scriptValueToJSCValue(values[i]);
585  props[i] = QScriptStaticScopeObject::PropertyInfo(id, jsval, attribs);
586  }
588  propertyCount, props));
589  delete[] props;
590  return result;
591 }
static unsigned propertyFlagsToJSCAttributes(const QScriptValue::PropertyFlags &flags)
static QScriptEnginePrivate * get(QScriptEngine *q)
WTF::RefPtr< JSC::Structure > staticScopeObjectStructure
JSC::ExecState * currentFrame
JSC::JSValue scriptValueToJSCValue(const QScriptValue &value)
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
QScriptValue scriptValueFromJSCValue(JSC::JSValue value)
Represents a static scope object.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ newStaticScopeObject() [2/2]

QScriptValue QScriptDeclarativeClass::newStaticScopeObject ( QScriptEngine engine)
static

Creates a static scope object that's initially empty, but to which new properties can be added.

Definition at line 597 of file qscriptdeclarativeclass.cpp.

598 {
600  QScript::APIShim shim(eng_p);
602 }
static QScriptEnginePrivate * get(QScriptEngine *q)
WTF::RefPtr< JSC::Structure > staticScopeObjectStructure
JSC::ExecState * currentFrame
QScriptValue scriptValueFromJSCValue(JSC::JSValue value)
Represents a static scope object.

◆ object()

QScriptDeclarativeClass::Object * QScriptDeclarativeClass::object ( const QScriptValue v)
static

Definition at line 239 of file qscriptdeclarativeclass.cpp.

Referenced by QDeclarativeObjectScriptClass::destroy(), QDeclarativeListScriptClass::newList(), QDeclarativeValueTypeScriptClass::newObject(), QDeclarativeObjectScriptClass::objectType(), and scopeChainValue().

240 {
242  if (!d || !d->isJSC())
243  return 0;
245 }
double d
Definition: qnumeric_p.h:62
static QScriptValuePrivate * get(const QScriptValue &q)
static QScriptDeclarativeClass::Object * declarativeObject(JSC::JSValue)
JSC::JSValue jscValue

◆ property() [1/2]

QScriptValue QScriptDeclarativeClass::property ( const QScriptValue v,
const Identifier name 
)
static

Definition at line 271 of file qscriptdeclarativeclass.cpp.

Referenced by QScript::DeclarativeObjectDelegate::getOwnPropertySlot().

272 {
274 
275  if (!d->isObject())
276  return QScriptValue();
277 
278  QScript::APIShim shim(d->engine);
279  JSC::ExecState *exec = d->engine->currentFrame;
280  JSC::JSObject *object = d->jscValue.getObject();
281  JSC::PropertySlot slot(const_cast<JSC::JSObject*>(object));
282  JSC::JSValue result;
283 
284  JSC::Identifier id(exec, (JSC::UString::Rep *)name);
285 
286  if (const_cast<JSC::JSObject*>(object)->getOwnPropertySlot(exec, id, slot)) {
287  result = slot.getValue(exec, id);
288  return d->engine->scriptValueFromJSCValue(result);
289  }
290 
291  return QScriptValue();
292 }
double d
Definition: qnumeric_p.h:62
static QScriptValuePrivate * get(const QScriptValue &q)
JSC::ExecState * currentFrame
const char * name
bool isObject() const
JSC::JSValue jscValue
QScriptValue scriptValueFromJSCValue(JSC::JSValue value)
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptEnginePrivate * engine

◆ property() [2/2]

QScriptDeclarativeClass::Value QScriptDeclarativeClass::property ( Object object,
const Identifier name 
)
virtual

Reimplemented in QDeclarativeObjectScriptClass, FlatListScriptClass, QDeclarativeContextScriptClass, QDeclarativeObjectMethodScriptClass, QDeclarativeTypeNameScriptClass, QDeclarativeListScriptClass, and QDeclarativeValueTypeScriptClass.

Definition at line 505 of file qscriptdeclarativeclass.cpp.

506 {
507  Q_UNUSED(object);
508  Q_UNUSED(name);
509  return Value();
510 }
const char * name
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ propertyFlags()

QScriptValue::PropertyFlags QScriptDeclarativeClass::propertyFlags ( Object object,
const Identifier name 
)
virtual

Definition at line 521 of file qscriptdeclarativeclass.cpp.

522 {
523  Q_UNUSED(object);
524  Q_UNUSED(name);
525  return 0;
526 }
const char * name
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ propertyNames()

QStringList QScriptDeclarativeClass::propertyNames ( Object object)
virtual

Reimplemented in QDeclarativeObjectScriptClass.

Definition at line 541 of file qscriptdeclarativeclass.cpp.

Referenced by QScript::DeclarativeObjectDelegate::getOwnPropertyNames().

542 {
543  Q_UNUSED(object);
544  return QStringList();
545 }
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ propertyValue()

QScriptDeclarativeClass::Value QScriptDeclarativeClass::propertyValue ( const QScriptValue v,
const Identifier name 
)
static

Definition at line 320 of file qscriptdeclarativeclass.cpp.

321 {
323 
324  if (!d->isObject())
325  return Value();
326 
327  QScript::APIShim shim(d->engine);
328  JSC::ExecState *exec = d->engine->currentFrame;
329  JSC::JSObject *object = d->jscValue.getObject();
330  JSC::PropertySlot slot(const_cast<JSC::JSObject*>(object));
331  JSC::JSValue result;
332 
333  JSC::Identifier id(exec, (JSC::UString::Rep *)name);
334 
335  if (const_cast<JSC::JSObject*>(object)->getOwnPropertySlot(exec, id, slot)) {
336  result = slot.getValue(exec, id);
337  return jscToValue(result);
338  }
339 
340  return Value();
341 }
double d
Definition: qnumeric_p.h:62
static QScriptValuePrivate * get(const QScriptValue &q)
static QScriptDeclarativeClass::Value jscToValue(const JSC::JSValue &val)
JSC::ExecState * currentFrame
const char * name
bool isObject() const
JSC::JSValue jscValue
QScriptEnginePrivate * engine

◆ pushCleanContext()

QScriptContext * QScriptDeclarativeClass::pushCleanContext ( QScriptEngine engine)
static

Enters a new execution context and returns the associated QScriptContext object.

Once you are done with the context, you should call popContext() to restore the old context.

By default, the `this' object of the new context is the Global Object. The context's callee() will be invalid.

Unlike pushContext(), the default scope chain is reset to include only the global object and the QScriptContext's activation object.

See also
QScriptEngine::popContext()

Definition at line 408 of file qscriptdeclarativeclass.cpp.

Referenced by QDeclarativeContextData::addImportedScript(), QDeclarativeExpressionPrivate::evalInObjectScope(), QDeclarativeInclude::finished(), QDeclarativeInclude::include(), QDeclarativeExpressionPrivate::init(), QDeclarativeWorkerScriptEnginePrivate::processLoad(), QDeclarativeExpressionPrivate::scriptValue(), and QDeclarativeInclude::worker_include().

409 {
410  if (!engine)
411  return 0;
412 
414  QScript::APIShim shim(d);
415 
416  JSC::CallFrame* newFrame = d->pushContext(d->currentFrame,
417  d->currentFrame->globalData().dynamicGlobalObject,
418  JSC::ArgList(), /*callee = */0, false, true);
419 
420  if (engine->agent())
421  engine->agent()->contextPush();
422 
423  return d->contextForFrame(newFrame);
424 }
double d
Definition: qnumeric_p.h:62
static QScriptEnginePrivate * get(QScriptEngine *q)
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
static QScriptContext * contextForFrame(JSC::ExecState *frame)
QScriptEngineAgent * agent() const
Returns the agent currently installed on this engine, or 0 if no agent is installed.
virtual void contextPush()
This function is called when a new script context has been pushed.
ExecState CallFrame

◆ queryProperty()

QScriptClass::QueryFlags QScriptDeclarativeClass::queryProperty ( Object object,
const Identifier name,
QScriptClass::QueryFlags  flags 
)
virtual

Reimplemented in QDeclarativeObjectScriptClass, FlatListScriptClass, QDeclarativeContextScriptClass, QDeclarativeObjectMethodScriptClass, QDeclarativeTypeNameScriptClass, QDeclarativeListScriptClass, and QDeclarativeValueTypeScriptClass.

Definition at line 495 of file qscriptdeclarativeclass.cpp.

Referenced by QScript::DeclarativeObjectDelegate::getOwnPropertySlot(), and QScript::DeclarativeObjectDelegate::put().

497 {
498  Q_UNUSED(object);
499  Q_UNUSED(name);
500  Q_UNUSED(flags);
501  return 0;
502 }
const char * name
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ scopeChainValue()

QScriptValue QScriptDeclarativeClass::scopeChainValue ( QScriptContext context,
int  index 
)
static

Definition at line 348 of file qscriptdeclarativeclass.cpp.

Referenced by QDeclarativeEnginePrivate::getContext(), QDeclarativeEnginePrivate::getUrl(), QDeclarativeInclude::include(), QDeclarativeInclude::QDeclarativeInclude(), QDeclarativeObjectScriptClass::queryProperty(), QDeclarativeObjectScriptClass::setProperty(), and QDeclarativeInclude::worker_include().

349 {
350  context->activationObject(); //ensure the creation of the normal scope for native context
353  QScript::APIShim shim(engine);
354 
355  JSC::ScopeChainNode *node = frame->scopeChain();
356  JSC::ScopeChainIterator it(node);
357 
358  if (index < 0) {
359  int count = 0;
360  for (it = node->begin(); it != node->end(); ++it)
361  ++count;
362 
363  index = qAbs(index);
364  if (index > count)
365  return QScriptValue();
366  else
367  index = count - index;
368  }
369 
370  for (it = node->begin(); it != node->end(); ++it) {
371 
372  if (index == 0) {
373 
374  JSC::JSObject *object = *it;
375  if (!object) return QScriptValue();
376 
377  if (object->inherits(&QScript::QScriptActivationObject::info)
378  && (static_cast<QScript::QScriptActivationObject*>(object)->delegate() != 0)) {
379  // Return the object that property access is being delegated to
380  object = static_cast<QScript::QScriptActivationObject*>(object)->delegate();
381  }
382  return engine->scriptValueFromJSCValue(object);
383 
384  } else {
385  --index;
386  }
387 
388  }
389 
390  return QScriptValue();
391 }
static JSC::ExecState * frameForContext(QScriptContext *context)
QScriptEnginePrivate * scriptEngineFromExec(const JSC::ExecState *exec)
#define it(className, varName)
static Object * object(const QScriptValue &)
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
QScriptEngine * engine() const
quint16 index
QScriptValue scriptValueFromJSCValue(JSC::JSValue value)
QScriptValue activationObject() const
Returns the activation object of this QScriptContext.
Represent a scope for native function call.
ExecState CallFrame
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ scriptClass()

QScriptDeclarativeClass * QScriptDeclarativeClass::scriptClass ( const QScriptValue v)
static

◆ setProperty()

void QScriptDeclarativeClass::setProperty ( Object object,
const Identifier name,
const QScriptValue value 
)
virtual

Reimplemented in QDeclarativeObjectScriptClass, FlatListScriptClass, QDeclarativeContextScriptClass, QDeclarativeTypeNameScriptClass, and QDeclarativeValueTypeScriptClass.

Definition at line 512 of file qscriptdeclarativeclass.cpp.

Referenced by QScript::DeclarativeObjectDelegate::put().

514 {
515  Q_UNUSED(object);
516  Q_UNUSED(name);
517  Q_UNUSED(value);
518 }
const char * name
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ setSupportsCall()

void QScriptDeclarativeClass::setSupportsCall ( bool  c)

Definition at line 440 of file qscriptdeclarativeclass.cpp.

Referenced by QDeclarativeObjectMethodScriptClass::QDeclarativeObjectMethodScriptClass().

441 {
442  d_ptr->supportsCall = c;
443 }
unsigned char c[8]
Definition: qnumeric_p.h:62
QScopedPointer< QScriptDeclarativeClassPrivate > d_ptr

◆ startsWithUpper()

bool QScriptDeclarativeClass::startsWithUpper ( const Identifier identifier)

Definition at line 479 of file qscriptdeclarativeclass.cpp.

Referenced by QDeclarativeTypeNameScriptClass::queryProperty().

480 {
481  JSC::UString::Rep *r = (JSC::UString::Rep *)identifier;
482  if (r->size() < 1)
483  return false;
484  return QChar::category((ushort)(r->data()[0])) == QChar::Letter_Uppercase;
485 }
Category category() const
Returns the character&#39;s category.
Definition: qchar.cpp:853
unsigned short ushort
Definition: qglobal.h:995

◆ supportsCall()

bool QScriptDeclarativeClass::supportsCall ( ) const

Definition at line 435 of file qscriptdeclarativeclass.cpp.

436 {
437  return d_ptr->supportsCall;
438 }
QScopedPointer< QScriptDeclarativeClassPrivate > d_ptr

◆ toArrayIndex()

quint32 QScriptDeclarativeClass::toArrayIndex ( const Identifier identifier,
bool *  ok 
)

Definition at line 487 of file qscriptdeclarativeclass.cpp.

Referenced by QDeclarativeListScriptClass::queryProperty().

488 {
489  JSC::UString::Rep *r = (JSC::UString::Rep *)identifier;
490  JSC::UString s(r);
491  return s.toArrayIndex(ok);
492 }

◆ toQObject()

QObject * QScriptDeclarativeClass::toQObject ( Object ,
bool *  ok = 0 
)
virtual

Reimplemented in QDeclarativeObjectScriptClass.

Definition at line 552 of file qscriptdeclarativeclass.cpp.

553 {
554  if (ok) *ok = false;
555  return 0;
556 }

◆ toString()

QString QScriptDeclarativeClass::toString ( const Identifier identifier)

Definition at line 473 of file qscriptdeclarativeclass.cpp.

Referenced by FlatListScriptClass::property(), QDeclarativePropertyCache::property(), QDeclarativeValueTypeScriptClass::queryProperty(), QDeclarativeTypeNameScriptClass::queryProperty(), QDeclarativeObjectScriptClass::setProperty(), and FlatListScriptClass::setProperty().

474 {
475  JSC::UString::Rep *r = (JSC::UString::Rep *)identifier;
476  return QString((QChar *)r->data(), r->size());
477 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72

◆ toVariant()

QVariant QScriptDeclarativeClass::toVariant ( Object ,
bool *  ok = 0 
)
virtual

Reimplemented in QDeclarativeValueTypeScriptClass, and QDeclarativeListScriptClass.

Definition at line 558 of file qscriptdeclarativeclass.cpp.

559 {
560  if (ok) *ok = false;
561  return QVariant();
562 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92

Friends and Related Functions

◆ QScriptDeclarativeClassPrivate

Definition at line 150 of file qscriptdeclarativeclass_p.h.

Properties

◆ d_ptr

QScopedPointer<QScriptDeclarativeClassPrivate> QScriptDeclarativeClass::d_ptr
protected

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