functions: revert the function init order to make pylint happy again. See #217
[pygobject.git] / tests / testhelpermodule.c
blobe26a004be312d61c71f152161f1131d85921a73a
1 #include "pygobject.h"
2 #include <gobject/gmarshal.h>
4 #include "test-thread.h"
5 #include "test-unknown.h"
6 #include "test-floating.h"
8 #include "pygi-python-compat.h"
10 static PyObject * _wrap_TestInterface__do_iface_method(PyObject *cls,
11 PyObject *args,
12 PyObject *kwargs);
14 static GType
15 test_type_get_type(void)
17 static GType gtype = 0;
18 GType parent_type;
20 if (gtype == 0)
22 GTypeInfo *type_info;
23 GTypeQuery query;
25 parent_type = g_type_from_name("PyGObject");
26 if (parent_type == 0)
27 g_error("could not get PyGObject from testmodule");
29 type_info = (GTypeInfo *)g_new0(GTypeInfo, 1);
31 g_type_query(parent_type, &query);
32 type_info->class_size = (guint16)query.class_size;
33 type_info->instance_size = (guint16)query.instance_size;
35 gtype = g_type_register_static(parent_type,
36 "TestType", type_info, 0);
37 if (!gtype)
38 g_error("Could not register TestType");
41 return gtype;
44 #define TYPE_TEST (test_type_get_type())
46 static PyObject *
47 _wrap_get_test_thread (PyObject * self)
49 GObject *obj;
51 test_thread_get_type();
52 g_assert (g_type_is_a (TEST_TYPE_THREAD, G_TYPE_OBJECT));
53 obj = g_object_new (TEST_TYPE_THREAD, NULL);
54 g_assert (obj != NULL);
56 return pygobject_new(obj);
59 static PyObject *
60 _wrap_get_unknown (PyObject * self)
62 GObject *obj;
63 obj = g_object_new (TEST_TYPE_UNKNOWN, NULL);
64 return pygobject_new(obj);
67 static PyObject *
68 _wrap_create_test_type (PyObject * self)
70 GObject *obj;
71 PyObject *rv;
72 obj = g_object_new(TYPE_TEST, NULL);
73 rv = pygobject_new(obj);
74 g_object_unref(obj);
75 return rv;
78 static PyObject *
79 _wrap_test_g_object_new (PyObject * self)
81 GObject *obj;
82 PyObject *rv;
84 obj = g_object_new(g_type_from_name("PyGObject"), NULL);
85 rv = PYGLIB_PyLong_FromLong(obj->ref_count); /* should be == 2 at this point */
86 g_object_unref(obj);
87 return rv;
90 /* TestUnknown */
91 static PyObject *
92 _wrap_test_interface_iface_method(PyGObject *self, PyObject *args, PyObject *kwargs)
94 static char *kwlist[] = { NULL };
96 if (!PyArg_ParseTupleAndKeywords(args, kwargs,":", kwlist))
97 return NULL;
99 test_interface_iface_method(TEST_INTERFACE(self->obj));
101 Py_INCREF(Py_None);
102 return Py_None;
105 static const PyMethodDef _PyTestInterface_methods[] = {
106 { "iface_method", (PyCFunction)_wrap_test_interface_iface_method, METH_VARARGS|METH_KEYWORDS,
107 NULL },
108 { "do_iface_method", (PyCFunction)_wrap_TestInterface__do_iface_method, METH_VARARGS|METH_KEYWORDS|METH_CLASS,
109 NULL },
110 { NULL, NULL, 0, NULL }
113 /* TestInterface */
114 PYGLIB_DEFINE_TYPE("test.Interface", PyTestInterface_Type, PyObject);
116 static PyObject *
117 _wrap_TestInterface__do_iface_method(PyObject *cls, PyObject *args, PyObject *kwargs)
119 TestInterfaceIface *iface;
120 static char *kwlist[] = { "self", NULL };
121 PyGObject *self;
123 if (!PyArg_ParseTupleAndKeywords(args, kwargs,"O!:TestInterface.iface_method", kwlist, &PyTestInterface_Type, &self))
124 return NULL;
126 iface = g_type_interface_peek(g_type_class_peek(pyg_type_from_object(cls)),
127 TEST_TYPE_INTERFACE);
128 if (iface->iface_method)
129 iface->iface_method(TEST_INTERFACE(self->obj));
130 else {
131 PyErr_SetString(PyExc_NotImplementedError,
132 "interface method TestInterface.iface_method not implemented");
133 return NULL;
135 Py_INCREF(Py_None);
136 return Py_None;
139 PYGLIB_DEFINE_TYPE("testhelper.Unknown", PyTestUnknown_Type, PyGObject);
141 static void
142 _wrap_TestInterface__proxy_do_iface_method(TestInterface *self)
144 PyGILState_STATE __py_state;
145 PyObject *py_self;
146 PyObject *py_retval;
147 PyObject *py_args;
148 PyObject *py_method;
150 __py_state = PyGILState_Ensure();
151 py_self = pygobject_new((GObject *) self);
152 if (!py_self) {
153 if (PyErr_Occurred())
154 PyErr_Print();
155 PyGILState_Release(__py_state);
156 return;
158 py_args = PyTuple_New(0);
159 py_method = PyObject_GetAttrString(py_self, "do_iface_method");
160 if (!py_method) {
161 if (PyErr_Occurred())
162 PyErr_Print();
163 Py_DECREF(py_args);
164 Py_DECREF(py_self);
165 PyGILState_Release(__py_state);
166 return;
168 py_retval = PyObject_CallObject(py_method, py_args);
169 if (!py_retval) {
170 if (PyErr_Occurred())
171 PyErr_Print();
172 Py_DECREF(py_method);
173 Py_DECREF(py_args);
174 Py_DECREF(py_self);
175 PyGILState_Release(__py_state);
176 return;
178 if (py_retval != Py_None) {
179 if (PyErr_Occurred())
180 PyErr_Print();
181 PyErr_SetString(PyExc_TypeError, "retval should be None");
182 Py_DECREF(py_retval);
183 Py_DECREF(py_method);
184 Py_DECREF(py_args);
185 Py_DECREF(py_self);
186 PyGILState_Release(__py_state);
187 return;
190 Py_DECREF(py_retval);
191 Py_DECREF(py_method);
192 Py_DECREF(py_args);
193 Py_DECREF(py_self);
194 PyGILState_Release(__py_state);
197 static void
198 __TestInterface__interface_init(TestInterfaceIface *iface,
199 PyTypeObject *pytype)
201 TestInterfaceIface *parent_iface = g_type_interface_peek_parent(iface);
202 PyObject *py_method;
204 py_method = pytype ? PyObject_GetAttrString((PyObject *) pytype,
205 "do_iface_method") : NULL;
207 if (py_method && !PyObject_TypeCheck(py_method, &PyCFunction_Type)) {
208 iface->iface_method = _wrap_TestInterface__proxy_do_iface_method;
209 } else {
210 PyErr_Clear();
211 if (parent_iface) {
212 iface->iface_method = parent_iface->iface_method;
214 Py_XDECREF(py_method);
218 static const GInterfaceInfo __TestInterface__iinfo = {
219 (GInterfaceInitFunc) __TestInterface__interface_init,
220 NULL,
221 NULL
224 /* TestFloating */
225 PYGLIB_DEFINE_TYPE("testhelper.Floating", PyTestFloating_Type, PyGObject);
227 /* TestOwnedByLibrary */
228 PYGLIB_DEFINE_TYPE("testhelper.OwnedByLibrary", PyTestOwnedByLibrary_Type, PyGObject);
230 static PyObject *
231 _wrap_test_owned_by_library_release (PyGObject *self)
233 test_owned_by_library_release (TEST_OWNED_BY_LIBRARY (self->obj));
234 return Py_None;
237 static const PyMethodDef _PyTestOwnedByLibrary_methods[] = {
238 { "release", (PyCFunction)_wrap_test_owned_by_library_release, METH_NOARGS, NULL },
239 { NULL, NULL, 0, NULL }
242 /* TestFloatingAndSunk */
243 PYGLIB_DEFINE_TYPE("testhelper.FloatingAndSunk", PyTestFloatingAndSunk_Type, PyGObject);
245 static PyObject *
246 _wrap_test_floating_and_sunk_release (PyGObject *self)
248 test_floating_and_sunk_release (TEST_FLOATING_AND_SUNK (self->obj));
249 return Py_None;
252 static const PyMethodDef _PyTestFloatingAndSunk_methods[] = {
253 { "release", (PyCFunction)_wrap_test_floating_and_sunk_release, METH_NOARGS, NULL },
254 { NULL, NULL, 0, NULL }
258 #include <string.h>
259 #include <glib-object.h>
261 static void
262 test1_callback (GObject *object, char *data)
264 g_return_if_fail (G_IS_OBJECT (object));
265 g_return_if_fail (!strcmp (data, "user-data"));
268 static void
269 test1_callback_swapped (char *data, GObject *object)
271 g_return_if_fail (G_IS_OBJECT (object));
272 g_return_if_fail (!strcmp (data, "user-data"));
275 static void
276 test2_callback (GObject *object, char *string)
278 g_return_if_fail (G_IS_OBJECT (object));
279 g_return_if_fail (!strcmp (string, "string"));
282 static int
283 test3_callback (GObject *object, double d)
285 g_return_val_if_fail (G_IS_OBJECT (object), -1);
286 g_return_val_if_fail (d == 42.0, -1);
288 return 20;
291 static void
292 test4_callback (GObject *object,
293 gboolean b, long l, float f, double d, guint uint, gulong ulong,
294 gpointer user_data)
296 g_return_if_fail (b == TRUE);
297 g_return_if_fail (l == 10L);
298 g_return_if_fail (f <= 3.14001 && f >= 3.13999);
299 g_return_if_fail (d <= 1.78001 && d >= 1.77999);
300 g_return_if_fail (uint == 20);
301 g_return_if_fail (ulong == 30L);
304 static float
305 test_float_callback (GObject *object, float f)
307 g_return_val_if_fail (G_IS_OBJECT (object), -1);
308 g_return_val_if_fail (f <= 1.234001 && f >= 1.123999, -1);
310 return f;
313 static double
314 test_double_callback (GObject *object, double d)
316 g_return_val_if_fail (G_IS_OBJECT (object), -1);
317 g_return_val_if_fail (d <= 1.234001 && d >= 1.123999, -1);
319 return d;
322 static gint64
323 test_int64_callback (GObject *object, gint64 i)
325 g_return_val_if_fail (G_IS_OBJECT (object), -1);
327 if (i == G_MAXINT64)
328 return i-1;
329 return i;
332 static char *
333 test_string_callback (GObject *object, char *s)
335 g_return_val_if_fail (G_IS_OBJECT (object), NULL);
336 g_return_val_if_fail (!strcmp(s, "str"), NULL);
338 return g_strdup (s);
341 static GObject *
342 test_object_callback (GObject *object, GObject *o)
344 g_return_val_if_fail (G_IS_OBJECT (object), NULL);
346 return o;
349 static GParamSpec *
350 test_paramspec_callback (GObject *object)
352 g_return_val_if_fail (G_IS_OBJECT (object), NULL);
354 return g_param_spec_boolean ("test-param", "test", "test boolean", TRUE, G_PARAM_READABLE);
357 static GValue *
358 test_gvalue_callback (GObject *object, const GValue *v)
360 GValue *ret = g_malloc0 (sizeof (GValue));
362 g_return_val_if_fail (G_IS_OBJECT (object), NULL);
363 g_return_val_if_fail (G_IS_VALUE (v), NULL);
365 g_value_init (ret, G_VALUE_TYPE (v));
366 g_value_copy (v, ret);
367 return ret;
370 static GValue *
371 test_gvalue_ret_callback (GObject *object, GType type)
373 GValue *ret = g_malloc0 (sizeof (GValue));
375 g_return_val_if_fail (G_IS_OBJECT (object), NULL);
377 g_value_init (ret, type);
379 switch (type) {
380 case G_TYPE_INT:
381 g_value_set_int(ret, G_MAXINT);
382 break;
383 case G_TYPE_INT64:
384 g_value_set_int64(ret, G_MAXINT64);
385 break;
386 case G_TYPE_UINT:
387 g_value_set_uint(ret, G_MAXUINT);
388 break;
389 case G_TYPE_UINT64:
390 g_value_set_uint64(ret, G_MAXUINT64);
391 break;
392 case G_TYPE_STRING:
393 g_value_set_string(ret, "hello");
394 break;
395 default:
396 g_critical ("test_gvalue_ret_callback() does not support type %s", g_type_name (type));
399 return ret;
402 static GParamSpec *
403 test_paramspec_in_callback (GObject *object, GParamSpec *p)
405 g_return_val_if_fail (G_IS_OBJECT (object), NULL);
406 g_return_val_if_fail (G_IS_PARAM_SPEC (p), NULL);
408 return p;
411 static void
412 connectcallbacks (GObject *object)
415 gchar *data = "user-data";
417 g_signal_connect (G_OBJECT (object),
418 "test1",
419 G_CALLBACK (test1_callback),
420 data);
421 g_signal_connect_swapped (G_OBJECT (object),
422 "test1",
423 G_CALLBACK (test1_callback_swapped),
424 data);
425 g_signal_connect (G_OBJECT (object),
426 "test2",
427 G_CALLBACK (test2_callback),
428 NULL);
429 g_signal_connect (G_OBJECT (object),
430 "test3",
431 G_CALLBACK (test3_callback),
432 NULL);
433 g_signal_connect (G_OBJECT (object),
434 "test4",
435 G_CALLBACK (test4_callback),
436 NULL);
437 g_signal_connect (G_OBJECT (object),
438 "test_float",
439 G_CALLBACK (test_float_callback),
440 NULL);
441 g_signal_connect (G_OBJECT (object),
442 "test_double",
443 G_CALLBACK (test_double_callback),
444 NULL);
445 g_signal_connect (G_OBJECT (object),
446 "test_int64",
447 G_CALLBACK (test_int64_callback),
448 NULL);
449 g_signal_connect (G_OBJECT (object),
450 "test_string",
451 G_CALLBACK (test_string_callback),
452 NULL);
453 g_signal_connect (G_OBJECT (object),
454 "test_object",
455 G_CALLBACK (test_object_callback),
456 NULL);
457 g_signal_connect (G_OBJECT (object),
458 "test_paramspec",
459 G_CALLBACK (test_paramspec_callback),
460 NULL);
461 g_signal_connect (G_OBJECT (object),
462 "test_gvalue",
463 G_CALLBACK (test_gvalue_callback),
464 NULL);
465 g_signal_connect (G_OBJECT (object),
466 "test_gvalue_ret",
467 G_CALLBACK (test_gvalue_ret_callback),
468 NULL);
469 g_signal_connect (G_OBJECT (object),
470 "test_paramspec_in",
471 G_CALLBACK (test_paramspec_in_callback),
472 NULL);
475 static PyObject *
476 _wrap_connectcallbacks(PyObject * self, PyObject *args)
478 PyGObject *obj;
480 if (!PyArg_ParseTuple(args, "O", &obj))
481 return NULL;
483 connectcallbacks (G_OBJECT (obj->obj));
485 Py_INCREF(Py_None);
486 return Py_None;
489 static PyObject *
490 _wrap_test_value(PyObject *self, PyObject *args)
492 GValue tvalue = {0,}, *value = &tvalue;
493 PyObject *obj;
495 if (!PyArg_ParseTuple(args, "O", &obj))
496 return NULL;
498 g_value_init(value, G_TYPE_VALUE);
499 if (pyg_value_from_pyobject(value, obj)) {
500 PyErr_SetString(PyExc_TypeError, "Could not convert to GValue");
501 return NULL;
504 return pyg_value_as_pyobject(value, FALSE);
507 static PyObject *
508 _wrap_test_state_ensure_release(PyObject *self, PyObject *args)
510 int state = pyg_gil_state_ensure ();
511 pyg_gil_state_release (state);
513 Py_RETURN_NONE;
516 static PyObject *
517 _wrap_test_value_array(PyObject *self, PyObject *args)
519 GValue tvalue = {0,}, *value = &tvalue;
520 PyObject *obj;
522 if (!PyArg_ParseTuple(args, "O", &obj))
523 return NULL;
525 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
526 g_value_init(value, G_TYPE_VALUE_ARRAY);
527 G_GNUC_END_IGNORE_DEPRECATIONS
529 if (pyg_value_from_pyobject(value, obj)) {
530 PyErr_SetString(PyExc_TypeError, "Could not convert to GValueArray");
531 return NULL;
534 return pyg_value_as_pyobject(value, FALSE);
538 static PyObject *
539 _wrap_value_array_get_nth_type(PyObject *self, PyObject *args)
541 guint n;
542 GType type;
543 GValue *nth;
544 GValueArray *arr;
545 PyObject *obj;
547 if (!PyArg_ParseTuple(args, "OI", &obj, &n))
548 return NULL;
550 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
552 if (pyg_boxed_check(obj, G_TYPE_VALUE) &&
553 G_VALUE_HOLDS(pyg_boxed_get(obj, GValue), G_TYPE_VALUE_ARRAY)) {
554 arr = g_value_get_boxed(pyg_boxed_get(obj, GValue));
555 } else if (pyg_boxed_check(obj, G_TYPE_VALUE_ARRAY)) {
556 arr = pyg_boxed_get(obj, GValueArray);
557 } else {
558 PyErr_SetString(PyExc_TypeError, "First argument is not GValueArray");
559 return NULL;
562 if (n >= arr->n_values) {
563 PyErr_SetString(PyExc_TypeError, "Index is out of bounds");
564 return NULL;
566 nth = g_value_array_get_nth(arr, n);
567 type = G_VALUE_TYPE(nth);
569 G_GNUC_END_IGNORE_DEPRECATIONS
571 return pyg_type_wrapper_new(type);
574 static PyObject *
575 _wrap_constant_strip_prefix(PyObject *self, PyObject *args)
577 const char *name, *strip_prefix;
578 const gchar *result;
580 if (!PyArg_ParseTuple (args, "ss", &name, &strip_prefix))
581 return NULL;
583 result = pyg_constant_strip_prefix (name, strip_prefix);
584 return PYGLIB_PyUnicode_FromString (result);
587 static PyObject *
588 _wrap_test_gerror_exception(PyObject *self, PyObject *args)
590 PyObject *py_method;
591 PyObject *py_args;
592 PyObject *py_ret;
593 GError *err = NULL;
595 if (!PyArg_ParseTuple(args, "O", &py_method))
596 return NULL;
598 py_args = PyTuple_New(0);
599 py_ret = PyObject_CallObject(py_method, py_args);
600 if (pyg_gerror_exception_check(&err)) {
601 pyg_error_check(&err);
602 return NULL;
605 Py_DECREF(py_args);
606 Py_DECREF(py_ret);
608 Py_INCREF(Py_None);
609 return Py_None;
612 static PyObject *
613 _wrap_test_owned_by_library_get_instance_list (PyObject *self)
615 PyObject *py_list, *py_obj;
616 GSList *list, *tmp;
618 list = test_owned_by_library_get_instance_list ();
620 if ((py_list = PyList_New (0)) == NULL) {
621 return NULL;
623 for (tmp = list; tmp != NULL; tmp = tmp->next) {
624 py_obj = pygobject_new (G_OBJECT (tmp->data));
625 if (py_obj == NULL) {
626 Py_DECREF (py_list);
627 return NULL;
629 PyList_Append (py_list, py_obj);
630 Py_DECREF (py_obj);
632 return py_list;
635 static PyObject *
636 _wrap_test_floating_and_sunk_get_instance_list (PyObject *self)
638 PyObject *py_list, *py_obj;
639 GSList *list, *tmp;
641 list = test_floating_and_sunk_get_instance_list ();
643 if ((py_list = PyList_New (0)) == NULL) {
644 return NULL;
646 for (tmp = list; tmp != NULL; tmp = tmp->next) {
647 py_obj = pygobject_new (G_OBJECT (tmp->data));
648 if (py_obj == NULL) {
649 Py_DECREF (py_list);
650 return NULL;
652 PyList_Append (py_list, py_obj);
653 Py_DECREF (py_obj);
655 return py_list;
659 static PyObject *
660 _wrap_test_parse_constructor_args (PyObject *self, PyObject *args)
662 char *arg_names[] = {"label", NULL};
663 char *prop_names[] = {"label", NULL};
664 GParameter params[1] = {{0}};
665 PyObject *parsed_args[1];
666 guint nparams = 0;
668 if (!PyArg_ParseTuple(args, "O", &(parsed_args[0])))
669 return NULL;
671 if (!pyg_parse_constructor_args (
672 TYPE_TEST, arg_names, prop_names, params, &nparams, parsed_args)) {
673 return NULL;
676 return PYGLIB_PyLong_FromLong (nparams);
679 static PyObject *
680 _wrap_test_to_unichar_conv (PyObject * self, PyObject *args)
682 PyObject *obj;
683 gunichar result;
685 if (!PyArg_ParseTuple(args, "O", &obj))
686 return NULL;
688 if (!pyg_pyobj_to_unichar_conv (obj, &result))
689 return NULL;
691 return PYGLIB_PyLong_FromLong (result);
694 static PyMethodDef testhelper_functions[] = {
695 { "test_parse_constructor_args", (PyCFunction)_wrap_test_parse_constructor_args, METH_VARARGS },
696 { "get_test_thread", (PyCFunction)_wrap_get_test_thread, METH_NOARGS },
697 { "test_to_unichar_conv", (PyCFunction)_wrap_test_to_unichar_conv, METH_VARARGS },
698 { "get_unknown", (PyCFunction)_wrap_get_unknown, METH_NOARGS },
699 { "create_test_type", (PyCFunction)_wrap_create_test_type, METH_NOARGS },
700 { "test_state_ensure_release", (PyCFunction)_wrap_test_state_ensure_release, METH_NOARGS },
701 { "test_g_object_new", (PyCFunction)_wrap_test_g_object_new, METH_NOARGS },
702 { "connectcallbacks", (PyCFunction)_wrap_connectcallbacks, METH_VARARGS },
703 { "test_value", (PyCFunction)_wrap_test_value, METH_VARARGS },
704 { "test_value_array", (PyCFunction)_wrap_test_value_array, METH_VARARGS },
705 { "value_array_get_nth_type", (PyCFunction)_wrap_value_array_get_nth_type, METH_VARARGS },
706 { "constant_strip_prefix", (PyCFunction)_wrap_constant_strip_prefix, METH_VARARGS },
707 { "test_gerror_exception", (PyCFunction)_wrap_test_gerror_exception, METH_VARARGS },
708 { "owned_by_library_get_instance_list", (PyCFunction)_wrap_test_owned_by_library_get_instance_list, METH_NOARGS },
709 { "floating_and_sunk_get_instance_list", (PyCFunction)_wrap_test_floating_and_sunk_get_instance_list, METH_NOARGS },
710 { NULL, NULL }
713 PYGLIB_MODULE_START(testhelper, "testhelper")
715 PyObject *gobject_module;
716 PyObject *m, *d;
719 if ((gobject_module = pygobject_init(-1, -1, -1)) == NULL)
720 return NULL;
721 Py_DECREF (gobject_module);
723 d = PyModule_GetDict(module);
725 if ((m = PyImport_ImportModule("gi.repository.GObject")) == NULL) {
726 PyErr_SetString(PyExc_ImportError,
727 "could not import gobject");
728 return PYGLIB_MODULE_ERROR_RETURN;
731 /* TestInterface */
732 PyTestInterface_Type.tp_methods = (struct PyMethodDef*)_PyTestInterface_methods;
733 PyTestInterface_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE);
734 pyg_register_interface(d, "Interface", TEST_TYPE_INTERFACE,
735 &PyTestInterface_Type);
736 pyg_register_interface_info(TEST_TYPE_INTERFACE, &__TestInterface__iinfo);
739 /* TestUnknown */
740 PyTestUnknown_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE);
741 PyTestUnknown_Type.tp_weaklistoffset = offsetof(PyGObject, weakreflist);
742 PyTestUnknown_Type.tp_dictoffset = offsetof(PyGObject, inst_dict);
743 pygobject_register_class(d, "Unknown", TEST_TYPE_UNKNOWN,
744 &PyTestUnknown_Type,
745 Py_BuildValue("(O)",
746 &PyGObject_Type,
747 &PyTestInterface_Type));
749 /* TestFloating */
750 PyTestFloating_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE);
751 PyTestFloating_Type.tp_weaklistoffset = offsetof(PyGObject, weakreflist);
752 PyTestFloating_Type.tp_dictoffset = offsetof(PyGObject, inst_dict);
753 pygobject_register_class(d, "Floating", TEST_TYPE_FLOATING,
754 &PyTestFloating_Type,
755 Py_BuildValue("(O)",
756 &PyGObject_Type));
758 /* TestOwnedByLibrary */
759 PyTestOwnedByLibrary_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE);
760 PyTestOwnedByLibrary_Type.tp_methods = (struct PyMethodDef*)_PyTestOwnedByLibrary_methods;
761 PyTestOwnedByLibrary_Type.tp_weaklistoffset = offsetof(PyGObject, weakreflist);
762 PyTestOwnedByLibrary_Type.tp_dictoffset = offsetof(PyGObject, inst_dict);
763 pygobject_register_class(d, "OwnedByLibrary", TEST_TYPE_OWNED_BY_LIBRARY,
764 &PyTestOwnedByLibrary_Type,
765 Py_BuildValue("(O)",
766 &PyGObject_Type));
768 /* TestFloatingAndSunk */
769 PyTestFloatingAndSunk_Type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE);
770 PyTestFloatingAndSunk_Type.tp_methods = (struct PyMethodDef*)_PyTestFloatingAndSunk_methods;
771 PyTestFloatingAndSunk_Type.tp_weaklistoffset = offsetof(PyGObject, weakreflist);
772 PyTestFloatingAndSunk_Type.tp_dictoffset = offsetof(PyGObject, inst_dict);
773 pygobject_register_class(d, "FloatingAndSunk", TEST_TYPE_FLOATING_AND_SUNK,
774 &PyTestFloatingAndSunk_Type,
775 Py_BuildValue("(O)",
776 &PyGObject_Type));
778 PYGLIB_MODULE_END