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 --- lldb/scripts/Python/python-wrapper.swig | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lldb/scripts/Python/python-wrapper.swig') diff --git a/lldb/scripts/Python/python-wrapper.swig b/lldb/scripts/Python/python-wrapper.swig index 8a99daa..b2984e6 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. -- cgit v1.1