pygobject r872 - in trunk: . glib



Author: johan
Date: Sat Jul 26 13:46:56 2008
New Revision: 872
URL: http://svn.gnome.org/viewvc/pygobject?rev=872&view=rev

Log:
2008-07-26  Johan Dahlin  <johan gnome org>

    * glib/pygmaincontext.c (pyglib_maincontext_register_types):
    * glib/pygmainloop.c (pyg_main_loop_init),
    (pyglib_mainloop_register_types):
    * glib/pygoptioncontext.c (pyg_option_context_set_main_group),
    (pyglib_option_context_register_types):
    * glib/pygoptiongroup.c (pyglib_option_group_register_types):
    * glib/pygspawn.c (pyglib_spawn_register_types):
    Convert the pid/mainloop/maincontext/optiongroup/optioncontext.



Modified:
   trunk/ChangeLog
   trunk/glib/pygmaincontext.c
   trunk/glib/pygmainloop.c
   trunk/glib/pygoptioncontext.c
   trunk/glib/pygoptiongroup.c
   trunk/glib/pygspawn.c

Modified: trunk/glib/pygmaincontext.c
==============================================================================
--- trunk/glib/pygmaincontext.c	(original)
+++ trunk/glib/pygmaincontext.c	Sat Jul 26 13:46:56 2008
@@ -31,6 +31,8 @@
 #include "pyglib.h"
 #include "pyglib-private.h"
 
+PYGLIB_DEFINE_TYPE("glib.MainContext", PyGMainContext_Type, PyGMainContext)
+
 static int
 pyg_main_context_init(PyGMainContext *self)
 {
@@ -85,49 +87,13 @@
     { NULL, NULL, 0 }
 };
 
-PyTypeObject PyGMainContext_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0,
-    "glib.MainContext",
-    sizeof(PyGMainContext),
-    0,
-    /* methods */
-    (destructor)pyg_main_context_dealloc,
-    (printfunc)0,
-    (getattrfunc)0,
-    (setattrfunc)0,
-    (cmpfunc)pyg_main_context_compare,
-    (reprfunc)0,
-    0,
-    0,
-    0,
-    (hashfunc)0,
-    (ternaryfunc)0,
-    (reprfunc)0,
-    (getattrofunc)0,
-    (setattrofunc)0,
-    0,
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
-    NULL,
-    (traverseproc)0,
-    (inquiry)0,
-    (richcmpfunc)0,
-    0,
-    (getiterfunc)0,
-    (iternextfunc)0,
-    _PyGMainContext_methods,
-    0,
-    0,
-    NULL,
-    NULL,
-    (descrgetfunc)0,
-    (descrsetfunc)0,
-    0,
-    (initproc)pyg_main_context_init,
-};
-
 void
 pyglib_maincontext_register_types(PyObject *d)
 {
+    PyGMainContext_Type.tp_dealloc = (destructor)pyg_main_context_dealloc;
+    PyGMainContext_Type.tp_compare = (cmpfunc)pyg_main_context_compare;
+    PyGMainContext_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
+    PyGMainContext_Type.tp_methods = _PyGMainContext_methods;
+    PyGMainContext_Type.tp_init = (initproc)pyg_main_context_init;
     PYGLIB_REGISTER_TYPE(d, PyGMainContext_Type, "MainContext"); 
 }

Modified: trunk/glib/pygmainloop.c
==============================================================================
--- trunk/glib/pygmainloop.c	(original)
+++ trunk/glib/pygmainloop.c	Sat Jul 26 13:46:56 2008
@@ -227,8 +227,10 @@
     return g_source_new(&pyg_signal_watch_funcs, sizeof(PySignalWatchSource));
 }
 
+PYGLIB_DEFINE_TYPE("glib.MainLoop", PyGMainLoop_Type, PyGMainLoop)
+
 static int
-pyg_main_loop_new(PyGMainLoop *self, PyObject *args, PyObject *kwargs)
+pyg_main_loop_init(PyGMainLoop *self, PyObject *args, PyObject *kwargs)
 {
 
     static char *kwlist[] = { "context", "is_running", NULL };
@@ -335,49 +337,13 @@
     { NULL, NULL, 0 }
 };
 
