pybank r102 - in trunk: . bank
- From: marklee svn gnome org
- To: svn-commits-list gnome org
- Subject: pybank r102 - in trunk: . bank
- Date: Fri, 3 Apr 2009 19:31:08 +0000 (UTC)
Author: marklee
Date: Fri Apr 3 19:31:07 2009
New Revision: 102
URL: http://svn.gnome.org/viewvc/pybank?rev=102&view=rev
Log:
Make the uint16, uint32, and uint64 unit tests pass.
* bank/bank-argument.c (pyg_argument_from_pyobject,
pyg_argument_to_pyobject):
* bank/btypes.py (Callable.type_check): Add proper support for uint16,
uint32, and uint64.
Modified:
trunk/ChangeLog
trunk/bank/bank-argument.c
trunk/bank/btypes.py
Modified: trunk/bank/bank-argument.c
==============================================================================
--- trunk/bank/bank-argument.c (original)
+++ trunk/bank/bank-argument.c Fri Apr 3 19:31:07 2009
@@ -44,6 +44,20 @@
case GI_TYPE_TAG_UINT8:
arg.v_uint8 = PyInt_AsLong(object);
break;
+ case GI_TYPE_TAG_UINT16:
+ arg.v_uint16 = PyInt_AsLong(object);
+ break;
+ case GI_TYPE_TAG_UINT32:
+ arg.v_uint32 = PyLong_AsLongLong(object);
+ break;
+ case GI_TYPE_TAG_UINT64:
+ if (PyInt_Check(object)) {
+ PyObject *long_obj = PyNumber_Long(object);
+ arg.v_uint64 = PyLong_AsUnsignedLongLong(long_obj);
+ Py_DECREF(long_obj);
+ } else
+ arg.v_uint64 = PyLong_AsUnsignedLongLong(object);
+ break;
case GI_TYPE_TAG_INT8:
case GI_TYPE_TAG_INT:
case GI_TYPE_TAG_BOOLEAN:
@@ -118,6 +132,15 @@
case GI_TYPE_TAG_UINT8:
obj = PyInt_FromLong(arg->v_uint8);
break;
+ case GI_TYPE_TAG_UINT16:
+ obj = PyInt_FromLong(arg->v_uint16);
+ break;
+ case GI_TYPE_TAG_UINT32:
+ obj = PyLong_FromLongLong(arg->v_uint32);
+ break;
+ case GI_TYPE_TAG_UINT64:
+ obj = PyLong_FromUnsignedLongLong(arg->v_uint64);
+ break;
case GI_TYPE_TAG_INT:
case GI_TYPE_TAG_INT8:
obj = PyInt_FromLong(arg->v_int);
Modified: trunk/bank/btypes.py
==============================================================================
--- trunk/bank/btypes.py (original)
+++ trunk/bank/btypes.py Fri Apr 3 19:31:07 2009
@@ -45,15 +45,20 @@
repo.TYPE_TAG_INT8,
repo.TYPE_TAG_UINT8,
repo.TYPE_TAG_INT16,
+ repo.TYPE_TAG_UINT16,
repo.TYPE_TAG_INT32):
if not isinstance(value, int):
raise TypeError("%s must be int, not %s" % (name, type(value).__name__))
- if tag in (repo.TYPE_TAG_UINT8,) and value < 0:
+ if tag in (repo.TYPE_TAG_UINT8,
+ repo.TYPE_TAG_UINT16) and value < 0:
raise TypeError("%s must be an unsigned value, not %s", name, value)
- elif tag in (repo.TYPE_TAG_INT64,):
+ elif tag in (repo.TYPE_TAG_UINT32,
+ repo.TYPE_TAG_INT64,
+ repo.TYPE_TAG_UINT64):
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_UINT64,) and value < 0:
+ if tag in (repo.TYPE_TAG_UINT32,
+ repo.TYPE_TAG_UINT64) 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]