Qt 4.8
Public Types | Public Functions | Static Public Functions | Public Variables | Static Public Variables | List of all members
QScriptEnginePrivate Class Reference

#include <qscriptengine_p.h>

Inheritance diagram for QScriptEnginePrivate:
QObjectPrivate QObjectData

Public Types

enum  ContextFlags { NativeContext = 1, CalledAsConstructorContext = 2, HasScopeContext = 4, ShouldRestoreCallFrame = 8 }
 
- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Public Functions

void _q_objectDestroyed (QObject *)
 
void agentDeleted (QScriptEngineAgent *agent)
 
QScriptValuePrivateallocateScriptValuePrivate (size_t)
 
void clearCurrentException ()
 
void collectGarbage ()
 
QScriptValue currentException () const
 
JSC::JSObject * customGlobalObject () const
 
JSC::JSValue defaultPrototype (int metaTypeId) const
 
void detachAllRegisteredScriptPrograms ()
 
void detachAllRegisteredScriptStrings ()
 
void detachAllRegisteredScriptValues ()
 
void disposeQObject (QObject *object)
 
void emitSignalHandlerException ()
 
JSC::JSValue evaluateHelper (JSC::ExecState *exec, intptr_t sourceId, JSC::EvalExecutable *executable, bool &compile)
 
void freeScriptValuePrivate (QScriptValuePrivate *p)
 
JSC::JSObject * getOriginalGlobalObjectProxy ()
 
JSC::ExecState * globalExec () const
 
JSC::JSObject * globalObject () const
 
bool hasDemarshalFunction (int type) const
 
bool isCollecting () const
 
void mark (JSC::MarkStack &markStack)
 
JSC::JSValue newObject ()
 
JSC::JSValue newQMetaObject (const QMetaObject *metaObject, JSC::JSValue ctor)
 
JSC::JSValue newQObject (QObject *object, QScriptEngine::ValueOwnership ownership=QScriptEngine::QtOwnership, const QScriptEngine::QObjectWrapOptions &options=0)
 
JSC::JSValue newVariant (const QVariant &)
 
JSC::JSValue newVariant (JSC::JSValue objectValue, const QVariant &)
 
JSC::JSGlobalObject * originalGlobalObject () const
 
void popContext ()
 
JSC::CallFramepushContext (JSC::CallFrame *exec, JSC::JSValue thisObject, const JSC::ArgList &args, JSC::JSObject *callee, bool calledAsConstructor=false, bool clearScopeChain=false)
 JSC native function doesn't have different stackframe or context. More...
 
QScript::QObjectDataqobjectData (QObject *object)
 
 QScriptEnginePrivate ()
 
void registerScriptProgram (QScriptProgramPrivate *program)
 
void registerScriptString (QScriptStringPrivate *value)
 
void registerScriptValue (QScriptValuePrivate *value)
 
void reportAdditionalMemoryCost (int size)
 
bool scriptConnect (QObject *sender, const char *signal, JSC::JSValue receiver, JSC::JSValue function, Qt::ConnectionType type)
 
bool scriptConnect (QObject *sender, int index, JSC::JSValue receiver, JSC::JSValue function, JSC::JSValue senderWrapper, Qt::ConnectionType type)
 
bool scriptConnect (JSC::JSValue signal, JSC::JSValue receiver, JSC::JSValue function, Qt::ConnectionType type)
 
bool scriptDisconnect (QObject *sender, const char *signal, JSC::JSValue receiver, JSC::JSValue function)
 
bool scriptDisconnect (QObject *sender, int index, JSC::JSValue receiver, JSC::JSValue function)
 
bool scriptDisconnect (JSC::JSValue signal, JSC::JSValue receiver, JSC::JSValue function)
 
QScriptValue scriptValueFromJSCValue (JSC::JSValue value)
 
JSC::JSValue scriptValueToJSCValue (const QScriptValue &value)
 
void setCurrentException (QScriptValue exception)
 
void setDefaultPrototype (int metaTypeId, JSC::JSValue prototype)
 
void setGlobalObject (JSC::JSObject *object)
 
QScript::TimeoutCheckerProxytimeoutChecker () const
 
QScriptString toStringHandle (const JSC::Identifier &name)
 
JSC::JSValue toUsableValue (JSC::JSValue value)
 If the given value is the original global object, returns the custom global object or a proxy to the original global object; otherwise returns value. More...
 
JSC::UString translationContextFromUrl (const JSC::UString &)
 
void unregisterScriptProgram (QScriptProgramPrivate *program)
 
void unregisterScriptString (QScriptStringPrivate *value)
 
void unregisterScriptValue (QScriptValuePrivate *value)
 
virtual ~QScriptEnginePrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static JSC::JSValue arrayFromStringList (JSC::ExecState *, const QStringList &lst)
 
static JSC::JSValue arrayFromVariantList (JSC::ExecState *, const QVariantList &lst)
 
static bool canEvaluate (const QString &program)
 
static QScriptSyntaxCheckResult checkSyntax (const QString &program)
 
static uint contextFlags (JSC::ExecState *)
 For native context, we use the ReturnValueRegister entry in the stackframe header to store flags. More...
 
static QScriptContextcontextForFrame (JSC::ExecState *frame)
 
static bool convertNumber (qsreal, int type, void *ptr)
 
static bool convertString (const QString &, int type, void *ptr)
 
static bool convertToNativeQObject (JSC::ExecState *, JSC::JSValue, const QByteArray &targetType, void **result)
 
static bool convertValue (JSC::ExecState *, JSC::JSValue value, int type, void *ptr)
 
static JSC::JSValue create (JSC::ExecState *, int type, const void *ptr)
 
static QScriptDeclarativeClassdeclarativeClass (JSC::JSValue)
 
static QScriptDeclarativeClass::ObjectdeclarativeObject (JSC::JSValue)
 
static JSC::ExecState * frameForContext (QScriptContext *context)
 
static const JSC::ExecState * frameForContext (const QScriptContext *context)
 
static QScriptEnginePrivateget (QScriptEngine *q)
 
static QScriptEngineget (QScriptEnginePrivate *d)
 
static bool hasValidCodeBlockRegister (JSC::ExecState *frame)
 
static bool isArray (JSC::JSValue)
 
static bool isDate (JSC::JSValue)
 
static bool isError (JSC::JSValue)
 
static bool isObject (JSC::JSValue)
 
static bool isQMetaObject (JSC::JSValue)
 
static bool isQObject (JSC::JSValue)
 
static bool isRegExp (JSC::JSValue)
 
static bool isVariant (JSC::JSValue)
 
static JSC::JSValue jscValueFromVariant (JSC::ExecState *, const QVariant &value)
 
static QVariant jscValueToVariant (JSC::ExecState *, JSC::JSValue value, int targetType)
 
static JSC::JSValue newArray (JSC::ExecState *, uint length)
 
static JSC::JSValue newDate (JSC::ExecState *, qsreal value)
 
static JSC::JSValue newDate (JSC::ExecState *, const QDateTime &)
 
static JSC::JSValue newRegExp (JSC::ExecState *, const QRegExp &)
 
static JSC::JSValue newRegExp (JSC::ExecState *, const QString &pattern, const QString &flags)
 
static JSC::JSValue objectFromVariantMap (JSC::ExecState *, const QVariantMap &vmap)
 
static JSC::JSValue property (JSC::ExecState *, JSC::JSValue, const JSC::Identifier &id, int resolveMode=QScriptValue::ResolvePrototype)
 
static JSC::JSValue property (JSC::ExecState *, JSC::JSValue, quint32 index, int resolveMode=QScriptValue::ResolvePrototype)
 
static JSC::JSValue property (JSC::ExecState *, JSC::JSValue, const JSC::UString &, int resolveMode)
 
static QScriptValue::PropertyFlags propertyFlags (JSC::ExecState *, JSC::JSValue value, const JSC::Identifier &id, const QScriptValue::ResolveFlags &mode)
 
static QScriptValue::PropertyFlags propertyFlags (JSC::ExecState *, JSC::JSValue value, const JSC::UString &name, const QScriptValue::ResolveFlags &mode)
 
static unsigned propertyFlagsToJSCAttributes (const QScriptValue::PropertyFlags &flags)
 
static JSC::JSValue propertyHelper (JSC::ExecState *, JSC::JSValue, const JSC::Identifier &id, int resolveMode)
 
static JSC::JSValue propertyHelper (JSC::ExecState *, JSC::JSValue, quint32, int resolveMode)
 
static void restoreException (JSC::ExecState *, JSC::JSValue)
 
static void saveException (JSC::ExecState *, JSC::JSValue *)
 
static void setContextFlags (JSC::ExecState *, uint)
 
static void setProperty (JSC::ExecState *, JSC::JSValue object, const JSC::UString &name, JSC::JSValue, const QScriptValue::PropertyFlags &flags=QScriptValue::KeepExistingFlags)
 
static void setProperty (JSC::ExecState *, JSC::JSValue object, const JSC::Identifier &id, JSC::JSValue, const QScriptValue::PropertyFlags &flags=QScriptValue::KeepExistingFlags)
 
static void setProperty (JSC::ExecState *, JSC::JSValue object, quint32 index, JSC::JSValue, const QScriptValue::PropertyFlags &flags=QScriptValue::KeepExistingFlags)
 
static void setVariantValue (JSC::JSValue objectValue, const QVariant &value)
 
static QStringList stringListFromArray (JSC::ExecState *, JSC::JSValue arr)
 
static JSC::JSValue thisForContext (JSC::ExecState *frame)
 
static JSC::Register * thisRegisterForFrame (JSC::ExecState *frame)
 
static bool toBool (JSC::ExecState *, JSC::JSValue)
 
static QDateTime toDateTime (JSC::ExecState *, JSC::JSValue)
 
static qint32 toInt32 (JSC::ExecState *, JSC::JSValue)
 
static qsreal toInteger (JSC::ExecState *, JSC::JSValue)
 
static qsreal toNumber (JSC::ExecState *, JSC::JSValue)
 
static const QMetaObjecttoQMetaObject (JSC::ExecState *, JSC::JSValue)
 
static QObjecttoQObject (JSC::ExecState *, JSC::JSValue)
 
static QRegExp toRegExp (JSC::ExecState *, JSC::JSValue)
 
static JSC::UString toString (JSC::ExecState *, JSC::JSValue)
 
static quint16 toUInt16 (JSC::ExecState *, JSC::JSValue)
 
static quint32 toUInt32 (JSC::ExecState *, JSC::JSValue)
 
static QVariant toVariant (JSC::ExecState *, JSC::JSValue)
 
static QVariantList variantListFromArray (JSC::ExecState *, JSC::JSArray *arr)
 
static QVariantMap variantMapFromObject (JSC::ExecState *, JSC::JSObject *obj)
 
static QVariantvariantValue (JSC::JSValue value)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

QScriptValue abortResult
 
QScriptEngineAgentactiveAgent
 
int agentLineNumber
 
JSC::UString cachedTranslationContext
 
JSC::UString cachedTranslationUrl
 
JSC::ExecState * currentFrame
 
QSet< QStringextensionsBeingImported
 
QScriptValuePrivatefreeScriptValues
 
int freeScriptValuesCount
 
JSC::JSGlobalData * globalData
 
QSet< QStringimportedExtensions
 
bool inEval
 
QHash< intptr_t, QScript::UStringSourceProviderWithFeedback * > loadedScripts
 
QScriptValue m_currentException
 
QHash< QObject *, QScript::QObjectData * > m_qobjectData
 
QHash< int, QScriptTypeInfo * > m_typeInfos
 
JSC::JSObject * originalGlobalObjectProxy
 
QList< QScriptEngineAgent * > ownedAgents
 
int processEventsInterval
 
QScript::QMetaObjectPrototypeqmetaobjectPrototype
 
WTF::RefPtr< JSC::Structure > qmetaobjectWrapperObjectStructure
 
QScript::QObjectPrototypeqobjectPrototype
 
WTF::RefPtr< JSC::Structure > qobjectWrapperObjectStructure
 
QSet< QScriptProgramPrivate * > registeredScriptPrograms
 
QScriptStringPrivateregisteredScriptStrings
 
QScriptValuePrivateregisteredScriptValues
 
WTF::RefPtr< JSC::Structure > scriptObjectStructure
 
WTF::RefPtr< JSC::Structure > staticScopeObjectStructure
 
QScript::QVariantPrototypevariantPrototype
 
WTF::RefPtr< JSC::Structure > variantWrapperObjectStructure
 
QSet< JSC::JSObject * > visitedConversionObjects
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Static Public Variables

static const int maxFreeScriptValues = 256
 

Detailed Description

Definition at line 148 of file qscriptengine_p.h.

Enumerations

◆ ContextFlags

Enumerator
NativeContext 
CalledAsConstructorContext 
HasScopeContext 
ShouldRestoreCallFrame 

Definition at line 258 of file qscriptengine_p.h.

Constructors and Destructors

◆ QScriptEnginePrivate()

QScriptEnginePrivate::QScriptEnginePrivate ( )

Definition at line 975 of file qscriptengine.cpp.

981 {
982  qMetaTypeId<QScriptValue>();
983  qMetaTypeId<QList<int> >();
984 #ifndef QT_NO_QOBJECT
985  qMetaTypeId<QObjectList>();
986 #endif
987 
989  qFatal("QScriptEngine: Must construct a Q(Core)Application before a QScriptEngine");
990  return;
991  }
992  JSC::initializeThreading();
993  JSC::IdentifierTable *oldTable = JSC::currentIdentifierTable();
994  globalData = JSC::JSGlobalData::create().releaseRef();
995  globalData->clientData = new QScript::GlobalClientData(this);
996  JSC::JSGlobalObject *globalObject = new (globalData)QScript::GlobalObject();
997 
998  JSC::ExecState* exec = globalObject->globalExec();
999 
1000  scriptObjectStructure = QScriptObject::createStructure(globalObject->objectPrototype());
1002 
1003  qobjectPrototype = new (exec) QScript::QObjectPrototype(exec, QScript::QObjectPrototype::createStructure(globalObject->objectPrototype()), globalObject->prototypeFunctionStructure());
1005 
1006  qmetaobjectPrototype = new (exec) QScript::QMetaObjectPrototype(exec, QScript::QMetaObjectPrototype::createStructure(globalObject->objectPrototype()), globalObject->prototypeFunctionStructure());
1008 
1009  variantPrototype = new (exec) QScript::QVariantPrototype(exec, QScript::QVariantPrototype::createStructure(globalObject->objectPrototype()), globalObject->prototypeFunctionStructure());
1011 
1012  globalObject->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, globalObject->prototypeFunctionStructure(), 1, JSC::Identifier(exec, "print"), QScript::functionPrint));
1013  globalObject->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, globalObject->prototypeFunctionStructure(), 0, JSC::Identifier(exec, "gc"), QScript::functionGC));
1014  globalObject->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, globalObject->prototypeFunctionStructure(), 0, JSC::Identifier(exec, "version"), QScript::functionVersion));
1015 
1016  // ### rather than extending Function.prototype, consider creating a QtSignal.prototype
1017  globalObject->functionPrototype()->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, globalObject->prototypeFunctionStructure(), 1, JSC::Identifier(exec, "disconnect"), QScript::functionDisconnect));
1018  globalObject->functionPrototype()->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, globalObject->prototypeFunctionStructure(), 1, JSC::Identifier(exec, "connect"), QScript::functionConnect));
1019 
1020  JSC::TimeoutChecker* originalChecker = globalData->timeoutChecker;
1021  globalData->timeoutChecker = new QScript::TimeoutCheckerProxy(*originalChecker);
1022  delete originalChecker;
1023 
1024  currentFrame = exec;
1025 
1026  cachedTranslationUrl = JSC::UString();
1027  cachedTranslationContext = JSC::UString();
1028  JSC::setCurrentIdentifierTable(oldTable);
1029 }
WTF::RefPtr< JSC::Structure > variantWrapperObjectStructure
WTF::RefPtr< JSC::Structure > qmetaobjectWrapperObjectStructure
static JSC::JSValue JSC_HOST_CALL functionDisconnect(JSC::ExecState *, JSC::JSObject *, JSC::JSValue, const JSC::ArgList &)
JSC::UString cachedTranslationContext
static JSC::JSValue JSC_HOST_CALL functionPrint(JSC::ExecState *, JSC::JSObject *, JSC::JSValue, const JSC::ArgList &)
WTF::RefPtr< JSC::Structure > staticScopeObjectStructure
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
static JSC::JSValue JSC_HOST_CALL functionVersion(JSC::ExecState *, JSC::JSObject *, JSC::JSValue, const JSC::ArgList &)
QScript::QVariantPrototype * variantPrototype
JSC::JSObject * globalObject() const
static WTF::PassRefPtr< JSC::Structure > createStructure(JSC::JSValue proto)
JSC::ExecState * currentFrame
static JSC::JSValue JSC_HOST_CALL functionConnect(JSC::ExecState *, JSC::JSObject *, JSC::JSValue, const JSC::ArgList &)
static WTF::PassRefPtr< JSC::Structure > createStructure(JSC::JSValue prototype)
QScript::QMetaObjectPrototype * qmetaobjectPrototype
static WTF::PassRefPtr< JSC::Structure > createStructure(JSC::JSValue prototype)
QScriptStringPrivate * registeredScriptStrings
Q_CORE_EXPORT void qFatal(const char *,...)
WTF::RefPtr< JSC::Structure > scriptObjectStructure
static QCoreApplication * instance()
Returns a pointer to the application&#39;s QCoreApplication (or QApplication) instance.
QScriptEngineAgent * activeAgent
QScript::QObjectPrototype * qobjectPrototype
QScriptValuePrivate * freeScriptValues
JSC::JSObject * originalGlobalObjectProxy
JSC::JSGlobalData * globalData
QScriptValuePrivate * registeredScriptValues
JSC::UString cachedTranslationUrl
static JSC::JSValue JSC_HOST_CALL functionGC(JSC::ExecState *, JSC::JSObject *, JSC::JSValue, const JSC::ArgList &)
WTF::RefPtr< JSC::Structure > qobjectWrapperObjectStructure

◆ ~QScriptEnginePrivate()

QScriptEnginePrivate::~QScriptEnginePrivate ( )
virtual

Definition at line 1031 of file qscriptengine.cpp.

1032 {
1033  QScript::APIShim shim(this);
1034 
1035  //disconnect all loadedScripts and generate all jsc::debugger::scriptUnload events
1037  for (it = loadedScripts.constBegin(); it != loadedScripts.constEnd(); ++it)
1038  it.value()->disconnectFromEngine();
1039 
1040  while (!ownedAgents.isEmpty())
1041  delete ownedAgents.takeFirst();
1042 
1048  globalData->heap.destroy();
1049  globalData->deref();
1050  while (freeScriptValues) {
1052  freeScriptValues = p->next;
1053  qFree(p);
1054  }
1055 }
QScriptValuePrivate * next
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
void detachAllRegisteredScriptStrings()
#define it(className, varName)
Q_CORE_EXPORT void qFree(void *ptr)
Definition: qmalloc.cpp:58
QList< QScriptEngineAgent * > ownedAgents
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QHash< QObject *, QScript::QObjectData * > m_qobjectData
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
const T & value() const
Returns the current item&#39;s value.
Definition: qhash.h:420
QHash< intptr_t, QScript::UStringSourceProviderWithFeedback * > loadedScripts
void detachAllRegisteredScriptPrograms()
QHash< int, QScriptTypeInfo * > m_typeInfos
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
QScriptValuePrivate * freeScriptValues
JSC::JSGlobalData * globalData
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319
void detachAllRegisteredScriptValues()

