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
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
|
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Nokia Corporation (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 http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSCRIPTENGINE_P_H
#define QSCRIPTENGINE_P_H
#include "qscriptenginefwd_p.h"
#ifndef QT_NO_SCRIPT
#include <QtCore/QDateTime>
#include <QtCore/QMutex>
#include <QtCore/QLinkedList>
#include <QtCore/QString>
#include <QtCore/QVector>
#include <QtCore/QHash>
#include <QtCore/qnumeric.h>
#include "qscriptengine.h"
#include "qscriptnameid_p.h"
#include "qscriptobjectfwd_p.h"
#include "qscriptrepository_p.h"
#include "qscriptgc_p.h"
#include "qscriptecmaarray_p.h"
#include "qscriptecmadate_p.h"
#include "qscriptecmaobject_p.h"
#include "qscriptecmaboolean_p.h"
#include "qscriptecmanumber_p.h"
#include "qscriptecmastring_p.h"
#include "qscriptecmafunction_p.h"
#include "qscriptextvariant_p.h"
#include "qscriptextqobject_p.h"
#include "qscriptvalue_p.h"
#include "qscriptcontextfwd_p.h"
#include <math.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.
//
namespace QScript {
class ArgumentsObjectData: public QScriptObjectData
{
public:
ArgumentsObjectData() : length(0) {}
virtual ~ArgumentsObjectData() {}
public: // attributes
QScriptValueImpl activation;
uint length;
};
} // namespace QScript
inline QScriptEnginePrivate *QScriptEnginePrivate::get(QScriptEngine *q)
{
if (q)
return q->d_func();
return 0;
}
inline const QScriptEnginePrivate *QScriptEnginePrivate::get(const QScriptEngine *q)
{
if (q)
return q->d_func();
return 0;
}
inline QScriptEngine *QScriptEnginePrivate::get(QScriptEnginePrivate *d)
{
return d->q_func();
}
inline QString QScriptEnginePrivate::toString(QScriptNameIdImpl *id)
{
if (! id)
return QString();
return id->s;
}
inline QString QScriptEnginePrivate::memberName(const QScript::Member &member) const
{
return toString(member.nameId());
}
inline void QScriptEnginePrivate::newReference(QScriptValueImpl *o, int mode)
{
Q_ASSERT(o);
o->m_type = QScript::ReferenceType;
o->m_int_value = (mode);
}
inline void QScriptEnginePrivate::newActivation(QScriptValueImpl *o)
{
Q_ASSERT(o);
newObject(o, nullValue(), m_class_activation);
}
inline void QScriptEnginePrivate::newPointer(QScriptValueImpl *o, void *ptr)
{
Q_ASSERT(o);
o->m_type = QScript::PointerType;
o->m_ptr_value = ptr;
}
inline void QScriptEnginePrivate::newInteger(QScriptValueImpl *o, int i)
{
Q_ASSERT(o);
o->m_type = QScript::IntegerType;
o->m_int_value = (i);
}
inline void QScriptEnginePrivate::newNameId(QScriptValueImpl *o, const QString &s)
{
Q_ASSERT(o);
o->m_type = QScript::StringType;
o->m_string_value = (nameId(s, /*persistent=*/false));
}
inline void QScriptEnginePrivate::newString(QScriptValueImpl *o, const QString &s)
{
Q_ASSERT(o);
o->m_type = QScript::StringType;
QScriptNameIdImpl *entry = new QScriptNameIdImpl(s);
m_tempStringRepository.append(entry);
o->m_string_value = (entry);
m_newAllocatedTempStringRepositoryChars += s.length();
}
inline void QScriptEnginePrivate::newNameId(QScriptValueImpl *o, QScriptNameIdImpl *id)
{
Q_ASSERT(o);
o->m_type = QScript::StringType;
o->m_string_value = (id);
}
inline const QScript::IdTable *QScriptEnginePrivate::idTable() const
{
return &m_id_table;
}
inline qsreal QScriptEnginePrivate::convertToNativeDouble(const QScriptValueImpl &value)
{
Q_ASSERT (value.isValid());
if (value.isNumber())
return value.m_number_value;
return convertToNativeDouble_helper(value);
}
inline qint32 QScriptEnginePrivate::convertToNativeInt32(const QScriptValueImpl &value)
{
Q_ASSERT (value.isValid());
return toInt32 (convertToNativeDouble(value));
}
inline bool QScriptEnginePrivate::convertToNativeBoolean(const QScriptValueImpl &value)
{
Q_ASSERT (value.isValid());
if (value.isBoolean())
return value.m_bool_value;
return convertToNativeBoolean_helper(value);
}
inline QString QScriptEnginePrivate::convertToNativeString(const QScriptValueImpl &value)
{
Q_ASSERT (value.isValid());
if (value.isString())
return value.m_string_value->s;
return convertToNativeString_helper(value);
}
inline qsreal QScriptEnginePrivate::toInteger(qsreal n)
{
if (qIsNaN(n))
return 0;
if (n == 0 || qIsInf(n))
return n;
int sign = n < 0 ? -1 : 1;
return sign * ::floor(::fabs(n));
}
inline qint32 QScriptEnginePrivate::toInt32(qsreal n)
{
if (qIsNaN(n) || qIsInf(n) || (n == 0))
return 0;
double sign = (n < 0) ? -1.0 : 1.0;
qsreal abs_n = fabs(n);
n = ::fmod(sign * ::floor(abs_n), D32);
const double D31 = D32 / 2.0;
if (sign == -1 && n < -D31)
n += D32;
else if (sign != -1 && n >= D31)
n -= D32;
return qint32 (n);
}
inline quint32 QScriptEnginePrivate::toUint32(qsreal n)
{
if (qIsNaN(n) || qIsInf(n) || (n == 0))
return 0;
double sign = (n < 0) ? -1.0 : 1.0;
qsreal abs_n = fabs(n);
n = ::fmod(sign * ::floor(abs_n), D32);
if (n < 0)
n += D32;
return quint32 (n);
}
inline quint16 QScriptEnginePrivate::toUint16(qsreal n)
{
if (qIsNaN(n) || qIsInf(n) || (n == 0))
return 0;
double sign = (n < 0) ? -1.0 : 1.0;
qsreal abs_n = fabs(n);
n = ::fmod(sign * ::floor(abs_n), D16);
if (n < 0)
n += D16;
return quint16 (n);
}
inline QScript::AST::Node *QScriptEnginePrivate::abstractSyntaxTree() const
{
return m_abstractSyntaxTree;
}
inline QScript::MemoryPool *QScriptEnginePrivate::nodePool()
{
return m_pool;
}
inline void QScriptEnginePrivate::setNodePool(QScript::MemoryPool *pool)
{
m_pool = pool;
}
inline QScript::Lexer *QScriptEnginePrivate::lexer()
{
return m_lexer;
}
inline void QScriptEnginePrivate::setLexer(QScript::Lexer *lexer)
{
m_lexer = lexer;
}
inline QScriptObject *QScriptEnginePrivate::allocObject()
{
return objectAllocator(m_objectGeneration);
}
inline QScriptContextPrivate *QScriptEnginePrivate::currentContext() const
{
return m_context;
}
inline QScriptContextPrivate *QScriptEnginePrivate::pushContext()
{
QScriptContext *context = m_frameRepository.get();
QScriptContextPrivate *ctx_p = QScriptContextPrivate::get(context);
ctx_p->init(m_context);
m_context = ctx_p;
#ifndef Q_SCRIPT_NO_EVENT_NOTIFY
notifyContextPush();
#endif
return m_context;
}
inline void QScriptEnginePrivate::popContext()
{
Q_ASSERT(m_context != 0);
#ifndef Q_SCRIPT_NO_EVENT_NOTIFY
notifyContextPop();
#endif
QScriptContextPrivate *context = m_context;
m_context = context->parentContext();
if (m_context) {
QScriptContextPrivate *p1 = m_context;
QScriptContextPrivate *p2 = context;
if ((p1->m_state != QScriptContext::ExceptionState)
|| (p2->m_state == QScriptContext::ExceptionState)) {
// propagate the state
p1->m_result = p2->m_result;
p1->m_state = p2->m_state;
// only update errorLineNumber if there actually was an exception
if (p2->m_state == QScriptContext::ExceptionState) {
if (p2->errorLineNumber != -1)
p1->errorLineNumber = p2->errorLineNumber;
else
p1->errorLineNumber = p1->currentLine;
}
}
}
m_frameRepository.release(QScriptContextPrivate::get(context));
}
inline void QScriptEnginePrivate::maybeGC()
{
if (objectAllocator.blocked())
return;
bool do_string_gc = ((m_stringRepository.size() - m_oldStringRepositorySize) > 256)
|| (m_newAllocatedStringRepositoryChars > 0x800000);
do_string_gc |= ((m_tempStringRepository.size() - m_oldTempStringRepositorySize) > 1024)
|| (m_newAllocatedTempStringRepositoryChars > 0x800000);
if (! do_string_gc && ! objectAllocator.poll())
return;
maybeGC_helper(do_string_gc);
}
inline void QScriptEnginePrivate::adjustBytesAllocated(int bytes)
{
objectAllocator.adjustBytesAllocated(bytes);
}
inline bool QScriptEnginePrivate::blockGC(bool block)
{
return objectAllocator.blockGC(block);
}
inline void QScriptEnginePrivate::markString(QScriptNameIdImpl *id, int /*generation*/)
{
id->used = true;
}
inline QScriptValueImpl QScriptEnginePrivate::createFunction(QScriptFunction *fun)
{
QScriptValueImpl v;
newFunction(&v, fun);
return v;
}
inline QScriptValueImpl QScriptEnginePrivate::newArray(const QScript::Array &value)
{
QScriptValueImpl v;
newArray(&v, value);
return v;
}
inline QScriptValueImpl QScriptEnginePrivate::newArray(uint length)
{
QScriptValueImpl v;
QScript::Array a(this);
a.resize(length);
newArray(&v, a);
return v;
}
inline QScriptClassInfo *QScriptEnginePrivate::registerClass(const QString &pname, int type)
{
if (type == -1)
type = ++m_class_prev_id;
QScriptClassInfo *oc = new QScriptClassInfo(this, QScriptClassInfo::Type(type), pname);
m_allocated_classes.append(oc);
return oc;
}
inline QScriptClassInfo *QScriptEnginePrivate::registerClass(const QString &name)
{
return registerClass(name, -1);
}
inline QScriptValueImpl QScriptEnginePrivate::createFunction(QScriptInternalFunctionSignature fun,
int length, QScriptClassInfo *classInfo, const QString &name)
{
return createFunction(new QScript::C2Function(fun, length, classInfo, name));
}
inline void QScriptEnginePrivate::newFunction(QScriptValueImpl *o, QScriptFunction *function)
{
QScriptValueImpl proto;
if (functionConstructor)
proto = functionConstructor->publicPrototype;
else {
// creating the Function prototype object
Q_ASSERT(objectConstructor);
proto = objectConstructor->publicPrototype;
}
newObject(o, proto, m_class_function);
o->setObjectData(function);
}
inline void QScriptEnginePrivate::newConstructor(QScriptValueImpl *ctor,
QScriptFunction *function,
QScriptValueImpl &proto)
{
newFunction(ctor, function);
ctor->setProperty(m_id_table.id_prototype, proto,
QScriptValue::Undeletable
| QScriptValue::ReadOnly
| QScriptValue::SkipInEnumeration);
proto.setProperty(m_id_table.id_constructor, *ctor,
QScriptValue::Undeletable
| QScriptValue::SkipInEnumeration);
}
inline void QScriptEnginePrivate::newArguments(QScriptValueImpl *object,
const QScriptValueImpl &activation,
uint length,
const QScriptValueImpl &callee)
{
QScript::ArgumentsObjectData *data = new QScript::ArgumentsObjectData();
data->activation = activation;
data->length = length;
newObject(object, m_class_arguments);
object->setObjectData(data);
object->setProperty(m_id_table.id_callee, callee,
QScriptValue::SkipInEnumeration);
object->setProperty(m_id_table.id_length, QScriptValueImpl(length),
QScriptValue::SkipInEnumeration);
}
inline QScriptFunction *QScriptEnginePrivate::convertToNativeFunction(const QScriptValueImpl &object)
{
if (object.isFunction())
return static_cast<QScriptFunction*> (object.objectData());
return 0;
}
inline QScriptValue QScriptEnginePrivate::toPublic(const QScriptValueImpl &value)
{
if (!value.isValid())
return QScriptValue();
QScriptValuePrivate *p = registerValue(value);
QScriptValue v;
QScriptValuePrivate::init(v, p);
return v;
}
inline QScriptValueImpl QScriptEnginePrivate::toImpl(const QScriptValue &value)
{
QScriptValuePrivate *p = QScriptValuePrivate::get(value);
if (!p)
return QScriptValueImpl();
if (p->value.type() == QScript::LazyStringType)
return toImpl_helper(value);
return p->value;
}
inline QScriptValueImplList QScriptEnginePrivate::toImplList(const QScriptValueList &lst)
{
QScriptValueImplList result;
QScriptValueList::const_iterator it;
for (it = lst.constBegin(); it != lst.constEnd(); ++it)
result.append(toImpl(*it));
return result;
}
inline QScriptValueImpl QScriptEnginePrivate::toObject(const QScriptValueImpl &value)
{
if (value.isObject() || !value.isValid())
return value;
return toObject_helper(value);
}
inline QScriptValueImpl QScriptEnginePrivate::toPrimitive(const QScriptValueImpl &object,
QScriptValueImpl::TypeHint hint)
{
Q_ASSERT(object.isValid());
if (! object.isObject())
return object;
return toPrimitive_helper(object, hint);
}
inline QDateTime QScriptEnginePrivate::toDateTime(const QScriptValueImpl &value) const
{
return dateConstructor->toDateTime(value);
}
inline void QScriptEnginePrivate::newArray(QScriptValueImpl *object, const QScript::Array &value)
{
arrayConstructor->newArray(object, value);
}
inline void QScriptEnginePrivate::newObject(QScriptValueImpl *o, const QScriptValueImpl &proto,
QScriptClassInfo *oc)
{
Q_ASSERT(o != 0);
QScriptObject *od = allocObject();
od->reset();
od->m_id = ++m_next_object_id;
if (proto.isValid())
od->m_prototype = proto;
else {
Q_ASSERT(objectConstructor);
od->m_prototype = objectConstructor->publicPrototype;
}
o->m_type = QScript::ObjectType;
od->m_class = (oc ? oc : m_class_object);
o->m_object_value = od;
}
inline void QScriptEnginePrivate::newObject(QScriptValueImpl *o, QScriptClassInfo *oc)
{
newObject(o, objectConstructor->publicPrototype, oc);
}
inline QScriptValueImpl QScriptEnginePrivate::newObject()
{
QScriptValueImpl v;
newObject(&v);
return v;
}
inline void QScriptEnginePrivate::newVariant(QScriptValueImpl *out,
const QVariant &value,
bool setDefaultPrototype)
{
Q_ASSERT(variantConstructor != 0);
variantConstructor->newVariant(out, value);
if (setDefaultPrototype) {
QScriptValueImpl proto = defaultPrototype(value.userType());
if (proto.isValid())
out->setPrototype(proto);
}
}
#ifndef QT_NO_QOBJECT
# ifndef Q_SCRIPT_NO_QMETAOBJECT_CACHE
inline QScriptMetaObject *QScriptEnginePrivate::cachedMetaObject(const QMetaObject *meta)
{
QScriptMetaObject *value = m_cachedMetaObjects.value(meta);
if (!value) {
value = new QScriptMetaObject;
m_cachedMetaObjects.insert(meta, value);
}
return value;
}
# endif
#endif // !QT_NO_QOBJECT
inline QScriptNameIdImpl *QScriptEnginePrivate::nameId(const QString &str, bool persistent)
{
QScriptNameIdImpl *entry = toStringEntry(str);
if (! entry)
entry = insertStringEntry(str);
Q_ASSERT(entry->unique);
if (persistent)
entry->persistent = true;
return entry;
}
inline QScriptNameIdImpl *QScriptEnginePrivate::intern(const QChar *u, int s)
{
QString tmp(u, s);
return nameId(tmp, /*persistent=*/ true);
}
inline QScriptValueImpl QScriptEnginePrivate::valueFromVariant(const QVariant &v)
{
QScriptValueImpl result = create(v.userType(), v.data());
Q_ASSERT(result.isValid());
return result;
}
inline QScriptValueImpl QScriptEnginePrivate::undefinedValue()
{
return m_undefinedValue;
}
inline QScriptValueImpl QScriptEnginePrivate::nullValue()
{
return m_nullValue;
}
inline QScriptValueImpl QScriptEnginePrivate::defaultPrototype(int metaTypeId) const
{
QScriptCustomTypeInfo info = m_customTypes.value(metaTypeId);
return info.prototype;
}
inline void QScriptEnginePrivate::setDefaultPrototype(int metaTypeId, const QScriptValueImpl &prototype)
{
QScriptCustomTypeInfo info = m_customTypes.value(metaTypeId);
info.prototype = prototype;
m_customTypes.insert(metaTypeId, info);
}
inline uint _q_scriptHash(const QString &key)
{
const QChar *p = key.unicode();
int n = qMin(key.size(), 128);
uint h = key.size();
uint g;
while (n--) {
h = (h << 4) + (*p++).unicode();
if ((g = (h & 0xf0000000)) != 0)
h ^= g >> 23;
h &= ~g;
}
return h;
}
inline QScriptNameIdImpl *QScriptEnginePrivate::toStringEntry(const QString &s)
{
uint h = _q_scriptHash(s) % m_string_hash_size;
for (QScriptNameIdImpl *entry = m_string_hash_base[h]; entry && entry->h == h; entry = entry->next) {
if (entry->s == s)
return entry;
}
return 0;
}
inline bool QScriptEnginePrivate::lessThan(const QScriptValueImpl &lhs, const QScriptValueImpl &rhs)
{
return QScriptContextPrivate::lt_cmp(lhs, rhs);
}
inline bool QScriptEnginePrivate::equals(const QScriptValueImpl &lhs, const QScriptValueImpl &rhs)
{
return QScriptContextPrivate::eq_cmp(lhs, rhs);
}
inline bool QScriptEnginePrivate::strictlyEquals(const QScriptValueImpl &lhs, const QScriptValueImpl &rhs)
{
return QScriptContextPrivate::strict_eq_cmp(lhs, rhs);
}
inline void QScriptEnginePrivate::unregisterValue(QScriptValuePrivate *p)
{
QScriptValueImpl &v = p->value;
Q_ASSERT(v.isValid());
if (v.isString()) {
QScriptNameIdImpl *id = v.stringValue();
m_stringHandles.remove(id);
} else if (v.isObject()) {
QScriptObject *instance = v.objectValue();
m_objectHandles.remove(instance);
} else {
int i = m_otherHandles.indexOf(p);
Q_ASSERT(i != -1);
m_otherHandles.remove(i);
}
m_handleRepository.release(p);
}
inline QScriptValueImpl QScriptEnginePrivate::globalObject() const
{
return m_globalObject;
}
inline bool QScriptEnginePrivate::hasUncaughtException() const
{
return (currentContext()->state() == QScriptContext::ExceptionState);
}
inline QScriptValueImpl QScriptEnginePrivate::uncaughtException() const
{
if (!hasUncaughtException())
return QScriptValueImpl();
return currentContext()->returnValue();
}
inline void QScriptEnginePrivate::maybeProcessEvents()
{
if (m_processEventsInterval > 0 && ++m_processEventIncr > 512) {
m_processEventIncr = 0;
processEvents();
}
}
inline bool QScriptEnginePrivate::shouldAbort() const
{
return m_abort;
}
inline void QScriptEnginePrivate::resetAbortFlag()
{
m_abort = false;
}
#ifndef Q_SCRIPT_NO_EVENT_NOTIFY
inline bool QScriptEnginePrivate::shouldNotify() const
{
return m_agent != 0;
}
inline void QScriptEnginePrivate::notifyScriptLoad(
qint64 id, const QString &program,
const QString &fileName, int lineNumber)
{
if (shouldNotify())
notifyScriptLoad_helper(id, program, fileName, lineNumber);
}
inline void QScriptEnginePrivate::notifyScriptUnload(qint64 id)
{
if (shouldNotify())
notifyScriptUnload_helper(id);
}
inline void QScriptEnginePrivate::notifyPositionChange(QScriptContextPrivate *ctx)
{
Q_ASSERT(m_agent != 0);
notifyPositionChange_helper(ctx);
}
inline void QScriptEnginePrivate::notifyContextPush()
{
if (shouldNotify())
notifyContextPush_helper();
}
inline void QScriptEnginePrivate::notifyContextPop()
{
if (shouldNotify())
notifyContextPop_helper();
}
inline void QScriptEnginePrivate::notifyFunctionEntry(QScriptContextPrivate *ctx)
{
if (shouldNotify())
notifyFunctionEntry_helper(ctx);
}
inline void QScriptEnginePrivate::notifyFunctionExit(QScriptContextPrivate *ctx)
{
if (shouldNotify())
notifyFunctionExit_helper(ctx);
}
inline void QScriptEnginePrivate::notifyException(QScriptContextPrivate *ctx)
{
if (shouldNotify())
notifyException_helper(ctx);
}
inline void QScriptEnginePrivate::notifyExceptionCatch(QScriptContextPrivate *ctx)
{
if (shouldNotify())
notifyExceptionCatch_helper(ctx);
}
#endif // Q_SCRIPT_NO_EVENT_NOTIFY
QT_END_NAMESPACE
#endif // QT_NO_SCRIPT
#endif
|