platform/upstream/qtdeclarative.git
11 years agoRemove v8 dependencies in qhashedstring
Lars Knoll [Tue, 21 May 2013 20:04:36 +0000 (22:04 +0200)]
Remove v8 dependencies in qhashedstring

Also remove now unused API in v8::String

Change-Id: I2570aedf407c89ad85da01cf0e2153a52b4e562d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoGet rid of v8::String::(Ascii)Value
Lars Knoll [Tue, 21 May 2013 19:23:01 +0000 (21:23 +0200)]
Get rid of v8::String::(Ascii)Value

Change-Id: I792a94590efbec852620d101b620b263a90e1d54
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix running through all tst_qqmlecmascript tests
Simon Hausmann [Tue, 21 May 2013 19:31:45 +0000 (21:31 +0200)]
Fix running through all tst_qqmlecmascript tests

* Implement SetHiddenField/GetHiddenField (hack)
* Fix recursive calls to SetEngine, to allow for the re-use of
  the QQmlEngine member in tst_qqmlecmascript after ~QQmlEngine
  was called on another instance
* Fix array sizing in function call parameter handling
* Don't try to clone the function object in Qt.binding (assert instead)

Change-Id: Ia3155dea8518348ec329037ca04e5c38e47a4f92
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFinalize sequence wrapping
Simon Hausmann [Tue, 21 May 2013 15:06:36 +0000 (17:06 +0200)]
Finalize sequence wrapping

* Move into QV4 namespace
* Get rid of sequence wrapper instance, all static methods now

Change-Id: I9a9e7ce10890cfe4625b3571bdb4b0ffec34658a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFold qv8sequencewrapper_p_p.h into qv8sequencewrapper.cpp
Simon Hausmann [Tue, 21 May 2013 14:31:05 +0000 (16:31 +0200)]
Fold qv8sequencewrapper_p_p.h into qv8sequencewrapper.cpp

Most of the implementation belongs into a C++ file instead of a header file,
it's not re-used from anywhere else.

Change-Id: Ib41e3e104d9544710343b869116368bbca999622
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoEliminate last v8 dependency from QV8SequenceWrapper
Simon Hausmann [Tue, 21 May 2013 14:24:00 +0000 (16:24 +0200)]
Eliminate last v8 dependency from QV8SequenceWrapper

Stub out file name and line number information in QV4::ExecutionContext,
used for warning generation.

Change-Id: I922541e1ee4a5e2211ca6c16494d2b9044a9c346
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoPort the rest of the sequence types to V4
Simon Hausmann [Tue, 14 May 2013 16:58:34 +0000 (18:58 +0200)]
Port the rest of the sequence types to V4

Change-Id: Ia248f54b65b74d16e91e6ec72503eb967894586d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix the build
Simon Hausmann [Tue, 21 May 2013 13:33:18 +0000 (15:33 +0200)]
Fix the build

Change-Id: I04a2e3c280b622378bf4431a77388e59eb31ad10
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoGet rid of v8::Primitive
Lars Knoll [Tue, 21 May 2013 10:45:12 +0000 (12:45 +0200)]
Get rid of v8::Primitive

Change-Id: Idd31a8d522119cade9bb18854e124b80f1c57123
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoGet rid of v8::Boolean
Lars Knoll [Tue, 21 May 2013 10:43:37 +0000 (12:43 +0200)]
Get rid of v8::Boolean

Change-Id: I10b4240db78532dfdf972bb0a6f191462d81caaa
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoGet rid of v8::Number
Lars Knoll [Tue, 21 May 2013 10:37:52 +0000 (12:37 +0200)]
Get rid of v8::Number

Change-Id: I38bdf8fe4dd73c61317912ec6308a9a1e870ad99
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoGet rid of v8::Integer
Lars Knoll [Tue, 21 May 2013 10:33:55 +0000 (12:33 +0200)]
Get rid of v8::Integer

Change-Id: I6b9ab830c4ff3cbf986dbcf7c056648b5a16a222
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove some unused classes from the v8 API
Lars Knoll [Tue, 21 May 2013 08:56:08 +0000 (10:56 +0200)]
Remove some unused classes from the v8 API

Change-Id: I6fdb7903a3cdb3b3167144f78bd7cf58647deb67
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoSmall exception handling fixes
Simon Hausmann [Tue, 21 May 2013 08:17:30 +0000 (10:17 +0200)]
Small exception handling fixes

