summaryrefslogtreecommitdiffstats
path: root/src/script/api
Commit message (Collapse)AuthorAgeFilesLines
* 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-071-3/+1
| | | | | | | | | | 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
|
* QScript: use JSC::NativeFunctionWrapper instead of JSC::PrototypeFunction ↵Olivier Goffart2010-04-191-2/+2
| | | | | | | | | | | | | | | | | when possible JSC::NativeFunctionWrapper is a typedef to either JSC::PrototypeFunction or JSC::JSFunction depending if we are running JIT or not. When using JIT, JSC::JSFunction is faster, as it allow JIT to do the native call dirrectly. The difference is that in that case, the JS stack is not fully set up so we have to be carefull. Unfortunately, it is not possible to make FunctionWrapper inherit from JSC::NativeFunctionWrapper, because JSFunction is slightly bigger, and we cannot fit in a Cell Reviewed-by: Kent Hansen
* Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into ↵Qt Continuous Integration System2010-04-172-2/+19
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 4.7-integration * '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (71 commits) Autotest: increase wait time to 3s on Windows to bypass 2s-granularity limitation Autotest: update to the new values for the locale do not expand variables in read()'s file name remove ability to use break() a block outside any loop don't add -unix to the qmake command line Increase the timeout for the QNAM getter test to 30 seconds Remove unstable hosts from the list qdoc: Output TOC for more class ref pages. Other fixes to the remote network stresstester Fix SSL connection problem. Make sure we don't try URLs that aren't HTTP or HTTPS Fix menu bar visibility. Add SSL remote host tests Split the remote and the local tests in two, in preparation for SSL tests Add tests for remote hosts Change the way we calculate the average transfer rates. Finish renaming Move these tests to tests/manual. Add a QNetworkAccessManager stresstest Add a non-blocking native function too ...
| * Speed up qsTr() by caching the translation contextKent Hansen2010-04-152-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qsTr() uses QFileInfo::baseName() to determine the translation context from a URL. The problem is that creating a QFileInfo object (and thus a file engine object), as well as processing the URL to determine the base name part, is very expensive. By caching the last translation URL and context, qsTr() becomes 5x faster. Only the most recent URL is cached, because a script's text will be translated all at once (as the script is evaluated), so for scripts with multiple translated strings only the first qsTr() call will cause a cache miss. The performance could be improved even further by getting rid of the QFileInfo dependency altogether; created QTBUG-9939 for that since it's a more risky change. Task-number: QTBUG-6908 Reviewed-by: Olivier Goffart
* | Fix mismatched import declarationsThiago Macieira2010-04-171-1/+1
| |
* | Merge remote branch 'origin/4.6' into qt-4.7-from-4.6Olivier Goffart2010-04-161-4/+4
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/3rdparty/webkit/VERSION src/3rdparty/webkit/WebCore/ChangeLog src/3rdparty/webkit/WebCore/page/FrameView.cpp src/3rdparty/webkit/WebCore/rendering/RenderWidget.cpp src/3rdparty/webkit/WebKit/qt/symbian/eabi/QtWebKitu.def src/s60installs/bwins/QtCoreu.def src/s60installs/bwins/QtGuiu.def src/s60installs/bwins/QtNetworku.def src/s60installs/eabi/QtGuiu.def tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
| * Symbol visibility fixes for RVCT4 on SymbianIain2010-04-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | RVCT 4 is far more strict with regards to symbol visiblity that RVCT 2.2, and will hide symbols unless all references have default visibility in the object files. Update the various places in Qt code where the symbol visibility was set incorrectly for DLL-based platforms (those that use __declspec(dllimport) and (dllexport). Note: QtWebkit and other Qt modules are fixed in different commits. Task-number: QTBUG-9903 Reviewed-by: Jason Barron
| * QtScript: Fix call stack issue with qsTr() when JIT is enabledKent Hansen2010-04-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the JIT is enabled, as well as JIT_OPTIMIZE_NATIVE_CALL defined, NativeFunctionWrapper is a typedef for JSFunction. This has the consequence that the native call frame will not be fully initialized by JIT-generated code (because it shouldn't have to); in particular, ExecState::codeBlock() is not set up. qsTr() relies on codeBlock() to return a sensible value, though, so it breaks this contract. By making qsTr a PrototypeFunction, the JIT will detect that the function call needs more elaborate setup, i.e. initialize codeBlock() as well. Reviewed-by: Olivier Goffart
| * Improve test coverage of QtScript translation functionsKent Hansen2010-04-141-2/+2
| | | | | | | | And fix two silly typos in the error messages.
* | Merge remote branch 'origin/4.6' into qt-4.7-from-4.6Thiago Macieira2010-04-141-3/+13
|\ \ | |/ | | | | | | Conflicts: src/script/api/qscriptengine.cpp
| * Make qsTr work in global scopeKent Hansen2010-04-131-3/+13
| | | | | | | | | | | | | | | | | | | | | | Search up the call stack to find the first non-empty source URL. Also and add an autotest for the QtScript translator functions since there was none (their presence was checked, but not their behavior...). Task-number: QTBUG-9775 Reviewed-by: Olivier Goffart
* | Fix crash on QScriptProgram destructionAaron Kennedy2010-04-121-0/+4
| |
* | Merge remote branch 'origin/4.6' into qt-4.7-from-4.6Thiago Macieira2010-04-092-4/+17
|\ \ | |/
| * Regressions in Global Object prototype accessKent Hansen2010-04-092-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 4.5, changing the prototype of the (custom) global object used to "Just Work"(tm). In the JSC-based back-end, the built-in global object acts as a proxy if a custom global object is set, because JSC doesn't (yet, anyway) provide a way to replace the global object. To complicate this further, we also have a proxy to the original global object (that bypasses the custom global object proxying (!)). This is so that properties of the original global object can still be accessed with the QtScript C++ API when a custom global object has been set. Unfortunately, JSObject::prototype()/setPrototype() are not virtual, meaning that a change of prototype in the source object is not reflected in the proxy or vice versa. Work around this for now by syncing the prototype at the appropriate places (QScriptEngine::setGlobalObject(), QScriptValue::setPrototype()). This fixes all except the case when a prototype is set from JS, since such a write doesn't go through our public C++ API. But this case can be detected and handled by the global object's JSObject::put() reimplementation. Created a separate report for that issue: QTBUG-9737. Task-number: QTBUG-7066 Reviewed-by: Jedrzej Nowacki
* | QScript: more missing APIShimOlivier Goffart2010-04-011-0/+2
| |
* | QScript: fix compilation warningOlivier Goffart2010-04-011-1/+1
| |
* | QScript: fix APIShim usage.Olivier Goffart2010-04-011-1/+1
| | | | | | | | | | APIShim needs to be named, otherwise it is just a temporary and the destructor is called too early
* | QtScript: remove duplicated APIshim in QScriptValueIteratorOlivier Goffart2010-04-011-6/+0
| | | | | | | | | | | | | | Added by both 7a11acd536d84ad22ef98a0fdbdb4322a55efafb and 3e5745ea75d73869918889cb374c3d651bed0991 in different branches. in ~QScriptValueIterator and ~QScriptValueIteratorPrivate Only one is required.
* | Merge remote branch 'origin/4.7' into 4.7Olivier Goffart2010-04-015-2/+51
|\ \ | | | | | | | | | | | | Conflicts: src/gui/text/qstatictext.cpp
| * | QtScript: Add yet more missing API shimsKent Hansen2010-03-263-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - for QScriptEngine and QScriptContext; we don't control what the JSC functions are doing, so it's better to have shims than not to have them (which can cause something to blow up), even if they might not be strictly necessary as of this writing. - for QScriptDeclarativeClass; otherwise the identifiers might be created/destroyed in the wrong engine. - for QScriptValueIterator destructor; otherwise the identifiers might be destroyed in the wrong engine. This is an attempt to fix a crash in Bauhaus, but it might still be crashing (i.e. still some shims missing, somewhere) ;(
| * | QtScript: Make sure the old identifier table is restoredKent Hansen2010-03-263-3/+6
| | | | | | | | | | | | Use a shim to take care of that.
* | | QScript: More missing APIShimOlivier Goffart2010-03-291-0/+4
| | | | | | | | | | | | Fixes crash in tst_QScriptValueIterator::remove on windows
* | | QScriptEngine: Fix reentrency involving creation and desctructions of ↵Olivier Goffart2010-03-293-24/+80
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | QScriptEngines the currentIdentifierTable table, which is a static thread local variable, could be corrupted. The main change is to fix the QScriptEngine constructor not to alter the currentIdentifierTable This showed a lot of cases where APIShim guards where missings. The problem was seen with creator, related to QTBUG-9426 Reviewed-by: Jedrzej Nowacki
* | 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