Functions

◆ _q_objectDestroyed()

void QScriptEnginePrivate::_q_objectDestroyed ( QObject object)

Definition at line 1516 of file qscriptengine.cpp.

Referenced by qobjectData().

1517 {
1519  it = m_qobjectData.find(object);
1520  Q_ASSERT(it != m_qobjectData.end());
1522  m_qobjectData.erase(it);
1523  delete data;
1524 }
#define it(className, varName)
T & value() const
Returns a modifiable reference to the current item&#39;s value.
Definition: qhash.h:348
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QHash< QObject *, QScript::QObjectData * > m_qobjectData
static const char * data(const QByteArray &arr)
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
The QHash::iterator class provides an STL-style non-const iterator for QHash and QMultiHash.
Definition: qhash.h:330
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865
iterator erase(iterator it)
Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator...
Definition: qhash.h:827

◆ agentDeleted()

void QScriptEnginePrivate::agentDeleted ( QScriptEngineAgent agent)

Definition at line 1359 of file qscriptengine.cpp.

Referenced by QScriptEngineAgent::~QScriptEngineAgent().

1360 {
1361  ownedAgents.removeOne(agent);
1362  if (activeAgent == agent) {
1363  QScriptEngineAgentPrivate::get(agent)->detach();
1364  activeAgent = 0;
1365  }
1366 }
QList< QScriptEngineAgent * > ownedAgents
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
Definition: qlist.h:796
static QScriptEngineAgent * get(QScriptEngineAgentPrivate *p)
QScriptEngineAgent * activeAgent

◆ allocateScriptValuePrivate()

QScriptValuePrivate * QScriptEnginePrivate::allocateScriptValuePrivate ( size_t  size)
inline

Definition at line 591 of file qscriptengine_p.h.

592 {
593  if (freeScriptValues) {
595  freeScriptValues = p->next;
597  return p;
598  }
599  return reinterpret_cast<QScriptValuePrivate*>(qMalloc(size));
600 }
QScriptValuePrivate * next
Q_CORE_EXPORT void * qMalloc(size_t size)
Definition: qmalloc.cpp:53
QScriptValuePrivate * freeScriptValues

◆ arrayFromStringList()

JSC::JSValue QScriptEnginePrivate::arrayFromStringList ( JSC::ExecState *  exec,
const QStringList lst 
)
static

Definition at line 1079 of file qscriptengine.cpp.

1080 {
1081  JSC::JSValue arr = newArray(exec, lst.size());
1082  for (int i = 0; i < lst.size(); ++i)
1083  setProperty(exec, arr, i, JSC::jsString(exec, lst.at(i)));
1084  return arr;
1085 }
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static void setProperty(JSC::ExecState *, JSC::JSValue object, const JSC::UString &name, JSC::JSValue, const QScriptValue::PropertyFlags &flags=QScriptValue::KeepExistingFlags)
static JSC::JSValue newArray(JSC::ExecState *, uint length)
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ arrayFromVariantList()

JSC::JSValue QScriptEnginePrivate::arrayFromVariantList ( JSC::ExecState *  exec,
const QVariantList lst 
)
static

Definition at line 1096 of file qscriptengine.cpp.

1097 {
1098  JSC::JSValue arr = newArray(exec, lst.size());
1099  for (int i = 0; i < lst.size(); ++i)
1100  setProperty(exec, arr, i, jscValueFromVariant(exec, lst.at(i)));
1101  return arr;
1102 }
static JSC::JSValue jscValueFromVariant(JSC::ExecState *, const QVariant &value)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
static void setProperty(JSC::ExecState *, JSC::JSValue object, const JSC::UString &name, JSC::JSValue, const QScriptValue::PropertyFlags &flags=QScriptValue::KeepExistingFlags)
static JSC::JSValue newArray(JSC::ExecState *, uint length)
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ canEvaluate()

bool QScriptEnginePrivate::canEvaluate ( const QString program)
static

◆ checkSyntax()

QScriptSyntaxCheckResult QScriptEnginePrivate::checkSyntax ( const QString program)
static

Definition at line 2619 of file qscriptengine.cpp.

Referenced by QScriptEngine::checkSyntax().

2620 {
2621  QScript::SyntaxChecker checker;
2622  QScript::SyntaxChecker::Result result = checker.checkSyntax(program);
2624  switch (result.state) {
2627  break;
2630  break;
2633  break;
2634  }
2635  p->errorLineNumber = result.errorLineNumber;
2637  p->errorMessage = result.errorMessage;
2638  return QScriptSyntaxCheckResult(p);
2639 }
QScriptSyntaxCheckResult::State state
Result checkSyntax(const QString &code)
The QScriptSyntaxCheckResult class provides the result of a script syntax check.
Definition: qscriptengine.h:75

◆ clearCurrentException()

void QScriptEnginePrivate::clearCurrentException ( )
inline

Definition at line 276 of file qscriptengine_p.h.

Referenced by QScriptEngineAgentPrivate::exceptionCatch().

QExplicitlySharedDataPointer< QScriptValuePrivate > d_ptr
Definition: qscriptvalue.h:209
QScriptValue m_currentException
void reset()
Resets this to be null.
Definition: qshareddata.h:150

◆ collectGarbage()

void QScriptEnginePrivate::collectGarbage ( )

Definition at line 1342 of file qscriptengine.cpp.

Referenced by QScript::functionGC().

1343 {
1344  QScript::APIShim shim(this);
1345  globalData->heap.collectAllGarbage();
1346 }
JSC::JSGlobalData * globalData

◆ contextFlags()

uint QScriptEnginePrivate::contextFlags ( JSC::ExecState *  exec)
static

For native context, we use the ReturnValueRegister entry in the stackframe header to store flags.

Warning
This function is not part of the public interface.
We can do that because this header is not used as the native function return their value thought C++

when setting flags, NativeContext should always be set

contextFlags returns 0 for non native context

Definition at line 1260 of file qscriptengine.cpp.

Referenced by QScriptContext::activationObject(), QScriptContext::callee(), QScriptContext::isCalledAsConstructor(), and QScriptContext::setActivationObject().

1261 {
1262  if (exec->codeBlock())
1263  return 0; //js function doesn't have flags
1264 
1265  return exec->returnValueRegister();
1266 }

◆ contextForFrame()

QScriptContext * QScriptEnginePrivate::contextForFrame ( JSC::ExecState *  frame)
inlinestatic

Definition at line 849 of file qscriptengine_p.h.

Referenced by QScript::ClassObjectDelegate::call(), QScript::DeclarativeObjectDelegate::call(), QScript::ClassObjectDelegate::construct(), QScript::QMetaObjectWrapperObject::execute(), QScript::GlobalObject::getOwnPropertyDescriptor(), QScript::GlobalObject::getOwnPropertySlot(), QScriptContext::parentContext(), QScript::FunctionWrapper::proxyCall(), QScript::FunctionWithArgWrapper::proxyCall(), QScript::FunctionWrapper::proxyConstruct(), QScript::FunctionWithArgWrapper::proxyConstruct(), QScriptDeclarativeClass::pushCleanContext(), and QScriptContextInfoPrivate::QScriptContextInfoPrivate().

850 {
851  if (frame && frame->callerFrame()->hasHostCallFrameFlag() && !frame->callee()
852  && frame->callerFrame()->removeHostCallFrameFlag() == QScript::scriptEngineFromExec(frame)->globalExec()) {
853  //skip the "fake" context created in Interpreter::execute.
854  frame = frame->callerFrame()->removeHostCallFrameFlag();
855  }
856  return reinterpret_cast<QScriptContext *>(frame);
857 }
The QScriptContext class represents a Qt Script function invocation.
JSC::ExecState * globalExec() const
QScriptEnginePrivate * scriptEngineFromExec(const JSC::ExecState *exec)

◆ convertNumber()

bool QScriptEnginePrivate::convertNumber ( qsreal  value,
int  type,
void *  ptr 
)
static

Definition at line 3347 of file qscriptengine.cpp.

Referenced by QScriptEngine::convertV2().

3348 {
3349  switch (QMetaType::Type(type)) {
3350  case QMetaType::Bool:
3351  *reinterpret_cast<bool*>(ptr) = QScript::ToBool(value);
3352  return true;
3353  case QMetaType::Int:
3354  *reinterpret_cast<int*>(ptr) = QScript::ToInt32(value);
3355  return true;
3356  case QMetaType::UInt:
3357  *reinterpret_cast<uint*>(ptr) = QScript::ToUInt32(value);
3358  return true;
3359  case QMetaType::LongLong:
3360  *reinterpret_cast<qlonglong*>(ptr) = qlonglong(QScript::ToInteger(value));
3361  return true;
3362  case QMetaType::ULongLong:
3363  *reinterpret_cast<qulonglong*>(ptr) = qulonglong(QScript::ToInteger(value));
3364  return true;
3365  case QMetaType::Double:
3366  *reinterpret_cast<double*>(ptr) = value;
3367  return true;
3368  case QMetaType::QString:
3369  *reinterpret_cast<QString*>(ptr) = QScript::ToString(value);
3370  return true;
3371  case QMetaType::Float:
3372  *reinterpret_cast<float*>(ptr) = value;
3373  return true;
3374  case QMetaType::Short:
3375  *reinterpret_cast<short*>(ptr) = short(QScript::ToInt32(value));
3376  return true;
3377  case QMetaType::UShort:
3378  *reinterpret_cast<unsigned short*>(ptr) = QScript::ToUInt16(value);
3379  return true;
3380  case QMetaType::Char:
3381  *reinterpret_cast<char*>(ptr) = char(QScript::ToInt32(value));
3382  return true;
3383  case QMetaType::UChar:
3384  *reinterpret_cast<unsigned char*>(ptr) = (unsigned char)(QScript::ToInt32(value));
3385  return true;
3386  case QMetaType::QChar:
3387  *reinterpret_cast<QChar*>(ptr) = QChar(QScript::ToUInt16(value));
3388  return true;
3389  default:
3390  break;
3391  }
3392  return false;
3393 }
int type
Definition: qmetatype.cpp:239
qsreal ToInteger(qsreal n)
quint32 ToUInt32(qsreal n)
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
Type
These are the built-in types supported by QMetaType:
Definition: qmetatype.h:64
QString ToString(qsreal)
unsigned int uint
Definition: qglobal.h:996
qint32 ToInt32(qsreal n)
const T * ptr(const T &t)
bool ToBool(qsreal)
quint16 ToUInt16(qsreal n)
quint64 qulonglong
Definition: qglobal.h:952
qint64 qlonglong
Definition: qglobal.h:951

◆ convertString()

bool QScriptEnginePrivate::convertString ( const QString value,
int  type,
void *  ptr 
)
static

Definition at line 3395 of file qscriptengine.cpp.

Referenced by QScriptEngine::convertV2().

3396 {
3397  switch (QMetaType::Type(type)) {
3398  case QMetaType::Bool:
3399  *reinterpret_cast<bool*>(ptr) = QScript::ToBool(value);
3400  return true;
3401  case QMetaType::Int:
3402  *reinterpret_cast<int*>(ptr) = QScript::ToInt32(value);
3403  return true;
3404  case QMetaType::UInt:
3405  *reinterpret_cast<uint*>(ptr) = QScript::ToUInt32(value);
3406  return true;
3407  case QMetaType::LongLong:
3408  *reinterpret_cast<qlonglong*>(ptr) = qlonglong(QScript::ToInteger(value));
3409  return true;
3410  case QMetaType::ULongLong:
3411  *reinterpret_cast<qulonglong*>(ptr) = qulonglong(QScript::ToInteger(value));
3412  return true;
3413  case QMetaType::Double:
3414  *reinterpret_cast<double*>(ptr) = QScript::ToNumber(value);
3415  return true;
3416  case QMetaType::QString:
3417  *reinterpret_cast<QString*>(ptr) = value;
3418  return true;
3419  case QMetaType::Float:
3420  *reinterpret_cast<float*>(ptr) = QScript::ToNumber(value);
3421  return true;
3422  case QMetaType::Short:
3423  *reinterpret_cast<short*>(ptr) = short(QScript::ToInt32(value));
3424  return true;
3425  case QMetaType::UShort:
3426  *reinterpret_cast<unsigned short*>(ptr) = QScript::ToUInt16(value);
3427  return true;
3428  case QMetaType::Char:
3429  *reinterpret_cast<char*>(ptr) = char(QScript::ToInt32(value));
3430  return true;
3431  case QMetaType::UChar:
3432  *reinterpret_cast<unsigned char*>(ptr) = (unsigned char)(QScript::ToInt32(value));
3433  return true;
3434  case QMetaType::QChar:
3435  *reinterpret_cast<QChar*>(ptr) = QChar(QScript::ToUInt16(value));
3436  return true;
3437  default:
3438  break;
3439  }
3440  return false;
3441 }
int type
Definition: qmetatype.cpp:239
qsreal ToInteger(qsreal n)
quint32 ToUInt32(qsreal n)
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
Type
These are the built-in types supported by QMetaType:
Definition: qmetatype.h:64
unsigned int uint
Definition: qglobal.h:996
qint32 ToInt32(qsreal n)
const T * ptr(const T &t)
bool ToBool(qsreal)
qsreal ToNumber(const QString &)
quint16 ToUInt16(qsreal n)
quint64 qulonglong
Definition: qglobal.h:952
qint64 qlonglong
Definition: qglobal.h:951

◆ convertToNativeQObject()

bool QScriptEnginePrivate::convertToNativeQObject ( JSC::ExecState *  exec,
JSC::JSValue  value,
const QByteArray targetType,
void **  result 
)
static

Definition at line 1485 of file qscriptengine.cpp.

Referenced by QScript::callQtMethod().

