#include <private/qv4engine_p.h>
#include <private/qv4value_p.h>
+#include <private/qv4functionobject_p.h>
QT_BEGIN_NAMESPACE
void QV8ContextWrapper::destroy()
{
- qPersistentDispose(m_sharedContext);
- qPersistentDispose(m_urlConstructor);
- qPersistentDispose(m_constructor);
}
void QV8ContextWrapper::init(QV8Engine *engine)
v8::Handle<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
ft->InstanceTemplate()->SetHasExternalResource(true);
ft->InstanceTemplate()->SetFallbackPropertyHandler(Getter, Setter);
- m_constructor = qPersistentNew<v8::Function>(ft->GetFunction());
+ m_constructor = ft->GetFunction()->v4Value();
}
{
v8::Handle<v8::FunctionTemplate> ft = v8::FunctionTemplate::New();
ft->InstanceTemplate()->SetHasExternalResource(true);
ft->InstanceTemplate()->SetFallbackPropertyHandler(NullGetter, NullSetter);
- m_urlConstructor = qPersistentNew<v8::Function>(ft->GetFunction());
+ m_urlConstructor = ft->GetFunction()->v4Value();
}
{
- v8::Handle<v8::Object> sharedContext = m_constructor->NewInstance();
+ v8::Handle<v8::Object> sharedContext = m_constructor.value().asFunctionObject()->newInstance();
QV8ContextResource *r = new QV8ContextResource(engine, 0, 0);
r->isSharedContext = true;
sharedContext->SetExternalResource(r);
- m_sharedContext = qPersistentNew<v8::Object>(sharedContext);
+ m_sharedContext = sharedContext->v4Value();
}
}
v8::Handle<v8::Object> QV8ContextWrapper::qmlScope(QQmlContextData *ctxt, QObject *scope)
{
// XXX NewInstance() should be optimized
- v8::Handle<v8::Object> rv = m_constructor->NewInstance();
+ v8::Handle<v8::Object> rv = m_constructor.value().asFunctionObject()->newInstance();
QV8ContextResource *r = new QV8ContextResource(m_engine, ctxt, scope);
rv->SetExternalResource(r);
return rv;
context->isJSContext = true;
// XXX NewInstance() should be optimized
- v8::Handle<v8::Object> rv = m_urlConstructor->NewInstance();
+ v8::Handle<v8::Object> rv = m_urlConstructor.value().asFunctionObject()->newInstance();
QV8ContextResource *r = new QV8ContextResource(m_engine, context, 0, true);
rv->SetExternalResource(r);
return rv;
#include <private/qtqmlglobal_p.h>
#include <private/qv8_p.h>
+#include <private/qv4value_p.h>
+
QT_BEGIN_NAMESPACE
class QUrl;
QQmlContextData *callingContext();
QQmlContextData *context(v8::Handle<v8::Value>);
- inline v8::Handle<v8::Object> sharedContext() const;
+ inline QV4::Value sharedContext() const;
void takeContextOwnership(v8::Handle<v8::Object> qmlglobal);
const v8::AccessorInfo &info);
QV8Engine *m_engine;
- v8::Persistent<v8::Function> m_constructor;
- v8::Persistent<v8::Function> m_urlConstructor;
- v8::Persistent<v8::Object> m_sharedContext;
+ QV4::PersistentValue m_constructor;
+ QV4::PersistentValue m_urlConstructor;
+ QV4::PersistentValue m_sharedContext;
};
-v8::Handle<v8::Object> QV8ContextWrapper::sharedContext() const
+QV4::Value QV8ContextWrapper::sharedContext() const
{
return m_sharedContext;
}