1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
|
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the QtScript module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the either Technology Preview License Agreement or the
** Beta Release License Agreement.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTENGINEFWD_P_H
#define QSCRIPTENGINEFWD_P_H
#ifndef QT_NO_QOBJECT
#include "private/qobject_p.h"
#endif
#ifndef QT_NO_SCRIPT
#include <QtCore/qobjectdefs.h>
#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtCore/QRegExp>
#include <QtCore/QSet>
#include <QtCore/QStringList>
#include <QtCore/QTime>
#include <QtCore/QVector>
#include "qscriptengine.h"
#include "qscriptrepository_p.h"
#include "qscriptgc_p.h"
#include "qscriptobjectfwd_p.h"
#include "qscriptclassinfo_p.h"
#include "qscriptstring_p.h"
QT_BEGIN_NAMESPACE
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
class QScriptClass;
class QScriptContext;
namespace QScript {
namespace AST {
class Node;
} // namespace AST
namespace Ecma {
class Object;
class Number;
class Boolean;
class String;
class Math;
class Date;
class Function;
class Array;
class RegExp;
class Error;
} // namespace Ecma
namespace Ext {
class Enumeration;
class Variant;
} // namespace Ext
class ExtQObject;
class ExtQMetaObject;
class Array;
class Lexer;
class Code;
class CompilationUnit;
class IdTable;
class MemoryPool;
class IdTable
{
public:
inline IdTable()
: id_constructor(0), id_false(0), id_null(0),
id_object(0), id_pointer(0), id_prototype(0),
id_arguments(0), id_this(0), id_toString(0),
id_true(0), id_undefined(0), id_valueOf(0),
id_length(0), id_callee(0), id___proto__(0),
id___qt_sender__(0)
{}
QScriptNameIdImpl *id_constructor;
QScriptNameIdImpl *id_false;
QScriptNameIdImpl *id_null;
QScriptNameIdImpl *id_object;
QScriptNameIdImpl *id_pointer;
QScriptNameIdImpl *id_prototype;
QScriptNameIdImpl *id_arguments;
QScriptNameIdImpl *id_this;
QScriptNameIdImpl *id_toString;
QScriptNameIdImpl *id_true;
QScriptNameIdImpl *id_undefined;
QScriptNameIdImpl *id_valueOf;
QScriptNameIdImpl *id_length;
QScriptNameIdImpl *id_callee;
QScriptNameIdImpl *id___proto__;
QScriptNameIdImpl *id___qt_sender__;
};
} // namespace QScript
#ifndef QT_NO_QOBJECT
class QScriptQObjectData;
class QScriptMetaObject;
#endif
class QScriptCustomTypeInfo
{
public:
QScriptCustomTypeInfo() : signature(0, '\0'), marshal(0), demarshal(0)
{ prototype.invalidate(); }
QByteArray signature;
QScriptEngine::MarshalFunction marshal;
QScriptEngine::DemarshalFunction demarshal;
QScriptValueImpl prototype;
};
class QScriptEnginePrivate
#ifndef QT_NO_QOBJECT
: public QObjectPrivate
#endif
{
Q_DECLARE_PUBLIC(QScriptEngine)
enum {
DefaultHashSize = 1021
};
public:
QScriptEnginePrivate();
virtual ~QScriptEnginePrivate();
void init();
void initStringRepository();
static inline QScriptEnginePrivate *get(QScriptEngine *q);
static inline const QScriptEnginePrivate *get(const QScriptEngine *q);
static inline QScriptEngine *get(QScriptEnginePrivate *d);
QScript::AST::Node *createAbstractSyntaxTree(
const QString &source, int lineNumber,
QString *errorMessage, int *errorLineNumber);
QScript::AST::Node *changeAbstractSyntaxTree(QScript::AST::Node *program);
inline QScript::AST::Node *abstractSyntaxTree() const;
inline bool hasUncaughtException() const;
inline QScriptValueImpl uncaughtException() const;
QStringList uncaughtExceptionBacktrace() const;
void clearExceptions();
#ifndef QT_NO_QOBJECT
void emitSignalHandlerException();
#endif
static bool canEvaluate(const QString &program);
static QScriptSyntaxCheckResult checkSyntax(const QString &program);
inline QScriptContextPrivate *currentContext() const;
inline QScriptContextPrivate *pushContext();
inline void popContext();
inline QScript::MemoryPool *nodePool();
inline QScript::Lexer *lexer();
inline QScriptObject *allocObject();
inline void maybeGC();
void maybeGC_helper(bool do_string_gc);
inline bool blockGC(bool block);
void gc();
bool isCollecting() const;
void processMarkStack(int generation);
inline void adjustBytesAllocated(int bytes);
void markObject(const QScriptValueImpl &object, int generation);
void markFrame(QScriptContextPrivate *context, int generation);
inline void markString(QScriptNameIdImpl *id, int generation);
inline QScriptValueImpl createFunction(QScriptFunction *fun);
inline QScriptValueImpl newArray(const QScript::Array &value);
inline QScriptValueImpl newArray(uint length = 0);
void evaluate(QScriptContextPrivate *context, const QString &contents,
int lineNumber, const QString &fileName = QString());
inline void setLexer(QScript::Lexer *lexer);
inline void setNodePool(QScript::MemoryPool *pool);
inline QScriptClassInfo *registerClass(const QString &pname, int type);
inline QScriptClassInfo *registerClass(const QString &name);
int registerCustomClassType();
inline QScriptValueImpl createFunction(QScriptInternalFunctionSignature fun,
int length, QScriptClassInfo *classInfo,
const QString &name = QString());
static inline QString toString(QScriptNameIdImpl *id);
inline QString memberName(const QScript::Member &member) const;
inline void newReference(QScriptValueImpl *object, int mode);
inline void newActivation(QScriptValueImpl *object);
inline void newFunction(QScriptValueImpl *object, QScriptFunction *function);
inline void newConstructor(QScriptValueImpl *ctor, QScriptFunction *function,
QScriptValueImpl &proto);
inline void newInteger(QScriptValueImpl *object, int i);
inline void newPointer(QScriptValueImpl *object, void *ptr);
inline void newNameId(QScriptValueImpl *object, const QString &s);
inline void newNameId(QScriptValueImpl *object, QScriptNameIdImpl *id);
inline void newString(QScriptValueImpl *object, const QString &s);
inline void newArguments(QScriptValueImpl *object, const QScriptValueImpl &activation,
uint length, const QScriptValueImpl &callee);
static inline QString convertToNativeString(const QScriptValueImpl &value);
static QString convertToNativeString_helper(const QScriptValueImpl &value);
static inline qsreal convertToNativeDouble(const QScriptValueImpl &value);
static qsreal convertToNativeDouble_helper(const QScriptValueImpl &value);
static inline bool convertToNativeBoolean(const QScriptValueImpl &value);
static bool convertToNativeBoolean_helper(const QScriptValueImpl &value);
static inline qint32 convertToNativeInt32(const QScriptValueImpl &value);
static inline QScriptFunction *convertToNativeFunction(const QScriptValueImpl &value);
inline QScriptValue toPublic(const QScriptValueImpl &value);
inline QScriptValueImpl toImpl(const QScriptValue &value);
QScriptValueImpl toImpl_helper(const QScriptValue &value);
inline QScriptValueImplList toImplList(const QScriptValueList &lst);
inline const QScript::IdTable *idTable() const;
inline QScriptValueImpl toObject(const QScriptValueImpl &value);
QScriptValueImpl toObject_helper(const QScriptValueImpl &value);
inline QScriptValueImpl toPrimitive(const QScriptValueImpl &object,
QScriptValueImpl::TypeHint hint = QScriptValueImpl::NoTypeHint);
QScriptValueImpl toPrimitive_helper(const QScriptValueImpl &object,
QScriptValueImpl::TypeHint hint);
static const qsreal D16;
static const qsreal D32;
inline static qsreal toInteger(qsreal n);
inline static qint32 toInt32(qsreal m);
inline static quint32 toUint32(qsreal n);
inline static quint16 toUint16(qsreal n);
inline QDateTime toDateTime(const QScriptValueImpl &value) const;
inline void newArray(QScriptValueImpl *object, const QScript::Array &value);
inline void newObject(QScriptValueImpl *o, const QScriptValueImpl &proto,
QScriptClassInfo *oc = 0);
inline void newObject(QScriptValueImpl *o, QScriptClassInfo *oc = 0);
QScriptValueImpl newObject(QScriptClass *scriptClass, const QScriptValueImpl &data);
inline QScriptValueImpl newObject();
inline void newVariant(QScriptValueImpl *out, const QVariant &value,
bool setDefaultPrototype = true);
#ifndef QT_NO_QOBJECT
void newQObject(QScriptValueImpl *out, QObject *object,
QScriptEngine::ValueOwnership ownership = QScriptEngine::QtOwnership,
const QScriptEngine::QObjectWrapOptions &options = 0,
bool setDefaultPrototype = true);
# ifndef Q_SCRIPT_NO_QMETAOBJECT_CACHE
inline QScriptMetaObject *cachedMetaObject(const QMetaObject *meta);
# endif
#endif
inline QScriptNameIdImpl *nameId(const QString &str, bool persistent = false);
inline QScriptNameIdImpl *intern(const QChar *u, int s);
QScriptString internedString(const QString &str);
QScriptString internedString(QScriptNameIdImpl *nid);
void uninternString(QScriptStringPrivate *d);
inline QScriptValueImpl valueFromVariant(const QVariant &v);
inline QScriptValueImpl undefinedValue();
inline QScriptValueImpl nullValue();
inline QScriptValueImpl defaultPrototype(int metaTypeId) const;
inline void setDefaultPrototype(int metaTypeId, const QScriptValueImpl &prototype);
QScriptValueImpl call(const QScriptValueImpl &callee, const QScriptValueImpl &thisObject,
const QScriptValueImplList &args, bool asConstructor);
QScriptValueImpl call(const QScriptValueImpl &callee, const QScriptValueImpl &thisObject,
const QScriptValueImpl &args, bool asConstructor);
void rehashStringRepository(bool resize = true);
inline QScriptNameIdImpl *toStringEntry(const QString &s);
QScriptNameIdImpl *insertStringEntry(const QString &s);
QScriptValueImpl create(int type, const void *ptr);
static bool convert(const QScriptValueImpl &value, int type, void *ptr,
QScriptEnginePrivate *eng);
QScriptValueImpl arrayFromStringList(const QStringList &lst);
static QStringList stringListFromArray(const QScriptValueImpl &arr);
QScriptValueImpl arrayFromVariantList(const QVariantList &lst);
static QVariantList variantListFromArray(const QScriptValueImpl &arr);
QScriptValueImpl objectFromVariantMap(const QVariantMap &vmap);
static QVariantMap variantMapFromObject(const QScriptValueImpl &obj);
static inline bool lessThan(const QScriptValueImpl &lhs, const QScriptValueImpl &rhs);
static inline bool equals(const QScriptValueImpl &lhs, const QScriptValueImpl &rhs);
static inline bool strictlyEquals(const QScriptValueImpl &lhs, const QScriptValueImpl &rhs);
QScriptValuePrivate *registerValue(const QScriptValueImpl &value);
inline void unregisterValue(QScriptValuePrivate *p);
inline QScriptValueImpl globalObject() const;
QScriptValueImpl objectById(qint64 id) const;
QScriptValueImpl importExtension(const QString &extension);
QStringList availableExtensions() const;
QStringList importedExtensions() const;
inline void maybeProcessEvents();
void setupProcessEvents();
void processEvents();
#ifndef QT_NO_QOBJECT
QScriptQObjectData *qobjectData(QObject *object);
bool scriptConnect(QObject *sender, const char *signal,
const QScriptValueImpl &receiver,
const QScriptValueImpl &function);
bool scriptDisconnect(QObject *sender, const char *signal,
const QScriptValueImpl &receiver,
const QScriptValueImpl &function);
bool scriptConnect(QObject *sender, int index,
const QScriptValueImpl &receiver,
const QScriptValueImpl &function,
const QScriptValueImpl &senderWrapper = QScriptValueImpl());
bool scriptDisconnect(QObject *sender, int index,
const QScriptValueImpl &receiver,
const QScriptValueImpl &function);
bool scriptConnect(const QScriptValueImpl &signal,
const QScriptValueImpl &receiver,
const QScriptValueImpl &function);
bool scriptDisconnect(const QScriptValueImpl &signal,
const QScriptValueImpl &receiver,
const QScriptValueImpl &function);
void _q_objectDestroyed(QObject *object);
void disposeQObject(QObject *object);
void deletePendingQObjects();
static bool convertToNativeQObject(const QScriptValueImpl &value,
const QByteArray &targetType,
void **result);
#endif
void abortEvaluation(const QScriptValueImpl &result);
inline bool shouldAbort() const;
inline void resetAbortFlag();
void setAgent(QScriptEngineAgent *agent);
QScriptEngineAgent *agent() const;
void agentDeleted(QScriptEngineAgent *agent);
void installTranslatorFunctions(QScriptValueImpl &object);
#ifndef Q_SCRIPT_NO_EVENT_NOTIFY
qint64 nextScriptId();
inline bool shouldNotify() const;
inline void notifyScriptLoad(qint64 id, const QString &program,
const QString &fileName, int lineNumber);
void notifyScriptLoad_helper(qint64 id, const QString &program,
const QString &fileName, int lineNumber);
inline void notifyScriptUnload(qint64 id);
void notifyScriptUnload_helper(qint64 id);
inline void notifyPositionChange(QScriptContextPrivate *ctx);
void notifyPositionChange_helper(QScriptContextPrivate *ctx);
inline void notifyContextPush();
void notifyContextPush_helper();
inline void notifyContextPop();
void notifyContextPop_helper();
inline void notifyFunctionEntry(QScriptContextPrivate *ctx);
void notifyFunctionEntry_helper(QScriptContextPrivate *ctx);
inline void notifyFunctionExit(QScriptContextPrivate *ctx);
void notifyFunctionExit_helper(QScriptContextPrivate *ctx);
inline void notifyException(QScriptContextPrivate *ctx);
void notifyException_helper(QScriptContextPrivate *ctx);
inline void notifyExceptionCatch(QScriptContextPrivate *ctx);
void notifyExceptionCatch_helper(QScriptContextPrivate *ctx);
void notifyDebugger(QScriptContextPrivate *ctx);
#endif // Q_SCRIPT_NO_EVENT_NOTIFY
public: // attributes
bool m_evaluating;
bool m_abort;
int m_callDepth;
int m_maxCallDepth;
int m_gc_depth;
QList<QScriptValueImpl> m_markStack;
QScriptValueImpl m_globalObject;
int m_oldStringRepositorySize;
int m_oldTempStringRepositorySize;
QVector<QScriptNameIdImpl*> m_stringRepository;
int m_newAllocatedStringRepositoryChars;
QVector<QScriptNameIdImpl*> m_tempStringRepository;
int m_newAllocatedTempStringRepositoryChars;
QScriptNameIdImpl **m_string_hash_base;
int m_string_hash_size;
QScript::GCAlloc<QScriptObject> objectAllocator;
int m_objectGeneration;
QScript::Repository<QScriptContext, QScriptContextPrivate> m_frameRepository;
QScriptContextPrivate *m_context;
QScriptValueImpl *tempStackBegin;
QScriptValueImpl *tempStackEnd;
QScript::AST::Node *m_abstractSyntaxTree;
QScript::Lexer *m_lexer;
QScript::MemoryPool *m_pool;
QStringList m_exceptionBacktrace;
qint64 m_scriptCounter;
QScriptValueImpl m_undefinedValue;
QScriptValueImpl m_nullValue;
QScript::Ecma::Object *objectConstructor;
QScript::Ecma::Number *numberConstructor;
QScript::Ecma::Boolean *booleanConstructor;
QScript::Ecma::String *stringConstructor;
QScript::Ecma::Date *dateConstructor;
QScript::Ecma::Function *functionConstructor;
QScript::Ecma::Array *arrayConstructor;
QScript::Ecma::RegExp *regexpConstructor;
QScript::Ecma::Error *errorConstructor;
QScript::Ext::Enumeration *enumerationConstructor;
QScript::Ext::Variant *variantConstructor;
QScript::ExtQObject *qobjectConstructor;
QScript::ExtQMetaObject *qmetaObjectConstructor;
QHash<int, QScriptCustomTypeInfo> m_customTypes;
QScriptFunction *m_evalFunction;
QList<QScriptClassInfo*> m_allocated_classes;
QScriptClassInfo *m_class_object;
QScriptClassInfo *m_class_function;
QScriptClassInfo *m_class_with;
QScriptClassInfo *m_class_arguments;
QScriptClassInfo *m_class_activation;
int m_class_prev_id;
qint64 m_next_object_id;
QScript::Repository<QScriptValuePrivate, QScriptValuePrivate> m_handleRepository;
QHash<QScriptObject*, QScriptValuePrivate*> m_objectHandles;
QHash<QScriptNameIdImpl*, QScriptValuePrivate*> m_stringHandles;
QVector<QScriptValuePrivate*> m_otherHandles;
QScript::Repository<QScriptStringPrivate,
QScriptStringPrivate> m_internedStringRepository;
QHash<QScriptNameIdImpl*, QScriptStringPrivate*> m_internedStrings;
QSet<QScriptObject*> visitedArrayElements;
#ifndef QT_NO_REGEXP
QHash<QString, QRegExp> m_regExpLiterals;
#endif
QScript::IdTable m_id_table;
QSet<QString> m_importedExtensions;
QSet<QString> m_extensionsBeingImported;
int m_processEventsInterval;
int m_nextProcessEvents;
int m_processEventIncr;
QTime m_processEventTracker;
QList<QScriptEngineAgent*> m_agents;
QScriptEngineAgent *m_agent;
#ifndef QT_NO_QOBJECT
QList<QObject*> m_qobjectsToBeDeleted;
QHash<QObject*, QScriptQObjectData*> m_qobjectData;
# ifndef Q_SCRIPT_NO_QMETAOBJECT_CACHE
QHash<const QMetaObject*, QScriptMetaObject*> m_cachedMetaObjects;
# endif
#endif
#ifdef QT_NO_QOBJECT
QScriptEngine *q_ptr;
#endif
};
QT_END_NAMESPACE
#endif // QT_NO_SCRIPT
#endif
|