ScopeChain QSFuncRefClass::refScope( const QSObject &ref ) { if( ref.isFunction() ) { return ( (QSReferenceData*) ref.shVal() )->context; } qWarning( "QSFuncRefClass::refScope() - not a reference" ); return ScopeChain(); }
QSObject QSFuncRefClass::refBase( const QSObject &ref ) { if( ref.isFunction() ) { return ( (QSReferenceData*) ref.shVal() )->base; } qWarning( "QSFuncRefClass::refBase() - not a reference" ); return ref.env()->createUndefined(); }
QSMember QSFuncRefClass::refMember( const QSObject &ref ) { if( ref.isFunction() ) { return ( (QSReferenceData*) ref.shVal() )->member; } qWarning( "QSFuncRefClass::refMember() - not a reference" ); return QSMember(); }
QSArgument QuickInterpreter::convertToArgument( const QSObject &o ) { if( !o.isValid() ) return QSArgument(); const QSClass *cl = o.objectType(); if( cl->name() == QString::fromLatin1("QObject") ) { QSWrapperShared *shared = (QSWrapperShared*) o.shVal(); if (shared->objects.isEmpty()) return QSArgument(); return QSArgument( shared->objects[0] ); } else if( cl == ptrClass ) { Q_ASSERT( ptrClass->pointer( &o ) ); return QSArgument( ptrClass->pointer( &o ) ); } else { return QSArgument( o.toVariant( QVariant::Invalid ) ); } }
QVariant QuickInterpreter::convertToArgument(const QSObject &o) { if(!o.isValid()) return QVariant(); const QSClass *cl = o.objectType(); if(cl->name() == QString::fromLatin1("QObject")) { QSWrapperShared *shared = (QSWrapperShared*) o.shVal(); if (shared->objects.isEmpty()) return QVariant(); QVariant v(QMetaType::QObjectStar, static_cast<QObject *>(0)); qVariantSetValue<QObject *>(v, shared->objects[0]); return v; } else if(cl == ptrClass) { Q_ASSERT(ptrClass->pointer(&o)); QVariant v(QMetaType::VoidStar, static_cast<void *>(0)); qVariantSetValue<void *>(v, ptrClass->pointer(&o)); return v; } else { return QVariant(o.toVariant(QVariant::Invalid)); } }
void QSAEditor::doObjectCompletion() { QTextCursor cursor = textCursor(); cursor.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor); QString objectName = cursor.selectedText(); if (objectName.endsWith(QLatin1Char('-'))) objectName.chop(1); objectName = objectName.simplified(); QString object = resolveFullyQualifiedValue(objectName, parseAssignments(functionCode())); bool assumedStatic = false; QSCompletionObject o; if(objectName == object) { QSObject stobj = env()->globalObject().get(object); if(stobj.isValid() && stobj.objectType()->valueType() == TypeClass) { #if defined ( QSA_COMPLETION_DEBUG ) printf(" -> assuming static\n"); #endif o = stobj; assumedStatic = true; } } if(o.type == QSCompletionObject::TNull) { o = queryObject(object); } #if defined ( QSA_COMPLETION_DEBUG ) printf(" -> type is: %d\n", o.type); #endif o.resolve(); if (o.isNull()) return; QVector<CompletionEntry> res; QSObject nullObject; switch (o.type) { case QSCompletionObject::TQSObject: #if defined ( QSA_COMPLETION_DEBUG ) printf(" -> objectType is: %s\n", o.qsobj.objectType()->name().latin1()); #endif if(o.qsobj.objectType()->name() == QString::fromLatin1("FactoryObject")){ QSObject sinst = ( (QSFactoryObjectProxy*) o.qsobj.objectType() )->staticInstance(); if(!sinst.isValid()) return; QSWrapperShared *shared = (QSWrapperShared*) sinst.shVal(); completeQObject( shared->objects, object, res ); break; } completeQSObject(o.qsobj, res, !assumedStatic); break; case QSCompletionObject::TQMetaObject: completeQMetaObject(o.meta, object, res, IncludeSuperClass, nullObject); break; case QSCompletionObject::TQObject: completeQObject(o.qobj, object, res); break; case QSCompletionObject::TNull: break; } if (!res.isEmpty()) { QFrame *f = new QFrame(0, Qt::Popup); f->setAttribute(Qt::WA_DeleteOnClose); QWidget *box = new CompletionBox(this, res); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(box); layout->setMargin(0); f->setLayout(layout); f->move(mapToGlobal(cursorRect().bottomLeft())); f->show(); box->setFocus(); } }
QRegExp* QSRegExpClass::regExp( QSEnv *e ) { QSObject t = e->thisValue(); Q_ASSERT( t.isA( e->regexpClass() ) ); return &((QSRegExpShared*)t.shVal())->reg; }