Changeset 769 for trunk/src/script
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/script/api/qscriptengine.cpp
r651 r769 42 42 #include <QtCore/qmetaobject.h> 43 43 44 #include "CodeBlock.h" 44 45 #include "Error.h" 45 46 #include "JSArray.h" … … 663 664 encoding = QCoreApplication::UnicodeUTF8; 664 665 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 '%0'").arg(encStr)); 666 667 } 667 668 int n = -1; … … 697 698 return JSC::throwError(exec, JSC::GeneralError, "qsTr(): second argument (comment) must be a string"); 698 699 if ((args.size() > 2) && !args.at(2).isNumber()) 699 return JSC::throwError(exec, JSC::GeneralError, "qsTr anslate(): third argument (n) must be a number");700 return JSC::throwError(exec, JSC::GeneralError, "qsTr(): third argument (n) must be a number"); 700 701 #ifndef QT_NO_QOBJECT 701 702 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 } 705 715 #endif 706 716 QString text(args.at(0).toString(exec)); … … 769 779 770 780 QScriptEnginePrivate::QScriptEnginePrivate() 771 : registeredScriptValues(0), freeScriptValues(0), 781 : registeredScriptValues(0), freeScriptValues(0), freeScriptValuesCount(0), 772 782 registeredScriptStrings(0), inEval(false) 773 783 { … … 1008 1018 return; 1009 1019 QScript::GlobalObject *glob = static_cast<QScript::GlobalObject*>(originalGlobalObject()); 1010 if (object == originalGlobalObjectProxy) 1020 if (object == originalGlobalObjectProxy) { 1011 1021 glob->customGlobalObject = 0; 1012 else { 1022 // Sync the internal prototype, since JSObject::prototype() is not virtual. 1023 glob->setPrototype(originalGlobalObjectProxy->prototype()); 1024 } else { 1013 1025 Q_ASSERT(object != originalGlobalObject()); 1014 1026 glob->customGlobalObject = object; 1027 // Sync the internal prototype, since JSObject::prototype() is not virtual. 1028 glob->setPrototype(object->prototype()); 1015 1029 } 1016 1030 } … … 1590 1604 #ifndef QT_NO_REGEXP 1591 1605 1592 extern QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax);1606 Q_DECL_IMPORT extern QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax); 1593 1607 1594 1608 /*! … … 2922 2936 JSC::JSGlobalObject *glob = d->originalGlobalObject(); 2923 2937 if (!jscObject || !jscObject.isObject()) 2924 jscObject = glob;2938 jscObject = d->globalObject(); 2925 2939 // unsigned attribs = JSC::DontEnum; 2926 2940 JSC::asObject(jscObject)->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, glob->prototypeFunctionStructure(), 5, JSC::Identifier(exec, "qsTranslate"), QScript::functionQsTranslate)); 2927 2941 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::PrototypeFunction(exec, glob->prototypeFunctionStructure(), 3, JSC::Identifier(exec, "qsTr"), QScript::functionQsTr)); 2929 2943 JSC::asObject(jscObject)->putDirectFunction(exec, new (exec)JSC::NativeFunctionWrapper(exec, glob->prototypeFunctionStructure(), 1, JSC::Identifier(exec, "QT_TR_NOOP"), QScript::functionQsTrNoOp)); 2930 2944 -
trunk/src/script/api/qscriptengine_p.h
r651 r769 256 256 QScriptValuePrivate *registeredScriptValues; 257 257 QScriptValuePrivate *freeScriptValues; 258 static const int maxFreeScriptValues = 256; 259 int freeScriptValuesCount; 258 260 QScriptStringPrivate *registeredScriptStrings; 259 261 QHash<int, QScriptTypeInfo*> m_typeInfos; … … 378 380 QScriptValuePrivate *p = freeScriptValues; 379 381 freeScriptValues = p->next; 382 --freeScriptValuesCount; 380 383 return p; 381 384 } … … 385 388 inline void QScriptEnginePrivate::freeScriptValuePrivate(QScriptValuePrivate *p) 386 389 { 387 p->next = freeScriptValues; 388 freeScriptValues = p; 390 if (freeScriptValuesCount < maxFreeScriptValues) { 391 p->next = freeScriptValues; 392 freeScriptValues = p; 393 ++freeScriptValuesCount; 394 } else { 395 qFree(p); 396 } 389 397 } 390 398 -
trunk/src/script/api/qscriptvalue.cpp
r651 r769 793 793 return; 794 794 } 795 JSC::JSObject *thisObject = JSC::asObject(d->jscValue); 795 796 JSC::JSValue other = d->engine->scriptValueToJSCValue(prototype); 796 797 … … 799 800 while (nextPrototypeValue && nextPrototypeValue.isObject()) { 800 801 JSC::JSObject *nextPrototype = JSC::asObject(nextPrototypeValue); 801 if (nextPrototype == JSC::asObject(d->jscValue)) {802 if (nextPrototype == thisObject) { 802 803 qWarning("QScriptValue::setPrototype() failed: cyclic prototype value"); 803 804 return; … … 805 806 nextPrototypeValue = nextPrototype->prototype(); 806 807 } 807 JSC::asObject(d->jscValue)->setPrototype(other); 808 809 thisObject->setPrototype(other); 810 811 // Sync the internal Global Object prototype if appropriate. 812 if (((thisObject == d->engine->originalGlobalObjectProxy) 813 && !d->engine->customGlobalObject()) 814 || (thisObject == d->engine->customGlobalObject())) { 815 d->engine->originalGlobalObject()->setPrototype(other); 816 } 808 817 } 809 818 … … 1149 1158 1150 1159 if (d->type != other.d_ptr->type) { 1151 if (d->type == QScriptValuePrivate::JavaScriptCore) 1152 return JSC::JSValue::strictEqual(d->jscValue, d->engine->scriptValueToJSCValue(other)); 1153 else if (other.d_ptr->type == QScriptValuePrivate::JavaScriptCore) 1154 return JSC::JSValue::strictEqual(other.d_ptr->engine->scriptValueToJSCValue(*this), other.d_ptr->jscValue); 1160 if (d->type == QScriptValuePrivate::JavaScriptCore) { 1161 QScriptEnginePrivate *eng_p = d->engine ? d->engine : other.d_ptr->engine; 1162 if (eng_p) 1163 return JSC::JSValue::strictEqual(d->jscValue, eng_p->scriptValueToJSCValue(other)); 1164 } else if (other.d_ptr->type == QScriptValuePrivate::JavaScriptCore) { 1165 QScriptEnginePrivate *eng_p = other.d_ptr->engine ? other.d_ptr->engine : d->engine; 1166 if (eng_p) 1167 return JSC::JSValue::strictEqual(eng_p->scriptValueToJSCValue(*this), other.d_ptr->jscValue); 1168 } 1155 1169 1156 1170 return false; … … 1942 1956 if (!array.isUndefinedOrNull()) { 1943 1957 if (!array.isObject()) { 1944 return d->engine->scriptValueFromJSCValue(JSC::throwError(exec, JSC::TypeError ));1958 return d->engine->scriptValueFromJSCValue(JSC::throwError(exec, JSC::TypeError, "Arguments must be an array")); 1945 1959 } 1946 1960 if (JSC::asObject(array)->classInfo() == &JSC::Arguments::info) … … 1953 1967 applyArgs.append(JSC::asArray(array)->get(exec, i)); 1954 1968 } else { 1955 Q_ASSERT_X(false, Q_FUNC_INFO, "implement me"); 1956 // return JSC::throwError(exec, JSC::TypeError); 1969 return d->engine->scriptValueFromJSCValue(JSC::throwError(exec, JSC::TypeError, "Arguments must be an array")); 1957 1970 } 1958 1971 } -
trunk/src/script/bridge/qscriptclassobject.cpp
r651 r769 227 227 228 228 QScriptEnginePrivate *eng_p = scriptEngineFromExec(exec); 229 //JSC::ExecState *oldFrame = eng_p->currentFrame;229 JSC::ExecState *oldFrame = eng_p->currentFrame; 230 230 eng_p->pushContext(exec, JSC::JSValue(), args, callee, true); 231 231 QScriptContext *ctx = eng_p->contextForFrame(eng_p->currentFrame); … … 235 235 if (!result.isObject()) 236 236 result = defaultObject; 237 eng_p->popContext(); 238 eng_p->currentFrame = oldFrame; 237 239 return JSC::asObject(eng_p->scriptValueToJSCValue(result)); 238 240 } -
trunk/src/script/bridge/qscriptqobject_p.h
r651 r769 305 305 static WTF::PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) 306 306 { 307 return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType ));307 return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, JSC::ImplementsHasInstance)); 308 308 } 309 309 -
trunk/src/script/parser/qscriptlexer.cpp
r651 r769 32 32 QT_BEGIN_NAMESPACE 33 33 34 extern double qstrtod(const char *s00, char const **se, bool *ok);34 Q_DECL_IMPORT extern double qstrtod(const char *s00, char const **se, bool *ok); 35 35 36 36 #define shiftWindowsLineBreak() \
Note:
See TracChangeset
for help on using the changeset viewer.