-PyTypeObject PyGMainLoop_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0,			
-    "glib.MainLoop",	
-    sizeof(PyGMainLoop),	
-    0,			
-    /* methods */
-    (destructor)pyg_main_loop_dealloc,	
-    (printfunc)0,	
-    (getattrfunc)0,	
-    (setattrfunc)0,	
-    (cmpfunc)pyg_main_loop_compare,
-    (reprfunc)0,	
-    0,			
-    0,		
-    0,		
-    (hashfunc)0,		
-    (ternaryfunc)0,		
-    (reprfunc)0,		
-    (getattrofunc)0,		
-    (setattrofunc)0,		
-    0,				
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, 
-    NULL,
-    (traverseproc)0,		
-    (inquiry)0,
-    (richcmpfunc)0,	
-    0,             
-    (getiterfunc)0,
-    (iternextfunc)0,
-    _PyGMainLoop_methods,
-    0,				
-    0,		       	
-    NULL,		
-    NULL,		
-    (descrgetfunc)0,	
-    (descrsetfunc)0,	
-    0,                 
-    (initproc)pyg_main_loop_new,
-};
-
 void
 pyglib_mainloop_register_types(PyObject *d)
 {
+    PyGMainLoop_Type.tp_dealloc = (destructor)pyg_main_loop_dealloc;
+    PyGMainLoop_Type.tp_compare = (cmpfunc)pyg_main_loop_compare;
+    PyGMainLoop_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
+    PyGMainLoop_Type.tp_methods = _PyGMainLoop_methods;
+    PyGMainLoop_Type.tp_init = (initproc)pyg_main_loop_init;
     PYGLIB_REGISTER_TYPE(d, PyGMainLoop_Type, "MainLoop"); 
 }

Modified: trunk/glib/pygoptioncontext.c
==============================================================================
--- trunk/glib/pygoptioncontext.c	(original)
+++ trunk/glib/pygoptioncontext.c	Sat Jul 26 13:46:56 2008
@@ -28,6 +28,8 @@
 #include "pyglib-private.h"
 #include "pygoptioncontext.h"
 
+PYGLIB_DEFINE_TYPE("glib.OptionContext", PyGOptionContext_Type, PyGOptionContext)
+
 static int
 pyg_option_context_init(PyGOptionContext *self, 
                         PyObject *args,
@@ -201,7 +203,8 @@
     g_group = pyglib_option_group_transfer_group(group);
     if (g_group == NULL)
     {
-        PyErr_SetString(PyExc_RuntimeError, "Group is already in a OptionContext.");
+        PyErr_SetString(PyExc_RuntimeError,
+			"Group is already in a OptionContext.");
         return NULL;
     }
 
@@ -277,49 +280,13 @@
     { NULL, NULL, 0 },
 };
 
-PyTypeObject PyGOptionContext_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0,
-    "gobject.OptionContext",
-    sizeof(PyGOptionContext),
-    0,
-    /* methods */
-    (destructor)pyg_option_context_dealloc,
-    (printfunc)0,
-    (getattrfunc)0,
-    (setattrfunc)0,
-    (cmpfunc)pyg_option_context_compare,
-    (reprfunc)0,
-    0,
-    0,
-    0,
-    (hashfunc)0,
-    (ternaryfunc)0,
-    (reprfunc)0,
-    (getattrofunc)0,
-    (setattrofunc)0,
-    0,
-    Py_TPFLAGS_DEFAULT,
-    NULL,
-    (traverseproc)0,
-    (inquiry)0,
-    (richcmpfunc)0,
-    0,
-    (getiterfunc)0,
-    (iternextfunc)0,
-    pyg_option_context_methods,
-    0,
-    0,
-    NULL,
-    NULL,
-    (descrgetfunc)0,
-    (descrsetfunc)0,
-    0,
-    (initproc)pyg_option_context_init,
-};
-
 void
 pyglib_option_context_register_types(PyObject *d)
 {
+    PyGOptionContext_Type.tp_dealloc = (destructor)pyg_option_context_dealloc;
+    PyGOptionContext_Type.tp_compare = (cmpfunc)pyg_option_context_compare;
+    PyGOptionContext_Type.tp_flags = Py_TPFLAGS_DEFAULT;
+    PyGOptionContext_Type.tp_methods = pyg_option_context_methods;
+    PyGOptionContext_Type.tp_init = (initproc)pyg_option_context_init;
     PYGLIB_REGISTER_TYPE(d, PyGOptionContext_Type, "OptionContext");
 }

