aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qml/qml/v8/qv8sequencewrapper.cpp12
-rw-r--r--src/qml/qml/v8/qv8sequencewrapper_p.h3
2 files changed, 12 insertions, 3 deletions
diff --git a/src/qml/qml/v8/qv8sequencewrapper.cpp b/src/qml/qml/v8/qv8sequencewrapper.cpp
index 6bd72387b5..c4b4e662f5 100644
--- a/src/qml/qml/v8/qv8sequencewrapper.cpp
+++ b/src/qml/qml/v8/qv8sequencewrapper.cpp
@@ -75,8 +75,7 @@ void QV8SequenceWrapper::init(QV8Engine *engine)
"})");
m_sort = qPersistentNew<v8::Function>(v8::FunctionTemplate::New(Sort)->GetFunction());
- m_arrayPrototype = qPersistentNew<v8::Object>(v8::Array::New(1)->GetPrototype()->ToObject()->Clone());
- m_arrayPrototype->Set(v8::String::New("sort"), m_sort);
+ m_arrayPrototype = qPersistentNew<v8::Value>(v8::Array::New(1)->GetPrototype());
v8::Local<v8::Script> defaultSortCompareScript = v8::Script::Compile(engine->toString(defaultSortString));
m_defaultSortComparer = qPersistentNew<v8::Function>(v8::Handle<v8::Function>(v8::Function::Cast(*defaultSortCompareScript->Run())));
@@ -92,6 +91,9 @@ void QV8SequenceWrapper::init(QV8Engine *engine)
ft->InstanceTemplate()->SetAccessor(v8::String::New("valueOf"), ValueOfGetter, 0,
m_valueOf, v8::DEFAULT,
v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete | v8::DontEnum));
+ ft->InstanceTemplate()->SetAccessor(v8::String::New("sort"), SortGetter, 0,
+ m_sort, v8::DEFAULT,
+ v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete | v8::DontEnum));
ft->InstanceTemplate()->SetHasExternalResource(true);
ft->InstanceTemplate()->MarkAsUseUserObjectComparison();
m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
@@ -246,6 +248,12 @@ v8::Handle<v8::Value> QV8SequenceWrapper::ValueOfGetter(v8::Local<v8::String> pr
return info.Data();
}
+v8::Handle<v8::Value> QV8SequenceWrapper::SortGetter(v8::Local<v8::String> property, const v8::AccessorInfo &info)
+{
+ Q_UNUSED(property);
+ return info.Data();
+}
+
v8::Handle<v8::Value> QV8SequenceWrapper::Sort(const v8::Arguments &args)
{
int argCount = args.Length();
diff --git a/src/qml/qml/v8/qv8sequencewrapper_p.h b/src/qml/qml/v8/qv8sequencewrapper_p.h
index 08bc6146f7..141d6f4428 100644
--- a/src/qml/qml/v8/qv8sequencewrapper_p.h
+++ b/src/qml/qml/v8/qv8sequencewrapper_p.h
@@ -87,7 +87,7 @@ private:
v8::Persistent<v8::Function> m_toString;
v8::Persistent<v8::Function> m_valueOf;
v8::Persistent<v8::Function> m_sort;
- v8::Persistent<v8::Object> m_arrayPrototype;
+ v8::Persistent<v8::Value> m_arrayPrototype;
v8::Persistent<v8::Function> m_defaultSortComparer;
static v8::Handle<v8::Value> IndexedGetter(quint32 index, const v8::AccessorInfo &info);
@@ -99,6 +99,7 @@ private:
static v8::Handle<v8::Value> ToStringGetter(v8::Local<v8::String> property, const v8::AccessorInfo &info);
static v8::Handle<v8::Value> ToString(const v8::Arguments &args);
static v8::Handle<v8::Value> ValueOfGetter(v8::Local<v8::String> property, const v8::AccessorInfo &info);
+ static v8::Handle<v8::Value> SortGetter(v8::Local<v8::String> property, const v8::AccessorInfo &info);
static v8::Handle<v8::Value> ValueOf(const v8::Arguments &args);
static v8::Handle<v8::Value> Getter(v8::Local<v8::String> property, const v8::AccessorInfo &info);
static v8::Handle<v8::Value> Setter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo &info);