From 5750453020926ce270aee38bd5eb7f0ff3467237 Mon Sep 17 00:00:00 2001 From: Lawrence D'Anna Date: Thu, 3 Oct 2019 04:01:07 +0000 Subject: new api class: SBFile Summary: SBFile is a scripting API wrapper for lldb_private::File This is the first step in a project to enable arbitrary python io.IOBase file objects -- including those that override the read() and write() methods -- to be used as the main debugger IOStreams. Currently this is impossible because python file objects must first be converted into FILE* streams by SWIG in order to be passed into the debugger. full prototype: https://github.com/smoofra/llvm-project/tree/files Reviewers: JDevlieghere, jasonmolenda, zturner, jingham, labath Reviewed By: labath Subscribers: labath, mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67793 llvm-svn: 373562 --- .../ScriptInterpreter/Python/PythonDataObjects.cpp | 19 +------------------ .../ScriptInterpreter/Python/PythonDataObjects.h | 2 -- 2 files changed, 1 insertion(+), 20 deletions(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index 6d9a74d39cc..20745d42e7a 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -949,7 +949,6 @@ PythonFile::PythonFile() : PythonObject() {} PythonFile::PythonFile(File &file, const char *mode) { Reset(file, mode); } - PythonFile::PythonFile(PyRefType type, PyObject *o) { Reset(type, o); } PythonFile::~PythonFile() {} @@ -1014,22 +1013,6 @@ void PythonFile::Reset(File &file, const char *mode) { #endif } -uint32_t PythonFile::GetOptionsFromMode(llvm::StringRef mode) { - if (mode.empty()) - return 0; - - return llvm::StringSwitch(mode.str()) - .Case("r", File::eOpenOptionRead) - .Case("w", File::eOpenOptionWrite) - .Case("a", File::eOpenOptionWrite | File::eOpenOptionAppend | - File::eOpenOptionCanCreate) - .Case("r+", File::eOpenOptionRead | File::eOpenOptionWrite) - .Case("w+", File::eOpenOptionRead | File::eOpenOptionWrite | - File::eOpenOptionCanCreate | File::eOpenOptionTruncate) - .Case("a+", File::eOpenOptionRead | File::eOpenOptionWrite | - File::eOpenOptionAppend | File::eOpenOptionCanCreate) - .Default(0); -} FileUP PythonFile::GetUnderlyingFile() const { if (!IsValid()) @@ -1038,7 +1021,7 @@ FileUP PythonFile::GetUnderlyingFile() const { // We don't own the file descriptor returned by this function, make sure the // File object knows about that. PythonString py_mode = GetAttributeValue("mode").AsType(); - auto options = PythonFile::GetOptionsFromMode(py_mode.GetString()); + auto options = File::GetOptionsFromMode(py_mode.GetString()); auto file = std::make_unique(PyObject_AsFileDescriptor(m_py_obj), options, false); if (!file->IsValid()) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h index 14484d93148..8fd2be1460f 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h @@ -466,8 +466,6 @@ public: void Reset(PyRefType type, PyObject *py_obj) override; void Reset(File &file, const char *mode); - static uint32_t GetOptionsFromMode(llvm::StringRef mode); - lldb::FileUP GetUnderlyingFile() const; }; -- cgit v1.2.3