1488 {
1489  if (!targetType.endsWith('*'))
1490  return false;
1491  if (QObject *qobject = toQObject(exec, value)) {
1492  int start = targetType.startsWith("const ") ? 6 : 0;
1493  QByteArray className = targetType.mid(start, targetType.size()-start-1);
1494  if (void *instance = qobject->qt_metacast(className)) {
1495  *result = instance;
1496  return true;
1497  }
1498  }
1499  return false;
1500 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static QObject * toQObject(JSC::ExecState *, JSC::JSValue)
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
bool startsWith(const QByteArray &a) const
Returns true if this byte array starts with byte array ba; otherwise returns false.
const char * className
Definition: qwizard.cpp:137
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...

◆ convertValue()

bool QScriptEnginePrivate::convertValue ( JSC::ExecState *  exec,
JSC::JSValue  value,
int  type,
void *  ptr 
)
static

Definition at line 3159 of file qscriptengine.cpp.

Referenced by QScript::callQtMethod(), QScriptEngine::convert(), QScriptEngine::convertV2(), jscValueToVariant(), and QScript::variantFromValue().

3161 {
3162  QScriptEnginePrivate *eng = exec ? QScript::scriptEngineFromExec(exec) : 0;
3163  if (eng) {
3165  if (info && info->demarshal) {
3166  info->demarshal(eng->scriptValueFromJSCValue(value), ptr);
3167  return true;
3168  }
3169  }
3170 
3171  // check if it's one of the types we know
3172  switch (QMetaType::Type(type)) {
3173  case QMetaType::Bool:
3174  *reinterpret_cast<bool*>(ptr) = toBool(exec, value);
3175  return true;
3176  case QMetaType::Int:
3177  *reinterpret_cast<int*>(ptr) = toInt32(exec, value);
3178  return true;
3179  case QMetaType::UInt:
3180  *reinterpret_cast<uint*>(ptr) = toUInt32(exec, value);
3181  return true;
3182  case QMetaType::LongLong:
3183  *reinterpret_cast<qlonglong*>(ptr) = qlonglong(toInteger(exec, value));
3184  return true;
3185  case QMetaType::ULongLong:
3186  *reinterpret_cast<qulonglong*>(ptr) = qulonglong(toInteger(exec, value));
3187  return true;
3188  case QMetaType::Double:
3189  *reinterpret_cast<double*>(ptr) = toNumber(exec, value);
3190  return true;
3191  case QMetaType::QString:
3192  if (value.isUndefined() || value.isNull())
3193  *reinterpret_cast<QString*>(ptr) = QString();
3194  else
3195  *reinterpret_cast<QString*>(ptr) = toString(exec, value);
3196  return true;
3197  case QMetaType::Float:
3198  *reinterpret_cast<float*>(ptr) = toNumber(exec, value);
3199  return true;
3200  case QMetaType::Short:
3201  *reinterpret_cast<short*>(ptr) = short(toInt32(exec, value));
3202  return true;
3203  case QMetaType::UShort:
3204  *reinterpret_cast<unsigned short*>(ptr) = QScript::ToUInt16(toNumber(exec, value));
3205  return true;
3206  case QMetaType::Char:
3207  *reinterpret_cast<char*>(ptr) = char(toInt32(exec, value));
3208  return true;
3209  case QMetaType::UChar:
3210  *reinterpret_cast<unsigned char*>(ptr) = (unsigned char)(toInt32(exec, value));
3211  return true;
3212  case QMetaType::QChar:
3213  if (value.isString()) {
3214  QString str = toString(exec, value);
3215  *reinterpret_cast<QChar*>(ptr) = str.isEmpty() ? QChar() : str.at(0);
3216  } else {
3217  *reinterpret_cast<QChar*>(ptr) = QChar(QScript::ToUInt16(toNumber(exec, value)));
3218  }
3219  return true;
3220  case QMetaType::QDateTime:
3221  if (isDate(value)) {
3222  *reinterpret_cast<QDateTime *>(ptr) = toDateTime(exec, value);
3223  return true;
3224  } break;
3225  case QMetaType::QDate:
3226  if (isDate(value)) {
3227  *reinterpret_cast<QDate *>(ptr) = toDateTime(exec, value).date();
3228  return true;
3229  } break;
3230 #ifndef QT_NO_REGEXP
3231  case QMetaType::QRegExp:
3232  if (isRegExp(value)) {
3233  *reinterpret_cast<QRegExp *>(ptr) = toRegExp(exec, value);
3234  return true;
3235  } break;
3236 #endif
3237 #ifndef QT_NO_QOBJECT
3239  if (isQObject(value) || value.isNull()) {
3240  *reinterpret_cast<QObject* *>(ptr) = toQObject(exec, value);
3241  return true;
3242  } break;
3244  if (isQObject(value) || value.isNull()) {
3245  QObject *qo = toQObject(exec, value);
3246  if (!qo || qo->isWidgetType()) {
3247  *reinterpret_cast<QWidget* *>(ptr) = reinterpret_cast<QWidget*>(qo);
3248  return true;
3249  }
3250  } break;
3251 #endif
3253  if (isArray(value)) {
3254  *reinterpret_cast<QStringList *>(ptr) = stringListFromArray(exec, value);
3255  return true;
3256  } break;
3258  if (isArray(value)) {
3259  *reinterpret_cast<QVariantList *>(ptr) = variantListFromArray(exec, JSC::asArray(value));
3260  return true;
3261  } break;
3263  if (isObject(value)) {
3264  *reinterpret_cast<QVariantMap *>(ptr) = variantMapFromObject(exec, JSC::asObject(value));
3265  return true;
3266  } break;
3267  case QMetaType::QVariant:
3268  *reinterpret_cast<QVariant*>(ptr) = toVariant(exec, value);
3269  return true;
3270  default:
3271  ;
3272  }
3273 
3275 #ifndef QT_NO_QOBJECT
3276  if (convertToNativeQObject(exec, value, name, reinterpret_cast<void* *>(ptr)))
3277  return true;
3278 #endif
3279  if (isVariant(value) && name.endsWith('*')) {
3280  int valueType = QMetaType::type(name.left(name.size()-1));
3281  QVariant &var = variantValue(value);
3282  if (valueType == var.userType()) {
3283  *reinterpret_cast<void* *>(ptr) = var.data();
3284  return true;
3285  } else {
3286  // look in the prototype chain
3287  JSC::JSValue proto = JSC::asObject(value)->prototype();
3288  while (proto.isObject()) {
3289  bool canCast = false;
3290  if (isVariant(proto)) {
3291  canCast = (type == variantValue(proto).userType())
3292  || (valueType && (valueType == variantValue(proto).userType()));
3293  }
3294 #ifndef QT_NO_QOBJECT
3295  else if (isQObject(proto)) {
3296  QByteArray className = name.left(name.size()-1);
3297  if (QObject *qobject = toQObject(exec, proto))
3298  canCast = qobject->qt_metacast(className) != 0;
3299  }
3300 #endif
3301  if (canCast) {
3302  QByteArray varTypeName = QMetaType::typeName(var.userType());
3303  if (varTypeName.endsWith('*'))
3304  *reinterpret_cast<void* *>(ptr) = *reinterpret_cast<void* *>(var.data());
3305  else
3306  *reinterpret_cast<void* *>(ptr) = var.data();
3307  return true;
3308  }
3309  proto = JSC::asObject(proto)->prototype();
3310  }
3311  }
3312  } else if (value.isNull() && name.endsWith('*')) {
3313  *reinterpret_cast<void* *>(ptr) = 0;
3314  return true;
3315  } else if (type == qMetaTypeId<QScriptValue>()) {
3316  if (!eng)
3317  return false;
3318  *reinterpret_cast<QScriptValue*>(ptr) = eng->scriptValueFromJSCValue(value);
3319  return true;
3320  }
3321 
3322  // lazy registration of some common list types
3323 #ifndef QT_NO_QOBJECT
3324  else if (type == qMetaTypeId<QObjectList>()) {
3325  if (!eng)
3326  return false;
3327  qScriptRegisterSequenceMetaType<QObjectList>(eng->q_func());
3328  return convertValue(exec, value, type, ptr);
3329  }
3330 #endif
3331  else if (type == qMetaTypeId<QList<int> >()) {
3332  if (!eng)
3333  return false;
3334  qScriptRegisterSequenceMetaType<QList<int> >(eng->q_func());
3335  return convertValue(exec, value, type, ptr);
3336  }
3337 
3338 #if 0
3339  if (!name.isEmpty()) {
3340  qWarning("QScriptEngine::convert: unable to convert value to type `%s'",
3341  name.constData());
3342  }
3343 #endif
3344  return false;
3345 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static bool isObject(JSC::JSValue)
int type
Definition: qmetatype.cpp:239
QScriptEnginePrivate * scriptEngineFromExec(const JSC::ExecState *exec)
static mach_timebase_info_data_t info
static QStringList stringListFromArray(JSC::ExecState *, JSC::JSValue arr)
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
static QVariant toVariant(JSC::ExecState *, JSC::JSValue)
static QVariantMap variantMapFromObject(JSC::ExecState *, JSC::JSObject *obj)
#define at(className, varName)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static QRegExp toRegExp(JSC::ExecState *, JSC::JSValue)
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static QObject * toQObject(JSC::ExecState *, JSC::JSValue)
int qMetaTypeId()
Definition: qmetatype.h:224
The QDate class provides date functions.
Definition: qdatetime.h:55
static qsreal toNumber(JSC::ExecState *, JSC::JSValue)
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
const char * className
Definition: qwizard.cpp:137
static bool convertToNativeQObject(JSC::ExecState *, JSC::JSValue, const QByteArray &targetType, void **result)
void * data()
Definition: qvariant.cpp:3077
static bool isVariant(JSC::JSValue)
static qint32 toInt32(JSC::ExecState *, JSC::JSValue)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static JSC::UString toString(JSC::ExecState *, JSC::JSValue)
const char * name
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static QDateTime toDateTime(JSC::ExecState *, JSC::JSValue)
Q_CORE_EXPORT void qWarning(const char *,...)
Type
These are the built-in types supported by QMetaType:
Definition: qmetatype.h:64
unsigned int uint
Definition: qglobal.h:996
static qsreal toInteger(JSC::ExecState *, JSC::JSValue)
const T * ptr(const T &t)
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
static int type(const char *typeName)
Returns a handle to the type called typeName, or 0 if there is no such type.
Definition: qmetatype.cpp:607
QHash< int, QScriptTypeInfo * > m_typeInfos
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
QDate date() const
Returns the date part of the datetime.
Definition: qdatetime.cpp:2357
static bool convertValue(JSC::ExecState *, JSC::JSValue value, int type, void *ptr)
static bool isDate(JSC::JSValue)
static QVariantList variantListFromArray(JSC::ExecState *, JSC::JSArray *arr)
static bool isRegExp(JSC::JSValue)
bool isWidgetType() const
Returns true if the object is a widget; otherwise returns false.
Definition: qobject.h:146
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
QScriptEngine::DemarshalFunction demarshal
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
static const char * typeName(int type)
Returns the type name associated with the given type, or 0 if no matching type was found...
Definition: qmetatype.cpp:406
static bool isQObject(JSC::JSValue)
static quint32 toUInt32(JSC::ExecState *, JSC::JSValue)
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
static QVariant & variantValue(JSC::JSValue value)
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
quint16 ToUInt16(qsreal n)
QScriptValue scriptValueFromJSCValue(JSC::JSValue value)
quint64 qulonglong
Definition: qglobal.h:952
static bool toBool(JSC::ExecState *, JSC::JSValue)
static bool isArray(JSC::JSValue)
qint64 qlonglong
Definition: qglobal.h:951
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...

◆ create()

JSC::JSValue QScriptEnginePrivate::create ( JSC::ExecState *  exec,
int  type,
const void *  ptr 
)
static

Definition at line 3056 of file qscriptengine.cpp.

Referenced by QScript::callQtMethod(), and QScript::QObjectConnectionManager::execute().

3057 {
3058  Q_ASSERT(ptr != 0);
3059  JSC::JSValue result;
3060  QScriptEnginePrivate *eng = exec ? QScript::scriptEngineFromExec(exec) : 0;
3061  QScriptTypeInfo *info = eng ? eng->m_typeInfos.value(type) : 0;
3062  if (info && info->marshal) {
3063  result = eng->scriptValueToJSCValue(info->marshal(eng->q_func(), ptr));
3064  } else {
3065  // check if it's one of the types we know
3066  switch (QMetaType::Type(type)) {
3067  case QMetaType::Void:
3068  return JSC::jsUndefined();
3069  case QMetaType::Bool:
3070  return JSC::jsBoolean(*reinterpret_cast<const bool*>(ptr));
3071  case QMetaType::Int:
3072  return JSC::jsNumber(exec, *reinterpret_cast<const int*>(ptr));
3073  case QMetaType::UInt:
3074  return JSC::jsNumber(exec, *reinterpret_cast<const uint*>(ptr));
3075  case QMetaType::LongLong:
3076  return JSC::jsNumber(exec, qsreal(*reinterpret_cast<const qlonglong*>(ptr)));
3077  case QMetaType::ULongLong:
3078  return JSC::jsNumber(exec, qsreal(*reinterpret_cast<const qulonglong*>(ptr)));
3079  case QMetaType::Double:
3080  return JSC::jsNumber(exec, qsreal(*reinterpret_cast<const double*>(ptr)));
3081  case QMetaType::QString:
3082  return JSC::jsString(exec, *reinterpret_cast<const QString*>(ptr));
3083  case QMetaType::Float:
3084  return JSC::jsNumber(exec, *reinterpret_cast<const float*>(ptr));
3085  case QMetaType::Short:
3086  return JSC::jsNumber(exec, *reinterpret_cast<const short*>(ptr));
3087  case QMetaType::UShort:
3088  return JSC::jsNumber(exec, *reinterpret_cast<const unsigned short*>(ptr));
3089  case QMetaType::Char:
3090  return JSC::jsNumber(exec, *reinterpret_cast<const char*>(ptr));
3091  case QMetaType::UChar:
3092  return JSC::jsNumber(exec, *reinterpret_cast<const unsigned char*>(ptr));
3093  case QMetaType::QChar:
3094  return JSC::jsNumber(exec, (*reinterpret_cast<const QChar*>(ptr)).unicode());
3096  result = arrayFromStringList(exec, *reinterpret_cast<const QStringList *>(ptr));
3097  break;
3099  result = arrayFromVariantList(exec, *reinterpret_cast<const QVariantList *>(ptr));
3100  break;
3102  result = objectFromVariantMap(exec, *reinterpret_cast<const QVariantMap *>(ptr));
3103  break;
3104  case QMetaType::QDateTime:
3105  result = newDate(exec, *reinterpret_cast<const QDateTime *>(ptr));
3106  break;
3107  case QMetaType::QDate:
3108  result = newDate(exec, QDateTime(*reinterpret_cast<const QDate *>(ptr)));
3109  break;
3110 #ifndef QT_NO_REGEXP
3111  case QMetaType::QRegExp:
3112  result = newRegExp(exec, *reinterpret_cast<const QRegExp *>(ptr));
3113  break;
3114 #endif
3115 #ifndef QT_NO_QOBJECT
3118  result = eng->newQObject(*reinterpret_cast<QObject* const *>(ptr));
3119  break;
3120 #endif
3121  case QMetaType::QVariant:
3122  result = eng->newVariant(*reinterpret_cast<const QVariant*>(ptr));
3123  break;
3124  default:
3125  if (type == qMetaTypeId<QScriptValue>()) {
3126  result = eng->scriptValueToJSCValue(*reinterpret_cast<const QScriptValue*>(ptr));
3127  if (!result)
3128  return JSC::jsUndefined();
3129  }
3130 
3131 #ifndef QT_NO_QOBJECT
3132  // lazy registration of some common list types
3133  else if (type == qMetaTypeId<QObjectList>()) {
3134  qScriptRegisterSequenceMetaType<QObjectList>(eng->q_func());
3135  return create(exec, type, ptr);
3136  }
3137 #endif
3138  else if (type == qMetaTypeId<QList<int> >()) {
3139  qScriptRegisterSequenceMetaType<QList<int> >(eng->q_func());
3140  return create(exec, type, ptr);
3141  }
3142 
3143  else {
3145  if (typeName.endsWith('*') && !*reinterpret_cast<void* const *>(ptr))
3146  return JSC::jsNull();
3147  else
3148  result = eng->newVariant(QVariant(type, ptr));
3149  }
3150  }
3151  }
3152  if (result && result.isObject() && info && info->prototype
3153  && JSC::JSValue::strictEqual(exec, JSC::asObject(result)->prototype(), eng->originalGlobalObject()->objectPrototype())) {
3154  JSC::asObject(result)->setPrototype(info->prototype);
3155  }
3156  return result;
3157 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
int type
Definition: qmetatype.cpp:239
QScriptEnginePrivate * scriptEngineFromExec(const JSC::ExecState *exec)
static mach_timebase_info_data_t info
static JSC::JSValue create(JSC::ExecState *, int type, const void *ptr)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
int qMetaTypeId()
Definition: qmetatype.h:224
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
JSC::JSValue scriptValueToJSCValue(const QScriptValue &value)
const char * typeName
Definition: qmetatype.cpp:239
JSC::JSGlobalObject * originalGlobalObject() const
static JSC::JSValue arrayFromStringList(JSC::ExecState *, const QStringList &lst)
Type
These are the built-in types supported by QMetaType:
Definition: qmetatype.h:64
const T * ptr(const T &t)
static JSC::JSValue newRegExp(JSC::ExecState *, const QRegExp &)
JSC::JSValue prototype
JSC::JSValue newVariant(const QVariant &)
QHash< int, QScriptTypeInfo * > m_typeInfos
static QByteArray prototype(const QList< QByteArray > &parameterTypes, const QList< QByteArray > &parameterNames, bool *ok)
Definition: qaxserver.cpp:685
static JSC::JSValue arrayFromVariantList(JSC::ExecState *, const QVariantList &lst)
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
static const char * typeName(int type)
Returns the type name associated with the given type, or 0 if no matching type was found...
Definition: qmetatype.cpp:406
static JSC::JSValue newDate(JSC::ExecState *, qsreal value)
double qsreal
Definition: qscriptvalue.h:52
JSC::JSValue newQObject(QObject *object, QScriptEngine::ValueOwnership ownership=QScriptEngine::QtOwnership, const QScriptEngine::QObjectWrapOptions &options=0)
static JSC::JSValue objectFromVariantMap(JSC::ExecState *, const QVariantMap &vmap)
QScriptEngine::MarshalFunction marshal
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...

◆ currentException()

QScriptValue QScriptEnginePrivate::currentException ( ) const
inline

Definition at line 275 of file qscriptengine_p.h.

275 { return m_currentException; }
QScriptValue m_currentException

◆ customGlobalObject()

JSC::JSObject * QScriptEnginePrivate::customGlobalObject ( ) const

Definition at line 1166 of file qscriptengine.cpp.

Referenced by toUsableValue().

1167 {
1169  return glob->customGlobalObject;
1170 }
JSC::JSGlobalObject * originalGlobalObject() const
JSC::JSObject * customGlobalObject

◆ declarativeClass()

QScriptDeclarativeClass * QScriptEnginePrivate::declarativeClass ( JSC::JSValue  v)
inlinestatic

Definition at line 1097 of file qscriptengine_p.h.

Referenced by QScriptDeclarativeClass::scriptClass(), and toVariant().

1098 {
1099  if (!QScriptEnginePrivate::isObject(v) || !v.inherits(&QScriptObject::info))
1100  return 0;
1101  QScriptObject *scriptObject = static_cast<QScriptObject*>(JSC::asObject(v));
1102  QScriptObjectDelegate *delegate = scriptObject->delegate();
1103  if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
1104  return 0;
1105  return static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->scriptClass();
1106 }
static bool isObject(JSC::JSValue)
virtual Type type() const =0
QScriptObjectDelegate * delegate() const
static const JSC::ClassInfo info

◆ declarativeObject()

QScriptDeclarativeClass::Object * QScriptEnginePrivate::declarativeObject ( JSC::JSValue  v)
inlinestatic

Definition at line 1108 of file qscriptengine_p.h.

Referenced by QScriptDeclarativeClass::object(), and toVariant().

1109 {
1110  if (!QScriptEnginePrivate::isObject(v) || !v.inherits(&QScriptObject::info))
1111  return 0;
1112  QScriptObject *scriptObject = static_cast<QScriptObject*>(JSC::asObject(v));
1113  QScriptObjectDelegate *delegate = scriptObject->delegate();
1114  if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
1115  return 0;
1116  return static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->object();
1117 }
static bool isObject(JSC::JSValue)
virtual Type type() const =0
QScriptObjectDelegate * delegate() const
static const JSC::ClassInfo info

◆ defaultPrototype()

JSC::JSValue QScriptEnginePrivate::defaultPrototype ( int  metaTypeId) const

Definition at line 1143 of file qscriptengine.cpp.

Referenced by newQObject(), and newVariant().

1144 {
1145  QScriptTypeInfo *info = m_typeInfos.value(metaTypeId);
1146  if (!info)
1147  return JSC::JSValue();
1148  return info->prototype;
1149 }
static mach_timebase_info_data_t info
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
JSC::JSValue prototype
QHash< int, QScriptTypeInfo * > m_typeInfos

◆ detachAllRegisteredScriptPrograms()

void QScriptEnginePrivate::detachAllRegisteredScriptPrograms ( )

Definition at line 1606 of file qscriptengine.cpp.

Referenced by ~QScriptEnginePrivate().

1607 {
1610  (*it)->detachFromEngine();
1612 }
#define it(className, varName)
const_iterator constEnd() const
Definition: qset.h:171
void clear()
Definition: qset.h:87
QSet< QScriptProgramPrivate * > registeredScriptPrograms
const_iterator constBegin() const
Definition: qset.h:168

◆ detachAllRegisteredScriptStrings()

void QScriptEnginePrivate::detachAllRegisteredScriptStrings ( )

Definition at line 1627 of file qscriptengine.cpp.

Referenced by ~QScriptEnginePrivate().

1628 {
1630  QScriptStringPrivate *next;
1631  for (it = registeredScriptStrings; it != 0; it = next) {
1632  it->detachFromEngine();
1633  next = it->next;
1634  it->prev = 0;
1635  it->next = 0;
1636  }
1638 }
#define it(className, varName)
QScriptStringPrivate * prev
QScriptStringPrivate * next
QScriptStringPrivate * registeredScriptStrings

◆ detachAllRegisteredScriptValues()

void QScriptEnginePrivate::detachAllRegisteredScriptValues ( )

Definition at line 1614 of file qscriptengine.cpp.

Referenced by ~QScriptEnginePrivate().

1615 {
1617  QScriptValuePrivate *next;
1618  for (it = registeredScriptValues; it != 0; it = next) {
1619  it->detachFromEngine();
1620  next = it->next;
1621  it->prev = 0;
1622  it->next = 0;
1623  }
1625 }
QScriptValuePrivate * next
#define it(className, varName)
QScriptValuePrivate * prev
QScriptValuePrivate * registeredScriptValues

◆ disposeQObject()

void QScriptEnginePrivate::disposeQObject ( QObject object)

Definition at line 1526 of file qscriptengine.cpp.

1527 {
1528  // TODO
1529 /* if (isCollecting()) {
1530  // wait until we're done with GC before deleting it
1531  int index = m_qobjectsToBeDeleted.indexOf(object);
1532  if (index == -1)
1533  m_qobjectsToBeDeleted.append(object);
1534  } else*/ {
1535  delete object;
1536  }
1537 }

◆ emitSignalHandlerException()

void QScriptEnginePrivate::emitSignalHandlerException ( )

Definition at line 1539 of file qscriptengine.cpp.

1540 {
1541  Q_Q(QScriptEngine);
1542  emit q->signalHandlerException(q->uncaughtException());
1543 }
#define Q_Q(Class)
Definition: qglobal.h:2483
The QScriptEngine class provides an environment for evaluating Qt Script code.
#define emit
Definition: qobjectdefs.h:76

◆ evaluateHelper()

JSC::JSValue QScriptEnginePrivate::evaluateHelper ( JSC::ExecState *  exec,
intptr_t  sourceId,
JSC::EvalExecutable *  executable,
bool &  compile 
)

Definition at line 1368 of file qscriptengine.cpp.

1371 {
1372  Q_Q(QScriptEngine);
1373  QBoolBlocker inEvalBlocker(inEval, true);
1374  q->currentContext()->activationObject(); //force the creation of a context for native function;
1375 
1376  JSC::Debugger* debugger = originalGlobalObject()->debugger();
1377  if (debugger)
1378  debugger->evaluateStart(sourceId);
1379 
1380  q->clearExceptions();
1381  JSC::DynamicGlobalObjectScope dynamicGlobalObjectScope(exec, exec->scopeChain()->globalObject);
1382 
1383  if (compile && !executable->isCompiled()) {
1384  JSC::JSObject* error = executable->compile(exec, exec->scopeChain());
1385  if (error) {
1386  compile = false;
1387  exec->setException(error);
1388 
1389  if (debugger) {
1390  debugger->exceptionThrow(JSC::DebuggerCallFrame(exec, error), sourceId, false);
1391  debugger->evaluateStop(error, sourceId);
1392  }
1393 
1394  return error;
1395  }
1396  }
1397 
1398  JSC::JSValue thisValue = thisForContext(exec);
1399  JSC::JSObject* thisObject = (!thisValue || thisValue.isUndefinedOrNull())
1400  ? exec->dynamicGlobalObject() : thisValue.toObject(exec);
1401  JSC::JSValue exceptionValue;
1402  timeoutChecker()->setShouldAbort(false);
1403  if (processEventsInterval > 0)
1404  timeoutChecker()->reset();
1405 
1406  JSC::JSValue result = exec->interpreter()->execute(executable, exec, thisObject, exec->scopeChain(), &exceptionValue);
1407 
1408  if (timeoutChecker()->shouldAbort()) {
1409  if (abortResult.isError())
1410  exec->setException(scriptValueToJSCValue(abortResult));
1411 
1412  if (debugger)
1413  debugger->evaluateStop(scriptValueToJSCValue(abortResult), sourceId);
1414 
1416  }
1417 
1418  if (exceptionValue) {
1419  exec->setException(exceptionValue);
1420 
1421  if (debugger)
1422  debugger->evaluateStop(exceptionValue, sourceId);
1423 
1424  return exceptionValue;
1425  }
1426 
1427  if (debugger)
1428  debugger->evaluateStop(result, sourceId);
1429 
1430  Q_ASSERT(!exec->hadException());
1431  return result;
1432 }
#define error(msg)
bool isError() const
Returns true if this QScriptValue is an object of the Error class; otherwise returns false...
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_Q(Class)
Definition: qglobal.h:2483
The QScriptEngine class provides an environment for evaluating Qt Script code.
JSC::JSValue scriptValueToJSCValue(const QScriptValue &value)
JSC::JSGlobalObject * originalGlobalObject() const
QScript::TimeoutCheckerProxy * timeoutChecker() const
void setShouldAbort(bool shouldAbort)
static JSC::JSValue thisForContext(JSC::ExecState *frame)
QScriptValue abortResult

◆ frameForContext() [1/2]

JSC::ExecState * QScriptEnginePrivate::frameForContext ( QScriptContext context)
inlinestatic

◆ frameForContext() [2/2]

const JSC::ExecState * QScriptEnginePrivate::frameForContext ( const QScriptContext context)
inlinestatic

Definition at line 864 of file qscriptengine_p.h.

865 {
866  return reinterpret_cast<const JSC::ExecState*>(context);
867 }

◆ freeScriptValuePrivate()

void QScriptEnginePrivate::freeScriptValuePrivate ( QScriptValuePrivate p)
inline

Definition at line 602 of file qscriptengine_p.h.

Referenced by QScriptValuePrivate::operator delete().

603 {
605  p->next = freeScriptValues;
606  freeScriptValues = p;
608  } else {
609  qFree(p);
610  }
611 }
QScriptValuePrivate * next
Q_CORE_EXPORT void qFree(void *ptr)
Definition: qmalloc.cpp:58
static const int maxFreeScriptValues
QScriptValuePrivate * freeScriptValues

◆ get() [1/2]

static QScriptEnginePrivate* QScriptEnginePrivate::get ( QScriptEngine q)
inlinestatic

◆ get() [2/2]

static QScriptEngine* QScriptEnginePrivate::get ( QScriptEnginePrivate d)
inlinestatic

Definition at line 159 of file qscriptengine_p.h.

159 { return d ? d->q_func() : 0; }

◆ getOriginalGlobalObjectProxy()

JSC::JSObject * QScriptEnginePrivate::getOriginalGlobalObjectProxy ( )

Definition at line 1172 of file qscriptengine.cpp.

1173 {
1175  JSC::ExecState* exec = currentFrame;
1177  }
1179 }
JSC::ExecState * currentFrame
JSC::JSGlobalObject * originalGlobalObject() const
WTF::RefPtr< JSC::Structure > scriptObjectStructure
JSC::JSObject * originalGlobalObjectProxy

◆ globalExec()

JSC::ExecState * QScriptEnginePrivate::globalExec ( ) const
inline

Definition at line 884 of file qscriptengine_p.h.

Referenced by contextForFrame(), and QScriptValueIteratorPrivate::ensureInitialized().

885 {
886  return originalGlobalObject()->globalExec();
887 }
JSC::JSGlobalObject * originalGlobalObject() const

◆ globalObject()

JSC::JSObject * QScriptEnginePrivate::globalObject ( ) const

Definition at line 1181 of file qscriptengine.cpp.

Referenced by mark(), QScriptEnginePrivate(), and setGlobalObject().

1182 {
1184  if (glob->customGlobalObject)
1185  return glob->customGlobalObject;
1186  return glob;
1187 }
JSC::JSGlobalObject * originalGlobalObject() const
JSC::JSObject * customGlobalObject

◆ hasDemarshalFunction()

bool QScriptEnginePrivate::hasDemarshalFunction ( int  type) const

Definition at line 3443 of file qscriptengine.cpp.

Referenced by QScript::QtPropertyFunction::execute().

3444 {
3446  return info && (info->demarshal != 0);
3447 }
int type
Definition: qmetatype.cpp:239
static mach_timebase_info_data_t info
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
QHash< int, QScriptTypeInfo * > m_typeInfos
QScriptEngine::DemarshalFunction demarshal

◆ hasValidCodeBlockRegister()

bool QScriptEnginePrivate::hasValidCodeBlockRegister ( JSC::ExecState *  frame)
inlinestatic

Definition at line 869 of file qscriptengine_p.h.

Referenced by QScriptContext::argumentsObject(), QScript::functionQsTr(), and QScriptContextInfoPrivate::QScriptContextInfoPrivate().

870 {
871 #if ENABLE(JIT)
872  // Frames created by the VM don't have their CodeBlock register
873  // initialized. We can detect such frames by checking if the
874  // callee is a host JSFunction.
875  JSC::JSObject *callee = frame->callee();
876  return !(callee && callee->inherits(&JSC::JSFunction::info)
877  && JSC::asFunction(callee)->isHostFunction());
878 #else
879  Q_UNUSED(frame);
880  return true;
881 #endif
882 }
static mach_timebase_info_data_t info
#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

◆ isArray()

bool QScriptEnginePrivate::isArray ( JSC::JSValue  value)
inlinestatic

Definition at line 916 of file qscriptengine_p.h.

Referenced by QScript::callQtMethod(), QScriptValue::isArray(), and toVariant().

917 {
918  return isObject(value) && value.inherits(&JSC::JSArray::info);
919 }
static bool isObject(JSC::JSValue)
static mach_timebase_info_data_t info

◆ isCollecting()

bool QScriptEnginePrivate::isCollecting ( ) const

Definition at line 1337 of file qscriptengine.cpp.

1338 {
1339  return globalData->heap.isBusy();
1340 }
JSC::JSGlobalData * globalData

◆ isDate()

bool QScriptEnginePrivate::isDate ( JSC::JSValue  value)
inlinestatic

Definition at line 921 of file qscriptengine_p.h.

Referenced by QScript::callQtMethod(), QScriptValue::isDate(), and toVariant().

922 {
923  return isObject(value) && value.inherits(&JSC::DateInstance::info);
924 }
static bool isObject(JSC::JSValue)
static mach_timebase_info_data_t info

◆ isError()

bool QScriptEnginePrivate::isError ( JSC::JSValue  value)
inlinestatic

Definition at line 926 of file qscriptengine_p.h.

Referenced by QScriptValue::isError().

927 {
928  return isObject(value) && value.inherits(&JSC::ErrorInstance::info);
929 }
static bool isObject(JSC::JSValue)
static mach_timebase_info_data_t info

◆ isObject()

bool QScriptEnginePrivate::isObject ( JSC::JSValue  value)
inlinestatic

Definition at line 911 of file qscriptengine_p.h.

Referenced by declarativeClass(), declarativeObject(), newVariant(), propertyHelper(), and toVariant().

912 {
913  return value && value.isObject();
914 }

◆ isQMetaObject()

bool QScriptEnginePrivate::isQMetaObject ( JSC::JSValue  value)
inlinestatic

Definition at line 960 of file qscriptengine_p.h.

Referenced by QScriptValue::isQMetaObject().

961 {
962 #ifndef QT_NO_QOBJECT
963  return isObject(value) && JSC::asObject(value)->inherits(&QScript::QMetaObjectWrapperObject::info);
964 #else
965  return false;
966 #endif
967 }
static const JSC::ClassInfo info
static bool isObject(JSC::JSValue)

◆ isQObject()

bool QScriptEnginePrivate::isQObject ( JSC::JSValue  value)
inlinestatic

Definition at line 945 of file qscriptengine_p.h.

Referenced by QScript::callQtMethod(), QScriptValue::isQObject(), and toVariant().

946 {
947 #ifndef QT_NO_QOBJECT
948  if (!isObject(value) || !value.inherits(&QScriptObject::info))
949  return false;
950  QScriptObject *object = static_cast<QScriptObject*>(JSC::asObject(value));
951  QScriptObjectDelegate *delegate = object->delegate();
952  return (delegate && (delegate->type() == QScriptObjectDelegate::QtObject ||
954  static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->scriptClass()->isQObject())));
955 #else
956  return false;
957 #endif
958 }
static bool isObject(JSC::JSValue)
virtual Type type() const =0
static const JSC::ClassInfo info

