本文整理汇总了C++中kjs::List::append方法的典型用法代码示例。如果您正苦于以下问题:C++ List::append方法的具体用法?C++ List::append怎么用?C++ List::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kjs::List
的用法示例。
在下文中一共展示了List::append方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startElement
bool SaxHandler::startElement( const QString &ns, const QString &ln, const QString &qn,
const QXmlAttributes &attrs )
{
if ( !jshandler.isValid() ) {
error = ErrorNoHandler;
return false;
}
KJS::Identifier funName("startElement");
if ( !jshandler.hasProperty(exec, funName) )
return QXmlDefaultHandler::startElement( ns, ln, qn, attrs );
KJS::Object fun = jshandler.get(exec, funName).toObject( exec );
if ( !fun.implementsCall() ) {
error = ErrorNotCallable;
return false;
}
KJS::List args;
args.append( KJS::String(ns) );
args.append( KJS::String(ln) );
args.append( KJS::String(qn) );
// TODO: XmlAttributes not yet supported
KJS::Value ret = fun.call( exec, jshandler, args );
return ret.toBoolean( exec );
}
示例2: constructorList
KJS::List KJSEmbedPart::constructorList() const
{
KJS::List items;
KJS::Object obj = js->globalObject();
KJS::ExecState *exec = js->globalExec();
KJS::ReferenceList l = obj.propList( exec );
KJS::ReferenceListIterator propIt = l.begin();
while ( propIt != l.end() ) {
KJS::Identifier name = propIt->getPropertyName( exec );
if ( obj.hasProperty( exec, name ) ) {
KJS::Value v = obj.get( exec, name );
KJS::Object vobj = v.toObject( exec );
if ( vobj.implementsConstruct() )
items.append( KJS::String( name.ustring() ) );
}
propIt++;
}
return items;
}
示例3: initScript
DOM::EventListener *KJSProxyImpl::createHTMLEventHandler(QString sourceUrl, QString code)
{
#ifdef KJS_DEBUGGER
if (KJSDebugWin::instance())
KJSDebugWin::instance()->setNextSourceInfo(sourceUrl,m_handlerLineno);
#else
Q_UNUSED(sourceUrl);
#endif
initScript();
//KJS::Constructor constr(KJS::Global::current().get("Function").imp());
KJS::Object constr = m_script->builtinFunction();
KJS::List args;
args.append(KJS::String("event"));
args.append(KJS::String(code));
Object handlerFunc = constr.construct(m_script->globalExec(), args); // ### is globalExec ok ?
return KJS::Window::retrieveWindow(m_part)->getJSEventListener(handlerFunc,true);
}
示例4: 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;
}
示例5: listFromVariantArgs
static KJS::List listFromVariantArgs(KJS::ExecState *exec, const NPVariant *args, unsigned argCount)
{
KJS::List aList;
unsigned i;
const NPVariant *v = args;
for (i = 0; i < argCount; i++) {
aList.append (convertNPVariantToValue (exec, v));
v++;
}
return aList;
}
示例6: QVBoxLayout
KateKJSWrapperConfigPage::KateKJSWrapperConfigPage(KJS::Object pageConstructor,PluginKateKJSWrapper* parent,
QWidget *parentWidget)
: Kate::PluginConfigPage( parentWidget ),m_plugin(parent)
{
QVBoxLayout *l=new QVBoxLayout(this);
l->setAutoAdd(true);
l->activate();
KJS::Interpreter *js = parent->m_part->interpreter();
KJS::ExecState *exec = js->globalExec();
exec->clearException();
KJS::List param;
param.append(parent->m_part->factory()->createProxy(exec,this,0));
m_pageObject=pageConstructor.construct(exec,param);
}
示例7:
static KMDI::ToolViewAccessor *createToolView(KJSEmbed::JSFactory *factory,KJS::Interpreter *js, Kate::MainWindow *winN,KJS::Object win,KJS::Object viewConstructor) {
KJS::List params;
KJS::ExecState *exec = js->globalExec();
params.append(win);
exec->clearException();
int dockPos;
if (!viewConstructor.implementsConstruct()) return 0;
KJS::Value dockPosV=viewConstructor.get(exec,KJS::Identifier("startPosition"));
if (exec->hadException()) {
dockPos=KDockWidget::DockLeft;
exec->clearException();
} else {
dockPos=dockPosV.toInteger(exec);
if (exec->hadException()) {
dockPos=KDockWidget::DockLeft;
exec->clearException();
}
}
QString viewName;
KJS::Value viewNameV=viewConstructor.get(exec,KJS::Identifier("name"));
if (exec->hadException()) {
viewName="kjs_unknown";
exec->clearException();
} else {
viewName=QString( viewNameV.toString(exec).qstring() );
if (exec->hadException()) {
viewName="kjs_unknown";
exec->clearException();
}
}
Kate::JS::ToolView *tv=new Kate::JS::ToolView(viewConstructor,exec,factory,params,viewName.utf8());
//params.append(factory->createProxy(exec,tv));
//KJS::Object otv=viewConstructor.construct(exec,params);
if (exec->hadException()) {
kdDebug()<<"Error while calling constructor"<<endl;
delete tv;
kdDebug()<<exec->exception().toString(exec).qstring()<<endl;
exec->clearException();
return 0;
}
KMDI::ToolViewAccessor *tva=winN->toolViewManager()->addToolView((KDockWidget::DockPosition)dockPos,tv,
tv->icon()?(*(tv->icon())):QPixmap(),tv->caption());
kdDebug()<<"****************************************************************************************"<<endl;
kdDebug()<<"PluginKateKJSWrapper: Toolview has been added"<<endl;
kdDebug()<<"****************************************************************************************"<<endl;
return tva;
}
示例8: fieldList
KJS::Value KstBindDataSource::fieldList(KJS::ExecState *exec, const KJS::List& args) {
Q_UNUSED(args)
KJS::List rc;
KstDataSourcePtr s = makeSource(_d);
if (!s) {
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
exec->setException(eobj);
return KJS::Object(exec->interpreter()->builtinArray().construct(exec, rc));
}
s->readLock();
QStringList l = s->fieldList();
s->unlock();
for (QStringList::ConstIterator i = l.begin(); i != l.end(); ++i) {
rc.append(KJS::String(*i));
}
return KJS::Object(exec->interpreter()->builtinArray().construct(exec, rc));
}
示例9: characters
bool SaxHandler::characters( const QString &chars )
{
if ( !jshandler.isValid() ) {
error = ErrorNoHandler;
return false;
}
KJS::Identifier funName("characters");
if ( !jshandler.hasProperty(exec, funName) )
return QXmlDefaultHandler::characters( chars );
KJS::Object fun = jshandler.get(exec, funName).toObject( exec );
if ( !fun.implementsCall() ) {
error = ErrorNotCallable;
return false;
}
KJS::List args;
args.append( KJS::String(chars) );
KJS::Value ret = fun.call( exec, jshandler, args );
return ret.toBoolean( exec );
}
示例10: qDebug
KJS::JSValue *KJSEmbed::convertToValue(KJS::ExecState *exec, const QVariant &value)
{
#ifdef KJSEMBED_VARIANT_DEBUG
qDebug() << "KJSEmbed::convertToValue typeid=" << value.type() << "typename=" << value.typeName() << "toString=" << value.toString();
#endif
KJS::JSValue *returnValue;
switch (value.type()) {
case QVariant::Invalid:
returnValue = KJS::jsNull();
break;
case QVariant::Int:
returnValue = KJS::jsNumber(value.value<int>());
break;
case QVariant::UInt:
returnValue = KJS::jsNumber(value.value<unsigned int>());
break;
case QVariant::LongLong:
returnValue = KJS::jsNumber(value.value<qlonglong>());
break;
case QVariant::ULongLong:
returnValue = KJS::jsNumber(value.value<qulonglong>());
break;
case QVariant::Double:
returnValue = KJS::jsNumber(value.value<double>());
break;
case QVariant::Bool:
returnValue = KJS::jsBoolean(value.value<bool>());
break;
case QVariant::ByteArray:
returnValue = KJS::jsString(QString(value.value<QByteArray>()));
break;
case QVariant::String:
returnValue = KJS::jsString(value.value<QString>());
break;
case QVariant::StringList: {
KJS::List items;
QStringList lst = value.value<QStringList>();
QStringList::Iterator idx = lst.begin();
for (; idx != lst.end(); ++idx) {
items.append(KJS::jsString((*idx)));
}
returnValue = exec->lexicalInterpreter()->builtinArray()->construct(exec, items);
break;
}
case QVariant::Date: // fall through
case QVariant::DateTime: // fall through
case QVariant::Time: {
QDateTime dt = QDateTime::currentDateTime();
if (value.type() == QVariant::Date) {
dt.setDate(value.toDate());
} else if (value.type() == QVariant::Time) {
dt.setTime(value.toTime());
} else {
dt = value.toDateTime();
}
KJS::List items;
items.append(KJS::jsNumber(dt.date().year()));
items.append(KJS::jsNumber(dt.date().month() - 1));
items.append(KJS::jsNumber(dt.date().day()));
items.append(KJS::jsNumber(dt.time().hour()));
items.append(KJS::jsNumber(dt.time().minute()));
items.append(KJS::jsNumber(dt.time().second()));
items.append(KJS::jsNumber(dt.time().msec()));
returnValue = exec->lexicalInterpreter()->builtinDate()->construct(exec, items);
break;
}
case QVariant::List: {
KJS::List items;
QList<QVariant> lst = value.toList();
foreach (const QVariant &item, lst) {
items.append(convertToValue(exec, item));
}
returnValue = exec->lexicalInterpreter()->builtinArray()->construct(exec, items);
break;
}
case QVariant::Map: {
QMap<QString, QVariant> map = value.toMap();
QMap<QString, QVariant>::Iterator idx = map.begin();
KJS::JSObject *obj = exec->lexicalInterpreter()->builtinObject()->construct(exec, KJS::List());
for (; idx != map.end(); ++idx) {
obj->put(exec, KJS::Identifier(toUString(idx.key())), convertToValue(exec, idx.value()));
}
returnValue = obj;
break;
}
default: {
if (value.canConvert< QWidget * >()) {
QWidget *widget = qvariant_cast< QWidget * >(value);
returnValue = widget ? createQObject(exec, widget, KJSEmbed::ObjectBinding::CPPOwned) : KJS::jsNull();
} else if (value.canConvert< QObject * >()) {
QObject *object = qvariant_cast< QObject * >(value);
returnValue = object ? createQObject(exec, object, KJSEmbed::ObjectBinding::CPPOwned) : KJS::jsNull();
} else {
returnValue = createVariant(exec, value.typeName(), value);
if (returnValue->isNull()) {
returnValue = KJS::jsString(value.value<QString>());
}
}
//.........这里部分代码省略.........
示例11: addView
void PluginKateKJSWrapper::addView(Kate::MainWindow *win)
{
PluginKateKJSWrapperView * view=getViewObject(win); // this is needed to ensure correct caching the javascript object
KJS::Interpreter *js = m_part->interpreter();
KJS::ExecState *exec = js->globalExec();
exec->clearException();
kdDebug()<<"****************************************************************************************"<<endl;
kdDebug()<<"PluginKateKJSWrapper::addView"<<endl;
kdDebug()<<"****************************************************************************************"<<endl;
kdDebug()<<"checking for newWindowHandler"<<endl;
if (!m_newWindowHandler.isNull()) {
KJS::List param;
param.append(view->winObj);
KJS::Object newWinFunc=m_newWindowHandler.toObject(exec);
if (exec->hadException()) {
exec->clearException();
} else {
if (newWinFunc.implementsCall()) {
newWinFunc.call(exec,js->globalObject(),param);
if (exec->hadException()) {
kdDebug()<<"Error while calling newWindowHandler"<<endl;
exec->clearException();
}
}
}
}
if (exec->hadException()) kdDebug()<<"void PluginKateKJSWrapper::addView(Kate::MainWindow *win): exec had an exception - 1"<<endl;
kdDebug()<<"checking for toolview constructors"<<endl;
if (! (m_toolViewConstructors.isNull() || (m_toolViewConstructors.type()==KJS::NullType))) {
KJS::Object constrs=m_toolViewConstructors.toObject(exec);
if (!exec->hadException()) {
if (QString(constrs.classInfo()->className)=="Array") {
kdDebug()<<"Toolview constructor array detected"<<endl;
int size=constrs.get(exec,KJS::Identifier("length")).toInteger(exec);
if (exec->hadException()) {
exec->clearException();
kdDebug()<<"Error while retrieving array length"<<endl;
}
else {
for (int i=0;i<size;i++) {
KJS::Object constrO=constrs.get(exec,i).toObject(exec);
if (exec->hadException()) {
exec->clearException();
} else {
KMDI::ToolViewAccessor *w=createToolView(m_part->factory(),js,win,view->winObj,constrO);
if (w) {
view->toolviews.append(QGuardedPtr<KMDI::ToolViewAccessor>(w));
}
exec->clearException();
}
}
}
} else {
kdDebug()<<"Single toolview constructor detected"<<endl;
if (!constrs.implementsConstruct()) {
kdWarning()<<"wrong object type"<<endl;
} else {
KMDI::ToolViewAccessor *w=createToolView(m_part->factory(),js,win,view->winObj,constrs);
if (w) {
view->toolviews.append(QGuardedPtr<KMDI::ToolViewAccessor>(w));
}
exec->clearException();
}
}
}
} else kdDebug()<<"void PluginKateKJSWrapper::addView(Kate::MainWindow *win): no toolview constructors"<<endl;
if (exec->hadException()) kdDebug()<<"void PluginKateKJSWrapper::addView(Kate::MainWindow *win): exec had an exception - 2"<<endl;
view->setInstance (new KInstance("kate"));
view->setXMLFile(QString("plugins/%1/%2.rc").arg(m_scriptname).arg(m_scriptname));
win->guiFactory()->addClient (view);
}
示例12: slotResult
void KSVGLoader::slotResult(KIO::Job *job)
{
if(job == m_job)
{
if(m_job->error() == 0)
{
QString check = static_cast<KIO::TransferJob *>(job)->url().prettyURL();
if(check.contains(".svgz") || check.contains(".svg.gz"))
{
// decode the gzipped svg and emit it
QIODevice *dev = KFilterDev::device(new QBuffer(m_data), "application/x-gzip");
dev->open(IO_ReadOnly);
emit gotResult(dev);
}
else
{
m_job = 0;
emit gotResult(new QBuffer(m_data));
m_data.resize(0);
}
}
}
else if(m_postUrlData.job == job)
{
// Notify that we're done
KJS::List callBackArgs;
callBackArgs.append(*m_postUrlData.status);
m_postUrlData.status->put(m_postUrlData.exec, KJS::Identifier("success"), KJS::Boolean(true));
m_postUrlData.callBackFunction->call(m_postUrlData.exec, *m_postUrlData.callBackFunction, callBackArgs);
}
else
{
QMap<KIO::TransferJob *, ImageStreamMap *>::Iterator it;
for(it = m_imageJobs.begin(); it != m_imageJobs.end(); ++it)
{
if(it.key() == job)
{
ImageStreamMap *streamMap = it.data();
QBuffer buffer(*(streamMap->data));
if(buffer.open(IO_ReadOnly))
{
const char *imageFormat = QImageIO::imageFormat(&buffer);
if(imageFormat != 0)
{
QImageIO imageIO(&buffer, imageFormat);
// Gamma correction
imageIO.setGamma(1/0.45454);
if(imageIO.read())
{
QImage *image = new QImage(imageIO.image());
image->detach();
(streamMap->imageElement)->setImage(image);
}
}
buffer.close();
}
(streamMap->data)->resize(0);
m_imageJobs.remove(static_cast<KIO::TransferJob *>(job));
emit imageReady(streamMap->imageElement);
break;
}
}
}
}
示例13: convertArguments
KJS::List SlotProxy::convertArguments(KJS::ExecState *exec, void **_a)
{
KJS::List args;
int offset = metaObject()->indexOfMethod(m_signature.constData());
QMetaMethod method = metaObject()->method(offset);
QList<QByteArray> params = method.parameterTypes();
int idx = 1;
#ifdef DEBUG_SLOTPROXY
qDebug() << "SlotProxy::convertArguments(): obj=" << this << " m_signature=" << m_signature << " offset=" << offset << " params=" << params;
#endif
foreach (const QByteArray ¶m, params) {
#ifdef DEBUG_SLOTPROXY
int type = QMetaType::type(param.constData());
qDebug("\tGot a %d - %s - _a[%d] = %p", type, param.data(), idx, _a[idx]);
qDebug("\t QMetaType::type()=%d", QMetaType::type(QByteArray("Pinya::") + param.constData()));
#endif
int tp = QVariant::nameToType(param.constData());
switch (tp) {
case QVariant::Int:
args.append(KJS::jsNumber(*(int *)_a[idx]));
break;
case QVariant::UInt:
args.append(KJS::jsNumber(*(uint *)_a[idx]));
break;
case QVariant::LongLong:
args.append(KJS::jsNumber(*(qlonglong *)_a[idx]));
break;
case QVariant::ULongLong:
args.append(KJS::jsNumber(*(qulonglong *)_a[idx]));
break;
case QVariant::Double:
args.append(KJS::jsNumber(*(double *)_a[idx]));
break;
case QVariant::Bool:
args.append(KJS::jsBoolean(*(bool *)_a[idx]));
break;
case QVariant::String:
args.append(KJS::jsString((*reinterpret_cast<QString(*)>(_a[idx]))));
break;
case QVariant::UserType: {
KJS::JSObject *returnValue;
KJS::JSObject *parent = exec->dynamicInterpreter()->globalObject();
QByteArray typeName = param.constData();
bool isPtr = typeName.contains("*");
if (isPtr) {
typeName.replace("*", ""); //krazy:exclude=doublequote_chars
}
#ifdef DEBUG_SLOTPROXY
qDebug() << "\tQVariant::UserType: typeName=" << typeName << " param=" << param.constData() << " isPtr" << isPtr;
#endif
if (parent->hasProperty(exec, KJS::Identifier(toUString(typeName)))) {
QObject *qObj;
if (isPtr &&
((qObj = *reinterpret_cast<QObject **>(_a[idx])) != 0)) {
#ifdef DEBUG_SLOTPROXY
qDebug() << "qObj=" << qObj;
#endif
Pointer<QObject> pov(*reinterpret_cast<QObject*(*)>(_a[idx]));
returnValue = StaticConstructor::bind(exec, typeName, pov);
if (returnValue) {
args.append(returnValue);
break;
} else {
#ifdef DEBUG_SLOTPROXY
qDebug("\t\tNo binding retrieved");
#endif
returnValue = StaticConstructor::construct(exec, parent, toUString(typeName));
if (returnValue) {
if (QObjectBinding *objImp = KJSEmbed::extractBindingImp<QObjectBinding>(exec, returnValue)) {
#ifdef DEBUG_SLOTPROXY
qDebug() << "\t\t\tFound QObjectBinding";
#endif
objImp->setOwnership(KJSEmbed::ObjectBinding::JSOwned);
objImp->setObject(qObj);
if (qObj->parent() != 0) {
objImp->setOwnership(KJSEmbed::ObjectBinding::QObjOwned);
} else {
objImp->setOwnership(KJSEmbed::ObjectBinding::CPPOwned);
}
args.append(returnValue);
break;
}
}
}
}
} else {
#ifdef DEBUG_SLOTPROXY
qDebug("\t\tNo binding registered");
#endif
KJS::JSObject *returnValue = 0;
const int metaTypeId = QMetaType::type(param.constData());
if (QMetaType::typeFlags(metaTypeId) & QMetaType::PointerToQObject) {
QObject *obj = (*reinterpret_cast< QObject*(*)>(_a[idx]));
returnValue = KJSEmbed::createQObject(exec, obj, KJSEmbed::ObjectBinding::QObjOwned);
}
if (returnValue) {
args.append(returnValue);
break;
}
}
//.........这里部分代码省略.........