From 27a14f19c810f494adddb8aaff960336ab4492e7 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Thu, 3 Oct 2019 22:50:18 +0000 Subject: Pass an SBStructuredData to scripted ThreadPlans on use. This will allow us to write reusable scripted ThreadPlans, since you can use key/value pairs with known keys in the plan to parametrize its behavior. Differential Revision: https://reviews.llvm.org/D68366 llvm-svn: 373675 --- .../ScriptInterpreter/Python/PythonDataObjects.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index fedd8f6..1862bbd 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -887,6 +887,23 @@ void PythonCallable::Reset(PyRefType type, PyObject *py_obj) { PythonObject::Reset(PyRefType::Borrowed, result.get()); } +PythonCallable::ArgInfo PythonCallable::GetNumInitArguments() const { + ArgInfo result = {0, false, false, false}; + if (!IsValid()) + return result; + PyObject *py_func_obj = m_py_obj; + if (!PyClass_Check(m_py_obj)) + return result; + + PythonObject __init__ = GetAttributeValue("__init__"); + if (__init__.IsValid() ) { + auto __init_callable__ = __init__.AsType(); + if (__init_callable__.IsValid()) + return __init_callable__.GetNumArguments(); + } + return result; +} + PythonCallable::ArgInfo PythonCallable::GetNumArguments() const { ArgInfo result = {0, false, false, false}; if (!IsValid()) -- cgit v1.1