public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-swagiaal-oguz: Document PY_NEW_EVENT_TYPE.
@ 2010-12-20 15:47 swagiaal
  0 siblings, 0 replies; only message in thread
From: swagiaal @ 2010-12-20 15:47 UTC (permalink / raw)
  To: archer-commits

The branch, archer-swagiaal-oguz has been updated
       via  7e3d874a1d76af982fe5843bfd0437b7433c30e4 (commit)
       via  60ab8235caad50831d995620291bfca2a7cb79a6 (commit)
       via  b3b9e9cf3dca5882002549b388d9fe88b075876c (commit)
       via  ffa7cb28dedf94aa326f4165133506805424b6ba (commit)
       via  9be4b0d2cc6b15b70fc036c50999c74e507290b3 (commit)
       via  08ba31f6f2a3412185f8abf8f815c2bb2404e293 (commit)
       via  780c0b463247d1ab8e35c028f23fb6536e16d3c6 (commit)
       via  2c1849ef67d28ff04e074a86b1116ac6282e2ca5 (commit)
       via  65da0d279139c947663d9bbb332871668447395b (commit)
       via  aeb1d0e16a16fce756f50e40bac2c77d09a5ebe5 (commit)
       via  d96454914173e99781679779026295b6c53df843 (commit)
       via  c12476e13194bfe8eeda21b0c577459bb9cb394f (commit)
       via  85095b29c0c7efacf813f7476e27c95992e914e3 (commit)
      from  8ffa9675d87a9fa1d38d5a9ef522dbc9bd9e7e1d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 7e3d874a1d76af982fe5843bfd0437b7433c30e4
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Mon Dec 20 10:45:25 2010 -0500

    Document PY_NEW_EVENT_TYPE.

commit 60ab8235caad50831d995620291bfca2a7cb79a6
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Mon Dec 20 10:39:02 2010 -0500

    Create and use PY_NEW_EVENT_TYPE macro
    
    PY_NEW_EVENT_TYPE creates all boiler plate code for events.

commit b3b9e9cf3dca5882002549b388d9fe88b075876c
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Dec 17 16:54:51 2010 -0500

    Use tp_dictoffset for events instead of getset.

commit ffa7cb28dedf94aa326f4165133506805424b6ba
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Dec 17 16:34:11 2010 -0500

    move thread initialization to event object.

commit 9be4b0d2cc6b15b70fc036c50999c74e507290b3
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Dec 17 14:36:34 2010 -0500

    Remove stopevent getset.

commit 08ba31f6f2a3412185f8abf8f815c2bb2404e293
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Dec 17 14:32:43 2010 -0500

    Create and use one generic initialize function.

commit 780c0b463247d1ab8e35c028f23fb6536e16d3c6
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Dec 17 13:38:02 2010 -0500

    Use observer_attach_inferior_exit for exited event.
    
    And test exit code.

commit 2c1849ef67d28ff04e074a86b1116ac6282e2ca5
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Dec 17 11:48:26 2010 -0500

    Move events singleton into its own files.

commit 65da0d279139c947663d9bbb332871668447395b
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Fri Dec 17 11:37:06 2010 -0500

    Use tpdictoffset for events object.
    
    ... and add 'events' instance to gdb module instead of events type.

commit aeb1d0e16a16fce756f50e40bac2c77d09a5ebe5
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Thu Dec 16 12:20:48 2010 -0500

    Remove stop_reason
    
    rely on class type instead.

commit d96454914173e99781679779026295b6c53df843
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Thu Dec 16 12:01:49 2010 -0500

    Remove event_type
    
    Rely on class type instead.

commit c12476e13194bfe8eeda21b0c577459bb9cb394f
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Thu Dec 16 11:20:52 2010 -0500

    removed the stop form py-breakpointstopevent.c and py-signalstopevent.c

commit 85095b29c0c7efacf813f7476e27c95992e914e3
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Thu Dec 16 11:14:07 2010 -0500

    Remove '_stop' from event names.
    
    Renamed signal_stop_event to signal_event.
    Renamed breakpoint_stop_event to breakpoint_event.

