[Python-checkins] r67263 - sandbox/trunk/tkinter-polo/src/_tkinter.c
guilherme.polo
python-checkins at python.org
Tue Nov 18 14:56:00 CET 2008
Author: guilherme.polo
Date: Tue Nov 18 14:56:00 2008
New Revision: 67263
Log:
Implement nb_nonzero for PyTclObjects
Modified:
sandbox/trunk/tkinter-polo/src/_tkinter.c
Modified: sandbox/trunk/tkinter-polo/src/_tkinter.c
==============================================================================
--- sandbox/trunk/tkinter-polo/src/_tkinter.c (original)
+++ sandbox/trunk/tkinter-polo/src/_tkinter.c Tue Nov 18 14:56:00 2008
@@ -844,6 +844,12 @@
return 0;
}
+static int
+PyTclObject_nonzero(PyTclObject *self)
+{
+ return Tcl_GetCharLength(self->value) ? 1 : 0;
+}
+
PyDoc_STRVAR(get_typename__doc__, "name of the Tcl type");
static PyObject*
@@ -868,6 +874,20 @@
{0}
};
+static PyNumberMethods PyTclObject_as_number = {
+ 0, /* nb_add */
+ 0, /* nb_subtract */
+ 0, /* nb_muliply */
+ 0, /* nb_divide */
+ 0, /* nb_remainder */
+ 0, /* nb_divmod */
+ 0, /* nb_power */
+ 0, /* nb_negative */
+ 0, /* nb_positive */
+ 0, /* nb_absolute */
+ (inquiry)PyTclObject_nonzero /* nb_nonzero */
+};
+
statichere PyTypeObject PyTclObject_Type = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
@@ -881,7 +901,7 @@
0, /*tp_setattr*/
(cmpfunc)PyTclObject_cmp, /*tp_compare*/
(reprfunc)PyTclObject_repr, /*tp_repr*/
- 0, /*tp_as_number*/
+ &PyTclObject_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash*/
More information about the Python-checkins
mailing list