本文整理汇总了C++中kjs::JSObject::implementsCall方法的典型用法代码示例。如果您正苦于以下问题:C++ JSObject::implementsCall方法的具体用法?C++ JSObject::implementsCall怎么用?C++ JSObject::implementsCall使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kjs::JSObject
的用法示例。
在下文中一共展示了JSObject::implementsCall方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
QVariant KJSObjectModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
Node *item = static_cast<Node*>(index.internalPointer());
KJS::JSObject *instance = item->instance;
if (role == Qt::DecorationRole )
{
if( instance->implementsConstruct() )
return QPixmap(":/images/class.png");
else if( instance->implementsCall() )
return QPixmap(":/images/method.png");
else
return QPixmap(":/images/property.png");
}
if( role == Qt::TextColorRole )
{
if( instance->implementsConstruct() )
return QColor("blue");
else if( instance->implementsCall() )
return QColor("green");
else
return QColor("black");
}
if (role == Qt::DisplayRole)
return item->name;
return QVariant();
}
示例2: jsNull
KJS::JSValue *SlotProxy::callMethod(const QByteArray &methodName, void **_a)
{
#ifdef DEBUG_SLOTPROXY
qDebug() << "SlotProxy::callMethod(" << methodName << ",_a) obj=" << this;
#endif
KJS::ExecState *exec = m_interpreter->globalExec();
exec->clearException();
// Crash
// KJS::Interpreter::globalExec()->context().thisValue()
KJS::List args = convertArguments(exec, _a);
KJS::Identifier id = KJS::Identifier(KJS::UString(methodName.data()));
KJS::JSObject *fun = m_object->get(exec, id)->toObject(exec);
KJS::JSValue *retValue;
if (!fun->implementsCall()) {
#ifdef DEBUG_SLOTPROXY
qDebug() << "SlotProxy::callMethod got bad handler";
#endif
QString msg = i18n("Bad slot handler: Object %1 Identifier %2 Method %3 Signature: %4.",
m_object->className().ascii(),
id.ascii(),
methodName.data(),
QString(m_signature));
retValue = throwError(exec, KJS::TypeError, msg);
} else {
retValue = fun->call(exec, m_object, args);
}
if (exec->hadException()) {
#ifdef DEBUG_SLOTPROXY
qDebug() << "SlotProxy::callMethod had exception";
#endif
if (m_interpreter->shouldPrintExceptions()) {
KJS::JSLock lock;
KJS::JSObject *exceptObj = exec->exception()->toObject(exec);//retValue->toObject(exec);
QString message = toQString(exceptObj->toString(exec));
QString sourceURL = toQString(exceptObj->get(exec, "sourceURL")->toString(exec));
int sourceId = exceptObj->get(exec, "sourceId")->toUInt32(exec);
// would include the line number, but it's always last line of file
int line = exceptObj->get(exec, "line")->toUInt32(exec);
(*KJSEmbed::conerr()) << i18n("Exception calling '%1' slot from %2:%3:%4", QString(methodName), !sourceURL.isEmpty() ? sourceURL : QString::number(sourceId), line, message) << endl;
}
// clear it so it doesn't stop other things
exec->clearException();
return KJS::jsNull();
} else {
if (retValue->type() == 1 || retValue->type() == 0) {
return KJS::jsNull();
}
}
return retValue;
}
示例3: callHandler
bool EventProxy::callHandler( QEvent *e )
{
// Be careful enabling this as if there are a lot of events then the event loop times
// out and the app crashes with 'Alarm Clock'.
// qDebug("JSObjectEventProxy::callHandler() event type %d" , e->type() );
KJS::ExecState *exec = m_interpreter->globalExec();
KJS::Identifier id = JSEventMapper::mapper()->findEventHandler( e->type() );
KJS::JSObject *jsobj(m_watch);
KJS::JSObject *fun = jsobj->get(exec, id )->toObject( exec );
KJS::JSValue *retValue;
if ( !fun->implementsCall() )
{
QString msg = i18n( "Bad event handler: Object %1 Identifier %2 Method %3 Type: %4.",
jsobj->className().ascii(),
id.ascii(),
fun->className().ascii(),
e->type());
retValue = throwError(exec, KJS::TypeError, msg);
}
else
{
// Process args
KJS::List args;
args.append( JSEventUtils::event(exec, e) );
// Call handler
retValue = fun->call( exec, jsobj, args );
}
if ( exec->hadException() )
{
if (m_interpreter->shouldPrintExceptions())
{
KJS::JSLock lock;
KJS::JSObject* exceptObj = retValue->toObject(exec);
QString message = toQString(exceptObj->toString(exec));
QString sourceURL = toQString(exceptObj->get(exec, "sourceURL")->toString(exec));
int sourceId = exceptObj->get(exec, "sourceId")->toUInt32(exec);
int line = exceptObj->get(exec, "line")->toUInt32(exec);
(*KJSEmbed::conerr()) << i18n("Exception calling '%1' function from %2:%3:%4", id.ascii(), !sourceURL.isEmpty() ? sourceURL : QString::number(sourceId), line, message) << endl;
}
// clear it so it doesn't stop other things
exec->clearException();
return false;
}
return true;
}
示例4: toNodeFilter
NodeFilter* toNodeFilter(KJS::JSValue* val)
{
if (!val || !val->isObject())
return 0;
if (val->isObject(&JSNodeFilter::info))
return static_cast<JSNodeFilter*>(val)->impl();
KJS::JSObject* o = static_cast<KJS::JSObject*>(val);
if (o->implementsCall())
return new NodeFilter(new JSNodeFilterCondition(o));
return 0;
}
示例5: throwError
KJS::JSValue *Engine::callMethod( KJS::JSObject *parent,
const KJS::UString &methodName, const KJS::List &args )
{
KJS::ExecState *exec = dptr->m_interpreter->globalExec();
KJS::Identifier id = KJS::Identifier( methodName);
KJS::JSObject *fun = parent->get( exec, id )->toObject( exec );
KJS::JSValue *retValue;
if ( !fun->implementsCall() ) {
QString msg = i18n( "%1 is not a function and cannot be called.", toQString(methodName) );
return throwError( exec, KJS::TypeError, msg );
}
retValue = fun->call( exec, parent, args );
if( exec->hadException() )
return exec->exception();
return retValue;
}