* Don't accept the exception if we're going to re-throw it (partial unwind
is not necessary as we don't have a stack-based context to clean up)
* However do accept() it if we decided to handle it (in qqmlvme.cpp)

Change-Id: I63bfa34f30fe19ad36de746b1f15fc6b641e563b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix crashes when invoking QML JS methods from C++
Simon Hausmann [Tue, 21 May 2013 08:27:25 +0000 (10:27 +0200)]
Fix crashes when invoking QML JS methods from C++

Make sure to size the QVarLengthArray properly to avoid out-of-bounds
access.

Change-Id: Id075730ffa2e366a729b401b8563ad7fd59597de
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoGet rid of v8::TryCatch and v8::Message
Lars Knoll [Mon, 20 May 2013 22:05:52 +0000 (00:05 +0200)]
Get rid of v8::TryCatch and v8::Message

They are now unused, so let's remove them from the v8 API.

Change-Id: I9c1b39632cb88785ae6fdda671580e0426ae97ba
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert the remaining TryCatch statements to use QV4::Exception
Lars Knoll [Mon, 20 May 2013 21:51:45 +0000 (23:51 +0200)]
Convert the remaining TryCatch statements to use QV4::Exception

v8::Script::Run doesn't catch the exception anymore. Instead we handle
this on the calling side, removing all needs for v8::TryCatch.

Change-Id: I946269a6734f50c728c4f153c00cd19db48f1a6a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove half the v8::TryCatch statements
Lars Knoll [Mon, 20 May 2013 20:12:41 +0000 (22:12 +0200)]
Remove half the v8::TryCatch statements

Replacing the other half requires a replacement for v8::Script.

Change-Id: I40fe99302fba23f286773ec1adaf8d3751db901d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix return value for QQmlJavascriptExpression::evaluate
Lars Knoll [Mon, 20 May 2013 18:32:58 +0000 (20:32 +0200)]
Fix return value for QQmlJavascriptExpression::evaluate

Change-Id: Idf95ee51b7d50682476371c7f49537930fdf96f1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoCleanup QQmlDelayedError
Lars Knoll [Mon, 20 May 2013 18:27:16 +0000 (20:27 +0200)]
Cleanup QQmlDelayedError

Remove dependency onto v8::Message and simplify conversion from
QV4::Exception to QQmlError.

Change-Id: Icfdfd7a2749210b2df9fda6cd5de94114b8adcfa
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd source file and line number to QV4::Exception
Lars Knoll [Mon, 20 May 2013 18:24:42 +0000 (20:24 +0200)]
Add source file and line number to QV4::Exception

This will allow us to replace v8::Message properly and give
us proper error reporting for uncaught exceptions.

Change-Id: I1c03b6c21456dea06931a874bb2aa5a0b00aff62
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMove QQmlJavascriptExression::evaluate over to v4
Lars Knoll [Mon, 20 May 2013 16:55:49 +0000 (18:55 +0200)]
Move QQmlJavascriptExression::evaluate over to v4

Change-Id: Ic4093dc5413f43af55a74a0e0f8c316ac1c6d974
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix some parts of workerscript and convert to v4
Lars Knoll [Mon, 20 May 2013 09:00:58 +0000 (11:00 +0200)]
Fix some parts of workerscript and convert to v4

Add some try/catch blocks around calls to v4, fixing
some crashes in the worker script auto test.

Change-Id: I591a25facc8afd5c6f99ffb7b75530c890318280
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRename QV8Worker to QV4::Serialize
Lars Knoll [Mon, 20 May 2013 09:13:48 +0000 (11:13 +0200)]
Rename QV8Worker to QV4::Serialize

The class is only being used in WorkerScript, but in itself
only does serialization of JS Values.

Change-Id: Ibf1b06acf5abcfcc00cada9cc8cad9a833bd7ea3
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoComment out two lines that cause assertions
Lars Knoll [Mon, 20 May 2013 09:00:06 +0000 (11:00 +0200)]
Comment out two lines that cause assertions

The subcontext code is only used to add debugging info
through the V8 API.

Change-Id: Ibcb3284180aca1568b44d9d387d96bfae715283d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix a bug in the creation of JS Array's from variant and string lists
Lars Knoll [Sun, 19 May 2013 21:50:47 +0000 (23:50 +0200)]
Fix a bug in the creation of JS Array's from variant and string lists

Correctly set the arrayDataLen or V4 assumes the array is empty.

Change-Id: I6b7454b2e7a2b459b1e41e6d6234f89460013107
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoProperly initialize regexp objects created from QRegExp's
Lars Knoll [Sun, 19 May 2013 21:16:48 +0000 (23:16 +0200)]
Properly initialize regexp objects created from QRegExp's

Change-Id: Id6c9abe7e20bf91c37a6bd335117266a8e8aa8fd
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix a bug in V4V8Object::put()
Lars Knoll [Sun, 19 May 2013 21:15:13 +0000 (23:15 +0200)]
Fix a bug in V4V8Object::put()

When a fallback handler returns an empty value it is not
intercepting the call, and thus the put() method of the base
obejct should get called.

Fixes most issues with worker threads.

Change-Id: I88f0fcb6349cc818163248d456e3fb916188f48f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoconvert qv8workerscript to v4
Lars Knoll [Thu, 16 May 2013 10:17:22 +0000 (12:17 +0200)]
convert qv8workerscript to v4

Change-Id: Ifc204f53a46c857a2a7caaa4f6900d4300163dbb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix connect/disconnect in QObject bindings
Simon Hausmann [Tue, 14 May 2013 06:43:45 +0000 (08:43 +0200)]
Fix connect/disconnect in QObject bindings

The hack of using ScriptOrigin to identify JS wrapper functions for Qt methods
is not possible for us to implement (or doesn't make sense). However the bindings
rely on this feature, so implement it using a semi-private property hack.

Change-Id: I6c7852f46916a9f549bf703d47546e7ddd75a1b1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoSmaller cleanups in qv8engine
Lars Knoll [Thu, 16 May 2013 07:31:28 +0000 (09:31 +0200)]
Smaller cleanups in qv8engine

Change-Id: I5cc7150c37312db78ce0985fe546646a9df61258
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoDon't GC constructors and prototypes
Lars Knoll [Tue, 14 May 2013 00:33:03 +0000 (02:33 +0200)]
Don't GC constructors and prototypes

Change-Id: Iedc894927bc93dc3f5778a4f7855eb3ec37b946b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoconvert QV8VariantWrapper to v4
Lars Knoll [Tue, 14 May 2013 00:01:04 +0000 (02:01 +0200)]
convert QV8VariantWrapper to v4

Implement variant support through a QV4::VariantObject
class. Port scarce resource support for the
pixmap and image variants.

Change-Id: Ib6aac8debc7f57224ccddb912ab4342c5f1dec15
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoChange some APIs in qv8variantwrapper over to be v4 based
Lars Knoll [Mon, 13 May 2013 16:39:57 +0000 (18:39 +0200)]
Change some APIs in qv8variantwrapper over to be v4 based

Change-Id: Idfba6a92bc23dbb8fe14d67ed4a4be901dc0e10a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix QJSValue::toVariant and isVariant
Lars Knoll [Mon, 13 May 2013 16:30:16 +0000 (18:30 +0200)]
Fix QJSValue::toVariant and isVariant

Change-Id: I7360e37e34756e26f3e8936751c6b65a9d0a2167
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMore correct conversion to a QString when toString() throws
Lars Knoll [Mon, 13 May 2013 16:29:33 +0000 (18:29 +0200)]
More correct conversion to a QString when toString() throws

Change-Id: I0c11b5ed593593f849ec272ae17f2ef4525f3629
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoGive the QJSValuePrivate the pointer to the engine back
Lars Knoll [Mon, 13 May 2013 16:07:44 +0000 (18:07 +0200)]
Give the QJSValuePrivate the pointer to the engine back

Unfortunately the value needs a pointer back to the engine, to keep
compatibility with the old code and have our tests pass unmodified.

Change-Id: Ibe26e6c770bd8d26dad4a26d42b40e3e1af4996c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAnother fix for getting more of the QML based tests running
Simon Hausmann [Mon, 13 May 2013 14:11:35 +0000 (16:11 +0200)]
Another fix for getting more of the QML based tests running

The QML testlib uses the in operator on the QObject bindings, which provides
properties using the named fallback property query/enumerator. We need to
include those in Object::__hasProperty__, which is used to implement "if (foo in bar")

Change-Id: Ib30a9e9d90e0e2379e655f5282c269f1b5cceb8d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFirst step towards porting sequence wrappers to V4
Simon Hausmann [Tue, 14 May 2013 13:59:10 +0000 (15:59 +0200)]
First step towards porting sequence wrappers to V4

The idea is to wrap sequence container types such as QStringList or
QList<int> in a JS object that behaves like an array and also shares the
prototype.

The next step is to generalize the QStringList implementation to be re-usable
for the other sequence types.

This also required extending the object iterator with support for these
kind-of array types.

Change-Id: I5f0a14f904233944297708037c944964f1b74923
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix build of tst_qqmlecmascript
Simon Hausmann [Mon, 13 May 2013 14:59:40 +0000 (16:59 +0200)]
Fix build of tst_qqmlecmascript

Comment out v8 persistent and weak reference handling related bits and
tests. Otherwise this auto test contains a lot of stuff we need.

Change-Id: Ieafd9c8ea5200e5429d6354243ccaddba4f4772e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix invocation of QQmlV4Functions in JS/QML
Simon Hausmann [Mon, 13 May 2013 14:24:40 +0000 (16:24 +0200)]
Fix invocation of QQmlV4Functions in JS/QML

After the renaming of the class we also need to fix the two places where
we refer to the type by name.

Change-Id: I3c446cb31c2ecfc457f161f6b5cd7e30f44b2227
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix lookups for properties called "name" in QML
Simon Hausmann [Mon, 13 May 2013 13:11:20 +0000 (15:11 +0200)]
Fix lookups for properties called "name" in QML

We give the function prototype the property name == "Function". The QML
scope object is created using a function template with a fallback property
handler and we inject it as activation object. Therefore a lookup for "name"
will end up as property looking up in activation object before going to the
fallback handler. The lookup for "name" will then succeed through the prototype
chain and find the FunctionPrototype's name property.

There are different ways of fixing this, including the QML side or the v8
binding implementation. But let's not give the function prototype the name
property - it doesn't appear to make much sense.

Change-Id: Icfb7bed7ef3e663ccb5f5cb189f664934264a558
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix exception handling not working reliably on x86/x86-64 Linux (Part 2)
Simon Hausmann [Sun, 12 May 2013 10:07:15 +0000 (12:07 +0200)]
Fix exception handling not working reliably on x86/x86-64 Linux (Part 2)

The registration of the unwind tables is done through the interposition
of the _Unwind_Find_FDE symbol from libgcc. Unfortunately that interposition
breaks when libgcc happens to come first in the linker scope. As it turns
out, the order is not for us to control, therefore the interposition may not
always work and our JIT generated functions may not get their unwind information
found at exception throwing time. That results in the program aborting with
an uncaught exception.

The proposed solution of replacing the interposition approach is two-fold:

(1) Go back to calling __register_frame explicitly, but only for functions that
exception _may_ pass through. In addition the performance of scalability of the
objects registered with __register_frame is a known issue upstream, as the LLVM
JIT also triggers the issue. It is being tracked at
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56460

(2) Instead of registering one FDE per function, we can theoretically register
one FDE for _all_ JIT generate functions, because they all use the same stack
layout that has exactly the same unwinding requirements from any function call
site. Since we can't guarantee the presence of all JIT generated code within
the same contiguous memory area, we can at least do it per executable memory
allocation chunk (page size). One chunk can contain many functions.

This patch implements part (2) by moving the per-function unwind info straight
to into the executable memory chunk and registering the entire chunk (page)
with libgcc. This also separates the regexp JIT executable memory from regular
functions, because only for the memory of the latter we need to register unwind
info.

Change-Id: Ic4d1978686463c6d319436c9083e4d7cf0409829
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix exception handling not working reliably on x86/x86-64 Linux (Part 1)
Simon Hausmann [Sun, 12 May 2013 10:07:15 +0000 (12:07 +0200)]
Fix exception handling not working reliably on x86/x86-64 Linux (Part 1)

The registration of the unwind tables is done through the interposition
of the _Unwind_Find_FDE symbol from libgcc. Unfortunately that interposition
breaks when libgcc happens to come first in the linker scope. As it turns
out, the order is not for us to control, therefore the interposition may not
always work and our JIT generated functions may not get their unwind information
found at exception throwing time. That results in the program aborting with
an uncaught exception.

The proposed solution of replacing the interposition approach is two-fold:

(1) Go back to calling __register_frame explicitly, but only for functions that
exception _may_ pass through. In addition the performance of scalability of the
objects registered with __register_frame is a known issue upstream, as the LLVM
JIT also triggers the issue. It is being tracked at
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56460

(2) Instead of registering one FDE per function, we can theoretically register
one FDE for _all_ JIT generate functions, because they all use the same stack
layout that has exactly the same unwinding requirements from any function call
site. Since we can't guarantee the presence of all JIT generated code within
the same contiguous memory area, we can at least do it per executable memory
allocation chunk (page size). One chunk can contain many functions.

This patch implements part (1) by delaying the registration of the FDE to right
before the exception gets thrown and then walks up the context chain. The test
cases that were previously slowed down before commit
b83696f9896401dd5e99eed35e36628710e44eeb are not affected because the many
temporary "eval" functions are never subject to exceptions.

Change-Id: I7cb8262e3e1f27d6de71a1e42be8a538cba6513f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoKeep track of the currently code currently being run through eval()
Simon Hausmann [Mon, 13 May 2013 05:47:05 +0000 (07:47 +0200)]
Keep track of the currently code currently being run through eval()

We need to keep track of the possibly recursive eval calls for back trace
functionality in the future as well as changes to the exception handling.

Change-Id: Ie8a9343dfe43754fee48bab4b96b4ec2ab1fb67b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoRemove unused variable
Simon Hausmann [Mon, 13 May 2013 08:30:02 +0000 (10:30 +0200)]
Remove unused variable

Change-Id: I20a17d8d1af0027e4be17eb067c61204c41b0f7c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoClean up context initialization
Simon Hausmann [Mon, 13 May 2013 08:25:01 +0000 (10:25 +0200)]
Clean up context initialization

ExecutionContext and its subclasses have various members that are
initialized differently in different call sites. This makes it difficult
to add new members (must find all call sites).

This patch attempts to centralize the member initializations and changes the
usage pattern so that after object creation the corresponding init method needs
to be called before initializing any other members by hand.

Change-Id: I37ac8462ed894c8b234915e114ed032e12bda8bd
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdd missing pushContext/popContext in SimpleCallContext usage
Simon Hausmann [Mon, 13 May 2013 08:06:32 +0000 (10:06 +0200)]
Add missing pushContext/popContext in SimpleCallContext usage

Otherwise engine->current isn't set correctly, and that would cause issues
if for example method_getOwnPropertyNames in this case would throw an exception

Change-Id: I6f7f9cfec864a8f39e6968ce396237638c118475
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix uninitialized context type variable
Simon Hausmann [Mon, 13 May 2013 07:38:25 +0000 (09:38 +0200)]
Fix uninitialized context type variable

Uninitialized it may lead to incorrect casts if
somebody calls asCallContext() for example.

Change-Id: I12d28bc29567563da5b382f7bc294c394033cbf0
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix exports for functions used in inline methods.
Erik Verbruggen [Mon, 13 May 2013 06:53:43 +0000 (08:53 +0200)]
Fix exports for functions used in inline methods.

Change-Id: I69781c6d4697de570be9c0f91560d3bef2376625
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix QV4Engine::globalCode
Simon Hausmann [Sun, 12 May 2013 12:36:02 +0000 (14:36 +0200)]
Fix QV4Engine::globalCode

Gcc appears to optimize away the temporary assignment unless we give
the object a name ;(

Change-Id: I9c10a92ec32654fd690cfd74a0f3e0cbf363de4c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix crash when running some QML auto-tests
Simon Hausmann [Sun, 12 May 2013 13:00:48 +0000 (15:00 +0200)]
Fix crash when running some QML auto-tests

Engine identifiers are strings, which as Managed sub-classes have a pointer to
the internalClass. For strings we generally use engine->emptyClass. So before
creating any identifiers, engine->emptyClass must be initialized. Otherwise
putting any of the identifiers later into for example a QV4::PersistentValue
will cause crashes, because string->internalClass->engine will be an
uninitialized value.

Change-Id: I35a19a1701c5938b61f61e876d656e126a9b8e09
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoInitial port of JS canvas bindings to use QV4::Object subclass instead of V8 resources
Simon Hausmann [Fri, 10 May 2013 11:48:47 +0000 (13:48 +0200)]
Initial port of JS canvas bindings to use QV4::Object subclass instead of V8 resources

This patch comes with the same prototype injection as during the QML locale
patch. This will allow for incremental porting method by method for this huge
binding.

Change-Id: Ie258f021ac6f926302bb375a8ce7a12fb5e0512a
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix typo in internal API
Simon Hausmann [Fri, 10 May 2013 14:49:35 +0000 (16:49 +0200)]
Fix typo in internal API

Enumberable -> Enumerable :)

Change-Id: I12afbade4c68c5bf86c3b623a1862e82483db844
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoAdd rudimentary internal field support
Simon Hausmann [Fri, 10 May 2013 14:46:01 +0000 (16:46 +0200)]
Add rudimentary internal field support

This patch maps the internal field support somewhat hackishly through
the public JS properties by prefixing them with _internalfield_.

Internal fields are used in only a few places in QML, including the context2d
bindings, which I'm trying to port along with passing auto tests.

Change-Id: I5fe6cd7a825f437b9d5cccbee8da67336d82002c
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix running various QML auto-tests
Simon Hausmann [Fri, 10 May 2013 14:41:27 +0000 (16:41 +0200)]
Fix running various QML auto-tests

The QML QTestLib support relies on listing test functions by doing
for (prop in theQmlComponentToTest) and relies on that iteration to include
the list of test functions declared. QV8QObjectWrapper does not set own
properties for all those functions but instead relies on the fallback
property enumerator and query feature of the V8 API (a patch that is Qt
specific).

This patch implements basic support for iteration over these properties.

The API also has support for named property handlers and indexed property
handlers. The former's dynamic property support is not used in QML, however
dynamic indexed properties are used in the JS sequence wrappers and not
covered by this patch.

Change-Id: Ic9ad3ac55b3c1e0a774a62154f83734255fe594d
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoImprove error reporting
Simon Hausmann [Fri, 10 May 2013 12:57:12 +0000 (14:57 +0200)]
Improve error reporting

Implement TryCatch::GetMessage by means of converting the exception value to a string.
That often produces rather readable error messages.

Change-Id: I50b040ffae1db19b4c9d962b2759c7eae0ebcea1
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoRemove unused engine pointer in QQmlLocaleData
Simon Hausmann [Fri, 10 May 2013 11:21:26 +0000 (13:21 +0200)]
Remove unused engine pointer in QQmlLocaleData

As per the comment, this is unused now and can be removed :)

