Change Value::isInt32() to convert to an integer if possible.
Use this to avoid casting doubles to ints twice. usage of
v8::Value::IsInt32() in two places.
Change-Id: I5b9d8be7d90b461c11440bf54660ceef7e8f0f1b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
inline bool isObject() const { return tag == Object_Type; }
#endif
inline bool isConvertibleToInt() const { return (tag & ConvertibleToInt) == ConvertibleToInt; }
- inline bool isInt32() const {
+ inline bool isInt32() {
if (tag == _Integer_Type)
return true;
- if (isDouble() && (int)dbl == dbl)
- return true;
+ if (isDouble()) {
+ int i = (int)dbl;
+ if (i == dbl) {
+ int_32 = i;
+ tag = _Integer_Type;
+ return true;
+ }
+ }
return false;
}
if (v.isBoolean())
return QVariant(v.booleanValue());
if (v.isNumber()) {
- if (v.isInt32())
- return QVariant(v.toInt32());
+ QV4::Value val = v;
+ if (val.isInt32())
+ return QVariant(val.integerValue());
return QVariant(v.asDouble());
}
if (v.isNull())
Qt::DropActions supportedActions = d->supportedActions;
// check arguments for supportedActions, maybe data?
if (args->length() >= 1) {
- v8::Handle<v8::Value> v = (*args)[0];
- if (v->IsInt32()) {
- supportedActions = Qt::DropActions(v->Int32Value());
+ QV4::Value v = (*args)[0];
+ if (v.isInt32()) {
+ supportedActions = Qt::DropActions(v.integerValue());
d->overrideActions = true;
}
}
Qt::DropAction action = event->dropAction();
if (args->length() >= 1) {
- v8::Handle<v8::Value> v = (*args)[0];
- if (v->IsInt32())
- action = Qt::DropAction(v->Int32Value());
+ QV4::Value v = (*args)[0];
+ if (v.isInt32())
+ action = Qt::DropAction(v.integerValue());
}
// get action from arguments.
event->setDropAction(action);