diff options
author | Steve Block <steveblock@google.com> | 2010-02-05 14:27:46 +0000 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-02-15 10:49:50 +0000 |
commit | 5e2bc6953fe6923165b8a5d7679939693a1d58d6 (patch) | |
tree | 6ccb8c24bc2bf5e8f413e6cfae250b729b426631 /JavaScriptCore | |
parent | 4a00f4fccc3cb7e9996749a05631f5d7b9de756e (diff) | |
download | external_webkit-5e2bc6953fe6923165b8a5d7679939693a1d58d6.zip external_webkit-5e2bc6953fe6923165b8a5d7679939693a1d58d6.tar.gz external_webkit-5e2bc6953fe6923165b8a5d7679939693a1d58d6.tar.bz2 |
Merge webkit.org at r54340 : Initial merge by git
Change-Id: Ib489d2ff91186ea3652522e1d586e54416a2cf44
Diffstat (limited to 'JavaScriptCore')
20 files changed, 1343 insertions, 91 deletions
diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog index 3f64567..578e282 100644 --- a/JavaScriptCore/ChangeLog +++ b/JavaScriptCore/ChangeLog @@ -1,3 +1,335 @@ +2010-02-04 Jedrzej Nowacki <jedrzej.nowacki@nokia.com> + + Reviewed by Simon Hausmann. + + Increase test coverage for the QScriptValue. + + https://bugs.webkit.org/show_bug.cgi?id=34533 + + * qt/tests/qscriptvalue/qscriptvalue.pro: + * qt/tests/qscriptvalue/tst_qscriptvalue.cpp: + (tst_QScriptValue::tst_QScriptValue): + (tst_QScriptValue::~tst_QScriptValue): + (tst_QScriptValue::dataHelper): + (tst_QScriptValue::newRow): + (tst_QScriptValue::testHelper): + (tst_QScriptValue::ctor): + * qt/tests/qscriptvalue/tst_qscriptvalue.h: Added. + * qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp: Added. + (tst_QScriptValue::initScriptValues): + (tst_QScriptValue::isValid_initData): + (tst_QScriptValue::isValid_makeData): + (tst_QScriptValue::isValid_test): + (tst_QScriptValue::isBool_initData): + (tst_QScriptValue::isBool_makeData): + (tst_QScriptValue::isBool_test): + (tst_QScriptValue::isBoolean_initData): + (tst_QScriptValue::isBoolean_makeData): + (tst_QScriptValue::isBoolean_test): + (tst_QScriptValue::isFunction_initData): + (tst_QScriptValue::isFunction_makeData): + (tst_QScriptValue::isFunction_test): + (tst_QScriptValue::isNull_initData): + (tst_QScriptValue::isNull_makeData): + (tst_QScriptValue::isNull_test): + (tst_QScriptValue::isString_initData): + (tst_QScriptValue::isString_makeData): + (tst_QScriptValue::isString_test): + (tst_QScriptValue::isUndefined_initData): + (tst_QScriptValue::isUndefined_makeData): + (tst_QScriptValue::isUndefined_test): + (tst_QScriptValue::isObject_initData): + (tst_QScriptValue::isObject_makeData): + (tst_QScriptValue::isObject_test): + +2010-02-03 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Define WTF_PLATFORM_BREWMP_SIMULATOR when AEE_SIMULATOR is defined + https://bugs.webkit.org/show_bug.cgi?id=34514 + + PLATFORM(BREWMP_SIMULATOR) guard is needed to make distinction between BREWMP + and BREWMP simulator. + + * wtf/Platform.h: + +2010-02-03 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Remove COMPILE_ASSERT conflict with the underlying PLATFORM + https://bugs.webkit.org/show_bug.cgi?id=34190 + + COMPILE_ASSERT conflicts with the underlying PLATFORM because it is defined + both in WTF's Assertions.h and BREWMP's AEEClassIDs.h. Include AEEClassIDs.h + in Assertions.h and undef COMPILE_ASSERT to avoid redefining COMPILE_ASSERT. + + * wtf/Assertions.h: + +2010-02-03 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Implement OwnPtrBrew to make sure BREW instances are freed. + https://bugs.webkit.org/show_bug.cgi?id=34518 + + Add OwnPtrBrew to release IFile, IFileMgr and IBitmap instances. + + * wtf/brew/OwnPtrBrew.cpp: Added. + (WTF::IFileMgr): + (WTF::IFile): + (WTF::IBitmap): + (WTF::freeOwnedPtrBrew): + * wtf/brew/OwnPtrBrew.h: Added. + (WTF::OwnPtrBrew::OwnPtrBrew): + (WTF::OwnPtrBrew::~OwnPtrBrew): + (WTF::OwnPtrBrew::get): + (WTF::OwnPtrBrew::release): + (WTF::OwnPtrBrew::outPtr): + (WTF::OwnPtrBrew::set): + (WTF::OwnPtrBrew::clear): + (WTF::OwnPtrBrew::operator*): + (WTF::OwnPtrBrew::operator->): + (WTF::OwnPtrBrew::operator!): + (WTF::OwnPtrBrew::operator UnspecifiedBoolType): + (WTF::OwnPtrBrew::swap): + (WTF::swap): + (WTF::operator==): + (WTF::operator!=): + (WTF::getPtr): + +2010-02-03 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Darin Adler. + + Export WTF::fastStrDup symbol + https://bugs.webkit.org/show_bug.cgi?id=34526 + + * JavaScriptCore.exp: + +2010-02-03 Kevin Watters <kevinwatters@gmail.com> + + Reviewed by Kevin Ollivier. + + [wx] Enable JIT compilation for wx. + + https://bugs.webkit.org/show_bug.cgi?id=34536 + + * wtf/Platform.h: + +2010-02-02 Oliver Hunt <oliver@apple.com> + + Reviewed by Geoffrey Garen. + + Crash in CollectorBitmap::get at nbcolympics.com + https://bugs.webkit.org/show_bug.cgi?id=34504 + + This was caused by the use of m_offset to determine the offset of + a new property into the property storage. This patch corrects + the effected cases by incorporating the anonymous slot count. It + also removes the duplicate copy of anonymous slot count from the + property table as keeping this up to date merely increased the + chance of a mismatch. Finally I've added a large number of + assertions in an attempt to prevent such a bug from happening + again. + + With the new assertions in place the existing anonymous slot tests + all fail without the m_offset fixes. + + * runtime/PropertyMapHashTable.h: + * runtime/Structure.cpp: + (JSC::Structure::materializePropertyMap): + (JSC::Structure::addPropertyTransitionToExistingStructure): + (JSC::Structure::addPropertyTransition): + (JSC::Structure::removePropertyTransition): + (JSC::Structure::flattenDictionaryStructure): + (JSC::Structure::addPropertyWithoutTransition): + (JSC::Structure::removePropertyWithoutTransition): + (JSC::Structure::copyPropertyTable): + (JSC::Structure::get): + (JSC::Structure::put): + (JSC::Structure::remove): + (JSC::Structure::insertIntoPropertyMapHashTable): + (JSC::Structure::createPropertyMapHashTable): + (JSC::Structure::rehashPropertyMapHashTable): + (JSC::Structure::checkConsistency): + +2010-02-02 Steve Falkenburg <sfalken@apple.com> + + Reviewed by Darin Adler. + + Copyright year updating for Windows version resources should be automatic + https://bugs.webkit.org/show_bug.cgi?id=34503 + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.rc: + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Add dummy main thread functions + https://bugs.webkit.org/show_bug.cgi?id=33569 + + Add dummy initializeMainThreadPlatform and + scheduleDispatchFunctionsOnMainThread. + + * wtf/brew/MainThreadBrew.cpp: Added. + (WTF::initializeMainThreadPlatform): + (WTF::scheduleDispatchFunctionsOnMainThread): + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Darin Adler. + + Add using WTF::getLocalTime to CurrentTime.h + https://bugs.webkit.org/show_bug.cgi?id=34493 + + * wtf/CurrentTime.h: + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Add HAVE_XXX definitions + https://bugs.webkit.org/show_bug.cgi?id=34414 + + Add HAVE_ERRNO_H=1 + + * wtf/Platform.h: + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Don't define HAVE_TM_GMTOFF, HAVE_TM_ZONE and HAVE_TIMEGM + https://bugs.webkit.org/show_bug.cgi?id=34388 + + BREWMP does not have these features. + + * wtf/Platform.h: + +2010-02-02 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Define WTF_PLATFORM_BREWMP=1 when BUILDING_BREWMP is defined + https://bugs.webkit.org/show_bug.cgi?id=34386 + + Define WTF_PLATFORM_BREWMP=1 so that PLATFORM(BREWMP) guard can be used. + + * wtf/Platform.h: + +2010-02-01 Kent Tamura <tkent@chromium.org> + + Reviewed by Darin Adler. + + Date.UTC() should apply TimeClip operation. + https://bugs.webkit.org/show_bug.cgi?id=34461 + + ECMAScript 5 15.9.4.3: + > 9 Return TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli))). + + * runtime/DateConstructor.cpp: + (JSC::dateUTC): Calls WTF::timeClip(). + +2010-02-01 Kent Tamura <tkent@chromium.org> + + Reviewed by Darin Adler. + + Fix a bug that Math.round() retunrs incorrect results for huge integers + https://bugs.webkit.org/show_bug.cgi?id=34462 + + * runtime/MathObject.cpp: + (JSC::mathProtoFuncRound): Avoid "arg + 0.5". + +2010-02-01 Kwang Yul Seo <skyul@company100.net> + + Reviewed by Eric Seidel. + + [BREWMP] Port WTF's currentTime + https://bugs.webkit.org/show_bug.cgi?id=33567 + + Combine GETUTCSECONDS and GETTIMEMS to calculate the number + of milliseconds since 1970/01/01 00:00:00 UTC. + + * wtf/CurrentTime.cpp: + (WTF::currentTime): + +2010-02-01 Patrick Gansterer <paroga@paroga.com> + + Reviewed by Darin Adler. + + [Qt] WinCE buildfix after r52729 and fix for Q_BIG_ENDIAN typo. + https://bugs.webkit.org/show_bug.cgi?id=34378 + + * wtf/Platform.h: + +2010-02-01 Oliver Hunt <oliver@apple.com> + + Reviewed by Gavin Barraclough. + + Structure not accounting for anonymous slots when computing property storage size + https://bugs.webkit.org/show_bug.cgi?id=34441 + + Previously any Structure with anonymous storage would have a property map, so we + were only including anonymous slot size if there was a property map. Given this + is no longer the case we should always include the anonymous slot count in the + property storage size. + + * runtime/Structure.h: + (JSC::Structure::propertyStorageSize): + +2010-02-01 Oliver Hunt <oliver@apple.com> + + Windows build fix, update exports file (again) + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2010-02-01 Oliver Hunt <oliver@apple.com> + + Windows build fix, update exports file + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + +2010-01-31 Oliver Hunt <oliver@apple.com> + + Reviewed by Maciej Stachowiak. + + JSC is failing to propagate anonymous slot count on some transitions + https://bugs.webkit.org/show_bug.cgi?id=34321 + + Remove secondary Structure constructor, and make Structure store a copy + of the number of anonymous slots directly so saving an immediate allocation + of a property map for all structures with anonymous storage, which also + avoids the leaked property map on new property transition in the original + version of this patch. + + We need to propagate the the anonymous slot count otherwise we can end up + with a structure recording incorrect information about the available and + needed space for property storage, or alternatively incorrectly reusing + some slots. + + * JavaScriptCore.exp: + * runtime/Structure.cpp: + (JSC::Structure::Structure): + (JSC::Structure::materializePropertyMap): + (JSC::Structure::addPropertyTransition): + (JSC::Structure::changePrototypeTransition): + (JSC::Structure::despecifyFunctionTransition): + (JSC::Structure::getterSetterTransition): + (JSC::Structure::toDictionaryTransition): + (JSC::Structure::flattenDictionaryStructure): + (JSC::Structure::copyPropertyTable): + (JSC::Structure::put): + (JSC::Structure::remove): + (JSC::Structure::insertIntoPropertyMapHashTable): + (JSC::Structure::createPropertyMapHashTable): + * runtime/Structure.h: + (JSC::Structure::create): + (JSC::Structure::hasAnonymousSlots): + (JSC::Structure::anonymousSlotCount): + 2010-01-31 Patrick Gansterer <paroga@paroga.com> Reviewed by Darin Adler. diff --git a/JavaScriptCore/JavaScriptCore.exp b/JavaScriptCore/JavaScriptCore.exp index 3821992..01d3144 100644 --- a/JavaScriptCore/JavaScriptCore.exp +++ b/JavaScriptCore/JavaScriptCore.exp @@ -292,7 +292,7 @@ __ZN3JSC9Structure27despecifyFunctionTransitionEPS0_RKNS_10IdentifierE __ZN3JSC9Structure28addPropertyWithoutTransitionERKNS_10IdentifierEjPNS_6JSCellE __ZN3JSC9Structure3getEPKNS_11UStringImplERjRPNS_6JSCellE __ZN3JSC9Structure40addPropertyTransitionToExistingStructureEPS0_RKNS_10IdentifierEjPNS_6JSCellERm -__ZN3JSC9StructureC1ENS_7JSValueERKNS_8TypeInfoE +__ZN3JSC9StructureC1ENS_7JSValueERKNS_8TypeInfoEj __ZN3JSC9StructureD1Ev __ZN3JSC9constructEPNS_9ExecStateENS_7JSValueENS_13ConstructTypeERKNS_13ConstructDataERKNS_7ArgListE __ZN3JSCeqERKNS_7UStringEPKc @@ -348,6 +348,7 @@ __ZN3WTF8Collator18setOrderLowerFirstEb __ZN3WTF8CollatorC1EPKc __ZN3WTF8CollatorD1Ev __ZN3WTF8fastFreeEPv +__ZN3WTF10fastStrDupEPKc __ZN3WTF8msToYearEd __ZN3WTF9dayInYearEdi __ZN3WTF9ByteArray6createEm diff --git a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def index 65ba684..6a0f1d8 100644 --- a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def +++ b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def @@ -14,7 +14,7 @@ EXPORTS ??0PrototypeFunction@JSC@@QAE@PAVExecState@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@HABVIdentifier@1@P6I?AVJSValue@1@0PAVJSObject@1@V61@ABVArgList@1@@Z@Z ??0RefCountedLeakCounter@WTF@@QAE@PBD@Z ??0StringObject@JSC@@QAE@PAVExecState@1@V?$NonNullPassRefPtr@VStructure@JSC@@@WTF@@ABVUString@1@@Z - ??0Structure@JSC@@AAE@VJSValue@1@ABVTypeInfo@1@@Z + ??0Structure@JSC@@AAE@VJSValue@1@ABVTypeInfo@1@I@Z ??0ThreadCondition@WTF@@QAE@XZ ??0UString@JSC@@QAE@PBD@Z ??0UString@JSC@@QAE@PB_WH@Z diff --git a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.rc b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.rc index 861fa3a..e09e26e 100644 --- a/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.rc +++ b/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.rc @@ -34,7 +34,7 @@ BEGIN VALUE "FileVersion", __VERSION_TEXT__ VALUE "CompanyName", "Apple Inc." VALUE "InternalName", "JavaScriptCore" - VALUE "LegalCopyright", "Copyright Apple Inc. 2003-2010" + VALUE "LegalCopyright", "Copyright Apple Inc. 2003-" __COPYRIGHT_YEAR_END_TEXT__ VALUE "OriginalFilename", "JavaScriptCore.dll" VALUE "ProductName", " JavaScriptCore" VALUE "ProductVersion", __VERSION_TEXT__ diff --git a/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro b/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro index 1ce5bc3..b12337f 100644 --- a/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro +++ b/JavaScriptCore/qt/tests/qscriptvalue/qscriptvalue.pro @@ -3,5 +3,9 @@ TARGET = tst_qscriptvalue QT += testlib include(../tests.pri) -SOURCES += tst_qscriptvalue.cpp +SOURCES += \ + tst_qscriptvalue.cpp \ + tst_qscriptvalue_generated.cpp +HEADERS += \ + tst_qscriptvalue.h diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp index 336a1a6..b44c5ca 100644 --- a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp +++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.cpp @@ -17,35 +17,43 @@ Boston, MA 02110-1301, USA. */ -#include "qscriptengine.h" -#include "qscriptvalue.h" -#include <QtTest/qtest.h> - -Q_DECLARE_METATYPE(QScriptValue*); -Q_DECLARE_METATYPE(QScriptValue); - -class tst_QScriptValue : public QObject { - Q_OBJECT - -public: - tst_QScriptValue() {} - virtual ~tst_QScriptValue() {} - -private slots: - void toString_data(); - void toString(); - void copyConstructor_data(); - void copyConstructor(); - void assignOperator_data(); - void assignOperator(); - void dataSharing(); - void constructors_data(); - void constructors(); - void call(); - - // copied from Qt's QtScript. - void ctor(); -}; +#include "tst_qscriptvalue.h" +#include <QtCore/qnumeric.h> + +tst_QScriptValue::tst_QScriptValue() + : engine(0) +{ +} + +tst_QScriptValue::~tst_QScriptValue() +{ + delete engine; +} + +void tst_QScriptValue::dataHelper(InitDataFunction init, DefineDataFunction define) +{ + QTest::addColumn<QString>("__expression__"); + (this->*init)(); + QHash<QString, QScriptValue>::const_iterator it; + for (it = m_values.constBegin(); it != m_values.constEnd(); ++it) { + m_currentExpression = it.key(); + (this->*define)(it.key().toLatin1()); + } + m_currentExpression = QString(); +} + +QTestData& tst_QScriptValue::newRow(const char* tag) +{ + return QTest::newRow(tag) << m_currentExpression; +} + +void tst_QScriptValue::testHelper(TestFunction fun) +{ + QFETCH(QString, __expression__); + QScriptValue value = m_values.value(__expression__); + (this->*fun)(__expression__.toLatin1(), value); +} + void tst_QScriptValue::ctor() { @@ -53,7 +61,7 @@ void tst_QScriptValue::ctor() { QScriptValue v; QCOMPARE(v.isValid(), false); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v(&eng, QScriptValue::UndefinedValue); @@ -168,14 +176,14 @@ void tst_QScriptValue::ctor() QCOMPARE(v.isValid(), true); QCOMPARE(v.isUndefined(), true); QCOMPARE(v.isObject(), false); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v(QScriptValue::NullValue); QCOMPARE(v.isValid(), true); QCOMPARE(v.isNull(), true); QCOMPARE(v.isObject(), false); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v(false); @@ -184,7 +192,7 @@ void tst_QScriptValue::ctor() QCOMPARE(v.isBool(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toBoolean(), false); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v(int(1)); @@ -192,7 +200,7 @@ void tst_QScriptValue::ctor() QCOMPARE(v.isNumber(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v(uint(1)); @@ -200,7 +208,7 @@ void tst_QScriptValue::ctor() QCOMPARE(v.isNumber(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v(1.0); @@ -208,7 +216,7 @@ void tst_QScriptValue::ctor() QCOMPARE(v.isNumber(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toNumber(), 1.0); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v("ciao"); @@ -216,7 +224,7 @@ void tst_QScriptValue::ctor() QCOMPARE(v.isString(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toString(), QLatin1String("ciao")); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } { QScriptValue v(QString("ciao")); @@ -224,19 +232,19 @@ void tst_QScriptValue::ctor() QCOMPARE(v.isString(), true); QCOMPARE(v.isObject(), false); QCOMPARE(v.toString(), QLatin1String("ciao")); - QCOMPARE(v.engine(), (QScriptEngine *)0); + QCOMPARE(v.engine(), (QScriptEngine*)0); } // copy constructor, operator= { QScriptValue v(1.0); QScriptValue v2(v); QCOMPARE(v2.strictlyEquals(v), true); - QCOMPARE(v2.engine(), (QScriptEngine *)0); + QCOMPARE(v2.engine(), (QScriptEngine*)0); QScriptValue v3(v); QCOMPARE(v3.strictlyEquals(v), true); QCOMPARE(v3.strictlyEquals(v2), true); - QCOMPARE(v3.engine(), (QScriptEngine *)0); + QCOMPARE(v3.engine(), (QScriptEngine*)0); QScriptValue v4(2.0); QCOMPARE(v4.strictlyEquals(v), false); @@ -423,5 +431,5 @@ void tst_QScriptValue::call() QVERIFY(incr.call().isValid()); // Exception. } + QTEST_MAIN(tst_QScriptValue) -#include "tst_qscriptvalue.moc" diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h new file mode 100644 index 0000000..ae81c49 --- /dev/null +++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue.h @@ -0,0 +1,133 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef tst_qscriptvalue_h +#define tst_qscriptvalue_h + +#include "qscriptengine.h" +#include "qscriptvalue.h" +#include <QtCore/qnumeric.h> +#include <QtTest/qtest.h> + +Q_DECLARE_METATYPE(QScriptValue*); +Q_DECLARE_METATYPE(QScriptValue); + +class tst_QScriptValue : public QObject { + Q_OBJECT + +public: + tst_QScriptValue(); + virtual ~tst_QScriptValue(); + +private slots: + void toString_data(); + void toString(); + void copyConstructor_data(); + void copyConstructor(); + void assignOperator_data(); + void assignOperator(); + void dataSharing(); + void constructors_data(); + void constructors(); + void call(); + void ctor(); + + // Generated test functions. + void isBool_data(); + void isBool(); + + void isBoolean_data(); + void isBoolean(); + + void isFunction_data(); + void isFunction(); + + void isNull_data(); + void isNull(); + + void isObject_data(); + void isObject(); + + void isString_data(); + void isString(); + + void isUndefined_data(); + void isUndefined(); + + void isValid_data(); + void isValid(); + +private: + typedef void (tst_QScriptValue::*InitDataFunction)(); + typedef void (tst_QScriptValue::*DefineDataFunction)(const char*); + void dataHelper(InitDataFunction init, DefineDataFunction define); + QTestData& newRow(const char* tag); + + typedef void (tst_QScriptValue::*TestFunction)(const char*, const QScriptValue&); + void testHelper(TestFunction fun); + + // Generated functions + + void initScriptValues(); + + void isBool_initData(); + void isBool_makeData(const char* expr); + void isBool_test(const char* expr, const QScriptValue& value); + + void isBoolean_initData(); + void isBoolean_makeData(const char* expr); + void isBoolean_test(const char* expr, const QScriptValue& value); + + void isFunction_initData(); + void isFunction_makeData(const char* expr); + void isFunction_test(const char* expr, const QScriptValue& value); + + void isNull_initData(); + void isNull_makeData(const char* expr); + void isNull_test(const char* expr, const QScriptValue& value); + + void isObject_initData(); + void isObject_makeData(const char* expr); + void isObject_test(const char* expr, const QScriptValue& value); + + void isString_initData(); + void isString_makeData(const char* expr); + void isString_test(const char* expr, const QScriptValue& value); + + void isUndefined_initData(); + void isUndefined_makeData(const char* expr); + void isUndefined_test(const char* expr, const QScriptValue& value); + + void isValid_initData(); + void isValid_makeData(const char* expr); + void isValid_test(const char* expr, const QScriptValue& value); + +private: + QScriptEngine* engine; + QHash<QString, QScriptValue> m_values; + QString m_currentExpression; +}; + +#define DEFINE_TEST_FUNCTION(name) \ +void tst_QScriptValue::name##_data() { dataHelper(&tst_QScriptValue::name##_initData, &tst_QScriptValue::name##_makeData); } \ +void tst_QScriptValue::name() { testHelper(&tst_QScriptValue::name##_test); } + + + +#endif // tst_qscriptvalue_h diff --git a/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp new file mode 100644 index 0000000..6d8ef48 --- /dev/null +++ b/JavaScriptCore/qt/tests/qscriptvalue/tst_qscriptvalue_generated.cpp @@ -0,0 +1,495 @@ +/* + Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "tst_qscriptvalue.h" + +#define DEFINE_TEST_VALUE(expr) m_values.insert(QString::fromLatin1(#expr), expr) + +void tst_QScriptValue::initScriptValues() +{ + m_values.clear(); + if (engine) + delete engine; + engine = new QScriptEngine; + DEFINE_TEST_VALUE(QScriptValue()); + DEFINE_TEST_VALUE(QScriptValue(QScriptValue::UndefinedValue)); + DEFINE_TEST_VALUE(QScriptValue(QScriptValue::NullValue)); + DEFINE_TEST_VALUE(QScriptValue(true)); + DEFINE_TEST_VALUE(QScriptValue(false)); + DEFINE_TEST_VALUE(QScriptValue(int(122))); + DEFINE_TEST_VALUE(QScriptValue(uint(124))); + DEFINE_TEST_VALUE(QScriptValue(0)); + DEFINE_TEST_VALUE(QScriptValue(0.0)); + DEFINE_TEST_VALUE(QScriptValue(123.0)); + DEFINE_TEST_VALUE(QScriptValue(6.37e-8)); + DEFINE_TEST_VALUE(QScriptValue(-6.37e-8)); + DEFINE_TEST_VALUE(QScriptValue(0x43211234)); + DEFINE_TEST_VALUE(QScriptValue(0x10000)); + DEFINE_TEST_VALUE(QScriptValue(0x10001)); + DEFINE_TEST_VALUE(QScriptValue(qSNaN())); + DEFINE_TEST_VALUE(QScriptValue(qQNaN())); + DEFINE_TEST_VALUE(QScriptValue(qInf())); + DEFINE_TEST_VALUE(QScriptValue(-qInf())); + DEFINE_TEST_VALUE(QScriptValue("NaN")); + DEFINE_TEST_VALUE(QScriptValue("Infinity")); + DEFINE_TEST_VALUE(QScriptValue("-Infinity")); + DEFINE_TEST_VALUE(QScriptValue("ciao")); + DEFINE_TEST_VALUE(QScriptValue(QString::fromLatin1("ciao"))); + DEFINE_TEST_VALUE(QScriptValue(QString(""))); + DEFINE_TEST_VALUE(QScriptValue(QString())); + DEFINE_TEST_VALUE(QScriptValue(QString("0"))); + DEFINE_TEST_VALUE(QScriptValue(QString("123"))); + DEFINE_TEST_VALUE(QScriptValue(QString("12.4"))); + DEFINE_TEST_VALUE(QScriptValue(0, QScriptValue::UndefinedValue)); + DEFINE_TEST_VALUE(QScriptValue(0, QScriptValue::NullValue)); + DEFINE_TEST_VALUE(QScriptValue(0, true)); + DEFINE_TEST_VALUE(QScriptValue(0, false)); + DEFINE_TEST_VALUE(QScriptValue(0, int(122))); + DEFINE_TEST_VALUE(QScriptValue(0, uint(124))); + DEFINE_TEST_VALUE(QScriptValue(0, 0)); + DEFINE_TEST_VALUE(QScriptValue(0, 0.0)); + DEFINE_TEST_VALUE(QScriptValue(0, 123.0)); + DEFINE_TEST_VALUE(QScriptValue(0, 6.37e-8)); + DEFINE_TEST_VALUE(QScriptValue(0, -6.37e-8)); + DEFINE_TEST_VALUE(QScriptValue(0, 0x43211234)); + DEFINE_TEST_VALUE(QScriptValue(0, 0x10000)); + DEFINE_TEST_VALUE(QScriptValue(0, 0x10001)); + DEFINE_TEST_VALUE(QScriptValue(0, qSNaN())); + DEFINE_TEST_VALUE(QScriptValue(0, qQNaN())); + DEFINE_TEST_VALUE(QScriptValue(0, qInf())); + DEFINE_TEST_VALUE(QScriptValue(0, -qInf())); + DEFINE_TEST_VALUE(QScriptValue(0, "NaN")); + DEFINE_TEST_VALUE(QScriptValue(0, "Infinity")); + DEFINE_TEST_VALUE(QScriptValue(0, "-Infinity")); + DEFINE_TEST_VALUE(QScriptValue(0, "ciao")); + DEFINE_TEST_VALUE(QScriptValue(0, QString::fromLatin1("ciao"))); + DEFINE_TEST_VALUE(QScriptValue(0, QString(""))); + DEFINE_TEST_VALUE(QScriptValue(0, QString())); + DEFINE_TEST_VALUE(QScriptValue(0, QString("0"))); + DEFINE_TEST_VALUE(QScriptValue(0, QString("123"))); + DEFINE_TEST_VALUE(QScriptValue(0, QString("12.3"))); + DEFINE_TEST_VALUE(QScriptValue(engine, QScriptValue::UndefinedValue)); + DEFINE_TEST_VALUE(QScriptValue(engine, QScriptValue::NullValue)); + DEFINE_TEST_VALUE(QScriptValue(engine, true)); + DEFINE_TEST_VALUE(QScriptValue(engine, false)); + DEFINE_TEST_VALUE(QScriptValue(engine, int(122))); + DEFINE_TEST_VALUE(QScriptValue(engine, uint(124))); + DEFINE_TEST_VALUE(QScriptValue(engine, 0)); + DEFINE_TEST_VALUE(QScriptValue(engine, 0.0)); + DEFINE_TEST_VALUE(QScriptValue(engine, 123.0)); + DEFINE_TEST_VALUE(QScriptValue(engine, 6.37e-8)); + DEFINE_TEST_VALUE(QScriptValue(engine, -6.37e-8)); + DEFINE_TEST_VALUE(QScriptValue(engine, 0x43211234)); + DEFINE_TEST_VALUE(QScriptValue(engine, 0x10000)); + DEFINE_TEST_VALUE(QScriptValue(engine, 0x10001)); + DEFINE_TEST_VALUE(QScriptValue(engine, qSNaN())); + DEFINE_TEST_VALUE(QScriptValue(engine, qQNaN())); + DEFINE_TEST_VALUE(QScriptValue(engine, qInf())); + DEFINE_TEST_VALUE(QScriptValue(engine, -qInf())); + DEFINE_TEST_VALUE(QScriptValue(engine, "NaN")); + DEFINE_TEST_VALUE(QScriptValue(engine, "Infinity")); + DEFINE_TEST_VALUE(QScriptValue(engine, "-Infinity")); + DEFINE_TEST_VALUE(QScriptValue(engine, "ciao")); + DEFINE_TEST_VALUE(QScriptValue(engine, QString::fromLatin1("ciao"))); + DEFINE_TEST_VALUE(QScriptValue(engine, QString(""))); + DEFINE_TEST_VALUE(QScriptValue(engine, QString())); + DEFINE_TEST_VALUE(QScriptValue(engine, QString("0"))); + DEFINE_TEST_VALUE(QScriptValue(engine, QString("123"))); + DEFINE_TEST_VALUE(QScriptValue(engine, QString("1.23"))); + DEFINE_TEST_VALUE(engine->evaluate("[]")); + DEFINE_TEST_VALUE(engine->evaluate("{}")); + DEFINE_TEST_VALUE(engine->evaluate("Object.prototype")); + DEFINE_TEST_VALUE(engine->evaluate("Date.prototype")); + DEFINE_TEST_VALUE(engine->evaluate("Array.prototype")); + DEFINE_TEST_VALUE(engine->evaluate("Function.prototype")); + DEFINE_TEST_VALUE(engine->evaluate("Error.prototype")); + DEFINE_TEST_VALUE(engine->evaluate("Object")); + DEFINE_TEST_VALUE(engine->evaluate("Array")); + DEFINE_TEST_VALUE(engine->evaluate("Number")); + DEFINE_TEST_VALUE(engine->evaluate("Function")); + DEFINE_TEST_VALUE(engine->evaluate("(function() { return 1; })")); + DEFINE_TEST_VALUE(engine->evaluate("(function() { return 'ciao'; })")); + DEFINE_TEST_VALUE(engine->evaluate("(function() { throw new Error('foo'); })")); + DEFINE_TEST_VALUE(engine->evaluate("/foo/")); + DEFINE_TEST_VALUE(engine->evaluate("new Object()")); + DEFINE_TEST_VALUE(engine->evaluate("new Array()")); + DEFINE_TEST_VALUE(engine->evaluate("new Error()")); +} + + +void tst_QScriptValue::isValid_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isValid_makeData(const char* expr) +{ + static QSet<QString> isValid; + if (isValid.isEmpty()) { + isValid << "QScriptValue(QScriptValue::UndefinedValue)" + << "QScriptValue(QScriptValue::NullValue)" + << "QScriptValue(true)" + << "QScriptValue(false)" + << "QScriptValue(int(122))" + << "QScriptValue(uint(124))" + << "QScriptValue(0)" + << "QScriptValue(0.0)" + << "QScriptValue(123.0)" + << "QScriptValue(6.37e-8)" + << "QScriptValue(-6.37e-8)" + << "QScriptValue(0x43211234)" + << "QScriptValue(0x10000)" + << "QScriptValue(0x10001)" + << "QScriptValue(qSNaN())" + << "QScriptValue(qQNaN())" + << "QScriptValue(qInf())" + << "QScriptValue(-qInf())" + << "QScriptValue(\"NaN\")" + << "QScriptValue(\"Infinity\")" + << "QScriptValue(\"-Infinity\")" + << "QScriptValue(\"ciao\")" + << "QScriptValue(QString::fromLatin1(\"ciao\"))" + << "QScriptValue(QString(\"\"))" + << "QScriptValue(QString())" + << "QScriptValue(QString(\"0\"))" + << "QScriptValue(QString(\"123\"))" + << "QScriptValue(QString(\"12.4\"))" + << "QScriptValue(0, QScriptValue::UndefinedValue)" + << "QScriptValue(0, QScriptValue::NullValue)" + << "QScriptValue(0, true)" + << "QScriptValue(0, false)" + << "QScriptValue(0, int(122))" + << "QScriptValue(0, uint(124))" + << "QScriptValue(0, 0)" + << "QScriptValue(0, 0.0)" + << "QScriptValue(0, 123.0)" + << "QScriptValue(0, 6.37e-8)" + << "QScriptValue(0, -6.37e-8)" + << "QScriptValue(0, 0x43211234)" + << "QScriptValue(0, 0x10000)" + << "QScriptValue(0, 0x10001)" + << "QScriptValue(0, qSNaN())" + << "QScriptValue(0, qQNaN())" + << "QScriptValue(0, qInf())" + << "QScriptValue(0, -qInf())" + << "QScriptValue(0, \"NaN\")" + << "QScriptValue(0, \"Infinity\")" + << "QScriptValue(0, \"-Infinity\")" + << "QScriptValue(0, \"ciao\")" + << "QScriptValue(0, QString::fromLatin1(\"ciao\"))" + << "QScriptValue(0, QString(\"\"))" + << "QScriptValue(0, QString())" + << "QScriptValue(0, QString(\"0\"))" + << "QScriptValue(0, QString(\"123\"))" + << "QScriptValue(0, QString(\"12.3\"))" + << "QScriptValue(engine, QScriptValue::UndefinedValue)" + << "QScriptValue(engine, QScriptValue::NullValue)" + << "QScriptValue(engine, true)" + << "QScriptValue(engine, false)" + << "QScriptValue(engine, int(122))" + << "QScriptValue(engine, uint(124))" + << "QScriptValue(engine, 0)" + << "QScriptValue(engine, 0.0)" + << "QScriptValue(engine, 123.0)" + << "QScriptValue(engine, 6.37e-8)" + << "QScriptValue(engine, -6.37e-8)" + << "QScriptValue(engine, 0x43211234)" + << "QScriptValue(engine, 0x10000)" + << "QScriptValue(engine, 0x10001)" + << "QScriptValue(engine, qSNaN())" + << "QScriptValue(engine, qQNaN())" + << "QScriptValue(engine, qInf())" + << "QScriptValue(engine, -qInf())" + << "QScriptValue(engine, \"NaN\")" + << "QScriptValue(engine, \"Infinity\")" + << "QScriptValue(engine, \"-Infinity\")" + << "QScriptValue(engine, \"ciao\")" + << "QScriptValue(engine, QString::fromLatin1(\"ciao\"))" + << "QScriptValue(engine, QString(\"\"))" + << "QScriptValue(engine, QString())" + << "QScriptValue(engine, QString(\"0\"))" + << "QScriptValue(engine, QString(\"123\"))" + << "QScriptValue(engine, QString(\"1.23\"))" + << "engine->evaluate(\"[]\")" + << "engine->evaluate(\"{}\")" + << "engine->evaluate(\"Object.prototype\")" + << "engine->evaluate(\"Date.prototype\")" + << "engine->evaluate(\"Array.prototype\")" + << "engine->evaluate(\"Function.prototype\")" + << "engine->evaluate(\"Error.prototype\")" + << "engine->evaluate(\"Object\")" + << "engine->evaluate(\"Array\")" + << "engine->evaluate(\"Number\")" + << "engine->evaluate(\"Function\")" + << "engine->evaluate(\"(function() { return 1; })\")" + << "engine->evaluate(\"(function() { return 'ciao'; })\")" + << "engine->evaluate(\"(function() { throw new Error('foo'); })\")" + << "engine->evaluate(\"/foo/\")" + << "engine->evaluate(\"new Object()\")" + << "engine->evaluate(\"new Array()\")" + << "engine->evaluate(\"new Error()\")"; + } + newRow(expr) << isValid.contains(expr); +} + +void tst_QScriptValue::isValid_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isValid(), expected); +} + +DEFINE_TEST_FUNCTION(isValid) + + +void tst_QScriptValue::isBool_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isBool_makeData(const char* expr) +{ + static QSet<QString> isBool; + if (isBool.isEmpty()) { + isBool << "QScriptValue(true)" + << "QScriptValue(false)" + << "QScriptValue(0, true)" + << "QScriptValue(0, false)" + << "QScriptValue(engine, true)" + << "QScriptValue(engine, false)"; + } + newRow(expr) << isBool.contains(expr); +} + +void tst_QScriptValue::isBool_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isBool(), expected); +} + +DEFINE_TEST_FUNCTION(isBool) + + +void tst_QScriptValue::isBoolean_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isBoolean_makeData(const char* expr) +{ + static QSet<QString> isBoolean; + if (isBoolean.isEmpty()) { + isBoolean << "QScriptValue(true)" + << "QScriptValue(false)" + << "QScriptValue(0, true)" + << "QScriptValue(0, false)" + << "QScriptValue(engine, true)" + << "QScriptValue(engine, false)"; + } + newRow(expr) << isBoolean.contains(expr); +} + +void tst_QScriptValue::isBoolean_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isBoolean(), expected); +} + +DEFINE_TEST_FUNCTION(isBoolean) + + +void tst_QScriptValue::isFunction_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isFunction_makeData(const char* expr) +{ + static QSet<QString> isFunction; + if (isFunction.isEmpty()) { + isFunction << "engine->evaluate(\"Function.prototype\")" + << "engine->evaluate(\"Object\")" + << "engine->evaluate(\"Array\")" + << "engine->evaluate(\"Number\")" + << "engine->evaluate(\"Function\")" + << "engine->evaluate(\"(function() { return 1; })\")" + << "engine->evaluate(\"(function() { return 'ciao'; })\")" + << "engine->evaluate(\"(function() { throw new Error('foo'); })\")" + << "engine->evaluate(\"/foo/\")"; + } + newRow(expr) << isFunction.contains(expr); +} + +void tst_QScriptValue::isFunction_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isFunction(), expected); +} + +DEFINE_TEST_FUNCTION(isFunction) + + +void tst_QScriptValue::isNull_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isNull_makeData(const char* expr) +{ + static QSet<QString> isNull; + if (isNull.isEmpty()) { + isNull << "QScriptValue(QScriptValue::NullValue)" + << "QScriptValue(0, QScriptValue::NullValue)" + << "QScriptValue(engine, QScriptValue::NullValue)"; + } + newRow(expr) << isNull.contains(expr); +} + +void tst_QScriptValue::isNull_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isNull(), expected); +} + +DEFINE_TEST_FUNCTION(isNull) + + +void tst_QScriptValue::isString_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isString_makeData(const char* expr) +{ + static QSet<QString> isString; + if (isString.isEmpty()) { + isString << "QScriptValue(\"NaN\")" + << "QScriptValue(\"Infinity\")" + << "QScriptValue(\"-Infinity\")" + << "QScriptValue(\"ciao\")" + << "QScriptValue(QString::fromLatin1(\"ciao\"))" + << "QScriptValue(QString(\"\"))" + << "QScriptValue(QString())" + << "QScriptValue(QString(\"0\"))" + << "QScriptValue(QString(\"123\"))" + << "QScriptValue(QString(\"12.4\"))" + << "QScriptValue(0, \"NaN\")" + << "QScriptValue(0, \"Infinity\")" + << "QScriptValue(0, \"-Infinity\")" + << "QScriptValue(0, \"ciao\")" + << "QScriptValue(0, QString::fromLatin1(\"ciao\"))" + << "QScriptValue(0, QString(\"\"))" + << "QScriptValue(0, QString())" + << "QScriptValue(0, QString(\"0\"))" + << "QScriptValue(0, QString(\"123\"))" + << "QScriptValue(0, QString(\"12.3\"))" + << "QScriptValue(engine, \"NaN\")" + << "QScriptValue(engine, \"Infinity\")" + << "QScriptValue(engine, \"-Infinity\")" + << "QScriptValue(engine, \"ciao\")" + << "QScriptValue(engine, QString::fromLatin1(\"ciao\"))" + << "QScriptValue(engine, QString(\"\"))" + << "QScriptValue(engine, QString())" + << "QScriptValue(engine, QString(\"0\"))" + << "QScriptValue(engine, QString(\"123\"))" + << "QScriptValue(engine, QString(\"1.23\"))"; + } + newRow(expr) << isString.contains(expr); +} + +void tst_QScriptValue::isString_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isString(), expected); +} + +DEFINE_TEST_FUNCTION(isString) + + +void tst_QScriptValue::isUndefined_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isUndefined_makeData(const char* expr) +{ + static QSet<QString> isUndefined; + if (isUndefined.isEmpty()) { + isUndefined << "QScriptValue(QScriptValue::UndefinedValue)" + << "QScriptValue(0, QScriptValue::UndefinedValue)" + << "QScriptValue(engine, QScriptValue::UndefinedValue)" + << "engine->evaluate(\"{}\")"; + } + newRow(expr) << isUndefined.contains(expr); +} + +void tst_QScriptValue::isUndefined_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isUndefined(), expected); +} + +DEFINE_TEST_FUNCTION(isUndefined) + +void tst_QScriptValue::isObject_initData() +{ + QTest::addColumn<bool>("expected"); + initScriptValues(); +} + +void tst_QScriptValue::isObject_makeData(const char* expr) +{ + static QSet<QString> isObject; + if (isObject.isEmpty()) { + isObject << "engine->evaluate(\"[]\")" + << "engine->evaluate(\"Object.prototype\")" + << "engine->evaluate(\"Date.prototype\")" + << "engine->evaluate(\"Array.prototype\")" + << "engine->evaluate(\"Function.prototype\")" + << "engine->evaluate(\"Error.prototype\")" + << "engine->evaluate(\"Object\")" + << "engine->evaluate(\"Array\")" + << "engine->evaluate(\"Number\")" + << "engine->evaluate(\"Function\")" + << "engine->evaluate(\"(function() { return 1; })\")" + << "engine->evaluate(\"(function() { return 'ciao'; })\")" + << "engine->evaluate(\"(function() { throw new Error('foo'); })\")" + << "engine->evaluate(\"/foo/\")" + << "engine->evaluate(\"new Object()\")" + << "engine->evaluate(\"new Array()\")" + << "engine->evaluate(\"new Error()\")"; + } + newRow(expr) << isObject.contains(expr); +} + +void tst_QScriptValue::isObject_test(const char*, const QScriptValue& value) +{ + QFETCH(bool, expected); + QCOMPARE(value.isObject(), expected); +} + +DEFINE_TEST_FUNCTION(isObject) + + diff --git a/JavaScriptCore/runtime/DateConstructor.cpp b/JavaScriptCore/runtime/DateConstructor.cpp index 2e476b3..e9a5c29 100644 --- a/JavaScriptCore/runtime/DateConstructor.cpp +++ b/JavaScriptCore/runtime/DateConstructor.cpp @@ -177,7 +177,7 @@ static JSValue JSC_HOST_CALL dateUTC(ExecState* exec, JSObject*, JSValue, const t.minute = args.at(4).toInt32(exec); t.second = args.at(5).toInt32(exec); double ms = (n >= 7) ? args.at(6).toNumber(exec) : 0; - return jsNumber(exec, gregorianDateTimeToMS(exec, t, ms, true)); + return jsNumber(exec, timeClip(gregorianDateTimeToMS(exec, t, ms, true))); } } // namespace JSC diff --git a/JavaScriptCore/runtime/MathObject.cpp b/JavaScriptCore/runtime/MathObject.cpp index 98ff3ba..8f22fba 100644 --- a/JavaScriptCore/runtime/MathObject.cpp +++ b/JavaScriptCore/runtime/MathObject.cpp @@ -218,7 +218,8 @@ JSValue JSC_HOST_CALL mathProtoFuncRound(ExecState* exec, JSObject*, JSValue, co double arg = args.at(0).toNumber(exec); if (signbit(arg) && arg >= -0.5) return jsNumber(exec, -0.0); - return jsNumber(exec, floor(arg + 0.5)); + double integer = ceil(arg); + return jsNumber(exec, integer - (integer - arg > 0.5)); } JSValue JSC_HOST_CALL mathProtoFuncSin(ExecState* exec, JSObject*, JSValue, const ArgList& args) diff --git a/JavaScriptCore/runtime/PropertyMapHashTable.h b/JavaScriptCore/runtime/PropertyMapHashTable.h index 5b63f79..44dc2b8 100644 --- a/JavaScriptCore/runtime/PropertyMapHashTable.h +++ b/JavaScriptCore/runtime/PropertyMapHashTable.h @@ -61,7 +61,6 @@ namespace JSC { unsigned size; unsigned keyCount; unsigned deletedSentinelCount; - unsigned anonymousSlotCount; unsigned lastIndexUsed; Vector<unsigned>* deletedOffsets; unsigned entryIndices[1]; diff --git a/JavaScriptCore/runtime/Structure.cpp b/JavaScriptCore/runtime/Structure.cpp index 77330aa..546e2bf 100644 --- a/JavaScriptCore/runtime/Structure.cpp +++ b/JavaScriptCore/runtime/Structure.cpp @@ -123,7 +123,7 @@ void Structure::dumpStatistics() #endif } -Structure::Structure(JSValue prototype, const TypeInfo& typeInfo) +Structure::Structure(JSValue prototype, const TypeInfo& typeInfo, unsigned anonymousSlotCount) : m_typeInfo(typeInfo) , m_prototype(prototype) , m_specificValueInPrevious(0) @@ -135,6 +135,7 @@ Structure::Structure(JSValue prototype, const TypeInfo& typeInfo) , m_hasGetterSetterProperties(false) , m_attributesInPrevious(0) , m_specificFunctionThrashCount(0) + , m_anonymousSlotCount(anonymousSlotCount) { ASSERT(m_prototype); ASSERT(m_prototype.isObject() || m_prototype.isNull()); @@ -275,7 +276,7 @@ void Structure::materializePropertyMap() for (ptrdiff_t i = structures.size() - 2; i >= 0; --i) { structure = structures[i]; structure->m_nameInPrevious->ref(); - PropertyMapEntry entry(structure->m_nameInPrevious.get(), structure->m_offset, structure->m_attributesInPrevious, structure->m_specificValueInPrevious, ++m_propertyTable->lastIndexUsed); + PropertyMapEntry entry(structure->m_nameInPrevious.get(), m_anonymousSlotCount + structure->m_offset, structure->m_attributesInPrevious, structure->m_specificValueInPrevious, ++m_propertyTable->lastIndexUsed); insertIntoPropertyMapHashTable(entry); } } @@ -341,7 +342,9 @@ PassRefPtr<Structure> Structure::addPropertyTransitionToExistingStructure(Struct if (Structure* existingTransition = structure->table.get(make_pair(propertyName.ustring().rep(), attributes), specificValue)) { ASSERT(existingTransition->m_offset != noOffset); - offset = existingTransition->m_offset; + offset = existingTransition->m_offset + existingTransition->m_anonymousSlotCount; + ASSERT(offset >= structure->m_anonymousSlotCount); + ASSERT(structure->m_anonymousSlotCount == existingTransition->m_anonymousSlotCount); return existingTransition; } @@ -361,12 +364,14 @@ PassRefPtr<Structure> Structure::addPropertyTransition(Structure* structure, con RefPtr<Structure> transition = toCacheableDictionaryTransition(structure); ASSERT(structure != transition); offset = transition->put(propertyName, attributes, specificValue); + ASSERT(offset >= structure->m_anonymousSlotCount); + ASSERT(structure->m_anonymousSlotCount == transition->m_anonymousSlotCount); if (transition->propertyStorageSize() > transition->propertyStorageCapacity()) transition->growPropertyStorageCapacity(); return transition.release(); } - RefPtr<Structure> transition = create(structure->m_prototype, structure->typeInfo()); + RefPtr<Structure> transition = create(structure->m_prototype, structure->typeInfo(), structure->anonymousSlotCount()); transition->m_cachedPrototypeChain = structure->m_cachedPrototypeChain; transition->m_previous = structure; @@ -393,11 +398,13 @@ PassRefPtr<Structure> Structure::addPropertyTransition(Structure* structure, con } offset = transition->put(propertyName, attributes, specificValue); + ASSERT(offset >= structure->m_anonymousSlotCount); + ASSERT(structure->m_anonymousSlotCount == transition->m_anonymousSlotCount); if (transition->propertyStorageSize() > transition->propertyStorageCapacity()) transition->growPropertyStorageCapacity(); - transition->m_offset = offset; - + transition->m_offset = offset - structure->m_anonymousSlotCount; + ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount()); structure->table.add(make_pair(propertyName.ustring().rep(), attributes), transition.get(), specificValue); return transition.release(); } @@ -409,13 +416,15 @@ PassRefPtr<Structure> Structure::removePropertyTransition(Structure* structure, RefPtr<Structure> transition = toUncacheableDictionaryTransition(structure); offset = transition->remove(propertyName); + ASSERT(offset >= structure->m_anonymousSlotCount); + ASSERT(structure->m_anonymousSlotCount == transition->m_anonymousSlotCount); return transition.release(); } PassRefPtr<Structure> Structure::changePrototypeTransition(Structure* structure, JSValue prototype) { - RefPtr<Structure> transition = create(prototype, structure->typeInfo()); + RefPtr<Structure> transition = create(prototype, structure->typeInfo(), structure->anonymousSlotCount()); transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties; @@ -427,14 +436,15 @@ PassRefPtr<Structure> Structure::changePrototypeTransition(Structure* structure, structure->materializePropertyMapIfNecessary(); transition->m_propertyTable = structure->copyPropertyTable(); transition->m_isPinnedPropertyTable = true; - + + ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount()); return transition.release(); } PassRefPtr<Structure> Structure::despecifyFunctionTransition(Structure* structure, const Identifier& replaceFunction) { ASSERT(structure->m_specificFunctionThrashCount < maxSpecificFunctionThrashCount); - RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo()); + RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo(), structure->anonymousSlotCount()); transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties; @@ -453,13 +463,14 @@ PassRefPtr<Structure> Structure::despecifyFunctionTransition(Structure* structur bool removed = transition->despecifyFunction(replaceFunction); ASSERT_UNUSED(removed, removed); } - + + ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount()); return transition.release(); } PassRefPtr<Structure> Structure::getterSetterTransition(Structure* structure) { - RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo()); + RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo(), structure->anonymousSlotCount()); transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; transition->m_hasGetterSetterProperties = transition->m_hasGetterSetterProperties; transition->m_hasNonEnumerableProperties = structure->m_hasNonEnumerableProperties; @@ -470,7 +481,8 @@ PassRefPtr<Structure> Structure::getterSetterTransition(Structure* structure) structure->materializePropertyMapIfNecessary(); transition->m_propertyTable = structure->copyPropertyTable(); transition->m_isPinnedPropertyTable = true; - + + ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount()); return transition.release(); } @@ -478,7 +490,7 @@ PassRefPtr<Structure> Structure::toDictionaryTransition(Structure* structure, Di { ASSERT(!structure->isUncacheableDictionary()); - RefPtr<Structure> transition = create(structure->m_prototype, structure->typeInfo()); + RefPtr<Structure> transition = create(structure->m_prototype, structure->typeInfo(), structure->anonymousSlotCount()); transition->m_dictionaryKind = kind; transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity; transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties; @@ -489,6 +501,7 @@ PassRefPtr<Structure> Structure::toDictionaryTransition(Structure* structure, Di transition->m_propertyTable = structure->copyPropertyTable(); transition->m_isPinnedPropertyTable = true; + ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount()); return transition.release(); } @@ -522,7 +535,7 @@ PassRefPtr<Structure> Structure::flattenDictionaryStructure(JSObject* object) // in the order that they are expected to be in, but we need to // reorder the storage, so we have to copy the current values out Vector<JSValue> values(propertyCount); - unsigned anonymousSlotCount = m_propertyTable->anonymousSlotCount; + unsigned anonymousSlotCount = m_anonymousSlotCount; for (unsigned i = 0; i < propertyCount; i++) { PropertyMapEntry* entry = sortedPropertyEntries[i]; values[i] = object->getDirectOffset(entry->offset); @@ -557,6 +570,7 @@ size_t Structure::addPropertyWithoutTransition(const Identifier& propertyName, u m_isPinnedPropertyTable = true; size_t offset = put(propertyName, attributes, specificValue); + ASSERT(offset >= m_anonymousSlotCount); if (propertyStorageSize() > propertyStorageCapacity()) growPropertyStorageCapacity(); return offset; @@ -571,6 +585,7 @@ size_t Structure::removePropertyWithoutTransition(const Identifier& propertyName m_isPinnedPropertyTable = true; size_t offset = remove(propertyName); + ASSERT(offset >= m_anonymousSlotCount); return offset; } @@ -627,7 +642,6 @@ PropertyMapHashTable* Structure::copyPropertyTable() if (m_propertyTable->deletedOffsets) newTable->deletedOffsets = new Vector<unsigned>(*m_propertyTable->deletedOffsets); - newTable->anonymousSlotCount = m_propertyTable->anonymousSlotCount; return newTable; } @@ -650,6 +664,7 @@ size_t Structure::get(const UString::Rep* rep, unsigned& attributes, JSCell*& sp if (rep == m_propertyTable->entries()[entryIndex - 1].key) { attributes = m_propertyTable->entries()[entryIndex - 1].attributes; specificValue = m_propertyTable->entries()[entryIndex - 1].specificValue; + ASSERT(m_propertyTable->entries()[entryIndex - 1].offset >= m_anonymousSlotCount); return m_propertyTable->entries()[entryIndex - 1].offset; } @@ -673,6 +688,7 @@ size_t Structure::get(const UString::Rep* rep, unsigned& attributes, JSCell*& sp if (rep == m_propertyTable->entries()[entryIndex - 1].key) { attributes = m_propertyTable->entries()[entryIndex - 1].attributes; specificValue = m_propertyTable->entries()[entryIndex - 1].specificValue; + ASSERT(m_propertyTable->entries()[entryIndex - 1].offset >= m_anonymousSlotCount); return m_propertyTable->entries()[entryIndex - 1].offset; } } @@ -821,9 +837,10 @@ size_t Structure::put(const Identifier& propertyName, unsigned attributes, JSCel newOffset = m_propertyTable->deletedOffsets->last(); m_propertyTable->deletedOffsets->removeLast(); } else - newOffset = m_propertyTable->keyCount + m_propertyTable->anonymousSlotCount; + newOffset = m_propertyTable->keyCount + m_anonymousSlotCount; m_propertyTable->entries()[entryIndex - 1].offset = newOffset; - + + ASSERT(newOffset >= m_anonymousSlotCount); ++m_propertyTable->keyCount; if ((m_propertyTable->keyCount + m_propertyTable->deletedSentinelCount) * 2 >= m_propertyTable->size) @@ -887,6 +904,7 @@ size_t Structure::remove(const Identifier& propertyName) m_propertyTable->entryIndices[i & m_propertyTable->sizeMask] = deletedSentinelIndex; size_t offset = m_propertyTable->entries()[entryIndex - 1].offset; + ASSERT(offset >= m_anonymousSlotCount); key->deref(); m_propertyTable->entries()[entryIndex - 1].key = 0; @@ -912,7 +930,7 @@ size_t Structure::remove(const Identifier& propertyName) void Structure::insertIntoPropertyMapHashTable(const PropertyMapEntry& entry) { ASSERT(m_propertyTable); - + ASSERT(entry.offset >= m_anonymousSlotCount); unsigned i = entry.key->existingHash(); unsigned k = 0; @@ -991,7 +1009,6 @@ void Structure::rehashPropertyMapHashTable(unsigned newTableSize) m_propertyTable = static_cast<PropertyMapHashTable*>(fastZeroedMalloc(PropertyMapHashTable::allocationSize(newTableSize))); m_propertyTable->size = newTableSize; m_propertyTable->sizeMask = newTableSize - 1; - m_propertyTable->anonymousSlotCount = oldTable->anonymousSlotCount; unsigned lastIndexUsed = 0; unsigned entryCount = oldTable->keyCount + oldTable->deletedSentinelCount; @@ -1121,6 +1138,7 @@ void Structure::checkConsistency() for (unsigned c = 1; c <= m_propertyTable->keyCount + m_propertyTable->deletedSentinelCount; ++c) { ASSERT(m_hasNonEnumerableProperties || !(m_propertyTable->entries()[c].attributes & DontEnum)); UString::Rep* rep = m_propertyTable->entries()[c].key; + ASSERT(m_propertyTable->entries()[c].offset >= m_anonymousSlotCount); if (!rep) continue; ++nonEmptyEntryCount; diff --git a/JavaScriptCore/runtime/Structure.h b/JavaScriptCore/runtime/Structure.h index f73f9b8..1353a5a 100644 --- a/JavaScriptCore/runtime/Structure.h +++ b/JavaScriptCore/runtime/Structure.h @@ -62,15 +62,7 @@ namespace JSC { friend class StructureTransitionTable; static PassRefPtr<Structure> create(JSValue prototype, const TypeInfo& typeInfo, unsigned anonymousSlotCount) { - Structure* structure = (new Structure(prototype, typeInfo)); - if (anonymousSlotCount) { - structure->materializePropertyMap(); - structure->m_isPinnedPropertyTable = true; - structure->m_propertyTable->anonymousSlotCount = anonymousSlotCount; - // Currently we don't allow more anonymous slots than fit in the inline capacity - ASSERT(structure->propertyStorageSize() <= structure->propertyStorageCapacity()); - } - return adoptRef(structure); + return adoptRef(new Structure(prototype, typeInfo, anonymousSlotCount)); } static void startIgnoringLeaks(); @@ -109,7 +101,7 @@ namespace JSC { void growPropertyStorageCapacity(); unsigned propertyStorageCapacity() const { return m_propertyStorageCapacity; } - unsigned propertyStorageSize() const { return m_propertyTable ? m_propertyTable->keyCount + m_propertyTable->anonymousSlotCount + (m_propertyTable->deletedOffsets ? m_propertyTable->deletedOffsets->size() : 0) : m_offset + 1; } + unsigned propertyStorageSize() const { return m_anonymousSlotCount + (m_propertyTable ? m_propertyTable->keyCount + (m_propertyTable->deletedOffsets ? m_propertyTable->deletedOffsets->size() : 0) : m_offset + 1); } bool isUsingInlineStorage() const; size_t get(const Identifier& propertyName); @@ -134,8 +126,8 @@ namespace JSC { bool hasNonEnumerableProperties() const { return m_hasNonEnumerableProperties; } - bool hasAnonymousSlots() const { return m_propertyTable && m_propertyTable->anonymousSlotCount; } - unsigned anonymousSlotCount() const { return m_propertyTable ? m_propertyTable->anonymousSlotCount : 0; } + bool hasAnonymousSlots() const { return !!m_anonymousSlotCount; } + unsigned anonymousSlotCount() const { return m_anonymousSlotCount; } bool isEmpty() const { return m_propertyTable ? !m_propertyTable->keyCount : m_offset == noOffset; } @@ -147,12 +139,8 @@ namespace JSC { void getPropertyNames(PropertyNameArray&, EnumerationMode mode); private: - static PassRefPtr<Structure> create(JSValue prototype, const TypeInfo& typeInfo) - { - return adoptRef(new Structure(prototype, typeInfo)); - } - Structure(JSValue prototype, const TypeInfo&); + Structure(JSValue prototype, const TypeInfo&, unsigned anonymousSlotCount); typedef enum { NoneDictionaryKind = 0, @@ -216,6 +204,8 @@ namespace JSC { PropertyMapHashTable* m_propertyTable; uint32_t m_propertyStorageCapacity; + + // m_offset does not account for anonymous slots signed char m_offset; unsigned m_dictionaryKind : 2; @@ -231,7 +221,8 @@ namespace JSC { unsigned m_attributesInPrevious : 7; #endif unsigned m_specificFunctionThrashCount : 2; - // 10 free bits + unsigned m_anonymousSlotCount : 5; + // 5 free bits }; inline size_t Structure::get(const Identifier& propertyName) diff --git a/JavaScriptCore/wtf/Assertions.h b/JavaScriptCore/wtf/Assertions.h index 352a74b..0e02af5 100644 --- a/JavaScriptCore/wtf/Assertions.h +++ b/JavaScriptCore/wtf/Assertions.h @@ -179,6 +179,14 @@ void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChann #undef ASSERT #endif +#if PLATFORM(BREWMP) +/* FIXME: We include this here only to avoid a conflict with the COMPILE_ASSERT macro. */ +#include <AEEClassIDs.h> + +/* FIXME: Change to use something other than COMPILE_ASSERT to avoid this conflict with the underlying platform */ +#undef COMPILE_ASSERT +#endif + #if ASSERT_DISABLED #define ASSERT(assertion) ((void)0) diff --git a/JavaScriptCore/wtf/CurrentTime.cpp b/JavaScriptCore/wtf/CurrentTime.cpp index b272874..30ca7c3 100644 --- a/JavaScriptCore/wtf/CurrentTime.cpp +++ b/JavaScriptCore/wtf/CurrentTime.cpp @@ -59,6 +59,8 @@ extern "C" time_t mktime(struct tm *t); #include <glib.h> #elif PLATFORM(WX) #include <wx/datetime.h> +#elif PLATFORM(BREWMP) +#include <AEEStdLib.h> #else // Posix systems relying on the gettimeofday() #include <sys/time.h> #endif @@ -277,6 +279,20 @@ double currentTime() return (double)now.GetTicks() + (double)(now.GetMillisecond() / 1000.0); } +#elif PLATFORM(BREWMP) + +// GETUTCSECONDS returns the number of seconds since 1980/01/06 00:00:00 UTC, +// and GETTIMEMS returns the number of milliseconds that have elapsed since the last +// occurrence of 00:00:00 local time. +// We can combine GETUTCSECONDS and GETTIMEMS to calculate the number of milliseconds +// since 1970/01/01 00:00:00 UTC. +double currentTime() +{ + // diffSeconds is the number of seconds from 1970/01/01 to 1980/01/06 + const unsigned diffSeconds = 315964800; + return static_cast<double>(diffSeconds + GETUTCSECONDS() + ((GETTIMEMS() % 1000) / msPerSecond)); +} + #else // Other Posix systems rely on the gettimeofday(). double currentTime() diff --git a/JavaScriptCore/wtf/CurrentTime.h b/JavaScriptCore/wtf/CurrentTime.h index 334a6e9..033448f 100644 --- a/JavaScriptCore/wtf/CurrentTime.h +++ b/JavaScriptCore/wtf/CurrentTime.h @@ -61,6 +61,7 @@ namespace WTF { } // namespace WTF using WTF::currentTime; +using WTF::getLocalTime; #endif // CurrentTime_h diff --git a/JavaScriptCore/wtf/Platform.h b/JavaScriptCore/wtf/Platform.h index 810c829..166a955 100644 --- a/JavaScriptCore/wtf/Platform.h +++ b/JavaScriptCore/wtf/Platform.h @@ -415,6 +415,13 @@ #define WTF_PLATFORM_GTK 1 #elif defined(BUILDING_HAIKU__) #define WTF_PLATFORM_HAIKU 1 +#elif defined(BUILDING_BREWMP__) +#define WTF_PLATFORM_BREWMP 1 +#if defined(AEE_SIMULATOR) +#define WTF_PLATFORM_BREWMP_SIMULATOR 1 +#else +#define WTF_PLATFORM_BREWMP_SIMULATOR 0 +#endif #elif OS(DARWIN) #define WTF_PLATFORM_MAC 1 #elif OS(WINDOWS) @@ -481,10 +488,10 @@ */ #if OS(WINCE) && PLATFORM(QT) # include <QtGlobal> -# undef WTF_PLATFORM_BIG_ENDIAN -# undef WTF_PLATFORM_MIDDLE_ENDIAN -# if Q_BYTE_ORDER == Q_BIG_EDIAN -# define WTF_PLATFORM_BIG_ENDIAN 1 +# undef WTF_CPU_BIG_ENDIAN +# undef WTF_CPU_MIDDLE_ENDIAN +# if Q_BYTE_ORDER == Q_BIG_ENDIAN +# define WTF_CPU_BIG_ENDIAN 1 # endif # include <ce_time.h> @@ -632,7 +639,7 @@ #if !OS(WINDOWS) && !OS(SOLARIS) && !OS(QNX) \ && !OS(SYMBIAN) && !OS(HAIKU) && !OS(RVCT) \ - && !OS(ANDROID) + && !OS(ANDROID) && !PLATFORM(BREWMP) #define HAVE_TM_GMTOFF 1 #define HAVE_TM_ZONE 1 #define HAVE_TIMEGM 1 @@ -688,6 +695,10 @@ #define HAVE_SYS_PARAM_H 1 #endif +#elif PLATFORM(BREWMP) + +#define HAVE_ERRNO_H 1 + #elif OS(QNX) #define HAVE_ERRNO_H 1 @@ -854,7 +865,7 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */ #define ENABLE_JIT 1 #endif -#if PLATFORM(QT) +#if PLATFORM(QT) || PLATFORM(WX) #if CPU(X86_64) && OS(DARWIN) #define ENABLE_JIT 1 #elif CPU(X86) && OS(DARWIN) @@ -918,8 +929,13 @@ on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */ #if (CPU(X86) && PLATFORM(MAC)) \ || (CPU(X86_64) && PLATFORM(MAC)) \ || (CPU(ARM_THUMB2) && PLATFORM(IPHONE)) \ +<<<<<<< HEAD || (CPU(ARM_THUMB2) && PLATFORM(ANDROID) && ENABLE(ANDROID_JSC_JIT)) \ || (CPU(X86) && PLATFORM(WIN)) +======= + || (CPU(X86) && PLATFORM(WIN)) \ + || (CPU(X86) && PLATFORM(WX)) +>>>>>>> webkit.org at r54340 #define ENABLE_YARR 1 #define ENABLE_YARR_JIT 1 #endif diff --git a/JavaScriptCore/wtf/brew/MainThreadBrew.cpp b/JavaScriptCore/wtf/brew/MainThreadBrew.cpp new file mode 100644 index 0000000..2690ea5 --- /dev/null +++ b/JavaScriptCore/wtf/brew/MainThreadBrew.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2009 Company 100, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "MainThread.h" + +namespace WTF { + +void initializeMainThreadPlatform() +{ + // not implemented +} + +void scheduleDispatchFunctionsOnMainThread() +{ + // not implemented +} + +} // namespace WTF + diff --git a/JavaScriptCore/wtf/brew/OwnPtrBrew.cpp b/JavaScriptCore/wtf/brew/OwnPtrBrew.cpp new file mode 100644 index 0000000..dadd82e --- /dev/null +++ b/JavaScriptCore/wtf/brew/OwnPtrBrew.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2010 Company 100, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "OwnPtrBrew.h" + +#include <AEEBitmap.h> +#include <AEEFile.h> +#include <AEEStdLib.h> + +namespace WTF { + +template <> void freeOwnedPtrBrew<IFileMgr>(IFileMgr* ptr) +{ + if (ptr) + IFILEMGR_Release(ptr); +} + +template <> void freeOwnedPtrBrew<IFile>(IFile* ptr) +{ + if (ptr) + IFILE_Release(ptr); +} + +template <> void freeOwnedPtrBrew<IBitmap>(IBitmap* ptr) +{ + if (ptr) + IBitmap_Release(ptr); +} + +template <typename T> void freeOwnedPtrBrew(T* ptr) +{ + FREEIF(ptr); +} + +} // namespace WTF diff --git a/JavaScriptCore/wtf/brew/OwnPtrBrew.h b/JavaScriptCore/wtf/brew/OwnPtrBrew.h new file mode 100644 index 0000000..1bb44fc --- /dev/null +++ b/JavaScriptCore/wtf/brew/OwnPtrBrew.h @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2008 Collabora Ltd. + * Copyright (C) 2010 Company 100, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef OwnPtrBrew_h +#define OwnPtrBrew_h + +#include <algorithm> +#include <wtf/Assertions.h> +#include <wtf/Noncopyable.h> + +// Forward delcarations at this point avoid the need to include BREW includes +// in WTF headers. +typedef struct _IFileMgr IFileMgr; +typedef struct _IFile IFile; +typedef struct IBitmap IBitmap; + +namespace WTF { + +template <typename T> void freeOwnedPtrBrew(T* ptr); +template<> void freeOwnedPtrBrew<IFileMgr>(IFileMgr*); +template<> void freeOwnedPtrBrew<IFile>(IFile*); +template<> void freeOwnedPtrBrew<IBitmap>(IBitmap*); + +template <typename T> class OwnPtrBrew : public Noncopyable { +public: + explicit OwnPtrBrew(T* ptr = 0) : m_ptr(ptr) { } + ~OwnPtrBrew() { freeOwnedPtrBrew(m_ptr); } + + T* get() const { return m_ptr; } + T* release() + { + T* ptr = m_ptr; + m_ptr = 0; + return ptr; + } + + T*& outPtr() + { + ASSERT(!m_ptr); + return m_ptr; + } + + void set(T* ptr) + { + ASSERT(!ptr || m_ptr != ptr); + freeOwnedPtrBrew(m_ptr); + m_ptr = ptr; + } + + void clear() + { + freeOwnedPtrBrew(m_ptr); + m_ptr = 0; + } + + T& operator*() const + { + ASSERT(m_ptr); + return *m_ptr; + } + + T* operator->() const + { + ASSERT(m_ptr); + return m_ptr; + } + + bool operator!() const { return !m_ptr; } + + // This conversion operator allows implicit conversion to bool but not to other integer types. + typedef T* OwnPtrBrew::*UnspecifiedBoolType; + operator UnspecifiedBoolType() const { return m_ptr ? &OwnPtrBrew::m_ptr : 0; } + + void swap(OwnPtrBrew& o) { std::swap(m_ptr, o.m_ptr); } + +private: + T* m_ptr; +}; + +template <typename T> inline void swap(OwnPtrBrew<T>& a, OwnPtrBrew<T>& b) +{ + a.swap(b); +} + +template <typename T, typename U> inline bool operator==(const OwnPtrBrew<T>& a, U* b) +{ + return a.get() == b; +} + +template <typename T, typename U> inline bool operator==(T* a, const OwnPtrBrew<U>& b) +{ + return a == b.get(); +} + +template <typename T, typename U> inline bool operator!=(const OwnPtrBrew<T>& a, U* b) +{ + return a.get() != b; +} + +template <typename T, typename U> inline bool operator!=(T* a, const OwnPtrBrew<U>& b) +{ + return a != b.get(); +} + +template <typename T> inline typename OwnPtrBrew<T>::PtrType getPtr(const OwnPtrBrew<T>& p) +{ + return p.get(); +} + +} // namespace WTF + +using WTF::OwnPtrBrew; + +#endif // OwnPtrBrew_h |