/*! \internal Pops a query off the queries list, performs a blocking call to QHostInfoAgent::lookupHost(), and emits the resultsReady() signal. This process repeats until the queries list is empty. */ void QHostInfoAgent::run() { #ifndef QT_NO_THREAD // Dont' allow thread termination during event delivery, but allow it // during the actual blocking host lookup stage. setTerminationEnabled(false); forever #endif { QHostInfoQuery *query; { #ifndef QT_NO_THREAD // the queries list is shared between threads. lock all // access to it. QMutexLocker locker(&mutex); if (!quit && queries.isEmpty()) cond.wait(&mutex); if (quit) { // Reset the quit variable in case QCoreApplication is // destroyed and recreated. quit = false; break; } if (queries.isEmpty()) continue; #else if (queries.isEmpty()) return; #endif query = queries.takeFirst(); pendingQueryId = query->object->lookupId; } #if defined(QHOSTINFO_DEBUG) qDebug("QHostInfoAgent::run(%p): looking up \"%s\"", this, query->hostName.toLatin1().constData()); #endif #ifndef QT_NO_THREAD // Start query - allow termination at this point, but not outside. We // don't want to all termination during event delivery, but we don't // want the lookup to prevent the app from quitting (the agent // destructor terminates the thread). setTerminationEnabled(true); #endif QHostInfo info = fromName(query->hostName); #ifndef QT_NO_THREAD setTerminationEnabled(false); #endif int id = query->object->lookupId; info.setLookupId(id); if (pendingQueryId == id) query->object->emitResultsReady(info); delete query; } }
int fromName(const std::string& name) { int i=0; while (names[i].name != NULL && name != names[i].name) ++i; if (names[i].name != NULL) return names[i].t; else if (name.substr(0,7)=="String<") { int n = 0; sscanf(name.c_str(), "String<%d>", &n); return buildString(n); } else if (name.substr(0,4)=="Mat<") { int nx = 0; int ny = 0; int pos = 8; sscanf(name.c_str(), "Mat<%d,%d,%n", &ny,&nx,&pos); int elem = fromName(name.substr(pos,name.length()-1-pos)); return matrix(elem, nx, ny); } else if (name.substr(0,4)=="Vec<") { int nx = 0; int pos = 8; sscanf(name.c_str(), "Vec<%d,%n", &nx,&pos); int elem = fromName(name.substr(pos,name.length()-1-pos)); return vector(elem, nx); } else if (name.substr(0,2)=="0x") { int t = 0; sscanf(name.c_str(), "0x%x", &t); return t; } else { std::cerr << "ERROR converting type from name "<<name<<std::endl; return Null; } }
bool FunctionMergePass::visitInitVar(InitVarExpr * from, InitVarExpr * to) { VariableDefn * fromVar = from->var(); VariableDefn * toVar = to->var(); StringRef fromName(fromVar->name()); if (!fromName.equals(toVar->name())) { reportDifference("Difference in variable name", fromVar, toVar); return false; } if (fromVar->type()->typeClass() != toVar->type()->typeClass()) { reportDifference("Difference in variable type", fromVar, toVar); return false; } // For now, we only support reference types. if (fromVar->type() != toVar->type()) { if (!fromVar->type()->isReferenceType()) { reportDifference("Non-reference type", fromVar, toVar); return false; } } return visitExpr(from->initExpr(), to->initExpr()); }
QHostInfo QHostInfoAgent::fromName(const QString &hostName) { // null shared pointer QSharedPointer<QNetworkSession> networkSession; return fromName(hostName, networkSession); }
/** * @brief Constructs a new AwsRegion object. * * If \p regionName is not recognised as a valid AWS region, AwsRegion::isValid * will return `false` for the created object. * * @param regionName Name of the AWS region for this object to represent. */ AwsRegion::AwsRegion(const QString ®ionName) : d_ptr(new AwsRegionPrivate(this)) { Q_D(AwsRegion); d->region = fromName(regionName); }
int main() { parse(); fromName(); return 0; }