summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorNeil Schemenauer <nascheme@enme.ucalgary.ca>2001-01-04 01:31:50 (GMT)
committerNeil Schemenauer <nascheme@enme.ucalgary.ca>2001-01-04 01:31:50 (GMT)
commita7ed69454286bd8291db1bcecd8d1f19cf79aa5e (patch)
tree8b21f153adb2682ad212a38ba48089444b30897e /Include
parentdd038db2c23769d9279ab50df57c5cb5b444825a (diff)
downloadcpython-a7ed69454286bd8291db1bcecd8d1f19cf79aa5e.zip
cpython-a7ed69454286bd8291db1bcecd8d1f19cf79aa5e.tar.gz
cpython-a7ed69454286bd8291db1bcecd8d1f19cf79aa5e.tar.bz2
- Add nb_cmp slot for new style nubmers.
- Define type flag for new style numbers. - Add Py_NotImplemented.
Diffstat (limited to 'Include')
-rw-r--r--Include/object.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/Include/object.h b/Include/object.h
index fa25d59..e5ef710 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -119,6 +119,11 @@ typedef int (*visitproc)(PyObject *, void *);
typedef int (*traverseproc)(PyObject *, visitproc, void *);
typedef struct {
+ /* For old style numbers all arguments are guaranteed to be of the
+ object's type (modulo coercion hacks that is); new style numbers
+ should check both arguments for proper type and implement the
+ necessary conversions in the slots themselves. */
+
binaryfunc nb_add;
binaryfunc nb_subtract;
binaryfunc nb_multiply;
@@ -153,6 +158,12 @@ typedef struct {
binaryfunc nb_inplace_and;
binaryfunc nb_inplace_xor;
binaryfunc nb_inplace_or;
+
+ /* New style number slots; these are only used the
+ Py_TPFLAGS_NEWSTYLENUMBER flag is set */
+
+ binaryfunc nb_cmp; /* XXX this should be richcmpfunc */
+
} PyNumberMethods;
typedef struct {
@@ -322,6 +333,9 @@ given type object has a specified feature.
/* PySequenceMethods and PyNumberMethods contain in-place operators */
#define Py_TPFLAGS_HAVE_INPLACEOPS (1L<<3)
+/* PyNumberMethods do their own coercion */
+#define Py_TPFLAGS_NEWSTYLENUMBER (1L<<4)
+
#define Py_TPFLAGS_DEFAULT (Py_TPFLAGS_HAVE_GETCHARBUFFER | \
Py_TPFLAGS_HAVE_SEQUENCE_IN | \
Py_TPFLAGS_HAVE_INPLACEOPS)
@@ -434,6 +448,14 @@ extern DL_IMPORT(PyObject) _Py_NoneStruct; /* Don't use this directly */
#define Py_None (&_Py_NoneStruct)
+/*
+Py_NotImplemented is a singleton used to signal that an operation is
+not implemented for a given type combination.
+*/
+
+extern DL_IMPORT(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
+
+#define Py_NotImplemented (&_Py_NotImplementedStruct)
/*
A common programming style in Python requires the forward declaration