1 //===-- SBCommandInterpreter.h ----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLDB_SBCommandInterpreter_h_
11 #define LLDB_SBCommandInterpreter_h_
13 #include "lldb/API/SBDefines.h"
14 #include "lldb/API/SBDebugger.h"
18 class SBCommandInterpreter
23 eBroadcastBitThreadShouldExit = (1 << 0),
24 eBroadcastBitResetPrompt = (1 << 1),
25 eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
26 eBroadcastBitAsynchronousOutputData = (1 << 3),
27 eBroadcastBitAsynchronousErrorData = (1 << 4)
30 SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs);
32 const lldb::SBCommandInterpreter &
33 operator = (const lldb::SBCommandInterpreter &rhs);
35 ~SBCommandInterpreter ();
38 GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type);
41 GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type);
47 CommandExists (const char *cmd);
50 AliasExists (const char *cmd);
56 GetBroadcasterClass ();
74 AddMultiwordCommand (const char* name, const char* help);
77 AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, const char* help);
80 SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
83 SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result);
86 HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false);
88 // The pointer based interface is not useful in SWIG, since the cursor & last_char arguments are string pointers INTO current_line
89 // and you can't do that in a scripting language interface in general...
91 // In either case, the way this works is that the you give it a line and cursor position in the line. The function
92 // will return the number of completions. The matches list will contain number_of_completions + 1 elements. The first
93 // element is the common substring after the cursor position for all the matches. The rest of the elements are the
94 // matches. The first element is useful if you are emulating the common shell behavior where the tab completes
95 // to the string that is common among all the matches, then you should first check if the first element is non-empty,
96 // and if so just insert it and move the cursor to the end of the insertion. The next tab will return an empty
97 // common substring, and a list of choices (if any), at which point you should display the choices and let the user
98 // type further to disambiguate.
101 HandleCompletion (const char *current_line,
103 const char *last_char,
104 int match_start_point,
105 int max_return_elements,
106 lldb::SBStringList &matches);
109 HandleCompletion (const char *current_line,
111 int match_start_point,
112 int max_return_elements,
113 lldb::SBStringList &matches);
115 // Catch commands before they execute by registering a callback that will
116 // get called when the command gets executed. This allows GUI or command
117 // line interfaces to intercept a command and stop it from happening
119 SetCommandOverrideCallback (const char *command_name,
120 lldb::CommandOverrideCallback callback,
123 SBCommandInterpreter (lldb_private::CommandInterpreter *interpreter_ptr = NULL); // Access using SBDebugger::GetCommandInterpreter();
127 lldb_private::CommandInterpreter &
130 lldb_private::CommandInterpreter *
134 reset (lldb_private::CommandInterpreter *);
136 friend class SBDebugger;
141 lldb_private::CommandInterpreter *m_opaque_ptr;
144 class SBCommandPluginInterface
148 DoExecute (lldb::SBDebugger debugger,
150 lldb::SBCommandReturnObject &result)
156 ~SBCommandPluginInterface ()
176 AddMultiwordCommand (const char* name, const char* help = NULL);
179 AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help = NULL);
183 friend class SBDebugger;
184 friend class SBCommandInterpreter;
186 SBCommand (lldb::CommandObjectSP cmd_sp);
188 lldb::CommandObjectSP m_opaque_sp;
193 #endif // LLDB_SBCommandInterpreter_h_