1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtScript module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QSCRIPTENGINEAGENT_P_H
41#define QSCRIPTENGINEAGENT_P_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <QtCore/qobjectdefs.h>
55#include "Debugger.h"
56#include "qscriptengineagent.h"
57
58#include "CallFrame.h"
59#include "SourceCode.h"
60#include "UString.h"
61#include "DebuggerCallFrame.h"
62
63QT_BEGIN_NAMESPACE
64
65class QScriptEnginePrivate;
66
67class QScriptEngineAgent;
68class Q_SCRIPT_EXPORT QScriptEngineAgentPrivate : public JSC::Debugger
69{
70 Q_DECLARE_PUBLIC(QScriptEngineAgent)
71public:
72 static QScriptEngineAgent* get(QScriptEngineAgentPrivate* p) {return p->q_func();}
73 static QScriptEngineAgentPrivate* get(QScriptEngineAgent* p) {return p->d_func();}
74
75 QScriptEngineAgentPrivate(){}
76 virtual ~QScriptEngineAgentPrivate(){}
77
78 void attach();
79 void detach();
80
81 //scripts
82 virtual void sourceParsed(JSC::ExecState*, const JSC::SourceCode&, int /*errorLine*/, const JSC::UString& /*errorMsg*/) {}
83 virtual void scriptUnload(qint64 id)
84 {
85 q_ptr->scriptUnload(id);
86 }
87 virtual void scriptLoad(qint64 id, const JSC::UString &program,
88 const JSC::UString &fileName, int baseLineNumber)
89 {
90 q_ptr->scriptLoad(id,program, fileName, baseLineNumber);
91 }
92
93 //exceptions
94 virtual void exception(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno, bool hasHandler)
95 {
96 Q_UNUSED(frame);
97 Q_UNUSED(sourceID);
98 Q_UNUSED(lineno);
99 Q_UNUSED(hasHandler);
100 }
101 virtual void exceptionThrow(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, bool hasHandler);
102 virtual void exceptionCatch(const JSC::DebuggerCallFrame& frame, intptr_t sourceID);
103
104 //statements
105 virtual void atStatement(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno/*, int column*/);
106 virtual void callEvent(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno)
107 {
108 Q_UNUSED(lineno);
109 q_ptr->contextPush();
110 q_ptr->functionEntry(scriptId: sourceID);
111 }
112 virtual void returnEvent(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno);
113 virtual void willExecuteProgram(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno)
114 {
115 Q_UNUSED(frame);
116 Q_UNUSED(sourceID);
117 Q_UNUSED(lineno);
118 }
119 virtual void didExecuteProgram(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno)
120 {
121 Q_UNUSED(frame);
122 Q_UNUSED(sourceID);
123 Q_UNUSED(lineno);
124 }
125 virtual void functionExit(const JSC::JSValue& returnValue, intptr_t sourceID);
126 //others
127 virtual void didReachBreakpoint(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno/*, int column*/);
128
129 virtual void evaluateStart(intptr_t sourceID)
130 {
131 q_ptr->functionEntry(scriptId: sourceID);
132 }
133 virtual void evaluateStop(const JSC::JSValue& returnValue, intptr_t sourceID);
134
135 QScriptEnginePrivate *engine;
136 QScriptEngineAgent *q_ptr;
137};
138
139QT_END_NAMESPACE
140
141#endif
142

source code of qtscript/src/script/api/qscriptengineagent_p.h