From a6de32b06c65d62f585d77eb77870f171a5f0e3b Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 23 Jul 2012 23:10:54 +0200 Subject: [PATCH] Debugger CLI: Pull QuitCommand out of CommandLineUserInterface --- src/apps/debugger/Jamfile | 1 + .../user_interface/cli/CliQuitCommand.cpp | 25 +++++++++++++++++ .../user_interface/cli/CliQuitCommand.h | 20 ++++++++++++++ .../cli/CommandLineUserInterface.cpp | 27 ++----------------- .../cli/CommandLineUserInterface.h | 2 -- 5 files changed, 48 insertions(+), 27 deletions(-) create mode 100644 src/apps/debugger/user_interface/cli/CliQuitCommand.cpp create mode 100644 src/apps/debugger/user_interface/cli/CliQuitCommand.h diff --git a/src/apps/debugger/Jamfile b/src/apps/debugger/Jamfile index 0f626b57cd..907865cbe3 100644 --- a/src/apps/debugger/Jamfile +++ b/src/apps/debugger/Jamfile @@ -175,6 +175,7 @@ Application Debugger : # user_interface/cli CliCommand.cpp CliContext.cpp + CliQuitCommand.cpp CommandLineUserInterface.cpp # user_interface/gui diff --git a/src/apps/debugger/user_interface/cli/CliQuitCommand.cpp b/src/apps/debugger/user_interface/cli/CliQuitCommand.cpp new file mode 100644 index 0000000000..d3a8cb83f7 --- /dev/null +++ b/src/apps/debugger/user_interface/cli/CliQuitCommand.cpp @@ -0,0 +1,25 @@ +/* + * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + + +#include "CliQuitCommand.h" + +#include "CliContext.h" + + +CliQuitCommand::CliQuitCommand() + : + CliCommand("quit Debugger", + "%s\n" + "Quits Debugger.") +{ +} + + +void +CliQuitCommand::Execute(int argc, const char* const* argv, CliContext& context) +{ + context.QuitSession(); +} diff --git a/src/apps/debugger/user_interface/cli/CliQuitCommand.h b/src/apps/debugger/user_interface/cli/CliQuitCommand.h new file mode 100644 index 0000000000..6f8f68445c --- /dev/null +++ b/src/apps/debugger/user_interface/cli/CliQuitCommand.h @@ -0,0 +1,20 @@ +/* + * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef CLI_QUIT_COMMAND_H +#define CLI_QUIT_COMMAND_H + + +#include "CliCommand.h" + + +class CliQuitCommand : public CliCommand { +public: + CliQuitCommand(); + virtual void Execute(int argc, const char* const* argv, + CliContext& context); +}; + + +#endif // CLI_QUIT_COMMAND_H diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp index 0be51f9d0f..0cb77f6a9e 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.cpp @@ -18,8 +18,8 @@ #include #include -#include "CliCommand.h" #include "CliContext.h" +#include "CliQuitCommand.h" // #pragma mark - CommandEntry @@ -72,29 +72,6 @@ private: }; -// #pragma mark - HelpCommand - - -struct CommandLineUserInterface::QuitCommand : CliCommand { - QuitCommand(CommandLineUserInterface* userInterface) - : - CliCommand("quit Debugger", - "%s\n" - "Quits Debugger."), - fUserInterface(userInterface) - { - } - - virtual void Execute(int argc, const char* const* argv, CliContext& context) - { - fUserInterface->fListener->UserInterfaceQuitRequested(); - } - -private: - CommandLineUserInterface* fUserInterface; -}; - - // #pragma mark - CommandLineUserInterface @@ -266,7 +243,7 @@ status_t CommandLineUserInterface::_RegisterCommands() { if (_RegisterCommand("help", new(std::nothrow) HelpCommand(this)) && - _RegisterCommand("quit", new(std::nothrow) QuitCommand(this))) { + _RegisterCommand("quit", new(std::nothrow) CliQuitCommand)) { return B_OK; } diff --git a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h index 35899c0871..7f0c0acbf2 100644 --- a/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h +++ b/src/apps/debugger/user_interface/cli/CommandLineUserInterface.h @@ -51,11 +51,9 @@ private: typedef BObjectList CommandList; struct HelpCommand; - struct QuitCommand; // GCC 2 support friend struct HelpCommand; - friend struct QuitCommand; private: static status_t _InputLoopEntry(void* data);