char *buffer = data.data() + offset;
memcpy(buffer, pattern.constData(), length*sizeof(QChar));
- } else if (engine->isQObject(v)) {
+ } else if (QV4::QObjectWrapper *qobjectWrapper = v.as<QV4::QObjectWrapper>()) {
// XXX TODO: Generalize passing objects between the main thread and worker scripts so
// that others can trivially plug in their elements.
- QQmlListModel *lm = qobject_cast<QQmlListModel *>(engine->toQObject(v));
+ QQmlListModel *lm = qobject_cast<QQmlListModel *>(qobjectWrapper->object);
if (lm && lm->agent()) {
QQmlListModelWorkerAgent *agent = lm->agent();
agent->addref();
if (!o)
return false;
- QV8Engine *v8 = d->engine()->publicEngine->handle();
- return v8->isQObject(d->value);
+ return o->as<QV4::QObjectWrapper>() != 0;
}
QT_END_NAMESPACE
return true;
} break;
case QMetaType::QObjectStar: {
- if (isQObject(value) || value.isNull()) {
+ QV4::QObjectWrapper *qobjectWrapper = value.as<QV4::QObjectWrapper>();
+ if (qobjectWrapper || value.isNull()) {
*reinterpret_cast<QObject* *>(data) = qtObjectFromJS(value);
return true;
} break;
const QVariant &v = vo->data;
canCast = (type == v.userType()) || (valueType && (valueType == v.userType()));
}
- else if (isQObject(QV4::Value::fromObject(proto))) {
+ else if (proto->as<QV4::QObjectWrapper>()) {
QByteArray className = name.left(name.size()-1);
if (QObject *qobject = qtObjectFromJS(QV4::Value::fromObject(proto)))
canCast = qobject->qt_metacast(className) != 0;
return re->toQRegExp();
if (QV4::VariantObject *v = value.as<QV4::VariantObject>())
return v->data;
- if (isQObject(value))
+ if (value.as<QV4::QObjectWrapper>())
return qVariantFromValue(qtObjectFromJS(value));
if (QV4::QmlValueTypeWrapper *v = value.as<QV4::QmlValueTypeWrapper>())
return v->toVariant();
// Return a JS wrapper for the given QObject \a object
inline QV4::Value newQObject(QObject *object);
inline QV4::Value newQObject(QObject *object, const ObjectOwnership ownership);
- inline bool isQObject(const QV4::Value &value);
inline QObject *toQObject(const QV4::Value &value);
// Return a JS string for the given QString \a string
Q_DISABLE_COPY(QV8Engine)
};
-bool QV8Engine::isQObject(const QV4::Value &value)
-{
- return value.isObject() ? m_qobjectWrapper.isQObject(value) : false;
-}
-
QObject *QV8Engine::toQObject(const QV4::Value &value)
{
return value.isObject() ? m_qobjectWrapper.toQObject(value) : 0;
v4->functionPrototype->defineDefaultProperty(v4, QStringLiteral("disconnect"), Disconnect);
}
-bool QV8QObjectWrapper::isQObject(v8::Handle<v8::Object> obj)
-{
- return obj->v4Value().as<QObjectWrapper>() != 0;
-}
-
QObject *QV8QObjectWrapper::toQObject(v8::Handle<v8::Object> obj)
{
QV4::QObjectWrapper *wrapper = obj->v4Value().as<QObjectWrapper>();
void destroy();
v8::Handle<v8::Value> newQObject(QObject *object);
- bool isQObject(v8::Handle<v8::Object>);
QObject *toQObject(v8::Handle<v8::Object>);
enum RevisionMode { IgnoreRevision, CheckRevision };