Change-Id: I74e26ee46755c6c4fcfc09fa4062690852f8b6cf
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix visibility of named function expressions in surrounding environment
Simon Hausmann [Fri, 10 May 2013 11:06:32 +0000 (13:06 +0200)]
Fix visibility of named function expressions in surrounding environment

Quoting from the spec: "However, unlike in a FunctionDeclaration, the
Identifier in a FunctionExpression cannot be referenced from and does not
affect the scope enclosing the FunctionExpression."

This was visible in QML start-up when evaluating helper functions: "(function
foo() { ...})" was compiled and run in the global scope and the returned
funtcion expression is executed later on. However we incorrectly also ended up
entering "foo" as a name into the global scope (which it was executed in),
causing then for example "foo" to become part of the "illegal" names in QML.

The case at point was that qv8sequencewrapper.cpp evaluates a helper script
with a named function expression "compare" and then later the QML canvas
auto-test failed because somewhere it declared a JS function in the scope
of a QML item called "compare".

All tests still pass, we do handle the case of looking up the named function
already in qv4context.cpp (getProperty, etc.).

Change-Id: Id9daaff355ce35ae4bc96dcbaba9710cd8cc2211
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix compilation of some qquick auto tests
Simon Hausmann [Fri, 10 May 2013 06:36:07 +0000 (08:36 +0200)]
Fix compilation of some qquick auto tests

