[pybank] Implement unwrapping of enums



commit 26a58de791e8627b7416e79ee2d1d200ad25b28b
Author: Tomeu Vizoso <tomeu sugarlabs org>
Date:   Tue May 26 19:06:58 2009 +0200

    Implement unwrapping of enums
---
 bank/bank-argument.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/bank/bank-argument.c b/bank/bank-argument.c
index 44495fb..0e64b79 100644
--- a/bank/bank-argument.c
+++ b/bank/bank-argument.c
@@ -26,6 +26,8 @@ pyg_argument_from_pyobject(PyObject *object, GITypeInfo *type_info)
 {
     GArgument arg;
     GITypeTag type_tag;
+    GIBaseInfo* interface_info;
+    GIInfoType interface_type;
 	
     type_tag = g_type_info_get_tag((GITypeInfo*)type_info);
     switch (type_tag) {
@@ -89,11 +91,15 @@ pyg_argument_from_pyobject(PyObject *object, GITypeInfo *type_info)
 	arg.v_double = PyFloat_AsDouble(object);
 	break;
     case GI_TYPE_TAG_INTERFACE:
-	if (object == Py_None)
-	    arg.v_pointer = NULL;
-	else
-	    arg.v_pointer = pygobject_get(object);
-	break;
+        interface_info = g_type_info_get_interface(type_info);
+        interface_type = g_base_info_get_type(interface_info);
+        if (interface_type == GI_INFO_TYPE_ENUM) {
+            arg.v_int = PyInt_AsLong(object);
+        } else if (object == Py_None)
+            arg.v_pointer = NULL;
+        else
+            arg.v_pointer = pygobject_get(object);
+        break;
     case GI_TYPE_TAG_ARRAY:
 	arg.v_pointer = NULL;
 	break;



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