-----------------------------------------------------------------------

Summary of changes:
 gdb/Makefile.in                                |   22 ++--
 gdb/python/py-breakpointevent.c                |   59 +++++++++
 gdb/python/py-breakpointstopevent.c            |  128 --------------------
 gdb/python/py-continueevent.c                  |   64 +---------
 gdb/python/py-event.c                          |  152 ++++++------------------
 gdb/python/py-event.h                          |   91 +++++++++++---
 gdb/python/py-eventregistry.c                  |    3 +
 gdb/python/py-events.c                         |  135 +++++++++++++++++++++
 gdb/python/{py-event.h => py-events.h}         |   27 +----
 gdb/python/py-exitedevent.c                    |   91 ++------------
 gdb/python/py-inferior.c                       |   24 +----
 gdb/python/py-signalevent.c                    |   59 +++++++++
 gdb/python/py-signalstopevent.c                |  122 -------------------
 gdb/python/py-stopevent.c                      |  101 ++--------------
 gdb/python/py-stopevent.h                      |   32 +----
 gdb/python/python-internal.h                   |    5 +-
 gdb/python/python.c                            |    4 +-
 gdb/testsuite/gdb.python/py-events-threads.exp |    4 +
 gdb/testsuite/gdb.python/py-events.py          |   16 ++-
 19 files changed, 446 insertions(+), 693 deletions(-)
 create mode 100644 gdb/python/py-breakpointevent.c
 delete mode 100644 gdb/python/py-breakpointstopevent.c
 create mode 100644 gdb/python/py-events.c
 copy gdb/python/{py-event.h => py-events.h} (61%)
 create mode 100644 gdb/python/py-signalevent.c
 delete mode 100644 gdb/python/py-signalstopevent.c

First 500 lines of diff:
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index fb687a8..c299f3d 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -273,11 +273,12 @@ SUBDIR_PYTHON_OBS = \
 	py-auto-load.o \
 	py-block.o \
 	py-breakpoint.o \
-	py-breakpointstopevent.o \
+	py-breakpointevent.o \
 	py-cmd.o \
 	py-continueevent.o \
 	py-event.o \
 	py-eventregistry.o \
+	py-events.o \
 	py-exitedevent.o \
 	py-frame.o \
 	py-function.o \
@@ -288,7 +289,7 @@ SUBDIR_PYTHON_OBS = \
 	py-param.o \
 	py-prettyprint.o \
 	py-progspace.o \
-	py-signalstopevent.o \
+	py-signalevent.o \
 	py-stopevent.o \
 	py-symbol.o \
 	py-symtab.o \
@@ -301,11 +302,12 @@ SUBDIR_PYTHON_SRCS = \
 	python/py-auto-load.c \
 	python/py-block.c \
 	python/py-breakpoint.c \
-	python/py-breakpointstopevent.c \
+	python/py-breakpointevent.c \
 	python/py-cmd.c \
 	python/py-continueevent.c \
 	python/py-event.c \
 	python/py-eventregistry.c \
+	python/py-events.c \
 	python/py-exitedevent.c \
 	python/py-frame.c \
 	python/py-function.c \
@@ -316,7 +318,7 @@ SUBDIR_PYTHON_SRCS = \
 	python/py-param.c \
 	python/py-prettyprint.c \
 	python/py-progspace.c \
-	python/py-signalstopevent.c \
+	python/py-signalevent.c \
 	python/py-stopevent.c \
 	python/py-symbol.c \
 	python/py-symtab.c \
