forked from OSchip/llvm-project
Add a variant of the CommandOverrideCallback that takes a
CommandReturnObject. Otherwise, all the overridden command can do is say it overrode the command, not say what it did... Also removed the duplicate definition of CommandOverrideCallback from the private interfaces. Now to figure out how to get this through the SB API's... <rdar://problem/17911629> llvm-svn: 214938
This commit is contained in:
parent
cabf54a313
commit
3b652621a9
|
@ -460,25 +460,37 @@ public:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
CommandOverrideCallback
|
||||
GetOverrideCallback () const
|
||||
bool
|
||||
HasOverrideCallback () const
|
||||
{
|
||||
return m_command_override_callback;
|
||||
return m_command_override_callback || m_deprecated_command_override_callback;
|
||||
}
|
||||
|
||||
void *
|
||||
GetOverrideCallbackBaton () const
|
||||
{
|
||||
return m_command_override_baton;
|
||||
}
|
||||
|
||||
void
|
||||
SetOverrideCallback (CommandOverrideCallback callback, void *baton)
|
||||
SetOverrideCallback (lldb::CommandOverrideCallback callback, void *baton)
|
||||
{
|
||||
m_deprecated_command_override_callback = callback;
|
||||
m_command_override_baton = baton;
|
||||
}
|
||||
|
||||
void
|
||||
SetOverrideCallback (lldb::CommandOverrideCallbackWithResult callback, void *baton)
|
||||
{
|
||||
m_command_override_callback = callback;
|
||||
m_command_override_baton = baton;
|
||||
}
|
||||
|
||||
bool
|
||||
InvokeOverrideCallback (const char **argv, CommandReturnObject &result)
|
||||
{
|
||||
if (m_command_override_callback)
|
||||
return m_command_override_callback(m_command_override_baton, argv, result);
|
||||
else if (m_deprecated_command_override_callback)
|
||||
return m_deprecated_command_override_callback(m_command_override_baton, argv);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool
|
||||
Execute (const char *args_string, CommandReturnObject &result) = 0;
|
||||
|
||||
|
@ -540,7 +552,8 @@ protected:
|
|||
bool m_is_alias;
|
||||
Flags m_flags;
|
||||
std::vector<CommandArgumentEntry> m_arguments;
|
||||
CommandOverrideCallback m_command_override_callback;
|
||||
lldb::CommandOverrideCallback m_deprecated_command_override_callback;
|
||||
lldb::CommandOverrideCallbackWithResult m_command_override_callback;
|
||||
void * m_command_override_baton;
|
||||
|
||||
// Helper function to populate IDs or ID ranges as the command argument data
|
||||
|
|
|
@ -40,7 +40,6 @@ namespace lldb_private
|
|||
typedef lldb::ThreadPlanSP (*ThreadPlanStepFromHereCallback) (ThreadPlan *current_plan, Flags &flags, lldb::FrameComparison operation, void *baton);
|
||||
typedef UnwindAssembly* (*UnwindAssemblyCreateInstance) (const ArchSpec &arch);
|
||||
typedef int (*ComparisonFunction)(const void *, const void *);
|
||||
typedef bool (*CommandOverrideCallback)(void *baton, const char **argv);
|
||||
typedef void (*DebuggerInitializeCallback)(Debugger &debugger);
|
||||
|
||||
} // namespace lldb_private
|
||||
|
|
|
@ -81,6 +81,9 @@ namespace lldb
|
|||
{
|
||||
typedef void (*LogOutputCallback) (const char *, void *baton);
|
||||
typedef bool (*CommandOverrideCallback)(void *baton, const char **argv);
|
||||
typedef bool (*CommandOverrideCallbackWithResult)(void *baton,
|
||||
const char **argv,
|
||||
lldb_private::CommandReturnObject &result);
|
||||
typedef bool (*ExpressionCancelCallback) (ExpressionEvaluationPhase phase, void *baton);
|
||||
}
|
||||
|
||||
|
|
|
@ -1005,14 +1005,13 @@ CommandObject::GetArgumentDescriptionAsCString (const lldb::CommandArgumentType
|
|||
bool
|
||||
CommandObjectParsed::Execute (const char *args_string, CommandReturnObject &result)
|
||||
{
|
||||
CommandOverrideCallback command_callback = GetOverrideCallback();
|
||||
bool handled = false;
|
||||
Args cmd_args (args_string);
|
||||
if (command_callback)
|
||||
if (HasOverrideCallback())
|
||||
{
|
||||
Args full_args (GetCommandName ());
|
||||
full_args.AppendArguments(cmd_args);
|
||||
handled = command_callback (GetOverrideCallbackBaton(), full_args.GetConstArgumentVector());
|
||||
handled = InvokeOverrideCallback (full_args.GetConstArgumentVector(), result);
|
||||
}
|
||||
if (!handled)
|
||||
{
|
||||
|
@ -1040,16 +1039,15 @@ CommandObjectParsed::Execute (const char *args_string, CommandReturnObject &resu
|
|||
bool
|
||||
CommandObjectRaw::Execute (const char *args_string, CommandReturnObject &result)
|
||||
{
|
||||
CommandOverrideCallback command_callback = GetOverrideCallback();
|
||||
bool handled = false;
|
||||
if (command_callback)
|
||||
if (HasOverrideCallback())
|
||||
{
|
||||
std::string full_command (GetCommandName ());
|
||||
full_command += ' ';
|
||||
full_command += args_string;
|
||||
const char *argv[2] = { nullptr, nullptr };
|
||||
argv[0] = full_command.c_str();
|
||||
handled = command_callback (GetOverrideCallbackBaton(), argv);
|
||||
handled = InvokeOverrideCallback (argv, result);
|
||||
}
|
||||
if (!handled)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue