VDMDelegateDataType *m_delegateDataType;
CreateModelData createItem;
StringValue stringValue;
- v8::Persistent<v8::Function> m_constructor;
+ v8::Persistent<v8::ObjectTemplate> m_constructor;
int m_ref;
int m_count;
v8::HandleScope handleScope;
v8::Context::Scope contextScope(v8Engine->context());
- v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetHasExternalResource(true);
- ft->PrototypeTemplate()->SetAccessor(
+ v8::Local<v8::ObjectTemplate> constructor = v8::ObjectTemplate::New();
+ constructor->SetHasExternalResource(true);
+ constructor->SetAccessor(
v8::String::New("index"), QQuickVisualDataModelItemMetaObject::get_index);
if (m_listAccessor
&& m_listAccessor->type() != QQuickListAccessor::Instance) {
createItem = &QQuickVDMListAccessorData::create;
stringValue = &QQuickVDMListAccessorData::stringValue;
- ft->PrototypeTemplate()->SetAccessor(
+ constructor->SetAccessor(
v8::String::New("modelData"), QQuickVDMListAccessorData::get_modelData);
- m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
+ m_constructor = qPersistentNew(constructor);
return;
}
const QString roleName = m_listModelInterface->toString(role);
const QByteArray propertyName = roleName.toUtf8();
addProperty(role, propertyId, propertyName, "QVariant");
- ft->PrototypeTemplate()->SetAccessor(
+ constructor->SetAccessor(
v8Engine->toString(roleName),
QQuickVDMListModelInterfaceData::get_property,
QQuickVDMListModelInterfaceData::set_property,
m_roleCount = m_propertyData.count();
if (m_propertyData.count() == 1) {
addProperty(roles.first(), 1, "modelData", "QVariant", true);
- ft->PrototypeTemplate()->SetAccessor(
+ constructor->SetAccessor(
v8::String::New("modelData"),
QQuickVDMListModelInterfaceData::get_property,
QQuickVDMListModelInterfaceData::set_property,
for (QHash<int, QByteArray>::const_iterator it = roleNames.begin(); it != roleNames.end(); ++it) {
const int propertyId = m_propertyData.count();
addProperty(it.key(), propertyId, it.value(), "QVariant");
- ft->PrototypeTemplate()->SetAccessor(
+ constructor->SetAccessor(
v8::String::New(it.value().constData(), it.value().length()),
QQuickVDMAbstractItemModelData::get_property,
QQuickVDMAbstractItemModelData::set_property,
m_roleCount = m_propertyData.count();
if (m_propertyData.count() == 1) {
addProperty(roleNames.begin().key(), 1, "modelData", "QVariant", true);
- ft->PrototypeTemplate()->SetAccessor(
+ constructor->SetAccessor(
v8::String::New("modelData"),
QQuickVDMAbstractItemModelData::get_property,
QQuickVDMAbstractItemModelData::set_property,
v8::Int32::New(0));
m_roleNames.insert("modelData", roleNames.begin().key());
}
- ft->PrototypeTemplate()->SetAccessor(
+ constructor->SetAccessor(
v8::String::New("hasModelChildren"),
QQuickVDMAbstractItemModelData::get_hasModelChildren);
} else if (m_listAccessor) {
if (!m_objectList) {
m_delegateDataType->propertyCache = new QQmlPropertyCache(
m_engine, m_delegateDataType->metaObject);
- m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
+ m_constructor = qPersistentNew(constructor);
}
}
v8::HandleScope handleScope;
v8::Context::Scope contextScope(engine->context());
- v8::Local<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
- ft->InstanceTemplate()->SetHasExternalResource(true);
- ft->PrototypeTemplate()->SetAccessor(v8::String::New("model"), get_model);
- ft->PrototypeTemplate()->SetAccessor(v8::String::New("groups"), get_groups, set_groups);
- ft->PrototypeTemplate()->SetAccessor(v8::String::New("isUnresolved"), get_member, 0, v8::Int32::New(30));
+
+ constructor = qPersistentNew(v8::ObjectTemplate::New());
+
+ constructor->SetHasExternalResource(true);
+ constructor->SetAccessor(v8::String::New("model"), get_model);
+ constructor->SetAccessor(v8::String::New("groups"), get_groups, set_groups);
+ constructor->SetAccessor(v8::String::New("isUnresolved"), get_member, 0, v8::Int32::New(30));
int notifierId = 0;
for (int i = 0; i < groupNames.count(); ++i, ++notifierId) {
propertyName.toUtf8(), "bool", notifierId);
propertyBuilder.setWritable(true);
- ft->PrototypeTemplate()->SetAccessor(
+ constructor->SetAccessor(
engine->toString(propertyName), get_member, set_member, v8::Int32::New(i + 1));
}
for (int i = 0; i < groupNames.count(); ++i, ++notifierId) {
propertyName.toUtf8(), "int", notifierId);
propertyBuilder.setWritable(true);
- ft->PrototypeTemplate()->SetAccessor(
+ constructor->SetAccessor(
engine->toString(propertyName), get_index, 0, v8::Int32::New(i + 1));
}
metaObject = builder.toMetaObject();
-
- constructor = qPersistentNew<v8::Function>(ft->GetFunction());
}
QQuickVisualDataModelItemMetaType::~QQuickVisualDataModelItemMetaType()