void QQmlPropertyCache::destroy()
{
- Q_ASSERT(engine || constructor.IsEmpty());
- if (constructor.IsEmpty())
+ Q_ASSERT(engine || constructor->isDeleted());
+ if (constructor->isDeleted())
delete this;
else
QQmlEnginePrivate::deleteInEngineThread(engine, this);
// that are tied to the specific QQmlEngine.
void QQmlPropertyCache::clear()
{
- qPersistentDispose(constructor);
engine = 0;
}
QQmlPropertyData::Flag signalFlags)
{
Q_UNUSED(revision);
- Q_ASSERT(constructor.IsEmpty()); // We should not be appending to an in-use property cache
+ Q_ASSERT(constructor->isDeleted()); // We should not be appending to an in-use property cache
_metaObject = metaObject;
#include <QtCore/qvarlengtharray.h>
#include <QtCore/qvector.h>
+#include <private/qv4value_p.h>
+
QT_BEGIN_NAMESPACE
class QV8Engine;
IndexCache signalHandlerIndexCache;
StringCache stringCache;
AllowedRevisionCache allowedRevisionCache;
- v8::Persistent<v8::Function> constructor;
+ QV4::PersistentValue constructor;
bool _hasPropertyOverrides : 1;
bool _ownMetaObject : 1;
defineReadonlyProperty(scope->engine->id_name, Value::fromString(name));
}
+Value FunctionObject::newInstance()
+{
+ return construct(internalClass->engine->current, 0, 0);
+}
+
bool FunctionObject::hasInstance(Managed *that, ExecutionContext *ctx, const Value &value)
{
FunctionObject *f = static_cast<FunctionObject *>(that);
FunctionObject(ExecutionContext *scope, String *name = 0);
+ Value newInstance();
+
static Value construct(Managed *that, ExecutionContext *context, Value *args, int argc);
static Value call(Managed *that, ExecutionContext *, const Value &, Value *, int);
inline Value construct(ExecutionContext *context, Value *args, int argc) {
{
PersistentValuePrivate *persistent = m_persistentValues;
while (persistent) {
- if (Managed *m = persistent->value.asManaged())
- persistent->value = Value::deletedValue();
+ persistent->value = Value::deletedValue();
PersistentValuePrivate *n = persistent->next;
persistent->next = 0;
persistent = n;
struct PersistentValuePrivate
{
PersistentValuePrivate()
- : value(Value::undefinedValue())
+ : value(Value::deletedValue())
, refcount(1)
, next(0)
{}
#include <private/qqmlexpression_p.h>
#include <private/qqmlglobal_p.h>
+#include <private/qv4functionobject_p.h>
+
#include <QtQml/qjsvalue.h>
#include <QtCore/qjsonarray.h>
#include <QtCore/qjsonobject.h>
Q_ASSERT(QQmlData::get(object, false)->propertyCache == this);
// Setup constructor
- if (constructor.IsEmpty()) {
+ if (constructor->isDeleted()) {
v8::Local<v8::FunctionTemplate> ft;
const QHashedString toString(QStringLiteral("toString"));
}
if (ft.IsEmpty()) {
- constructor = qPersistentNew<v8::Function>(engine->qobjectWrapper()->m_constructor);
+ constructor = engine->qobjectWrapper()->m_constructor->v4Value();
} else {
ft->InstanceTemplate()->SetFallbackPropertyHandler(QV8QObjectWrapper::Getter,
QV8QObjectWrapper::Setter,
0,
QV8QObjectWrapper::Enumerator);
ft->InstanceTemplate()->SetHasExternalResource(true);
- constructor = qPersistentNew<v8::Function>(ft->GetFunction());
+ constructor = ft->GetFunction()->v4Value();
}
QQmlCleanup::addToEngine(this->engine);
}
- v8::Local<v8::Object> result = constructor->NewInstance();
+ v8::Local<v8::Object> result = v8::Local<v8::Object>::New(constructor->asFunctionObject()->newInstance());
QV8QObjectResource *r = new QV8QObjectResource(engine, object);
result->SetExternalResource(r);
return result;