[pybank] implement ulong checks and conversions
- From: Johan Dahlin <johan src gnome org>
- To: svn-commits-list gnome org
- Subject: [pybank] implement ulong checks and conversions
- Date: Tue, 2 Jun 2009 10:44:47 -0400 (EDT)
commit 7b0d6b30cbbe367bca02bfc236eac35108da3de0
Author: Tomeu Vizoso <tomeu sugarlabs org>
Date: Mon May 11 12:02:17 2009 +0200
implement ulong checks and conversions
---
bank/bank-argument.c | 24 +++++++++++++++++++++++-
bank/btypes.py | 7 +++++--
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/bank/bank-argument.c b/bank/bank-argument.c
index e611448..571f583 100644
--- a/bank/bank-argument.c
+++ b/bank/bank-argument.c
@@ -42,6 +42,9 @@ pyg_argument_from_pyobject(PyObject *object, GITypeInfo *type_info)
case GI_TYPE_TAG_UINT8:
arg.v_uint8 = PyInt_AsLong(object);
break;
+ case GI_TYPE_TAG_UINT:
+ arg.v_uint = PyInt_AsLong(object);
+ break;
case GI_TYPE_TAG_UINT16:
arg.v_uint16 = PyInt_AsLong(object);
break;
@@ -57,10 +60,20 @@ pyg_argument_from_pyobject(PyObject *object, GITypeInfo *type_info)
arg.v_uint64 = PyLong_AsUnsignedLongLong(object);
break;
case GI_TYPE_TAG_INT8:
+ arg.v_int8 = PyInt_AsLong(object);
+ break;
case GI_TYPE_TAG_INT:
- case GI_TYPE_TAG_BOOLEAN:
arg.v_int = PyInt_AsLong(object);
break;
+ case GI_TYPE_TAG_LONG:
+ arg.v_long = PyInt_AsLong(object);
+ break;
+ case GI_TYPE_TAG_ULONG:
+ arg.v_ulong = PyInt_AsLong(object);
+ break;
+ case GI_TYPE_TAG_BOOLEAN:
+ arg.v_boolean = PyInt_AsLong(object);
+ break;
case GI_TYPE_TAG_INT16:
arg.v_int16 = PyInt_AsLong(object);
break;
@@ -159,6 +172,9 @@ pyg_argument_to_pyobject(GArgument *arg, GITypeInfo *type_info)
case GI_TYPE_TAG_UINT8:
obj = PyInt_FromLong(arg->v_uint8);
break;
+ case GI_TYPE_TAG_UINT:
+ obj = PyInt_FromLong(arg->v_uint);
+ break;
case GI_TYPE_TAG_UINT16:
obj = PyInt_FromLong(arg->v_uint16);
break;
@@ -171,6 +187,12 @@ pyg_argument_to_pyobject(GArgument *arg, GITypeInfo *type_info)
case GI_TYPE_TAG_INT:
obj = PyInt_FromLong(arg->v_int);
break;
+ case GI_TYPE_TAG_LONG:
+ obj = PyInt_FromLong(arg->v_long);
+ break;
+ case GI_TYPE_TAG_ULONG:
+ obj = PyInt_FromLong(arg->v_ulong);
+ break;
case GI_TYPE_TAG_INT8:
obj = PyInt_FromLong(arg->v_int8);
break;
diff --git a/bank/btypes.py b/bank/btypes.py
index 9f47b0d..21a19f4 100644
--- a/bank/btypes.py
+++ b/bank/btypes.py
@@ -45,6 +45,7 @@ class Callable(object):
name, type(value).__name__))
elif tag in (repo.TYPE_TAG_INT,
repo.TYPE_TAG_INT8,
+ repo.TYPE_TAG_UINT,
repo.TYPE_TAG_UINT8,
repo.TYPE_TAG_INT16,
repo.TYPE_TAG_UINT16,
@@ -56,11 +57,13 @@ class Callable(object):
raise TypeError("%s must be an unsigned value, not %s", name, value)
elif tag in (repo.TYPE_TAG_UINT32,
repo.TYPE_TAG_INT64,
- repo.TYPE_TAG_UINT64):
+ repo.TYPE_TAG_UINT64,
+ repo.TYPE_TAG_ULONG):
if not isinstance(value, (int, long)):
raise TypeError("%s must be int or long, not %s" % (name, type(value).__name__))
if tag in (repo.TYPE_TAG_UINT32,
- repo.TYPE_TAG_UINT64) and value < 0:
+ repo.TYPE_TAG_UINT64,
+ repo.TYPE_TAG_ULONG) and value < 0:
raise TypeError("%s must be an unsigned value, not %s", name, value)
elif tag in (repo.TYPE_TAG_FLOAT,
repo.TYPE_TAG_DOUBLE):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]