Skip to content
Commit 764af878 authored by Tom Tromey's avatar Tom Tromey Committed by Tom de Vries
Browse files

[gdb/python] Add typesafe wrapper around PyObject_CallMethod



In gdb/python/py-tui.c we have code like this:
...
      gdbpy_ref<> result (PyObject_CallMethod (m_window.get(), "hscroll",
                                              "i", num_to_scroll, nullptr));
...

The nullptr is superfluous, the format string already indicates that there's
only one method argument.

OTOH, passing no method args does use a nullptr:
...
      gdbpy_ref<> result (PyObject_CallMethod (m_window.get (), "render",
                                               nullptr));
...

Furthermore, choosing the right format string chars can be tricky.

Add a typesafe wrapper around PyObject_CallMethod that hides these
details, such that we can use the more intuitive:
...
      gdbpy_ref<> result (gdbpy_call_method (m_window.get(), "hscroll",
                                             num_to_scroll));
...
and:
...
      gdbpy_ref<> result (gdbpy_call_method (m_window.get (), "render"));
...

Tested on x86_64-linux.

Co-Authored-By: default avatarTom de Vries <tdevries@suse.de>
Approved-By: default avatarTom Tromey <tom@tromey.com>
parent 72476aca
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment