本文整理汇总了C++中QScriptObject类的典型用法代码示例。如果您正苦于以下问题:C++ QScriptObject类的具体用法?C++ QScriptObject怎么用?C++ QScriptObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QScriptObject类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: allocObject
inline void QScriptEnginePrivate::newObject(QScriptValueImpl *o,
const QScriptValueImpl &proto,
QScriptClassInfo *oc)
{
QScriptObject *od = allocObject();
od->reset();
}
示例2:
QScriptDeclarativeClass::Object *QScriptDeclarativeClass::object(const QScriptValue &v)
{
QScriptValuePrivate *d = QScriptValuePrivate::get(v);
if (!d || !d->isJSC() || !d->jscValue.inherits(&QScriptObject::info))
return 0;
QScriptObject *scriptObject = static_cast<QScriptObject*>(JSC::asObject(d->jscValue));
QScriptObjectDelegate *delegate = scriptObject->delegate();
if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
return 0;
return static_cast<QScript::DeclarativeObjectDelegate*>(delegate)->object();
}
示例3: Q_ASSERT
QScriptValue QScriptDeclarativeClass::newObject(QScriptEngine *engine,
QScriptDeclarativeClass *scriptClass,
Object *object)
{
Q_ASSERT(engine);
Q_ASSERT(scriptClass);
QScriptEnginePrivate *p = static_cast<QScriptEnginePrivate *>(QObjectPrivate::get(engine));
JSC::ExecState* exec = p->currentFrame;
QScriptObject *result = new (exec) QScriptObject(p->scriptObjectStructure);
result->setDelegate(new QScript::DeclarativeObjectDelegate(scriptClass, object));
return p->scriptValueFromJSCValue(result);
}
示例4: Q_ASSERT
QScriptDeclarativeClass::Value
QScriptDeclarativeClass::newObjectValue(QScriptEngine *engine,QScriptDeclarativeClass *scriptClass, Object *object)
{
Q_ASSERT(engine);
Q_ASSERT(scriptClass);
QScriptEnginePrivate *p = QScriptEnginePrivate::cs_getPrivate(engine);
QScript::APIShim shim(p);
JSC::ExecState* exec = p->currentFrame;
QScriptObject *result = new (exec) QScriptObject(p->scriptObjectStructure);
result->setDelegate(new QScript::DeclarativeObjectDelegate(scriptClass, object));
return jscToValue(JSC::JSValue(result));
}
示例5: compareToObject
bool DeclarativeObjectDelegate::compareToObject(QScriptObject *o, JSC::ExecState *exec, JSC::JSObject *o2)
{
if (!o2->inherits(&QScriptObject::info))
return false;
QScriptObject *scriptObject = static_cast<QScriptObject*>(o2);
QScriptObjectDelegate *delegate = scriptObject->delegate();
if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
return false;
DeclarativeObjectDelegate *other = static_cast<DeclarativeObjectDelegate*>(delegate);
if (m_class != other->m_class)
return false;
else
return m_class->compare(m_object, other->m_object);
}
示例6: Q_ASSERT
JSC::JSObject* ClassObjectDelegate::construct(JSC::ExecState *exec, JSC::JSObject *callee,
const JSC::ArgList &args)
{
Q_ASSERT(callee->inherits(&QScriptObject::info));
QScriptObject *obj = static_cast<QScriptObject*>(callee);
QScriptObjectDelegate *delegate = obj->delegate();
QScriptClass *scriptClass = static_cast<ClassObjectDelegate*>(delegate)->scriptClass();
QScriptEnginePrivate *eng_p = scriptEngineFromExec(exec);
//JSC::ExecState *oldFrame = eng_p->currentFrame;
eng_p->pushContext(exec, JSC::JSValue(), args, callee, true);
QScriptContext *ctx = eng_p->contextForFrame(eng_p->currentFrame);
QScriptValue defaultObject = ctx->thisObject();
QScriptValue result = qvariant_cast<QScriptValue>(scriptClass->extension(QScriptClass::Callable, qVariantFromValue(ctx)));
if (!result.isObject())
result = defaultObject;
return JSC::asObject(eng_p->scriptValueToJSCValue(result));
}
示例7: throwError
JSC::JSValue JSC_HOST_CALL ClassObjectDelegate::call(JSC::ExecState *exec, JSC::JSObject *callee,
JSC::JSValue thisValue, const JSC::ArgList &args)
{
if (!callee->inherits(&QScriptObject::info))
return JSC::throwError(exec, JSC::TypeError, "callee is not a ClassObject object");
QScriptObject *obj = static_cast<QScriptObject*>(callee);
QScriptObjectDelegate *delegate = obj->delegate();
if (!delegate || (delegate->type() != QScriptObjectDelegate::ClassObject))
return JSC::throwError(exec, JSC::TypeError, "callee is not a ClassObject object");
QScriptClass *scriptClass = static_cast<ClassObjectDelegate*>(delegate)->scriptClass();
QScriptEnginePrivate *eng_p = scriptEngineFromExec(exec);
JSC::ExecState *oldFrame = eng_p->currentFrame;
eng_p->pushContext(exec, thisValue, args, callee);
QScriptContext *ctx = eng_p->contextForFrame(eng_p->currentFrame);
QScriptValue scriptObject = eng_p->scriptValueFromJSCValue(obj);
QVariant result = scriptClass->extension(QScriptClass::Callable, QVariant::fromValue(ctx));
eng_p->popContext();
eng_p->currentFrame = oldFrame;
return QScriptEnginePrivate::jscValueFromVariant(exec, result);
}
示例8: setValue
void QScriptValueIteratorImpl::setValue(const QScriptValueImpl &value)
{
if (!m_member.isValid())
return;
if (m_member.isGetterOrSetter()) {
// find and call the setter
QScriptValueImpl setter;
if (m_member.isObjectProperty() && !m_member.isSetter()) {
QScript::Member mb;
QScriptObject *obj = m_object.m_object_value;
mb.object(m_member.nameId(), obj->memberCount(), 0);
if (!obj->findSetter(&mb))
return;
m_object.get(mb, &setter);
} else {
m_object.get(m_member, &setter);
}
setter.call(m_object, QScriptValueImplList() << value);
} else {
m_object.put(m_member, value);
}
}
示例9: QScriptValueImpl
QScriptValueImpl QScriptValueIteratorImpl::value() const
{
if (!m_member.isValid())
return QScriptValueImpl();
QScriptValueImpl result;
m_object.get(m_member, &result);
if (m_member.isGetterOrSetter()) {
// find and call the getter
QScriptValueImpl getter;
if (m_member.isObjectProperty() && !m_member.isGetter()) {
QScript::Member mb;
QScriptObject *obj = m_object.m_object_value;
mb.object(m_member.nameId(), obj->memberCount(), 0);
if (!obj->findGetter(&mb))
return QScriptValueImpl();
m_object.get(mb, &getter);
} else {
getter = result;
}
result = getter.call(m_object);
}
return result;
}
示例10: call
JSC::JSValue DeclarativeObjectDelegate::call(JSC::ExecState *exec, JSC::JSObject *callee,
JSC::JSValue thisValue, const JSC::ArgList &args)
{
if (!callee->inherits(&QScriptObject::info))
return JSC::throwError(exec, JSC::TypeError, "callee is not a DeclarativeObject object");
QScriptObject *obj = static_cast<QScriptObject*>(callee);
QScriptObjectDelegate *delegate = obj->delegate();
if (!delegate || (delegate->type() != QScriptObjectDelegate::DeclarativeClassObject))
return JSC::throwError(exec, JSC::TypeError, "callee is not a DeclarativeObject object");
QScriptDeclarativeClass *scriptClass = static_cast<DeclarativeObjectDelegate*>(delegate)->m_class;
QScriptEnginePrivate *eng_p = scriptEngineFromExec(exec);
QScript::SaveFrameHelper saveFrame(eng_p, exec);
eng_p->pushContext(exec, thisValue, args, callee);
QScriptContext *ctxt = eng_p->contextForFrame(eng_p->currentFrame);
QScriptValue scriptObject = eng_p->scriptValueFromJSCValue(obj);
QScriptDeclarativeClass::Value result =
scriptClass->call(static_cast<DeclarativeObjectDelegate*>(delegate)->m_object, ctxt);
eng_p->popContext();
return (JSC::JSValue &)(result);
}
示例11: switch
QDebug &operator<<(QDebug &d, const QScriptValueImpl &object)
{
d.nospace() << "QScriptValue(";
switch (object.type()) {
case QScript::InvalidType:
d.nospace() << "Invalid)";
return d;
case QScript::BooleanType:
d.nospace() << "bool=" << object.toBoolean();
break;
case QScript::IntegerType:
d.nospace() << "int=" << object.toInt32();
break;
case QScript::NumberType:
d.nospace() << "qsreal=" << object.toNumber();
break;
case QScript::LazyStringType:
case QScript::StringType:
d.nospace() << "string=" << object.toString();
break;
case QScript::ReferenceType:
d.nospace() << "reference";
break;
case QScript::NullType:
d.nospace() << "null";
break;
case QScript::UndefinedType:
d.nospace() << "undefined";
break;
case QScript::PointerType:
d.nospace() << "pointer";
break;
case QScript::ObjectType:
d.nospace() << object.classInfo()->name() << ",{";
QScriptObject *od = object.objectValue();
for (int i=0; i<od->memberCount(); ++i) {
if (i != 0)
d << ",";
QScript::Member m;
od->member(i, &m);
if (m.isValid() && m.isObjectProperty()) {
d << object.engine()->toString(m.nameId());
QScriptValueImpl o;
od->get(m, &o);
d.nospace() << QLatin1String(":")
<< (o.classInfo()
? o.classInfo()->name()
: QLatin1String("?"));
}
}
d.nospace() << "} scope={";
QScriptValueImpl scope = object.scope();
while (scope.isValid()) {
Q_ASSERT(scope.isObject());
d.nospace() << " " << scope.objectValue();
scope = scope.scope();
}
d.nospace() << "}";
break;
}
d << ")";
return d;
}