Inline functions here use std::numeric_limits, so include the header
file.

Change-Id: Ib84f41b65ee965c3e0868f85643491feecceade5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoPort the of qml locale getters to V4 accessors
Simon Hausmann [Thu, 9 May 2013 12:36:32 +0000 (14:36 +0200)]
Port the of qml locale getters to V4 accessors

Added support for getters/setters to the class generator
as well as a simple help template for calling the member
function getters.

Change-Id: I3bb287a53d9f249837fa2c513d4886873476ad95
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix unsafe casting to target thisobject in class generator
Simon Hausmann [Wed, 8 May 2013 18:26:04 +0000 (20:26 +0200)]
Fix unsafe casting to target thisobject in class generator

We must also check if the asFoo() on the managed object succeeds
before calling the method.

Change-Id: I26ed56fec044b54221ca44e7789a2e9d0acec9ec
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoPorted over a few more locale functions
Simon Hausmann [Wed, 8 May 2013 18:11:34 +0000 (20:11 +0200)]
Ported over a few more locale functions

This code is becoming much simpler :)

Change-Id: Icd31bedd13f4a8fce145992b2a7706594ac809bf
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoBegin implement C++ style wrappers in QQmlLocale
Simon Hausmann [Wed, 8 May 2013 14:48:09 +0000 (16:48 +0200)]
Begin implement C++ style wrappers in QQmlLocale

