Changeset 62078 in webkit
- Timestamp:
- Jun 28, 2010 8:04:36 PM (14 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r62053 r62078 1 2010-06-28 Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] QScriptEngine API should contain a newArray function 6 https://bugs.webkit.org/show_bug.cgi?id=39115 7 8 * qt/api/qscriptengine.cpp: 9 (QScriptEngine::newArray): 10 * qt/api/qscriptengine.h: 11 * qt/api/qscriptengine_p.cpp: 12 (QScriptEnginePrivate::newArray): 13 * qt/api/qscriptengine_p.h: 14 * qt/tests/qscriptengine/tst_qscriptengine.cpp: 15 (tst_QScriptEngine::newArray): 16 1 17 2010-06-28 Xan Lopez <xlopez@igalia.com> 2 18 -
trunk/JavaScriptCore/qt/api/qscriptengine.cpp
r60583 r62078 207 207 208 208 /*! 209 Creates a QtScript object of class Array with the given \a length. 210 211 \sa newObject() 212 */ 213 QScriptValue QScriptEngine::newArray(uint length) 214 { 215 return QScriptValuePrivate::get(d_ptr->newArray(length)); 216 } 217 218 /*! 209 219 Returns this engine's Global Object. 210 220 -
trunk/JavaScriptCore/qt/api/qscriptengine.h
r60583 r62078 52 52 QScriptValue undefinedValue(); 53 53 QScriptValue newObject(); 54 QScriptValue newArray(uint length = 0); 54 55 QScriptValue globalObject() const; 55 56 private: -
trunk/JavaScriptCore/qt/api/qscriptengine_p.cpp
r61726 r62078 83 83 } 84 84 85 QScriptValuePrivate* QScriptEnginePrivate::newArray(uint length) const 86 { 87 JSObjectRef array = JSObjectMakeArray(m_context, /* argumentCount */ 0, /* arguments */ 0, /* exception */ 0); 88 89 if (length > 0) { 90 JSRetainPtr<JSStringRef> lengthRef(Adopt, JSStringCreateWithUTF8CString("length")); 91 JSObjectSetProperty(m_context, array, lengthRef.get(), JSValueMakeNumber(m_context, length), kJSPropertyAttributeNone, /* exception */ 0); 92 } 93 94 return new QScriptValuePrivate(this, array); 95 } 96 85 97 QScriptValuePrivate* QScriptEnginePrivate::globalObject() const 86 98 { -
trunk/JavaScriptCore/qt/api/qscriptengine_p.h
r61003 r62078 58 58 59 59 QScriptValuePrivate* newObject() const; 60 QScriptValuePrivate* newArray(uint length) const; 60 61 QScriptValuePrivate* globalObject() const; 61 62 -
trunk/JavaScriptCore/qt/tests/qscriptengine/tst_qscriptengine.cpp
r60662 r62078 48 48 void toObject(); 49 49 void toObjectTwoEngines(); 50 void newArray(); 50 51 }; 51 52 … … 410 411 } 411 412 413 void tst_QScriptEngine::newArray() 414 { 415 QScriptEngine eng; 416 QScriptValue array = eng.newArray(); 417 QCOMPARE(array.isValid(), true); 418 // QCOMPARE(array.isArray(), true); 419 QCOMPARE(array.isObject(), true); 420 QVERIFY(!array.isFunction()); 421 // QCOMPARE(array.scriptClass(), (QScriptClass*)0); 422 423 // Prototype should be Array.prototype. 424 QCOMPARE(array.prototype().isValid(), true); 425 // QCOMPARE(array.prototype().isArray(), true); 426 QCOMPARE(array.prototype().strictlyEquals(eng.evaluate("Array.prototype")), true); 427 428 QScriptValue arrayWithSize = eng.newArray(42); 429 QCOMPARE(arrayWithSize.isValid(), true); 430 // QCOMPARE(arrayWithSize.isArray(), true); 431 QCOMPARE(arrayWithSize.isObject(), true); 432 QCOMPARE(arrayWithSize.property("length").toInt32(), 42); 433 } 434 412 435 QTEST_MAIN(tst_QScriptEngine) 413 436 #include "tst_qscriptengine.moc"
Note: See TracChangeset
for help on using the changeset viewer.