Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/script/api/qscriptengine.cpp

    r651 r769  
    4242#include <QtCore/qmetaobject.h>
    4343
     44
    4445#include "Error.h"
    4546#include "JSArray.h"
     
    663664            encoding = QCoreApplication::UnicodeUTF8;
    664665        else
    665             return JSC::throwError(exec, JSC::GeneralError, QString::fromLatin1("qsTranslate(): invalid encoding '%s'").arg(encStr));
     666            return JSC::throwError(exec, JSC::GeneralError, QString::fromLatin1("qsTranslate(): invalid encoding '%'").arg(encStr));
    666667    }
    667668    int n = -1;
     
    697698        return JSC::throwError(exec, JSC::GeneralError, "qsTr(): second argument (comment) must be a string");
    698699    if ((args.size() > 2) && !args.at(2).isNumber())
    699         return JSC::throwError(exec, JSC::GeneralError, "qsTranslate(): third argument (n) must be a number");
     700        return JSC::throwError(exec, JSC::GeneralError, "qsTr(): third argument (n) must be a number");
    700701#ifndef QT_NO_QOBJECT
    701702    QString context;
    702     QScriptContext *ctx = QScriptEnginePrivate::contextForFrame(exec);
    703     if (ctx && ctx->parentContext())
    704         context = QFileInfo(QScriptContextInfo(ctx->parentContext()).fileName()).baseName();
     703    // The first non-empty source URL in the call stack determines the translation context.
     704    {
     705        JSC::ExecState *frame = exec->removeHostCallFrameFlag();
     706        while (frame) {
     707            if (frame->codeBlock() && frame->codeBlock()->source()
     708                && !frame->codeBlock()->source()->url().isEmpty()) {
     709                context = QFileInfo(frame->codeBlock()->source()->url()).baseName();
     710                break;
     711            }
     712            frame = frame->callerFrame()->removeHostCallFrameFlag();
     713        }
     714    }
    705715#endif
    706716    QString text(args.at(0).toString(exec));
     
    769779
    770780QScriptEnginePrivate::QScriptEnginePrivate()
    771     : registeredScriptValues(0), freeScriptValues(0),
     781    : registeredScriptValues(0), freeScriptValues(0),
    772782      registeredScriptStrings(0), inEval(false)
    773783{
     
    10081018        return;
    10091019    QScript::GlobalObject *glob = static_cast<QScript::GlobalObject*>(originalGlobalObject());
    1010     if (object == originalGlobalObjectProxy)
     1020    if (object == originalGlobalObjectProxy)
    10111021        glob->customGlobalObject = 0;
    1012     else {
     1022        // Sync the internal prototype, since JSObject::prototype() is not virtual.
     1023        glob->setPrototype(originalGlobalObjectProxy->prototype());
     1024    } else {
    10131025        Q_ASSERT(object != originalGlobalObject());
    10141026        glob->customGlobalObject = object;
     1027
     1028
    10151029    }
    10161030}
     
    15901604#ifndef QT_NO_REGEXP
    15911605
    1592 extern QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax);
     1606extern QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax);
    15931607
    15941608/*!
     
    29222936    JSC::JSGlobalObject *glob = d->originalGlobalObject();
    29232937    if (!jscObject || !jscObject.isObject())
    2924         jscObject = glob;
     2938        jscObject = ;
    29252939//    unsigned attribs = JSC::DontEnum;
    29262940    JSC::asObject(jscObject)->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, glob->prototypeFunctionStructure(), 5, JSC::Identifier(exec, "qsTranslate"), QScript::functionQsTranslate));
    29272941    JSC::asObject(jscObject)->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, glob->prototypeFunctionStructure(), 2, JSC::Identifier(exec, "QT_TRANSLATE_NOOP"), QScript::functionQsTranslateNoOp));
    2928     JSC::asObject(jscObject)->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, glob->prototypeFunctionStructure(), 3, JSC::Identifier(exec, "qsTr"), QScript::functionQsTr));
     2942    JSC::asObject(jscObject)->putDirectFunction(exec, new (exec)JSC::(exec, glob->prototypeFunctionStructure(), 3, JSC::Identifier(exec, "qsTr"), QScript::functionQsTr));
    29292943    JSC::asObject(jscObject)->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, glob->prototypeFunctionStructure(), 1, JSC::Identifier(exec, "QT_TR_NOOP"), QScript::functionQsTrNoOp));
    29302944
Note: See TracChangeset for help on using the changeset viewer.