diff options
| author | Lawrence D'Anna <lawrence_danna@apple.com> | 2019-10-15 16:46:27 +0000 |
|---|---|---|
| committer | Lawrence D'Anna <lawrence_danna@apple.com> | 2019-10-15 16:46:27 +0000 |
| commit | d9b553ec9961e95740535d3aeff62817f867767f (patch) | |
| tree | a20193fd70d7956369ddf7c7b75407b7273c597f /lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h | |
| parent | 1184c27fa586f8fe713921150146d433aae969ff (diff) | |
| download | llvm-d9b553ec9961e95740535d3aeff62817f867767f.zip llvm-d9b553ec9961e95740535d3aeff62817f867767f.tar.gz llvm-d9b553ec9961e95740535d3aeff62817f867767f.tar.bz2 | |
SBFile::GetFile: convert SBFile back into python native files.
Summary:
This makes SBFile::GetFile public and adds a SWIG typemap to convert
the result back into a python native file.
If the underlying File itself came from a python file, it is returned
identically. Otherwise a new python file object is created using
the file descriptor.
Reviewers: JDevlieghere, jasonmolenda, labath
Reviewed By: labath
Subscribers: lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D68737
llvm-svn: 374911
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h')
| -rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h index a26b64a..b794810 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h @@ -638,7 +638,7 @@ public: void Reset(PyRefType type, PyObject *py_obj) override; ArgInfo GetNumArguments() const; - + // If the callable is a Py_Class, then find the number of arguments // of the __init__ method. ArgInfo GetNumInitArguments() const; @@ -658,7 +658,6 @@ public: class PythonFile : public PythonObject { public: PythonFile(); - PythonFile(File &file, const char *mode); PythonFile(PyRefType type, PyObject *o); ~PythonFile() override; @@ -668,7 +667,21 @@ public: using PythonObject::Reset; void Reset(PyRefType type, PyObject *py_obj) override; - void Reset(File &file, const char *mode); + + static llvm::Expected<PythonFile> FromFile(File &file, + const char *mode = nullptr); + + // FIXME delete this after FILE* typemaps are deleted + // and ScriptInterpreterPython is fixed + PythonFile(File &file, const char *mode = nullptr) { + auto f = FromFile(file, mode); + if (f) + *this = std::move(f.get()); + else { + Reset(); + llvm::consumeError(f.takeError()); + } + } lldb::FileUP GetUnderlyingFile() const; |
