diff options
author | Enrico Granata <egranata@apple.com> | 2016-06-24 02:07:15 +0000 |
---|---|---|
committer | Enrico Granata <egranata@apple.com> | 2016-06-24 02:07:15 +0000 |
commit | a5d6765cb04214b10b5b5b550e554c5411c03b43 (patch) | |
tree | 23ea54790d247d50d16323a95ee044b9d5bbd0cf /lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp | |
parent | 68f7f1cf00a0405446fe765d2ed6e583a6e5947b (diff) | |
download | bcm5719-llvm-a5d6765cb04214b10b5b5b550e554c5411c03b43.tar.gz bcm5719-llvm-a5d6765cb04214b10b5b5b550e554c5411c03b43.zip |
Fix an issue where the @lldb.command marker would not work with the new 5-argument version of the Python command function
This:
a) teaches PythonCallable to look inside a callable object
b) teaches PythonCallable to discover whether a callable method is bound
c) teaches lldb.command to dispatch to either the older 4 argument version or the newer 5 argument version
llvm-svn: 273640
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp')
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index 02228df5147..1fdf4c70a5d 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -1109,13 +1109,37 @@ PythonCallable::Reset(PyRefType type, PyObject *py_obj) PythonCallable::ArgInfo PythonCallable::GetNumArguments() const { - ArgInfo result = { 0, false, false }; + ArgInfo result = { 0, false, false, false }; if (!IsValid()) return result; PyObject *py_func_obj = m_py_obj; if (PyMethod_Check(py_func_obj)) + { py_func_obj = PyMethod_GET_FUNCTION(py_func_obj); + PythonObject im_self = GetAttributeValue("im_self"); + if (im_self.IsValid() && !im_self.IsNone()) + result.is_bound_method = true; + } + else + { + // see if this is a callable object with an __call__ method + if (!PyFunction_Check(py_func_obj)) + { + PythonObject __call__ = GetAttributeValue("__call__"); + if (__call__.IsValid()) + { + auto __callable__ = __call__.AsType<PythonCallable>(); + if (__callable__.IsValid()) + { + py_func_obj = PyMethod_GET_FUNCTION(__callable__.get()); + PythonObject im_self = GetAttributeValue("im_self"); + if (im_self.IsValid() && !im_self.IsNone()) + result.is_bound_method = true; + } + } + } + } if (!py_func_obj) return result; |