bool XLIFFHandler::endElement(const QString& namespaceURI, const QString& localName, const QString& /*qName*/ ) { if (namespaceURI == m_URI || namespaceURI == m_URI12) { if (localName == QLatin1String("xliff")) { popContext(XC_xliff); } else if (localName == QLatin1String("source")) { m_source = accum; } else if (localName == QLatin1String("target")) { translations.append(accum); } else if (localName == QLatin1String("context-group")) { popContext(XC_context_group); } else if (currentContext() == XC_context_linenumber && localName == QLatin1String("context")) { bool ok; m_lineNumber = accum.trimmed().toInt(&ok); if (!ok) m_lineNumber = -1; popContext(XC_context_linenumber); } else if (localName == QLatin1String("note")) { m_comment = accum; } else if (localName == QLatin1String("ph")) { m_ctype.clear(); popContext(XC_ph); } else if (localName == QLatin1String("trans-unit")) { if (!hasContext(XC_restype_plurals)) { tor->insert( TranslatorMessage(m_context.toUtf8(), m_source.toUtf8(), m_comment.toUtf8(), "", m_fileName, m_lineNumber, translations, true, m_type, false) ); translations.clear(); m_lineNumber = -1; } } else if (localName == QLatin1String("group")) { if (hasContext(XC_restype_plurals)) { tor->insert( TranslatorMessage(m_context.toUtf8(), m_source.toUtf8(), m_comment.toUtf8(), "", m_fileName, m_lineNumber, translations, true, m_type, true) ); popContext(XC_restype_plurals); translations.clear(); m_lineNumber = -1; } popContext(XC_group); } return true; } return false; }
void HeadlessBackend::createContext() { assert(!hasContext()); static const char* argv[] = { "mbgl" }; static int argc = 1; static auto* app = new QApplication(argc, const_cast<char**>(argv)); Q_UNUSED(app); impl.reset(new QtImpl); }
std::vector<float> WGLWidget::JavaScriptVector::value() const { if (!hasContext()) throw WException("JavaScriptVector: vector not assigned to a WGLWidget"); for (unsigned i = 0; i < context_->jsVectorList_.size(); i++) { if (context_->jsVectorList_[i].id == id_) { return context_->jsVectorList_[i].serverSideCopy; } } std::vector<float> result; for (unsigned i = 0; i < length(); ++i) { result.push_back(0.0f); } return result; }
void HeadlessBackend::createContext() { assert(!hasContext()); CGLContextObj glContext = nullptr; CGLError error = CGLCreateContext(display->attribute<CGLPixelFormatObj>(), nullptr, &glContext); if (error != kCGLNoError) { throw std::runtime_error(std::string("Error creating GL context object:") + CGLErrorString(error) + "\n"); } error = CGLEnable(glContext, kCGLCEMPEngine); if (error != kCGLNoError) { throw std::runtime_error(std::string("Error enabling OpenGL multithreading:") + CGLErrorString(error) + "\n"); } impl.reset(new CGLImpl(glContext)); }
void Host::processEvents(uint32 timeout) { if( !hasContext() ) return; ENetEvent event; while(enet_host_service(host, &event, timeout) > 0) { switch(event.type) { case ENET_EVENT_TYPE_CONNECT: handleConnectEvent(&event); break; case ENET_EVENT_TYPE_DISCONNECT: handleDisconnectEvent(&event); break; case ENET_EVENT_TYPE_RECEIVE: handleReceiveEvent(&event); break; }; } }
// ---------------------------------------------------------------------------- // TextLanguage::loadZScript // // Loads types (classes) and functions from parsed ZScript definitions [defs] // ---------------------------------------------------------------------------- void TextLanguage::loadZScript(ZScript::Definitions& defs, bool custom) { // Classes for (auto& c : defs.classes()) { // Add class as type addWord(Type, c.name(), custom); // Add class functions for (auto& f : c.functions()) { // Ignore overriding functions if (f.isOverride()) continue; // Check if the function exists auto func = function(f.name()); // If it doesn't, create it if (!func) { functions_.push_back(TLFunction(f.name())); func = &functions_.back(); } // Add the context if (!func->hasContext(c.name())) func->addContext( c.name(), f, custom, zfuncs_ex_props_[func->name()].description, zfuncs_ex_props_[func->name()].deprecated_f); } } }
WMatrix4x4 WGLWidget::JavaScriptMatrix4x4::value() const { if (!hasContext()) throw WException("JavaScriptMatrix4x4: matrix not assigned to a WGLWidget"); WMatrix4x4 originalCpy; for (unsigned i = 0; i<context_->jsMatrixList_.size(); i++) if (context_->jsMatrixList_[i].id == id_) originalCpy = context_->jsMatrixList_[i].serverSideCopy; // apply all operations int nbMult = 0; for (unsigned i = 0; i<operations_.size(); i++) { switch (operations_[i]) { case op::TRANSPOSE: originalCpy = originalCpy.transposed(); break; case op::INVERT: #ifndef WT_TARGET_JAVA originalCpy = #endif originalCpy.inverted(); break; case op::MULTIPLY: #ifndef WT_TARGET_JAVA originalCpy = originalCpy * matrices_[nbMult]; #else originalCpy.mul(matrices_[nbMult]); #endif nbMult++; break; } } return originalCpy; }
bool XLIFFHandler::endElement(const QString &namespaceURI, const QString& localName, const QString &qName) { Q_UNUSED(qName); if (namespaceURI == m_URITT) { if (hasContext(XC_trans_unit) || hasContext(XC_restype_plurals)) m_extra[localName] = accum; else m_translator.setExtra(localName, accum); return true; } if (namespaceURI != m_URI && namespaceURI != m_URI12) return false; //qDebug() << "URI:" << namespaceURI << "QNAME:" << qName; if (localName == QLatin1String("xliff")) { popContext(XC_xliff); } else if (localName == QLatin1String("source")) { if (hasContext(XC_alt_trans)) { if (m_isPlural && m_oldSources.isEmpty()) m_oldSources.append(QString()); m_oldSources.append(accum); m_hadAlt = true; } else { m_sources.append(accum); } } else if (localName == QLatin1String("target")) { if (popContext(XC_restype_translation)) { accum.replace(QChar(Translator::TextVariantSeparator), QChar(Translator::BinaryVariantSeparator)); m_translations.append(accum); } } else if (localName == QLatin1String("context-group")) { if (popContext(XC_context_group)) { m_refs.append(TranslatorMessage::Reference( m_extraFileName.isEmpty() ? m_fileName : m_extraFileName, m_lineNumber)); m_extraFileName.clear(); m_lineNumber = -1; } else { popContext(XC_context_group_any); } } else if (localName == QLatin1String("context")) { if (popContext(XC_context_linenumber)) { bool ok; m_lineNumber = accum.trimmed().toInt(&ok); if (!ok) m_lineNumber = -1; } else if (popContext(XC_context_filename)) { m_extraFileName = accum; } else if (popContext(XC_context_comment)) { m_comment = accum; } else if (popContext(XC_context_old_comment)) { m_oldComment = accum; } } else if (localName == QLatin1String("note")) { if (popContext(XC_extra_comment)) m_extraComment = accum; else if (popContext(XC_translator_comment)) m_translatorComment = accum; } else if (localName == QLatin1String("ph")) { m_ctype.clear(); popContext(XC_ph); } else if (localName == QLatin1String("trans-unit")) { popContext(XC_trans_unit); if (!m_hadAlt) m_oldSources.append(QString()); if (!hasContext(XC_restype_plurals)) { if (!finalizeMessage(false)) return false; } } else if (localName == QLatin1String("alt-trans")) { popContext(XC_alt_trans); } else if (localName == QLatin1String("group")) { if (popContext(XC_restype_plurals)) { if (!finalizeMessage(true)) return false; } else if (popContext(XC_restype_context)) { m_context.clear(); } else { popContext(XC_group); } } return true; }
bool XLIFFHandler::startElement(const QString& namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts ) { Q_UNUSED(qName); if (namespaceURI == m_URITT) goto bail; if (namespaceURI != m_URI && namespaceURI != m_URI12) return false; if (localName == QLatin1String("xliff")) { // make sure that the stack is not empty during parsing pushContext(XC_xliff); } else if (localName == QLatin1String("file")) { m_fileName = atts.value(QLatin1String("original")); m_language = atts.value(QLatin1String("target-language")); m_language.replace(QLatin1Char('-'), QLatin1Char('_')); m_sourceLanguage = atts.value(QLatin1String("source-language")); m_sourceLanguage.replace(QLatin1Char('-'), QLatin1Char('_')); if (m_sourceLanguage == QLatin1String("en")) m_sourceLanguage.clear(); } else if (localName == QLatin1String("group")) { if (atts.value(QLatin1String("restype")) == QLatin1String(restypeContext)) { m_context = atts.value(QLatin1String("resname")); pushContext(XC_restype_context); } else { if (atts.value(QLatin1String("restype")) == QLatin1String(restypePlurals)) { pushContext(XC_restype_plurals); m_id = atts.value(QLatin1String("id")); if (atts.value(QLatin1String("translate")) == QLatin1String("no")) m_type = TranslatorMessage::Obsolete; } else { pushContext(XC_group); } } } else if (localName == QLatin1String("trans-unit")) { if (!hasContext(XC_restype_plurals) || m_sources.isEmpty() /* who knows ... */) if (atts.value(QLatin1String("translate")) == QLatin1String("no")) m_type = TranslatorMessage::Obsolete; if (!hasContext(XC_restype_plurals)) { m_id = atts.value(QLatin1String("id")); if (m_id.startsWith(QLatin1String("_msg"))) m_id.clear(); } if (m_type != TranslatorMessage::Obsolete && atts.value(QLatin1String("approved")) != QLatin1String("yes")) m_type = TranslatorMessage::Unfinished; pushContext(XC_trans_unit); m_hadAlt = false; } else if (localName == QLatin1String("alt-trans")) { pushContext(XC_alt_trans); } else if (localName == QLatin1String("source")) { m_isPlural = atts.value(QLatin1String(attribPlural)) == QLatin1String("yes"); } else if (localName == QLatin1String("target")) { if (atts.value(QLatin1String("restype")) != QLatin1String(restypeDummy)) pushContext(XC_restype_translation); } else if (localName == QLatin1String("context-group")) { QString purpose = atts.value(QLatin1String("purpose")); if (purpose == QLatin1String("location")) pushContext(XC_context_group); else pushContext(XC_context_group_any); } else if (currentContext() == XC_context_group && localName == QLatin1String("context")) { QString ctxtype = atts.value(QLatin1String("context-type")); if (ctxtype == QLatin1String("linenumber")) pushContext(XC_context_linenumber); else if (ctxtype == QLatin1String("sourcefile")) pushContext(XC_context_filename); } else if (currentContext() == XC_context_group_any && localName == QLatin1String("context")) { QString ctxtype = atts.value(QLatin1String("context-type")); if (ctxtype == QLatin1String(contextMsgctxt)) pushContext(XC_context_comment); else if (ctxtype == QLatin1String(contextOldMsgctxt)) pushContext(XC_context_old_comment); } else if (localName == QLatin1String("note")) { if (atts.value(QLatin1String("annotates")) == QLatin1String("source") && atts.value(QLatin1String("from")) == QLatin1String("developer")) pushContext(XC_extra_comment); else pushContext(XC_translator_comment); } else if (localName == QLatin1String("ph")) { QString ctype = atts.value(QLatin1String("ctype")); if (ctype.startsWith(QLatin1String("x-ch-"))) m_ctype = ctype.mid(5); pushContext(XC_ph); } bail: if (currentContext() != XC_ph) accum.clear(); return true; }