The locale.currencySymbol function is converted into a member function
of the wrapper. For the time of the transition the prototype chain is
modified to be obj -> v8 proto template -> v4classgen generated proto

Change-Id: I72913e9d284a2a3678b23c7d7ce27fbb3447f1fb
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoCleanup v8 dependencies from QQmlV8Function
Lars Knoll [Wed, 8 May 2013 14:22:39 +0000 (16:22 +0200)]
Cleanup v8 dependencies from QQmlV8Function

... and rename it to QQmlV4Function

Change-Id: Iad72347babf62691e26306877d4f229fda127eb7
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove v8 dependencies from QQmlV4Handle
Lars Knoll [Wed, 8 May 2013 13:56:03 +0000 (15:56 +0200)]
Remove v8 dependencies from QQmlV4Handle

Change-Id: I87d2183738ec7cfeea846a28f2b9aed79a233f68
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoReplace V8 resource in QQmlLocale with managed subclass
Simon Hausmann [Wed, 8 May 2013 13:55:44 +0000 (15:55 +0200)]
Replace V8 resource in QQmlLocale with managed subclass

This is more lightweight and is the next step towards moving the
class binding away from V8.

Change-Id: Ic9c5901d3a6ef2f665ab22df9d2fcbb0698120eb
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoConverted remaining regular QQmlLocale functions to QV4
Simon Hausmann [Wed, 8 May 2013 07:21:57 +0000 (09:21 +0200)]
Converted remaining regular QQmlLocale functions to QV4

