summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2008-05-29 19:42:34 (GMT)
committerThomas Heller <theller@ctypes.org>2008-05-29 19:42:34 (GMT)
commit9287acf83df56a11aaa001657df652ed6804b105 (patch)
tree616f535ee369132b23cd26fad0b16a31d1257f5e /Modules
parenta52b244cc10a7644d86c4f09b761b3611a65378d (diff)
downloadcpython-9287acf83df56a11aaa001657df652ed6804b105.zip
cpython-9287acf83df56a11aaa001657df652ed6804b105.tar.gz
cpython-9287acf83df56a11aaa001657df652ed6804b105.tar.bz2
ctypes NULL function pointers have a boolean False value now.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 5b2a054..740b7f6 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -3784,6 +3784,26 @@ CFuncPtr_repr(CFuncPtrObject *self)
self);
}
+static int
+Pointer_nonzero(CDataObject *self)
+{
+ return *(void **)self->b_ptr != NULL;
+}
+
+static PyNumberMethods Pointer_as_number = {
+ 0, /* nb_add */
+ 0, /* nb_subtract */
+ 0, /* nb_multiply */
+ 0, /* nb_divide */
+ 0, /* nb_remainder */
+ 0, /* nb_divmod */
+ 0, /* nb_power */
+ 0, /* nb_negative */
+ 0, /* nb_positive */
+ 0, /* nb_absolute */
+ (inquiry)Pointer_nonzero, /* nb_nonzero */
+};
+
PyTypeObject CFuncPtr_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes.CFuncPtr",
@@ -3795,7 +3815,7 @@ PyTypeObject CFuncPtr_Type = {
0, /* tp_setattr */
0, /* tp_compare */
(reprfunc)CFuncPtr_repr, /* tp_repr */
- 0, /* tp_as_number */
+ &Pointer_as_number, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
@@ -5003,26 +5023,6 @@ static PyMappingMethods Pointer_as_mapping = {
Pointer_subscript,
};
-static int
-Pointer_nonzero(CDataObject *self)
-{
- return *(void **)self->b_ptr != NULL;
-}
-
-static PyNumberMethods Pointer_as_number = {
- 0, /* nb_add */
- 0, /* nb_subtract */
- 0, /* nb_multiply */
- 0, /* nb_divide */
- 0, /* nb_remainder */
- 0, /* nb_divmod */
- 0, /* nb_power */
- 0, /* nb_negative */
- 0, /* nb_positive */
- 0, /* nb_absolute */
- (inquiry)Pointer_nonzero, /* nb_nonzero */
-};
-
PyTypeObject Pointer_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes._Pointer",