summaryrefslogtreecommitdiffstats
path: root/src/script/api
Commit message (Collapse)AuthorAgeFilesLines
* QtScript: Add API for reporting additional memory costsKent Hansen2010-03-254-3/+62
| | | | | | | | | | | | | | | | | | | | | | | | QScriptEngine::reportAdditionalMemoryCost(int). This function provides the ability to give a hint to the engine that it should perhaps trigger garbage collection sooner rather than later. For example, if you've implemented a JS ByteArray class that wraps a QByteArray, and a user constructs a few hundred temporary ByteArray objects of large sizes, failure to report the additional memory cost may cause the application's memory consumption to grow and grow (because the script engine thinks they are "cheap" objects, the GC won't kick in). Reporting the correct size can be difficult (or impossible) in some cases. For example, it's difficult to predict the total amount of system memory & resources consumed by a QImage. But even reporting a heuristic / approximate cost can be better than reporting no cost. Task-number: QTBUG-6238 Reviewed-by: Simon Hausmann
* QtScript: Add QObjectWrapOption for not exposing slotsKent Hansen2010-03-242-0/+2
| | | | | | | | | This makes it possible to have a prototype object in place that handles all slot calls, rather than having the slots be recreated in each wrapper object. Task-number: QTBUG-3637 Reviewed-by: Simon Hausmann
* QtScript: Add more missing API shimsKent Hansen2010-03-242-4/+9
| | | | | | Their absence was causing Bauhaus to crash. Reviewed-by: Simon Hausmann
* Merge branch '4.6-s60' into 4.7-s60axis2010-03-222-4/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure.exe mkspecs/common/symbian/symbian.conf src/gui/graphicsview/qgraphicswidget.h src/gui/kernel/qapplication.cpp src/gui/text/qtextlayout.cpp src/openvg/qpixmapdata_vg.cpp src/s60installs/s60installs.pro tools/runonphone/main.cpp tools/runonphone/serenum_unix.cpp qtextlayout.cpp fixed up together with Eskil. Kept the configure.exe from 4.7 without recompile.
| * installTranslatorFunctions doesn't work for custom global objectKent Hansen2010-03-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | Regression against the old back-end. Don't set the translator properties on the original global object but rather on the active one (except for String.prototype.arg, which should always be added to the original String constructor to match 4.5 behavior). Task-number: QTBUG-6437 Reviewed-by: Jedrzej Nowacki
| * Don't assert in QScriptValue::call()Kent Hansen2010-03-181-3/+2
| | | | | | | | | | | | | | | | | | Oops, the case of a non-array object argument wasn't implemented nor tested in the new back-end. This commit brings it in line with the behavior of the old back-end. Also test that QScriptValue::construct() doesn't have the same problem. Reviewed-by: TrustMe
* | Add missing QtScript API shimsKent Hansen2010-03-152-0/+4
| | | | | | | | Need shims wherever a JSC::Identifier can be created/destroyed.
* | Improve performance of QScriptValueIteratorKent Hansen2010-03-101-21/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The implementation was getting all the property names (identifiers) and storing their string representation. In e.g. value() and setValue(), the string representation then had to be converted back to an identifier. This was unnecessary work. Instead, store the identifiers directly, and use them via the QScriptValue private API whenever we can. This greatly improves the performance of scriptName(), value(), setValue(), flags() and remove(). (tests/benchmarks/script/qscriptvalueiterator is 4-5 times faster.) Reviewed-by: Jedrzej Nowacki
* | Add default argument values for QScriptValuePrivate property functionsKent Hansen2010-03-102-10/+11
| | | | | | | | | | | | | | | | Make them mirror the defaults of the public API, so that the QScriptValuePrivate property functions can be used internally in the same manner as the public API. Reviewed-by: Jedrzej Nowacki
* | Move method implementation to private classKent Hansen2010-03-102-5/+11
| | | | | | | | | | | | | | | | In preparation of being able to call toStringHandle() directly on a JSC::Identifier in QScriptValueIterator implementation. Reviewed-by: Jedrzej Nowacki
* | Update src/3rdparty/javascriptcore and adapt src/script to the changesKent Hansen2010-03-107-29/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Update qscriptvalueiterator test to expect length property when iterating arrays and strings. - Use EvalExecutable::create() instead of EvalExecutable constructor. The constructor is private. - Reimplement getOwnPropertyDescriptor() in all custom script objects. - Remove all reimplementations of getPropertyAttributes(). It doesn't exist in trunk anymore (getOwnPropertyDescriptor() is used instead). - Remove checkDontDelete argument from deleteProperty() reimplementations. The purpose of this argument was to support deleting properties with attribute Undeletable from C++. But it was quite an invasive patch to JavaScriptCore, and it doesn't seem worth it. If this feature is really crucial it should be re-done upstream. One of the tests needed to be updated so it's not sensitive to the C++ undeletability. - Adapt getOwnPropertyNames() reimplementations to signature change. - Add missing QScriptObject structure flags, otherwise we don't get all virtual calls. - Remove our patch for reporting column numbers in the debugger callbacks. It was just too intrusive. As with the checkDontDelete issue, this should be redone upstream if it's really important. In 4.7, QScriptEngineAgent will always report a column number of 1. Other compilation fixes: - InternalFunction::name() takes an ExecState* argument, not GlobalData* - ScopeChain::globalObject is no longer a function but a member variable - ScopeChainNode constructor takes a GlobalObject argument - Heap::collect() is called collectAllGarbage() - JSValue::strictEqual() takes an ExecState* argument - Debugger::exception() takes a bool hasHandler argument - Debugger no longer reports column number (we decided to drop that patch from JSC) - UString doesn't have operator+=(char*) - Update the autotests to reflect the columnNumber=1 change. - Add helper class to avoid crashing inside JSC. Ever since r52856 in WebKit trunk, this is needed. There are probably a lot of other public API functions that need this guard as well, but I'll add them as they are discovered. - Update mkdist-javascriptcore tag, exclude a few more files. - Set ENABLE_JSC_MULTIPLE_THREADS=0 define on Mac due to r52355 in trunk. Reviewed-by: Simon Hausmann
* | QScript: Fix crash when converting a null value to a variant.Olivier Goffart2010-03-041-1/+3
| | | | | | | | | | | | Fixes test tst_QScriptValue::equals(engine->newVariant(QVariant(123)) <=> engine->newArray(10)) Reviewed-by: Jedrzej Nowacki
* | QScript: Test against QMetaType::QVariant instead of against the stringOlivier Goffart2010-03-041-5/+6
| | | | | | | | | | | | | | now that QVariant is known to QMetaType, we can test for the metatype id instead of doing string comparison Reviewed-by: Kent Hansen
* | Perform latin1 conversion directly on JSC::UStringKent Hansen2010-03-012-17/+35
| | | | | | | | | | | | | | | | | | This conversion needs to be as fast as possible since it's performed every time you access a QObject property from QtScript. Hence, we should avoid going via QString and instead do the conversion ourselves. Reviewed-by: Jedrzej Nowacki
* | Avoid conversion between JavaScriptCore String type and QStringKent Hansen2010-03-014-18/+18
| | | | | | | | | | | | | | Use JSC::UString internally. Only when the public API demands it should a JSC::UString be converted to a QString. Reviewed-by: Jedrzej Nowacki
* | Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt-s60-public into master-s60axis2010-02-262-3/+11
|\ \ | |/ | | | | | | | | Conflicts: qmake/generators/symbian/initprojectdeploy_symbian.cpp qmake/generators/symbian/symmake_abld.h
| * Fix memory leak when lazily binding QScriptValue to an engineKent Hansen2010-02-222-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Avoid the engine's list of free script values from growing without bounds. When a QScriptValue is initially not bound, its private will be allocated from the normal heap (and not from the engine's pool of privates, because there is no engine at this point). But when a value is later bound (e.g. by setting it as a property of an object, or by passing it as argument to QScriptValue::call()) and is subsequently destroyed, its private will be handed to the engine, which will add it to its free-list (hence the memory is not freed). This allocation/deallocation asymmetry causes this list go keep growing. The solution is to limit the size of the free-list, and free the memory of the private immediately when the list has reached a certain size. Task-number: QTBUG-8400 Reviewed-by: Olivier Goffart
* | QScriptValue::isQMetaObject crash fix.Jedrzej Nowacki2010-02-241-1/+1
| | | | | | | | | | | | | | | | QScriptValue::isQMetaObject shouldn't crash for a value that internally is represented as a non JSObjects values. Additional check was added to QScriptEnginePrivate::isQMetaObject. Reviewed-by: Kent Hansen
* | Second attempt at work-around for MSVC2008 compiler crashKent Hansen2010-02-221-0/+5
| | | | | | | | | | | | Turn off optimizations in qscriptengine.cpp. I tried to turn it off/on for a selective few functions, but without success.
* | Work around MSVC2008 compiler crashKent Hansen2010-02-192-1/+27
| | | | | | | | | | | | | | | | | | "e:\pulse\work\91088\src\script\api\qscriptengine.h(360) : fatal error C1001: An internal error has occurred in the compiler. (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c[0x510A0530:0x00000007]', line 243) To work around this problem, try simplifying or changing the program near the locations listed above." Apparently the compiler doesn't like that a few functions are inlined.
* | Avoid calling out to public API in the QtScript implementationKent Hansen2010-02-184-287/+459
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's no reason to construct QScriptValues when JSC::JSValues can be operated on directly. A benchmark showed that ~10% of the time for reading a QObject property from a script was spent just creating and destroying QScriptValue temporaries. It's time to finally get rid of this potential bottleneck, not just in the QObject integration but everywhere. This change refactors the code so that all internal operations are performed on JSC::JSValue (most importantly, conversion from/to Qt types), and the public API functions are just thin wrappers around these. E.g. instead of doing enginePrivate->scriptValueFromJSCValue(jsValue).toQObject() the implementation now does QScriptEnginePrivate::toQObject(jsValue) Other operations are delegated to the engine implementation in similar style. Task-number: QTBUG-8304 Reviewed-by: Jedrzej Nowacki
* | Move property helper functions to QScriptEnginePrivateKent Hansen2010-02-184-206/+288
| | | | | | | | | | | | More preparation for operating purely on JSC::JSValue internally. Reviewed-by: Jedrzej Nowacki
* | Move more script value conversion code to helper functionsKent Hansen2010-02-182-65/+152
| | | | | | | | | | | | In preparation of operating purely on JSC::JSValue internally. Reviewed-by: Jedrzej Nowacki
* | Cleanup: Move value conversion code to helper functionsKent Hansen2010-02-183-11/+60
| | | | | | | | | | | | In preparation of doing this conversion in more places. Reviewed-by: Jedrzej Nowacki
* | Move implementation of QScriptValue construction functions to private classKent Hansen2010-02-182-91/+133
| | | | | | | | | | | | | | | | In preparation of getting rid of QScriptValue construction internally; the implementation should only call the private functions that operate directly on JSC::JSValues. Reviewed-by: Jedrzej Nowacki
* | Cleanup: Move number conversion functions to QScriptEnginePrivateKent Hansen2010-02-183-84/+81
| | | | | | | | | | | | | | Also rename ToUint{16,32} to ToUInt{16,32} to follow the Qt naming (it takes precedence over the ECMA one). Reviewed-by: Jedrzej Nowacki
* | Move some helper function declarations outside QT_NO_QOBJECT guardKent Hansen2010-02-181-13/+14
| | | | | | | | | | | | | | These are not dependent on QObject, I don't know how they ended up inside there. Reviewed-by: Jedrzej Nowacki
* | Cleanup: Move exception helper functions to QScriptEnginePrivateKent Hansen2010-02-183-35/+35
| | | | | | | | | | | | Because that's where they belong. Reviewed-by: Jedrzej Nowacki
* | Optimization: Avoid calling out to public API functionKent Hansen2010-02-151-2/+1
| | | | | | | | | | | | | | | | All the public QScriptEngine::create() function does is call the private implementation anyway, so call QScriptEnginePrivate::create() directly. Reviewed-by: Jedrzej Nowacki <jedrzej.nowacki@nokia.com>
* | Use RefPtr to store QScriptProgram's EvalExecutableKent Hansen2010-02-012-6/+7
|/ | | | | Otherwise we crash with latest WebKit trunk because the SourceProvider is prematurely destructed.
* Don't crash when comparing JSCore value without engine to non-JSCore valueKent Hansen2010-01-271-4/+9
| | | | | Task-number: None, discovering while doing test refactoring Reviewed-by: Jedrzej Nowacki
* Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into ↵Qt Continuous Integration System2010-01-1132-32/+32
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 4.6-integration * '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (71 commits) QNAM HTTP Code: Cache socket state inside ensureConnection() tst_qhttpnetworkconnection: Test also HEAD in some tests tst_qhttpnetworkconnection: Relax condition in getMultipleWithPriorities QNAM HTTP Code: When starting new request, prefer connected sockets. typo fix Added the 'framecapture' WebKit example to the default build. Fix code example fix typo in qreadwritelock's documentation QNAM HTTP: Don't call d_func() so often QNAM HTTP: Fix readBuffer maximum size. QNAM HTTP: Optimize eatWhitespace() QNAM HTTP: Check if socket already tries to connect. network internals: fix build on S60 [syncqt] Make -separate-module work with WebKit's directory structure doc: Corrected explanation of when append() does nothing. doc: Added clarification about allocating space for the 0 terminator. Add a way to access the normalised URL in QUrl. [syncqt] Make it possible to synchronize headers for a separate module [syncqt] Make it possible to override the base directory network internals: start HTTP GET requests right away when called ...
| * Update copyright year to 2010Jason McDonald2010-01-0632-32/+32
| | | | | | | | Reviewed-by: Trust Me
* | Correctly determine QScriptValue::isQObject() for QObjects using theMichael Brasser2010-01-111-4/+8
|/ | | | | | | | QScriptDeclarativeClass. Task-number: QTBUG-6178 Reviewed-by: Kent Hansen Reviewed-by: Aaron Kennedy
* Fix translation context for qsTr.Michael Brasser2009-12-101-3/+4
| | | | | | | Use the base of the file name as the translation context. (This was the original behavior before the switch to JSC.) Reviewed-by: Kent Hansen
* Fix garbage collection issue with script-owned objects with connectionsKent Hansen2009-11-301-10/+11
| | | | | | | | | | This reinstates the pre-4.6 behavior: A script-owned C++ object that's not referenced anymore should be garbage collected, even if it has connections. In order to achieve this, the "weak" reference to the C++ object's wrapper must be invalidated. Task-number: QTBUG-6366 Reviewed-by: Simon Hausmann
* Don't crash in eval() function when QtScript debugger is attachedKent Hansen2009-11-231-2/+8
| | | | | | | | | | | | | | | | | | | | | The built-in eval() function bypasses the script registration performed by QScriptEngine::evaluate(), so if we get an atStatement() callback from JSC from that script, the scriptID-to-sourceProvider lookup will fail. In this case, just return from atStatement() without delivering the positionChange() callback to the QScriptEngineAgent, since the agent will not have received the scriptLoad() callback for that script anyway. This is a change in behavior from 4.5, but we consider it the minimum-impact fix at this point to keep 4.6.0 from crashing. The only downside is that debugging will effectively be "disabled" for the script passed to eval(), but that's a lot better than crashing. Task-number: QTBUG-6108 Reviewed-by: Jedrzej Nowacki
* Merge branch '4.6' of oslo-staging-1 into 4.6Simon Hausmann2009-11-191-1/+5
|\
| * Application object must be constructed before QScriptEngineKent Hansen2009-11-181-1/+5
| | | | | | | | | | | | | | | | | | This is required due to the switch to the JavaScriptCore-based back-end. Instead of segfaulting somewhere inside JSC::initializeThreading(), call qFatal() when this constraint has been violated. Reviewed-by: Simon Hausmann
* | Ran the script utils/normalizeOlivier Goffart2009-11-181-1/+1
|/ | | | Over src/ tools/ examples/ and demos/
* Fixed the QtScript license information in the source files to referSimon Hausmann2009-11-1732-608/+32
| | | | | | | | to the LGPL only. To do this I ran replace-licenses.zsh $QTDIR/src/script release Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
* Replace LGPL license tags with LGPL-ONLYSimon Hausmann2009-11-1732-32/+32
| | | | Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
* Add QScriptDeclarativeClassAaron Kennedy2009-11-103-3/+16
| | | | | | | | | QScriptDeclarativeClass is a private, but exported, class used by the declarativeui module. It is very similar to QScriptClass, but slightly faster and provides a couple of "backdoor" extension mechanisms used by declarative. Reviewed-by: Warwick Allison
* added missing include for template instantiation (in qDeleteAll)mae2009-11-101-1/+1
| | | | (cherry picked from commit d01db18696a7729b0d54af76f5224aed6750f3bb)
* During a GC mark the scope chain of QScriptContextsAaron Kennedy2009-11-101-0/+18
| | | | | | | | | | | | | | | | | It appears that simply being in the scope chain of an existant frame isn't sufficient to be marked. This can lead to a QScriptContext scope chain that contains a JSObject that has been collected. For example, this code: QScriptContext *ctxt = engine->pushContext(); ctxt.pushScope(engine->newObject()); previouslyCreatedFunctionObject.call(); // causes a GC can lead to the object added to the scope chain to have become invalid. This leads to hilarity later on. Reviewed-by: Kent Hansen
* Add QScriptString::toArrayIndex() functionKent Hansen2009-10-302-0/+31
| | | | | | | | | | Avoid hacking a custom toArrayIndex() in the example; instead provide an ECMA-compliant conversion that's as fast as possible (having to convert the QScriptString to a QString and then convert the result to a number is considerably slower than calling JSC's Identifier::toArrayIndex() function directly). Reviewed-by: Olivier Goffart
* Say hello to QScriptProgram :-)Kent Hansen2009-10-287-58/+510
| | | | | | | | | | | QScriptProgram encapsulates a Qt Script program (AKA a script). It retains the compiled representation of the script, so that repeated evaluation of the same script becomes faster. An overload of QScriptEngine::evaluate() that takes a QScriptProgram has been added. Reviewed-by: Olivier Goffart
* Inline QtScript exception helper functionsKent Hansen2009-10-233-18/+18
| | | | | | Makes QScriptValue::toNumber() ~50% faster. Reviewed-by: Olivier Goffart
* Avoid calls to public QScriptValue::engine() functionKent Hansen2009-10-233-16/+31
| | | | | | | | | | Calls to engine() are mostly done for checking that the "source" and "target" engines are the same, but we don't want those checks to slow us down. Use an inline getEngine() function instead. This makes e.g. QScriptValue::call() ~10% faster for a function like "function(a, b) { return a + b; }". Reviewed-by: Olivier Goffart
* Speed up QScriptValue creation by avoiding operator= to be calledKent Hansen2009-10-231-32/+18
| | | | | | | | For non-object values, just return the value immediately; there is no way that the later check (result.isObject()) will be true anyway. This makes qScriptValueFromValue() ~50% faster. Reviewed-by: Olivier Goffart