kjs_debugwin.h Source File (khtml Library)

| # khtml Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kjs_debugwin.h

    00001 /*
    00002  *  This file is part of the KDE libraries
    00003  *  Copyright (C) 2000-2001 Harri Porten (porten@kde.org)
    00004  *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
    00005  *
    00006  *  This library is free software; you can redistribute it and/or
    00007  *  modify it under the terms of the GNU Library General Public
    00008  *  License as published by the Free Software Foundation; either
    00009  *  version 2 of the License, or (at your option) any later version.
    00010  *
    00011  *  This library is distributed in the hope that it will be useful,
    00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014  *  Library General Public License for more details.
    00015  *
    00016  *  You should have received a copy of the GNU Library General Public
    00017  *  License along with this library; if not, write to the Free Software
    00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00019  */
    00020
    00021 #ifndef _KJS_DEBUGGER_H_
    00022 #define _KJS_DEBUGGER_H_
    00023
    00024 #include <qglobal.h>
    00025
    00026 //#define KJS_DEBUGGER
    00027
    00028 #ifdef KJS_DEBUGGER
    00029
    00030 #include <qwidget.h>
    00031 #include <qpixmap.h>
    00032 #include <qptrlist.h>
    00033
    00034 #include <kjs/debugger.h>
    00035
    00036 #include "dom/dom_misc.h"
    00037
    00038 class QListBox;
    00039 class QComboBox;
    00040 class QLineEdit;
    00041 class QPushButton;
    00042
    00043 namespace KJS {
    00044   class FunctionImp;
    00045   class List;
    00046   class ScriptInterpreter;
    00047 };
    00048
    00056 class FakeModal : public QWidget
    00057 {
    00058     Q_OBJECT
    00059 public:
    00060     FakeModal() {}
    00061     void enable(QWidget *modal);
    00062     void disable();
    00063
    00064 protected:
    00065     bool eventFilter( QObject *obj, QEvent *evt );
    00066     QWidget *modalWidget;
    00067 };
    00068
    00069
    00076 class StackFrame {
    00077  public:
    00078   StackFrame(int s, int l, QString n, bool stepped)
    00079     : sourceId(s), lineno(l), name(n), step(stepped),
    00080     next(stepped) {}
    00081   QString toString();
    00082
    00083   int sourceId;
    00084   int lineno;
    00085   QString name;
    00086   bool step;
    00087   bool next;
    00088 };
    00089
    00090 class SourceFile : public DOM::DomShared {
    00091  public:
    00092   SourceFile(QString u, QString c, int i) : url(u), code(c), index(i) {}
    00093   QString url;
    00094   QString code;
    00095   int index;
    00096 };
    00097
    00113 class SourceFragment {
    00114  public:
    00115   SourceFragment(int sid, int bl, SourceFile *sf);
    00116   ~SourceFragment();
    00117
    00118   int sourceId;
    00119   int baseLine;
    00120   SourceFile *sourceFile;
    00121 };
    00122
    00132 class KJSDebugWin : public QWidget, public KJS::Debugger {
    00133   Q_OBJECT
    00134 public:
    00135   KJSDebugWin(QWidget *parent=0, const char *name=0);
    00136   virtual ~KJSDebugWin();
    00137
    00138   static KJSDebugWin *createInstance();
    00139   static void destroyInstance();
    00140   static KJSDebugWin *instance() { return kjs_html_debugger; }
    00141
    00142   enum Mode { Disabled = 0, // No break on any statements
    00143               Next     = 1, // Will break on next statement in current context
    00144               Step     = 2, // Will break on next statement in current or deeper context
    00145               Continue = 3, // Will continue until next breakpoint
    00146               Stop     = 4  // The script will stop execution completely,
    00147                             // as soon as possible
    00148   };
    00149
    00150   void highLight(int sourceId, int line);
    00151   void setNextSourceInfo(QString url, int baseLine);
    00152   void setSourceFile(QString url, QString code);
    00153   void appendSourceFile(QString url, QString code);
    00154   bool inSession() const { return m_inSession; }
    00155   void setMode(Mode m) { m_mode = m; }
    00156
    00157   // functions overridden from KJS:Debugger
    00158   bool sourceParsed(KJS::ExecState *exec, int sourceId,
    00159                     const KJS::UString &source, int errorLine);
    00160   bool sourceUnused(KJS::ExecState * exec, int sourceId);
    00161   bool exception(KJS::ExecState *exec, int sourceId,
    00162                  int lineno, KJS::Object &exceptionObj);
    00163   bool atStatement(KJS::ExecState *exec, int sourceId,
    00164                    int firstLine, int lastLine);
    00165   bool callEvent(KJS::ExecState *exec, int sourceId, int lineno,
    00166           KJS::Object &function, const KJS::List &args);
    00167   bool returnEvent(KJS::ExecState *exec, int sourceId,
    00168                    int lineno, KJS::Object &function);
    00169 public slots:
    00170   void next();
    00171   void step();
    00172   void cont();
    00173   void stop();
    00174   void breakNext();
    00175   void toggleBreakpoint();
    00176   void showFrame(int frameno);
    00177   void sourceSelected(int sourceSelIndex);
    00178   void eval();
    00179
    00180 protected:
    00181
    00182   virtual void closeEvent(QCloseEvent *e);
    00183
    00184 private:
    00185   void enterSession();
    00186   void leaveSession();
    00187   void setCode(const QString &code,int SourceId);
    00188   void updateFrameList();
    00189
    00190   struct Breakpoint {
    00191     int lineno;
    00192     Breakpoint *next;
    00193   };
    00194   struct SourceBreakpoints {
    00195     int sourceId;
    00196     Breakpoint *breakpoints;
    00197     SourceBreakpoints *next;
    00198   };
    00199   SourceBreakpoints *m_sourceBreakpoints;
    00200
    00201   bool setBreakpoint(int sourceId, int line);
    00202   bool deleteBreakpoint(int sourceId, int line);
    00203   void clearAllBreakpoints(int sourceId = -1);
    00204   int breakpointLine(int sourceId, int line0, int line1);
    00205   bool haveBreakpoint(int sourceId, int line0, int line1);
    00206
    00207   bool m_inSession;
    00208
    00209   QListBox *m_sourceDisplay;
    00210   QListBox *m_frameList;
    00211   QPushButton *m_stepButton;
    00212   QPushButton *m_nextButton;
    00213   QPushButton *m_continueButton;
    00214   QPushButton *m_stopButton;
    00215   QPushButton *m_breakButton;
    00216   QPushButton *m_breakpointButton;
    00217   QComboBox *m_sourceSel;
    00218   QPixmap m_stopIcon;
    00219   QPixmap m_emptyIcon;
    00220   QLineEdit *m_evalEdit;
    00221   QPushButton *m_evalButton;
    00222
    00223   SourceFile *m_curSourceFile;
    00224   QPtrList<StackFrame> m_frames;
    00225   Mode m_mode;
    00226   /* url->SourceFile mapping*/
    00227   QMap<QString,SourceFile*> m_sourceFiles;
    00228   /* SourceId->SourceFragment mapping*/
    00229   QMap<int,SourceFragment*> m_sourceFragments;
    00230   /* combobox index->SourceFile mapping*/
    00231   QMap<int,SourceFile*> m_sourceSelFiles;
    00232
    00233   QString m_nextSourceUrl;
    00234   int m_nextSourceBaseLine;
    00235   FakeModal m_fakeModal;
    00236   //const KJS::ExecutionContext *m_curContext;
    00237   //KJScript *m_curScript;
    00238   KJS::ExecState *m_curExecState;
    00239   static KJSDebugWin *kjs_html_debugger;
    00240 };
    00241
    00242 #endif // KJS_DEBUGGER
    00243
    00244 #endif // _KJS_DEBUGGER_H_

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:34:13 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001