diff options
author | Zachary Turner <zturner@google.com> | 2015-11-12 16:23:16 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2015-11-12 16:23:16 +0000 |
commit | b58fb2f47a4f792fed292b139c2b2a325ed3abb5 (patch) | |
tree | fcf7947f8aba5ab719b7edad32300c10db75e777 /lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp | |
parent | 183c010c9a36ff131288c15b324f1c2f7d6a0a50 (diff) | |
download | bcm5719-llvm-b58fb2f47a4f792fed292b139c2b2a325ed3abb5.tar.gz bcm5719-llvm-b58fb2f47a4f792fed292b139c2b2a325ed3abb5.zip |
Begin converting uses of PyCallable to PythonCallable.
PyCallable is a class that exists solely within the swig wrapper
code. PythonCallable is a more generic implementation of the same
idea that can be used by any Python-related interop code, and lives
in PythonDataObjects.h
The CL is mostly mechanical, and it doesn't cover every possible
user of PyCallable, because I want to minimize the impact of this
change (as well as making it easier to figure out what went wrong
in case this causes a failure). I plan to finish up the rest of
the changes in a subsequent patch, culminating in the removal of
PyCallable entirely.
llvm-svn: 252906
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp')
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index 0c5ba7d343a..abcf71b8663 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -904,31 +904,35 @@ PythonCallable::Reset(PyRefType type, PyObject *py_obj) } -void -PythonCallable::GetNumArguments(size_t &num_args, bool &has_varargs, bool &has_kwargs) const +PythonCallable::ArgInfo +PythonCallable::GetNumArguments() const { - num_args = 0; - has_varargs = false; - has_kwargs = false; + ArgInfo result = { 0, false, false }; if (!IsValid()) - return; + return result; PyObject *py_func_obj = m_py_obj; if (PyMethod_Check(py_func_obj)) py_func_obj = PyMethod_GET_FUNCTION(py_func_obj); if (!py_func_obj) - return; + return result; PyCodeObject* code = (PyCodeObject*)PyFunction_GET_CODE(py_func_obj); if (!code) - return; + return result; - num_args = code->co_argcount; - if (code->co_flags & CO_VARARGS) - has_varargs = true; - if (code->co_flags & CO_VARKEYWORDS) - has_kwargs = true; + result.count = code->co_argcount; + result.has_varargs = !!(code->co_flags & CO_VARARGS); + result.has_kwargs = !!(code->co_flags & CO_VARKEYWORDS); + return result; +} + +PythonObject +PythonCallable::operator ()() +{ + return PythonObject(PyRefType::Owned, + PyObject_CallObject(m_py_obj, nullptr)); } PythonObject |