diff options
author | Jim Ingham <jingham@apple.com> | 2019-10-03 22:50:18 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2019-10-03 22:50:18 +0000 |
commit | 27a14f19c810f494adddb8aaff960336ab4492e7 (patch) | |
tree | a7eae222175b77917ee9ccfd1b0f21555d7118f4 /lldb/scripts/Python/python-wrapper.swig | |
parent | 145cdad11925194ec41949b5c8f0cb037f9e7941 (diff) | |
download | bcm5719-llvm-27a14f19c810f494adddb8aaff960336ab4492e7.tar.gz bcm5719-llvm-27a14f19c810f494adddb8aaff960336ab4492e7.zip |
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
Diffstat (limited to 'lldb/scripts/Python/python-wrapper.swig')
-rw-r--r-- | lldb/scripts/Python/python-wrapper.swig | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lldb/scripts/Python/python-wrapper.swig b/lldb/scripts/Python/python-wrapper.swig index 8a99daa90c8..b2984e6ddc2 100644 --- a/lldb/scripts/Python/python-wrapper.swig +++ b/lldb/scripts/Python/python-wrapper.swig @@ -250,6 +250,7 @@ LLDBSwigPythonCreateScriptedThreadPlan ( const char *python_class_name, const char *session_dictionary_name, + lldb_private::StructuredDataImpl *args_impl, std::string &error_string, const lldb::ThreadPlanSP& thread_plan_sp ) @@ -279,7 +280,23 @@ LLDBSwigPythonCreateScriptedThreadPlan if (!tp_arg.IsAllocated()) Py_RETURN_NONE; - PythonObject result = pfunc(tp_arg, dict); + PythonObject result = {}; + size_t init_num_args = pfunc.GetNumInitArguments().count; + if (init_num_args == 3) { + if (args_impl != nullptr) { + error_string.assign("args passed, but __init__ does not take an args dictionary"); + Py_RETURN_NONE; + } + result = pfunc(tp_arg, dict); + } else if (init_num_args = 4) { + lldb::SBStructuredData *args_value = new lldb::SBStructuredData(args_impl); + PythonObject args_arg(PyRefType::Owned, SBTypeToSWIGWrapper(args_value)); + result = pfunc(tp_arg, args_arg, dict); + } else { + error_string.assign("wrong number of arguments in __init__, should be 1 or 2 (not including self & dict)"); + Py_RETURN_NONE; + } + // FIXME: At this point we should check that the class we found supports all the methods // that we need. |