◆ isRegExp()

bool QScriptEnginePrivate::isRegExp ( JSC::JSValue  value)
inlinestatic

Definition at line 931 of file qscriptengine_p.h.

Referenced by QScript::callQtMethod(), QScriptValue::isRegExp(), toRegExp(), and toVariant().

932 {
933  return isObject(value) && value.inherits(&JSC::RegExpObject::info);
934 }
static bool isObject(JSC::JSValue)
static mach_timebase_info_data_t info

◆ isVariant()

bool QScriptEnginePrivate::isVariant ( JSC::JSValue  value)
inlinestatic

Definition at line 936 of file qscriptengine_p.h.

Referenced by QScript::callQtMethod(), QScriptValue::isVariant(), jscValueToVariant(), newVariant(), toVariant(), and QScript::variantFromValue().

937 {
938  if (!isObject(value) || !value.inherits(&QScriptObject::info))
939  return false;
940  QScriptObject *object = static_cast<QScriptObject*>(JSC::asObject(value));
941  QScriptObjectDelegate *delegate = object->delegate();
942  return (delegate && (delegate->type() == QScriptObjectDelegate::Variant));
943 }
static bool isObject(JSC::JSValue)
virtual Type type() const =0
static const JSC::ClassInfo info

◆ jscValueFromVariant()

JSC::JSValue QScriptEnginePrivate::jscValueFromVariant ( JSC::ExecState *  exec,
const QVariant value 
)
inlinestatic

Definition at line 634 of file qscriptengine_p.h.

