pybank r101 - in trunk: . bank
- From: marklee svn gnome org
- To: svn-commits-list gnome org
- Subject: pybank r101 - in trunk: . bank
- Date: Wed, 1 Apr 2009 00:45:22 +0000 (UTC)
Author: marklee
Date: Wed Apr 1 00:45:22 2009
New Revision: 101
URL: http://svn.gnome.org/viewvc/pybank?rev=101&view=rev
Log:
Make the int16, int32, and int64 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 int16,
int32, and int64.
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 Wed Apr 1 00:45:22 2009
@@ -49,6 +49,15 @@
case GI_TYPE_TAG_BOOLEAN:
arg.v_int = PyInt_AsLong(object);
break;
+ case GI_TYPE_TAG_INT16:
+ arg.v_int16 = PyInt_AsLong(object);
+ break;
+ case GI_TYPE_TAG_INT32:
+ arg.v_int32 = PyInt_AsLong(object);
+ break;
+ case GI_TYPE_TAG_INT64:
+ arg.v_int64 = PyLong_AsLongLong(object);
+ break;
case GI_TYPE_TAG_FLOAT:
arg.v_float = (float)PyFloat_AsDouble(object);
break;
@@ -113,6 +122,15 @@
case GI_TYPE_TAG_INT8:
obj = PyInt_FromLong(arg->v_int);
break;
+ case GI_TYPE_TAG_INT16:
+ obj = PyInt_FromLong(arg->v_int16);
+ break;
+ case GI_TYPE_TAG_INT32:
+ obj = PyInt_FromLong(arg->v_int32);
+ break;
+ case GI_TYPE_TAG_INT64:
+ obj = PyLong_FromLongLong(arg->v_int64);
+ break;
case GI_TYPE_TAG_FLOAT:
obj = PyFloat_FromDouble(arg->v_float);
break;
Modified: trunk/bank/btypes.py
==============================================================================
--- trunk/bank/btypes.py (original)
+++ trunk/bank/btypes.py Wed Apr 1 00:45:22 2009
@@ -43,11 +43,18 @@
name, type(value).__name__))
elif tag in (repo.TYPE_TAG_INT,
repo.TYPE_TAG_INT8,
- repo.TYPE_TAG_UINT8):
+ repo.TYPE_TAG_UINT8,
+ repo.TYPE_TAG_INT16,
+ 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:
raise TypeError("%s must be an unsigned value, not %s", name, value)
+ elif tag in (repo.TYPE_TAG_INT64,):
+ 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:
+ raise TypeError("%s must be an unsigned value, not %s", name, value)
elif tag in (repo.TYPE_TAG_FLOAT,
repo.TYPE_TAG_DOUBLE):
if not isinstance(value, float):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]