Use Host::File in lldb_private::StreamFile and other places to cleanup host
layer a bit more.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125149 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index e239c55..8a302fe 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -1102,24 +1102,27 @@
 }
 
 size_t
-CommandInterpreter::GetConfirmationInputReaderCallback (void *baton,
-                                    InputReader &reader,
-                                    lldb::InputReaderAction action,
-                                    const char *bytes,
-                                    size_t bytes_len)
+CommandInterpreter::GetConfirmationInputReaderCallback 
+(
+    void *baton,
+    InputReader &reader,
+    lldb::InputReaderAction action,
+    const char *bytes,
+    size_t bytes_len
+)
 {
-    FILE *out_fh = reader.GetDebugger().GetOutputFileHandle();
+    File &out_file = reader.GetDebugger().GetOutputFile();
     bool *response_ptr = (bool *) baton;
     
     switch (action)
     {
     case eInputReaderActivate:
-        if (out_fh)
+        if (out_file.IsValid())
         {
             if (reader.GetPrompt())
             {
-                ::fprintf (out_fh, "%s", reader.GetPrompt());
-                ::fflush (out_fh);
+                out_file.Printf ("%s", reader.GetPrompt());
+                out_file.Flush ();
             }
         }
         break;
@@ -1128,10 +1131,10 @@
         break;
 
     case eInputReaderReactivate:
-        if (out_fh && reader.GetPrompt())
+        if (out_file.IsValid() && reader.GetPrompt())
         {
-            ::fprintf (out_fh, "%s", reader.GetPrompt());
-            ::fflush (out_fh);
+            out_file.Printf ("%s", reader.GetPrompt());
+            out_file.Flush ();
         }
         break;
 
@@ -1152,11 +1155,10 @@
         }
         else
         {
-            if (out_fh && !reader.IsDone() && reader.GetPrompt())
+            if (out_file.IsValid() && !reader.IsDone() && reader.GetPrompt())
             {
-                ::fprintf (out_fh, "Please answer \"y\" or \"n\"\n");
-                ::fprintf (out_fh, "%s", reader.GetPrompt());
-                ::fflush (out_fh);
+                out_file.Printf ("Please answer \"y\" or \"n\"\n%s", reader.GetPrompt());
+                out_file.Flush ();
             }
         }
         break;
diff --git a/source/Interpreter/ScriptInterpreterPython.cpp b/source/Interpreter/ScriptInterpreterPython.cpp
index 88f4223..54d4606 100644
--- a/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/source/Interpreter/ScriptInterpreterPython.cpp
@@ -198,7 +198,7 @@
     ScriptInterpreter (interpreter, eScriptLanguagePython),
     m_embedded_python_pty (),
     m_embedded_thread_input_reader_sp (),
-    m_dbg_stdout (interpreter.GetDebugger().GetOutputFileHandle()),
+    m_dbg_stdout (interpreter.GetDebugger().GetOutputFile().GetStream()),
     m_new_sysout (NULL),
     m_dictionary_name (interpreter.GetDebugger().GetInstanceName().AsCString()),
     m_terminal_state (),
@@ -570,24 +570,17 @@
     if (script_interpreter->m_script_lang != eScriptLanguagePython)
         return 0;
     
-    FILE *out_fh = reader.GetDebugger().GetOutputFileHandle ();
-    if (out_fh == NULL)
-        out_fh = stdout;
+    File &out_file = reader.GetDebugger().GetOutputFile();
 
     switch (notification)
     {
     case eInputReaderActivate:
         {
-            if (out_fh)
-            {
-                ::fprintf (out_fh, "Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.\n");
-            }
+            out_file.Printf ("Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.\n");
+
             // Save terminal settings if we can
-            int input_fd;
-            FILE *input_fh = reader.GetDebugger().GetInputFileHandle();
-            if (input_fh != NULL)
-                input_fd = ::fileno (input_fh);
-            else
+            int input_fd = reader.GetDebugger().GetInputFile().GetDescriptor();
+            if (input_fd == File::kInvalidDescriptor)
                 input_fd = STDIN_FILENO;
 
             script_interpreter->SaveTerminalState(input_fd);
@@ -596,7 +589,7 @@
             {
                 while (!GetPythonLock(1)) 
                 {
-                    ::fprintf (out_fh, "Python interpreter locked on another thread; waiting to acquire lock...\n");
+                    out_file.Printf ("Python interpreter locked on another thread; waiting to acquire lock...\n");
                 }
                 script_interpreter->EnterSession ();
                 ReleasePythonLock();
@@ -718,7 +711,7 @@
     // try to embed a running interpreter loop inside the already running Python interpreter loop, so we won't
     // do it.
 
-    if (debugger.GetInputFileHandle() == NULL)
+    if (!debugger.GetInputFile().IsValid())
         return;
 
     InputReaderSP reader_sp (new InputReader(debugger));
@@ -1035,21 +1028,19 @@
 {
   static StringList commands_in_progress;
 
-    FILE *out_fh = reader.GetDebugger().GetOutputFileHandle();
-    if (out_fh == NULL)
-        out_fh = stdout;
+    File &out_file = reader.GetDebugger().GetOutputFile();
 
     switch (notification)
     {
     case eInputReaderActivate:
         {
             commands_in_progress.Clear();
-            if (out_fh)
+            if (out_file.IsValid())
             {
-                ::fprintf (out_fh, "%s\n", g_reader_instructions);
+                out_file.Printf ("%s\n", g_reader_instructions);
                 if (reader.GetPrompt())
-                    ::fprintf (out_fh, "%s", reader.GetPrompt());
-                ::fflush (out_fh);
+                    out_file.Printf ("%s", reader.GetPrompt());
+                out_file.Flush ();
             }
         }
         break;
@@ -1058,10 +1049,10 @@
         break;
 
     case eInputReaderReactivate:
-        if (reader.GetPrompt() && out_fh)
+        if (reader.GetPrompt() && out_file.IsValid())
         {
-            ::fprintf (out_fh, "%s", reader.GetPrompt());
-            ::fflush (out_fh);
+            out_file.Printf ("%s", reader.GetPrompt());
+            out_file.Flush ();
         }
         break;
 
@@ -1069,10 +1060,10 @@
         {
             std::string temp_string (bytes, bytes_len);
             commands_in_progress.AppendString (temp_string.c_str());
-            if (out_fh && !reader.IsDone() && reader.GetPrompt())
+            if (out_file.IsValid() && !reader.IsDone() && reader.GetPrompt())
             {
-                ::fprintf (out_fh, "%s", reader.GetPrompt());
-                ::fflush (out_fh);
+                out_file.Printf ("%s", reader.GetPrompt());
+                out_file.Flush ();
             }
         }
         break;
@@ -1108,7 +1099,7 @@
                         }
                     }
                     else
-                        ::fprintf (out_fh, "Warning: No command attached to breakpoint.\n");
+                        out_file.Printf ("Warning: No command attached to breakpoint.\n");
                 }
                 else
                 {