diff options
author | Johan Dahlin <johan@gnome.org> | 2008-07-26 13:46:56 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2008-07-26 13:46:56 +0000 |
commit | 4cd2081ae3d8adacd4256742be9e90714783c242 (patch) | |
tree | c5e4fe6b3ca14cd5c994418a8f18a1d00116cfaf /glib | |
parent | ec4671da7f7fe70f40dafb91a870fa644c2b9f2c (diff) | |
download | pygobject-4cd2081ae3d8adacd4256742be9e90714783c242.tar.gz pygobject-4cd2081ae3d8adacd4256742be9e90714783c242.tar.xz pygobject-4cd2081ae3d8adacd4256742be9e90714783c242.zip |
Convert the pid/mainloop/maincontext/optiongroup/optioncontext.
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.
svn path=/trunk/; revision=872
Diffstat (limited to 'glib')
-rw-r--r-- | glib/pygmaincontext.c | 48 | ||||
-rw-r--r-- | glib/pygmainloop.c | 50 | ||||
-rw-r--r-- | glib/pygoptioncontext.c | 51 | ||||
-rw-r--r-- | glib/pygoptiongroup.c | 48 | ||||
-rw-r--r-- | glib/pygspawn.c | 50 |
5 files changed, 37 insertions, 210 deletions
diff --git a/glib/pygmaincontext.c b/glib/pygmaincontext.c index c969af5..d4906be 100644 --- a/glib/pygmaincontext.c +++ b/glib/pygmaincontext.c @@ -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 @@ static PyMethodDef _PyGMainContext_methods[] = { { 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"); } diff --git a/glib/pygmainloop.c b/glib/pygmainloop.c index 04653de..e966962 100644 --- a/glib/pygmainloop.c +++ b/glib/pygmainloop.c @@ -227,8 +227,10 @@ pyg_signal_watch_new(void) 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 @@ static PyMethodDef _PyGMainLoop_methods[] = { { 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"); } diff --git a/glib/pygoptioncontext.c b/glib/pygoptioncontext.c index ea3c304..00bf7ee 100644 --- a/glib/pygoptioncontext.c +++ b/glib/pygoptioncontext.c @@ -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 @@ pyg_option_context_set_main_group(PyGOptionContext *self, 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 @@ static PyMethodDef pyg_option_context_methods[] = { { 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"); } diff --git a/glib/pygoptiongroup.c b/glib/pygoptiongroup.c index cb1d62f..c230245 100644 --- a/glib/pygoptiongroup.c +++ b/glib/pygoptiongroup.c @@ -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 @@ static PyMethodDef pyg_option_group_methods[] = { { 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"); } diff --git a/glib/pygspawn.c b/glib/pygspawn.c index 515cdd9..7bb76b5 100644 --- a/glib/pygspawn.c +++ b/glib/pygspawn.c @@ -32,6 +32,8 @@ struct _PyGChildSetupData { 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 @@ pyg_pid_tp_init(PyObject *self, PyObject *args, PyObject *kwargs) 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 @@ void 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"); } |