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".



git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@158235 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectPlatform.cpp b/source/Commands/CommandObjectPlatform.cpp
index 7d99e71..7487f8a 100644
--- a/source/Commands/CommandObjectPlatform.cpp
+++ b/source/Commands/CommandObjectPlatform.cpp
@@ -31,15 +31,15 @@
 //----------------------------------------------------------------------
 // "platform select <platform-name>"
 //----------------------------------------------------------------------
-class CommandObjectPlatformSelect : public CommandObject
+class CommandObjectPlatformSelect : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformSelect (CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "platform select",
-                       "Create a platform if needed and select it as the current platform.",
-                       "platform select <platform-name>",
-                       0),
+        CommandObjectParsed (interpreter, 
+                             "platform select",
+                             "Create a platform if needed and select it as the current platform.",
+                             "platform select <platform-name>",
+                             0),
         m_option_group (interpreter),
         m_platform_options (false) // Don't include the "--platform" option by passing false
     {
@@ -52,8 +52,37 @@
     {
     }
 
+    virtual int
+    HandleCompletion (Args &input,
+                      int &cursor_index,
+                      int &cursor_char_position,
+                      int match_start_point,
+                      int max_return_elements,
+                      bool &word_complete,
+                      StringList &matches)
+    {
+        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
+        completion_str.erase (cursor_char_position);
+        
+        CommandCompletions::PlatformPluginNames (m_interpreter, 
+                                                 completion_str.c_str(),
+                                                 match_start_point,
+                                                 max_return_elements,
+                                                 NULL,
+                                                 word_complete,
+                                                 matches);
+        return matches.GetSize();
+    }
+
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_option_group;
+    }
+
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         if (args.GetArgumentCount() == 1)
         {
@@ -89,37 +118,7 @@
         }
         return result.Succeeded();
     }
-    
-    
-    virtual int
-    HandleCompletion (Args &input,
-                      int &cursor_index,
-                      int &cursor_char_position,
-                      int match_start_point,
-                      int max_return_elements,
-                      bool &word_complete,
-                      StringList &matches)
-    {
-        std::string completion_str (input.GetArgumentAtIndex(cursor_index));
-        completion_str.erase (cursor_char_position);
-        
-        CommandCompletions::PlatformPluginNames (m_interpreter, 
-                                                 completion_str.c_str(),
-                                                 match_start_point,
-                                                 max_return_elements,
-                                                 NULL,
-                                                 word_complete,
-                                                 matches);
-        return matches.GetSize();
-    }
 
-    virtual Options *
-    GetOptions ()
-    {
-        return &m_option_group;
-    }
-
-protected:
     OptionGroupOptions m_option_group;
     OptionGroupPlatform m_platform_options;
 };
@@ -127,15 +126,15 @@
 //----------------------------------------------------------------------
 // "platform list"
 //----------------------------------------------------------------------
-class CommandObjectPlatformList : public CommandObject
+class CommandObjectPlatformList : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformList (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "platform list",
-                       "List all platforms that are available.",
-                       NULL,
-                       0)
+        CommandObjectParsed (interpreter,
+                             "platform list",
+                             "List all platforms that are available.",
+                             NULL,
+                             0)
     {
     }
 
@@ -144,8 +143,9 @@
     {
     }
 
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         Stream &ostrm = result.GetOutputStream();
         ostrm.Printf("Available platforms:\n");
@@ -181,15 +181,15 @@
 //----------------------------------------------------------------------
 // "platform status"
 //----------------------------------------------------------------------
-class CommandObjectPlatformStatus : public CommandObject
+class CommandObjectPlatformStatus : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformStatus (CommandInterpreter &interpreter) :
-        CommandObject (interpreter,
-                       "platform status",
-                       "Display status for the currently selected platform.",
-                       NULL,
-                       0)
+        CommandObjectParsed (interpreter,
+                             "platform status",
+                             "Display status for the currently selected platform.",
+                             NULL,
+                             0)
     {
     }
 
@@ -198,8 +198,9 @@
     {
     }
 
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         Stream &ostrm = result.GetOutputStream();      
         
@@ -221,15 +222,15 @@
 //----------------------------------------------------------------------
 // "platform connect <connect-url>"
 //----------------------------------------------------------------------
-class CommandObjectPlatformConnect : public CommandObject
+class CommandObjectPlatformConnect : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformConnect (CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "platform connect",
-                       "Connect a platform by name to be the currently selected platform.",
-                       "platform connect <connect-url>",
-                       0)
+        CommandObjectParsed (interpreter, 
+                             "platform connect",
+                             "Connect a platform by name to be the currently selected platform.",
+                             "platform connect <connect-url>",
+                             0)
     {
     }
 
@@ -238,8 +239,9 @@
     {
     }
 
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         Stream &ostrm = result.GetOutputStream();      
         
@@ -270,15 +272,15 @@
 //----------------------------------------------------------------------
 // "platform disconnect"
 //----------------------------------------------------------------------