Modified: trunk/glib/pygoptiongroup.c
==============================================================================
--- trunk/glib/pygoptiongroup.c	(original)
+++ trunk/glib/pygoptiongroup.c	Sat Jul 26 13:46:56 2008
@@ -28,6 +28,8 @@
 #include "pyglib-private.h"
 #include "pygoptiongroup.h"
 
+PYGLIB_DEFINE_TYPE("glib.OptionGroup", PyGOptionGroup_Type, PyGOptionGroup)
+
 static gboolean
 check_if_owned(PyGOptionGroup *self)
 {
@@ -254,50 +256,14 @@
     { NULL, NULL, 0 },
 };
 
-PyTypeObject PyGOptionGroup_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0,
-    "gobject.OptionGroup",
-    sizeof(PyGOptionGroup),
-    0,
-    /* methods */
-    (destructor)pyg_option_group_dealloc,
-    (printfunc)0,
-    (getattrfunc)0,
-    (setattrfunc)0,
-    (cmpfunc)pyg_option_group_compare,
-    (reprfunc)0,
-    0,
-    0,
-    0,
-    (hashfunc)0,
-    (ternaryfunc)0,
-    (reprfunc)0,
-    (getattrofunc)0,
-    (setattrofunc)0,
-    0,
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
-    NULL,
-    (traverseproc)0,
-    (inquiry)0,
-    (richcmpfunc)0,
-    0,
-    (getiterfunc)0,
-    (iternextfunc)0,
-    pyg_option_group_methods,
-    0,
-    0,
-    NULL,
-    NULL,
-    (descrgetfunc)0,
-    (descrsetfunc)0,
-    0,
-    (initproc)pyg_option_group_init,
-};
-
 void
 pyglib_option_group_register_types(PyObject *d)
 {
+    PyGOptionGroup_Type.tp_dealloc = (destructor)pyg_option_group_dealloc;
+    PyGOptionGroup_Type.tp_compare = (cmpfunc)pyg_option_group_compare;
+    PyGOptionGroup_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
+    PyGOptionGroup_Type.tp_methods = pyg_option_group_methods;
+    PyGOptionGroup_Type.tp_init = (initproc)pyg_option_group_init;
     PYGLIB_REGISTER_TYPE(d, PyGOptionGroup_Type, "OptionGroup");
 }
 

Modified: trunk/glib/pygspawn.c
==============================================================================
--- trunk/glib/pygspawn.c	(original)
+++ trunk/glib/pygspawn.c	Sat Jul 26 13:46:56 2008
@@ -32,6 +32,8 @@
     PyObject *data;
 };
 
+PYGLIB_DEFINE_TYPE("glib.Pid", PyGPid_Type, PyIntObject)
+
 static PyObject *
 pyg_pid_close(PyIntObject *self, PyObject *args, PyObject *kwargs)
 {
@@ -59,50 +61,6 @@
     return -1;
 }
 
-static PyTypeObject PyGPid_Type = {
-    PyObject_HEAD_INIT(NULL)
-    0,
-    "glib.Pid",
-    sizeof(PyIntObject),
-    0,
-    0,					  /* 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 */
-    0,      				  /* tp_doc */
-    0,					  /* tp_traverse */
-    0,					  /* tp_clear */
-    0,					  /* tp_richcompare */
-    0,					  /* tp_weaklistoffset */
-    0,					  /* tp_iter */
-    0,					  /* tp_iternext */
-    pyg_pid_methods,			  /* 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 */
-    pyg_pid_tp_init,		  	  /* tp_init */
-    0,					  /* tp_alloc */
-    0,					  /* tp_new */
-    (freefunc)pyg_pid_free,		  /* tp_free */
-    0,					  /* tp_is_gc */
-};
-
 PyObject *
 pyg_pid_new(GPid pid)
 {
@@ -293,5 +251,9 @@
 pyglib_spawn_register_types(PyObject *d)
 {
     PyGPid_Type.tp_base = &PyInt_Type;
+    PyGPid_Type.tp_flags = Py_TPFLAGS_DEFAULT;
+    PyGPid_Type.tp_methods = pyg_pid_methods;
+    PyGPid_Type.tp_init = pyg_pid_tp_init;
+    PyGPid_Type.tp_free = (freefunc)pyg_pid_free;
     PYGLIB_REGISTER_TYPE(d, PyGPid_Type, "Pid");
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]