factor out an abstract base class for File

Summary:
This patch factors out File as an abstract base
class and moves most of its actual functionality into
a subclass called NativeFile.   In the next patch,
I'm going to be adding subclasses of File that
don't necessarily have any connection to actual OS files,
so they will not inherit from NativeFile.

This patch was split out as a prerequisite for
https://reviews.llvm.org/D68188

Reviewers: JDevlieghere, jasonmolenda, labath

Reviewed By: labath

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D68317

llvm-svn: 373564
This commit is contained in:
Lawrence D'Anna
2019-10-03 04:31:46 +00:00
parent 96898eb6a9
commit f913fd6eb0
17 changed files with 367 additions and 262 deletions

View File

@@ -1024,8 +1024,8 @@ FileUP PythonFile::GetUnderlyingFile() const {
// File object knows about that.
PythonString py_mode = GetAttributeValue("mode").AsType<PythonString>();
auto options = File::GetOptionsFromMode(py_mode.GetString());
auto file = std::make_unique<File>(PyObject_AsFileDescriptor(m_py_obj),
options, false);
auto file = std::unique_ptr<File>(
new NativeFile(PyObject_AsFileDescriptor(m_py_obj), options, false));
if (!file->IsValid())
return nullptr;
return file;