[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>
This commit is contained in:
committed by
GitHub
parent
7ce613fc77
commit
f22d82cef2
@@ -108,10 +108,17 @@ ScriptedProcess::ScriptedProcess(lldb::TargetSP target_sp,
|
||||
ExecutionContext exe_ctx(target_sp, /*get_process=*/false);
|
||||
|
||||
// Create process script object
|
||||
StructuredData::GenericSP object_sp = GetInterface().CreatePluginObject(
|
||||
auto obj_or_err = GetInterface().CreatePluginObject(
|
||||
m_scripted_metadata.GetClassName(), exe_ctx,
|
||||
m_scripted_metadata.GetArgsSP());
|
||||
|
||||
if (!obj_or_err) {
|
||||
error.SetErrorString("Failed to create script object.");
|
||||
return;
|
||||
}
|
||||
|
||||
StructuredData::GenericSP object_sp = *obj_or_err;
|
||||
|
||||
if (!object_sp || !object_sp->IsValid()) {
|
||||
error.SetErrorStringWithFormat("ScriptedProcess::%s () - ERROR: %s",
|
||||
__FUNCTION__,
|
||||
|
||||
Reference in New Issue
Block a user