Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
Show First 20 Lines • Show All 632 Lines • ▼ Show 20 Lines | public: | ||||
static bool Check(PyObject *py_obj); | static bool Check(PyObject *py_obj); | ||||
// Bring in the no-argument base class version | // Bring in the no-argument base class version | ||||
using PythonObject::Reset; | using PythonObject::Reset; | ||||
void Reset(PyRefType type, PyObject *py_obj) override; | void Reset(PyRefType type, PyObject *py_obj) override; | ||||
ArgInfo GetNumArguments() const; | ArgInfo GetNumArguments() const; | ||||
// If the callable is a Py_Class, then find the number of arguments | // If the callable is a Py_Class, then find the number of arguments | ||||
// of the __init__ method. | // of the __init__ method. | ||||
ArgInfo GetNumInitArguments() const; | ArgInfo GetNumInitArguments() const; | ||||
PythonObject operator()(); | PythonObject operator()(); | ||||
PythonObject operator()(std::initializer_list<PyObject *> args); | PythonObject operator()(std::initializer_list<PyObject *> args); | ||||
PythonObject operator()(std::initializer_list<PythonObject> args); | PythonObject operator()(std::initializer_list<PythonObject> args); | ||||
template <typename Arg, typename... Args> | template <typename Arg, typename... Args> | ||||
PythonObject operator()(const Arg &arg, Args... args) { | PythonObject operator()(const Arg &arg, Args... args) { | ||||
return operator()({arg, args...}); | return operator()({arg, args...}); | ||||
} | } | ||||
}; | }; | ||||
class PythonFile : public PythonObject { | class PythonFile : public PythonObject { | ||||
public: | public: | ||||
PythonFile(); | PythonFile(); | ||||
PythonFile(File &file, const char *mode); | |||||
PythonFile(PyRefType type, PyObject *o); | PythonFile(PyRefType type, PyObject *o); | ||||
~PythonFile() override; | ~PythonFile() override; | ||||
static bool Check(PyObject *py_obj); | static bool Check(PyObject *py_obj); | ||||
using PythonObject::Reset; | using PythonObject::Reset; | ||||
void Reset(PyRefType type, PyObject *py_obj) override; | 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()); | |||||
labath: It looks like there's just one caller of this constructor (the "out" typemap for FILE*). Can we… | |||||
It's also called in some parts of ScriptInterpreterPython that are broken for other reasons, and are getting fixed later in my patch queue. I'll just put a fixme here and delete it when all the other code that uses it also gets deleted, ok? lawrence_danna: It's also called in some parts of ScriptInterpreterPython that are broken for other reasons… | |||||
Sounds good. labath: Sounds good. | |||||
} | |||||
} | |||||
lldb::FileUP GetUnderlyingFile() const; | lldb::FileUP GetUnderlyingFile() const; | ||||
llvm::Expected<lldb::FileSP> ConvertToFile(bool borrowed = false); | llvm::Expected<lldb::FileSP> ConvertToFile(bool borrowed = false); | ||||
llvm::Expected<lldb::FileSP> | llvm::Expected<lldb::FileSP> | ||||
ConvertToFileForcingUseOfScriptingIOMethods(bool borrowed = false); | ConvertToFileForcingUseOfScriptingIOMethods(bool borrowed = false); | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |
It looks like there's just one caller of this constructor (the "out" typemap for FILE*). Can we just inline this stuff there and delete this constructor?