summaryrefslogtreecommitdiffstats
path: root/src/script
Commit message (Collapse)AuthorAgeFilesLines
* Update licenseheader text in source filesJyri Tahtela2011-05-132-52/+52
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Make QtScript support COLLECT_ON_EVERY_ALLOCATION defineKent Hansen2011-02-251-11/+12
| | | | | | | | | | | | | | JSC has a define in runtime/Collector.cpp that can be enabled to force garbage collection on every allocation. This can be useful when investigating GC-related issues. When the define is enabled, GC callbacks will happen before the QScriptEngine(Private) is completely initialized, so we need to initialize some things earlier (nice cleanup, actually), and add some guards in the marking callback. All tests pass with define off and on. Task-number: QTBUG-17781 Reviewed-by: Olivier Goffart
* Add missing API shims to QScriptValue constructorsKent Hansen2011-02-251-0/+5
| | | | | | | | | | | | | This is needed to ensure that the calls into JSC are safe, e.g. with regards to reentrancy. I was not able to construct a testcase, but several of our autotests crash without this change if COLLECT_ON_EVERY_ALLOCATION is set to 1 in Collector.cpp (this forces a garbage collection every time an object is allocated). Task-number: QTBUG-17815 Reviewed-by: Olivier Goffart
* Don't crash when marking arguments object of native contextKent Hansen2011-02-252-2/+16
| | | | | | | | | | | | | | | | | | | | | JSC assumes that the callee is always valid, since JSC::Arguments is used for JS frames, which must have a callee. But we use JSC::Arguments for arguments object of pushContext()-created contexts, and then there is no callee. But the callee member can't be null, so now we put a fake callee there and make sure it doesn't bleed up to the public API. Alternative solution: Add "if (d->callee)" to JSC::Arguments::markChildren(), then no other changes would be needed. But we don't want to patch JSC any more. Non-solution: Subclass JSC::Arguments and reimplement markChildren() to temporarily set a dummy callee during marking. Can't be done, as JSC::Arguments::d is private (again, we don't want to patch JSC). Task-number: QTBUG-17788 Reviewed-by: Olivier Goffart
* Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integrationQt Continuous Integration System2011-02-141-3/+1
|\ | | | | | | | | | | | | | | | | | | | | * '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Don't leak ScopeChainNode's Rename 'plugins\qmldebugging' (work around qmake issues) Correct the "module not installed" error handling Flickable uses the flick velocity to determine whether to retain grab Make addImportPath() work for windows paths starting with lower case Report any exceptions occurring in WorkerScript javascript code MouseArea docs - link to onCanceled() from onReleased()
| * Don't leak ScopeChainNode'sAaron Kennedy2011-02-141-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Create a sub-scope of the global scope chain, rather than a completely new scope chain. Leaks are difficult to autotest, but an autotest for QScriptDeclarativeClass::pushCleanContext() was added to ensure its behavior doesn't regress. To reproduce the leak (prior to this change) use: while (true) { QScriptDeclarativeClass::pushCleanContext(&engine); engine.popContext(); } Change-Id: I41ac61ea1664da569eb329c8276f2a0bb6d2f1f7 Task-number: QTBUG-17166 Reviewed-by: Martin Jones
* | Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into ↵Qt Continuous Integration System2011-02-084-5/+32
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 4.7-integration * '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (21 commits) Fix compilation of QMutableSetIterator::value() with QT_STRICT_ITERATORS Fix the compilation error that the previous fix didn't fix Use the thread-default glib context for the DBus connection in the ICD bearer manager. Check that _POSIX_THREAD_SAFE_FUNCTIONS is larger than zero. Use an increasing size for the getpwuid_r buffer. Make sure we use at least 1024 bytes when calling getpwuid_r. Fix compilation error: symbol is namespaced. Don't crash when creating backtrace for built-in JS function (2nd try) Revert "Improved performance of mapFromGlobal/mapToGlobal on X11" QtDBus: do not wait for reply for AddMatch and RemoveMatch Make qdbus show all types, even those that it doesn't know about Doc: Fix the docs saying what the locale codec is used for Autotest: simple improvements Autotest: Use QElapsedTimer for timings directfb: Pixmap creation always premultiplied the alpha even when it is already premultiplied in the image. Don't crash when BMP color table is broken Designer: Fix a crash in the Signal-Slot-Editor. complain about unmatched quotes/parens use const ref move multiple inclusion check for feature files to correct location ...
| * Don't crash when creating backtrace for built-in JS function (2nd try)Kent Hansen2011-02-084-4/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 147df10403ba280b3f04c1e3d6c4b1cf386abe5d did not quite fix the issue; other places need the same checks. When the JIT is enabled, frames for built-in JS host calls (such as Array.prototype.forEach) are not fully initialized. In particular, the CodeBlock register of such frames is not set (see comment in JITCall.cpp). We need to check if the codeBlock is actually valid before we start using it. This fixes the crash(es) but not the problem of actually getting the arguments for such frames through the API. There's also a related problem when a QtScript function (newFunction()) is called as a callback of a built-in JS host function (QTBUG-17287). These problems will go away once JavaScriptCore is updated to a more recent version (4.8 at the earliest), since the native-vs-script frame handling has been unified. Task-number: QTBUG-17137 Reviewed-by: Olivier Goffart
| * Don't crash when creating backtrace for built-in JS functionKent Hansen2011-02-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | When the JIT is enabled, NativeFunctionWrapper (used for built-in functions such as Array.prototype.forEach) inherits JSFunction, so we must check whether the function is actually a JS (script) function before we start accessing script-specific properties. Task-number: QTBUG-17137 Reviewed-by: Olivier Goffart
* | Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integrationQt Continuous Integration System2011-01-302-0/+15
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (151 commits) expect fail for some PinchArea tests on mac Allow functions to be passed in as values for grouped properties Fix lineHeight autotests. Update Docs, Examples and Demos for new CreateObject overloadable Adding support for group properties in Component::CreateObject() Update test, versioning is fixed so expect-fail no longer needed Test failure fixed - remove XFAIL photoviewer needs QtQuick 1.1 for Image::cache disable some pincharea tests on mac temporarily Fix failing test on mac for Qt.application Fix test breakage for qdeclarativeworkerscript Fix typo in error message. Doc fix for lineHeight. Add support for line spacing in Text element. Fixing right-to-left text in Text and TextInput Fix MaximumLineCount in Text and add tests Ensure simple objects also get the appropriate property cache Add test for Loader implicitWidth/implicitHeight Don't crash when appending a null item Test for passing functions to createObject() for property bindings ...
| * Merge branch 'qtquick11' of scm.dev.nokia.troll.no:qt/qt-qml into qtquick11Bea Lam2011-01-272-0/+6
| |\
| | * Implement property versioning inside the declarative engineAaron Kennedy2011-01-272-0/+6
| | | | | | | | | | | | Task-number: QTBUG-13451
| * | Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into qtquick11Bea Lam2011-01-271-1/+0
| |\ \ | | |/ | |/| | | | | | | | | | Conflicts: src/declarative/graphicsitems/qdeclarativegridview.cpp src/declarative/graphicsitems/qdeclarativelistview.cpp
| * | Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into qtquick11Martin Jones2011-01-1968-69/+79
| |\ \
| * | | Symbian compile fixKai Koehne2010-12-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | armv5 complained that the call to QChar::category() was ambiguous, because there is a version taking an uint, and a version taking ushort as argument. Reviewed-by: Christiaan Janssen
| * | | Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into qtquick11Yann Bodson2010-11-231-1/+1
| |\ \ \
| * | | | Small optimization of enum detection in script.Michael Brasser2010-11-122-0/+9
| | | | | | | | | | | | | | | | | | | | Reviewed-by: Martin Jones
* | | | | Invalidate QScriptPrograms when engine is destroyedKent Hansen2011-01-284-7/+42
| |_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the engine is destroyed before the program, the program must be invalidated; otherwise the program destructor will access a stale engine pointer, which can cause a crash (it crashes on Symbian, but "only" gives a Valgrind warning on Linux for our autotests). We need to keep track of all associated programs, just like we already do for values and strings. This fix follows the exact same pattern, but uses a QSet to keep the patch minimal. No new tests, but the evaluateProgram() test runs successfully on Symbian now, and there are no more Valgrind warnings. Task-number: QTBUG-16987 Reviewed-by: Olivier Goffart
* | | | QtScript/JSC on Symbian: Enhanced memory allocator for Collector heapKent Hansen2011-01-251-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cherry-picked from http://trac.webkit.org/changeset/56370 The old allocator caused QML to crash in MCL (TB10.1, week 1). Task-number: QTBUG-14293 Reviewed-by: Simon Hausmann
* | | | Revert "QtScript/JSC on Symbian: Enhanced memory allocator for Collector heap"Kent Hansen2011-01-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 7db489a0de073a2a56fe32d16f1cbe1bebdfd06d. The change to CollectorHeapIterator.h is not Symbian-specific and it introduced test failures on all platforms (tst_QScriptEngineAgent::positionChange_3()).
* | | | QtScript/JSC on Symbian: Enhanced memory allocator for Collector heapKent Hansen2011-01-251-1/+0
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | Cherry-picked from http://trac.webkit.org/changeset/56370 The old allocator caused QML to crash in MCL (TB10.1, week 1). Task-number: QTBUG-14293 Reviewed-by: Simon Hausmann
* | | Update copyright year to 2011.Jason McDonald2011-01-1067-69/+69
| | | | | | | | | | | | Reviewed-by: Trust Me
* | | Add compiler optimization for QtScript/JSC on SymbianKent Hansen2010-12-281-0/+10
| |/ |/| | | | | | | | | | | | | | | Ported from http://trac.webkit.org/changeset/73126. This gives a ~70% performance improvement for the SunSpider and V8 benchmarks. Task-number: QTBUG-15847 Reviewed-by: Simon Hausmann
* | Doc: Fixing typoSergio Ahumada2010-11-161-1/+1
|/
* Fix GC-related crash in QScriptValue::setData()Kent Hansen2010-11-091-0/+1
| | | | | | | | | | | | | | | Yet another missing API shim. When converting the QScriptValue to JSC, a JSCell may be allocated, which can cause the GC to trigger. If an identifier (JSC::Identifier) is then garbage collected, the destructor will try to remove itself from the currentIdentifierTable(). Because the API shim was missing, the identifier table was 0. It's difficult to create a bulletproof test for this case, but the attached test is a best effort (it crashes on my machine without the fix). Task-number: QTBUG-15144 Reviewed-by: Jedrzej Nowacki
* Don't crash if QScriptClass property getter returns an invalid valueKent Hansen2010-11-081-0/+12
| | | | | | | | | | | | | It's possible that a class claims to have a property of a given name (i.e. queryProperty() returns true), but returns an invalid value for that property. In that case we should silently convert the value to undefined, otherwise the value may wreak havoc in JS. This is a regression from Qt 4.5 (pre-JavaScriptCore-based), which had this check. Task-number: QTBUG-15079 Reviewed-by: Jedrzej Nowacki
* QScriptValue::construct(): Don't crash if function throws non-ObjectKent Hansen2010-10-281-5/+8
| | | | | | | | | | | | | If an exception occurs, we should ignore the result of JSC::construct() and return the exception value, even if the exception is not an object. This makes the behavior match the documentation: "Calling construct() can cause an exception to occur in the script engine; in that case, construct() returns the value that was thrown". Task-number: QTBUG-14801 Reviewed-by: Jedrzej Nowacki
* Fix QScriptEngine::abortEvaluation.Jedrzej Nowacki2010-09-301-2/+5
| | | | | | | | This patch reduce time in which QScriptEngine would abort an script executing multiple long-running native functions. Task-number: QTBUG-9433 Reviewed-by: Olivier Goffart
* Merge commit 'staging-1/4.7' into doc-4.7Morten Engvoldsen2010-09-033-6/+6
|\
| * Reduce memory consumption of QtScript/JSC on SymbianKent Hansen2010-09-021-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Backport of Jay's patch from https://bugs.webkit.org/show_bug.cgi?id=34349 with minor modifications. Even though the original patch was rejected upstream and has been superseded by the patches for https://bugs.webkit.org/show_bug.cgi?id=43185, those patches are more involved (affecting all platforms), hence difficult/risky to backport. Task-number: QTBUG-13361 Reviewed-by: Simon Hausmann
| * doc: Remove \internal tag from QScriptProgramKent Hansen2010-08-312-5/+2
| | | | | | | | | | | | | | | | The class has been there since 4.6 (http://labs.trolltech.com/blogs/2009/11/23/qtscript-in-46/), but we don't see a reason to hide it any longer. Task-number: QTBUG-13229 Reviewed-by: Olivier Goffart
* | Fixed spelling, broken links, and missing default values.Jerome Pasion2010-08-301-1/+1
|/ | | | | Tasks: QTBUG-13271, QTBUG-13212, QTBUG-12321 Reviewer: David Boddie
* Make qsTrId() / QT_TRID_NOOP() accessible from QtScriptKent Hansen2010-08-231-0/+28
| | | | | | | | | QScriptEngine::installTranslatorFunctions() now installs wrapper functions for qsTrId and QT_TRID_NOOP (similar to the existing ones for tr() and translate()). Task-number: QTBUG-8454 Reviewed-by: Jedrzej Nowacki
* Fix memory leak in QtScript variable objectKent Hansen2010-08-102-2/+2
| | | | | | | | | | | | | | | The d-pointer is of type JSVariableObjectData*, but JSVariableObjectData doesn't have a virtual destructor. Hence we must cast the d-pointer to our subclass when deleting. In particular, this will ensure that the destructor of the symbolTable member is called, which will deallocate the table storage. (For QScriptActivationObject this did not cause a leak in practice, because its symbolTable is always empty, and JSC's hash table uses lazy allocation.) Task-number: QTBUG-12479 Reviewed-by: Olivier Goffart
* Correcting spelling mistakes in documentation. Part of fix for QTBUG-11938.Jerome Pasion2010-08-091-1/+1
| | | | | Reviewer: David Boddie Task number: QTBUG-11938
* QScript: remove JSC::JSLockOlivier Goffart2010-07-291-4/+0
| | | | | | They are useless and cause warnings in the code. Reviewed-by: Kent Hansen
* QScript: document/obsolete things that does not work since the move to JSCOlivier Goffart2010-07-295-20/+23
| | | | Reviewed-by: Kent Hansen
* QScriptEngineAgent: recompile all the function when installing a debugger.Olivier Goffart2010-07-272-0/+3
| | | | | | | | | | | | | | Recompile all the function is necessary to ger the debug opcode that notifies us when the position changes. The change in CollectorHeapIterator.h is nessesary to get it work as Debugger::recompileAllJSFunctions uses LiveObjectIterator, LiveObjectIterator initialied m_cell to -1 and to ++(*this) in its constructor. But as m_cell is of type size_t (unsigned) then the < comparison will always fail as it is an unsigned comparison. This was already fixed upstream in r54672 Reviewed-by: Jedrzej Nowacki
* QScriptDeclarativeObject: we need to save the current stack pointer.Olivier Goffart2010-07-271-2/+2
| | | | | | | in DeclarativeObjectDelegate::put, else we cannot get a proper backtrace in the debugger. Reviewed-by: Kent Hansen
* QScriptValue::objectId(): do not assert if the value is not a cellOlivier Goffart2010-07-271-1/+1
| | | | | | JSC::JSValue::asCell asserts if it is not a cell Reviewed-by: Jedrzej Nowacki
* QScriptEngineAgent: ensure that the top of the backtrace is correct in ↵Olivier Goffart2010-07-231-0/+3
| | | | | | exceptionThrow Reviewed-by: Jedrzej Nowacki
* Add missing API shimsKent Hansen2010-07-071-0/+6
| | | | | | | | There were still a couple of functions that didn't have them. This could cause said functions to crash if multiple script engines were being used. Reviewed-by: Jedrzej Nowacki
* Fix conversion between JavaScript Date and QDateTimeKent Hansen2010-06-256-427/+53
| | | | | | | | | | Use JavaScriptCore's conversion functions rather than our own (incomplete) implementation. Specifically, this means daylight saving time is finally handled correctly on Windows. Task-number: QTBUG-9770 Reviewed-by: Olivier Goffart
* Use custom static scopes to improve QML/JavaScript performanceKent Hansen2010-06-257-9/+321
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces a new internal JS object type, QScriptStaticScopeObject, that enables the JS compiler to make more aggressive optimizations of scoped property access. QScriptStaticScopeObject registers all its properties in a symbol table that the JS compiler has access to. If the compiler finds the property in the symbol table, it will generate the fast index-based op_{get,put}_scoped_var bytecodes, rather than the dynamic (slow) op_resolve and friends. If the compiler _doesn't_ find the property in the symbol table, it infers that it's safe to skip the scope object when later resolving the property, which will also improve performance (see op_resolve_skip bytecode). QScriptStaticScopeObject is only safe to use when all relevant properties are known at JS compile time; that is, when a function that has the static scope object in its scope chain is compiled. It's up to the user of the class (e.g. QtDeclarative) to ensure that this constraint is not violated. The API for constructing QScriptStaticScopeObject instances is not public; it lives in QScriptDeclarativeClass for now, an internal class exported for the purpose of QML. The instance is returned as a QScriptValue and can be manipulated like any other JS object (e.g. by QScriptValue::setProperty()). The other part of this commit utilizes QScriptStaticScopeObject in QtDeclarative in the two major places where it's currently possible: 1) QML disallows adding properties to the Global Object. Furthermore, it's not possible for QML IDs and properties to "shadow" global variables. Hence, a QScriptStaticScopeObject can be used to hold all the standard ECMA properties, and this scope object can come _before_ the QML component in the scope chain. This enables binding expressions and scripts to have optimized (direct) access to e.g. Math.sin. 2) Imported scripts can have their properties (resulting from variable declarations ("var" statements) and function declarations) added to a static scope object. This enables functions in the script to have optimized (direct) access to the script's own properties, as well as to global properties such as Math. With this change, it's no longer possible to delete properties of the Global Object, nor delete properties of an imported script. It's a compromise we make in order to make the optimization safe. Task-number: QTBUG-8576 Reviewed-by: Aaron Kennedy Reviewed-by: Olivier Goffart Reviewed-by: Jedrzej Nowacki
* Usefully convert from QtScript object/array to QVariantKent Hansen2010-06-173-17/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For arrays, the conversion would crash if the array was cyclic. Introduce a set that keeps track of which objects are being converted, and return an empty list when a cycle is detected. For other types of objects, the object was previously attempted to be converted to a primitive, which typically meant you would get the string representation ("[object Object]"), since most (practically all) objects can be converted to a string -- not useful at all. Change the conversion so it converts the object to a QVariantMap instead. This was already done for slots that took a QVariantMap as argument, but only one level deep. Make the conversion recursive, using the same mechanism as for arrays to detect cycles. This change also means that you get a meaningful JS object => QVariant => JS object roundtrip. It also aligns the behavior with the Qt WebKit bridge. Update the documentation to describe the new behavior. The 4.7 changelog will also be updated under "important behavioral changes". This change exposed an issue with one of the QML autotests: A JS object was assigned to a QVariant property, which caused it to be converted to a string (rather than a QVariantMap) -- just shows that the previous behavior was unintuitive). Later, this variant property is compared to another object, the intention being to compare the _properties_ of the two objects; but because the variant property contained a string, this would cause the other operand (object) to be converted to a string as well ("[object Object]"), causing a meaningless test pass. Change the test to deserialize both objects using JSON.stringify, and compare the resulting strings, so that actual JS object => QVariant(Map) => JS object roundtrip is tested (the intention). Task-number: QTBUG-3511 Reviewed-by: Olivier Goffart
* Allow to build Qt in static with mingwThierry Bastian2010-06-072-4/+2
| | | | | | | | | | Some functions were marked with Q_DECL_IMPORT where they should just be Q_CORE_EXPORT. The reason is that this macro is expanded to nothing in case of static builds whereas Q_DECL_IMPORT isn't (it is a dllimport). That leads the linker to try to import it and it shouldn't. Task-number: QTBUG-10791 Reviewed-by: gabi
* Ensure that activation object has been created before popping scope of ↵Kent Hansen2010-05-271-0/+1
| | | | | | | | | | | native context One shouldn't have to call activationObject() or scopeChain() before calling popScope(); the scope chain should always have 2 items (activation and global object) before we start popping anything from the internal chain. Task-number: QTBUG-11020 Reviewed-by: Olivier Goffart
* doc: Fixed many broken links.Martin Smith2010-05-191-3/+14
|
* Merge branch 'qt-4.7-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration ↵Qt Continuous Integration System2010-04-221-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | into 4.7-integration * 'qt-4.7-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration: (71 commits) Revert "Attempt at fixing compile failure introduced by 4.6 merge in qpaintengine_vg.cpp" Attempt at fixing compile failure introduced by 4.6 merge in qpaintengine_vg.cpp Fixing the wrong QUrl usage When on Symbian use smaller files. correctly position glyphs for complex languages Removed inneccessary QGlyphLayout::offsets initialization. Fix mirrored characters for RTL text in Symbian QNAM: Add a code comment related to the cache tst_QSystemSemaphore::processes fixed for WinCE tst_qsystemsemaphore: fix deployment of lackey.exe for WinCE tst_qsharedmemory: create multiple instances of lackey.exe on WinCE tst_qsharedmemory: fix deployment of lackey.exe for WinCE fix compilation of tst_sharedmemory on Windows CE QtScript: regression with instanceof operator for QMetaObject wrappers examples/widgets/stylesheet fix mainwindow.ui QStyleSheetStyle: fix memory leak on base style change QNAM HTTP: Fixed a bug when getting empty files with pipelining Fix window transparency on Symbian. Tweak the 'normalGeometry' of the widget before setting it. Use QDesktopWidget as a status pane observer on Symbian. ...
| * Merge remote branch 'origin/4.6' into qt-4.7-from-4.6Thiago Macieira2010-04-211-1/+1
| |\ | | | | | | | | | | | | | | | | | | Conflicts: src/openvg/qpaintengine_vg.cpp src/script/bridge/qscriptqobject_p.h tests/auto/bic/tst_bic.cpp