What remains are property accessors

Change-Id: Iadc5168b7759dfd6d4fc0e8f28e286ddd684bc7f
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoFix PersistentValue::isEmpty()
Lars Knoll [Wed, 8 May 2013 13:21:42 +0000 (15:21 +0200)]
Fix PersistentValue::isEmpty()

A PersistentValue can have a d pointer and still be
empty (because it contains an empty value).

This fixes an assertion when destructing the QML engine
and qmlscene finally doesn't crash on exit anymore :)

Change-Id: Idce2bb42f562526af8ec09d9062cce7ac825a8dc
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove the remaining traces of v8::persistent
Lars Knoll [Wed, 8 May 2013 13:04:25 +0000 (15:04 +0200)]
Remove the remaining traces of v8::persistent

Change-Id: Id542914c64558c1eba30a300cb10606fa499e594
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove v8::persistent usage from particles
Lars Knoll [Wed, 8 May 2013 12:36:48 +0000 (14:36 +0200)]
Remove v8::persistent usage from particles

Change-Id: I69cd4ccf51c40e2ee63f024a7ccc2d8b35b14ae4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove v8::persistent usage from local storage
Lars Knoll [Wed, 8 May 2013 12:30:24 +0000 (14:30 +0200)]
Remove v8::persistent usage from local storage

