diff options
| author | Tomeu Vizoso <tomeu@sugarlabs.org> | 2010-01-02 16:31:55 +0100 |
|---|---|---|
| committer | Tomeu Vizoso <tomeu@sugarlabs.org> | 2010-04-23 16:33:19 +0200 |
| commit | 3ba666b7ab9c393963922c272e7d87bff50a93f9 (patch) | |
| tree | 8c463f92c7cc65153dd5e7f8fb5604a7d3901378 /gi/pygi-boxed.c | |
| parent | af9e4e086d160fe7fb24758ed81753e784b198a8 (diff) | |
| download | pygobject-3ba666b7ab9c393963922c272e7d87bff50a93f9.tar.gz | |
Add basic support for unions
https://bugzilla.gnome.org/show_bug.cgi?id=603598
Diffstat (limited to 'gi/pygi-boxed.c')
| -rw-r--r-- | gi/pygi-boxed.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/gi/pygi-boxed.c b/gi/pygi-boxed.c index b157eb88..c3207969 100644 --- a/gi/pygi-boxed.c +++ b/gi/pygi-boxed.c @@ -63,7 +63,7 @@ _boxed_new (PyTypeObject *type, return NULL; } - info = _pygi_object_get_gi_info((PyObject *)type, &PyGIStructInfo_Type); + info = _pygi_object_get_gi_info((PyObject *)type, &PyGIBaseInfo_Type); if (info == NULL) { if (PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Format(PyExc_TypeError, "missing introspection information"); @@ -71,7 +71,21 @@ _boxed_new (PyTypeObject *type, return NULL; } - size = g_struct_info_get_size((GIStructInfo *)info); + switch (g_base_info_get_type(info)) { + case GI_INFO_TYPE_UNION: + size = g_union_info_get_size((GIUnionInfo *)info); + break; + case GI_INFO_TYPE_BOXED: + case GI_INFO_TYPE_STRUCT: + size = g_struct_info_get_size((GIStructInfo *)info); + break; + default: + PyErr_Format(PyExc_TypeError, + "info should be Boxed or Union, not '%d'", + g_base_info_get_type(info)); + return NULL; + } + boxed = g_slice_alloc0(size); if (boxed == NULL) { PyErr_NoMemory(); |
