[pygobject] Move info string retrieval into generic function
- From: Simon Feltman <sfeltman src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Move info string retrieval into generic function
- Date: Mon, 7 Oct 2013 22:06:39 +0000 (UTC)
commit e7b758badd0ab0b147117859f7871c39fb5399c1
Author: Simon Feltman <sfeltman src gnome org>
Date: Fri Oct 4 13:36:11 2013 -0700
Move info string retrieval into generic function
Add get_info_string for sharing binding of simple string retrieval on
GIBaseInfo objects.
https://bugzilla.gnome.org/show_bug.cgi?id=709008
gi/pygi-info.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 636b16d..db963a0 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -54,6 +54,17 @@ _generate_doc_string(PyGIBaseInfo *self)
}
static PyObject *
+_get_info_string (PyGIBaseInfo *self,
+ const gchar* (*get_info_string)(GIBaseInfo*))
+{
+ const gchar *value = get_info_string ((GIBaseInfo*)self->info);
+ if (value == NULL) {
+ Py_RETURN_NONE;
+ }
+ return PYGLIB_PyUnicode_FromString (value);
+}
+
+static PyObject *
_get_child_info (PyGIBaseInfo *self,
GIBaseInfo* (*get_child_info)(GIBaseInfo*))
{
@@ -227,13 +238,13 @@ _wrap_g_base_info_get_name (PyGIBaseInfo *self)
static PyObject *
_wrap_g_base_info_get_name_unescaped (PyGIBaseInfo *self)
{
- return PYGLIB_PyUnicode_FromString (g_base_info_get_name (self->info));
+ return _get_info_string (self, g_base_info_get_name);
}
static PyObject *
_wrap_g_base_info_get_namespace (PyGIBaseInfo *self)
{
- return PYGLIB_PyUnicode_FromString (g_base_info_get_namespace (self->info));
+ return _get_info_string (self, g_base_info_get_namespace);
}
static PyObject *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]