Commit 5ea09371 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

QmlJS: Compile with QT_NO_CAST_FROM_ASCII

Change-Id: I0c5654a978f47a4db5428936fd44633f21394830
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@digia.com>
parent 964c01a4
TEMPLATE = lib
TARGET = QmlJS
DEFINES += QMLJS_BUILD_DIR QT_CREATOR
DEFINES += QMLJS_BUILD_DIR QT_CREATOR QT_NO_CAST_FROM_ASCII
QT +=script
include(../../qtcreatorlibrary.pri)
......
......@@ -7,7 +7,8 @@ QtcLibrary {
cpp.includePaths: base.concat("parser")
cpp.defines: base.concat([
"QMLJS_BUILD_DIR",
"QT_CREATOR"
"QT_CREATOR",
"QT_NO_CAST_FROM_ASCII"
])
cpp.optimization: "fast"
......
......@@ -710,7 +710,7 @@ static bool checkTopLevelBindingForParentReference(ExpressionStatement *expStmt,
SourceLocation location = locationFromRange(expStmt->firstSourceLocation(), expStmt->lastSourceLocation());
QString stmtSource = source.mid(location.begin(), location.length);
if (stmtSource.contains(QRegExp("(^|\\W)parent\\.")))
if (stmtSource.contains(QRegExp(QLatin1String("(^|\\W)parent\\."))))
return true;
return false;
......@@ -804,7 +804,7 @@ bool Check::visit(UiScriptBinding *ast)
return false;
}
if (id.isEmpty() || (!id.at(0).isLower() && id.at(0) != '_')) {
if (id.isEmpty() || (!id.at(0).isLower() && id.at(0) != QLatin1Char('_'))) {
addMessage(ErrInvalidId, loc);
return false;
}
......
......@@ -940,10 +940,10 @@ CodeFormatter::TokenKind CodeFormatter::extendedTokenKind(const QmlJS::Token &to
if (text == "list")
return List;
} else if (kind == Keyword) {
const QChar char1 = text.at(0);
const QChar char2 = text.at(1);
const QChar char3 = (text.size() > 2 ? text.at(2) : QChar());
switch (char1.toLatin1()) {
const char char1 = text.at(0).toLatin1();
const char char2 = text.at(1).toLatin1();
const char char3 = (text.size() > 2 ? text.at(2).toLatin1() : 0);
switch (char1) {
case 'v':
return Var;
case 'i':
......@@ -1019,7 +1019,7 @@ void CodeFormatter::dump() const
qDebug() << "Current indent depth:" << m_indentDepth;
}
QString CodeFormatter::stateToString(int type) const
QByteArray CodeFormatter::stateToString(int type) const
{
const QMetaEnum &metaEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("StateType"));
return metaEnum.valueToKey(type);
......
......@@ -278,7 +278,7 @@ protected:
bool isExpressionEndState(int type) const;
void dump() const;
QString stateToString(int type) const;
QByteArray stateToString(int type) const;
private:
void recalculateStateAfter(const QTextBlock &block);
......
......@@ -125,11 +125,11 @@ Document::MutablePtr Document::create(const QString &fileName, Language language
Document::Language Document::guessLanguageFromSuffix(const QString &fileName)
{
if (fileName.endsWith(".qml", Qt::CaseInsensitive))
if (fileName.endsWith(QLatin1String(".qml"), Qt::CaseInsensitive))
return QmlLanguage;
if (fileName.endsWith(".js", Qt::CaseInsensitive))
if (fileName.endsWith(QLatin1String(".js"), Qt::CaseInsensitive))
return JavaScriptLanguage;
if (fileName.endsWith(".json", Qt::CaseInsensitive))
if (fileName.endsWith(QLatin1String(".json"), Qt::CaseInsensitive))
return JsonLanguage;
return UnknownLanguage;
}
......
......@@ -186,10 +186,10 @@ QChar QmlJSIndenter::lastParen() const
const Token &token = yyLinizerState.tokens.at(index);
if (token.is(Token::LeftParenthesis))
return QChar('(');
return QLatin1Char('(');
else if (token.is(Token::RightParenthesis))
return QChar(')');
return QLatin1Char(')');
}
return QChar();
......@@ -324,7 +324,7 @@ int QmlJSIndenter::indentForContinuationLine()
Q_ASSERT(j - 1 >= 0);
if (QString::fromLatin1("!=<>").indexOf(yyLine->at(j - 1)) == -1 &&
j + 1 < yyLine->length() && yyLine->at(j + 1) != '=') {
j + 1 < yyLine->length() && yyLine->at(j + 1) != QLatin1Char('=')) {
if (braceDepth == 0 && delimDepth == 0 &&
j < yyLine->length() - 1 &&
!yyLine->endsWith(QLatin1Char(',')) &&
......
......@@ -1131,7 +1131,7 @@ QList<const ObjectValue *> PrototypeIterator::all()
FunctionValue::FunctionValue(ValueOwner *valueOwner)
: ObjectValue(valueOwner)
{
setClassName("Function");
setClassName(QLatin1String("Function"));
setMember(QLatin1String("length"), valueOwner->numberValue());
setPrototype(valueOwner->functionPrototype());
}
......@@ -1450,7 +1450,7 @@ bool CppQmlTypes::hasModule(const QString &module) const
QString CppQmlTypes::qualifiedName(const QString &module, const QString &type, ComponentVersion version)
{
return QString("%1/%2 %3").arg(
return QString::fromLatin1("%1/%2 %3").arg(
module, type,
version.toString());
......@@ -1532,14 +1532,16 @@ void ConvertToNumber::visit(const StringValue *)
void ConvertToNumber::visit(const ObjectValue *object)
{
if (const FunctionValue *valueOfMember = value_cast<FunctionValue>(object->lookupMember("valueOf", ContextPtr()))) {
if (const FunctionValue *valueOfMember = value_cast<FunctionValue>(
object->lookupMember(QLatin1String("valueOf"), ContextPtr()))) {
_result = value_cast<NumberValue>(valueOfMember->returnValue());
}
}
void ConvertToNumber::visit(const FunctionValue *object)
{
if (const FunctionValue *valueOfMember = value_cast<FunctionValue>(object->lookupMember("valueOf", ContextPtr()))) {
if (const FunctionValue *valueOfMember = value_cast<FunctionValue>(
object->lookupMember(QLatin1String("valueOf"), ContextPtr()))) {
_result = value_cast<NumberValue>(valueOfMember->returnValue());
}
}
......@@ -1593,14 +1595,16 @@ void ConvertToString::visit(const StringValue *value)
void ConvertToString::visit(const ObjectValue *object)
{
if (const FunctionValue *toStringMember = value_cast<FunctionValue>(object->lookupMember("toString", ContextPtr()))) {
if (const FunctionValue *toStringMember = value_cast<FunctionValue>(
object->lookupMember(QLatin1String("toString"), ContextPtr()))) {
_result = value_cast<StringValue>(toStringMember->returnValue());
}
}
void ConvertToString::visit(const FunctionValue *object)
{
if (const FunctionValue *toStringMember = value_cast<FunctionValue>(object->lookupMember("toString", ContextPtr()))) {
if (const FunctionValue *toStringMember = value_cast<FunctionValue>(
object->lookupMember(QLatin1String("toString"), ContextPtr()))) {
_result = value_cast<StringValue>(toStringMember->returnValue());
}
}
......
......@@ -334,8 +334,8 @@ bool LineInfo::readLine()
the other way around, as we are parsing backwards.
*/
yyLinizerState.braceDepth +=
yyLinizerState.line.count('}') + yyLinizerState.line.count(']') -
yyLinizerState.line.count('{') - yyLinizerState.line.count('[');
yyLinizerState.line.count(QLatin1Char('}')) + yyLinizerState.line.count(QLatin1Char(']')) -
yyLinizerState.line.count(QLatin1Char('{')) - yyLinizerState.line.count(QLatin1Char('['));
/*
We use a dirty trick for
......
......@@ -342,7 +342,7 @@ Import LinkPrivate::importNonFile(Document::Ptr doc, const ImportInfo &importInf
const QString &packagePath = importInfo.path();
// check the filesystem with full version
foreach (const QString &importPath, importPaths) {
QString libraryPath = QString("%1/%2.%3").arg(importPath, packagePath, version.toString());
QString libraryPath = QString::fromLatin1("%1/%2.%3").arg(importPath, packagePath, version.toString());
if (importLibrary(doc, libraryPath, &import, importPath)) {
importFound = true;
break;
......@@ -351,7 +351,7 @@ Import LinkPrivate::importNonFile(Document::Ptr doc, const ImportInfo &importInf
if (!importFound) {
// check the filesystem with major version
foreach (const QString &importPath, importPaths) {
QString libraryPath = QString("%1/%2.%3").arg(importPath, packagePath,
QString libraryPath = QString::fromLatin1("%1/%2.%3").arg(importPath, packagePath,
QString::number(version.majorVersion()));
if (importLibrary(doc, libraryPath, &import, importPath)) {
importFound = true;
......@@ -362,7 +362,7 @@ Import LinkPrivate::importNonFile(Document::Ptr doc, const ImportInfo &importInf
if (!importFound) {
// check the filesystem with no version
foreach (const QString &importPath, importPaths) {
QString libraryPath = QString("%1/%2").arg(importPath, packagePath);
QString libraryPath = QString::fromLatin1("%1/%2").arg(importPath, packagePath);
if (importLibrary(doc, libraryPath, &import, importPath)) {
importFound = true;
break;
......
......@@ -194,10 +194,11 @@ PropertyReader::PropertyReader(Document::Ptr doc, AST::UiObjectInitializer *ast)
property->statement->firstSourceLocation(),
property->statement->lastSourceLocation()));
if (isLiteralValue(property)) {
m_properties.insert(propertyName + '.' + propertyNamePart2, QVariant(deEscape(stripQuotes(astValue))));
m_properties.insert(propertyName + QLatin1Char('.') + propertyNamePart2,
QVariant(deEscape(stripQuotes(astValue))));
} else if (isEnum(property->statement)) { //enum
m_properties.insert(propertyName + '.' + propertyNamePart2, QVariant(astValue));
m_bindingOrEnum.append(propertyName + '.' + propertyNamePart2);
m_properties.insert(propertyName + QLatin1Char('.') + propertyNamePart2, QVariant(astValue));
m_bindingOrEnum.append(propertyName + QLatin1Char('.') + propertyNamePart2);
}
}
}
......@@ -230,7 +231,7 @@ QLinearGradient PropertyReader::parseGradient(const QString &propertyName, bool
initializer->rbraceToken));
const QString objectPropertyName = objectBinding->qualifiedId->name.toString();
const QString typeName = objectBinding->qualifiedTypeNameId->name.toString();
if (objectPropertyName == propertyName && typeName.contains("Gradient")) {
if (objectPropertyName == propertyName && typeName.contains(QLatin1String("Gradient"))) {
QLinearGradient gradient;
QVector<QGradientStop> stops;
......@@ -238,10 +239,10 @@ QLinearGradient PropertyReader::parseGradient(const QString &propertyName, bool
UiObjectMember *member = members->member;
if (UiObjectDefinition *objectDefinition = cast<UiObjectDefinition *>(member)) {
PropertyReader localParser(m_doc, objectDefinition->initializer);
if (localParser.hasProperty("color") && localParser.hasProperty("position")) {
QColor color = QmlJS::toQColor(localParser.readProperty("color").toString());
qreal position = localParser.readProperty("position").toReal();
if (localParser.isBindingOrEnum("color") || localParser.isBindingOrEnum("position"))
if (localParser.hasProperty(QLatin1String("color")) && localParser.hasProperty(QLatin1String("position"))) {
QColor color = QmlJS::toQColor(localParser.readProperty(QLatin1String("color")).toString());
qreal position = localParser.readProperty(QLatin1String("position")).toReal();
if (localParser.isBindingOrEnum(QLatin1String("color")) || localParser.isBindingOrEnum(QLatin1String("position")))
*isBound = true;
stops.append( QPair<qreal, QColor>(position, color));
}
......
......@@ -131,7 +131,7 @@ public:
}
// ensure good ending
if (!_result.endsWith("\n\n") || !_line.isEmpty())
if (!_result.endsWith(QLatin1String("\n\n")) || !_line.isEmpty())
newLine();
return _result;
......@@ -287,7 +287,7 @@ protected:
while (startSpaces < line->size() && line->at(startSpaces).isSpace())
++startSpaces;
line->replace(0, startSpaces, QString(indent, ' '));
line->replace(0, startSpaces, QString(indent, QLatin1Char(' ')));
for (int i = 0; i < splits->size(); ++i) {
(*splits)[i].offset = splits->at(i).offset - startSpaces + indent;
}
......@@ -313,7 +313,7 @@ protected:
continue;
// the extra space is to avoid // comments sticking to the 0 offset
QString indentLine = newContext.join("\n") + QLatin1String("\n ") + restLine;
QString indentLine = newContext.join(QLatin1String("\n")) + QLatin1String("\n ") + restLine;
int indent = tryIndent(indentLine);
QList<Split> newSplits = possibleSplits.mid(i + 1);
......@@ -511,7 +511,7 @@ protected:
{
out("import ", ast->importToken);
if (!ast->fileName.isNull()) {
out(QString("\"%1\"").arg(ast->fileName.toString()));
out(QString::fromLatin1("\"%1\"").arg(ast->fileName.toString()));
} else {
accept(ast->importUri);
}
......
......@@ -331,7 +331,7 @@ void Rewriter::replaceMemberValue(UiObjectMember *propertyMember,
}
if (needsSemicolon)
replacement += ';';
replacement += QLatin1Char(';');
m_changeSet->replace(startOffset, endOffset, replacement);
}
......
......@@ -145,7 +145,7 @@ bool SimpleAbstractStreamReader::readFromSource(const QString &source)
lexer.setCode(source, /*line = */ 1, /*qmlMode = */true);
if (!parser.parse()) {
QString errorMessage = QString("%1:%2: %3").arg(
QString errorMessage = QString::fromLatin1("%1:%2: %3").arg(
QString::number(parser.errorLineNumber()),
QString::number(parser.errorColumnNumber()),
parser.errorMessage());
......@@ -162,7 +162,7 @@ QStringList SimpleAbstractStreamReader::errors() const
void SimpleAbstractStreamReader::addError(const QString &error, const AST::SourceLocation &sourceLocation)
{
m_errors << QString("%1:%2: %3\n").arg(
m_errors << QString::fromLatin1("%1:%2: %3\n").arg(
QString::number(sourceLocation.startLine),
QString::number(sourceLocation.startColumn),
error);
......
......@@ -264,7 +264,7 @@ Message::Message(Type type,
message = message.arg(arg1, arg2);
}
if (appendTypeId)
message.append(QString(" (M%1)").arg(QString::number(prototype.type)));
message.append(QString::fromLatin1(" (M%1)").arg(QString::number(prototype.type)));
}
bool Message::isValid() const
......@@ -292,7 +292,7 @@ DiagnosticMessage Message::toDiagnosticMessage() const
QString Message::suppressionString() const
{
return QString("@disable-check M%1").arg(QString::number(type));
return QString::fromLatin1("@disable-check M%1").arg(QString::number(type));
}
QRegExp Message::suppressionPattern()
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment