summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
diff options
context:
space:
mode:
authorLawrence D'Anna <lawrence_danna@apple.com>2019-10-14 20:15:34 +0000
committerLawrence D'Anna <lawrence_danna@apple.com>2019-10-14 20:15:34 +0000
commit62c9fe4273e8f2a0f3f0f4c86de3a90668532354 (patch)
tree50c6f7a76ff044c13465b9ad7583558d6c275e1d /lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
parent322f12afc3673fc868899857b069ce59084dba05 (diff)
downloadbcm5719-llvm-62c9fe4273e8f2a0f3f0f4c86de3a90668532354.tar.gz
bcm5719-llvm-62c9fe4273e8f2a0f3f0f4c86de3a90668532354.zip
uint32_t options -> File::OpenOptions options
Summary: This patch re-types everywhere that passes a File::OpenOptions as a uint32_t so it actually uses File::OpenOptions. It also converts some OpenOptions related functions that fail by returning 0 or NULL into llvm::Expected split off from https://reviews.llvm.org/D68737 Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68853 llvm-svn: 374817
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp')
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
index 5346e3f5914..c3588f6ec33 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -1090,8 +1090,12 @@ 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::unique_ptr<File>(
- new NativeFile(PyObject_AsFileDescriptor(m_py_obj), options, false));
+ if (!options) {
+ llvm::consumeError(options.takeError());
+ return nullptr;
+ }
+ auto file = std::unique_ptr<File>(new NativeFile(
+ PyObject_AsFileDescriptor(m_py_obj), options.get(), false));
if (!file->IsValid())
return nullptr;
return file;
@@ -1165,9 +1169,10 @@ std::error_code PythonException::convertToErrorCode() const {
char PythonException::ID = 0;
-llvm::Expected<uint32_t> GetOptionsForPyObject(const PythonObject &obj) {
- uint32_t options = 0;
+llvm::Expected<File::OpenOptions>
+GetOptionsForPyObject(const PythonObject &obj) {
#if PY_MAJOR_VERSION >= 3
+ auto options = File::OpenOptions(0);
auto readable = As<bool>(obj.CallMethod("readable"));
if (!readable)
return readable.takeError();
@@ -1178,11 +1183,11 @@ llvm::Expected<uint32_t> GetOptionsForPyObject(const PythonObject &obj) {
options |= File::eOpenOptionRead;
if (writable.get())
options |= File::eOpenOptionWrite;
+ return options;
#else
PythonString py_mode = obj.GetAttributeValue("mode").AsType<PythonString>();
- options = File::GetOptionsFromMode(py_mode.GetString());
+ return File::GetOptionsFromMode(py_mode.GetString());
#endif
- return options;
}
// Base class template for python files. All it knows how to do
@@ -1245,7 +1250,7 @@ namespace {
class SimplePythonFile : public OwnedPythonFile<NativeFile> {
public:
SimplePythonFile(const PythonFile &file, bool borrowed, int fd,
- uint32_t options)
+ File::OpenOptions options)
: OwnedPythonFile(file, borrowed, fd, options, false) {}
};
} // namespace
OpenPOWER on IntegriCloud