Remove QJSValue::toInt32() and toUInt32() functions
[profile/ivi/qtdeclarative.git] / src / declarative / qml / v8 / qjsvalue.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtScript module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL-ONLY$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser
11 ** General Public License version 2.1 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.LGPL included in the
13 ** packaging of this file.  Please review the following information to
14 ** ensure the GNU Lesser General Public License version 2.1 requirements
15 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** If you have questions regarding the use of this file, please contact
18 ** us via http://www.qt-project.org/.
19 **
20 ** $QT_END_LICENSE$
21 **
22 ****************************************************************************/
23
24 #include "qscriptisolate_p.h"
25 #include "qjsengine.h"
26 #include "qv8engine_p.h"
27 #include "qjsvalue.h"
28 #include "qjsvalue_p.h"
29 #include "qscript_impl_p.h"
30 #include "qscriptshareddata_p.h"
31 #include <QtCore/qstring.h>
32
33 /*!
34   \since 5.0
35   \class QJSValue
36
37   \brief The QJSValue class acts as a container for Qt/JavaScript data types.
38
39   \ingroup qtjavascript
40   \mainclass
41
42   QJSValue supports the types defined in the \l{ECMA-262}
43   standard: The primitive types, which are Undefined, Null, Boolean,
44   Number, and String; and the Object type. Additionally, built-in
45   support is provided for Qt/C++ types such as QVariant and QObject.
46
47   For the object-based types (including Date and RegExp), use the
48   newT() functions in QJSEngine (e.g. QJSEngine::newObject())
49   to create a QJSValue of the desired type. For the primitive types,
50   use one of the QJSValue constructor overloads.
51
52   The methods named isT() (e.g. isBool(), isUndefined()) can be
53   used to test if a value is of a certain type. The methods named
54   toT() (e.g. toBool(), toString()) can be used to convert a
55   QJSValue to another type. You can also use the generic
56   QJSValue_cast() function.
57
58   Object values have zero or more properties which are themselves
59   QJSValues. Use setProperty() to set a property of an object, and
60   call property() to retrieve the value of a property.
61
62   \snippet doc/src/snippets/code/src_script_qjsvalue.cpp 0
63
64   If you want to iterate over the properties of a script object, use
65   the QJSValueIterator class.
66
67   Object values have an internal \c{prototype} property, which can be
68   accessed with prototype() and setPrototype().
69
70   Function objects (objects for which isCallable()) returns true) can
71   be invoked by calling call(). Constructor functions can be used to
72   construct new objects by calling callAsConstructor().
73
74   Use equals() or strictlyEquals() to compare a QJSValue to another.
75
76   Note that a QJSValue for which isObject() is true only carries a
77   reference to an actual object; copying the QJSValue will only
78   copy the object reference, not the object itself. If you want to
79   clone an object (i.e. copy an object's properties to another
80   object), you can do so with the help of a \c{for-in} statement in
81   script code, or QJSValueIterator in C++.
82
83   \sa QJSEngine, QJSValueIterator
84 */
85
86 /*!
87     \enum QJSValue::SpecialValue
88
89     This enum is used to specify a single-valued type.
90
91     \value UndefinedValue An undefined value.
92
93     \value NullValue A null value.
94 */
95
96 QT_BEGIN_NAMESPACE
97
98 /*!
99   Constructs a new QJSValue with a boolean \a value.
100 */
101 QJSValue::QJSValue(bool value)
102     : d_ptr(new QJSValuePrivate(value))
103 {
104 }
105
106 /*!
107   Constructs a new QJSValue with a number \a value.
108 */
109 QJSValue::QJSValue(int value)
110     : d_ptr(new QJSValuePrivate(value))
111 {
112 }
113
114 /*!
115   Constructs a new QJSValue with a number \a value.
116 */
117 QJSValue::QJSValue(uint value)
118     : d_ptr(new QJSValuePrivate(value))
119 {
120 }
121
122 /*!
123   Constructs a new QJSValue with a number \a value.
124 */
125 QJSValue::QJSValue(double value)
126     : d_ptr(new QJSValuePrivate(value))
127 {
128 }
129
130 /*!
131   Constructs a new QJSValue with a string \a value.
132 */
133 QJSValue::QJSValue(const QString& value)
134     : d_ptr(new QJSValuePrivate(value))
135 {
136 }
137
138 /*!
139   Constructs a new QJSValue with a special \a value.
140 */
141 QJSValue::QJSValue(SpecialValue value)
142     : d_ptr(new QJSValuePrivate(value))
143 {
144 }
145
146 /*!
147   Constructs a new QJSValue with a string \a value.
148 */
149 QJSValue::QJSValue(const QLatin1String &value)
150     : d_ptr(new QJSValuePrivate(value))
151 {
152 }
153
154 /*!
155   Constructs a new QJSValue with a string \a value.
156 */
157 #ifndef QT_NO_CAST_FROM_ASCII
158 QJSValue::QJSValue(const char *value)
159     : d_ptr(new QJSValuePrivate(QString::fromAscii(value)))
160 {
161 }
162 #endif
163
164 /*!
165     Block automatic convertion to bool
166     \internal
167 */
168 QJSValue::QJSValue(void* d)
169 {
170     Q_UNUSED(d);
171     Q_ASSERT(false);
172 }
173
174 /*!
175     Constructs a new QJSValue from private
176     \internal
177 */
178 QJSValue::QJSValue(QJSValuePrivate* d)
179     : d_ptr(d)
180 {
181 }
182
183 /*!
184     Constructs a new QJSValue from private
185     \internal
186 */
187 QJSValue::QJSValue(QScriptPassPointer<QJSValuePrivate> d)
188     : d_ptr(d.give())
189 {
190 }
191
192 /*!
193   Constructs a new QJSValue that is a copy of \a other.
194
195   Note that if \a other is an object (i.e., isObject() would return
196   true), then only a reference to the underlying object is copied into
197   the new script value (i.e., the object itself is not copied).
198 */
199 QJSValue::QJSValue(const QJSValue& other)
200     : d_ptr(other.d_ptr)
201 {
202 }
203
204 /*!
205     Destroys this QJSValue.
206 */
207 QJSValue::~QJSValue()
208 {
209 }
210
211 /*!
212   Returns true if this QJSValue is of the primitive type Boolean;
213   otherwise returns false.
214
215   \sa toBool()
216 */
217 bool QJSValue::isBool() const
218 {
219     Q_D(const QJSValue);
220     QScriptIsolate api(d->engine());
221     return d->isBool();
222 }
223
224 /*!
225   Returns true if this QJSValue is of the primitive type Number;
226   otherwise returns false.
227
228   \sa toNumber()
229 */
230 bool QJSValue::isNumber() const
231 {
232     Q_D(const QJSValue);
233     QScriptIsolate api(d->engine());
234     return d->isNumber();
235 }
236
237 /*!
238   Returns true if this QJSValue is of the primitive type Null;
239   otherwise returns false.
240 */
241 bool QJSValue::isNull() const
242 {
243     Q_D(const QJSValue);
244     QScriptIsolate api(d->engine());
245     return d->isNull();
246 }
247
248 /*!
249   Returns true if this QJSValue is of the primitive type String;
250   otherwise returns false.
251
252   \sa toString()
253 */
254 bool QJSValue::isString() const
255 {
256     Q_D(const QJSValue);
257     QScriptIsolate api(d->engine());
258     return d->isString();
259 }
260
261 /*!
262   Returns true if this QJSValue is of the primitive type Undefined;
263   otherwise returns false.
264
265   \sa QJSEngine::undefinedValue()
266 */
267 bool QJSValue::isUndefined() const
268 {
269     Q_D(const QJSValue);
270     QScriptIsolate api(d->engine());
271     return d->isUndefined();
272 }
273
274 /*!
275   Returns true if this QJSValue is an object of the Error class;
276   otherwise returns false.
277 */
278 bool QJSValue::isError() const
279 {
280     Q_D(const QJSValue);
281     QScriptIsolate api(d->engine());
282     return d->isError();
283 }
284
285 /*!
286   Returns true if this QJSValue is an object of the Array class;
287   otherwise returns false.
288
289   \sa QJSEngine::newArray()
290 */
291 bool QJSValue::isArray() const
292 {
293     Q_D(const QJSValue);
294     QScriptIsolate api(d->engine());
295     return d->isArray();
296  }
297
298 /*!
299   Returns true if this QJSValue is of the Object type; otherwise
300   returns false.
301
302   Note that function values, variant values, and QObject values are
303   objects, so this function returns true for such values.
304
305   \sa QJSEngine::newObject()
306 */
307 bool QJSValue::isObject() const
308 {
309     Q_D(const QJSValue);
310     QScriptIsolate api(d->engine());
311     return d->isObject();
312 }
313
314 /*!
315   Returns true if this QJSValue can be called a function, otherwise
316   returns false.
317
318   \sa call()
319 */
320 bool QJSValue::isCallable() const
321 {
322     Q_D(const QJSValue);
323     QScriptIsolate api(d->engine());
324     return d->isCallable();
325 }
326
327 #ifdef QT_DEPRECATED
328
329 /*!
330   \obsolete
331
332   Use isCallable() instead.
333 */
334 bool QJSValue::isFunction() const
335 {
336     Q_D(const QJSValue);
337     QScriptIsolate api(d->engine());
338     return d->isCallable();
339 }
340
341 #endif // QT_DEPRECATED
342
343 /*!
344   Returns true if this QJSValue is a variant value;
345   otherwise returns false.
346
347   \sa toVariant()
348 */
349 bool QJSValue::isVariant() const
350 {
351     Q_D(const QJSValue);
352     QScriptIsolate api(d->engine());
353     return d->isVariant();
354 }
355
356 /*!
357   Returns the string value of this QJSValue, as defined in
358   \l{ECMA-262} section 9.8, "ToString".
359
360   Note that if this QJSValue is an object, calling this function
361   has side effects on the script engine, since the engine will call
362   the object's toString() function (and possibly valueOf()) in an
363   attempt to convert the object to a primitive value (possibly
364   resulting in an uncaught script exception).
365
366   \sa isString()
367 */
368 QString QJSValue::toString() const
369 {
370     Q_D(const QJSValue);
371     QScriptIsolate api(d->engine());
372     return d->toString();
373 }
374
375 /*!
376   Returns the number value of this QJSValue, as defined in
377   \l{ECMA-262} section 9.3, "ToNumber".
378
379   Note that if this QJSValue is an object, calling this function
380   has side effects on the script engine, since the engine will call
381   the object's valueOf() function (and possibly toString()) in an
382   attempt to convert the object to a primitive value (possibly
383   resulting in an uncaught script exception).
384
385   \sa isNumber(), toInt(), toUInt()
386 */
387 double QJSValue::toNumber() const
388 {
389     Q_D(const QJSValue);
390     QScriptIsolate api(d->engine());
391     return d->toNumber();
392 }
393
394 /*!
395   Returns the boolean value of this QJSValue, using the conversion
396   rules described in \l{ECMA-262} section 9.2, "ToBoolean".
397
398   Note that if this QJSValue is an object, calling this function
399   has side effects on the script engine, since the engine will call
400   the object's valueOf() function (and possibly toString()) in an
401   attempt to convert the object to a primitive value (possibly
402   resulting in an uncaught script exception).
403
404   \sa isBool()
405 */
406 bool QJSValue::toBool() const
407 {
408     Q_D(const QJSValue);
409     QScriptIsolate api(d->engine());
410     return d->toBool();
411 }
412
413 /*!
414   Returns the signed 32-bit integer value of this QJSValue, using
415   the conversion rules described in \l{ECMA-262} section 9.5, "ToInt32".
416
417   Note that if this QJSValue is an object, calling this function
418   has side effects on the script engine, since the engine will call
419   the object's valueOf() function (and possibly toString()) in an
420   attempt to convert the object to a primitive value (possibly
421   resulting in an uncaught script exception).
422
423   \sa toNumber(), toUInt()
424 */
425 qint32 QJSValue::toInt() const
426 {
427     Q_D(const QJSValue);
428     QScriptIsolate api(d->engine());
429     return d->toInt32();
430 }
431
432 /*!
433   Returns the unsigned 32-bit integer value of this QJSValue, using
434   the conversion rules described in \l{ECMA-262} section 9.6, "ToUint32".
435
436   Note that if this QJSValue is an object, calling this function
437   has side effects on the script engine, since the engine will call
438   the object's valueOf() function (and possibly toString()) in an
439   attempt to convert the object to a primitive value (possibly
440   resulting in an uncaught script exception).
441
442   \sa toNumber(), toInt()
443 */
444 quint32 QJSValue::toUInt() const
445 {
446     Q_D(const QJSValue);
447     QScriptIsolate api(d->engine());
448     return d->toUInt32();
449 }
450
451 /*!
452   Returns the QVariant value of this QJSValue, if it can be
453   converted to a QVariant; otherwise returns an invalid QVariant.
454   The conversion is performed according to the following table:
455
456     \table
457     \header \o Input Type \o Result
458     \row    \o Undefined  \o An invalid QVariant.
459     \row    \o Null       \o An invalid QVariant.
460     \row    \o Boolean    \o A QVariant containing the value of the boolean.
461     \row    \o Number     \o A QVariant containing the value of the number.
462     \row    \o String     \o A QVariant containing the value of the string.
463     \row    \o QVariant Object \o The result is the QVariant value of the object (no conversion).
464     \row    \o QObject Object \o A QVariant containing a pointer to the QObject.
465     \row    \o Date Object \o A QVariant containing the date value (toDateTime()).
466     \row    \o RegExp Object \o A QVariant containing the regular expression value.
467     \row    \o Array Object \o The array is converted to a QVariantList. Each element is converted to a QVariant, recursively; cyclic references are not followed.
468     \row    \o Object     \o The object is converted to a QVariantMap. Each property is converted to a QVariant, recursively; cyclic references are not followed.
469     \endtable
470
471   \sa isVariant()
472 */
473 QVariant QJSValue::toVariant() const
474 {
475     Q_D(const QJSValue);
476     QScriptIsolate api(d->engine());
477     return d->toVariant();
478 }
479
480 /*!
481   Calls this QJSValue as a function, passing \a args as arguments
482   to the function, and using the globalObject() as the "this"-object.
483   Returns the value returned from the function.
484
485   If this QJSValue is not callable, call() does nothing and
486   returns an undefined QJSValue.
487
488   Calling call() can cause an exception to occur in the script engine;
489   in that case, call() returns the value that was thrown (typically an
490   \c{Error} object). You can call
491   QJSEngine::hasUncaughtException() to determine if an exception
492   occurred.
493
494   \sa isCallable(), callWithInstance(), callAsConstructor()
495 */
496 QJSValue QJSValue::call(const QJSValueList &args)
497 {
498     Q_D(QJSValue);
499     QScriptIsolate api(d->engine());
500     return d->call(/*thisObject=*/0, args);
501 }
502
503 /*!
504   Calls this QJSValue as a function, using \a instance as
505   the `this' object in the function call, and passing \a args
506   as arguments to the function. Returns the value returned from
507   the function.
508
509   If this QJSValue is not a function, call() does nothing
510   and returns an undefined QJSValue.
511
512   Note that if \a instance is not an object, the global object
513   (see \l{QJSEngine::globalObject()}) will be used as the
514   `this' object.
515
516   Calling call() can cause an exception to occur in the script engine;
517   in that case, call() returns the value that was thrown (typically an
518   \c{Error} object). You can call
519   QJSEngine::hasUncaughtException() to determine if an exception
520   occurred.
521
522   \sa call()
523 */
524 QJSValue QJSValue::callWithInstance(const QJSValue &instance, const QJSValueList &args)
525 {
526     Q_D(QJSValue);
527     QScriptIsolate api(d->engine());
528     return d->call(QJSValuePrivate::get(instance), args);
529 }
530
531 /*!
532   Creates a new \c{Object} and calls this QJSValue as a
533   constructor, using the created object as the `this' object and
534   passing \a args as arguments. If the return value from the
535   constructor call is an object, then that object is returned;
536   otherwise the default constructed object is returned.
537
538   If this QJSValue is not a function, callAsConstructor() does
539   nothing and returns an undefined QJSValue.
540
541   Calling this function can cause an exception to occur in the
542   script engine; in that case, the value that was thrown
543   (typically an \c{Error} object) is returned. You can call
544   QJSEngine::hasUncaughtException() to determine if an exception
545   occurred.
546
547   \sa call(), QJSEngine::newObject()
548 */
549 QJSValue QJSValue::callAsConstructor(const QJSValueList &args)
550 {
551     Q_D(QJSValue);
552     QScriptIsolate api(d->engine());
553     return QJSValuePrivate::get(d->callAsConstructor(args));
554 }
555
556 #ifdef QT_DEPRECATED
557
558 /*!
559   \obsolete
560
561   Use callWithInstance() instead.
562 */
563 QJSValue QJSValue::call(const QJSValue& thisObject, const QJSValueList& args)
564 {
565     Q_D(QJSValue);
566     QScriptIsolate api(d->engine());
567     return d->call(QJSValuePrivate::get(thisObject), args);
568 }
569
570 /*!
571   \obsolete
572
573   Use callAsConstructor() instead.
574 */
575 QJSValue QJSValue::construct(const QJSValueList &args)
576 {
577     Q_D(QJSValue);
578     QScriptIsolate api(d->engine());
579     return QJSValuePrivate::get(d->callAsConstructor(args));
580 }
581
582 /*!
583   \obsolete
584
585   Returns the QJSEngine that created this QJSValue,
586   or 0 if this QJSValue is invalid or the value is not
587   associated with a particular engine.
588 */
589 QJSEngine* QJSValue::engine() const
590 {
591     Q_D(const QJSValue);
592     QScriptIsolate api(d->engine());
593     QV8Engine* engine = d->engine();
594     if (engine)
595         return QV8Engine::get(engine);
596     return 0;
597 }
598
599 #endif // QT_DEPRECATED
600
601 /*!
602   If this QJSValue is an object, returns the internal prototype
603   (\c{__proto__} property) of this object; otherwise returns an
604   undefined QJSValue.
605
606   \sa setPrototype(), isObject()
607 */
608 QJSValue QJSValue::prototype() const
609 {
610     Q_D(const QJSValue);
611     QScriptIsolate api(d->engine());
612     return QJSValuePrivate::get(d->prototype());
613 }
614
615 /*!
616   If this QJSValue is an object, sets the internal prototype
617   (\c{__proto__} property) of this object to be \a prototype;
618   otherwise does nothing.
619
620   The internal prototype should not be confused with the public
621   property with name "prototype"; the public prototype is usually
622   only set on functions that act as constructors.
623
624   \sa prototype(), isObject()
625 */
626 void QJSValue::setPrototype(const QJSValue& prototype)
627 {
628     Q_D(QJSValue);
629     QScriptIsolate api(d->engine());
630     d->setPrototype(QJSValuePrivate::get(prototype));
631 }
632
633 /*!
634   Assigns the \a other value to this QJSValue.
635
636   Note that if \a other is an object (isObject() returns true),
637   only a reference to the underlying object will be assigned;
638   the object itself will not be copied.
639 */
640 QJSValue& QJSValue::operator=(const QJSValue& other)
641 {
642     d_ptr = other.d_ptr;
643     return *this;
644 }
645
646 /*!
647   Returns true if this QJSValue is equal to \a other, otherwise
648   returns false. The comparison follows the behavior described in
649   \l{ECMA-262} section 11.9.3, "The Abstract Equality Comparison
650   Algorithm".
651
652   This function can return true even if the type of this QJSValue
653   is different from the type of the \a other value; i.e. the
654   comparison is not strict.  For example, comparing the number 9 to
655   the string "9" returns true; comparing an undefined value to a null
656   value returns true; comparing a \c{Number} object whose primitive
657   value is 6 to a \c{String} object whose primitive value is "6"
658   returns true; and comparing the number 1 to the boolean value
659   \c{true} returns true. If you want to perform a comparison
660   without such implicit value conversion, use strictlyEquals().
661
662   Note that if this QJSValue or the \a other value are objects,
663   calling this function has side effects on the script engine, since
664   the engine will call the object's valueOf() function (and possibly
665   toString()) in an attempt to convert the object to a primitive value
666   (possibly resulting in an uncaught script exception).
667
668   \sa strictlyEquals()
669 */
670 bool QJSValue::equals(const QJSValue& other) const
671 {
672     Q_D(const QJSValue);
673     QJSValuePrivate* otherValue = QJSValuePrivate::get(other);
674     QScriptIsolate api(d->engine() ? d->engine() : otherValue->engine());
675     return d_ptr->equals(otherValue);
676 }
677
678 /*!
679   Returns true if this QJSValue is equal to \a other using strict
680   comparison (no conversion), otherwise returns false. The comparison
681   follows the behavior described in \l{ECMA-262} section 11.9.6, "The
682   Strict Equality Comparison Algorithm".
683
684   If the type of this QJSValue is different from the type of the
685   \a other value, this function returns false. If the types are equal,
686   the result depends on the type, as shown in the following table:
687
688     \table
689     \header \o Type \o Result
690     \row    \o Undefined  \o true
691     \row    \o Null       \o true
692     \row    \o Boolean    \o true if both values are true, false otherwise
693     \row    \o Number     \o false if either value is NaN (Not-a-Number); true if values are equal, false otherwise
694     \row    \o String     \o true if both values are exactly the same sequence of characters, false otherwise
695     \row    \o Object     \o true if both values refer to the same object, false otherwise
696     \endtable
697
698   \sa equals()
699 */
700 bool QJSValue::strictlyEquals(const QJSValue& other) const
701 {
702     Q_D(const QJSValue);
703     QJSValuePrivate* o = QJSValuePrivate::get(other);
704     QScriptIsolate api(d->engine() ? d->engine() : o->engine());
705     return d_ptr->strictlyEquals(o);
706 }
707
708 /*!
709   Returns the value of this QJSValue's property with the given \a name.
710   If no such property exists, an undefined QJSValue is returned.
711
712   If the property is implemented using a getter function (i.e. has the
713   PropertyGetter flag set), calling property() has side-effects on the
714   script engine, since the getter function will be called (possibly
715   resulting in an uncaught script exception). If an exception
716   occurred, property() returns the value that was thrown (typically
717   an \c{Error} object).
718
719   \sa setProperty(), hasProperty(), QJSValueIterator
720 */
721 QJSValue QJSValue::property(const QString& name) const
722 {
723     Q_D(const QJSValue);
724     QScriptIsolate api(d->engine());
725     return QJSValuePrivate::get(d->property(name));
726 }
727
728 /*!
729   \overload
730
731   Returns the property at the given \a arrayIndex.
732
733   This function is provided for convenience and performance when
734   working with array objects.
735
736   If this QJSValue is not an Array object, this function behaves
737   as if property() was called with the string representation of \a
738   arrayIndex.
739 */
740 QJSValue QJSValue::property(quint32 arrayIndex) const
741 {
742     Q_D(const QJSValue);
743     QScriptIsolate api(d->engine());
744     return QJSValuePrivate::get(d->property(arrayIndex));
745 }
746
747 /*!
748   Sets the value of this QJSValue's property with the given \a name to
749   the given \a value.
750
751   If this QJSValue is not an object, this function does nothing.
752
753   If this QJSValue does not already have a property with name \a name,
754   a new property is created.
755
756   \sa property(), deleteProperty()
757 */
758 void QJSValue::setProperty(const QString& name, const QJSValue& value)
759 {
760     Q_D(QJSValue);
761     QScriptIsolate api(d->engine());
762     d->setProperty(name, QJSValuePrivate::get(value));
763 }
764
765 /*!
766   \overload
767
768   Sets the property at the given \a arrayIndex to the given \a value.
769
770   This function is provided for convenience and performance when
771   working with array objects.
772
773   If this QJSValue is not an Array object, this function behaves
774   as if setProperty() was called with the string representation of \a
775   arrayIndex.
776 */
777 void QJSValue::setProperty(quint32 arrayIndex, const QJSValue& value)
778 {
779     Q_D(QJSValue);
780     QScriptIsolate api(d->engine());
781     d->setProperty(arrayIndex, QJSValuePrivate::get(value));
782 }
783
784 /*!
785   Attempts to delete this object's property of the given \a name.
786   Returns true if the property was deleted, otherwise returns false.
787
788   The behavior of this function is consistent with the JavaScript
789   delete operator. In particular:
790
791   \list
792   \o Non-configurable properties cannot be deleted.
793   \o This function will return true even if this object doesn't
794      have a property of the given \a name (i.e., non-existent
795      properties are "trivially deletable").
796   \o If this object doesn't have an own property of the given
797      \a name, but an object in the prototype() chain does, the
798      prototype object's property is not deleted, and this function
799      returns true.
800   \endlist
801
802   \sa setProperty(), hasOwnProperty()
803 */
804 bool QJSValue::deleteProperty(const QString &name)
805 {
806     Q_D(QJSValue);
807     QScriptIsolate api(d->engine());
808     return d->deleteProperty(name);
809 }
810
811 /*!
812   Returns true if this object has a property of the given \a name,
813   otherwise returns false.
814
815   \sa property(), hasOwnProperty()
816 */
817 bool QJSValue::hasProperty(const QString &name) const
818 {
819     Q_D(const QJSValue);
820     QScriptIsolate api(d->engine());
821     return d->hasProperty(name);
822 }
823
824 /*!
825   Returns true if this object has an own (not prototype-inherited)
826   property of the given \a name, otherwise returns false.
827
828   \sa property(), hasProperty()
829 */
830 bool QJSValue::hasOwnProperty(const QString &name) const
831 {
832     Q_D(const QJSValue);
833     QScriptIsolate api(d->engine());
834     return d->hasOwnProperty(name);
835 }
836
837 /*!
838  * If this QJSValue is a QObject, returns the QObject pointer
839  * that the QJSValue represents; otherwise, returns 0.
840  *
841  * If the QObject that this QJSValue wraps has been deleted,
842  * this function returns 0 (i.e. it is possible for toQObject()
843  * to return 0 even when isQObject() returns true).
844  *
845  * \sa isQObject()
846  */
847 QObject *QJSValue::toQObject() const
848 {
849     Q_D(const QJSValue);
850     QScriptIsolate api(d->engine());
851     return d->toQObject();
852 }
853
854 /*!
855   Returns a QDateTime representation of this value, in local time.
856   If this QJSValue is not a date, or the value of the date is NaN
857   (Not-a-Number), an invalid QDateTime is returned.
858
859   \sa isDate()
860 */
861 QDateTime QJSValue::toDateTime() const
862 {
863     Q_D(const QJSValue);
864     QScriptIsolate api(d->engine());
865     return d->toDataTime();
866 }
867
868 /*!
869   Returns true if this QJSValue is an object of the Date class;
870   otherwise returns false.
871
872   \sa QJSEngine::newDate()
873 */
874 bool QJSValue::isDate() const
875 {
876     Q_D(const QJSValue);
877     QScriptIsolate api(d->engine());
878     return d->isDate();
879 }
880
881 /*!
882   Returns true if this QJSValue is an object of the RegExp class;
883   otherwise returns false.
884 */
885 bool QJSValue::isRegExp() const
886 {
887     Q_D(const QJSValue);
888     QScriptIsolate api(d->engine());
889     return d->isRegExp();
890 }
891
892 /*!
893   Returns true if this QJSValue is a QObject; otherwise returns
894   false.
895
896   Note: This function returns true even if the QObject that this
897   QJSValue wraps has been deleted.
898
899   \sa toQObject(), QJSEngine::newQObject()
900 */
901 bool QJSValue::isQObject() const
902 {
903     Q_D(const QJSValue);
904     QScriptIsolate api(d->engine());
905     return d->isQObject();
906 }
907
908 QT_END_NAMESPACE