aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-06-11 14:12:09 -0600
committerTom Tromey <tromey@adacore.com>2024-06-13 10:13:37 -0600
commitc2d091ff5c8b68d9682a070d7970ba6ebc4b5760 (patch)
tree09baafeeab26a99e43f23a595e1581694a49851f /gdb
parent7c03e522d4e059a7c59533e4b01771a7cc4bb68e (diff)
downloadgdb-c2d091ff5c8b68d9682a070d7970ba6ebc4b5760.zip
gdb-c2d091ff5c8b68d9682a070d7970ba6ebc4b5760.tar.gz
gdb-c2d091ff5c8b68d9682a070d7970ba6ebc4b5760.tar.bz2
Add gdbpy_call_method overloads for gdbpy_ref<>
This adds an overload of gdbpy_call_method that accepts a gdbpy_ref<>. This is just a small convenience. Reviewed-By: Tom de Vries <tdevries@suse.de>
Diffstat (limited to 'gdb')
-rw-r--r--gdb/python/py-tui.c10
-rw-r--r--gdb/python/python-internal.h9
2 files changed, 14 insertions, 5 deletions
diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c
index 901f6fe..984fa9b 100644
--- a/gdb/python/py-tui.c
+++ b/gdb/python/py-tui.c
@@ -164,7 +164,7 @@ tui_py_window::~tui_py_window ()
if (m_window != nullptr
&& PyObject_HasAttrString (m_window.get (), "close"))
{
- gdbpy_ref<> result = gdbpy_call_method (m_window.get (), "close");
+ gdbpy_ref<> result = gdbpy_call_method (m_window, "close");
if (result == nullptr)
gdbpy_print_stack ();
}
@@ -197,7 +197,7 @@ tui_py_window::rerender ()
if (PyObject_HasAttrString (m_window.get (), "render"))
{
- gdbpy_ref<> result = gdbpy_call_method (m_window.get (), "render");
+ gdbpy_ref<> result = gdbpy_call_method (m_window, "render");
if (result == nullptr)
gdbpy_print_stack ();
}
@@ -210,7 +210,7 @@ tui_py_window::do_scroll_horizontal (int num_to_scroll)
if (PyObject_HasAttrString (m_window.get (), "hscroll"))
{
- gdbpy_ref<> result = gdbpy_call_method (m_window.get(), "hscroll",
+ gdbpy_ref<> result = gdbpy_call_method (m_window, "hscroll",
num_to_scroll);
if (result == nullptr)
gdbpy_print_stack ();
@@ -224,7 +224,7 @@ tui_py_window::do_scroll_vertical (int num_to_scroll)
if (PyObject_HasAttrString (m_window.get (), "vscroll"))
{
- gdbpy_ref<> result = gdbpy_call_method (m_window.get (), "vscroll",
+ gdbpy_ref<> result = gdbpy_call_method (m_window, "vscroll",
num_to_scroll);
if (result == nullptr)
gdbpy_print_stack ();
@@ -246,7 +246,7 @@ tui_py_window::click (int mouse_x, int mouse_y, int mouse_button)
if (PyObject_HasAttrString (m_window.get (), "click"))
{
- gdbpy_ref<> result = gdbpy_call_method (m_window.get (), "click",
+ gdbpy_ref<> result = gdbpy_call_method (m_window, "click",
mouse_x, mouse_y, mouse_button);
if (result == nullptr)
gdbpy_print_stack ();
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index caf85f5..f4c35ba 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -207,6 +207,15 @@ gdbpy_call_method (PyObject *o, const char *method,
arg, args...));
}
+/* An overload that takes a gdbpy_ref<> rather than a raw 'PyObject *'. */
+
+template<typename... Args>
+static inline gdbpy_ref<>
+gdbpy_call_method (const gdbpy_ref<> &o, const char *method, Args... args)
+{
+ return gdbpy_call_method (o.get (), method, args...);
+}
+
/* Poison PyObject_CallMethod. The typesafe wrapper gdbpy_call_method should be
used instead. */
#undef PyObject_CallMethod