Referenced by arrayFromVariantList(), QScript::ClassObjectDelegate::call(), QScript::callQtMethod(), QScript::QObjectConnectionManager::execute(), QScript::QtPropertyFunction::execute(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertySlot(), and objectFromVariantMap().

635 {
636  JSC::JSValue result = create(exec, v.userType(), v.data());
637  Q_ASSERT(result);
638  return result;
639 }
static JSC::JSValue create(JSC::ExecState *, int type, const void *ptr)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ jscValueToVariant()

QVariant QScriptEnginePrivate::jscValueToVariant ( JSC::ExecState *  exec,
JSC::JSValue  value,
int  targetType 
)
static

Definition at line 1057 of file qscriptengine.cpp.

1058 {
1059  QVariant v(targetType, (void *)0);
1060  if (convertValue(exec, value, targetType, v.data()))
1061  return v;
1062  if (uint(targetType) == QVariant::LastType)
1063  return toVariant(exec, value);
1064  if (isVariant(value)) {
1065  v = variantValue(value);
1066  if (v.canConvert(QVariant::Type(targetType))) {
1067  v.convert(QVariant::Type(targetType));
1068  return v;
1069  }
1070  QByteArray typeName = v.typeName();
1071  if (typeName.endsWith('*')
1072  && (QMetaType::type(typeName.left(typeName.size()-1)) == targetType)) {
1073  return QVariant(targetType, *reinterpret_cast<void* *>(v.data()));
1074  }
1075  }
1076  return QVariant();
1077 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static QVariant toVariant(JSC::ExecState *, JSC::JSValue)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static bool isVariant(JSC::JSValue)
const char * typeName
Definition: qmetatype.cpp:239
unsigned int uint
Definition: qglobal.h:996
Type
This enum type defines the types of variable that a QVariant can contain.
Definition: qvariant.h:95
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
static int type(const char *typeName)
Returns a handle to the type called typeName, or 0 if there is no such type.
Definition: qmetatype.cpp:607
static bool convertValue(JSC::ExecState *, JSC::JSValue value, int type, void *ptr)
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
static QVariant & variantValue(JSC::JSValue value)
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...

◆ mark()

void QScriptEnginePrivate::mark ( JSC::MarkStack &  markStack)

Definition at line 1275 of file qscriptengine.cpp.

1276 {
1277  Q_Q(QScriptEngine);
1278 
1279  if (originalGlobalObject()) {
1280  markStack.append(originalGlobalObject());
1281  markStack.append(globalObject());
1283  markStack.append(originalGlobalObjectProxy);
1284  }
1285 
1286  if (qobjectPrototype)
1287  markStack.append(qobjectPrototype);
1289  markStack.append(qmetaobjectPrototype);
1290  if (variantPrototype)
1291  markStack.append(variantPrototype);
1292 
1293  {
1295  for (it = registeredScriptValues; it != 0; it = it->next) {
1296  if (it->isJSC())
1297  markStack.append(it->jscValue);
1298  }
1299  }
1300 
1301  {
1303  for (it = m_typeInfos.constBegin(); it != m_typeInfos.constEnd(); ++it) {
1304  if ((*it)->prototype)
1305  markStack.append((*it)->prototype);
1306  }
1307  }
1308 
1309  if (q) {
1310  QScriptContext *context = q->currentContext();
1311 
1312  while (context) {
1313  JSC::ScopeChainNode *node = frameForContext(context)->scopeChain();
1314  JSC::ScopeChainIterator it(node);
1315  for (it = node->begin(); it != node->end(); ++it) {
1316  JSC::JSObject *object = *it;
1317  if (object)
1318  markStack.append(object);
1319  }
1320 
1321  context = context->parentContext();
1322  }
1323  }
1324 
1325 #ifndef QT_NO_QOBJECT
1326  markStack.drain(); // make sure everything is marked before marking qobject data
1327  {
1329  for (it = m_qobjectData.constBegin(); it != m_qobjectData.constEnd(); ++it) {
1330  QScript::QObjectData *qdata = it.value();
1331  qdata->mark(markStack);
1332  }
1333  }
1334 #endif
1335 }
The QScriptContext class represents a Qt Script function invocation.
QScriptValuePrivate * next
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
static JSC::ExecState * frameForContext(QScriptContext *context)
#define it(className, varName)
QScript::QVariantPrototype * variantPrototype
JSC::JSObject * globalObject() const
#define Q_Q(Class)
Definition: qglobal.h:2483
The QScriptEngine class provides an environment for evaluating Qt Script code.
QHash< QObject *, QScript::QObjectData * > m_qobjectData
QScript::QMetaObjectPrototype * qmetaobjectPrototype
JSC::JSGlobalObject * originalGlobalObject() const
void mark(JSC::MarkStack &)
const T & value() const
Returns the current item&#39;s value.
Definition: qhash.h:420
QHash< int, QScriptTypeInfo * > m_typeInfos
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
QScript::QObjectPrototype * qobjectPrototype
JSC::JSObject * originalGlobalObjectProxy
JSC::JSValue jscValue
QScriptValuePrivate * registeredScriptValues
QScriptContext * parentContext() const
Returns the parent context of this QScriptContext.

◆ newArray()

JSC::JSValue QScriptEnginePrivate::newArray ( JSC::ExecState *  exec,
uint  length 
)
inlinestatic

Definition at line 889 of file qscriptengine_p.h.

Referenced by arrayFromStringList(), and arrayFromVariantList().

890 {
891  return JSC::constructEmptyArray(exec, length);
892 }

◆ newDate() [1/2]

JSC::JSValue QScriptEnginePrivate::newDate ( JSC::ExecState *  exec,
qsreal  value 
)
inlinestatic

Definition at line 894 of file qscriptengine_p.h.

895 {
896  JSC::JSValue val = JSC::jsNumber(exec, value);
897  JSC::ArgList args(&val, 1);
898  return JSC::constructDate(exec, args);
899 }

◆ newDate() [2/2]

JSC::JSValue QScriptEnginePrivate::newDate ( JSC::ExecState *  exec,
const QDateTime value 
)
inlinestatic

Definition at line 901 of file qscriptengine_p.h.

902 {
903  return newDate(exec, QScript::DateTimeToMs(exec, value));
904 }
qsreal DateTimeToMs(JSC::ExecState *exec, const QDateTime &dt)
Converts a QDateTime to a JS date value (milliseconds).
static JSC::JSValue newDate(JSC::ExecState *, qsreal value)

◆ newObject()

JSC::JSValue QScriptEnginePrivate::newObject ( )
inline

Definition at line 906 of file qscriptengine_p.h.

Referenced by QScriptContext::argumentsObject().

907 {
909 }
JSC::ExecState * currentFrame
WTF::RefPtr< JSC::Structure > scriptObjectStructure

◆ newQMetaObject()

JSC::JSValue QScriptEnginePrivate::newQMetaObject ( const QMetaObject metaObject,
JSC::JSValue  ctor 
)

Definition at line 1475 of file qscriptengine.cpp.

1477 {
1478  if (!metaObject)
1479  return JSC::jsNull();
1480  JSC::ExecState* exec = currentFrame;
1482  return result;
1483 }
WTF::RefPtr< JSC::Structure > qmetaobjectWrapperObjectStructure
JSC::ExecState * currentFrame

◆ newQObject()

JSC::JSValue QScriptEnginePrivate::newQObject ( QObject object,
QScriptEngine::ValueOwnership  ownership = QScriptEngine::QtOwnership,
const QScriptEngine::QObjectWrapOptions &  options = 0 
)

Definition at line 1436 of file qscriptengine.cpp.

Referenced by create(), QScript::QObjectDelegate::getOwnPropertyDescriptor(), QScript::QObjectDelegate::getOwnPropertySlot(), QScript::qobjectProtoFuncFindChild(), and QScript::qobjectProtoFuncFindChildren().

1439 {
1440  if (!object)
1441  return JSC::jsNull();
1442  JSC::ExecState* exec = currentFrame;
1444  bool preferExisting = (options & QScriptEngine::PreferExistingWrapperObject) != 0;
1445  QScriptEngine::QObjectWrapOptions opt = options & ~QScriptEngine::PreferExistingWrapperObject;
1446  QScriptObject *result = 0;
1447  if (preferExisting) {
1448  result = data->findWrapper(ownership, opt);
1449  if (result)
1450  return result;
1451  }
1452  result = new (exec) QScriptObject(qobjectWrapperObjectStructure);
1453  if (preferExisting)
1454  data->registerWrapper(result, ownership, opt);
1455  result->setDelegate(new QScript::QObjectDelegate(object, ownership, options));
1456  /*if (setDefaultPrototype)*/ {
1457  const QMetaObject *meta = object->metaObject();
1458  while (meta) {
1459  QByteArray typeString = meta->className();
1460  typeString.append('*');
1461  int typeId = QMetaType::type(typeString);
1462  if (typeId != 0) {
1463  JSC::JSValue proto = defaultPrototype(typeId);
1464  if (proto) {
1465  result->setPrototype(proto);
1466  break;
1467  }
1468  }
1469  meta = meta->superClass();
1470  }
1471  }
1472  return result;
1473 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
QByteArray & append(char c)
Appends the character ch to this byte array.
QScript::QObjectData * qobjectData(QObject *object)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
JSC::JSValue defaultPrototype(int metaTypeId) const
JSC::ExecState * currentFrame
The QScriptEngine class provides an environment for evaluating Qt Script code.
static const char * data(const QByteArray &arr)
QScriptObject * findWrapper(QScriptEngine::ValueOwnership ownership, const QScriptEngine::QObjectWrapOptions &options) const
static int type(const char *typeName)
Returns a handle to the type called typeName, or 0 if there is no such type.
Definition: qmetatype.cpp:607
const QMetaObject * superClass() const
Returns the meta-object of the superclass, or 0 if there is no such object.
Definition: qobjectdefs.h:494
const char * className() const
Returns the class name.
Definition: qobjectdefs.h:491
void setDelegate(QScriptObjectDelegate *delegate)
WTF::RefPtr< JSC::Structure > qobjectWrapperObjectStructure
void registerWrapper(QScriptObject *wrapper, QScriptEngine::ValueOwnership ownership, const QScriptEngine::QObjectWrapOptions &options)

◆ newRegExp() [1/2]

JSC::JSValue QScriptEnginePrivate::newRegExp ( JSC::ExecState *  exec,
const QRegExp regexp 
)
static

Definition at line 1644 of file qscriptengine.cpp.

1645 {
1646  JSC::JSValue buf[2];
1647  JSC::ArgList args(buf, sizeof(buf));
1648 
1649  //convert the pattern to a ECMAScript pattern
1650  QString pattern = qt_regexp_toCanonical(regexp.pattern(), regexp.patternSyntax());
1651  if (regexp.isMinimal()) {
1652  QString ecmaPattern;
1653  int len = pattern.length();
1654  ecmaPattern.reserve(len);
1655  int i = 0;
1656  const QChar *wc = pattern.unicode();
1657  bool inBracket = false;
1658  while (i < len) {
1659  QChar c = wc[i++];
1660  ecmaPattern += c;
1661  switch (c.unicode()) {
1662  case '?':
1663  case '+':
1664  case '*':
1665  case '}':
1666  if (!inBracket)
1667  ecmaPattern += QLatin1Char('?');
1668  break;
1669  case '\\':
1670  if (i < len)
1671  ecmaPattern += wc[i++];
1672  break;
1673  case '[':
1674  inBracket = true;
1675  break;
1676  case ']':
1677  inBracket = false;
1678  break;
1679  default:
1680  break;
1681  }
1682  }
1683  pattern = ecmaPattern;
1684  }
1685 
1686  JSC::UString jscPattern = pattern;
1687  QString flags;
1688  if (regexp.caseSensitivity() == Qt::CaseInsensitive)
1689  flags.append(QLatin1Char('i'));
1690  JSC::UString jscFlags = flags;
1691  buf[0] = JSC::jsString(exec, jscPattern);
1692  buf[1] = JSC::jsString(exec, jscFlags);
1693  return JSC::constructRegExp(exec, args);
1694 }
unsigned char c[8]
Definition: qnumeric_p.h:62
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
The QString class provides a Unicode character string.
Definition: qstring.h:83
Qt::CaseSensitivity caseSensitivity() const
Returns Qt::CaseSensitive if the regexp is matched case sensitively; otherwise returns Qt::CaseInsens...
Definition: qregexp.cpp:3985
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
void reserve(int size)
Attempts to allocate memory for at least size characters.
Definition: qstring.h:881
Q_CORE_EXPORT QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax)
Definition: qregexp.cpp:1323
const QChar * unicode() const
Returns a &#39;\0&#39;-terminated Unicode representation of the string.
Definition: qstring.h:706
QString pattern() const
Returns the pattern string of the regular expression.
Definition: qregexp.cpp:3960
PatternSyntax patternSyntax() const
Returns the syntax used by the regular expression.
Definition: qregexp.cpp:4012
QString & append(QChar c)
Definition: qstring.cpp:1777
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
bool isMinimal() const
Returns true if minimal (non-greedy) matching is enabled; otherwise returns false.
Definition: qregexp.cpp:4046

◆ newRegExp() [2/2]

JSC::JSValue QScriptEnginePrivate::newRegExp ( JSC::ExecState *  exec,
const QString pattern,
const QString flags 
)
static

Definition at line 1698 of file qscriptengine.cpp.

1699 {
1700  JSC::JSValue buf[2];
1701  JSC::ArgList args(buf, sizeof(buf));
1702  JSC::UString jscPattern = pattern;
1703  QString strippedFlags;
1704  if (flags.contains(QLatin1Char('i')))
1705  strippedFlags += QLatin1Char('i');
1706  if (flags.contains(QLatin1Char('m')))
1707  strippedFlags += QLatin1Char('m');
1708  if (flags.contains(QLatin1Char('g')))
1709  strippedFlags += QLatin1Char('g');
1710  JSC::UString jscFlags = strippedFlags;
1711  buf[0] = JSC::jsString(exec, jscPattern);
1712  buf[1] = JSC::jsString(exec, jscFlags);
1713  return JSC::constructRegExp(exec, args);
1714 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ newVariant() [1/2]

JSC::JSValue QScriptEnginePrivate::newVariant ( const QVariant value)

Definition at line 1716 of file qscriptengine.cpp.

Referenced by QScript::callQtMethod(), create(), and newVariant().

1717 {
1719  obj->setDelegate(new QScript::QVariantDelegate(value));
1720  JSC::JSValue proto = defaultPrototype(value.userType());
1721  if (proto)
1722  obj->setPrototype(proto);
1723  return obj;
1724 }
WTF::RefPtr< JSC::Structure > variantWrapperObjectStructure
JSC::JSValue defaultPrototype(int metaTypeId) const
JSC::ExecState * currentFrame
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
void setDelegate(QScriptObjectDelegate *delegate)

◆ newVariant() [2/2]

JSC::JSValue QScriptEnginePrivate::newVariant ( JSC::JSValue  objectValue,
const QVariant value 
)

Definition at line 1726 of file qscriptengine.cpp.

1728 {
1729  if (!isObject(objectValue))
1730  return newVariant(value);
1731  JSC::JSObject *jscObject = JSC::asObject(objectValue);
1732  if (!jscObject->inherits(&QScriptObject::info)) {
1733  qWarning("QScriptEngine::newVariant(): changing class of non-QScriptObject not supported");
1734  return JSC::JSValue();
1735  }
1736  QScriptObject *jscScriptObject = static_cast<QScriptObject*>(jscObject);
1737  if (!isVariant(objectValue)) {
1738  jscScriptObject->setDelegate(new QScript::QVariantDelegate(value));
1739  } else {
1740  setVariantValue(objectValue, value);
1741  }
1742  return objectValue;
1743 }
static bool isObject(JSC::JSValue)
static const JSC::ClassInfo info
static bool isVariant(JSC::JSValue)
Q_CORE_EXPORT void qWarning(const char *,...)
JSC::JSValue newVariant(const QVariant &)
void setDelegate(QScriptObjectDelegate *delegate)
static void setVariantValue(JSC::JSValue objectValue, const QVariant &value)

◆ objectFromVariantMap()

JSC::JSValue QScriptEnginePrivate::objectFromVariantMap ( JSC::ExecState *  exec,
const QVariantMap vmap 
)
static

Definition at line 1118 of file qscriptengine.cpp.

1119 {
1120  JSC::JSValue obj = JSC::constructEmptyObject(exec);
1122  for (it = vmap.constBegin(); it != vmap.constEnd(); ++it)
1123  setProperty(exec, obj, it.key(), jscValueFromVariant(exec, it.value()));
1124  return obj;
1125 }
static JSC::JSValue jscValueFromVariant(JSC::ExecState *, const QVariant &value)
#define it(className, varName)
static void setProperty(JSC::ExecState *, JSC::JSValue object, const JSC::UString &name, JSC::JSValue, const QScriptValue::PropertyFlags &flags=QScriptValue::KeepExistingFlags)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the map.
Definition: qmap.h:374
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the map...
Definition: qmap.h:380
friend class const_iterator
Definition: qmap.h:369

◆ originalGlobalObject()

JSC::JSGlobalObject * QScriptEnginePrivate::originalGlobalObject ( ) const

◆ popContext()

void QScriptEnginePrivate::popContext ( )
Warning
This function is not part of the public interface. counter part of QScriptEnginePrivate::pushContext

Definition at line 2868 of file qscriptengine.cpp.

Referenced by QScript::ClassObjectDelegate::call(), QScript::DeclarativeObjectDelegate::call(), QScript::QtFunction::call(), QScript::QMetaObjectWrapperObject::call(), QScript::ClassObjectDelegate::construct(), QScript::QMetaObjectWrapperObject::construct(), QScript::QtPropertyFunction::execute(), QScript::FunctionWrapper::proxyCall(), QScript::FunctionWithArgWrapper::proxyCall(), QScript::FunctionWrapper::proxyConstruct(), and QScript::FunctionWithArgWrapper::proxyConstruct().

2869 {
2870  uint flags = contextFlags(currentFrame);
2871  bool hasScope = flags & HasScopeContext;
2872  if (flags & ShouldRestoreCallFrame) { //normal case
2873  JSC::RegisterFile &registerFile = currentFrame->interpreter()->registerFile();
2874  JSC::Register *const newEnd = currentFrame->registers() - JSC::RegisterFile::CallFrameHeaderSize - currentFrame->argumentCount();
2875  if (hasScope)
2876  currentFrame->scopeChain()->pop()->deref();
2877  registerFile.shrink(newEnd);
2878  } else if(hasScope) { //the stack frame was created by the Interpreter, we don't need to rewind it.
2879  currentFrame->setScopeChain(currentFrame->scopeChain()->pop());
2880  currentFrame->scopeChain()->deref();
2881  }
2882  currentFrame = currentFrame->callerFrame();
2883 }
static uint contextFlags(JSC::ExecState *)
For native context, we use the ReturnValueRegister entry in the stackframe header to store flags...
JSC::ExecState * currentFrame
unsigned int uint
Definition: qglobal.h:996

◆ property() [1/3]

JSC::JSValue QScriptEnginePrivate::property ( JSC::ExecState *  exec,
JSC::JSValue  value,
const JSC::Identifier &  id,
int  resolveMode = QScriptValue::ResolvePrototype 
)
inlinestatic

Definition at line 720 of file qscriptengine_p.h.

Referenced by QScript::functionConnect(), QScript::functionDisconnect(), QScriptValuePrivate::property(), propertyHelper(), stringListFromArray(), toRegExp(), variantListFromArray(), and variantMapFromObject().

721 {
722  Q_ASSERT(isObject(value));
723  JSC::JSObject *object = JSC::asObject(value);
724  JSC::PropertySlot slot(object);
725  if ((resolveMode & QScriptValue::ResolvePrototype) && object->getPropertySlot(exec, id, slot))
726  return slot.getValue(exec, id);
727  return propertyHelper(exec, value, id, resolveMode);
728 }
static bool isObject(JSC::JSValue)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static JSC::JSValue propertyHelper(JSC::ExecState *, JSC::JSValue, const JSC::Identifier &id, int resolveMode)

◆ property() [2/3]

JSC::JSValue QScriptEnginePrivate::property ( JSC::ExecState *  exec,
JSC::JSValue  value,
quint32  index,
int  resolveMode = QScriptValue::ResolvePrototype 
)
inlinestatic

Definition at line 730 of file qscriptengine_p.h.

731 {
732  Q_ASSERT(isObject(value));
733  JSC::JSObject *object = JSC::asObject(value);
734  JSC::PropertySlot slot(object);
735  if ((resolveMode & QScriptValue::ResolvePrototype) && object->getPropertySlot(exec, index, slot))
736  return slot.getValue(exec, index);
737  return propertyHelper(exec, value, index, resolveMode);
738 }
static bool isObject(JSC::JSValue)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static JSC::JSValue propertyHelper(JSC::ExecState *, JSC::JSValue, const JSC::Identifier &id, int resolveMode)
quint16 index

◆ property() [3/3]

JSC::JSValue QScriptEnginePrivate::property ( JSC::ExecState *  exec,
JSC::JSValue  value,
const JSC::UString &  name,
int  resolveMode 
)
inlinestatic

Definition at line 715 of file qscriptengine_p.h.

716 {
717  return property(exec, value, JSC::Identifier(exec, name), resolveMode);
718 }
const char * name
static JSC::JSValue property(JSC::ExecState *, JSC::JSValue, const JSC::Identifier &id, int resolveMode=QScriptValue::ResolvePrototype)

◆ propertyFlags() [1/2]

QScriptValue::PropertyFlags QScriptEnginePrivate::propertyFlags ( JSC::ExecState *  exec,
JSC::JSValue  value,
const JSC::Identifier &  id,
const QScriptValue::ResolveFlags &  mode 
)
static

Definition at line 1917 of file qscriptengine.cpp.

Referenced by QScriptValuePrivate::propertyFlags().

1919 {
1920  JSC::JSObject *object = JSC::asObject(value);
1921  unsigned attribs = 0;
1922  JSC::PropertyDescriptor descriptor;
1923  if (object->getOwnPropertyDescriptor(exec, id, descriptor))
1924  attribs = descriptor.attributes();
1925  else {
1926  if ((mode & QScriptValue::ResolvePrototype) && object->prototype() && object->prototype().isObject()) {
1927  JSC::JSValue proto = object->prototype();
1928  return propertyFlags(exec, proto, id, mode);
1929  }
1930  return 0;
1931  }
1932  QScriptValue::PropertyFlags result = 0;
1933  if (attribs & JSC::ReadOnly)
1934  result |= QScriptValue::ReadOnly;
1935  if (attribs & JSC::DontEnum)
1937  if (attribs & JSC::DontDelete)
1938  result |= QScriptValue::Undeletable;
1939  //We cannot rely on attribs JSC::Setter/Getter because they are not necesserly set by JSC (bug?)
1940  if (attribs & JSC::Getter || !object->lookupGetter(exec, id).isUndefinedOrNull())
1941  result |= QScriptValue::PropertyGetter;
1942  if (attribs & JSC::Setter || !object->lookupSetter(exec, id).isUndefinedOrNull())
1943  result |= QScriptValue::PropertySetter;
1944 #ifndef QT_NO_QOBJECT
1945  if (attribs & QScript::QObjectMemberAttribute)
1946  result |= QScriptValue::QObjectMember;
1947 #endif
1949  return result;
1950 }
PropertyFlags
Definition: qmetaobject_p.h:61
PropertyFlag
This enum describes the attributes of a property.
Definition: qscriptvalue.h:69
static QScriptValue::PropertyFlags propertyFlags(JSC::ExecState *, JSC::JSValue value, const JSC::Identifier &id, const QScriptValue::ResolveFlags &mode)

◆ propertyFlags() [2/2]

QScriptValue::PropertyFlags QScriptEnginePrivate::propertyFlags ( JSC::ExecState *  exec,
JSC::JSValue  value,
const JSC::UString &  name,
const QScriptValue::ResolveFlags &  mode 
)
inlinestatic

Definition at line 740 of file qscriptengine_p.h.

743 {
744  return propertyFlags(exec, value, JSC::Identifier(exec, name), mode);
745 }
const char * name
static QScriptValue::PropertyFlags propertyFlags(JSC::ExecState *, JSC::JSValue value, const JSC::Identifier &id, const QScriptValue::ResolveFlags &mode)

◆ propertyFlagsToJSCAttributes()

unsigned QScriptEnginePrivate::propertyFlagsToJSCAttributes ( const QScriptValue::PropertyFlags flags)
inlinestatic

Definition at line 668 of file qscriptengine_p.h.

Referenced by QScriptDeclarativeClass::newStaticScopeObject(), and setProperty().

669 {
670  unsigned attribs = 0;
671  if (flags & QScriptValue::ReadOnly)
672  attribs |= JSC::ReadOnly;
674  attribs |= JSC::DontEnum;
675  if (flags & QScriptValue::Undeletable)
676  attribs |= JSC::DontDelete;
677  attribs |= flags & QScriptValue::UserRange;
678  return attribs;
679 }

◆ propertyHelper() [1/2]

JSC::JSValue QScriptEnginePrivate::propertyHelper ( JSC::ExecState *  exec,
JSC::JSValue  value,
const JSC::Identifier &  id,
int  resolveMode 
)
static

Definition at line 1794 of file qscriptengine.cpp.

1795 {
1796  JSC::JSValue result;
1797  if (!(resolveMode & QScriptValue::ResolvePrototype)) {
1798  // Look in the object's own properties
1799  JSC::JSObject *object = JSC::asObject(value);
1800  JSC::PropertySlot slot(object);
1801  if (object->getOwnPropertySlot(exec, id, slot))
1802  result = slot.getValue(exec, id);
1803  }
1804  if (!result && (resolveMode & QScriptValue::ResolveScope)) {
1805  // ### check if it's a function object and look in the scope chain
1806  JSC::JSValue scope = property(exec, value, "__qt_scope__", QScriptValue::ResolveLocal);
1807  if (isObject(scope))
1808  result = property(exec, scope, id, resolveMode);
1809  }
1810  return result;
1811 }
static bool isObject(JSC::JSValue)
static JSC::JSValue property(JSC::ExecState *, JSC::JSValue, const JSC::Identifier &id, int resolveMode=QScriptValue::ResolvePrototype)

◆ propertyHelper() [2/2]

JSC::JSValue QScriptEnginePrivate::propertyHelper ( JSC::ExecState *  exec,
JSC::JSValue  value,
quint32  index,
int  resolveMode 
)
static

Definition at line 1813 of file qscriptengine.cpp.

1814 {
1815  JSC::JSValue result;
1816  if (!(resolveMode & QScriptValue::ResolvePrototype)) {
1817  // Look in the object's own properties
1818  JSC::JSObject *object = JSC::asObject(value);
1819  JSC::PropertySlot slot(object);
1820  if (object->getOwnPropertySlot(exec, index, slot))
1821  result = slot.getValue(exec, index);
1822  }
1823  return result;
1824 }
quint16 index

◆ pushContext()

JSC::CallFrame * QScriptEnginePrivate::pushContext ( JSC::CallFrame exec,
JSC::JSValue  _thisObject,
const JSC::ArgList &  args,
JSC::JSObject *  callee,
bool  calledAsConstructor = false,
bool  clearScopeChain = false 
)

JSC native function doesn't have different stackframe or context.

Warning
This function is not part of the public interface. push a context for a native function. so we need to create one.

use popContext right after to go back to the previous context the context if no stack overflow has hapenned

exec is the current top frame.

return the new top frame. (might be the same as exec if a new stackframe was not needed) or 0 if stack overflow

Definition at line 2778 of file qscriptengine.cpp.

Referenced by QScript::ClassObjectDelegate::call(), QScript::DeclarativeObjectDelegate::call(), QScript::QtFunction::call(), QScript::QMetaObjectWrapperObject::call(), QScript::ClassObjectDelegate::construct(), QScript::QMetaObjectWrapperObject::construct(), QScript::QtPropertyFunction::execute(), QScript::FunctionWrapper::proxyCall(), QScript::FunctionWithArgWrapper::proxyCall(), QScript::FunctionWrapper::proxyConstruct(), QScript::FunctionWithArgWrapper::proxyConstruct(), and QScriptDeclarativeClass::pushCleanContext().

2781 {
2782  JSC::JSValue thisObject = _thisObject;
2783  if (!callee) {
2784  // callee can't be zero, as this can cause JSC to crash during GC
2785  // marking phase if the context's Arguments object has been created.
2786  // Fake it by using the global object. Note that this is also handled
2787  // in QScriptContext::callee(), as that function should still return
2788  // an invalid value.
2789  callee = originalGlobalObject();
2790  }
2791  if (calledAsConstructor) {
2792  //JSC doesn't create default created object for native functions. so we do it
2793  JSC::JSValue prototype = callee->get(exec, exec->propertyNames().prototype);
2794  JSC::Structure *structure = prototype.isObject() ? JSC::asObject(prototype)->inheritorID()
2795  : originalGlobalObject()->emptyObjectStructure();
2796  thisObject = new (exec) QScriptObject(structure);
2797  }
2798 
2799  int flags = NativeContext;
2800  if (calledAsConstructor)
2801  flags |= CalledAsConstructorContext;
2802 
2803  //build a frame
2804  JSC::CallFrame *newCallFrame = exec;
2805  if (callee == 0 //called from public QScriptEngine::pushContext
2806  || exec->returnPC() == 0 || (contextFlags(exec) & NativeContext) //called from native-native call
2807  || (exec->codeBlock() && exec->callee() != callee)) { //the interpreter did not build a frame for us.
2808  //We need to check if the Interpreter might have already created a frame for function called from JS.
2809  JSC::Interpreter *interp = exec->interpreter();
2810  JSC::Register *oldEnd = interp->registerFile().end();
2811  int argc = args.size() + 1; //add "this"
2812  JSC::Register *newEnd = oldEnd + argc + JSC::RegisterFile::CallFrameHeaderSize;
2813  if (!interp->registerFile().grow(newEnd))
2814  return 0; //### Stack overflow
2815  newCallFrame = JSC::CallFrame::create(oldEnd);
2816  newCallFrame[0] = thisObject;
2817  int dst = 0;
2818  JSC::ArgList::const_iterator it;
2819  for (it = args.begin(); it != args.end(); ++it)
2820  newCallFrame[++dst] = *it;
2821  newCallFrame += argc + JSC::RegisterFile::CallFrameHeaderSize;
2822 
2823  if (!clearScopeChain) {
2824  newCallFrame->init(0, /*vPC=*/0, exec->scopeChain(), exec, flags | ShouldRestoreCallFrame, argc, callee);
2825  } else {
2826  newCallFrame->init(0, /*vPC=*/0, globalExec()->scopeChain(), exec, flags | ShouldRestoreCallFrame, argc, callee);
2827  }
2828  } else {
2829  setContextFlags(newCallFrame, flags);
2830 #if ENABLE(JIT)
2831  exec->registers()[JSC::RegisterFile::Callee] = JSC::JSValue(callee); //JIT let the callee set the 'callee'
2832 #endif
2833  if (calledAsConstructor) {
2834  //update the new created this
2835  JSC::Register* thisRegister = thisRegisterForFrame(newCallFrame);
2836  *thisRegister = thisObject;
2837  }
2838  }
2839  currentFrame = newCallFrame;
2840  return newCallFrame;
2841 }
JSC::ExecState * globalExec() const
static JSC::Register * thisRegisterForFrame(JSC::ExecState *frame)
#define it(className, varName)
static uint contextFlags(JSC::ExecState *)
For native context, we use the ReturnValueRegister entry in the stackframe header to store flags...
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
JSC::ExecState * currentFrame
static void setContextFlags(JSC::ExecState *, uint)
JSC::JSGlobalObject * originalGlobalObject() const
static QByteArray prototype(const QList< QByteArray > &parameterTypes, const QList< QByteArray > &parameterNames, bool *ok)
Definition: qaxserver.cpp:685
ExecState CallFrame

◆ qobjectData()

QScript::QObjectData * QScriptEnginePrivate::qobjectData ( QObject object)

Definition at line 1502 of file qscriptengine.cpp.

Referenced by newQObject(), scriptConnect(), and scriptDisconnect().

1503 {
1505  it = m_qobjectData.constFind(object);
1506  if (it != m_qobjectData.constEnd())
1507  return it.value();
1508 
1510  m_qobjectData.insert(object, data);
1511  QObject::connect(object, SIGNAL(destroyed(QObject*)),
1512  q_func(), SLOT(_q_objectDestroyed(QObject*)));
1513  return data;
1514 }
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
#define it(className, varName)
#define SLOT(a)
Definition: qobjectdefs.h:226
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
#define SIGNAL(a)
Definition: qobjectdefs.h:227
QHash< QObject *, QScript::QObjectData * > m_qobjectData
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
const T & value() const
Returns the current item&#39;s value.
Definition: qhash.h:420
static const char * data(const QByteArray &arr)
const_iterator constFind(const Key &key) const
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:859
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
void _q_objectDestroyed(QObject *)

◆ registerScriptProgram()

void QScriptEnginePrivate::registerScriptProgram ( QScriptProgramPrivate program)
inline

Definition at line 579 of file qscriptengine_p.h.

Referenced by QScriptProgramPrivate::executable().

580 {
583 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool contains(const T &value) const
Definition: qset.h:91
const_iterator insert(const T &value)
Definition: qset.h:179
QSet< QScriptProgramPrivate * > registeredScriptPrograms

◆ registerScriptString()

void QScriptEnginePrivate::registerScriptString ( QScriptStringPrivate value)
inline

Definition at line 826 of file qscriptengine_p.h.

Referenced by toStringHandle().

827 {
829  value->prev = 0;
830  value->next = registeredScriptStrings;
832  registeredScriptStrings->prev = value;
833  registeredScriptStrings = value;
834 }
AllocationType type
QScriptStringPrivate * prev
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QScriptStringPrivate * next
QScriptStringPrivate * registeredScriptStrings

◆ registerScriptValue()

void QScriptEnginePrivate::registerScriptValue ( QScriptValuePrivate value)
inline

Definition at line 613 of file qscriptengine_p.h.

614 {
615  value->prev = 0;
616  value->next = registeredScriptValues;
618  registeredScriptValues->prev = value;
619  registeredScriptValues = value;
620 }
QScriptValuePrivate * next
QScriptValuePrivate * prev
QScriptValuePrivate * registeredScriptValues

◆ reportAdditionalMemoryCost()

void QScriptEnginePrivate::reportAdditionalMemoryCost ( int  size)

Definition at line 1348 of file qscriptengine.cpp.

1349 {
1350  if (size > 0)
1351  globalData->heap.reportExtraMemoryCost(size);
1352 }
JSC::JSGlobalData * globalData

◆ restoreException()

void QScriptEnginePrivate::restoreException ( JSC::ExecState *  exec,
JSC::JSValue  val 
)
inlinestatic

Definition at line 820 of file qscriptengine_p.h.

Referenced by QScriptValue::call(), QScriptValue::construct(), QScriptValue::equals(), and QScript::ToPrimitive().

821 {
822  if (exec && val)
823  exec->setException(val);
824 }

◆ saveException()

void QScriptEnginePrivate::saveException ( JSC::ExecState *  exec,
JSC::JSValue *  val 
)
inlinestatic

Definition at line 810 of file qscriptengine_p.h.

Referenced by QScriptValue::call(), QScriptValue::construct(), QScriptValue::equals(), and QScript::ToPrimitive().

811 {
812  if (exec) {
813  *val = exec->exception();
814  exec->clearException();
815  } else {
816  *val = JSC::JSValue();
817  }
818 }

◆ scriptConnect() [1/3]

bool QScriptEnginePrivate::scriptConnect ( QObject sender,
const char *  signal,
JSC::JSValue  receiver,
JSC::JSValue  function,
Qt::ConnectionType  type 
)

Definition at line 1545 of file qscriptengine.cpp.

Referenced by QScript::functionConnect(), QScriptEngine::qScriptConnect(), and scriptConnect().

1548 {
1549  Q_ASSERT(sender);
1550  Q_ASSERT(signal);
1551  const QMetaObject *meta = sender->metaObject();
1552  int index = meta->indexOfSignal(QMetaObject::normalizedSignature(signal+1));
1553  if (index == -1)
1554  return false;
1555  return scriptConnect(sender, index, receiver, function, /*wrapper=*/JSC::JSValue(), type);
1556 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
int type
Definition: qmetatype.cpp:239
static QByteArray normalizedSignature(const char *method)
Normalizes the signature of the given method.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int indexOfSignal(const char *signal) const
Finds signal and returns its index; otherwise returns -1.
quint16 index
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
bool scriptConnect(QObject *sender, const char *signal, JSC::JSValue receiver, JSC::JSValue function, Qt::ConnectionType type)

◆ scriptConnect() [2/3]

bool QScriptEnginePrivate::scriptConnect ( QObject sender,
int  index,
JSC::JSValue  receiver,
JSC::JSValue  function,
JSC::JSValue  senderWrapper,
Qt::ConnectionType  type 
)

Definition at line 1570 of file qscriptengine.cpp.

1574 {
1576  return data->addSignalHandler(sender, signalIndex, receiver, function, senderWrapper, type);
1577 }
int type
Definition: qmetatype.cpp:239
bool addSignalHandler(QObject *sender, int signalIndex, JSC::JSValue receiver, JSC::JSValue slot, JSC::JSValue senderWrapper, Qt::ConnectionType type)
QScript::QObjectData * qobjectData(QObject *object)
static const char * data(const QByteArray &arr)
int signalIndex(const char *signalName) const
Returns the signal index used in the internal connectionLists vector.
Definition: qobject.cpp:3719

◆ scriptConnect() [3/3]

bool QScriptEnginePrivate::scriptConnect ( JSC::JSValue  signal,
JSC::JSValue  receiver,
JSC::JSValue  function,
Qt::ConnectionType  type 
)

Definition at line 1588 of file qscriptengine.cpp.

1590 {
1591  QScript::QtFunction *fun = static_cast<QScript::QtFunction*>(JSC::asObject(signal));
1592  int index = fun->mostGeneralMethod();
1593  return scriptConnect(fun->qobject(), index, receiver, function, fun->wrapperObject(), type);
1594 }
QScriptObject * wrapperObject() const
int type
Definition: qmetatype.cpp:239
QObject * qobject() const
quint16 index
int mostGeneralMethod(QMetaMethod *out=0) const
bool scriptConnect(QObject *sender, const char *signal, JSC::JSValue receiver, JSC::JSValue function, Qt::ConnectionType type)

◆ scriptDisconnect() [1/3]

bool QScriptEnginePrivate::scriptDisconnect ( QObject sender,
const char *  signal,
JSC::JSValue  receiver,
JSC::JSValue  function 
)

Definition at line 1558 of file qscriptengine.cpp.

Referenced by QScript::functionDisconnect(), QScriptEngine::qScriptDisconnect(), and scriptDisconnect().

1560 {
1561  Q_ASSERT(sender);
1562  Q_ASSERT(signal);
1563  const QMetaObject *meta = sender->metaObject();
1564  int index = meta->indexOfSignal(QMetaObject::normalizedSignature(signal+1));
1565  if (index == -1)
1566  return false;
1567  return scriptDisconnect(sender, index, receiver, function);
1568 }
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
static QByteArray normalizedSignature(const char *method)
Normalizes the signature of the given method.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int indexOfSignal(const char *signal) const
Finds signal and returns its index; otherwise returns -1.
bool scriptDisconnect(QObject *sender, const char *signal, JSC::JSValue receiver, JSC::JSValue function)
quint16 index
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ scriptDisconnect() [2/3]

bool QScriptEnginePrivate::scriptDisconnect ( QObject sender,
int  index,
JSC::JSValue  receiver,
JSC::JSValue  function 
)

Definition at line 1579 of file qscriptengine.cpp.

1581 {
1583  if (!data)
1584  return false;
1585  return data->removeSignalHandler(sender, signalIndex, receiver, function);
1586 }
QScript::QObjectData * qobjectData(QObject *object)
bool removeSignalHandler(QObject *sender, int signalIndex, JSC::JSValue receiver, JSC::JSValue slot)
static const char * data(const QByteArray &arr)
int signalIndex(const char *signalName) const
Returns the signal index used in the internal connectionLists vector.
Definition: qobject.cpp:3719

◆ scriptDisconnect() [3/3]

bool QScriptEnginePrivate::scriptDisconnect ( JSC::JSValue  signal,
JSC::JSValue  receiver,
JSC::JSValue  function 
)

Definition at line 1596 of file qscriptengine.cpp.

1598 {
1599  QScript::QtFunction *fun = static_cast<QScript::QtFunction*>(JSC::asObject(signal));
1600  int index = fun->mostGeneralMethod();
1601  return scriptDisconnect(fun->qobject(), index, receiver, function);
1602 }
QObject * qobject() const
bool scriptDisconnect(QObject *sender, const char *signal, JSC::JSValue receiver, JSC::JSValue function)
quint16 index
int mostGeneralMethod(QMetaMethod *out=0) const

◆ scriptValueFromJSCValue()

QScriptValue QScriptEnginePrivate::scriptValueFromJSCValue ( JSC::JSValue  value)
inline

Definition at line 641 of file qscriptengine_p.h.

Referenced by QScriptContext::activationObject(), QScriptContext::argumentsObject(), QScript::ClassObjectDelegate::call(), QScript::DeclarativeObjectDelegate::call(), QScriptContext::callee(), convertValue(), QScript::ClassObjectDelegate::deleteProperty(), QScriptEngineAgentPrivate::evaluateStop(), QScriptEngineAgentPrivate::exceptionCatch(), QScriptEngineAgentPrivate::exceptionThrow(), QScriptDeclarativeClass::function(), QScriptEngineAgentPrivate::functionExit(), QScript::ClassObjectDelegate::getOwnPropertyDescriptor(), QScript::ClassObjectDelegate::getOwnPropertyNames(), QScript::ClassObjectDelegate::getOwnPropertySlot(), QScript::ClassObjectDelegate::hasInstance(), QScriptDeclarativeClass::newObject(), QScriptDeclarativeClass::newStaticScopeObject(), QScriptContext::popScope(), QScriptDeclarativeClass::property(), QScript::ClassObjectDelegate::put(), QScript::DeclarativeObjectDelegate::put(), QScriptContext::scopeChain(), QScriptDeclarativeClass::scopeChainValue(), QScriptContext::thisObject(), QScriptContext::throwError(), QScript::ToPrimitive(), and QScriptDeclarativeClass::Value::toScriptValue().

642 {
643  if (!value)
644  return QScriptValue();
645 
646  QScriptValuePrivate *p_value = new (this)QScriptValuePrivate(this);
647  p_value->initFrom(value);
648  return QScriptValuePrivate::toPublic(p_value);
649 }
static QScriptValue toPublic(QScriptValuePrivate *d)
void initFrom(JSC::JSValue value)
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57

◆ scriptValueToJSCValue()

JSC::JSValue QScriptEnginePrivate::scriptValueToJSCValue ( const QScriptValue value)
inline

Definition at line 651 of file qscriptengine_p.h.

Referenced by QScript::ClassObjectDelegate::construct(), create(), evaluateHelper(), QScript::QMetaObjectWrapperObject::execute(), QScript::GlobalObject::getOwnPropertyDescriptor(), QScript::ClassObjectDelegate::getOwnPropertyDescriptor(), QScript::GlobalObject::getOwnPropertySlot(), QScript::ClassObjectDelegate::getOwnPropertySlot(), QScriptDeclarativeClass::newStaticScopeObject(), QScript::FunctionWrapper::proxyCall(), QScript::FunctionWithArgWrapper::proxyCall(), QScript::FunctionWrapper::proxyConstruct(), QScript::FunctionWithArgWrapper::proxyConstruct(), QScriptContext::pushScope(), QScriptEngine::qScriptConnect(), QScriptEngine::qScriptDisconnect(), QScriptContext::setActivationObject(), QScriptContext::setReturnValue(), QScriptContext::setThisObject(), QScriptValue::strictlyEquals(), QScriptContext::throwValue(), and QScriptDeclarativeClass::Value::Value().

652 {
654  if (!vv)
655  return JSC::JSValue();
657  Q_ASSERT(!vv->engine || vv->engine == this);
658  vv->engine = this;
659  if (vv->type == QScriptValuePrivate::Number) {
660  vv->initFrom(JSC::jsNumber(currentFrame, vv->numberValue));
661  } else { //QScriptValuePrivate::String
662  vv->initFrom(JSC::jsString(currentFrame, vv->stringValue));
663  }
664  }
665  return vv->jscValue;
666 }
static QScriptValuePrivate * get(const QScriptValue &q)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
JSC::ExecState * currentFrame
void initFrom(JSC::JSValue value)
JSC::JSValue jscValue
QScriptEnginePrivate * engine

◆ setContextFlags()

void QScriptEnginePrivate::setContextFlags ( JSC::ExecState *  exec,
uint  flags 
)
static

Definition at line 1268 of file qscriptengine.cpp.

Referenced by QScriptContext::activationObject(), and QScriptContext::setActivationObject().

1269 {
1270  Q_ASSERT(!exec->codeBlock());
1271  exec->registers()[JSC::RegisterFile::ReturnValueRegister] = JSC::Register::withInt(flags);
1272 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ setCurrentException()

void QScriptEnginePrivate::setCurrentException ( QScriptValue  exception)
inline

Definition at line 274 of file qscriptengine_p.h.

Referenced by QScriptEngineAgentPrivate::exceptionThrow().

274 { m_currentException = exception; }
QScriptValue m_currentException

◆ setDefaultPrototype()

void QScriptEnginePrivate::setDefaultPrototype ( int  metaTypeId,
JSC::JSValue  prototype 
)

Definition at line 1151 of file qscriptengine.cpp.

1152 {
1153  QScriptTypeInfo *info = m_typeInfos.value(metaTypeId);
1154  if (!info) {
1155  info = new QScriptTypeInfo();
1156  m_typeInfos.insert(metaTypeId, info);
1157  }
1158  info->prototype = prototype;
1159 }
static mach_timebase_info_data_t info
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
JSC::JSValue prototype
QHash< int, QScriptTypeInfo * > m_typeInfos
static QByteArray prototype(const QList< QByteArray > &parameterTypes, const QList< QByteArray > &parameterNames, bool *ok)
Definition: qaxserver.cpp:685

◆ setGlobalObject()

void QScriptEnginePrivate::setGlobalObject ( JSC::JSObject *  object)

Definition at line 1189 of file qscriptengine.cpp.

1190 {
1191  if (object == globalObject())
1192  return;
1194  if (object == originalGlobalObjectProxy) {
1195  glob->customGlobalObject = 0;
1196  // Sync the internal prototype, since JSObject::prototype() is not virtual.
1197  glob->setPrototype(originalGlobalObjectProxy->prototype());
1198  } else {
1199  Q_ASSERT(object != originalGlobalObject());
1200  glob->customGlobalObject = object;
1201  // Sync the internal prototype, since JSObject::prototype() is not virtual.
1202  glob->setPrototype(object->prototype());
1203  }
1204 }
JSC::JSObject * globalObject() const
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
JSC::JSGlobalObject * originalGlobalObject() const
JSC::JSObject * customGlobalObject
JSC::JSObject * originalGlobalObjectProxy

◆ setProperty() [1/3]

void QScriptEnginePrivate::setProperty ( JSC::ExecState *  exec,
JSC::JSValue  object,
const JSC::UString &  name,
JSC::JSValue  value,
const QScriptValue::PropertyFlags flags = QScriptValue::KeepExistingFlags 
)
inlinestatic

Definition at line 747 of file qscriptengine_p.h.

Referenced by arrayFromStringList(), arrayFromVariantList(), objectFromVariantMap(), QScriptValuePrivate::setProperty(), and setProperty().

749 {
750  setProperty(exec, objectValue, JSC::Identifier(exec, name), value, flags);
751 }
const char * name
static void setProperty(JSC::ExecState *, JSC::JSValue object, const JSC::UString &name, JSC::JSValue, const QScriptValue::PropertyFlags &flags=QScriptValue::KeepExistingFlags)

◆ setProperty() [2/3]

void QScriptEnginePrivate::setProperty ( JSC::ExecState *  exec,
JSC::JSValue  object,
const JSC::Identifier &  id,
JSC::JSValue  value,
const QScriptValue::PropertyFlags flags = QScriptValue::KeepExistingFlags 
)
static

Definition at line 1826 of file qscriptengine.cpp.

1828 {
1829  JSC::JSObject *thisObject = JSC::asObject(objectValue);
1830  JSC::JSValue setter = thisObject->lookupSetter(exec, id);
1831  JSC::JSValue getter = thisObject->lookupGetter(exec, id);
1832  if ((flags & QScriptValue::PropertyGetter) || (flags & QScriptValue::PropertySetter)) {
1833  if (!value) {
1834  // deleting getter/setter
1835  if ((flags & QScriptValue::PropertyGetter) && (flags & QScriptValue::PropertySetter)) {
1836  // deleting both: just delete the property
1837  thisObject->deleteProperty(exec, id);
1838  } else if (flags & QScriptValue::PropertyGetter) {
1839  // preserve setter, if there is one
1840  thisObject->deleteProperty(exec, id);
1841  if (setter && setter.isObject())
1842  thisObject->defineSetter(exec, id, JSC::asObject(setter));
1843  } else { // flags & QScriptValue::PropertySetter
1844  // preserve getter, if there is one
1845  thisObject->deleteProperty(exec, id);
1846  if (getter && getter.isObject())
1847  thisObject->defineGetter(exec, id, JSC::asObject(getter));
1848  }
1849  } else {
1850  if (value.isObject()) { // ### should check if it has callData()
1851  // defining getter/setter
1852  if (id == exec->propertyNames().underscoreProto) {
1853  qWarning("QScriptValue::setProperty() failed: "
1854  "cannot set getter or setter of native property `__proto__'");
1855  } else {
1856  if (flags & QScriptValue::PropertyGetter)
1857  thisObject->defineGetter(exec, id, JSC::asObject(value));
1858  if (flags & QScriptValue::PropertySetter)
1859  thisObject->defineSetter(exec, id, JSC::asObject(value));
1860  }
1861  } else {
1862  qWarning("QScriptValue::setProperty(): getter/setter must be a function");
1863  }
1864  }
1865  } else {
1866  // setting the value
1867  if (getter && getter.isObject() && !(setter && setter.isObject())) {
1868  qWarning("QScriptValue::setProperty() failed: "
1869  "property '%s' has a getter but no setter",
1870  qPrintable(QString(id.ustring())));
1871  return;
1872  }
1873  if (!value) {
1874  // ### check if it's a getter/setter property
1875  thisObject->deleteProperty(exec, id);
1876  } else if (flags != QScriptValue::KeepExistingFlags) {
1877  if (thisObject->hasOwnProperty(exec, id))
1878  thisObject->deleteProperty(exec, id); // ### hmmm - can't we just update the attributes?
1879  thisObject->putWithAttributes(exec, id, value, propertyFlagsToJSCAttributes(flags));
1880  } else {
1881  JSC::PutPropertySlot slot;
1882  thisObject->put(exec, id, value, slot);
1883  }
1884  }
1885 }
static unsigned propertyFlagsToJSCAttributes(const QScriptValue::PropertyFlags &flags)
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_CORE_EXPORT void qWarning(const char *,...)
#define qPrintable(string)
Definition: qglobal.h:1750

◆ setProperty() [3/3]

void QScriptEnginePrivate::setProperty ( JSC::ExecState *  exec,
JSC::JSValue  object,
quint32  index,
JSC::JSValue  value,
const QScriptValue::PropertyFlags flags = QScriptValue::KeepExistingFlags 
)
static

Definition at line 1887 of file qscriptengine.cpp.

1889 {
1890  if (!value) {
1891  JSC::asObject(objectValue)->deleteProperty(exec, index);
1892  } else {
1893  if ((flags & QScriptValue::PropertyGetter) || (flags & QScriptValue::PropertySetter)) {
1894  // fall back to string-based setProperty(), since there is no
1895  // JSC::JSObject::defineGetter(unsigned)
1896  setProperty(exec, objectValue, JSC::Identifier::from(exec, index), value, flags);
1897  } else {
1898  if (flags != QScriptValue::KeepExistingFlags) {
1899  // if (JSC::asObject(d->jscValue)->hasOwnProperty(exec, arrayIndex))
1900  // JSC::asObject(d->jscValue)->deleteProperty(exec, arrayIndex);
1901  unsigned attribs = 0;
1902  if (flags & QScriptValue::ReadOnly)
1903  attribs |= JSC::ReadOnly;
1904  if (flags & QScriptValue::SkipInEnumeration)
1905  attribs |= JSC::DontEnum;
1906  if (flags & QScriptValue::Undeletable)
1907  attribs |= JSC::DontDelete;
1908  attribs |= flags & QScriptValue::UserRange;
1909  JSC::asObject(objectValue)->putWithAttributes(exec, index, value, attribs);
1910  } else {
1911  JSC::asObject(objectValue)->put(exec, index, value);
1912  }
1913  }
1914  }
1915 }
static void setProperty(JSC::ExecState *, JSC::JSValue object, const JSC::UString &name, JSC::JSValue, const QScriptValue::PropertyFlags &flags=QScriptValue::KeepExistingFlags)
quint16 index

◆ setVariantValue()

void QScriptEnginePrivate::setVariantValue ( JSC::JSValue  objectValue,
const QVariant value 
)
inlinestatic

Definition at line 1089 of file qscriptengine_p.h.

Referenced by newVariant().

1090 {
1091  Q_ASSERT(objectValue.inherits(&QScriptObject::info));
1092  QScriptObjectDelegate *delegate = static_cast<QScriptObject*>(JSC::asObject(objectValue))->delegate();
1093  Q_ASSERT(delegate && (delegate->type() == QScriptObjectDelegate::Variant));
1094  static_cast<QScript::QVariantDelegate*>(delegate)->setValue(value);
1095 }
static const JSC::ClassInfo info
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ stringListFromArray()

QStringList QScriptEnginePrivate::stringListFromArray ( JSC::ExecState *  exec,
JSC::JSValue  arr 
)
static

Definition at line 1087 of file qscriptengine.cpp.

1088 {
1089  QStringList lst;
1090  uint len = toUInt32(exec, property(exec, arr, exec->propertyNames().length));
1091  for (uint i = 0; i < len; ++i)
1092  lst.append(toString(exec, property(exec, arr, i)));
1093  return lst;
1094 }
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
static JSC::UString toString(JSC::ExecState *, JSC::JSValue)
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
unsigned int uint
Definition: qglobal.h:996
static JSC::JSValue property(JSC::ExecState *, JSC::JSValue, const JSC::Identifier &id, int resolveMode=QScriptValue::ResolvePrototype)
static quint32 toUInt32(JSC::ExecState *, JSC::JSValue)

◆ thisForContext()

JSC::JSValue QScriptEnginePrivate::thisForContext ( JSC::ExecState *  frame)
static
Warning
This function is not part of the public interface. Return the 'this' value for a given context

Definition at line 1231 of file qscriptengine.cpp.

Referenced by evaluateHelper(), and QScriptContext::thisObject().

1232 {
1233  if (frame->codeBlock() != 0) {
1234  return frame->thisValue();
1235  } else if(frame == frame->lexicalGlobalObject()->globalExec()) {
1236  return frame->globalThisValue();
1237  } else {
1238  JSC::Register *thisRegister = thisRegisterForFrame(frame);
1239  return thisRegister->jsValue();
1240  }
1241 }
static JSC::Register * thisRegisterForFrame(JSC::ExecState *frame)

◆ thisRegisterForFrame()

JSC::Register * QScriptEnginePrivate::thisRegisterForFrame ( JSC::ExecState *  frame)
static

Definition at line 1243 of file qscriptengine.cpp.

Referenced by QScriptContext::setThisObject(), and thisForContext().

1244 {
1245  Q_ASSERT(frame->codeBlock() == 0); // only for native calls
1246  return frame->registers() - JSC::RegisterFile::CallFrameHeaderSize - frame->argumentCount();
1247 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ timeoutChecker()

QScript::TimeoutCheckerProxy * QScriptEnginePrivate::timeoutChecker ( ) const

Definition at line 1354 of file qscriptengine.cpp.

Referenced by evaluateHelper().

1355 {
1356  return static_cast<QScript::TimeoutCheckerProxy*>(globalData->timeoutChecker);
1357 }
JSC::JSGlobalData * globalData

◆ toBool()

bool QScriptEnginePrivate::toBool ( JSC::ExecState *  exec,
JSC::JSValue  value 
)
inlinestatic

Definition at line 969 of file qscriptengine_p.h.

Referenced by QScriptValue::toBool(), QScriptValue::toBoolean(), toRegExp(), and toVariant().

970 {
971  JSC::JSValue savedException;
972  saveException(exec, &savedException);
973  bool result = value.toBoolean(exec);
974  restoreException(exec, savedException);
975  return result;
976 }
static void restoreException(JSC::ExecState *, JSC::JSValue)
static void saveException(JSC::ExecState *, JSC::JSValue *)

◆ toDateTime()

QDateTime QScriptEnginePrivate::toDateTime ( JSC::ExecState *  exec,
JSC::JSValue  value 
)
inlinestatic

Definition at line 1038 of file qscriptengine_p.h.

Referenced by QScriptValue::toDateTime(), and toVariant().

1039 {
1040  if (!isDate(value))
1041  return QDateTime();
1042  qsreal t = static_cast<JSC::DateInstance*>(JSC::asObject(value))->internalNumber();
1043  return QScript::MsToDateTime(exec, t);
1044 }
static bool isDate(JSC::JSValue)
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
double qsreal
Definition: qscriptvalue.h:52
QDateTime MsToDateTime(JSC::ExecState *exec, qsreal t)
Converts a JS date value (milliseconds) to a QDateTime (local time).

◆ toInt32()

qint32 QScriptEnginePrivate::toInt32 ( JSC::ExecState *  exec,
JSC::JSValue  value 
)
inlinestatic

Definition at line 996 of file qscriptengine_p.h.

Referenced by QScript::callQtMethod(), QScriptValue::toInt32(), and toVariant().

997 {
998  JSC::JSValue savedException;
999  saveException(exec, &savedException);
1000  qint32 result = value.toInt32(exec);
1001  restoreException(exec, savedException);
1002  return result;
1003 }
int qint32
Definition: qglobal.h:937
static void restoreException(JSC::ExecState *, JSC::JSValue)
static void saveException(JSC::ExecState *, JSC::JSValue *)

◆ toInteger()

qsreal QScriptEnginePrivate::toInteger ( JSC::ExecState *  exec,
JSC::JSValue  value 
)
inlinestatic

Definition at line 978 of file qscriptengine_p.h.

Referenced by QScriptValue::toInteger().

979 {
980  JSC::JSValue savedException;
981  saveException(exec, &savedException);
982  qsreal result = value.toInteger(exec);
983  restoreException(exec, savedException);
984  return result;
985 }
static void restoreException(JSC::ExecState *, JSC::JSValue)
static void saveException(JSC::ExecState *, JSC::JSValue *)
double qsreal
Definition: qscriptvalue.h:52

◆ toNumber()

qsreal QScriptEnginePrivate::toNumber ( JSC::ExecState *  exec,
JSC::JSValue  value 
)
inlinestatic

Definition at line 987 of file qscriptengine_p.h.

Referenced by QScriptValue::toNumber(), and toVariant().

988 {
989  JSC::JSValue savedException;
990  saveException(exec, &savedException);
991  qsreal result = value.toNumber(exec);
992  restoreException(exec, savedException);
993  return result;
994 }
static void restoreException(JSC::ExecState *, JSC::JSValue)
static void saveException(JSC::ExecState *, JSC::JSValue *)
double qsreal
Definition: qscriptvalue.h:52

◆ toQMetaObject()

const QMetaObject * QScriptEnginePrivate::toQMetaObject ( JSC::ExecState *  ,
JSC::JSValue  value 
)
inlinestatic

Definition at line 1072 of file qscriptengine_p.h.

Referenced by QScriptValue::toQMetaObject().

1073 {
1074 #ifndef QT_NO_QOBJECT
1075  if (isQMetaObject(value))
1076  return static_cast<QScript::QMetaObjectWrapperObject*>(JSC::asObject(value))->value();
1077 #endif
1078  return 0;
1079 }
static bool isQMetaObject(JSC::JSValue)

◆ toQObject()

QObject * QScriptEnginePrivate::toQObject ( JSC::ExecState *  exec,
JSC::JSValue  value 
)
inlinestatic

Definition at line 1046 of file qscriptengine_p.h.

Referenced by convertToNativeQObject(), QScript::QtPropertyFunction::execute(), QScriptValue::toQObject(), and toVariant().

1047 {
1048 #ifndef QT_NO_QOBJECT
1049  if (isObject(value) && value.inherits(&QScriptObject::info)) {
1050  QScriptObject *object = static_cast<QScriptObject*>(JSC::asObject(value));
1051  QScriptObjectDelegate *delegate = object->delegate();
1052  if (!delegate)
1053  return 0;
1054  if (delegate->type() == QScriptObjectDelegate::QtObject)
1055  return static_cast<QScript::QObjectDelegate*>(delegate)->value();
1057  return static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->scriptClass()->toQObject(declarativeObject(value));
1058  if (delegate->type() == QScriptObjectDelegate::Variant) {
1059  QVariant var = variantValue(value);
1060  int type = var.userType();
1061  if ((type == QMetaType::QObjectStar) || (type == QMetaType::QWidgetStar))
1062  return *reinterpret_cast<QObject* const *>(var.constData());
1063  }
1064  } else if (isObject(value) && value.inherits(&QScript::QScriptActivationObject::info)) {
1065  QScript::QScriptActivationObject *proxy = static_cast<QScript::QScriptActivationObject *>(JSC::asObject(value));
1066  return toQObject(exec, proxy->delegate());
1067  }
1068 #endif
1069  return 0;
1070 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static bool isObject(JSC::JSValue)
int type
Definition: qmetatype.cpp:239
virtual Type type() const =0
static QObject * toQObject(JSC::ExecState *, JSC::JSValue)
static const JSC::ClassInfo info
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
const void * constData() const
Definition: qvariant.cpp:3065
static QScriptDeclarativeClass::Object * declarativeObject(JSC::JSValue)
static QVariant & variantValue(JSC::JSValue value)
Represent a scope for native function call.

◆ toRegExp()

QRegExp QScriptEnginePrivate::toRegExp ( JSC::ExecState *  exec,
JSC::JSValue  value 
)
static

Definition at line 1747 of file qscriptengine.cpp.

Referenced by QScriptValue::toRegExp(), and toVariant().

1748 {
1749  if (!isRegExp(value))
1750  return QRegExp();
1751  QString pattern = toString(exec, property(exec, value, "source", QScriptValue::ResolvePrototype));
1753  if (toBool(exec, property(exec, value, "ignoreCase", QScriptValue::ResolvePrototype)))
1754  kase = Qt::CaseInsensitive;
1755  return QRegExp(pattern, kase, QRegExp::RegExp2);
1756 }
The QRegExp class provides pattern matching using regular expressions.
Definition: qregexp.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
static JSC::UString toString(JSC::ExecState *, JSC::JSValue)
CaseSensitivity
Definition: qnamespace.h:1451
static bool isRegExp(JSC::JSValue)
static JSC::JSValue property(JSC::ExecState *, JSC::JSValue, const JSC::Identifier &id, int resolveMode=QScriptValue::ResolvePrototype)
static bool toBool(JSC::ExecState *, JSC::JSValue)

◆ toString()

JSC::UString QScriptEnginePrivate::toString ( JSC::ExecState *  exec,
JSC::JSValue  value 
)
inlinestatic

Definition at line 1020 of file qscriptengine_p.h.

Referenced by QScript::callQtMethod(), QScript::functionConnect(), QScript::functionDisconnect(), stringListFromArray(), toRegExp(), QScriptValue::toString(), and toVariant().

1021 {
1022  if (!value)
1023  return JSC::UString();
1024  JSC::JSValue savedException;
1025  saveException(exec, &savedException);
1026  JSC::UString str = value.toString(exec);
1027  if (exec && exec->hadException() && !str.size()) {
1028  JSC::JSValue savedException2;
1029  saveException(exec, &savedException2);
1030  str = savedException2.toString(exec);
1031  restoreException(exec, savedException2);
1032  }
1033  if (savedException)
1034  restoreException(exec, savedException);
1035  return str;
1036 }
static void restoreException(JSC::ExecState *, JSC::JSValue)
static void saveException(JSC::ExecState *, JSC::JSValue *)

◆ toStringHandle()

QScriptString QScriptEnginePrivate::toStringHandle ( const JSC::Identifier &  name)

Definition at line 1952 of file qscriptengine.cpp.

1953 {
1954  QScriptString result;
1956  QScriptStringPrivate::init(result, p);
1958  return result;
1959 }
static void init(QScriptString &q, QScriptStringPrivate *d)
The QScriptString class acts as a handle to "interned" strings in a QScriptEngine.
Definition: qscriptstring.h:38
const char * name
void registerScriptString(QScriptStringPrivate *value)

◆ toUInt16()

quint16 QScriptEnginePrivate::toUInt16 ( JSC::ExecState *  exec,
JSC::JSValue  value 
)
inlinestatic

Definition at line 1014 of file qscriptengine_p.h.

Referenced by QScriptValue::toUInt16().

1015 {
1016  // ### no equivalent function in JSC
1017  return QScript::ToUInt16(toNumber(exec, value));
1018 }
static qsreal toNumber(JSC::ExecState *, JSC::JSValue)
quint16 ToUInt16(qsreal n)

◆ toUInt32()

quint32 QScriptEnginePrivate::toUInt32 ( JSC::ExecState *  exec,
JSC::JSValue  value 
)
inlinestatic

Definition at line 1005 of file qscriptengine_p.h.

Referenced by stringListFromArray(), QScriptValue::toUInt32(), and variantListFromArray().

1006 {
1007  JSC::JSValue savedException;
1008  saveException(exec, &savedException);
1009  quint32 result = value.toUInt32(exec);
1010  restoreException(exec, savedException);
1011  return result;
1012 }
static void restoreException(JSC::ExecState *, JSC::JSValue)
static void saveException(JSC::ExecState *, JSC::JSValue *)
unsigned int quint32
Definition: qglobal.h:938

◆ toUsableValue()

JSC::JSValue QScriptEnginePrivate::toUsableValue ( JSC::JSValue  value)

If the given value is the original global object, returns the custom global object or a proxy to the original global object; otherwise returns value.

Warning
This function is not part of the public interface.

Definition at line 1216 of file qscriptengine.cpp.

Referenced by QScript::QMetaObjectWrapperObject::call(), QScript::QtFunction::execute(), QScript::QtPropertyFunction::execute(), QScript::qmetaobjectProtoFuncClassName(), QScript::qobjectProtoFuncFindChild(), QScript::qobjectProtoFuncFindChildren(), QScript::qobjectProtoFuncToString(), QScript::variantProtoFuncToString(), and QScript::variantProtoFuncValueOf().

1217 {
1218  if (!value || !value.isObject() || !JSC::asObject(value)->isGlobalObject())
1219  return value;
1220  Q_ASSERT(JSC::asObject(value) == originalGlobalObject());
1221  if (customGlobalObject())
1222  return customGlobalObject();
1226 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
JSC::ExecState * currentFrame
JSC::JSGlobalObject * originalGlobalObject() const
WTF::RefPtr< JSC::Structure > scriptObjectStructure
JSC::JSObject * customGlobalObject() const
JSC::JSObject * originalGlobalObjectProxy

◆ toVariant()

QVariant QScriptEnginePrivate::toVariant ( JSC::ExecState *  exec,
JSC::JSValue  value 
)
static

Definition at line 1760 of file qscriptengine.cpp.

Referenced by QScript::callQtMethod(), QScript::QVariantDelegate::compareToObject(), jscValueToVariant(), QScriptValue::toVariant(), QScript::variantFromValue(), variantListFromArray(), and variantMapFromObject().

1761 {
1762  if (!value) {
1763  return QVariant();
1764  } else if (isObject(value)) {
1765  if (isVariant(value))
1766  return variantValue(value);
1767 #ifndef QT_NO_QOBJECT
1768  else if (isQObject(value))
1769  return QVariant::fromValue(toQObject(exec, value));
1770 #endif
1771  else if (isDate(value))
1772  return QVariant(toDateTime(exec, value));
1773 #ifndef QT_NO_REGEXP
1774  else if (isRegExp(value))
1775  return QVariant(toRegExp(exec, value));
1776 #endif
1777  else if (isArray(value))
1778  return variantListFromArray(exec, JSC::asArray(value));
1779  else if (QScriptDeclarativeClass *dc = declarativeClass(value))
1780  return dc->toVariant(declarativeObject(value));
1781  return variantMapFromObject(exec, JSC::asObject(value));
1782  } else if (value.isInt32()) {
1783  return QVariant(toInt32(exec, value));
1784  } else if (value.isDouble()) {
1785  return QVariant(toNumber(exec, value));
1786  } else if (value.isString()) {
1787  return QVariant(toString(exec, value));
1788  } else if (value.isBoolean()) {
1789  return QVariant(toBool(exec, value));
1790  }
1791  return QVariant();
1792 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
static bool isObject(JSC::JSValue)
static QVariantMap variantMapFromObject(JSC::ExecState *, JSC::JSObject *obj)
static QRegExp toRegExp(JSC::ExecState *, JSC::JSValue)
static QObject * toQObject(JSC::ExecState *, JSC::JSValue)
static QScriptDeclarativeClass * declarativeClass(JSC::JSValue)
static qsreal toNumber(JSC::ExecState *, JSC::JSValue)
static bool isVariant(JSC::JSValue)
static qint32 toInt32(JSC::ExecState *, JSC::JSValue)
static JSC::UString toString(JSC::ExecState *, JSC::JSValue)
static QDateTime toDateTime(JSC::ExecState *, JSC::JSValue)
static QVariant fromValue(const T &value)
Returns a QVariant containing a copy of value.
Definition: qvariant.h:336
static bool isDate(JSC::JSValue)
static QVariantList variantListFromArray(JSC::ExecState *, JSC::JSArray *arr)
static bool isRegExp(JSC::JSValue)
static bool isQObject(JSC::JSValue)
static QScriptDeclarativeClass::Object * declarativeObject(JSC::JSValue)
static QVariant & variantValue(JSC::JSValue value)
static bool toBool(JSC::ExecState *, JSC::JSValue)
static bool isArray(JSC::JSValue)

◆ translationContextFromUrl()

JSC::UString QScriptEnginePrivate::translationContextFromUrl ( const JSC::UString &  url)

Definition at line 3449 of file qscriptengine.cpp.

Referenced by QScript::functionQsTr().

3450 {
3451  if (url != cachedTranslationUrl) {
3453  cachedTranslationUrl = url;
3454  }
3455  return cachedTranslationContext;
3456 }
JSC::UString cachedTranslationContext
QString baseName() const
Returns the base name of the file without the path.
Definition: qfileinfo.cpp:773
JSC::UString cachedTranslationUrl
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:60

◆ unregisterScriptProgram()

void QScriptEnginePrivate::unregisterScriptProgram ( QScriptProgramPrivate program)
inline

Definition at line 585 of file qscriptengine_p.h.

Referenced by QScriptProgramPrivate::executable(), and QScriptProgramPrivate::~QScriptProgramPrivate().

586 {
589 }
bool remove(const T &value)
Definition: qset.h:89
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool contains(const T &value) const
Definition: qset.h:91
QSet< QScriptProgramPrivate * > registeredScriptPrograms

◆ unregisterScriptString()

void QScriptEnginePrivate::unregisterScriptString ( QScriptStringPrivate value)
inline

Definition at line 836 of file qscriptengine_p.h.

837 {
839  if (value->prev)
840  value->prev->next = value->next;
841  if (value->next)
842  value->next->prev = value->prev;
843  if (value == registeredScriptStrings)
844  registeredScriptStrings = value->next;
845  value->prev = 0;
846  value->next = 0;
847 }
AllocationType type
QScriptStringPrivate * prev
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QScriptStringPrivate * next
QScriptStringPrivate * registeredScriptStrings

◆ unregisterScriptValue()

void QScriptEnginePrivate::unregisterScriptValue ( QScriptValuePrivate value)
inline

Definition at line 622 of file qscriptengine_p.h.

623 {
624  if (value->prev)
625  value->prev->next = value->next;
626  if (value->next)
627  value->next->prev = value->prev;
628  if (value == registeredScriptValues)
629  registeredScriptValues = value->next;
630  value->prev = 0;
631  value->next = 0;
632 }
QScriptValuePrivate * next
QScriptValuePrivate * prev
QScriptValuePrivate * registeredScriptValues

◆ variantListFromArray()

QVariantList QScriptEnginePrivate::variantListFromArray ( JSC::ExecState *  exec,
JSC::JSArray *  arr 
)
static

Definition at line 1104 of file qscriptengine.cpp.

Referenced by toVariant().

1105 {
1107  if (eng->visitedConversionObjects.contains(arr))
1108  return QVariantList(); // Avoid recursion.
1109  eng->visitedConversionObjects.insert(arr);
1110  QVariantList lst;
1111  uint len = toUInt32(exec, property(exec, arr, exec->propertyNames().length));
1112  for (uint i = 0; i < len; ++i)
1113  lst.append(toVariant(exec, property(exec, arr, i)));
1114  eng->visitedConversionObjects.remove(arr);
1115  return lst;
1116 }
QScriptEnginePrivate * scriptEngineFromExec(const JSC::ExecState *exec)
static QVariant toVariant(JSC::ExecState *, JSC::JSValue)
bool remove(const T &value)
Definition: qset.h:89
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
bool contains(const T &value) const
Definition: qset.h:91
const_iterator insert(const T &value)
Definition: qset.h:179
unsigned int uint
Definition: qglobal.h:996
static JSC::JSValue property(JSC::ExecState *, JSC::JSValue, const JSC::Identifier &id, int resolveMode=QScriptValue::ResolvePrototype)
static quint32 toUInt32(JSC::ExecState *, JSC::JSValue)
QList< QVariant > QVariantList
Definition: qvariant.h:443
QSet< JSC::JSObject * > visitedConversionObjects

◆ variantMapFromObject()

QVariantMap QScriptEnginePrivate::variantMapFromObject ( JSC::ExecState *  exec,
JSC::JSObject *  obj 
)
static

Definition at line 1127 of file qscriptengine.cpp.

Referenced by toVariant().

1128 {
1130  if (eng->visitedConversionObjects.contains(obj))
1131  return QVariantMap(); // Avoid recursion.
1132  eng->visitedConversionObjects.insert(obj);
1133  JSC::PropertyNameArray propertyNames(exec);
1134  obj->getOwnPropertyNames(exec, propertyNames, JSC::IncludeDontEnumProperties);
1135  QVariantMap vmap;
1136  JSC::PropertyNameArray::const_iterator it = propertyNames.begin();
1137  for( ; it != propertyNames.end(); ++it)
1138  vmap.insert(it->ustring(), toVariant(exec, property(exec, obj, *it)));
1139  eng->visitedConversionObjects.remove(obj);
1140  return vmap;
1141 }
QScriptEnginePrivate * scriptEngineFromExec(const JSC::ExecState *exec)
#define it(className, varName)
static QVariant toVariant(JSC::ExecState *, JSC::JSValue)
bool remove(const T &value)
Definition: qset.h:89
QMap< QString, QVariant > QVariantMap
Definition: qvariant.h:444
bool contains(const T &value) const
Definition: qset.h:91
const_iterator insert(const T &value)
Definition: qset.h:179
static JSC::JSValue property(JSC::ExecState *, JSC::JSValue, const JSC::Identifier &id, int resolveMode=QScriptValue::ResolvePrototype)
iterator insert(const Key &key, const T &value)
Inserts a new item with the key key and a value of value.
Definition: qmap.h:559
QSet< JSC::JSObject * > visitedConversionObjects

◆ variantValue()

QVariant & QScriptEnginePrivate::variantValue ( JSC::JSValue  value)
inlinestatic

Definition at line 1081 of file qscriptengine_p.h.

Referenced by QScript::callQtMethod(), jscValueToVariant(), toVariant(), and QScript::variantFromValue().

1082 {
1083  Q_ASSERT(value.inherits(&QScriptObject::info));
1084  QScriptObjectDelegate *delegate = static_cast<QScriptObject*>(JSC::asObject(value))->delegate();
1085  Q_ASSERT(delegate && (delegate->type() == QScriptObjectDelegate::Variant));
1086  return static_cast<QScript::QVariantDelegate*>(delegate)->value();
1087 }
static const JSC::ClassInfo info
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

Properties

◆ abortResult

QScriptValue QScriptEnginePrivate::abortResult

Definition at line 383 of file qscriptengine_p.h.

Referenced by evaluateHelper().

◆ activeAgent

QScriptEngineAgent* QScriptEnginePrivate::activeAgent

Definition at line 373 of file qscriptengine_p.h.

Referenced by agentDeleted().

◆ agentLineNumber

int QScriptEnginePrivate::agentLineNumber

◆ cachedTranslationContext

JSC::UString QScriptEnginePrivate::cachedTranslationContext

Definition at line 387 of file qscriptengine_p.h.

Referenced by QScriptEnginePrivate().

◆ cachedTranslationUrl

JSC::UString QScriptEnginePrivate::cachedTranslationUrl

Definition at line 386 of file qscriptengine_p.h.

Referenced by QScriptEnginePrivate().

◆ currentFrame

JSC::ExecState* QScriptEnginePrivate::currentFrame

Definition at line 358 of file qscriptengine_p.h.

Referenced by QScriptEngineAgentPrivate::atStatement(), QScript::ClassObjectDelegate::call(), QScript::DeclarativeObjectDelegate::call(), QScript::QtFunction::call(), QScript::QMetaObjectWrapperObject::call(), QScript::ClassObjectDelegate::construct(), QScript::QMetaObjectWrapperObject::construct(), QScriptEngine::convertV2(), QScriptDeclarativeClass::createPersistentIdentifier(), QScriptEngineAgentPrivate::didReachBreakpoint(), QScriptValue::equals(), QScriptEngineAgentPrivate::exceptionCatch(), QScriptEngineAgentPrivate::exceptionThrow(), QScript::QtPropertyFunction::execute(), QScriptDeclarativeClass::function(), QScriptDeclarativeClass::functionValue(), getOriginalGlobalObjectProxy(), QScript::GlobalObject::getOwnPropertyDescriptor(), QScript::GlobalObject::getOwnPropertySlot(), QScriptDeclarativeClass::newObject(), QScriptDeclarativeClass::newObjectValue(), newQMetaObject(), newQObject(), QScriptDeclarativeClass::newStaticScopeObject(), newVariant(), QScriptDeclarativeClass::property(), QScriptDeclarativeClass::propertyValue(), QScript::FunctionWrapper::proxyCall(), QScript::FunctionWithArgWrapper::proxyCall(), QScript::FunctionWrapper::proxyConstruct(), QScript::FunctionWithArgWrapper::proxyConstruct(), QScriptDeclarativeClass::pushCleanContext(), QScriptEnginePrivate(), QScriptValue::QScriptValue(), QScript::SaveFrameHelper::SaveFrameHelper(), QScriptValue::strictlyEquals(), QScript::ToPrimitive(), toUsableValue(), and QScriptDeclarativeClass::Value::Value().

◆ extensionsBeingImported

QSet<QString> QScriptEnginePrivate::extensionsBeingImported

Definition at line 390 of file qscriptengine_p.h.

◆ freeScriptValues

QScriptValuePrivate* QScriptEnginePrivate::freeScriptValues

Definition at line 376 of file qscriptengine_p.h.

Referenced by ~QScriptEnginePrivate().

◆ freeScriptValuesCount

int QScriptEnginePrivate::freeScriptValuesCount

Definition at line 378 of file qscriptengine_p.h.

◆ globalData

JSC::JSGlobalData* QScriptEnginePrivate::globalData

◆ importedExtensions

QSet<QString> QScriptEnginePrivate::importedExtensions

Definition at line 389 of file qscriptengine_p.h.

◆ inEval

bool QScriptEnginePrivate::inEval

Definition at line 384 of file qscriptengine_p.h.

Referenced by evaluateHelper().

◆ loadedScripts

QHash<intptr_t, QScript::UStringSourceProviderWithFeedback*> QScriptEnginePrivate::loadedScripts

◆ m_currentException

QScriptValue QScriptEnginePrivate::m_currentException

Definition at line 393 of file qscriptengine_p.h.

◆ m_qobjectData

QHash<QObject*, QScript::QObjectData*> QScriptEnginePrivate::m_qobjectData

Definition at line 398 of file qscriptengine_p.h.

Referenced by _q_objectDestroyed(), mark(), qobjectData(), and ~QScriptEnginePrivate().

◆ m_typeInfos

QHash<int, QScriptTypeInfo*> QScriptEnginePrivate::m_typeInfos

◆ maxFreeScriptValues

const int QScriptEnginePrivate::maxFreeScriptValues = 256
static

Definition at line 377 of file qscriptengine_p.h.

◆ originalGlobalObjectProxy

JSC::JSObject* QScriptEnginePrivate::originalGlobalObjectProxy

◆ ownedAgents

QList<QScriptEngineAgent*> QScriptEnginePrivate::ownedAgents

◆ processEventsInterval

int QScriptEnginePrivate::processEventsInterval

Definition at line 382 of file qscriptengine_p.h.

Referenced by evaluateHelper().

◆ qmetaobjectPrototype

QScript::QMetaObjectPrototype* QScriptEnginePrivate::qmetaobjectPrototype

Definition at line 366 of file qscriptengine_p.h.

Referenced by mark(), and QScriptEnginePrivate().

◆ qmetaobjectWrapperObjectStructure

WTF::RefPtr<JSC::Structure> QScriptEnginePrivate::qmetaobjectWrapperObjectStructure

Definition at line 367 of file qscriptengine_p.h.

Referenced by newQMetaObject(), and QScriptEnginePrivate().

◆ qobjectPrototype

QScript::QObjectPrototype* QScriptEnginePrivate::qobjectPrototype

Definition at line 363 of file qscriptengine_p.h.

Referenced by mark(), and QScriptEnginePrivate().

◆ qobjectWrapperObjectStructure

WTF::RefPtr<JSC::Structure> QScriptEnginePrivate::qobjectWrapperObjectStructure

Definition at line 364 of file qscriptengine_p.h.

Referenced by newQObject(), and QScriptEnginePrivate().

◆ registeredScriptPrograms

QSet<QScriptProgramPrivate*> QScriptEnginePrivate::registeredScriptPrograms

Definition at line 380 of file qscriptengine_p.h.

Referenced by detachAllRegisteredScriptPrograms().

◆ registeredScriptStrings

QScriptStringPrivate* QScriptEnginePrivate::registeredScriptStrings

Definition at line 379 of file qscriptengine_p.h.

Referenced by detachAllRegisteredScriptStrings().

◆ registeredScriptValues

QScriptValuePrivate* QScriptEnginePrivate::registeredScriptValues

Definition at line 375 of file qscriptengine_p.h.

Referenced by detachAllRegisteredScriptValues(), and mark().

◆ scriptObjectStructure

WTF::RefPtr<JSC::Structure> QScriptEnginePrivate::scriptObjectStructure

◆ staticScopeObjectStructure

WTF::RefPtr<JSC::Structure> QScriptEnginePrivate::staticScopeObjectStructure

◆ variantPrototype

QScript::QVariantPrototype* QScriptEnginePrivate::variantPrototype

Definition at line 369 of file qscriptengine_p.h.

Referenced by mark(), and QScriptEnginePrivate().

◆ variantWrapperObjectStructure

WTF::RefPtr<JSC::Structure> QScriptEnginePrivate::variantWrapperObjectStructure

Definition at line 370 of file qscriptengine_p.h.

Referenced by newVariant(), and QScriptEnginePrivate().

◆ visitedConversionObjects

QSet<JSC::JSObject*> QScriptEnginePrivate::visitedConversionObjects

Definition at line 395 of file qscriptengine_p.h.

Referenced by variantListFromArray(), and variantMapFromObject().


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