aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v8
Commit message (Collapse)AuthorAgeFilesLines
* doc: fix some more typosSergio Ahumada2012-09-101-1/+1
| | | | | Change-Id: I7fa055049b9e5900d597754c6004febb153de12b Reviewed-by: Jerome Pasion <jerome.pasion@nokia.com>
* doc: fix some typos in .cpp filesSergio Ahumada2012-09-071-1/+1
| | | | | Change-Id: Ica7685aefde84ec80d8af7a67541af454de4adce Reviewed-by: Jerome Pasion <jerome.pasion@nokia.com>
* Delete weak JS objects on exit right awayThomas McGuire2012-08-311-1/+4
| | | | | | | | | This reduces memory leaks on exit when the engine is destroyed after exec() has finished. Change-Id: I917d103966d55b4dd3ba4e986ff902e29d8fb0ac Reviewed-by: Chris Adams <christopher.adams@nokia.com> Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
* Evaluate bindings more intelligently during constructionAaron Kennedy2012-08-293-0/+10
| | | | | | | | | | | | | | | | | Instead of just evaluating bindings in a fixed order, and possibly having to evaluate a single binding multiple times, prior to reading a property, we check if there are any bindings "pending" on it and evaluate them then. A pending binding is one that has been assigned to the property, but not yet evaluated. To minimize side effects we only do this for "safe" bindings. A safe binding is one that has no side effects, which we currently define as not calling functions or otherwise assigning values during its evaluation. This isn't an entirely foolproof way to ensure that the evaluation has no side effects, but it should be good enough. Change-Id: I98aa76a95719e5d182e8941738d64f8d409f404a Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
* Console API: Print JS objectAurindam Jana2012-08-281-12/+23
| | | | | | | | | Calling console.log(), console.debug(), print() etc would only print out "Object" if a JS Object was passed as an argument. This patch calls the toString() on the object. Change-Id: Iadf8b4d1fe81c3e2c7bd65e3c153a930fd994bef Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
* Refactor singleton type registration codeChris Adams2012-08-281-94/+80
| | | | | | | | | | | Previously each singleton type was registered as an implicit separate import. This commit changes the code so that these types are treated just like any other type in the registration sense. It also ensures that singleton types are instantiated per-engine. Change-Id: I5c81c4ca5bf65210f7125d74a62a282a21838068 Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
* Restrict v8 property lookup to the execution contextMatthew Vogt2012-08-275-47/+57
| | | | | | | | | | | | | When resolving property names, only properties known to the current context of execution should be available. If a property name has been overriden by a component extension, code executing in the context of the base component should resolve the property name to the property available inside the base component or its bases. Task-number: QTBUG-24891 Change-Id: I9687cc28e108226d5a939627a901c8254344b598 Reviewed-by: Michael Brasser <michael.brasser@nokia.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
* Immediatley delete QV8QObjectResource objects to reduce memory leaksThomas McGuire2012-08-241-2/+6
| | | | | | | | | | This reduces memory leaks when deleting the v8 engine. Otherwise, the memory would only be reclaimed during a full GC run, which might not happen at all. Change-Id: Iac34bad1f2280adc530d3b3d7a074c5d022005a4 Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com> Reviewed-by: Chris Adams <christopher.adams@nokia.com>
* Avoid dynamic lookup of signal handler argumentsMichael Brasser2012-08-242-33/+1
| | | | | | | | | | | Rewrite signal handlers to include the parameters in the rewrite. Also check whether parameters are actually used when possible, and if not don't provide them to the expression. Change-Id: I7d65c05f4639979dd61035cf7478119ef7647c25 Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com> Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
* Increase test coverage for V4Matthew Vogt2012-08-234-0/+22
| | | | | | | | Add test for integer operations, Math functions and exercise some previously uncovered code. Change-Id: Idff3f3672498775ac117ca98bf34b0fe96cbf760 Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
* Make connectNotify() work with QMLThomas McGuire2012-08-222-2/+5
| | | | | | | | | Call connectNotify() and disconnectNotify() in QQmlNotifierEndPoint, which works for QML signal handlers and for QML bindings. Task-number: QTBUG-11284 Change-Id: Ic9a08ee6687e5c7e606f315c8fb30eec1493cd83 Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
* Trim trailing whitespace.Stephen Kelly2012-08-222-17/+17
| | | | | Change-Id: I3d268d3ce8d73c7287f51abe9a28c165cb75acb9 Reviewed-by: Chris Adams <christopher.adams@nokia.com>
* Export QV8ValueTypeWrapper.Aaron McCarthy2012-08-221-1/+2
| | | | | | | This is required to implement value types in other modules. Change-Id: I0d59abb321b046efbaa73a5dcd24b72ee343fba7 Reviewed-by: Chris Adams <christopher.adams@nokia.com>
* Fix compilation on Linux with gcc-4.6Sean Harmer2012-08-211-7/+10
| | | | | | | | | Also make use of the seed. Change-Id: I03bd961489d95504bf973c02d51979904fbd9b1c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Use object identity to detect cycles in JS-to-C++ type conversionKent Hansen2012-08-204-34/+39
| | | | | | | | | | | | | | | | | | | | | | | | The documentation for v8::Object::GetIdentityHash() states that the hash value is not guaranteed to be unique (the current implementation just returns a random number). Hence, the hash value should not be used to determine whether an object has already been visited during type conversion; in the worst (and non-deterministic) case, the conversion will be "cut off" prematurely (due to identical hash values for two different objects), resulting in data loss. Instead, represent the visited objects as a set of V8 object handles. This is safe since the type conversion is always done on the stack, within a handle scope. Use v8::Object::GetIdentityHash() merely to implement the qHash() specialization needed for the set. V8 already provides an operator==() for handles, and it is documented to return true "if the objects to which they refer are identical", which is the behavior required by the set implementation. Task-number: QTBUG-21681 Change-Id: I1f2a1eee8f7c197c02c2ffeaaa1fc0274e8ab740 Reviewed-by: Michael Brasser <michael.brasser@nokia.com> Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
* Get rid of engine-wide state of visited objects for type conversionKent Hansen2012-08-204-42/+58
| | | | | | | | Pass the state through to internal conversion functions instead. Change-Id: Ifab9a9472d7271ee5da103ed915427dfd4f2b15b Reviewed-by: Michael Brasser <michael.brasser@nokia.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Add missing QT_{BEGIN,END}_NAMESPACEKent Hansen2012-08-171-0/+4
| | | | | Change-Id: Id924df99bd000ca5e7ffbef122c0087733f53685 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Document QJSEngine's lack of exception handling APIKent Hansen2012-08-161-3/+7
| | | | | | | | | | | | Since we consider throwing non-Error values an edge case, we decided not to add a an exception handling API (like QScriptEngine::hasUncaughtException() or v8::TryCatch) yet. Document this limitation in QJSEngine::evaluate(). Task-number: QTBUG-25857 Change-Id: I7f4869a152f176e613e3e8d2f81efeae198bd560 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
* Reduce memory consumption of source coordinatesMatthew Vogt2012-08-168-18/+23
| | | | | | | | | | Reduce memory consumption by storing source location coordinates as 16-bit variables (in run-time structures). Also modify qmlmin to restrict line lengths so that the column bound is not normally exceeded. Change-Id: I08605626ffbdf081b6da2aea1116bdfe24998572 Reviewed-by: Yann Bodson <yann.bodson@nokia.com>
* Remove the use of QWidgetStar from QtQml.Stephen Kelly2012-08-151-11/+1
| | | | | | | | | The enum value can be removed so that it can be replaced in functionality with QMetaType::PointerToQObject. There is no advantage to QtDeclarative knowing that a value is a QWidget pointer. Change-Id: I14530132bc37fbb0dc55ba8aaa5bb68db0d87bad Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Permit value types with metatype IDs >= QMetaType::UserMatthew Vogt2012-08-103-17/+13
| | | | | | | | | Remove the assumption that value types must be types defined by Qt, having metatype IDs below QMetaType::User. Task-number: QTBUG-26352 Change-Id: Ib5a56ff2e7892e82adf17a3a1e7517a0c9fe0534 Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
* Allow invokable functions of value-type classes to be calledChris Adams2012-08-093-12/+51
| | | | | | | | | | | | Previously, invokable functions of value-type classes were returned as properties. This commit fixes that bug by allowing such functions to be invoked normally. It also improves copy-value type handling. This commit also ensures that QMatrix4x4 value types are constructed with qreal values as this is the storage type used internally. Change-Id: Iab0fe4c522ed53d60154e8a8d46dda925fb9f4de Reviewed-by: Martin Jones <martin.jones@nokia.com>
* Ensure that copy sequences can be passed as argumentsChris Adams2012-08-093-1/+18
| | | | | | | | | | | | Previously, automatic conversion from JS array to sequence copy resource was not performed in the case where the array was passed as a parameter to a QObject function invocation. This commit adds code to check if the parameter type is a sequence type - and if so, and if the value is a variantlist, we convert it to a sequence of the appropriate type. Change-Id: I3cc3e2f95604bc71d1d8d237e1acffa1e03b78ba Reviewed-by: Glenn Watson <glenn.watson@nokia.com>
* Fix test failures in Qt Location with string lists.Glenn Watson2012-08-092-3/+12
| | | | | | | | | | | | | Cloning the V8 prototype introduces some unexpected behaviour in the way string lists are used in Qt Location. Instead, leave the prototype intact and used a named property accessor to return the sort method for sequence wrappers. A test case will be added to declarative once a more isolated test case has been created. Change-Id: I533a66f60af4394a2cc8c938fdfc13bd193f0065 Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
* Add type name to singleton (module api) implementations.Glenn Watson2012-08-081-41/+43
| | | | | | | | | | | | | This change renames the previous module api implementation to singleton types. When a singleton type is registered, a type name must be provided that is used when accessing the API from QML. This makes the implementation more consistent with the rest of QML. Task-number: QTBUG-26549 Change-Id: Iab0bb1ccf516bd3ae20aee562a64d22976e0aecd Reviewed-by: Chris Adams <christopher.adams@nokia.com>
* Support JS Array.sort() function for sequence wrappers.Glenn Watson2012-08-083-2/+67
| | | | | | | | | | | | | | The V8 natve sort implementation calls some functions that are incompatible with the way sequence wrappers work. In particular, it calls an internal length() function which does not pass through the length accessor provided by sequence wrappers, so the sort function always thinks the array is zero length. Instead, clone the array prototype and override the sort function with one that is specific to sequence wrappers. Task-number: QTBUG-25269 Change-Id: Ic83b9ee0bd3a0707e512f28057f0f99b432fded4 Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
* Improve QML basic types documentationChris Adams2012-07-301-1/+1
| | | | | | | | | | | | | | | Basic types are provided either by the language (int, string, bool, real, double, date, url, var, variant) or by modules (value types). In 5.1 we would like modules to be able to provide more basic types, and thus a cleaner separation of the documentation makes sense. This patch also improves linking of the term QtQml so that a clear distinction is made between the QtQml QML module and the QtQml C++ Qt Module (the QtQml QML module links now point to the QtQml type reference page). Change-Id: Ibe3ad33e4616c5f29ea38dadc27e13938aedb9d7 Reviewed-by: Bea Lam <bea.lam@nokia.com>
* Fix value-type semantics in variant propertiesChris Adams2012-07-242-29/+73
| | | | | | | | | | | Previously, variant properties storing value-type values would be treated as value-type-copy values rather than value-type-reference values. This caused inconsistency in behaviour with value-type subproperty assignment. Task-number: QTBUG-26562 Change-Id: I524ee06ab8e02bf9582c1a88f3317278199225e0 Reviewed-by: Martin Jones <martin.jones@nokia.com>
* Allow color to be explicitly compared to a stringMatthew Vogt2012-07-113-1/+41
| | | | | | | | | | Add the Qt.colorEqual() function which compares any combination of two supplied color and string arguments, by converting the string arguments to colors as necessary. Task-number: QTBUG-18754 Change-Id: I75baef9a2edd30a5f8b9cb5e151e4adba6f6a371 Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
* Fix broken value-type support by allowing property definitionChris Adams2012-07-115-1/+121
| | | | | | | | | | | | | | | | | | | | | In QtQuick 1.x the "variant" property type was supported, which could be used to allow value type properties to be defined in QML. In QtQuick 2.0, we have deprecated the "variant" property, but its replacement ("var") is not suited for defining lightweight C++ type values (such as QColor, QFont, QRectF, QVector3D etc). This commit allows those QML basic types to be used in QML once more, by supporting them in the property definition syntax. Note that since some value types are provided by QtQuick and others are provided by QtQml, if a client imports only QtQml they can define but not use properties of certain types (eg, font). Task-number: QTBUG-21034 Task-number: QTBUG-18217 Change-Id: Ia951a8522f223408d27293bb96c276281a710277 Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
* Use V4 binding for non-final properties where possibleMatthew Vogt2012-07-092-1/+4
| | | | | | | | | When a property referenced in a binding is not marked as final, do not automatically abort optimization. Instead generate both V4 and V8 binidngs, and only fall back to the V8 binding if necessary at run time. Change-Id: I1bcc7e2b495935c5d519a9a223f640c1972cdb4e Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
* Add some private V8ASSERT macros.Andrew den Exter2012-07-041-0/+11
| | | | | | | | Simple variation on the V8THROW macros to consilidate the normal usage pattern of if (!condition) THROW. Change-Id: I71aaabab705c3f73922efdaf8bb40b5dcc390101 Reviewed-by: Chris Adams <christopher.adams@nokia.com>
* Add basic documentation for QML translation functions.Michael Brasser2012-06-281-4/+128
| | | | | Change-Id: I50932ffd956061dd172616c4de863eb1a322394d Reviewed-by: Bea Lam <bea.lam@nokia.com>
* Add enum values from related typesMatthew Vogt2012-06-271-2/+3
| | | | | | | | | | If moc marks a type as being related to another type (by using that type's enums or properties), then include the enum values exported by the related type in those exposed by the dependent type. Task-number: QTBUG-22675 Change-Id: I78e72791a4f470200a9ba986a865ffac6c873725 Reviewed-by: Chris Adams <christopher.adams@nokia.com>
* Support enum return types in Q_INVOKABLE functions.Matthew Vogt2012-06-221-3/+13
| | | | | | | | | Handle enums correctly when used as the return type of a Q_INVOKABLE function. Task-number: QTBUG-23543 Change-Id: I14a506ffee08f5ba6aa0fdf27d6104a3ae5c48b3 Reviewed-by: Chris Adams <christopher.adams@nokia.com>
* Create new documentation structureChris Adams2012-06-211-3/+3
| | | | | | | | | | | | | | | | | | | | The documentation currently has no clear separation between Qt QML and Qt Quick. With recent commits like: 6c8378eaf1edbbefe6aaa3672b0127816a004fd7 and ab1e510121c8a679fdaca12ccd30e0f7ac12a26b the separation between the language definition and implementation, provided by Qt QML, and the standard library for the QML language, provided by Qt Quick, is clear. This commit creates a new documentation structure that is more navigable and separates concepts into logical categories, with clear separation between QtQML and QtQuick. It also provides a more generic QML Application Developer Resources page which contains links to information for QML application developers. Change-Id: Ia807ccfbfd24ffa0e1c7f0a51ed9d2ed3aa6a733 Reviewed-by: Martin Jones <martin.jones@nokia.com>
* Delay conversion of v8 exceptions to QQmlErrors.Michael Brasser2012-06-051-8/+5
| | | | | | | | | This conversion in relatively expensive, and not required for transient exceptions that occur during startup due to the order of binding evaluation. Change-Id: I29a16c075890c8966c0bad0a77412ad232c791bb Reviewed-by: Matthew Vogt <matthew.vogt@nokia.com>
* Fix doc snippets paths and parsing errorsBea Lam2012-05-314-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qtqml.qdocconf and qtquick.qdocconf now refer to the correct snippets and source directories. Snippet paths in .qdoc and .cpp files have been updated to refer to the new shortened path references, e.g. \snippet qml/file.cpp instead of \snippet doc/src/snippets/qml/file.cpp. This also deletes snippets from src/qml/doc/snippets that belonged under src/quick/doc/snippets (and were already duplicated there anyway) and restores some snippet files that shouldn't have been deleted. Also fixes some inline snippets to use \code .. \endcode instead of \qml .. \endqml as they contained javascript or partial QML snippets that were causing parsing errors from qdoc. There are still snippet errors arising from qmlintro.qdoc as the qmlintro snippets directory that it refers to cannot be located. There are also two references to a removed snippet identifier in examples/qml/cppextensions/plugins/plugin.cpp that need to be fixed in conjunction with the related docs in a later commit as the relevant code has changed and the docs are now invalid. Task-number: QTBUG-25721 Change-Id: I50c665245a74c140470c58a32546591d187dfe4b Reviewed-by: Chris Adams <christopher.adams@nokia.com>
* Ensure that variant property references keep QObjects aliveChris Adams2012-05-301-4/+8
| | | | | | | | | | | | | Previously, only var property references could keep QObjects alive. This meant that the garbage collector would collect QObject data prematurely. This commit ensures that variant properties keep QObjects alive as required. Task-number: QTBUG-24767 Change-Id: Ic98a06863251a3e7d6384ba9256810a78fb23406 Reviewed-by: Martin Jones <martin.jones@nokia.com>
* Add internal API for accessing V8 handles of QJS typesKent Hansen2012-05-294-0/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make it possible to use the V8 API directly. This might be necessary in cases where the QJS API is missing some functionality (e.g., controlling the V8 profiler), or for performance reasons (e.g., avoiding overhead of QJSValue indirection). The V8 API is clearly more extensive than the QJS API, and QJS will likely never reach feature parity with it (since that's outside the scope of QJS). By providing access to the underlying V8 types, users can still choose to use V8 directly in the (hopefully rare) cases where the public QJS API isn't sufficient. Two new functions are introduced: - qt_QJSEngineV8Context(QJSEngine *) returns a local handle to the engine's internal V8 context. - qt_QJSValueV8Value(const QJSValue &) returns a local handle to the QJSValue's internal V8 value. The caller is responsible for - ensuring that a V8 handle scope is in place; - entering/exiting the QJSEngine's V8 context. The documentation and tests show how that can be done. Also added a benchmark for QJSValue that can be used to measure the effect of using raw V8 API for some common operations. Change-Id: I680aeb2f67ffe5eeadd432a05c8084e43921a118 Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Fix crash caused by unregistered enum typesChris Adams2012-05-281-4/+10
| | | | | | | | | | If the enum type isn't registered with Q_ENUMS, the metatype lookup fails, which results in a crash in certain circumstances. This commit ensures that when assigning an undefined value to an unregistered-enum-type property, no crash occurs. Change-Id: I0b539b591c9c9d6262c748300e4f4b6813d4f9a6 Reviewed-by: Martin Jones <martin.jones@nokia.com>
* Add an v8 object template for visual data model change sets.Andrew den Exter2012-05-253-2/+2
| | | | | | | | | | This is more optimal than dynamically creating an object per change for each signal emission. Also create static string instances for property names common to all item objects. Change-Id: I8b0a6b683df4ee9c55c15cc928603e82f37045f7 Reviewed-by: Martin Jones <martin.jones@nokia.com> Reviewed-by: Chris Adams <christopher.adams@nokia.com>
* Remove exceptions support from QtQmlChris Adams2012-05-251-14/+2
| | | | | | | | | | | | | | Previously, the sequence wrapper handled std::alloc exceptions. This commit removes that handling, as there are many other ways to use up all of the available address space memory which aren't handled (eg, loading lots of large images), and exception support causes a large overhead. See a1151929fffc765e128d72d170342020b34dd0b3 for more information. Change-Id: I68c9d7744e7dcece7b3112352e01ac71ead12f62 Reviewed-by: Glenn Watson <glenn.watson@nokia.com> Reviewed-by: Martin Jones <martin.jones@nokia.com>
* Use static dispatch tables for QQmlAbstractBindingAaron Kennedy2012-05-242-25/+60
| | | | | | | | | This saves us the space of the virtual table pointer, but does somewhat limit us to the 4 QQmlAbstractBinding types that we have today. Change-Id: I03d06ef2ec0c51271c28e7a5aab6dc689d369da4 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* Update license headersKent Hansen2012-05-243-30/+84
| | | | | | Change-Id: Ica6a0d62697ec6ef626280ca203b6f6839f64d81 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
* Lazily create QMetaObjectsAaron Kennedy2012-05-241-17/+16
| | | | | | | | | | For internal QML built types, creating a metaobject each time is just wasteful. Additionally, as the property caches were always created from the intermediate QMetaObject, it was difficult to pass information directly from the compiler to the property cache. Change-Id: I769526b0edaaf16a86883f3065b75618b94e4077 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
* Fix the logic in void return type checkKent Hansen2012-05-241-1/+1
| | | | | | | | | | Since the introduction of QMetaType::UnknownType, QMetaType::Void no longer has value 0. Hence, the optimization in this code (avoiding return type construction/passing/conversion when the return type is void) was "lost". Change-Id: I32313f8287c4f0e01fee3c2b4ba722f31457242c Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Remove QJSEngine::ContextOwnership and associated constructorKent Hansen2012-05-244-24/+8
| | | | | | | | | This API was intended for QtWebKit integration, but we decided to keep it out of the public headers and introduce it in a different way later. Change-Id: I7f30b20b741eca8569e63a7e4e27171d75293567 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Remove QQmlEngine::collectGarbage() overloadKent Hansen2012-05-241-3/+1
| | | | | | | | | | | QQmlEngine inherits from QJSEngine, which has a collectGarbage() function that does exactly the same. Also remove doc references to non-existing function reportAdditionalMemoryCost(). Change-Id: Iff12d2cf940f3afcd88967eb9a841c2f6082ca37 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
* Enable binding to properties of type QJSValue.Andrew den Exter2012-05-242-2/+11
| | | | | | | | | This allows javascript objects of all types to be bound to properties declared in c++. Compared to a QVariant the primary benefit this offers is a type which functions and objects with functions can be bound to. Change-Id: Idb3313e7ff1d616ab12d44f616083c8296201f3a Reviewed-by: Kent Hansen <kent.hansen@nokia.com>