Qt 4.8
qscriptvalue_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
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 #ifndef QSCRIPTVALUE_P_H
25 #define QSCRIPTVALUE_P_H
26 
27 //
28 // W A R N I N G
29 // -------------
30 //
31 // This file is not part of the Qt API. It exists purely as an
32 // implementation detail. This header file may change from version to
33 // version without notice, or even be removed.
34 //
35 // We mean it.
36 //
37 
38 #include <QtCore/qobjectdefs.h>
39 
40 #include "wtf/Platform.h"
41 #include "JSValue.h"
42 
44 
45 class QString;
47 
48 class QScriptValue;
50 {
52 public:
53  inline void* operator new(size_t, QScriptEnginePrivate*);
54  inline void operator delete(void*);
55 
56  enum Type {
60  };
61 
63  inline ~QScriptValuePrivate();
64 
65  inline void initFrom(JSC::JSValue value);
66  inline void initFrom(qsreal value);
67  inline void initFrom(const QString &value);
68 
69  inline bool isJSC() const;
70  inline bool isObject() const;
71 
72  static inline QScriptValuePrivate *get(const QScriptValue &q)
73  {
74  return q.d_ptr.data();
75  }
76 
78  {
79  return QScriptValue(d);
80  }
81 
82  static inline QScriptEnginePrivate *getEngine(const QScriptValue &q)
83  {
84  if (!q.d_ptr)
85  return 0;
86  return q.d_ptr->engine;
87  }
88 
89  inline JSC::JSValue property(const JSC::Identifier &id,
90  const QScriptValue::ResolveFlags &mode = QScriptValue::ResolvePrototype) const;
91  inline JSC::JSValue property(quint32 index, const QScriptValue::ResolveFlags &mode = QScriptValue::ResolvePrototype) const;
92  inline JSC::JSValue property(const JSC::UString &, const QScriptValue::ResolveFlags &mode = QScriptValue::ResolvePrototype) const;
93  inline void setProperty(const JSC::UString &name, const JSC::JSValue &value,
95  inline void setProperty(const JSC::Identifier &id, const JSC::JSValue &value,
97  inline void setProperty(quint32 index, const JSC::JSValue &value,
100  const JSC::Identifier &id, const QScriptValue::ResolveFlags &mode = QScriptValue::ResolvePrototype) const;
101 
102  void detachFromEngine();
103 
105  {
106  if ( (type == JavaScriptCore) && (engine) && jscValue.isCell() )
107  return (qint64)jscValue.asCell();
108  else
109  return -1;
110  }
111 
114  JSC::JSValue jscValue;
117 
118  // linked list of engine's script values
121 
123 };
124 
126  : engine(e), prev(0), next(0)
127 {
128  ref = 0;
129 }
130 
131 inline bool QScriptValuePrivate::isJSC() const
132 {
133  return (type == JavaScriptCore);
134 }
135 
136 inline bool QScriptValuePrivate::isObject() const
137 {
138  return isJSC() && jscValue && jscValue.isObject();
139 }
140 
141 // Rest of inline functions implemented in qscriptengine_p.h
142 
144 
145 #endif
QExplicitlySharedDataPointer< QScriptValuePrivate > d_ptr
Definition: qscriptvalue.h:209
double d
Definition: qnumeric_p.h:62
QScriptValuePrivate(QScriptEnginePrivate *)
QScriptValuePrivate * next
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
void setProperty(const JSC::UString &name, const JSC::JSValue &value, const QScriptValue::PropertyFlags &flags=QScriptValue::KeepExistingFlags)
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
static QScriptValue toPublic(QScriptValuePrivate *d)
The QString class provides a Unicode character string.
Definition: qstring.h:83
QScriptValuePrivate * prev
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static QScriptEnginePrivate * getEngine(const QScriptValue &q)
const char * name
__int64 qint64
Definition: qglobal.h:942
bool isObject() const
QBasicAtomicInt ref
PropertyFlags
Definition: qmetaobject_p.h:61
JSC::JSValue property(const JSC::Identifier &id, const QScriptValue::ResolveFlags &mode=QScriptValue::ResolvePrototype) const
unsigned int quint32
Definition: qglobal.h:938
void initFrom(JSC::JSValue value)
double qsreal
Definition: qscriptvalue.h:52
quint16 index
JSC::JSValue jscValue
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptEnginePrivate * engine
QScriptValue::PropertyFlags propertyFlags(const JSC::Identifier &id, const QScriptValue::ResolveFlags &mode=QScriptValue::ResolvePrototype) const