aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib/language
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2019-02-19 22:16:04 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2019-02-25 15:58:40 +0000
commit0876dc4d6abb147ccdcc190adfad01c704a73e61 (patch)
treee8a1d558827e2a9e4092600cbe1a2029895d9f99 /src/lib/corelib/language
parente160b26d8c7476c63f6220ac69d1d6405e8ce3aa (diff)
Use QStringLiteral more where it is possible
Change-Id: I7419cc3fbc1e8776de3943852dcedab4c95d1c32 Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/lib/corelib/language')
-rw-r--r--src/lib/corelib/language/builtindeclarations.cpp50
-rw-r--r--src/lib/corelib/language/evaluatorscriptclass.cpp4
-rw-r--r--src/lib/corelib/language/filetags.cpp2
-rw-r--r--src/lib/corelib/language/item.cpp12
-rw-r--r--src/lib/corelib/language/moduleloader.cpp22
-rw-r--r--src/lib/corelib/language/projectresolver.cpp4
-rw-r--r--src/lib/corelib/language/propertydeclaration.cpp2
-rw-r--r--src/lib/corelib/language/scriptengine.cpp66
8 files changed, 81 insertions, 81 deletions
diff --git a/src/lib/corelib/language/builtindeclarations.cpp b/src/lib/corelib/language/builtindeclarations.cpp
index 3ca0608d4..34cd497da 100644
--- a/src/lib/corelib/language/builtindeclarations.cpp
+++ b/src/lib/corelib/language/builtindeclarations.cpp
@@ -62,26 +62,26 @@ const char QBS_LANGUAGE_VERSION[] = "1.0";
BuiltinDeclarations::BuiltinDeclarations()
: m_languageVersion(Version::fromString(QLatin1String(QBS_LANGUAGE_VERSION)))
, m_typeMap(std::initializer_list<std::pair<QString, ItemType>>({
- { QLatin1String("Artifact"), ItemType::Artifact },
- { QLatin1String("Depends"), ItemType::Depends },
- { QLatin1String("Export"), ItemType::Export },
- { QLatin1String("FileTagger"), ItemType::FileTagger },
- { QLatin1String("Group"), ItemType::Group },
- { QLatin1String("JobLimit"), ItemType::JobLimit },
- { QLatin1String("Module"), ItemType::Module },
- { QLatin1String("ModuleProvider"), ItemType::ModuleProvider },
- { QLatin1String("Parameter"), ItemType::Parameter },
- { QLatin1String("Parameters"), ItemType::Parameters },
- { QLatin1String("Probe"), ItemType::Probe },
- { QLatin1String("Product"), ItemType::Product },
- { QLatin1String("Profile"), ItemType::Profile },
- { QLatin1String("Project"), ItemType::Project },
- { QLatin1String("Properties"), ItemType::Properties }, // Callers have to handle the SubProject case.
- { QLatin1String("PropertyOptions"), ItemType::PropertyOptions },
- { QLatin1String("Rule"), ItemType::Rule },
- { QLatin1String("Scanner"), ItemType::Scanner },
- { QLatin1String("SubProject"), ItemType::SubProject },
- { QLatin1String("Transformer"), ItemType::Transformer }
+ { QStringLiteral("Artifact"), ItemType::Artifact },
+ { QStringLiteral("Depends"), ItemType::Depends },
+ { QStringLiteral("Export"), ItemType::Export },
+ { QStringLiteral("FileTagger"), ItemType::FileTagger },
+ { QStringLiteral("Group"), ItemType::Group },
+ { QStringLiteral("JobLimit"), ItemType::JobLimit },
+ { QStringLiteral("Module"), ItemType::Module },
+ { QStringLiteral("ModuleProvider"), ItemType::ModuleProvider },
+ { QStringLiteral("Parameter"), ItemType::Parameter },
+ { QStringLiteral("Parameters"), ItemType::Parameters },
+ { QStringLiteral("Probe"), ItemType::Probe },
+ { QStringLiteral("Product"), ItemType::Product },
+ { QStringLiteral("Profile"), ItemType::Profile },
+ { QStringLiteral("Project"), ItemType::Project },
+ { QStringLiteral("Properties"), ItemType::Properties }, // Callers have to handle the SubProject case.
+ { QStringLiteral("PropertyOptions"), ItemType::PropertyOptions },
+ { QStringLiteral("Rule"), ItemType::Rule },
+ { QStringLiteral("Scanner"), ItemType::Scanner },
+ { QStringLiteral("SubProject"), ItemType::SubProject },
+ { QStringLiteral("Transformer"), ItemType::Transformer }
}))
{
addArtifactItem();
@@ -137,7 +137,7 @@ QString BuiltinDeclarations::nameForType(ItemType itemType) const
{
// Iterating is okay here, as this mapping is not used in hot code paths.
if (itemType == ItemType::PropertiesInSubProject)
- return QLatin1String("Properties");
+ return QStringLiteral("Properties");
for (auto it = m_typeMap.constBegin(); it != m_typeMap.constEnd(); ++it) {
if (it.value() == itemType)
return it.key();
@@ -400,11 +400,11 @@ void BuiltinDeclarations::addProductItem()
PropertyDeclaration::Boolean, StringConstants::trueValue());
PropertyDeclaration profilesDecl(StringConstants::profilesProperty(),
PropertyDeclaration::StringList);
- profilesDecl.setDeprecationInfo(DeprecationInfo(Version::fromString(QLatin1String("1.9.0")),
+ profilesDecl.setDeprecationInfo(DeprecationInfo(Version::fromString(QStringLiteral("1.9.0")),
Tr::tr("Use qbs.profiles instead.")));
item << profilesDecl;
item << PropertyDeclaration(StringConstants::targetNameProperty(), PropertyDeclaration::String,
- QLatin1String("new String(name)"
+ QStringLiteral("new String(name)"
".replace(/[/\\\\?%*:|\"<>]/g, '_').valueOf()"));
item << buildDirProperty();
item << PropertyDeclaration(StringConstants::destinationDirProperty(),
@@ -422,7 +422,7 @@ void BuiltinDeclarations::addProductItem()
item << PropertyDeclaration(StringConstants::versionProperty(), PropertyDeclaration::String);
item << PropertyDeclaration(StringConstants::multiplexByQbsPropertiesProperty(),
- PropertyDeclaration::StringList, QLatin1String("[\"profiles\"]"));
+ PropertyDeclaration::StringList, QStringLiteral("[\"profiles\"]"));
item << PropertyDeclaration(StringConstants::multiplexedTypeProperty(),
PropertyDeclaration::StringList);
item << PropertyDeclaration(StringConstants::aggregateProperty(), PropertyDeclaration::Boolean);
@@ -518,7 +518,7 @@ void BuiltinDeclarations::addRuleItem()
<< StringConstants::projectVar() << StringConstants::productVar()
<< StringConstants::inputsVar() << StringConstants::inputVar());
item << outputArtifactsDecl;
- PropertyDeclaration usingsDecl(QLatin1String("usings"), PropertyDeclaration::StringList);
+ PropertyDeclaration usingsDecl(QStringLiteral("usings"), PropertyDeclaration::StringList);
usingsDecl.setDeprecationInfo(DeprecationInfo(Version(1, 5),
Tr::tr("Use 'inputsFromDependencies' instead")));
item << usingsDecl;
diff --git a/src/lib/corelib/language/evaluatorscriptclass.cpp b/src/lib/corelib/language/evaluatorscriptclass.cpp
index 829cb7494..c0e140d0b 100644
--- a/src/lib/corelib/language/evaluatorscriptclass.cpp
+++ b/src/lib/corelib/language/evaluatorscriptclass.cpp
@@ -433,7 +433,7 @@ QScriptClass::QueryFlags EvaluatorScriptClass::queryItemProperty(const Evaluatio
QString EvaluatorScriptClass::resultToString(const QScriptValue &scriptValue)
{
return (scriptValue.isObject()
- ? QLatin1String("[Object: ")
+ ? QStringLiteral("[Object: ")
+ QString::number(scriptValue.objectId()) + QLatin1Char(']')
: scriptValue.toVariant().toString());
}
@@ -509,7 +509,7 @@ static void convertToPropertyType_impl(const QString &pathPropertiesBaseDir, con
QString actualBaseDir;
if (item && !pathPropertiesBaseDir.isEmpty()) {
const VariantValueConstPtr itemSourceDir
- = item->variantProperty(QLatin1String("sourceDirectory"));
+ = item->variantProperty(QStringLiteral("sourceDirectory"));
actualBaseDir = itemSourceDir ? itemSourceDir->value().toString() : pathPropertiesBaseDir;
}
switch (decl.type()) {
diff --git a/src/lib/corelib/language/filetags.cpp b/src/lib/corelib/language/filetags.cpp
index 02beef7d6..83086b892 100644
--- a/src/lib/corelib/language/filetags.cpp
+++ b/src/lib/corelib/language/filetags.cpp
@@ -82,7 +82,7 @@ LogWriter operator <<(LogWriter w, const FileTags &tags)
if (firstLoop)
firstLoop = false;
else
- w.write(QLatin1String(", "));
+ w.write(QStringLiteral(", "));
w.write(tag.toString());
}
w.write(')');
diff --git a/src/lib/corelib/language/item.cpp b/src/lib/corelib/language/item.cpp
index 9ac12b0e6..39dc39370 100644
--- a/src/lib/corelib/language/item.cpp
+++ b/src/lib/corelib/language/item.cpp
@@ -106,12 +106,12 @@ Item *Item::clone() const
QString Item::typeName() const
{
switch (type()) {
- case ItemType::IdScope: return QLatin1String("[IdScope]");
- case ItemType::ModuleInstance: return QLatin1String("[ModuleInstance]");
- case ItemType::ModuleParameters: return QLatin1String("[ModuleParametersInstance]");
- case ItemType::ModulePrefix: return QLatin1String("[ModulePrefix]");
- case ItemType::Outer: return QLatin1String("[Outer]");
- case ItemType::Scope: return QLatin1String("[Scope]");
+ case ItemType::IdScope: return QStringLiteral("[IdScope]");
+ case ItemType::ModuleInstance: return QStringLiteral("[ModuleInstance]");
+ case ItemType::ModuleParameters: return QStringLiteral("[ModuleParametersInstance]");
+ case ItemType::ModulePrefix: return QStringLiteral("[ModulePrefix]");
+ case ItemType::Outer: return QStringLiteral("[Outer]");
+ case ItemType::Scope: return QStringLiteral("[Scope]");
default: return BuiltinDeclarations::instance().nameForType(type());
}
}
diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp
index e6ef0eac4..abe10bf24 100644
--- a/src/lib/corelib/language/moduleloader.cpp
+++ b/src/lib/corelib/language/moduleloader.cpp
@@ -296,8 +296,8 @@ ModuleLoaderResult ModuleLoader::load(const SetupProjectParameters &parameters)
for (const QString &key : m_parameters.overriddenValues().keys()) {
static const QStringList prefixes({ StringConstants::projectPrefix(),
- QLatin1String("projects"),
- QLatin1String("products"), QLatin1String("modules"),
+ QStringLiteral("projects"),
+ QStringLiteral("products"), QStringLiteral("modules"),
StringConstants::moduleProviders(),
StringConstants::qbsModule()});
bool ok = false;
@@ -673,7 +673,7 @@ void ModuleLoader::handleProject(ModuleLoaderResult *loadResult,
const QString minVersionStr
= m_evaluator->stringValue(projectItem, StringConstants::minimumQbsVersionProperty(),
- QLatin1String("1.3.0"));
+ QStringLiteral("1.3.0"));
const Version minVersion = Version::fromString(minVersionStr);
if (!minVersion.isValid()) {
throw ErrorInfo(Tr::tr("The value '%1' of Project.minimumQbsVersion "
@@ -809,7 +809,7 @@ ModuleLoader::MultiplexTable ModuleLoader::combine(const MultiplexTable &table,
ModuleLoader::MultiplexInfo ModuleLoader::extractMultiplexInfo(Item *productItem,
Item *qbsModuleItem)
{
- static const QString mpmKey = QLatin1String("multiplexMap");
+ static const QString mpmKey = QStringLiteral("multiplexMap");
const QScriptValue multiplexMap = m_evaluator->value(qbsModuleItem, mpmKey);
QStringList multiplexByQbsProperties = m_evaluator->stringListValue(
@@ -1214,15 +1214,15 @@ void ModuleLoader::prepareProduct(ProjectContext *projectContext, Item *productI
// and nothing else, thus providing us with the pure environment that we need to
// evaluate the product's exported properties in isolation in the project resolver.
Item * const importer = Item::create(productItem->pool(), ItemType::Product);
- importer->setProperty(QLatin1String("name"),
+ importer->setProperty(QStringLiteral("name"),
VariantValue::create(shadowProductPrefix() + productContext.name));
importer->setFile(productItem->file());
importer->setLocation(productItem->location());
importer->setScope(projectContext->scope);
importer->setupForBuiltinType(m_logger);
Item * const dependsItem = Item::create(productItem->pool(), ItemType::Depends);
- dependsItem->setProperty(QLatin1String("name"), VariantValue::create(productContext.name));
- dependsItem->setProperty(QLatin1String("required"), VariantValue::create(false));
+ dependsItem->setProperty(QStringLiteral("name"), VariantValue::create(productContext.name));
+ dependsItem->setProperty(QStringLiteral("required"), VariantValue::create(false));
dependsItem->setFile(importer->file());
dependsItem->setLocation(importer->location());
dependsItem->setupForBuiltinType(m_logger);
@@ -1418,7 +1418,7 @@ void ModuleLoader::handleProduct(ModuleLoader::ProductContext *productContext)
for (auto it = exportsData.find(productContext->name);
it != exportsData.end() && it.key() == productContext->name; ++it) {
if (it.value().multiplexId == productContext->multiplexConfigurationId) {
- createNonPresentModule(productContext->name, QLatin1String("disabled"),
+ createNonPresentModule(productContext->name, QStringLiteral("disabled"),
it.value().exportItem);
break;
}
@@ -1525,7 +1525,7 @@ void ModuleLoader::handleModuleSetupError(ModuleLoader::ProductContext *productC
qCDebug(lcModuleLoader()) << "non-required module" << module.name.toString()
<< "found, but not usable in product" << productContext->name
<< error.toString();
- createNonPresentModule(module.name.toString(), QLatin1String("failed validation"),
+ createNonPresentModule(module.name.toString(), QStringLiteral("failed validation"),
module.item);
}
}
@@ -2337,7 +2337,7 @@ void ModuleLoader::adjustDefiningItemsInGroupModuleInstances(const Item::Module
QBS_CHECK(v->definingItem());
Item *& replacement = definingItemReplacements[v->definingItem()];
- static const QString caseA = QLatin1String("__group_case_a");
+ static const QString caseA = QStringLiteral("__group_case_a");
if (v->definingItem() == instanceWithProperty
|| v->definingItem()->variantProperty(caseA)) {
// Case a)
@@ -3085,7 +3085,7 @@ Item *ModuleLoader::searchAndLoadModuleFile(ProductContext *productContext,
}
}
if (!isRequired)
- return createNonPresentModule(fullName, QLatin1String("not found"), nullptr);
+ return createNonPresentModule(fullName, QStringLiteral("not found"), nullptr);
if (Q_UNLIKELY(triedToLoadModule))
throw ErrorInfo(Tr::tr("Module %1 could not be loaded.").arg(fullName),
dependsItemLocation);
diff --git a/src/lib/corelib/language/projectresolver.cpp b/src/lib/corelib/language/projectresolver.cpp
index 9e9befbf3..6d5435899 100644
--- a/src/lib/corelib/language/projectresolver.cpp
+++ b/src/lib/corelib/language/projectresolver.cpp
@@ -872,8 +872,8 @@ void ProjectResolver::adaptExportedPropertyValues(const Item *shadowProductItem)
QVariantMap prefixMap;
for (const QVariant &v : prefixList) {
const QVariantMap o = v.toMap();
- prefixMap.insert(o.value(QLatin1String("prefix")).toString(),
- o.value(QLatin1String("replacement")).toString());
+ prefixMap.insert(o.value(QStringLiteral("prefix")).toString(),
+ o.value(QStringLiteral("replacement")).toString());
}
const auto valueRefersToImportingProduct
= [shadowProductName, shadowProductBuildDir](const QString &value) {
diff --git a/src/lib/corelib/language/propertydeclaration.cpp b/src/lib/corelib/language/propertydeclaration.cpp
index c7826dc39..5ea6a3d88 100644
--- a/src/lib/corelib/language/propertydeclaration.cpp
+++ b/src/lib/corelib/language/propertydeclaration.cpp
@@ -156,7 +156,7 @@ QString PropertyDeclaration::typeString(PropertyDeclaration::Type t)
case StringList: return stringListString();
case Variant: return variantString();
case VariantList: return varListString();
- case UnknownType: return QLatin1String("unknown");
+ case UnknownType: return QStringLiteral("unknown");
}
Q_UNREACHABLE(); // For stupid compilers.
}
diff --git a/src/lib/corelib/language/scriptengine.cpp b/src/lib/corelib/language/scriptengine.cpp
index 7b2c69aa1..973501bc3 100644
--- a/src/lib/corelib/language/scriptengine.cpp
+++ b/src/lib/corelib/language/scriptengine.cpp
@@ -107,10 +107,10 @@ ScriptEngine::ScriptEngine(Logger &logger, EvalContext evalContext, QObject *par
{
setProcessEventsInterval(1000); // For the cancelation mechanism to work.
m_cancelationError = currentContext()->throwValue(tr("Execution canceled"));
- QScriptValue objectProto = globalObject().property(QLatin1String("Object"));
- m_definePropertyFunction = objectProto.property(QLatin1String("defineProperty"));
+ QScriptValue objectProto = globalObject().property(QStringLiteral("Object"));
+ m_definePropertyFunction = objectProto.property(QStringLiteral("defineProperty"));
QBS_ASSERT(m_definePropertyFunction.isFunction(), /* ignore */);
- m_emptyFunction = evaluate(QLatin1String("(function(){})"));
+ m_emptyFunction = evaluate(QStringLiteral("(function(){})"));
QBS_ASSERT(m_emptyFunction.isFunction(), /* ignore */);
// Initially push a new context to turn off scope chain insanity mode.
QScriptEngine::pushContext();
@@ -630,8 +630,8 @@ CodeLocation ScriptEngine::lastErrorLocation(const QScriptValue &v,
{
const QScriptValue &errorVal = lastErrorValue(v);
const CodeLocation errorLoc(errorVal.property(StringConstants::fileNameProperty()).toString(),
- errorVal.property(QLatin1String("lineNumber")).toInt32(),
- errorVal.property(QLatin1String("expressionCaretOffset")).toInt32(),
+ errorVal.property(QStringLiteral("lineNumber")).toInt32(),
+ errorVal.property(QStringLiteral("expressionCaretOffset")).toInt32(),
false);
return errorLoc.isValid() ? errorLoc : fallbackLocation;
}
@@ -674,7 +674,7 @@ public:
: m_engine(engine)
{
m_proto = engine->globalObject().property(typeName)
- .property(QLatin1String("prototype"));
+ .property(QStringLiteral("prototype"));
QBS_ASSERT(m_proto.isObject(), return);
m_descriptor = engine->newObject();
}
@@ -683,7 +683,7 @@ public:
{
QScriptValue f = m_engine->evaluate(code);
QBS_ASSERT(f.isFunction(), return);
- m_descriptor.setProperty(QLatin1String("value"), f);
+ m_descriptor.setProperty(QStringLiteral("value"), f);
m_engine->defineProperty(m_proto, name, m_descriptor);
}
@@ -697,7 +697,7 @@ static QScriptValue js_consoleError(QScriptContext *context, QScriptEngine *engi
{
if (Q_UNLIKELY(context->argumentCount() != 1))
return context->throwError(QScriptContext::SyntaxError,
- QLatin1String("console.error() expects 1 argument"));
+ QStringLiteral("console.error() expects 1 argument"));
logger->qbsLog(LoggerError) << context->argument(0).toString();
return engine->undefinedValue();
}
@@ -706,7 +706,7 @@ static QScriptValue js_consoleWarn(QScriptContext *context, QScriptEngine *engin
{
if (Q_UNLIKELY(context->argumentCount() != 1))
return context->throwError(QScriptContext::SyntaxError,
- QLatin1String("console.warn() expects 1 argument"));
+ QStringLiteral("console.warn() expects 1 argument"));
logger->qbsWarning() << context->argument(0).toString();
return engine->undefinedValue();
}
@@ -715,7 +715,7 @@ static QScriptValue js_consoleInfo(QScriptContext *context, QScriptEngine *engin
{
if (Q_UNLIKELY(context->argumentCount() != 1))
return context->throwError(QScriptContext::SyntaxError,
- QLatin1String("console.info() expects 1 argument"));
+ QStringLiteral("console.info() expects 1 argument"));
logger->qbsInfo() << context->argument(0).toString();
return engine->undefinedValue();
}
@@ -724,7 +724,7 @@ static QScriptValue js_consoleDebug(QScriptContext *context, QScriptEngine *engi
{
if (Q_UNLIKELY(context->argumentCount() != 1))
return context->throwError(QScriptContext::SyntaxError,
- QLatin1String("console.debug() expects 1 argument"));
+ QStringLiteral("console.debug() expects 1 argument"));
logger->qbsDebug() << context->argument(0).toString();
return engine->undefinedValue();
}
@@ -738,27 +738,27 @@ void ScriptEngine::installQbsBuiltins()
{
globalObject().setProperty(StringConstants::qbsModule(), m_qbsObject = newObject());
- globalObject().setProperty(QLatin1String("console"), m_consoleObject = newObject());
- installConsoleFunction(QLatin1String("debug"), &js_consoleDebug);
- installConsoleFunction(QLatin1String("error"), &js_consoleError);
- installConsoleFunction(QLatin1String("info"), &js_consoleInfo);
- installConsoleFunction(QLatin1String("log"), &js_consoleLog);
- installConsoleFunction(QLatin1String("warn"), &js_consoleWarn);
+ globalObject().setProperty(QStringLiteral("console"), m_consoleObject = newObject());
+ installConsoleFunction(QStringLiteral("debug"), &js_consoleDebug);
+ installConsoleFunction(QStringLiteral("error"), &js_consoleError);
+ installConsoleFunction(QStringLiteral("info"), &js_consoleInfo);
+ installConsoleFunction(QStringLiteral("log"), &js_consoleLog);
+ installConsoleFunction(QStringLiteral("warn"), &js_consoleWarn);
}
void ScriptEngine::extendJavaScriptBuiltins()
{
- JSTypeExtender arrayExtender(this, QLatin1String("Array"));
- arrayExtender.addFunction(QLatin1String("contains"),
- QLatin1String("(function(e){return this.indexOf(e) !== -1;})"));
- arrayExtender.addFunction(QLatin1String("containsAll"),
- QLatin1String("(function(e){var $this = this;"
+ JSTypeExtender arrayExtender(this, QStringLiteral("Array"));
+ arrayExtender.addFunction(QStringLiteral("contains"),
+ QStringLiteral("(function(e){return this.indexOf(e) !== -1;})"));
+ arrayExtender.addFunction(QStringLiteral("containsAll"),
+ QStringLiteral("(function(e){var $this = this;"
"return e.every(function (v) { return $this.contains(v) });})"));
- arrayExtender.addFunction(QLatin1String("containsAny"),
- QLatin1String("(function(e){var $this = this;"
+ arrayExtender.addFunction(QStringLiteral("containsAny"),
+ QStringLiteral("(function(e){var $this = this;"
"return e.some(function (v) { return $this.contains(v) });})"));
- arrayExtender.addFunction(QLatin1String("uniqueConcat"),
- QLatin1String("(function(other){"
+ arrayExtender.addFunction(QStringLiteral("uniqueConcat"),
+ QStringLiteral("(function(other){"
"var r = this.concat();"
"var s = {};"
"r.forEach(function(x){ s[x] = true; });"
@@ -770,13 +770,13 @@ void ScriptEngine::extendJavaScriptBuiltins()
"});"
"return r;})"));
- JSTypeExtender stringExtender(this, QLatin1String("String"));
- stringExtender.addFunction(QLatin1String("contains"),
- QLatin1String("(function(e){return this.indexOf(e) !== -1;})"));
- stringExtender.addFunction(QLatin1String("startsWith"),
- QLatin1String("(function(e){return this.slice(0, e.length) === e;})"));
- stringExtender.addFunction(QLatin1String("endsWith"),
- QLatin1String("(function(e){return this.slice(-e.length) === e;})"));
+ JSTypeExtender stringExtender(this, QStringLiteral("String"));
+ stringExtender.addFunction(QStringLiteral("contains"),
+ QStringLiteral("(function(e){return this.indexOf(e) !== -1;})"));
+ stringExtender.addFunction(QStringLiteral("startsWith"),
+ QStringLiteral("(function(e){return this.slice(0, e.length) === e;})"));
+ stringExtender.addFunction(QStringLiteral("endsWith"),
+ QStringLiteral("(function(e){return this.slice(-e.length) === e;})"));
}
void ScriptEngine::installFunction(const QString &name, int length, QScriptValue *functionValue,