Files
llvm/lldb/source/Commands/CommandObjectCrossref.cpp
Jim Ingham 5a98841673 Make raw & parsed commands subclasses of CommandObject rather than having the raw version implement an
Execute which was never going to get run and another ExecuteRawCommandString.  Took the knowledge of how
to prepare raw & parsed commands out of CommandInterpreter and put it in CommandObject where it belongs.

Also took all the cases where there were the subcommands of Multiword commands declared in the .h file for
the overall command and moved them into the .cpp file.

Made the CommandObject flags work for raw as well as parsed commands.

Made "expr" use the flags so that it requires you to be paused to run "expr".

llvm-svn: 158235
2012-06-08 21:56:10 +00:00

89 lines
2.3 KiB
C++

//===-- CommandObjectCrossref.cpp -------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Interpreter/CommandObjectCrossref.h"
// C Includes
// C++ Includes
// Other libraries and framework includes
// Project includes
#include "lldb/Interpreter/CommandReturnObject.h"
using namespace lldb;
using namespace lldb_private;
//-------------------------------------------------------------------------
// CommandObjectCrossref
//-------------------------------------------------------------------------
CommandObjectCrossref::CommandObjectCrossref
(
CommandInterpreter &interpreter,
const char *name,
const char *help,
const char *syntax
) :
CommandObjectParsed (interpreter, name, help, syntax),
m_crossref_object_types()
{
}
CommandObjectCrossref::~CommandObjectCrossref ()
{
}
bool
CommandObjectCrossref::DoExecute (Args& command, CommandReturnObject &result)
{
if (m_crossref_object_types.GetArgumentCount() == 0)
{
result.AppendErrorWithFormat ("There are no objects for which you can call '%s'.\n", GetCommandName());
result.SetStatus (eReturnStatusFailed);
}
else
{
GenerateHelpText (result);
}
return result.Succeeded();
}
void
CommandObjectCrossref::AddObject (const char *obj_name)
{
m_crossref_object_types.AppendArgument (obj_name);
}
const char **
CommandObjectCrossref::GetObjectTypes () const
{
return m_crossref_object_types.GetConstArgumentVector();
}
void
CommandObjectCrossref::GenerateHelpText (CommandReturnObject &result)
{
result.AppendMessage ("This command can be called on the following types of objects:");
const size_t count = m_crossref_object_types.GetArgumentCount();
for (size_t i = 0; i < count; ++i)
{
const char *obj_name = m_crossref_object_types.GetArgumentAtIndex(i);
result.AppendMessageWithFormat (" %s (e.g. '%s %s')\n", obj_name,
obj_name, GetCommandName());
}
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
bool
CommandObjectCrossref::IsCrossRefObject ()
{
return true;
}