summaryrefslogtreecommitdiffstats
path: root/src/script/api/qscriptengine.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix a compilation warning.Jedrzej Nowacki2011-05-041-2/+2
| | | | | | | QString::QString(const char* ) is deprecated static QString::fromXXX function should be used instead. Reviewed-by: Gabriel de Dietrich
* Implement qScriptConnect(), qScriptDisconnect()Gabriel de Dietrich2011-04-281-12/+76
| | | | | | | | | | | These functions are currently being used by QDeclarative. Needed for tst_qdeclarativeecmascript. The semantics are stricter than what the documentation suggests. When calling qScriptDisconnect(), the connection must have been be made with qScriptConnect(). Reviewed-by: Olivier
* Performance fix, QSV::call is now ~25% faster.Jedrzej Nowacki2011-03-241-0/+6
| | | | | | | | | | Cache the current global object handle. That value should not change often, but it is used in several places (for example function call). The main optimization consists on avoiding calling v8::Object::GetPrototype inside QSEP::globalObject. Reviewed-by: Kent Hansen
* Small performance optimizationJedrzej Nowacki2011-03-241-1/+1
| | | | | | Avoid calling QSEP::globalObject twice in QSEP::setGlobalObject method. Reviewed-by: TrustMe
* Refer to upstream V8 bug in FIXME commentKent Hansen2011-03-161-2/+1
| | | | | | | This was indeed a bug in V8 which has now been reported. We use the workaround for now, even though it badly hurts performance (it can be improved by caching the "length" string in the engine, though).
* Implement QScriptEngine::reportAdditionalMemory.Jedrzej Nowacki2011-03-111-0/+11
|
* Create a mapping between QScriptEnginePrivate and v8::Isolate.Jedrzej Nowacki2011-03-111-2/+14
| | | | | | | | | The mapping is needed in callbacks that do not allow to pass user data. The way it is implemented is a bit expensive (it have to be thread safe), but I hope it is temporary solution until the v8 bug is not fixed. http://code.google.com/p/v8/issues/detail?id=1205
* Put property handler binding in the right placeGabriel de Dietrich2011-03-101-4/+0
| | | | Reviewed-by: Olivier
* Support for QScriptEngine::AutoCreateDynamicPropertiesGabriel de Dietrich2011-03-071-0/+4
| | | | | | | | And make parts of tst_QScriptExtQObject::wrapOptions() pass as well as other XFAIL related to hasOwnProperty() not being implemented for QObject. Reviewed-by: Jedrzej Nowacki
* Handle throwing exception when converting argumentsOlivier Goffart2011-03-031-5/+7
| | | | Fixes tst_QScriptExtQObject::callQtInvokable6
* Partial fix for tst_QScriptExtQObject::getSetChildrenOlivier Goffart2011-03-021-12/+0
| | | | | Implement the way to get child object. But we still do not remove them.
* QScriptContext: identify explicity the kinds of contextsCaio Marcelo de Oliveira Filho2011-03-011-2/+2
| | | | | | | | | There are five different kinds of QScriptContext(Private) implementations, for different purposes. This commit adds inline functions to identify them according the invariants that each one has, with the intetion of making things more readable. Reviewed-by: Olivier Goffart
* Fix logic in QScriptEnginePrivate::newQObject()Gabriel de Dietrich2011-02-281-1/+1
| | | | Reviewed-by: Olivier
* Revert "Fix tst_QScriptExtQObject::getSetStaticProperty_methodPersistence"Olivier Goffart2011-02-281-2/+2
| | | | | | | | | | This reverts commit a9eac675b1b44ce0db50614c831ae991725dabdf. It break some garbage collection tests. Also moving deallocateAdditionalResources is not a good idea, since We remove the internal pointers of stuff that still could be garbage collected.
* Make tst_QScriptExtQObject::enumerateMetaObject() passGabriel de Dietrich2011-02-251-1/+1
| | | | | | The v8 template for QMetaObject lacked a NamedPropertyEnumerator. Reviewed-by: Olivier Goffart
* Fix tst_QScriptExtQObject::getSetStaticProperty_methodPersistenceOlivier Goffart2011-02-241-2/+2
| | | | | | | | We keep the values of the metamethod we created already. deallocateAdditionalResources is moved up because it needs to be called before the Isolate is exited (as it will result on some object being destroyed, hence out metaMethod hash to be cleaned)
* First attempt to implement QSEAP push and pop context callbacks.Jedrzej Nowacki2011-02-231-0/+4
|
* Support QScriptEngine::QObjectWrapOptions in newObjectOlivier Goffart2011-02-231-13/+17
| | | | Fixes tst_QScriptExtQObject::enumerate
* QScript QObject binding refactoringOlivier Goffart2011-02-231-9/+9
| | | | Better naming, and less indirections
* Fix getSetStaticProperty_changeInJSOlivier Goffart2011-02-221-4/+0
| | | | | | Passing a string variant to QMetaProperty::write if the property is an integer would not change the property. But QtScript expect that a conversion is made anyway ("ciao"->0)
* QScriptExtensionPlugin: do not unload plugins!Caio Marcelo de Oliveira Filho2011-02-211-1/+3
| | | | | | | | | | | | | | | | | | | | | This reverts 31483b3f73567944aefecac35bff97e8092d320a. While it was correct in the sense that we were really leaking, the plugins, in practice for now we want to keep them this way. Olivier pointed out some facts - It's hard to make QPluginLoader actually support the feature 'unload plugins during termination'; - Some plugins do not support being unloaded at all, and current QtScript support them; - InvalidValue() implementation should be different and will avoid this issue. For reference, the issue with QPluginLoader is at http://bugreports.qt.nokia.com/browse/QTBUG-17458
* avoid useless strings conversionOlivier Goffart2011-02-211-2/+2
|
* QScriptClass: implement support for name()Caio Marcelo de Oliveira Filho2011-02-181-0/+8
| | | | | | | | | | | | | | | | | | When intercepting getter calls for objects made by a QScriptClass, if there isn't an existing "toString", we return our default implementation: a function that returns name(). Since we are intercepting before the prototype() can "say" something, we need to check if it has its own "toString", if so, we don't give the default one. We don't want to use Object default toString implementation, that's why we get the "own property" of the prototype. This also excludes other possible cases where user sets the toString of the prototype of a prototype, but this seems to be a rare case. We can support later if needed. Reviewed-by: Olivier Goffart
* Use EvaluateScope in QScriptValue::callOlivier Goffart2011-02-171-14/+20
| | | | | | and construct. And now, EvaluateScope works with embedded calls.
* Make QScriptEnginePrivate inherit from QScriptObjectPrivateOlivier Goffart2011-02-161-24/+25
| | | | | This is how it worked before, and cannot be changed without breaking binary compatibility
* Fixes tst_QScriptClass::scriptClassWithNullEngineOlivier Goffart2011-02-161-1/+1
|
* QScriptExtensionPlugin: fix crash when exiting autotestCaio Marcelo de Oliveira Filho2011-02-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | The issue was caused by our InvalidValue() (created with QScriptValue()) leaking some references. In my system this was caused by two things acting together - Plugins were not being unloaded properly, so their destructors were not called; - Kross::EcmaPlugin when instantiated, created some QScriptValues in its Private object. This commit changes availableExtensions() to unload the plugins loaded, since we only want to get the keys. This avoids the issue for our tests. However the problem remains, if we add a simple QScriptValue member to our test plugins, it will still break, because for importExtension, we rely on the plugins being destroyed when application terminates, but they are not, so InvalidValue() leaks again. I've created a bug to investigate the issue with not destroying plugins during termination: http://bugreports.qt.nokia.com/browse/QTBUG-17458
* Implements QScriptEngine::abortEvaluationOlivier Goffart2011-02-151-4/+20
|
* Implements QScriptEngine::setProcessEventIntervalOlivier Goffart2011-02-151-8/+73
| | | | There is a thread that is timing out and will ask for the callback.
* Fix tst_qscriptcontext::throwValueInGlobalContext.Jedrzej Nowacki2011-02-101-1/+0
| | | | | | This patch fix a regression in equals, strictlyEquals and lessThan. These functions internally call QSEP::evaluate which clear exceptions as a side effect.
* Implement QScriptEngineAgent callbacks.Jedrzej Nowacki2011-02-091-1/+8
| | | | | | | | | Callbacks scriptLoad and scriptUnload were fully implemented. There is a behavior change, in V8 port unload event is triggered only if a script is garbage collected. It means that load / unload may be asymmetric and that all agents are disconnected from engine before all scripts are unloaded.
* QScriptEngine: fix property flags for native functionsCaio Marcelo de Oliveira Filho2011-02-091-2/+2
| | | | | | | | | Fix the tests and implementation to conform with ECMA-262, property "prototype" of the function and "constructor" of the prototype object associated with the function. This makes more tests pass since V8 did the right thing in situations that we were expecting the wrong.
* QScriptEngine::setGlobalObject set the prototypeOlivier Goffart2011-02-091-132/+4
| | | | | | | | | | | setGlobalObject will actually set the prototype of the global object The reason we do that is that if we set an interceptor, all the properteis will be intercepted. But we have to work around the fact that for v8, the real global object is the prototype of the global object. So we use the prototype of the global object everywhere.
* Massive includes cleanup.Jedrzej Nowacki2011-02-011-7/+1
| | | | | | | | | It was really difficult to find correct includes dependency in *.cpp files because of all forward declarations. This patch creates a container file (for *_impl_p.h) files that can be included instead. In the same time I was able to get rid of implementation details from private headers.
* Implement QSE::setAgent and QSE::agentJedrzej Nowacki2011-02-011-4/+12
| | | | This agent doesn't do anything but at least it pass ownership tests.
* Build fix.Jedrzej Nowacki2011-01-281-0/+2577
| | | | | Problem of v8 linking is solved now. These is not the perfect solution but it works. CI gate probably would be operational after that patch.
* Say goodbye to QtScript/JSC, say hello to the beginnings of QtScript/V8Kent Hansen2010-09-031-4438/+0
|
* doc: Remove \internal tag from QScriptProgramKent Hansen2010-08-311-2/+1
| | | | | | | | The class has been there since 4.6 (http://labs.trolltech.com/blogs/2009/11/23/qtscript-in-46/), but we don't see a reason to hide it any longer. Task-number: QTBUG-13229 Reviewed-by: Olivier Goffart
* Make qsTrId() / QT_TRID_NOOP() accessible from QtScriptKent Hansen2010-08-231-0/+28
| | | | | | | | | QScriptEngine::installTranslatorFunctions() now installs wrapper functions for qsTrId and QT_TRID_NOOP (similar to the existing ones for tr() and translate()). Task-number: QTBUG-8454 Reviewed-by: Jedrzej Nowacki
* QScript: remove JSC::JSLockOlivier Goffart2010-07-291-4/+0
| | | | | | They are useless and cause warnings in the code. Reviewed-by: Kent Hansen
* QScript: document/obsolete things that does not work since the move to JSCOlivier Goffart2010-07-291-7/+4
| | | | Reviewed-by: Kent Hansen
* QScriptEngineAgent: recompile all the function when installing a debugger.Olivier Goffart2010-07-271-0/+1
| | | | | | | | | | | | | | Recompile all the function is necessary to ger the debug opcode that notifies us when the position changes. The change in CollectorHeapIterator.h is nessesary to get it work as Debugger::recompileAllJSFunctions uses LiveObjectIterator, LiveObjectIterator initialied m_cell to -1 and to ++(*this) in its constructor. But as m_cell is of type size_t (unsigned) then the < comparison will always fail as it is an unsigned comparison. This was already fixed upstream in r54672 Reviewed-by: Jedrzej Nowacki
* Fix conversion between JavaScript Date and QDateTimeKent Hansen2010-06-251-0/+47
| | | | | | | | | | Use JavaScriptCore's conversion functions rather than our own (incomplete) implementation. Specifically, this means daylight saving time is finally handled correctly on Windows. Task-number: QTBUG-9770 Reviewed-by: Olivier Goffart
* Use custom static scopes to improve QML/JavaScript performanceKent Hansen2010-06-251-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces a new internal JS object type, QScriptStaticScopeObject, that enables the JS compiler to make more aggressive optimizations of scoped property access. QScriptStaticScopeObject registers all its properties in a symbol table that the JS compiler has access to. If the compiler finds the property in the symbol table, it will generate the fast index-based op_{get,put}_scoped_var bytecodes, rather than the dynamic (slow) op_resolve and friends. If the compiler _doesn't_ find the property in the symbol table, it infers that it's safe to skip the scope object when later resolving the property, which will also improve performance (see op_resolve_skip bytecode). QScriptStaticScopeObject is only safe to use when all relevant properties are known at JS compile time; that is, when a function that has the static scope object in its scope chain is compiled. It's up to the user of the class (e.g. QtDeclarative) to ensure that this constraint is not violated. The API for constructing QScriptStaticScopeObject instances is not public; it lives in QScriptDeclarativeClass for now, an internal class exported for the purpose of QML. The instance is returned as a QScriptValue and can be manipulated like any other JS object (e.g. by QScriptValue::setProperty()). The other part of this commit utilizes QScriptStaticScopeObject in QtDeclarative in the two major places where it's currently possible: 1) QML disallows adding properties to the Global Object. Furthermore, it's not possible for QML IDs and properties to "shadow" global variables. Hence, a QScriptStaticScopeObject can be used to hold all the standard ECMA properties, and this scope object can come _before_ the QML component in the scope chain. This enables binding expressions and scripts to have optimized (direct) access to e.g. Math.sin. 2) Imported scripts can have their properties (resulting from variable declarations ("var" statements) and function declarations) added to a static scope object. This enables functions in the script to have optimized (direct) access to the script's own properties, as well as to global properties such as Math. With this change, it's no longer possible to delete properties of the Global Object, nor delete properties of an imported script. It's a compromise we make in order to make the optimization safe. Task-number: QTBUG-8576 Reviewed-by: Aaron Kennedy Reviewed-by: Olivier Goffart Reviewed-by: Jedrzej Nowacki
* Usefully convert from QtScript object/array to QVariantKent Hansen2010-06-171-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* 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-171-1/+13
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-151-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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