117 const QVariant &v = static_cast<QVariantDelegate*>(delegate)->value(); |
119 const QVariant &v = static_cast<QVariantDelegate*>(delegate)->value(); |
118 JSC::UString result; |
120 JSC::UString result; |
119 JSC::JSValue value = variantProtoFuncValueOf(exec, callee, thisValue, args); |
121 JSC::JSValue value = variantProtoFuncValueOf(exec, callee, thisValue, args); |
120 if (value.isObject()) { |
122 if (value.isObject()) { |
121 result = v.toString(); |
123 result = v.toString(); |
122 if (result.isEmpty() && !v.canConvert(QVariant::String)) { |
124 if (result.isEmpty() && !v.canConvert(QVariant::String)) |
123 result = "QVariant("; |
125 result = QString::fromLatin1("QVariant(%0)").arg(QString::fromLatin1(v.typeName())); |
124 result += v.typeName(); |
|
125 result += ")"; |
|
126 } |
|
127 } else { |
126 } else { |
128 result = value.toString(exec); |
127 result = value.toString(exec); |
129 } |
128 } |
130 return JSC::jsString(exec, result); |
129 return JSC::jsString(exec, result); |
131 } |
130 } |
132 |
131 |
133 bool QVariantDelegate::compareToObject(QScriptObject *, JSC::ExecState *exec, JSC::JSObject *o2) |
132 bool QVariantDelegate::compareToObject(QScriptObject *, JSC::ExecState *exec, JSC::JSObject *o2) |
134 { |
133 { |
135 const QVariant &variant1 = value(); |
134 const QVariant &variant1 = value(); |
136 return variant1 == scriptEngineFromExec(exec)->scriptValueFromJSCValue(o2).toVariant(); |
135 return variant1 == QScriptEnginePrivate::toVariant(exec, o2); |
137 } |
136 } |
138 |
137 |
139 QVariantPrototype::QVariantPrototype(JSC::ExecState* exec, WTF::PassRefPtr<JSC::Structure> structure, |
138 QVariantPrototype::QVariantPrototype(JSC::ExecState* exec, WTF::PassRefPtr<JSC::Structure> structure, |
140 JSC::Structure* prototypeFunctionStructure) |
139 JSC::Structure* prototypeFunctionStructure) |
141 : QScriptObject(structure) |
140 : QScriptObject(structure) |
142 { |
141 { |
143 setDelegate(new QVariantDelegate(QVariant())); |
142 setDelegate(new QVariantDelegate(QVariant())); |
144 |
143 |
145 putDirectFunction(exec, new (exec) JSC::PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, variantProtoFuncToString), JSC::DontEnum); |
144 putDirectFunction(exec, new (exec) JSC::NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().toString, variantProtoFuncToString), JSC::DontEnum); |
146 putDirectFunction(exec, new (exec) JSC::PrototypeFunction(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, variantProtoFuncValueOf), JSC::DontEnum); |
145 putDirectFunction(exec, new (exec) JSC::NativeFunctionWrapper(exec, prototypeFunctionStructure, 0, exec->propertyNames().valueOf, variantProtoFuncValueOf), JSC::DontEnum); |
147 } |
146 } |
148 |
147 |
149 |
148 |
150 } // namespace QScript |
149 } // namespace QScript |
151 |
150 |