diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-09-21 10:56:11 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-09-21 14:29:16 (GMT) |
commit | 65b4ce3c51283adb76dcb73cc654b06359b1ae00 (patch) | |
tree | c71e10c6da5f986cc83ab520efce3a5952114efe /src/script/bridge/qscriptvariant.cpp | |
parent | 1b34feacef7a2d3ac005449a7cfbcb08a6bbf947 (diff) | |
download | Qt-65b4ce3c51283adb76dcb73cc654b06359b1ae00.zip Qt-65b4ce3c51283adb76dcb73cc654b06359b1ae00.tar.gz Qt-65b4ce3c51283adb76dcb73cc654b06359b1ae00.tar.bz2 |
QtScript: Fix comparing QVariant and QObject.
This add a hook inside JSC to be able to implement our own comparison function
when comparing objects.
Reviewed-by: Kent Hansen
Diffstat (limited to 'src/script/bridge/qscriptvariant.cpp')
-rw-r--r-- | src/script/bridge/qscriptvariant.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/script/bridge/qscriptvariant.cpp b/src/script/bridge/qscriptvariant.cpp index 583b61c..aa7ad94 100644 --- a/src/script/bridge/qscriptvariant.cpp +++ b/src/script/bridge/qscriptvariant.cpp @@ -148,6 +148,13 @@ static JSC::JSValue JSC_HOST_CALL variantProtoFuncToString(JSC::ExecState *exec, return JSC::jsString(exec, result); } +bool QVariantDelegate::compareToObject(QScriptObject *, JSC::ExecState *exec, JSC::JSObject *o2) +{ + const QVariant &variant1 = value(); + return variant1 == scriptEngineFromExec(exec)->scriptValueFromJSCValue(o2).toVariant(); +} + + QVariantPrototype::QVariantPrototype(JSC::ExecState* exec, WTF::PassRefPtr<JSC::Structure> structure, JSC::Structure* prototypeFunctionStructure) : QScriptObject(structure) @@ -158,6 +165,7 @@ QVariantPrototype::QVariantPrototype(JSC::ExecState* exec, WTF::PassRefPtr<JSC:: putDirectFunction(exec, new (exec) JSC::PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, variantProtoFuncValueOf), JSC::DontEnum); } + } // namespace QScript QT_END_NAMESPACE |