aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-03-21 21:32:23 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2013-04-02 17:42:04 +0200
commit8175a760693ff103c74112a4b04d2a90ff4627a9 (patch)
treee6debb95a881e180f5d44d3253d8e686d7d1068c /src
parentfadb9ae5ab87b905522a6cbd6b7d439ba9407eca (diff)
Some further fixes to the v8 API
Better implementation of user comparisons, and fix a bug in GetPropertyNames. Change-Id: I2afa87239e4e269707d1809712b0beefed162d0e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/v4/qv4managed.h3
-rw-r--r--src/v4/qv4runtime.cpp6
-rw-r--r--src/v4/qv4v8.cpp18
-rw-r--r--src/v4/qv4v8.h2
4 files changed, 21 insertions, 8 deletions
diff --git a/src/v4/qv4managed.h b/src/v4/qv4managed.h
index 08f6f5b8f4..a69adf369c 100644
--- a/src/v4/qv4managed.h
+++ b/src/v4/qv4managed.h
@@ -229,7 +229,8 @@ protected:
uint strictMode : 1; // used by FunctionObject
uint type : 5;
mutable uint subtype : 3;
- uint unused : 16;
+ uint externalComparison : 1;
+ uint unused : 15;
};
};
diff --git a/src/v4/qv4runtime.cpp b/src/v4/qv4runtime.cpp
index 777daac2c5..5240efd0ec 100644
--- a/src/v4/qv4runtime.cpp
+++ b/src/v4/qv4runtime.cpp
@@ -787,8 +787,8 @@ uint __qmljs_equal(const Value &x, const Value &y, ExecutionContext *ctx)
case Value::String_Type:
return x.stringValue()->isEqualTo(y.stringValue());
case Value::Object_Type:
- if (x.objectValue()->externalResource && y.objectValue()->externalResource)
- return ctx->engine->externalResourceComparison(x, y);
+ if (x.objectValue()->externalComparison || y.objectValue()->externalComparison)
+ return x.objectValue()->externalComparison && y.objectValue()->externalComparison && ctx->engine->externalResourceComparison(x, y);
return x.objectValue() == y.objectValue();
default: // double
return x.doubleValue() == y.doubleValue();
@@ -837,7 +837,7 @@ Bool __qmljs_strict_equal(const Value &x, const Value &y, ExecutionContext *ctx)
return false;
if (x.isString())
return __qmljs_string_equal(x.stringValue(), y.stringValue());
- if (x.isObject() && x.objectValue()->externalResource && y.objectValue()->externalResource)
+ if (x.isObject() && x.objectValue()->externalComparison && y.objectValue()->externalComparison)
return ctx->engine->externalResourceComparison(x, y);
return false;
}
diff --git a/src/v4/qv4v8.cpp b/src/v4/qv4v8.cpp
index ada6fd1413..ce66109535 100644
--- a/src/v4/qv4v8.cpp
+++ b/src/v4/qv4v8.cpp
@@ -933,7 +933,7 @@ Local<Array> Object::GetPropertyNames()
assert(o);
VM::ArrayObject *array = currentEngine()->newArrayObject(currentEngine()->current)->asArrayObject();
- ObjectIterator it(currentEngine()->current, o, ObjectIterator::WithProtoChain);
+ ObjectIterator it(currentEngine()->current, o, ObjectIterator::WithProtoChain|ObjectIterator::EnumberableOnly);
while (1) {
VM::Value v = it.nextPropertyNameAsString();
if (v.isNull())
@@ -948,8 +948,15 @@ Local<Array> Object::GetOwnPropertyNames()
QQmlJS::VM::Object *o = ConstValuePtr(this)->asObject();
assert(o);
VM::Value arg = VM::Value::fromObject(o);
- VM::Value result = ObjectPrototype::method_getOwnPropertyNames(currentEngine()->current, VM::Value::undefinedValue(), &arg, 1);
- return Local<Array>::New((Value::fromVmValue(result)));
+ ArrayObject *array = currentEngine()->newArrayObject(currentEngine()->current)->asArrayObject();
+ ObjectIterator it(currentEngine()->current, o, ObjectIterator::EnumberableOnly);
+ while (1) {
+ VM::Value v = it.nextPropertyNameAsString();
+ if (v.isNull())
+ break;
+ array->push_back(v);
+ }
+ return Local<Array>::New(Value::fromVmValue(VM::Value::fromObject(array)));
}
Local<Value> Object::GetPrototype()
@@ -1709,6 +1716,7 @@ Local<Object> ObjectTemplate::NewInstance()
VM::ExecutionEngine *engine = currentEngine();
VM::Object *o = new (engine->memoryManager) V4V8Object<VM::Object>(engine, this);
o->prototype = engine->objectPrototype;
+ o->externalComparison = m_useUserComparison;
return Local<Object>::New(Value::fromVmValue(VM::Value::fromObject(o)));
}
@@ -1786,7 +1794,7 @@ void ObjectTemplate::SetHasExternalResource(bool value)
void ObjectTemplate::MarkAsUseUserObjectComparison()
{
- Q_UNIMPLEMENTED();
+ m_useUserComparison = true;
}
ObjectTemplate::ObjectTemplate()
@@ -1808,6 +1816,8 @@ ObjectTemplate::ObjectTemplate()
m_indexedPropertyQuery = 0;
m_indexedPropertyDeleter = 0;
m_indexedPropertyEnumerator = 0;
+
+ m_useUserComparison = false;
}
Handle<Primitive> Undefined()
diff --git a/src/v4/qv4v8.h b/src/v4/qv4v8.h
index 0860a32f4c..bd31792b89 100644
--- a/src/v4/qv4v8.h
+++ b/src/v4/qv4v8.h
@@ -2118,6 +2118,8 @@ class V8EXPORT ObjectTemplate : public Template {
IndexedPropertyDeleter m_indexedPropertyDeleter;
IndexedPropertyEnumerator m_indexedPropertyEnumerator;
Persistent<Value> m_indexedPropertyData;
+
+ bool m_useUserComparison;
private:
ObjectTemplate();
};