From 3925204c1f5880f491e08d8481e88342bbeb7bc4 Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Fri, 3 Sep 2021 17:35:02 +0000 Subject: [lldb/Plugins] Introduce Scripted Interface Factory This patch splits the previous `ScriptedProcessPythonInterface` into multiple specific classes: 1. The `ScriptedInterface` abstract class that carries the interface instance object and its virtual pure abstract creation method. 2. The `ScriptedPythonInterface` that holds a generic `Dispatch` method that can be used by various interfaces to call python methods and also keeps a reference to the Python Script Interpreter instance. 3. The `ScriptedProcessInterface` that describes the base Scripted Process model with all the methods used in the underlying script. All these components are used to refactor the `ScriptedProcessPythonInterface` class, making it more modular. This patch is also a requirement for the upcoming work on `ScriptedThread`. Differential Revision: https://reviews.llvm.org/D107521 Signed-off-by: Med Ismail Bennani --- .../Python/ScriptedPythonInterface.cpp | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp new file mode 100644 index 0000000..097cbbd --- /dev/null +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp @@ -0,0 +1,38 @@ +//===-- ScriptedPythonInterface.cpp ---------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "lldb/Host/Config.h" +#include "lldb/Utility/Log.h" +#include "lldb/Utility/Logging.h" +#include "lldb/lldb-enumerations.h" + +#if LLDB_ENABLE_PYTHON + +// LLDB Python header must be included first +#include "lldb-python.h" + +#include "SWIGPythonBridge.h" +#include "ScriptInterpreterPythonImpl.h" +#include "ScriptedPythonInterface.h" + +using namespace lldb; +using namespace lldb_private; + +ScriptedPythonInterface::ScriptedPythonInterface( + ScriptInterpreterPythonImpl &interpreter) + : ScriptedInterface(), m_interpreter(interpreter) {} + +Status +ScriptedPythonInterface::GetStatusFromMethod(llvm::StringRef method_name) { + Status error; + Dispatch(method_name, error); + + return error; +} + +#endif -- cgit v1.1