aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-newobjfileevent.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2018-08-24 20:09:19 +0100
committerPedro Alves <palves@redhat.com>2018-08-24 22:57:16 +0100
commitd98fc15be2b8dd5699c1852db7d9d979231123dc (patch)
treeb90de293d215ac05883021a5ac2da87d63136cb2 /gdb/python/py-newobjfileevent.c
parentda3c873831707454d45cee6705075b27a1732f09 (diff)
downloadbinutils-d98fc15be2b8dd5699c1852db7d9d979231123dc.zip
binutils-d98fc15be2b8dd5699c1852db7d9d979231123dc.tar.gz
binutils-d98fc15be2b8dd5699c1852db7d9d979231123dc.tar.bz2
gdb/python: Use copy-initialization more when possible
gdb/ChangeLog: 2018-08-24 Pedro Alves <palves@redhat.com> * python/py-bpevent.c (create_breakpoint_event_object): Use copy-initialization. * python/py-continueevent.c (emit_continue_event): Use copy-initialization. * python/py-exitedevent.c (create_exited_event_object): Return a gdbpy_ref<>. (emit_exited_event): Use copy-initialization. * python/py-inferior.c (python_new_inferior) (python_inferior_deleted, add_thread_object): Use copy-initialization. * python/py-infevents.c (create_inferior_call_event_object) (create_register_changed_event_object) (create_memory_changed_event_object): Return a gdbpy_ref<>. (emit_inferior_call_event, emit_memory_changed_event) (emit_register_changed_event): Use copy-initialization. * python/py-newobjfileevent.c (create_new_objfile_event_object): Return a gdbpy_ref<>. (emit_new_objfile_event): Use copy-initialization. (create_clear_objfiles_event_object): Return a gdbpy_ref<>. (emit_clear_objfiles_event): Use copy-initialization. * python/py-signalevent.c (create_signal_event_object): Use copy-initialization. * python/py-threadevent.c (create_thread_event_object): Use copy-initialization.
Diffstat (limited to 'gdb/python/py-newobjfileevent.c')
-rw-r--r--gdb/python/py-newobjfileevent.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/gdb/python/py-newobjfileevent.c b/gdb/python/py-newobjfileevent.c
index 86de9ac..a9341a3 100644
--- a/gdb/python/py-newobjfileevent.c
+++ b/gdb/python/py-newobjfileevent.c
@@ -20,25 +20,23 @@
#include "defs.h"
#include "py-event.h"
-static PyObject *
+static gdbpy_ref<>
create_new_objfile_event_object (struct objfile *objfile)
{
- PyObject *py_objfile;
-
gdbpy_ref<> objfile_event
- (create_event_object (&new_objfile_event_object_type));
+ = create_event_object (&new_objfile_event_object_type);
if (objfile_event == NULL)
return NULL;
/* Note that objfile_to_objfile_object returns a borrowed reference,
so we don't need a decref here. */
- py_objfile = objfile_to_objfile_object (objfile);
+ PyObject *py_objfile = objfile_to_objfile_object (objfile);
if (!py_objfile || evpy_add_attribute (objfile_event.get (),
"new_objfile",
py_objfile) < 0)
return NULL;
- return objfile_event.release ();
+ return objfile_event;
}
/* Callback function which notifies observers when a new objfile event occurs.
@@ -51,7 +49,7 @@ emit_new_objfile_event (struct objfile *objfile)
if (evregpy_no_listeners_p (gdb_py_events.new_objfile))
return 0;
- gdbpy_ref<> event (create_new_objfile_event_object (objfile));
+ gdbpy_ref<> event = create_new_objfile_event_object (objfile);
if (event != NULL)
return evpy_emit_event (event.get (), gdb_py_events.new_objfile);
return -1;
@@ -60,25 +58,23 @@ emit_new_objfile_event (struct objfile *objfile)
/* Subroutine of emit_clear_objfiles_event to simplify it. */
-static PyObject *
+static gdbpy_ref<>
create_clear_objfiles_event_object (void)
{
- PyObject *py_progspace;
-
gdbpy_ref<> objfile_event
- (create_event_object (&clear_objfiles_event_object_type));
+ = create_event_object (&clear_objfiles_event_object_type);
if (objfile_event == NULL)
return NULL;
/* Note that pspace_to_pspace_object returns a borrowed reference,
so we don't need a decref here. */
- py_progspace = pspace_to_pspace_object (current_program_space);
+ PyObject *py_progspace = pspace_to_pspace_object (current_program_space);
if (!py_progspace || evpy_add_attribute (objfile_event.get (),
"progspace",
py_progspace) < 0)
return NULL;
- return objfile_event.release ();
+ return objfile_event;
}
/* Callback function which notifies observers when the "clear objfiles"
@@ -92,7 +88,7 @@ emit_clear_objfiles_event (void)
if (evregpy_no_listeners_p (gdb_py_events.clear_objfiles))
return 0;
- gdbpy_ref<> event (create_clear_objfiles_event_object ());
+ gdbpy_ref<> event = create_clear_objfiles_event_object ();
if (event != NULL)
return evpy_emit_event (event.get (), gdb_py_events.clear_objfiles);
return -1;