diff options
author | Paul Olav Tvete <paul.tvete@nokia.com> | 2010-08-19 10:04:39 (GMT) |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@nokia.com> | 2010-08-19 10:04:39 (GMT) |
commit | a226143eeda6771efc4f0df6955351336735cb60 (patch) | |
tree | a279f87d74f5929e36fe6a3aa5e4f4d843b32458 /src/script | |
parent | c02ad51733d0a2885ddb39cb7e3b09355ab97213 (diff) | |
parent | ffbce9839f8be5c2f21cc66b617dbeb0a47af269 (diff) | |
download | Qt-a226143eeda6771efc4f0df6955351336735cb60.zip Qt-a226143eeda6771efc4f0df6955351336735cb60.tar.gz Qt-a226143eeda6771efc4f0df6955351336735cb60.tar.bz2 |
Merge remote branch 'qt/master' into lighthouse-master
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/api/qscriptcontext.cpp | 2 | ||||
-rw-r--r-- | src/script/api/qscriptengine.cpp | 50 | ||||
-rw-r--r-- | src/script/api/qscriptengine.h | 67 | ||||
-rw-r--r-- | src/script/api/qscriptvalue.cpp | 12 | ||||
-rw-r--r-- | src/script/bridge/qscriptactivationobject.cpp | 2 | ||||
-rw-r--r-- | src/script/bridge/qscriptclassobject.cpp | 6 | ||||
-rw-r--r-- | src/script/bridge/qscriptqobject.cpp | 10 | ||||
-rw-r--r-- | src/script/bridge/qscriptstaticscopeobject.cpp | 2 |
8 files changed, 59 insertions, 92 deletions
diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp index 1a11100..abaf5f9 100644 --- a/src/script/api/qscriptcontext.cpp +++ b/src/script/api/qscriptcontext.cpp @@ -324,7 +324,7 @@ QScriptValue QScriptContext::argumentsObject() const When a function is called as constructor, the thisObject() contains the newly constructed object to be initialized. - \note This function is only guarenteed to work for a context + \note This function is only guaranteed to work for a context corresponding to native functions. */ bool QScriptContext::isCalledAsConstructor() const diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index bda71c0..dc22ec3 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -1706,7 +1706,7 @@ QVariant QScriptEnginePrivate::toVariant(JSC::ExecState *exec, JSC::JSValue valu return variantValue(value); #ifndef QT_NO_QOBJECT else if (isQObject(value)) - return qVariantFromValue(toQObject(exec, value)); + return QVariant::fromValue(toQObject(exec, value)); #endif else if (isDate(value)) return QVariant(toDateTime(exec, value)); @@ -2430,10 +2430,6 @@ QScriptValue QScriptEngine::newQMetaObject( \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 13 - \warning This function is not available with MSVC 6. Use - qScriptValueFromQMetaObject() instead if you need to support that version - of the compiler. - \sa QScriptEngine::newQMetaObject() */ @@ -2441,14 +2437,17 @@ QScriptValue QScriptEngine::newQMetaObject( \fn QScriptValue qScriptValueFromQMetaObject(QScriptEngine *engine) \since 4.3 \relates QScriptEngine + \obsolete Uses \a engine to create a QScriptValue that represents the Qt class \c{T}. This function is equivalent to - QScriptEngine::scriptValueFromQMetaObject(). It is provided as a - work-around for MSVC 6, which doesn't support member template - functions. + QScriptEngine::scriptValueFromQMetaObject(). + + \note This function was provided as a workaround for MSVC 6 + which did not support member template functions. It is advised + to use the other form in new code. \sa QScriptEngine::newQMetaObject() */ @@ -2979,14 +2978,7 @@ JSC::JSValue QScriptEnginePrivate::create(JSC::ExecState *exec, int type, const case QMetaType::LongLong: return JSC::jsNumber(exec, qsreal(*reinterpret_cast<const qlonglong*>(ptr))); case QMetaType::ULongLong: -#if defined(Q_OS_WIN) && defined(_MSC_FULL_VER) && _MSC_FULL_VER <= 12008804 -#pragma message("** NOTE: You need the Visual Studio Processor Pack to compile support for 64bit unsigned integers.") - return JSC::jsNumber(exec, qsreal((qlonglong)*reinterpret_cast<const qulonglong*>(ptr))); -#elif defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) - return JSC::jsNumber(exec, qsreal((qlonglong)*reinterpret_cast<const qulonglong*>(ptr))); -#else return JSC::jsNumber(exec, qsreal(*reinterpret_cast<const qulonglong*>(ptr))); -#endif case QMetaType::Double: return JSC::jsNumber(exec, qsreal(*reinterpret_cast<const double*>(ptr))); case QMetaType::QString: @@ -3744,10 +3736,6 @@ QStringList QScriptEngine::importedExtensions() const to newVariant()); you can change this behavior by installing your own type conversion functions with qScriptRegisterMetaType(). - \warning This function is not available with MSVC 6. Use - qScriptValueFromValue() instead if you need to support that - version of the compiler. - \sa fromScriptValue(), qScriptRegisterMetaType() */ @@ -3761,10 +3749,6 @@ QStringList QScriptEngine::importedExtensions() const description of the built-in type conversion provided by QtScript. - \warning This function is not available with MSVC 6. Use - qScriptValueToValue() or qscriptvalue_cast() instead if you need - to support that version of the compiler. - \sa toScriptValue(), qScriptRegisterMetaType() */ @@ -3772,29 +3756,35 @@ QStringList QScriptEngine::importedExtensions() const \fn QScriptValue qScriptValueFromValue(QScriptEngine *engine, const T &value) \since 4.3 \relates QScriptEngine + \obsolete Creates a QScriptValue using the given \a engine with the given \a value of template type \c{T}. This function is equivalent to QScriptEngine::toScriptValue(). - It is provided as a work-around for MSVC 6, which doesn't support - member template functions. - \sa qScriptValueToValue() + \note This function was provided as a workaround for MSVC 6 + which did not support member template functions. It is advised + to use the other form in new code. + + \sa QScriptEngine::toScriptValue(), qscriptvalue_cast */ /*! \fn T qScriptValueToValue(const QScriptValue &value) \since 4.3 \relates QScriptEngine + \obsolete Returns the given \a value converted to the template type \c{T}. This function is equivalent to QScriptEngine::fromScriptValue(). - It is provided as a work-around for MSVC 6, which doesn't - support member template functions. - \sa qScriptValueFromValue() + \note This function was provided as a workaround for MSVC 6 + which did not support member template functions. It is advised + to use the other form in new code. + + \sa QScriptEngine::fromScriptValue() */ /*! @@ -3813,7 +3803,7 @@ QStringList QScriptEngine::importedExtensions() const \l{Conversion Between QtScript and C++ Types} for more information about the restrictions on types that can be used with QScriptValue. - \sa qScriptValueFromValue() + \sa QScriptEngine::fromScriptValue() */ /*! diff --git a/src/script/api/qscriptengine.h b/src/script/api/qscriptengine.h index 3212ed5..830d477 100644 --- a/src/script/api/qscriptengine.h +++ b/src/script/api/qscriptengine.h @@ -65,13 +65,11 @@ inline QScriptValue qscriptQMetaObjectConstructor(QScriptContext *, QScriptEngin class QRegExp; #endif -#ifndef QT_NO_MEMBER_TEMPLATES template <typename T> inline QScriptValue qScriptValueFromValue(QScriptEngine *, const T &); template <typename T> -inline T qScriptValueToValue(const QScriptValue &); -#endif +inline T qscriptvalue_cast(const QScriptValue &); class QScriptSyntaxCheckResultPrivate; class Q_SCRIPT_EXPORT QScriptSyntaxCheckResult @@ -196,9 +194,7 @@ public: QScriptValue newQMetaObject(const QMetaObject *metaObject, const QScriptValue &ctor = QScriptValue()); -# ifndef QT_NO_MEMBER_TEMPLATES template <class T> QScriptValue scriptValueFromQMetaObject(); -# endif // QT_NO_MEMBER_TEMPLATES #endif // QT_NO_QOBJECT @@ -213,7 +209,6 @@ public: -#ifndef QT_NO_MEMBER_TEMPLATES template <typename T> inline QScriptValue toScriptValue(const T &value) { @@ -222,9 +217,8 @@ public: template <typename T> inline T fromScriptValue(const QScriptValue &value) { - return qScriptValueToValue<T>(value); + return qscriptvalue_cast<T>(value); } -#endif // QT_NO_MEMBER_TEMPLATES void installTranslatorFunctions(const QScriptValue &object = QScriptValue()); @@ -285,19 +279,6 @@ private: }; #ifndef QT_NO_QOBJECT -template <class T> -inline QScriptValue qScriptValueFromQMetaObject( - QScriptEngine *engine -#ifndef qdoc - , T * /* dummy */ = 0 -#endif - ) -{ - typedef QScriptValue(*ConstructPtr)(QScriptContext *, QScriptEngine *, T *); - ConstructPtr cptr = qscriptQMetaObjectConstructor<T>; - return engine->newQMetaObject(&T::staticMetaObject, - engine->newFunction(reinterpret_cast<QScriptEngine::FunctionWithArgSignature>(cptr), 0)); -} #define Q_SCRIPT_DECLARE_QMETAOBJECT(T, _Arg1) \ template<> inline QScriptValue qscriptQMetaObjectConstructor<T>(QScriptContext *ctx, QScriptEngine *eng, T *) \ @@ -311,12 +292,26 @@ template<> inline QScriptValue qscriptQMetaObjectConstructor<T>(QScriptContext * return o; \ } -# ifndef QT_NO_MEMBER_TEMPLATES - template <class T> QScriptValue QScriptEngine::scriptValueFromQMetaObject() - { - return qScriptValueFromQMetaObject<T>(this); - } -# endif // QT_NO_MEMBER_TEMPLATES +template <class T> QScriptValue QScriptEngine::scriptValueFromQMetaObject() +{ + typedef QScriptValue(*ConstructPtr)(QScriptContext *, QScriptEngine *, T *); + ConstructPtr cptr = qscriptQMetaObjectConstructor<T>; + return newQMetaObject(&T::staticMetaObject, + newFunction(reinterpret_cast<FunctionWithArgSignature>(cptr), 0)); +} + +#ifdef QT_DEPRECATED +template <class T> +inline QT_DEPRECATED QScriptValue qScriptValueFromQMetaObject( + QScriptEngine *engine +#ifndef qdoc + , T * /* dummy */ = 0 +#endif + ) +{ + return engine->scriptValueFromQMetaObject<T>(); +} +#endif #endif // QT_NO_QOBJECT @@ -349,11 +344,7 @@ inline bool qscriptvalue_cast_helper(const QScriptValue &value, int type, void * } template<typename T> -T qscriptvalue_cast(const QScriptValue &value -#if !defined qdoc && defined Q_CC_MSVC && _MSC_VER < 1300 -, T * = 0 -#endif - ) +T qscriptvalue_cast(const QScriptValue &value) { T t; const int id = qMetaTypeId<T>(); @@ -366,19 +357,19 @@ T qscriptvalue_cast(const QScriptValue &value return T(); } -#if !defined Q_CC_MSVC || _MSC_VER >= 1300 template <> inline QVariant qscriptvalue_cast<QVariant>(const QScriptValue &value) { return value.toVariant(); } -#endif +#ifdef QT_DEPRECATED template <typename T> -inline T qScriptValueToValue(const QScriptValue &value) +inline QT_DEPRECATED T qScriptValueToValue(const QScriptValue &value) { return qscriptvalue_cast<T>(value); } +#endif inline void qScriptRegisterMetaType_helper(QScriptEngine *eng, int type, QScriptEngine::MarshalFunction mf, @@ -418,7 +409,7 @@ QScriptValue qScriptValueFromSequence(QScriptEngine *eng, const Container &cont) typename Container::const_iterator it; quint32 i; for (it = begin, i = 0; it != end; ++it, ++i) - a.setProperty(i, qScriptValueFromValue(eng, *it)); + a.setProperty(i, eng->toScriptValue(*it)); return a; } @@ -428,11 +419,7 @@ void qScriptValueToSequence(const QScriptValue &value, Container &cont) quint32 len = value.property(QLatin1String("length")).toUInt32(); for (quint32 i = 0; i < len; ++i) { QScriptValue item = value.property(i); -#if defined Q_CC_MSVC && !defined Q_CC_MSVC_NET - cont.push_back(qscriptvalue_cast<Container::value_type>(item)); -#else cont.push_back(qscriptvalue_cast<typename Container::value_type>(item)); -#endif } } diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index f6390bb..fbd5d96 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -688,10 +688,6 @@ static bool LessThan(QScriptValue lhs, QScriptValue rhs) return false; case Number: -#if defined Q_CC_MSVC && !defined Q_CC_MSVC_NET - if (qIsNaN(lhs.toNumber()) || qIsNaN(rhs.toNumber())) - return false; -#endif return lhs.toNumber() < rhs.toNumber(); case Boolean: @@ -714,13 +710,7 @@ static bool LessThan(QScriptValue lhs, QScriptValue rhs) if (lhs.isString() && rhs.isString()) return lhs.toString() < rhs.toString(); - qsreal n1 = lhs.toNumber(); - qsreal n2 = rhs.toNumber(); -#if defined Q_CC_MSVC && !defined Q_CC_MSVC_NET - if (qIsNaN(n1) || qIsNaN(n2)) - return false; -#endif - return n1 < n2; + return lhs.toNumber() < rhs.toNumber(); } static bool Equals(QScriptValue lhs, QScriptValue rhs) diff --git a/src/script/bridge/qscriptactivationobject.cpp b/src/script/bridge/qscriptactivationobject.cpp index 6a8ae56..85224d1 100644 --- a/src/script/bridge/qscriptactivationobject.cpp +++ b/src/script/bridge/qscriptactivationobject.cpp @@ -53,7 +53,7 @@ QScriptActivationObject::QScriptActivationObject(JSC::ExecState *callFrame, JSC: QScriptActivationObject::~QScriptActivationObject() { - delete d; + delete d_ptr(); } bool QScriptActivationObject::getOwnPropertySlot(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertySlot& slot) diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp index dd229f1..28f7bd1 100644 --- a/src/script/bridge/qscriptclassobject.cpp +++ b/src/script/bridge/qscriptclassobject.cpp @@ -211,7 +211,7 @@ JSC::JSValue JSC_HOST_CALL ClassObjectDelegate::call(JSC::ExecState *exec, JSC:: eng_p->pushContext(exec, thisValue, args, callee); QScriptContext *ctx = eng_p->contextForFrame(eng_p->currentFrame); QScriptValue scriptObject = eng_p->scriptValueFromJSCValue(obj); - QVariant result = scriptClass->extension(QScriptClass::Callable, qVariantFromValue(ctx)); + QVariant result = scriptClass->extension(QScriptClass::Callable, QVariant::fromValue(ctx)); eng_p->popContext(); eng_p->currentFrame = oldFrame; return QScriptEnginePrivate::jscValueFromVariant(exec, result); @@ -239,7 +239,7 @@ JSC::JSObject* ClassObjectDelegate::construct(JSC::ExecState *exec, JSC::JSObjec QScriptContext *ctx = eng_p->contextForFrame(eng_p->currentFrame); QScriptValue defaultObject = ctx->thisObject(); - QScriptValue result = qvariant_cast<QScriptValue>(scriptClass->extension(QScriptClass::Callable, qVariantFromValue(ctx))); + QScriptValue result = qvariant_cast<QScriptValue>(scriptClass->extension(QScriptClass::Callable, QVariant::fromValue(ctx))); if (!result.isObject()) result = defaultObject; eng_p->popContext(); @@ -256,7 +256,7 @@ bool ClassObjectDelegate::hasInstance(QScriptObject* object, JSC::ExecState *exe QScriptEnginePrivate *eng_p = scriptEngineFromExec(exec); QScript::SaveFrameHelper saveFrame(eng_p, exec); args << eng_p->scriptValueFromJSCValue(object) << eng_p->scriptValueFromJSCValue(value); - QVariant result = scriptClass()->extension(QScriptClass::HasInstance, qVariantFromValue(args)); + QVariant result = scriptClass()->extension(QScriptClass::HasInstance, QVariant::fromValue(args)); return result.toBool(); } diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp index 5e4f097..d24f2fe 100644 --- a/src/script/bridge/qscriptqobject.cpp +++ b/src/script/bridge/qscriptqobject.cpp @@ -664,7 +664,7 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c if (actual.isNumber()) { int ival = QScriptEnginePrivate::toInt32(exec, actual); if (m.valueToKey(ival) != 0) { - qVariantSetValue(v, ival); + v.setValue(ival); converted = true; matchDistance += 10; } @@ -672,7 +672,7 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c JSC::UString sval = QScriptEnginePrivate::toString(exec, actual); int ival = m.keyToValue(convertToLatin1(sval)); if (ival != -1) { - qVariantSetValue(v, ival); + v.setValue(ival); converted = true; matchDistance += 10; } @@ -1668,7 +1668,7 @@ static JSC::JSValue JSC_HOST_CALL qobjectProtoFuncFindChild(JSC::ExecState *exec QString name; if (args.size() != 0) name = args.at(0).toString(exec); - QObject *child = qFindChild<QObject*>(obj, name); + QObject *child = obj->findChild<QObject*>(name); QScriptEngine::QObjectWrapOptions opt = QScriptEngine::PreferExistingWrapperObject; return engine->newQObject(child, QScriptEngine::QtOwnership, opt); } @@ -1709,10 +1709,10 @@ static JSC::JSValue JSC_HOST_CALL qobjectProtoFuncFindChildren(JSC::ExecState *e } } else { const QString name(args.at(0).toString(exec)); - children = qFindChildren<QObject*>(obj, name); + children = obj->findChildren<QObject*>(name); } } else { - children = qFindChildren<QObject*>(obj, QString()); + children = obj->findChildren<QObject*>(QString()); } // create the result array with the children const int length = children.size(); diff --git a/src/script/bridge/qscriptstaticscopeobject.cpp b/src/script/bridge/qscriptstaticscopeobject.cpp index 44548a4..940c859 100644 --- a/src/script/bridge/qscriptstaticscopeobject.cpp +++ b/src/script/bridge/qscriptstaticscopeobject.cpp @@ -87,7 +87,7 @@ QScriptStaticScopeObject::QScriptStaticScopeObject(WTF::NonNullPassRefPtr<JSC::S QScriptStaticScopeObject::~QScriptStaticScopeObject() { - delete d; + delete d_ptr(); } bool QScriptStaticScopeObject::getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot& slot) |