Change-Id: Ifda1ad5d4cfab86e9ced9e415d39ee392c676882
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove v8::Persistent usage from qquickcanvas
Lars Knoll [Wed, 8 May 2013 12:25:40 +0000 (14:25 +0200)]
Remove v8::Persistent usage from qquickcanvas

Change-Id: If714583818f894e8ac839cd35cd475deff00eafb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMove the QV4::Function out of qv4functionobject_p.h
Lars Knoll [Wed, 8 May 2013 12:24:30 +0000 (14:24 +0200)]
Move the QV4::Function out of qv4functionobject_p.h

QV4::Function has dependencies onto wtf. Moving it into it's
own header allows including qv4functionobject from other modules.

Change-Id: Ie6947085026a26ea250c232cc3b219737d009f5c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoRemove v8::Persistent usage from qquickloader
Lars Knoll [Wed, 8 May 2013 12:02:11 +0000 (14:02 +0200)]
Remove v8::Persistent usage from qquickloader

Change-Id: I0a7ffdc3ed159ec8f506cadc73ba8ae77c003a41
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAnother v8::Persistent removed
Lars Knoll [Wed, 8 May 2013 11:48:53 +0000 (13:48 +0200)]
Another v8::Persistent removed

Change-Id: I581f848730811aab7fbd36bb44ca9a71703c53d8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert qqmldelegatemodel to not use v8::Persistent
Lars Knoll [Wed, 8 May 2013 11:32:24 +0000 (13:32 +0200)]
Convert qqmldelegatemodel to not use v8::Persistent

Change-Id: I337aaa546f7fa93c829ad0f3c1f651347e93f8d4
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert qqmladaptermodel to use QV4::persistentValue
Lars Knoll [Wed, 8 May 2013 11:29:28 +0000 (13:29 +0200)]
Convert qqmladaptermodel to use QV4::persistentValue

Change-Id: I231c166d796c64fd8a50da54893383f5241ce81d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMove qqmlvmemetaobject over to use QV4::PersistentValue
Lars Knoll [Wed, 8 May 2013 11:16:20 +0000 (13:16 +0200)]
Move qqmlvmemetaobject over to use QV4::PersistentValue

Change-Id: Ifdf57d6cb266a7b63fec9f1f85bda8070c44036f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd more convenient get/put API to QV4::Object
Lars Knoll [Wed, 8 May 2013 11:14:40 +0000 (13:14 +0200)]
Add more convenient get/put API to QV4::Object

We can retrieve the current context from the Object
itself, so it's possible to offer a simplified
get/put API that doesn't require a context argument.

Clean up a circular include dependency between qv4engine
and qv4object.

Change-Id: I39a37d479ace1ffbfe8ac59b393cab8e4be07677
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert qqmllocale to use QV4::PersistentValue
Lars Knoll [Wed, 8 May 2013 10:33:22 +0000 (12:33 +0200)]
Convert qqmllocale to use QV4::PersistentValue

Change-Id: I9fd82f6f1d76d6ff8cbf0e7626fb32233c563ece
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert qqmljavascriptexpression to use QV4::PersistentValue
Lars Knoll [Wed, 8 May 2013 10:31:23 +0000 (12:31 +0200)]
Convert qqmljavascriptexpression to use QV4::PersistentValue

Change-Id: Idd704b55be61dd78c59fffdf966fc8497af852d6
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert qqmltypeloader to use QV4::PersistentValue
Lars Knoll [Wed, 8 May 2013 09:06:31 +0000 (11:06 +0200)]
Convert qqmltypeloader to use QV4::PersistentValue

Change-Id: Ifc4e2aea870a3a8ab37cd4d0674c672f0850f98f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoAdd flag to the engine to enable/disable RegExp JITting.
Erik Verbruggen [Tue, 7 May 2013 09:54:45 +0000 (11:54 +0200)]
Add flag to the engine to enable/disable RegExp JITting.

Change-Id: I4b632e6f8ab7cf20576f94764ed506de8be63efb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoMove QQuickworkerscript over to QV4::PersistentValue
Lars Knoll [Wed, 8 May 2013 05:17:45 +0000 (07:17 +0200)]
Move QQuickworkerscript over to QV4::PersistentValue