@@ -2015,8 +2017,8 @@ py-breakpoint.o: $(srcdir)/python/py-breakpoint.c
 	$(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-breakpoint.c
 	$(POSTCOMPILE)
 
-py-breakpointstopevent.o: $(srcdir)/python/py-breakpointstopevent.c
-	$(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-breakpointstopevent.c
+py-breakpointevent.o: $(srcdir)/python/py-breakpointevent.c
+	$(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-breakpointevent.c
 	$(POSTCOMPILE)
 
 py-cmd.o: $(srcdir)/python/py-cmd.c
@@ -2035,6 +2037,10 @@ py-eventregistry.o: $(srcdir)/python/py-eventregistry.c
 	$(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-eventregistry.c
 	$(POSTCOMPILE)
 
+py-events.o: $(srcdir)/python/py-events.c
+	$(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-events.c
+	$(POSTCOMPILE)
+
 py-exitedevent.o: $(srcdir)/python/py-exitedevent.c
 	$(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-exitedevent.c
 	$(POSTCOMPILE)
@@ -2075,8 +2081,8 @@ py-progspace.o: $(srcdir)/python/py-progspace.c
 	$(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-progspace.c
 	$(POSTCOMPILE)
 
-py-signalstopevent.o: $(srcdir)/python/py-signalstopevent.c
-	$(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-signalstopevent.c
+py-signalevent.o: $(srcdir)/python/py-signalevent.c
+	$(COMPILE) $(PYTHON_CFLAGS) $(srcdir)/python/py-signalevent.c
 	$(POSTCOMPILE)
 
 py-stopevent.o: $(srcdir)/python/py-stopevent.c
diff --git a/gdb/python/py-breakpointevent.c b/gdb/python/py-breakpointevent.c
new file mode 100644
index 0000000..7601955
--- /dev/null
+++ b/gdb/python/py-breakpointevent.c
@@ -0,0 +1,59 @@
+/* Python interface to inferior breakpoint stop events.
+
+   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include "py-stopevent.h"
+
+static PyTypeObject breakpoint_event_object_type;
+
+static void
+breakpoint_evpy_dealloc (PyObject *self)
+{
+  Py_DECREF (((breakpoint_event_object *) self)->breakpoint);
+  stop_evpy_dealloc (self);
+}
+
+/* Create and initialize a BreakpointEvent object.  */
+
+breakpoint_event_object *
+create_breakpoint_event_object (struct bpstats *bs, thread_object *stopped_thread)
+{
+  breakpoint_event_object *breakpoint_event_obj =
+      (breakpoint_event_object *)
+      create_stop_event_object (&breakpoint_event_object_type,
+                                stopped_thread);
+
+  if (!breakpoint_event_obj)
+    return NULL;
+
+  breakpoint_event_obj->breakpoint = gdbpy_breakpoint_from_bpstats (bs);
+  Py_INCREF (breakpoint_event_obj->breakpoint);
+
+  evpy_add_attribute ((event_object *) breakpoint_event_obj,
+                      "breakpoint",
+                      (PyObject *) breakpoint_event_obj->breakpoint);
+
+  return breakpoint_event_obj;
+}
+
+PY_NEW_EVENT_TYPE (breakpoint,
+                   "gdb.BreakpointEvent",
+                   "BreakpointEvent",
+                   "GDB breakpoint stop event object",
+                   stop_event_object_type,
+                   static);
diff --git a/gdb/python/py-breakpointstopevent.c b/gdb/python/py-breakpointstopevent.c
deleted file mode 100644
index a635369..0000000
--- a/gdb/python/py-breakpointstopevent.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/* Python interface to inferior breakpoint stop events.
-
-   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
-
-   This file is part of GDB.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include "py-stopevent.h"
-
-static PyTypeObject breakpoint_stop_event_object_type;
-
-static void
-bp_stop_evpy_dealloc (PyObject *self)
-{
-  Py_DECREF (((breakpoint_stop_event_object *) self)->breakpoint);
-  stop_evpy_dealloc (self);
-}
-
-/* Create and initialize a BreakpointStopEvent object.  */
-
-breakpoint_stop_event_object *
-create_breakpoint_event_object (struct bpstats *bs, PyObject *stopped_thread)
-{
-  breakpoint_stop_event_object *breakpoint_stop_event_obj =
-      (breakpoint_stop_event_object *)
-      create_stop_event_object (&breakpoint_stop_event_object_type,
-                                BREAKPOINT);
-
-  if (!breakpoint_stop_event_obj)
-    return NULL;
-
-  breakpoint_stop_event_obj->stop_event.event.inferior_thread =
-        stopped_thread;
-
-  breakpoint_stop_event_obj->breakpoint = gdbpy_breakpoint_from_bpstats (bs);
-  Py_INCREF (breakpoint_stop_event_obj->breakpoint);
-
-  return breakpoint_stop_event_obj;
-}
-
-/* Python function to get the stop event's breakpoint.  */
-
-static PyObject *
-bp_stop_evpy_get_breakpoint (PyObject *self, void *closure)
-{
-  breakpoint_stop_event_object *breakpoint_stop_event_obj =
-    (breakpoint_stop_event_object *) self;
-
-  //FIXME: Where is this reference being freed ?
-  Py_INCREF (breakpoint_stop_event_obj->breakpoint);
-
-  return (PyObject *) (breakpoint_stop_event_obj->breakpoint);
-}
-
-/* Initialize the Python breakpoint stop event code.  */
-
-void
-gdbpy_initialize_breakpoint_stop_event (void)
-{
-  breakpoint_stop_event_object_type.tp_base = &stop_event_object_type;
-  if (PyType_Ready (&breakpoint_stop_event_object_type) < 0)
-    return;
-
-  Py_INCREF (&breakpoint_stop_event_object_type);
-  PyModule_AddObject (gdb_module, "BreakpointStopEvent",
-                      (PyObject *) &breakpoint_stop_event_object_type);
-}
-
-static PyGetSetDef breakpoint_stop_event_object_getset[] =
-{
-  { "breakpoint", bp_stop_evpy_get_breakpoint, NULL, "Breakpoint.", NULL },
-
-  { NULL } /* Sentinel. */
-};
-
-static PyTypeObject breakpoint_stop_event_object_type =
-{
-  PyObject_HEAD_INIT (NULL)
-  0,                                          /* ob_size */
-  "gdb.BreakpointStopEvent",                  /* tp_name */
-  sizeof (breakpoint_stop_event_object),      /* tp_basicsize */
-  0,                                          /* tp_itemsize */
-  bp_stop_evpy_dealloc,                       /* tp_dealloc */
-  0,                                          /* tp_print */
-  0,                                          /* tp_getattr */
-  0,                                          /* tp_setattr */
-  0,                                          /* tp_compare */
-  0,                                          /* tp_repr */
-  0,                                          /* tp_as_number */
-  0,                                          /* tp_as_sequence */
-  0,                                          /* tp_as_mapping */
-  0,                                          /* tp_hash  */
-  0,                                          /* tp_call */
-  0,                                          /* tp_str */
-  0,                                          /* tp_getattro */
-  0,                                          /* tp_setattro */
-  0,                                          /* tp_as_buffer */
-  Py_TPFLAGS_DEFAULT,                         /* tp_flags */
-  "GDB breakpoint stop event object",         /* tp_doc */
-  0,                                          /* tp_traverse */
-  0,                                          /* tp_clear */
-  0,                                          /* tp_richcompare */
-  0,                                          /* tp_weaklistoffset */
-  0,                                          /* tp_iter */
-  0,                                          /* tp_iternext */
-  0,                                          /* tp_methods */
-  0,                                          /* tp_members */
-  breakpoint_stop_event_object_getset,        /* tp_getset */
-  0,                                          /* tp_base */
-  0,                                          /* tp_dict */
-  0,                                          /* tp_descr_get */
-  0,                                          /* tp_descr_set */
-  0,                                          /* tp_dictoffset */
-  0,                                          /* tp_init */
-  0                                           /* tp_alloc */
-};
diff --git a/gdb/python/py-continueevent.c b/gdb/python/py-continueevent.c
index a649059..4533f25 100644
--- a/gdb/python/py-continueevent.c
+++ b/gdb/python/py-continueevent.c
@@ -37,22 +37,7 @@ create_continue_event_object ()
 {
   return (continue_event_object *)
       create_event_object (&continue_event_object_type,
-                           "continue");
-}
-
-/* Initialize the Python continue event code.  */
-
-void
-gdbpy_initialize_continue_event (void)
-{
-  continue_event_object_type.tp_base = &event_object_type;
-  if (PyType_Ready (&continue_event_object_type) < 0)
-    return;
-
-  //FIXME: Where is this freed ?
-  Py_INCREF (&continue_event_object_type);
-  PyModule_AddObject (gdb_module, "ContinueEvent",
-                      (PyObject *) &continue_event_object_type);
+                           (thread_object *) Py_None);
 }
 
 /* Callback function which notifies oversvers when a continue event occurs.
@@ -65,44 +50,9 @@ emit_continue_event (ptid_t ptid)
                    gdb_py_events->cont);
 }
 
-static PyTypeObject continue_event_object_type =
-{
-  PyObject_HEAD_INIT (NULL)
-  0,                                          /* ob_size */
-  "gdb.ContinueEvent",                        /* tp_name */
-  sizeof (continue_event_object),             /* tp_basicsize */
-  0,                                          /* tp_itemsize */
-  continue_evpy_dealloc,                      /* tp_dealloc */
-  0,                                          /* tp_print */
-  0,                                          /* tp_getattr */
-  0,                                          /* tp_setattr */
-  0,                                          /* tp_compare */
-  0,                                          /* tp_repr */
-  0,                                          /* tp_as_number */
-  0,                                          /* tp_as_sequence */
-  0,                                          /* tp_as_mapping */
-  0,                                          /* tp_hash  */
-  0,                                          /* tp_call */
-  0,                                          /* tp_str */
-  0,                                          /* tp_getattro */
-  0,                                          /* tp_setattro */
-  0,                                          /* tp_as_buffer */
-  Py_TPFLAGS_DEFAULT,                         /* tp_flags */
-  "GDB continue event object",                /* tp_doc */
-  0,                                          /* tp_traverse */
-  0,                                          /* tp_clear */
-  0,                                          /* tp_richcompare */
-  0,                                          /* tp_weaklistoffset */
-  0,                                          /* tp_iter */
-  0,                                          /* tp_iternext */
-  0,                                          /* tp_methods */
-  0,                                          /* tp_members */
-  0,                                          /* tp_getset */
-  0,                                          /* tp_base */
-  0,                                          /* tp_dict */
-  0,                                          /* tp_descr_get */
-  0,                                          /* tp_descr_set */
-  0,                                          /* tp_dictoffset */
-  0,                                          /* tp_init */
-  0                                           /* tp_alloc */
-};
+PY_NEW_EVENT_TYPE (continue,
+                   "gdb.ContinueEvent",
+                   "ContinueEvent",
+                   "GDB continue event object",
+                   event_object_type,
+                   static);
diff --git a/gdb/python/py-event.c b/gdb/python/py-event.c
index 6c8d881..2faa452 100644
--- a/gdb/python/py-event.c
+++ b/gdb/python/py-event.c
@@ -22,101 +22,73 @@
 void
 evpy_dealloc (PyObject *self)
 {
-  Py_DECREF (((event_object *) self)->event_type);
+  Py_XDECREF (((event_object *) self)->dict);
   self->ob_type->tp_free (self);
 }
 
 event_object *
 create_event_object (PyTypeObject *py_type,
-                     const char *event_type)
+                     thread_object *inferior_thread)
 {
   event_object *event_obj;
 
   event_obj = PyObject_New (event_object, py_type);
   if (!event_obj)
-    return NULL;
-
-  event_obj->event_type = (PyStringObject *) PyString_FromString (event_type);
+    goto fail;
 
-  return event_obj;
-}
+  event_obj->dict = PyDict_New ();
+  if (!event_obj->dict)
+    goto fail;
 
-/* Python function to get the event's thread.  */
+  event_obj->inferior_thread = (PyObject *)inferior_thread;
 
-static PyObject *
-evpy_get_inferior_thread (PyObject *self, void *closure)
-{
-  event_object *event_obj = (event_object *) self;
+  evpy_add_attribute (event_obj, "inferior_thread", event_obj->inferior_thread);
 
-  //FIXME where is this getting cleared.
-  Py_INCREF (event_obj->inferior_thread);
+  return event_obj;
 
-  return (PyObject *) (event_obj->inferior_thread);
+ fail:
+  Py_XDECREF (event_obj);
+  Py_XDECREF (event_obj->dict);
+  return NULL;
 }
 
-/* Python function to get the event's type.  */
+/* Add the attribute ATTR to the event object EVENT. In
+   python this attribute will be accessable by the name NAME.  */
 
-static PyObject *
-evpy_get_event_type (PyObject *self, void *closure)
+void
+evpy_add_attribute (event_object *event, char *name, PyObject *attr)
 {
-  event_object *event_obj = (event_object *) self;
-
-  //FIXME where is this getting cleared.
-  Py_INCREF (event_obj->event_type);
-
-  return (PyObject *) (event_obj->event_type);
+  if (PyObject_SetAttrString ((PyObject *) event, name, attr) < 0)
+    error (_("Could not add event attribute %s"), name);
 }
 
-/* Initialize python events.  */
+/* Initialize the Python event code.  */
 
 void
-gdbpy_initialize_py_events()
+gdbpy_initialize_event (void)
 {
-
-  if (PyType_Ready (&events_object_type) < 0)
-    return;
-
-  gdb_py_events = PyObject_New (events_object,
-                                &events_object_type);
-
-  gdb_py_events->stop = create_eventregistry_object ();
-  gdb_py_events->breakpoint = create_eventregistry_object ();
-  gdb_py_events->signal = create_eventregistry_object ();
-  gdb_py_events->cont = create_eventregistry_object ();
-  gdb_py_events->exited = create_eventregistry_object ();
-
-  PyDict_SetItemString (events_object_type.tp_dict,
-                        "stop",
-                        (PyObject *) gdb_py_events->stop);
-  PyDict_SetItemString (events_object_type.tp_dict,
-                        "breakpoint",
-                        (PyObject *) gdb_py_events->breakpoint);
-  PyDict_SetItemString (events_object_type.tp_dict,
-                        "signal",
-                        (PyObject *) gdb_py_events->signal);
-  PyDict_SetItemString (events_object_type.tp_dict,
-                        "cont",
-                        (PyObject *) gdb_py_events->cont);
-  PyDict_SetItemString (events_object_type.tp_dict,
-                        "exited",
-                        (PyObject *) gdb_py_events->exited);
-
-  Py_INCREF (&events_object_type);
-  PyModule_AddObject (gdb_module, "events", (PyObject *) &events_object_type);
+  gdbpy_initialize_event_generic (&event_object_type,
+                                  NULL,
+                                  "Event");
 }
 
+/* Initialize the given event type. If BASE is not NULL it will
+  be set as the types base.  */
 
-/* Initialize the Python event code. */
 void
-gdbpy_initialize_event (void)
+gdbpy_initialize_event_generic (PyTypeObject *type,
+                                PyTypeObject *base, char *name)
 {
-  if (PyType_Ready (&event_object_type) < 0)
-    return;
+  if (base)
+    type->tp_base = base;
+  if (PyType_Ready (type) < 0)
+    error(_("Could not initialize event %s"), name);
 
-  Py_INCREF (&event_object_type);
-  PyModule_AddObject (gdb_module, "Event", (PyObject *) &event_object_type);
+  Py_INCREF (type);
+  PyModule_AddObject (gdb_module, name, (PyObject *) type);
 }
 
+
 /* Notify the list of listens that the given EVENT has occured.  */


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-12-20 15:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-20 15:47 [SCM] archer-swagiaal-oguz: Document PY_NEW_EVENT_TYPE swagiaal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).