From cedaf867421f4c43a2da712f00e9626e64c8b250 Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Fri, 23 Nov 2012 04:21:49 +0900 Subject: [PATCH] Enable mobule build with QT_NO_TRANSLATION Change-Id: Id7aeef0d499f48ddc64b4ea3e4dc713db8458c38 Reviewed-by: Oswald Buddenhagen Reviewed-by: Alan Alpert (RIM) --- src/qml/qml/qqmlcompiler.cpp | 5 ++++- src/qml/qml/qqmlinstruction.cpp | 2 ++ src/qml/qml/qqmlinstruction_p.h | 10 ++++++++-- src/qml/qml/qqmlvme.cpp | 2 ++ src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 3 ++- src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 2 ++ src/qml/qml/v8/qv8engine.cpp | 2 ++ src/qmltest/quicktest.cpp | 2 ++ tools/qmlscene/main.cpp | 8 ++++++++ 9 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp index cdbdb1e..0b22228 100644 --- a/src/qml/qml/qqmlcompiler.cpp +++ b/src/qml/qml/qqmlcompiler.cpp @@ -3524,6 +3524,7 @@ void QQmlCompiler::genBindingAssignment(QQmlScript::Value *binding, Q_ASSERT(binding->bindingReference); const BindingReference &ref = *binding->bindingReference; +#ifndef QT_NO_TRANSLATION if (ref.dataType == BindingReference::TrId) { const TrBindingReference &tr = static_cast(ref); @@ -3542,7 +3543,9 @@ void QQmlCompiler::genBindingAssignment(QQmlScript::Value *binding, store.comment = output->indexForByteArray(tr.comment.toUtf8()); store.n = tr.n; output->addInstruction(store); - } else if (ref.dataType == BindingReference::V4) { + } else +#endif + if (ref.dataType == BindingReference::V4) { const JSBindingReference &js = static_cast(ref); Instruction::StoreV4Binding store; diff --git a/src/qml/qml/qqmlinstruction.cpp b/src/qml/qml/qqmlinstruction.cpp index 50ebbaa..96d12cf 100644 --- a/src/qml/qml/qqmlinstruction.cpp +++ b/src/qml/qml/qqmlinstruction.cpp @@ -117,12 +117,14 @@ void QQmlCompiledData::dump(QQmlInstruction *instr, int idx) case QQmlInstruction::StoreStringQList: qWarning().nospace() << idx << "\t\t" << "STORE_STRING_QLIST\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value); break; +#ifndef QT_NO_TRANSLATION case QQmlInstruction::StoreTrString: qWarning().nospace() << idx << "\t\t" << "STORE_TR_STRING\t" << instr->storeTrString.propertyIndex << "\t" << instr->storeTrString.context << "\t" << instr->storeTrString.text << "\t" << instr->storeTrString.comment << "\t" << instr->storeTrString.n; break; case QQmlInstruction::StoreTrIdString: qWarning().nospace() << idx << "\t\t" << "STORE_TRID_STRING\t" << instr->storeTrIdString.propertyIndex << "\t" << instr->storeTrIdString.text << "\t" << instr->storeTrIdString.n; break; +#endif case QQmlInstruction::StoreByteArray: qWarning().nospace() << idx << "\t\t" << "STORE_BYTEARRAY" << instr->storeByteArray.propertyIndex << "\t" << instr->storeByteArray.value << "\t\t" << datas.at(instr->storeByteArray.value); break; diff --git a/src/qml/qml/qqmlinstruction_p.h b/src/qml/qml/qqmlinstruction_p.h index 6c1e4ab..62ed0d5 100644 --- a/src/qml/qml/qqmlinstruction_p.h +++ b/src/qml/qml/qqmlinstruction_p.h @@ -85,8 +85,8 @@ QT_BEGIN_NAMESPACE F(StoreJSValueBool, storeBool) \ F(StoreStringList, storeString) \ F(StoreStringQList, storeString) \ - F(StoreTrString, storeTrString) \ - F(StoreTrIdString, storeTrIdString) \ + F_TRANSLATION(F, StoreTrString, storeTrString) \ + F_TRANSLATION(F, StoreTrIdString, storeTrIdString) \ F(StoreByteArray, storeByteArray) \ F(StoreUrl, storeUrl) \ F(StoreUrlQList, storeUrl) \ @@ -136,6 +136,12 @@ QT_BEGIN_NAMESPACE F(FetchValueType, fetchValue) \ F(PopValueType, fetchValue) +#ifndef QT_NO_TRANSLATION +#define F_TRANSLATION(F, I, FMT) F(I, FMT) +#else +#define F_TRANSLATION(F, I, FMT) +#endif + #if defined(Q_CC_GNU) && (!defined(Q_CC_INTEL) || __INTEL_COMPILER >= 1200) # define QML_THREADED_VME_INTERPRETER #endif diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp index 3ad442f..da918c3 100644 --- a/src/qml/qml/qqmlvme.cpp +++ b/src/qml/qml/qqmlvme.cpp @@ -396,12 +396,14 @@ QObject *QQmlVME::run(QList *errors, QML_STORE_POINTER(StoreString, &PRIMITIVES.at(instr.value)); QML_STORE_POINTER(StoreByteArray, &DATAS.at(instr.value)); QML_STORE_POINTER(StoreUrl, &URLS.at(instr.value)); +#ifndef QT_NO_TRANSLATION QML_STORE_VALUE(StoreTrString, QString, QCoreApplication::translate(DATAS.at(instr.context).constData(), DATAS.at(instr.text).constData(), DATAS.at(instr.comment).constData(), instr.n)); QML_STORE_VALUE(StoreTrIdString, QString, qtTrId(DATAS.at(instr.text).constData(), instr.n)); +#endif // Store a literal value in a QList QML_STORE_LIST(StoreStringList, QStringList, PRIMITIVES.at(instr.value)); diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index c4352de..8e8e320 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1328,6 +1328,7 @@ v8::Handle createComponent(const v8::Arguments &args) return v8engine->newQObject(c); } +#ifndef QT_NO_TRANSLATION /*! \qmlmethod string qsTranslate(string context, string sourceText, string disambiguation, int n) @@ -1556,7 +1557,7 @@ v8::Handle qsTrIdNoOp(const v8::Arguments &args) return v8::Undefined(); return args[0]; } - +#endif // QT_NO_TRANSLATION /*! \qmlmethod Qt::locale(name) diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index 08e7d4f..de171bb 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -100,12 +100,14 @@ v8::Handle quit(const v8::Arguments &args); v8::Handle resolvedUrl(const v8::Arguments &args); v8::Handle createQmlObject(const v8::Arguments &args); v8::Handle createComponent(const v8::Arguments &args); +#ifndef QT_NO_TRANSLATION v8::Handle qsTranslate(const v8::Arguments &args); v8::Handle qsTranslateNoOp(const v8::Arguments &args); v8::Handle qsTr(const v8::Arguments &args); v8::Handle qsTrNoOp(const v8::Arguments &args); v8::Handle qsTrId(const v8::Arguments &args); v8::Handle qsTrIdNoOp(const v8::Arguments &args); +#endif v8::Handle stringArg(const v8::Arguments &args); v8::Handle locale(const v8::Arguments &args); v8::Handle binding(const v8::Arguments &args); diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 19aea29..030cfda 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -640,12 +640,14 @@ void QV8Engine::initializeGlobal(v8::Handle global) qt->Set(v8::String::New("createComponent"), V8FUNCTION(createComponent, this)); } +#ifndef QT_NO_TRANSLATION global->Set(v8::String::New("qsTranslate"), V8FUNCTION(qsTranslate, this)); global->Set(v8::String::New("QT_TRANSLATE_NOOP"), V8FUNCTION(qsTranslateNoOp, this)); global->Set(v8::String::New("qsTr"), V8FUNCTION(qsTr, this)); global->Set(v8::String::New("QT_TR_NOOP"), V8FUNCTION(qsTrNoOp, this)); global->Set(v8::String::New("qsTrId"), V8FUNCTION(qsTrId, this)); global->Set(v8::String::New("QT_TRID_NOOP"), V8FUNCTION(qsTrIdNoOp, this)); +#endif global->Set(v8::String::New("print"), consoleLogFn); global->Set(v8::String::New("console"), console); diff --git a/src/qmltest/quicktest.cpp b/src/qmltest/quicktest.cpp index 614dde3..6a96395 100644 --- a/src/qmltest/quicktest.cpp +++ b/src/qmltest/quicktest.cpp @@ -212,6 +212,7 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD QuickTestResult::parseArgs(argc, argv); +#ifndef QT_NO_TRANSLATION QTranslator translator; if (!translationFile.isEmpty()) { if (translator.load(translationFile)) { @@ -220,6 +221,7 @@ int quick_test_main(int argc, char **argv, const char *name, const char *sourceD qWarning("Could not load the translation file '%s'.", qPrintable(translationFile)); } } +#endif // Determine where to look for the test data. if (testPath.isEmpty() && sourceDir) { diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp index cee09e0..32bf32e 100644 --- a/tools/qmlscene/main.cpp +++ b/tools/qmlscene/main.cpp @@ -305,11 +305,13 @@ static void displayFileDialog(Options *options) #endif } +#ifndef QT_NO_TRANSLATION static void loadTranslationFile(QTranslator &translator, const QString& directory) { translator.load(QLatin1String("qml_" )+QLocale::system().name(), directory + QLatin1String("/i18n")); QCoreApplication::installTranslator(&translator); } +#endif static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory) { @@ -412,6 +414,7 @@ int main(int argc, char ** argv) app.setOrganizationName("Qt Project"); app.setOrganizationDomain("qt-project.org"); +#ifndef QT_NO_TRANSLATION QTranslator translator; QTranslator qtTranslator; QString sysLocale = QLocale::system().name(); @@ -432,6 +435,7 @@ int main(int argc, char ** argv) qWarning() << "Could not load the translation file" << options.translationFile; } } +#endif QUnifiedTimer::instance()->setSlowModeEnabled(options.slowAnimations); @@ -446,7 +450,9 @@ int main(int argc, char ** argv) if (!options.file.isEmpty()) { if (!options.versionDetection || checkVersion(options.file)) { +#ifndef QT_NO_TRANSLATION QTranslator translator; +#endif // TODO: as soon as the engine construction completes, the debug service is // listening for connections. But actually we aren't ready to debug anything. @@ -458,7 +464,9 @@ int main(int argc, char ** argv) engine.addNamedBundle(bundles.at(i).first, bundles.at(i).second); if (options.file.isLocalFile()) { QFileInfo fi(options.file.toLocalFile()); +#ifndef QT_NO_TRANSLATION loadTranslationFile(translator, fi.path()); +#endif loadDummyDataFiles(engine, fi.path()); } QObject::connect(&engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit())); -- 2.7.4