Moved DebuggerParser instance variable to Debugger class, since it *belongs*

to the Debugger and only *talks* to the PromptDialog.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@476 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2005-06-09 15:08:23 +00:00
parent f37ab61597
commit 90ed128060
11 changed files with 150 additions and 53 deletions

View File

@ -1,3 +1,20 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DCmdQuit.cxx,v 1.2 2005-06-09 15:08:21 stephena Exp $
//============================================================================
#include "bspf.hxx"
#include "DCmdQuit.hxx"

View File

@ -1,3 +1,20 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DCmdQuit.hxx,v 1.2 2005-06-09 15:08:21 stephena Exp $
//============================================================================
#ifndef DCMDQUIT_HXX
#define DCMDQUIT_HXX

View File

@ -1,3 +1,20 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DebuggerCommand.cxx,v 1.2 2005-06-09 15:08:22 stephena Exp $
//============================================================================
#include "bspf.hxx"
#include "DebuggerCommand.hxx"

View File

@ -1,3 +1,20 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DebuggerCommand.hxx,v 1.2 2005-06-09 15:08:22 stephena Exp $
//============================================================================
#ifndef DEBUGGER_COMMAND_HXX
#define DEBUGGER_COMMAND_HXX

View File

@ -1,14 +1,37 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DebuggerParser.cxx,v 1.2 2005-06-09 15:08:22 stephena Exp $
//============================================================================
#include "bspf.hxx"
#include "DebuggerParser.hxx"
#include "DebuggerCommand.hxx"
#include "DCmdQuit.hxx"
DebuggerParser::DebuggerParser() {
DebuggerParser::DebuggerParser()
: quitCmd(NULL)
{
done = false;
quitCmd = new DCmdQuit(this);
}
DebuggerParser::~DebuggerParser() {
delete quitCmd;
}
string DebuggerParser::currentAddress() {
return "currentAddress()";
}
@ -17,7 +40,7 @@ void DebuggerParser::setDone() {
done = true;
}
string DebuggerParser::run(string command) {
string DebuggerParser::run(const string& command) {
if(command == "quit") {
// TODO: use lookup table to determine which DebuggerCommand to run
return quitCmd->execute();

View File

@ -1,3 +1,20 @@
//============================================================================
//
// SSSS tt lll lll
// SS SS tt ll ll
// SS tttttt eeee ll ll aaaa
// SSSS tt ee ee ll ll aa
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: DebuggerParser.hxx,v 1.2 2005-06-09 15:08:22 stephena Exp $
//============================================================================
#ifndef DEBUGGER_PARSER_HXX
#define DEBUGGER_PARSER_HXX
@ -9,9 +26,11 @@ class DebuggerParser
{
public:
DebuggerParser();
~DebuggerParser();
string currentAddress();
void setDone();
string run(string command);
string run(const string& command);
private:
DebuggerCommand *quitCmd;

View File

@ -8,12 +8,12 @@
// SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa
//
// Copyright (c) 1995-2004 by Bradford W. Mott
// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team
//
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Console.hxx,v 1.31 2005-05-12 18:45:20 stephena Exp $
// $Id: Console.hxx,v 1.32 2005-06-09 15:08:22 stephena Exp $
//============================================================================
#ifndef CONSOLE_HXX
@ -35,7 +35,7 @@ class System;
This class represents the entire game console.
@author Bradford W. Mott
@version $Id: Console.hxx,v 1.31 2005-05-12 18:45:20 stephena Exp $
@version $Id: Console.hxx,v 1.32 2005-06-09 15:08:22 stephena Exp $
*/
class Console
{

View File

@ -13,26 +13,32 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Debugger.cxx,v 1.2 2005-06-03 17:52:06 stephena Exp $
// $Id: Debugger.cxx,v 1.3 2005-06-09 15:08:23 stephena Exp $
//============================================================================
#include "bspf.hxx"
#include "Version.hxx"
#include "OSystem.hxx"
#include "FrameBuffer.hxx"
#include "DebuggerDialog.hxx"
#include "bspf.hxx"
#include "DebuggerParser.hxx"
#include "Debugger.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Debugger::Debugger(OSystem* osystem)
: DialogContainer(osystem),
myConsole(NULL)
: DialogContainer(osystem),
myConsole(NULL),
myParser(NULL)
{
// Init parser
myParser = new DebuggerParser();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Debugger::~Debugger()
{
delete myParser;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -53,3 +59,9 @@ void Debugger::initializeVideo()
string title = string("Stella version ") + STELLA_VERSION + ": Debugger mode";
myOSystem->frameBuffer().initialize(title, kDebuggerWidth, kDebuggerHeight, false);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string Debugger::run(const string& command)
{
return myParser->run(command);
}

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: Debugger.hxx,v 1.2 2005-06-03 17:52:06 stephena Exp $
// $Id: Debugger.hxx,v 1.3 2005-06-09 15:08:23 stephena Exp $
//============================================================================
#ifndef DEBUGGER_HXX
@ -21,6 +21,7 @@
class OSystem;
class Console;
class DebuggerParser;
#include "DialogContainer.hxx"
@ -30,10 +31,11 @@ enum {
};
/**
The base dialog for the ROM launcher in Stella.
The base dialog for the ROM launcher in Stella. Also acts as the parent
for all debugging operations in Stella (parser, etc).
@author Stephen Anthony
@version $Id: Debugger.hxx,v 1.2 2005-06-03 17:52:06 stephena Exp $
@version $Id: Debugger.hxx,v 1.3 2005-06-09 15:08:23 stephena Exp $
*/
class Debugger : public DialogContainer
{
@ -59,10 +61,16 @@ class Debugger : public DialogContainer
*/
void initializeVideo();
/**
Run the debugger command and return the result.
*/
const string run(const string& command);
void setConsole(Console* console) { myConsole = console; }
private:
Console* myConsole;
DebuggerParser* myParser;
};
#endif

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: PromptDialog.cxx,v 1.6 2005-06-09 04:31:45 urchlay Exp $
// $Id: PromptDialog.cxx,v 1.7 2005-06-09 15:08:23 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -23,6 +23,7 @@
#include "FrameBuffer.hxx"
#include "EventHandler.hxx"
#include "Version.hxx"
#include "Debugger.hxx"
#include "PromptDialog.hxx"
@ -39,7 +40,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PromptDialog::PromptDialog(OSystem* osystem, DialogContainer* parent,
int x, int y, int w, int h)
: Dialog(osystem, parent, x, y, w, h)
: Dialog(osystem, parent, x, y, w, h)
{
_kConsoleCharWidth = instance()->consoleFont().getMaxCharWidth();
_kConsoleLineHeight = instance()->consoleFont().getFontHeight() + 2;
@ -59,10 +60,6 @@ PromptDialog::PromptDialog(OSystem* osystem, DialogContainer* parent,
_scrollBar = new ScrollBarWidget(this, _w - kScrollBarWidth - 1, 0, kScrollBarWidth, _h);
_scrollBar->setTarget(this);
// Init callback
_callbackProc = 0;
_callbackRefCon = 0;
// Init History
_historyIndex = 0;
_historyLine = 0;
@ -72,10 +69,6 @@ PromptDialog::PromptDialog(OSystem* osystem, DialogContainer* parent,
_promptStartPos = _promptEndPos = -1;
// Init parser (FIXME: should the parser be a class variable,
// instead of an instance variable?
parser = new DebuggerParser();
// Display greetings & prompt
string version = string("Stella version ") + STELLA_VERSION + "\n";
print(version.c_str());
@ -152,7 +145,6 @@ void PromptDialog::handleKeyDown(int ascii, int keycode, int modifiers)
assert(_promptEndPos >= _promptStartPos);
int len = _promptEndPos - _promptStartPos;
bool keepRunning = true;
if (len > 0)
{
@ -168,11 +160,8 @@ void PromptDialog::handleKeyDown(int ascii, int keycode, int modifiers)
// Add the input to the history
addToHistory(str);
// Pass it to the input callback, if any
if (_callbackProc)
keepRunning = (*_callbackProc)(this, str, _callbackRefCon);
print( parser->run(str) + "\n" );
// Pass the command to the debugger, and print the result
print( instance()->debugger().run(str) + "\n" );
// Get rid of the string buffer
delete [] str;

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//
// $Id: PromptDialog.hxx,v 1.4 2005-06-09 04:31:45 urchlay Exp $
// $Id: PromptDialog.hxx,v 1.5 2005-06-09 15:08:23 stephena Exp $
//
// Based on code from ScummVM - Scumm Interpreter
// Copyright (C) 2002-2004 The ScummVM project
@ -25,10 +25,10 @@
class CommandSender;
class DialogContainer;
class ScrollBarWidget;
class DebuggerParser;
#include <stdarg.h>
#include "Dialog.hxx"
#include "DebuggerParser.hxx"
enum {
kBufferSize = 32768,
@ -49,18 +49,6 @@ class PromptDialog : public Dialog
int vprintf(const char *format, va_list argptr);
#undef putchar
void putchar(int c);
typedef bool (*InputCallbackProc)(PromptDialog *console, const char *input, void *refCon);
typedef bool (*CompletionCallbackProc)(PromptDialog* console, const char *input, char*& completion, void *refCon);
void setInputCallback(InputCallbackProc proc, void *refCon) {
_callbackProc = proc;
_callbackRefCon = refCon;
}
void setCompletionCallback(CompletionCallbackProc proc, void *refCon) {
_completionCallbackProc = proc;
_completionCallbackRefCon = refCon;
}
protected:
inline char &buffer(int idx) { return _buffer[idx % kBufferSize]; }
@ -106,16 +94,6 @@ class PromptDialog : public Dialog
int _promptEndPos;
ScrollBarWidget* _scrollBar;
DebuggerParser* parser;
// The _callbackProc is called whenver a data line is entered
//
InputCallbackProc _callbackProc;
void *_callbackRefCon;
// _completionCallbackProc is called when tab is pressed
CompletionCallbackProc _completionCallbackProc;
void *_completionCallbackRefCon;
char _history[kHistorySize][kLineBufferSize];
int _historySize;