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-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.io/contact-us/. 19 ** 20 ** $QT_END_LICENSE$ 21 ** 22 ****************************************************************************/ 23 24 #ifndef QSCRIPTENGINEAGENT_P_H 25 #define QSCRIPTENGINEAGENT_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 #include "Debugger.h" 40 #include "qscriptengineagent.h" 41 42 #include "CallFrame.h" 43 #include "SourceCode.h" 44 #include "UString.h" 45 #include "DebuggerCallFrame.h" 46 47 QT_BEGIN_NAMESPACE 48 49 class QScriptEnginePrivate; 50 51 class QScriptEngineAgent; 52 class Q_SCRIPT_EXPORT QScriptEngineAgentPrivate : public JSC::Debugger 53 { Q_DECLARE_PUBLIC(QScriptEngineAgent)54 Q_DECLARE_PUBLIC(QScriptEngineAgent) 55 public: 56 static QScriptEngineAgent* get(QScriptEngineAgentPrivate* p) {return p->q_func();} get(QScriptEngineAgent * p)57 static QScriptEngineAgentPrivate* get(QScriptEngineAgent* p) {return p->d_func();} 58 QScriptEngineAgentPrivate()59 QScriptEngineAgentPrivate(){} ~QScriptEngineAgentPrivate()60 virtual ~QScriptEngineAgentPrivate(){} 61 62 void attach(); 63 void detach(); 64 65 //scripts sourceParsed(JSC::ExecState *,const JSC::SourceCode &,int,const JSC::UString &)66 virtual void sourceParsed(JSC::ExecState*, const JSC::SourceCode&, int /*errorLine*/, const JSC::UString& /*errorMsg*/) {} scriptUnload(qint64 id)67 virtual void scriptUnload(qint64 id) 68 { 69 q_ptr->scriptUnload(id); 70 } scriptLoad(qint64 id,const JSC::UString & program,const JSC::UString & fileName,int baseLineNumber)71 virtual void scriptLoad(qint64 id, const JSC::UString &program, 72 const JSC::UString &fileName, int baseLineNumber) 73 { 74 q_ptr->scriptLoad(id,program, fileName, baseLineNumber); 75 } 76 77 //exceptions exception(const JSC::DebuggerCallFrame & frame,intptr_t sourceID,int lineno,bool hasHandler)78 virtual void exception(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno, bool hasHandler) 79 { 80 Q_UNUSED(frame); 81 Q_UNUSED(sourceID); 82 Q_UNUSED(lineno); 83 Q_UNUSED(hasHandler); 84 } 85 virtual void exceptionThrow(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, bool hasHandler); 86 virtual void exceptionCatch(const JSC::DebuggerCallFrame& frame, intptr_t sourceID); 87 88 //statements 89 virtual void atStatement(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno/*, int column*/); callEvent(const JSC::DebuggerCallFrame &,intptr_t sourceID,int lineno)90 virtual void callEvent(const JSC::DebuggerCallFrame&, intptr_t sourceID, int lineno) 91 { 92 Q_UNUSED(lineno); 93 q_ptr->contextPush(); 94 q_ptr->functionEntry(sourceID); 95 } 96 virtual void returnEvent(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno); willExecuteProgram(const JSC::DebuggerCallFrame & frame,intptr_t sourceID,int lineno)97 virtual void willExecuteProgram(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno) 98 { 99 Q_UNUSED(frame); 100 Q_UNUSED(sourceID); 101 Q_UNUSED(lineno); 102 } didExecuteProgram(const JSC::DebuggerCallFrame & frame,intptr_t sourceID,int lineno)103 virtual void didExecuteProgram(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno) 104 { 105 Q_UNUSED(frame); 106 Q_UNUSED(sourceID); 107 Q_UNUSED(lineno); 108 } 109 virtual void functionExit(const JSC::JSValue& returnValue, intptr_t sourceID); 110 //others 111 virtual void didReachBreakpoint(const JSC::DebuggerCallFrame& frame, intptr_t sourceID, int lineno/*, int column*/); 112 evaluateStart(intptr_t sourceID)113 virtual void evaluateStart(intptr_t sourceID) 114 { 115 q_ptr->functionEntry(sourceID); 116 } 117 virtual void evaluateStop(const JSC::JSValue& returnValue, intptr_t sourceID); 118 119 QScriptEnginePrivate *engine; 120 QScriptEngineAgent *q_ptr; 121 }; 122 123 QT_END_NAMESPACE 124 125 #endif 126