diff options
| author | Med Ismail Bennani <ismail@bennani.ma> | 2023-10-25 10:05:54 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-25 10:05:54 -0700 |
| commit | f22d82cef28a882cec4d242910933e9f5d7dcdce (patch) | |
| tree | 2a75ad93c317a3b302fd0829c72fb40530114feb /lldb/bindings/python | |
| parent | 7ce613fc77af092dd6e9db71ce3747b75bc5616e (diff) | |
| download | llvm-f22d82cef28a882cec4d242910933e9f5d7dcdce.tar.gz llvm-f22d82cef28a882cec4d242910933e9f5d7dcdce.tar.bz2 llvm-f22d82cef28a882cec4d242910933e9f5d7dcdce.zip | |
[lldb/Interpreter] Make ScriptedInterface Object creation more generic (#68052)
This patch changes the way plugin objects used with Scripted Interfaces
are created.
Instead of implementing a different SWIG method to create the object for
every scripted interface, this patch makes the creation more generic by
re-using some of the ScriptedPythonInterface templated Dispatch code.
This patch also improves error handling of the object creation by
returning an `llvm::Expected`.
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
Diffstat (limited to 'lldb/bindings/python')
| -rw-r--r-- | lldb/bindings/python/python-wrapper.swig | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/lldb/bindings/python/python-wrapper.swig b/lldb/bindings/python/python-wrapper.swig index cb54901e66d0..17bc7b1f2198 100644 --- a/lldb/bindings/python/python-wrapper.swig +++ b/lldb/bindings/python/python-wrapper.swig @@ -229,49 +229,6 @@ PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateCommandObject return pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger_sp)), dict); } -PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedObject( - const char *python_class_name, const char *session_dictionary_name, - lldb::ExecutionContextRefSP exe_ctx_sp, - const lldb_private::StructuredDataImpl &args_impl, - std::string &error_string) { - if (python_class_name == NULL || python_class_name[0] == '\0' || - !session_dictionary_name) - return PythonObject(); - - PyErr_Cleaner py_err_cleaner(true); - - auto dict = PythonModule::MainModule().ResolveName<PythonDictionary>( - session_dictionary_name); - auto pfunc = PythonObject::ResolveNameWithDictionary<PythonCallable>( - python_class_name, dict); - - if (!pfunc.IsAllocated()) { - error_string.append("could not find script class: "); - error_string.append(python_class_name); - return PythonObject(); - } - - llvm::Expected<PythonCallable::ArgInfo> arg_info = pfunc.GetArgInfo(); - if (!arg_info) { - llvm::handleAllErrors( - arg_info.takeError(), - [&](PythonException &E) { error_string.append(E.ReadBacktrace()); }, - [&](const llvm::ErrorInfoBase &E) { - error_string.append(E.message()); - }); - return PythonObject(); - } - - PythonObject result = {}; - if (arg_info.get().max_positional_args == 2) { - result = pfunc(SWIGBridge::ToSWIGWrapper(exe_ctx_sp), SWIGBridge::ToSWIGWrapper(args_impl)); - } else { - error_string.assign("wrong number of arguments in __init__, should be 2 " - "(not including self)"); - } - return result; -} - PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedThreadPlan( const char *python_class_name, const char *session_dictionary_name, const lldb_private::StructuredDataImpl &args_impl, |