Change-Id: I6ff1d4942eac147a5bebd4a7be0774dabae91a04
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert xmlhttprequest to use QV4::PersistentValue
Lars Knoll [Wed, 8 May 2013 05:09:26 +0000 (07:09 +0200)]
Convert xmlhttprequest to use QV4::PersistentValue

Change-Id: I9001769225323f73cf8e50823d608dd0b5a52707
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoconvert qv8sequencewrapper to use QV4::PersistentValue
Lars Knoll [Wed, 8 May 2013 05:32:45 +0000 (07:32 +0200)]
convert qv8sequencewrapper to use QV4::PersistentValue

Change-Id: I211121a1cd389e7973ca1395e46c8f96f73d3a50
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert qv8qobjectwrapper to use QV4::PersistentValue
Lars Knoll [Wed, 8 May 2013 05:32:31 +0000 (07:32 +0200)]
Convert qv8qobjectwrapper to use QV4::PersistentValue

Change-Id: Iae8849fe105c242266ffc5e9b790d42ccd6d7955
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoconvert qv8variantwrapper to use QV4::PersistentValue
Lars Knoll [Wed, 8 May 2013 05:31:54 +0000 (07:31 +0200)]
convert qv8variantwrapper to use QV4::PersistentValue

Change-Id: Iccccc41a031e72b7ed7ac90bf022f5e1bdea3876
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert qv8Valuetypewrapper to use QV4::PersistentValue
Lars Knoll [Wed, 8 May 2013 05:31:36 +0000 (07:31 +0200)]
Convert qv8Valuetypewrapper to use QV4::PersistentValue

Change-Id: I175bd2d84425c5ae9497a5a3644474bee34e1a5b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert qv8typewrapper to use QV4::PersistentValue
Lars Knoll [Wed, 8 May 2013 05:31:24 +0000 (07:31 +0200)]
Convert qv8typewrapper to use QV4::PersistentValue

Change-Id: I6d33528fb5c7f2cd5eca1a742d6dcd217988e466
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert qv8listwrapper to use QV4::PersistentValue
Lars Knoll [Wed, 8 May 2013 05:31:04 +0000 (07:31 +0200)]
Convert qv8listwrapper to use QV4::PersistentValue

Change-Id: I1a85ae5ca0f4688174cda6127a326aed51f64b1b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert qv8include to QV4::PersistentValue
Lars Knoll [Wed, 8 May 2013 05:30:42 +0000 (07:30 +0200)]
Convert qv8include to QV4::PersistentValue

Change-Id: I9764ad7d28932bd67e3d284415c26f1b3b837056
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConvert context wrapper to QV4::PersistentValue
Lars Knoll [Wed, 8 May 2013 05:30:20 +0000 (07:30 +0200)]
Convert context wrapper to QV4::PersistentValue

Change-Id: Ied2ac64aacf92ebaa606e478f51505d97953e6c0
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix possible crash
Lars Knoll [Tue, 7 May 2013 15:53:46 +0000 (17:53 +0200)]
Fix possible crash

The m_instanceTemplate member in the v8::FunctionTemplate
can in some cases be uninitialized.

Change-Id: I6d827889b17dbd4b9d26df48173cbf02c64d76b1
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoFix the doubly linked list logic in QV4::PersistentValue
Lars Knoll [Wed, 8 May 2013 08:51:22 +0000 (10:51 +0200)]
Fix the doubly linked list logic in QV4::PersistentValue

The old code wasn't hooking the list up correctly, leading
to PersistentValues being garbage collected.

Change-Id: Id5613e35a3adb34181be9863cf1a7e994571241f
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoConverted the remaining locale extensions to Date and String protos to V4
Simon Hausmann [Tue, 7 May 2013 13:06:40 +0000 (15:06 +0200)]
Converted the remaining locale extensions to Date and String protos to V4

Change-Id: Iaf7de0fba8015a7de59aeeafd9ba76766945af48
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoRemove more v8::Persistent usages
Lars Knoll [Tue, 7 May 2013 10:29:30 +0000 (12:29 +0200)]
Remove more v8::Persistent usages

Change-Id: Ifa1706e2e609ded86a8bc1a840ca2ed36b869098
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
11 years agoGet rid of QV8Engine::qtDateTimeFromJsDate
Simon Hausmann [Tue, 7 May 2013 11:17:08 +0000 (13:17 +0200)]
Get rid of QV8Engine::qtDateTimeFromJsDate

Change-Id: I6a748ace761661ffe40e8fa73839f974e8a0afac
QV4::DateObject has a very convenient toQDateTime() function :)
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
11 years agoMake the default constructor of PersistentValue not allocate a d pointer
Lars Knoll [Tue, 7 May 2013 11:17:57 +0000 (13:17 +0200)]
Make the default constructor of PersistentValue not allocate a d pointer

This is also required to change the v8::Persistent in QQmlData over
to v4.

Change-Id: Ib3164ded9c772e977f6b43ef6163a3aa74da3800
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>