void LayoutParser::parseLayout() { static const QStringList typeValues(QString::fromLatin1("general,url,email,number,phonenumber,common").split(',')); static const QStringList orientationValues(QString::fromLatin1("landscape,portrait").split(',')); const QXmlStreamAttributes attributes(m_xml.attributes()); const TagLayout::LayoutType type(enumValue("type", typeValues, TagLayout::General)); const TagLayout::LayoutOrientation orientation(enumValue("orientation", orientationValues, TagLayout::Landscape)); const bool uniform_font_size(boolValue(attributes.value(QLatin1String("uniform-font-size")), false)); TagLayoutPtr new_layout(TagLayoutPtr(new TagLayout(type, orientation, uniform_font_size))); m_keyboard->appendLayout(new_layout); bool found_section(false); while (m_xml.readNextStartElement()) { const QStringRef name(m_xml.name()); if (name == QLatin1String("section")) { found_section = true; parseSection(new_layout); } else { error(QString::fromLatin1("Expected '<section>', but got '<%1>'.").arg(name.toString())); } } if (not found_section) { error(QString::fromLatin1("Expected '<section>'.")); } }
SEXP InstanceObjectTable::get(const char * name, Rboolean* canCache) const { SEXP ans = R_UnboundValue; checkInstance(); if (canCache) *canCache = TRUE; if (_internal) { if (!qstrcmp(name, "this")) ans = _instance->internalSexp(R_EmptyEnv); else if (!qstrcmp(name, "super")) ans = superClosure(); else ans = findVarInFrame(fieldEnv(), install(name)); if (ans == R_UnboundValue) ans = enumValue(name); } if (ans == R_UnboundValue) { Property *prop = _instance->klass()->property(name); if (prop) { // FIXME: throw error if not readable? if (prop->isReadable()) ans = prop->read(_instance->sexp()); delete prop; } } if (ans == R_UnboundValue && methodExists(name)) ans = methodClosure(name); // make a wrapper for method return ans; }
LONG TSHReg::EnumValue(HKEY hkey, DWORD dwIndex, LPTSTR pszValueName, LPDWORD pcchValueName, LPDWORD pdwType, LPVOID pvData, LPDWORD pcbData) { static TModuleProc7<LONG,HKEY,DWORD,LPTSTR,LPDWORD,LPDWORD,LPVOID,LPDWORD> enumValue(GetModule(), EnumValueStr); return enumValue(hkey, dwIndex, pszValueName, pcchValueName, pdwType, pvData, pcbData); }
void LayoutParser::parseModifiers(const TagBindingPtr &binding) { static const QStringList keys_values(QString::fromLatin1("alt,shift,altshift").split(',')); const QXmlStreamAttributes attributes(m_xml.attributes()); const TagModifiers::Keys keys(enumValue("keys", keys_values, TagModifiers::Shift)); TagModifiersPtr new_modifiers(new TagModifiers(keys)); binding->appendModifiers(new_modifiers); while (m_xml.readNextStartElement()) { const QStringRef name(m_xml.name()); if (name == QLatin1String("binding")) { if (not new_modifiers->binding()) { parseBinding(new_modifiers); } else { error(QString::fromLatin1("Expected only one '<binding>', but got another one.")); } } else { error(QString::fromLatin1("Expected '<binding>', but got '<%1>'.").arg(name.toString())); } } if (not new_modifiers->binding()) { error(QString::fromLatin1("Expected exactly one '<binding>', but got none.")); } }
void LayoutParser::parseKey(const TagRowPtr &row) { static const QStringList styleValues(QString::fromLatin1("normal,special,deadkey").split(',')); static const QStringList widthValues(QString::fromLatin1("small,medium,large,x-large,xx-large,stretched").split(',')); const QXmlStreamAttributes attributes(m_xml.attributes()); const TagKey::Style style(enumValue("style", styleValues, TagKey::Normal)); const TagKey::Width width(enumValue("width", widthValues, TagKey::Medium)); const bool rtl(boolValue(attributes.value(QLatin1String("rtl")), false)); const QString id(attributes.value(QLatin1String("id")).toString()); TagKeyPtr new_key(new TagKey(style, width, rtl, id)); row->appendElement(new_key); while (m_xml.readNextStartElement()) { const QStringRef name(m_xml.name()); if (name == QLatin1String("binding")) { if (not new_key->binding()) { parseBinding(new_key); } else { error(QString::fromLatin1("Expected only one '<binding>', but got another one.")); } } else if (name == QLatin1String("extended")) { if (not new_key->extended()) { parseExtended(new_key); } else { error(QString::fromLatin1("Expected only one '<extended>', but got another one.")); } } else { error(QString::fromLatin1("Expected '<binding>' or '<extended>', but got '<%1>'.").arg(name.toString())); } } if (not new_key->binding()) { error(QString::fromLatin1("Expected exactly one '<binding>' but got none.")); } }
Rboolean InstanceObjectTable::exists(const char * name, Rboolean *canCache) const { bool found = FALSE; checkInstance(); if (canCache) *canCache = TRUE; if (_internal) found = !qstrcmp(name, "this") || findVarInFrame(fieldEnv(), install(name)) != R_UnboundValue || enumValue(name) != R_UnboundValue; if (!found) found = methodExists(name); if (!found) { Property *prop = _instance->klass()->property(name); if (prop) { found = true; delete prop; } } return (Rboolean)found; }
void LayoutParser::parseRow(const TagRowContainerPtr &row_container) { static const QStringList heightValues(QString::fromLatin1("small,medium,large,x-large,xx-large").split(',')); const TagRow::Height height(enumValue("height", heightValues, TagRow::Medium)); TagRowPtr new_row(new TagRow(height)); row_container->appendRow (new_row); while (m_xml.readNextStartElement()) { const QStringRef name(m_xml.name()); if (name == QLatin1String("key")) { parseKey(new_row); } else if (name == QLatin1String("spacer")) { parseSpacer(new_row); } else { error(QString::fromLatin1("Expected '<key>' or '<spacer>', but got '<%1>'.").arg(name.toString())); } } }
void LayoutParser::parseBinding(const TagBindingContainerPtr &binding_container) { static const QStringList actionValues(QString::fromLatin1( "insert,shift,backspace,space,cycle,layout_menu,sym,return,commit," "decimal_separator,plus_minus_toggle,switch,on_off_toggle,compose," "left,up,right,down,close,tab,dead,left-layout,right-layout,command" ).split(',')); Q_ASSERT(actionValues.count() == Key::NumActions); const QXmlStreamAttributes attributes(m_xml.attributes()); const TagBinding::Action action(enumValue("action", actionValues, TagBinding::Insert)); const QString label(attributes.value(QLatin1String("label")).toString()); const QString secondary_label(attributes.value(QLatin1String("secondary_label")).toString()); const QString accents(attributes.value(QLatin1String("accents")).toString()); const QString accented_labels(attributes.value(QLatin1String("accented_labels")).toString()); const QString cycleset(attributes.value(QLatin1String("cycleset")).toString()); const QString sequence(attributes.value(QLatin1String("sequence")).toString()); const QString icon(attributes.value(QLatin1String("icon")).toString()); const bool dead(boolValue(attributes.value(QLatin1String("dead")), false)); const bool quick_pick(boolValue(attributes.value(QLatin1String("quick_pick")), false)); const bool rtl(boolValue(attributes.value(QLatin1String("rtl")), false)); const bool enlarge(boolValue(attributes.value(QLatin1String("enlarge")), false)); TagBindingPtr new_binding(new TagBinding(action, label, secondary_label, accents, accented_labels, cycleset, sequence, icon, dead, quick_pick, rtl, enlarge)); binding_container->setBinding(new_binding); while (m_xml.readNextStartElement()) { const QStringRef name(m_xml.name()); if (name == QLatin1String("modifiers")) { parseModifiers(new_binding); } else { error(QString::fromLatin1("Expected '<modifiers>', but got '<%1>'.").arg(name.toString())); } } }
void LayoutParser::parseSection(const TagLayoutPtr &layout) { static const QStringList typeValues(QString::fromLatin1("sloppy,non-sloppy").split(',')); const QXmlStreamAttributes attributes(m_xml.attributes()); const QString id(attributes.value(QLatin1String("id")).toString()); const bool movable(boolValue(attributes.value(QLatin1String("movable")), true)); const TagSection::SectionType type(enumValue("type", typeValues, TagSection::Sloppy)); const QString style(attributes.value(QLatin1String("style")).toString()); if (id.isEmpty()) { error("Expected non-empty 'id' attribute in '<section>'."); return; } TagSectionPtr new_section(new TagSection(id, movable, type, style)); layout->appendSection(new_section); bool found_row(false); while (m_xml.readNextStartElement()) { const QStringRef name(m_xml.name()); if (name == QLatin1String("row")) { parseRow(new_section); found_row = true; } else { error(QString::fromLatin1("Expected '<row>', but got '<%1>'.").arg(name.toString())); } } if (not found_row) { error(QString::fromLatin1("Expected '<row>'.")); } }