summaryrefslogtreecommitdiffstats
path: root/src/script/api/qscriptvalue.cpp
Commit message (Collapse)AuthorAgeFilesLines
* don't crash when attempting to access properties of a JS Object that ↵Kent Hansen2009-08-261-24/+23
| | | | | | | | | | | belonged to a deleted script engine When the engine is deleted, the JSValue is invalidated, but the QScriptValue's type will still be QScriptValuePrivate::JSC. Use a new helper function, isObject(), that checks both that the value is of type JSC _and_ that it is valid, before calling JSValue::isObject() (JSValue::isObject() assumes that the value is valid).
* fix performance issue with QScriptValue::propertyFlags()Kent Hansen2009-08-261-28/+37
| | | | | | | Calling QScriptEngine::toStringHandle() is dead slow, so don't call it; use JSC::Identifier directly. This is the same issue as was fixed for setProperty() in commit a8574172dd5e6bc11cf6f69b6fad5a063549e88d.
* fix performance issue with QScriptValue::setProperty()Kent Hansen2009-08-241-75/+81
| | | | | Calling QScriptEngine::toStringHandle() is dead slow, so don't call it; use JSC::Identifier() directly instead.
* add an internal QScriptValue ctor to initialize from d-pointerKent Hansen2009-08-241-0/+8
| | | | | Avoid having to create a dummy QScriptValue (which will have its d_ptr set to 0).
* make some internal qtscript functions inlineKent Hansen2009-08-241-53/+0
| | | | Make it faster.
* compile fix with namespaced Qthjk2009-08-241-2/+2
|
* pass engine pointer to QScriptValuePrivateKent Hansen2009-08-241-31/+17
| | | | Just a little cleanup.
* handle memory management of QScriptValuePrivate in engine if possibleKent Hansen2009-08-241-15/+31
| | | | | | | | | Avoid calling malloc() and free() so often. The premise is that QScriptValue is usually a short-lived type, and only a few QScriptValues exist at a time, so if we cache privates in the engine, QScriptValues will be much faster to create and destroy. Reviewed-by: Olivier Goffart
* avoid calling QScriptValue::isFunction() inside call() and construct()Kent Hansen2009-08-241-16/+26
| | | | | | | Avoid calling virtual function JSC::JSValue::get{Call,Construct}Data() twice. Reviewed-by: Olivier Goffart
* use QVarLengthArray instead of QVector for holding JS argumentsKent Hansen2009-08-241-4/+3
| | | | | | It's faster. Reviewed-by: Olivier Goffart
* QScriptValue: No need to create the activation object for call or constructOlivier Goffart2009-08-241-4/+0
| | | | It is uneeded and add useless overhead
* Fix obsolete license headers.Jason McDonald2009-08-211-1/+1
| | | | Reviewed-by: Trust Me
* compile again after mergeHarald Fernengel2009-08-211-33/+4
|
* implement registered script values as a doubly linked listKent Hansen2009-08-201-1/+1
| | | | It's faster.
* use a list to keep track of registered script valuesKent Hansen2009-08-201-36/+20
| | | | Get rid of the hash.
* store the engine's d-pointer in QScriptValuePrivateKent Hansen2009-08-201-117/+85
| | | | | It's the d-pointer that we most frequently want to access, so store it to avoid having to use QScriptEnginePrivate::get() all over the place.
* remove redundant variableKent Hansen2009-08-201-5/+2
|
* Fix QScriptValue::objectId().Jedrzej Nowacki2009-08-191-2/+2
| | | | | | | QScriptValue id were made persistent. It depands on JSC:JSValue JSCell pointer not on QScriptValuePrivate attr. Reviewed-by: Kent Hansen
* Clean upJedrzej Nowacki2009-08-191-1/+0
| | | | | | There is no point in setting class member in destructor Reviewed-by: Kent Hansen
* Internal API clean up.Jedrzej Nowacki2009-08-191-11/+0
| | | | | | Static method QScriptValue::initFromJSCValue was removed. Reviewed-by: Kent Hansen
* Clean up.Jedrzej Nowacki2009-08-191-32/+32
| | | | | | | | | Internal API of QScriptValue were cleaned. toPublic() was removed and replaced by standard static Private::get(). All initFromXXX() methods were replaced by overload call of initFrom(). Reviewed-by: Kent Hansen
* Clean up.Jedrzej Nowacki2009-08-181-11/+9
| | | | | | | Get rid of conversion functions QScript::qtStringFromJSCUString and QScript::qtStringToJSCUString. Code was moved to cast operators. Reviewed-by: Kent Hansen
* Fix compilation on WindowsSimon Hausmann2009-08-141-0/+1
| | | | | | In WebKit/JSC config.h needs to be included first in .cpp files, to among other things make sure that min/max are not defined as macros through windows.h.
* Lazily construct the QScriptActivationObjectOlivier Goffart2009-08-131-0/+5
| | | | | | | | | | | We can store flags on the ReturnValueRegister entry in the stackframe header (as native function don't use that) Then when requesting an activation object we can lookup the flags to know if we should create it. This reduce a lot the cost of a native call. Reviewed-by: Kent Hansen
* Make simple function getters inlineOlivier Goffart2009-08-121-5/+0
|
* Refactor the way the JS stack are created for native functionOlivier Goffart2009-08-121-1/+0
| | | | | | | | | | The original JavaScriptCore doesn't create stack frame or scope for native function. JSC has been patched to support that. This commit revert our patches to JSC, and implement create the stack frame from QScript Reviewed-by: Kent Hansen
* make property flags lookup work for properties in prototype chainKent Hansen2009-08-101-3/+7
| | | | | JSObject::getPropertyAttributes() does not follow the prototype chain, so we have to do it.
* make ResolveScope property lookup work (kind of)Kent Hansen2009-08-101-2/+9
| | | | | Look in the __qt_scope__ property that is set by QScriptValue::setScope().
* add configure options for (not) building the QtScript moduleKent Hansen2009-08-071-4/+0
| | | | | | | | | | | | | | | | | | -script (default) and -no-script. This means we can get rid of the SCRIPT feature from qfeatures, since it's now handled by the new configure variable. It also allows us to get rid of all the QT_NO_SCRIPT ifdefs from the source files, since qmake isn't going to include those files for compilation when you configure with -no-script. The QtScriptTools module will be disabled if the QtScript module is not built. You'll have to build the old QtScript back-end (will be made available in a separate package), then build the QtScriptTools module yourself. Reviewed-by: Simon Hausmann
* remove docs that mention QScriptValue::{scope,setScope}()Kent Hansen2009-08-061-2/+2
| | | | | | Those functions are internal and we don't want to support them in the JSC back-end, because they expose too much implementation detail of the old back-end.
* adapt to commit 014c4c63066fd3920594e6a58b02f314b5c88cdfKent Hansen2009-08-041-6/+6
|
* Unify QScriptValue::toObject() and QScriptEngine::toObject()Benjamin Poulain2009-08-031-19/+1
| | | | | | | QScriptValue::toObject() call QScriptEngine::toObject() so the code is not duplicated. Reviewed-by: Kent Hansen
* Move the declaration on some function into qscriptengine_p.hOlivier Goffart2009-07-311-7/+0
|
* Fix license headersOlivier Goffart2009-07-291-7/+37
|
* don't allow defining getter/setter for __proto__ propertyKent Hansen2009-07-281-4/+9
|
* make more tests pass for QScriptValue::setProperty()Kent Hansen2009-07-281-23/+53
| | | | | | JSC doesn't provide a way of un-defining a getter/setter. If deleting e.g. only the setter, we remember the getter, delete the property, then re-establish the getter.
* make QScriptEngine::setGlobalObject() work to some extentKent Hansen2009-07-271-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | JSC requires that the global object is actually a JSGlobalObject instance, whereas QScriptEngine::setGlobalObject() allows any object to be set as the global object. The way we solve this is by proxying from an internal global object to the custom (user-set) object. We need to take care that the internal global object is never actually exposed through our API; a brilliantly named helper function, toUsableValue(), makes that happen. Evaluating "var a = 10" with a custom global object doesn't work yet; the variable always ends up in the internal Global Object. For variable assignments, JSC appears to bypass the normal JSObject::put() and instead use JSGlobalObject::copyGlobals{From,To}(), which means I can't intercept and proxy the assignments. This commit enough to get the Context2D example working. There's another bug with iteration of the built-in Global Object's properties (non-enumerable properties are always skipped by the JSC C++ API, whereas with QScriptValueIterator they should not be), but that's a totally separate issue.
* don't rely on custom global object to get GC callbackKent Hansen2009-07-271-2/+2
| | | | | | | | | | | Install custom ClientData on JSGlobalData instance instead. Also some cleanups to avoid globalObject et al being accessed directly. Killed the proxying scheme employed in setGlobalObject() since it didn't work; if you stored the original Global Object and replaced it with another object, then added properties to the new object, they would show up in the old object, too (because the old object would always proxy to whatever the current Global Object was).
* Remove the uncaughtException, use the JSC exception insteadBenjamin Poulain2009-07-271-16/+7
| | | | | | | | | Use the exception from JSC::exec instead of QScriptEngin::uncaughtException. A few more tests are passing for qscriptvalue and qscriptqobject. Reviewed-by: Kent Hansen
* Clear the exceptions before calling a function.Olivier Goffart2009-07-241-4/+24
| | | | | | | | So the exception we get as result are the one thrown by the function. (fix tst_QScriptEngine::newRegExp test) Reviewed-by: Kent Hansen
* Implement QScriptString as a wraper around the JSC::IdentifierOlivier Goffart2009-07-231-64/+75
|
* make QScriptValue::{call,construct}() use JSC::{call,construct}()Kent Hansen2009-07-231-56/+4
| | | | | Support has been added to the JSC functions to support host functions as well, so now we can use them directly.
* More tests fixed (QScriptValue::toString)Olivier Goffart2009-07-221-0/+8
| | | | | | Handle Exception in a toString function Reviewed-by: Kent Hansen
* Fix the return value of a function call that throws an error.Ariya Hidayat2009-07-171-1/+3
|
* Fix the return value of a constructor that throws an error.Ariya Hidayat2009-07-171-1/+3
|
* implement cyclic prototype chain checkKent Hansen2009-07-171-1/+12
|
* make QScriptValue::toString() et al work when there's an exceptionKent Hansen2009-07-171-11/+75
| | | | | JSC refuses to call functions when there's an exception that hasn't been dealt with, so save the exception and restore it afterwards.
* We cant rely on property attributes from JavaScriptCore for the setter and ↵Olivier Goffart2009-07-161-3/+3
| | | | getter
* Convert the strings or number value to jscvalue when they are used with an ↵Olivier Goffart2009-07-161-12/+14
| | | | | | | engine Also change the stringValue not to be a pointer. This fixes a memory leak.
* don't try to be so cleverKent Hansen2009-07-151-7/+4
| | | | | | If we implement the ability to change the global object, the global object pointer can change, so we need to keep a reference to the object if it's stored in a QScriptValue.