-class CommandObjectPlatformDisconnect : public CommandObject
+class CommandObjectPlatformDisconnect : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformDisconnect (CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "platform disconnect",
-                       "Disconnect a platform by name to be the currently selected platform.",
-                       "platform disconnect",
-                       0)
+        CommandObjectParsed (interpreter, 
+                             "platform disconnect",
+                             "Disconnect a platform by name to be the currently selected platform.",
+                             "platform disconnect",
+                             0)
     {
     }
 
@@ -287,8 +289,9 @@
     {
     }
 
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
         if (platform_sp)
@@ -347,15 +350,15 @@
 //----------------------------------------------------------------------
 // "platform process launch"
 //----------------------------------------------------------------------
-class CommandObjectPlatformProcessLaunch : public CommandObject
+class CommandObjectPlatformProcessLaunch : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformProcessLaunch (CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "platform process launch",
-                       "Launch a new process on a remote platform.",
-                       "platform process launch program",
-                       0),
+        CommandObjectParsed (interpreter, 
+                             "platform process launch",
+                             "Launch a new process on a remote platform.",
+                             "platform process launch program",
+                             0),
         m_options (interpreter)
     {
     }
@@ -365,8 +368,15 @@
     {
     }
     
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+    
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
         
@@ -453,12 +463,6 @@
         return result.Succeeded();
     }
     
-    virtual Options *
-    GetOptions ()
-    {
-        return &m_options;
-    }
-    
 protected:
     ProcessLaunchCommandOptions m_options;
 };
@@ -468,15 +472,15 @@
 //----------------------------------------------------------------------
 // "platform process list"
 //----------------------------------------------------------------------
-class CommandObjectPlatformProcessList : public CommandObject
+class CommandObjectPlatformProcessList : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformProcessList (CommandInterpreter &interpreter) :
-        CommandObject (interpreter, 
-                       "platform process list",
-                       "List processes on a remote platform by name, pid, or many other matching attributes.",
-                       "platform process list",
-                       0),
+        CommandObjectParsed (interpreter, 
+                             "platform process list",
+                             "List processes on a remote platform by name, pid, or many other matching attributes.",
+                             "platform process list",
+                             0),
         m_options (interpreter)
     {
     }
@@ -486,8 +490,15 @@
     {
     }
     
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+    
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
         
@@ -581,14 +592,6 @@
         return result.Succeeded();
     }
     
-    virtual Options *
-    GetOptions ()
-    {
-        return &m_options;
-    }
-    
-protected:
-    
     class CommandOptions : public Options
     {
     public:
@@ -744,15 +747,15 @@
 //----------------------------------------------------------------------
 // "platform process info"
 //----------------------------------------------------------------------
-class CommandObjectPlatformProcessInfo : public CommandObject
+class CommandObjectPlatformProcessInfo : public CommandObjectParsed
 {
 public:
     CommandObjectPlatformProcessInfo (CommandInterpreter &interpreter) :
-    CommandObject (interpreter, 
-                   "platform process info",
-                   "Get detailed information for one or more process by process ID.",
-                   "platform process info <pid> [<pid> <pid> ...]",
-                   0)
+    CommandObjectParsed (interpreter, 
+                         "platform process info",
+                         "Get detailed information for one or more process by process ID.",
+                         "platform process info <pid> [<pid> <pid> ...]",
+                         0)
     {
         CommandArgumentEntry arg;
         CommandArgumentData pid_args;
@@ -773,8 +776,9 @@
     {
     }
     
+protected:
     virtual bool
-    Execute (Args& args, CommandReturnObject &result)
+    DoExecute (Args& args, CommandReturnObject &result)
     {
         PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
         if (platform_sp)
@@ -872,15 +876,15 @@
 };
 
 
-class CommandObjectPlatformShell : public CommandObject
+class CommandObjectPlatformShell : public CommandObjectRaw
 {
 public:
     CommandObjectPlatformShell (CommandInterpreter &interpreter) :
-    CommandObject (interpreter, 
-                   "platform shell",
-                   "Run a shell command on a the selected platform.",
-                   "platform shell <shell-command>",
-                   0)
+        CommandObjectRaw (interpreter, 
+                         "platform shell",
+                         "Run a shell command on a the selected platform.",
+                         "platform shell <shell-command>",
+                         0)
     {
     }
     
@@ -889,18 +893,9 @@
     {
     }
     
+protected:
     virtual bool
-    Execute (Args& command,
-             CommandReturnObject &result)
-    {
-        return false;
-    }
-    
-    virtual bool
-    WantsRawCommandString() { return true; }    
-
-    bool
-    ExecuteRawCommandString (const char *raw_command_line, CommandReturnObject &result)
+    DoExecute (const char *raw_command_line, CommandReturnObject &result)
     {
         // TODO: Implement "Platform::RunShellCommand()" and switch over to using
         // the current platform when it is in the interface. 
@@ -936,8 +931,6 @@
         }
         return true;
     }
-
-protected:
 };
 
 //----------------------------------------------------------------------