diff options
author | Guido van Rossum <guido@python.org> | 1994-08-01 11:34:53 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1994-08-01 11:34:53 (GMT) |
commit | b6775db241f5fe5e3dc2ca09fc6c9e6164d4b2af (patch) | |
tree | 9362939305b2d088b8f19a530c9015d886bc2801 /Include/object.h | |
parent | 2979b01ff88ac4c5b316d9bf98edbaaaffac8e24 (diff) | |
download | cpython-b6775db241f5fe5e3dc2ca09fc6c9e6164d4b2af.zip cpython-b6775db241f5fe5e3dc2ca09fc6c9e6164d4b2af.tar.gz cpython-b6775db241f5fe5e3dc2ca09fc6c9e6164d4b2af.tar.bz2 |
Merge alpha100 branch back to main trunk
Diffstat (limited to 'Include/object.h')
-rw-r--r-- | Include/object.h | 124 |
1 files changed, 83 insertions, 41 deletions
diff --git a/Include/object.h b/Include/object.h index 24989bf..416ca77 100644 --- a/Include/object.h +++ b/Include/object.h @@ -5,7 +5,7 @@ extern "C" { #endif /*********************************************************** -Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum, +Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum, Amsterdam, The Netherlands. All Rights Reserved @@ -133,48 +133,66 @@ NB: the methods for certain type groups are now contained in separate method blocks. */ +typedef object * (*unaryfunc) PROTO((object *)); +typedef object * (*binaryfunc) PROTO((object *, object *)); +typedef int (*inquiry) PROTO((object *)); +typedef int (*coercion) PROTO((object **, object **)); +typedef object *(*intargfunc) PROTO((object *, int)); +typedef object *(*intintargfunc) PROTO((object *, int, int)); +typedef int(*intobjargproc) PROTO((object *, int, object *)); +typedef int(*intintobjargproc) PROTO((object *, int, int, object *)); +typedef int(*objobjargproc) PROTO((object *, object *, object *)); + typedef struct { - object *(*nb_add) FPROTO((object *, object *)); - object *(*nb_subtract) FPROTO((object *, object *)); - object *(*nb_multiply) FPROTO((object *, object *)); - object *(*nb_divide) FPROTO((object *, object *)); - object *(*nb_remainder) FPROTO((object *, object *)); - object *(*nb_divmod) FPROTO((object *, object *)); - object *(*nb_power) FPROTO((object *, object *)); - object *(*nb_negative) FPROTO((object *)); - object *(*nb_positive) FPROTO((object *)); - object *(*nb_absolute) FPROTO((object *)); - int (*nb_nonzero) FPROTO((object *)); - object *(*nb_invert) FPROTO((object *)); - object *(*nb_lshift) FPROTO((object *, object *)); - object *(*nb_rshift) FPROTO((object *, object *)); - object *(*nb_and) FPROTO((object *, object *)); - object *(*nb_xor) FPROTO((object *, object *)); - object *(*nb_or) FPROTO((object *, object *)); - int (*nb_coerce) FPROTO((object **, object **)); - object *(*nb_int) FPROTO((object *)); - object *(*nb_long) FPROTO((object *)); - object *(*nb_float) FPROTO((object *)); - object *(*nb_oct) FPROTO((object *)); - object *(*nb_hex) FPROTO((object *)); + binaryfunc nb_add; + binaryfunc nb_subtract; + binaryfunc nb_multiply; + binaryfunc nb_divide; + binaryfunc nb_remainder; + binaryfunc nb_divmod; + binaryfunc nb_power; + unaryfunc nb_negative; + unaryfunc nb_positive; + unaryfunc nb_absolute; + inquiry nb_nonzero; + unaryfunc nb_invert; + binaryfunc nb_lshift; + binaryfunc nb_rshift; + binaryfunc nb_and; + binaryfunc nb_xor; + binaryfunc nb_or; + coercion nb_coerce; + unaryfunc nb_int; + unaryfunc nb_long; + unaryfunc nb_float; + unaryfunc nb_oct; + unaryfunc nb_hex; } number_methods; typedef struct { - int (*sq_length) FPROTO((object *)); - object *(*sq_concat) FPROTO((object *, object *)); - object *(*sq_repeat) FPROTO((object *, int)); - object *(*sq_item) FPROTO((object *, int)); - object *(*sq_slice) FPROTO((object *, int, int)); - int (*sq_ass_item) FPROTO((object *, int, object *)); - int (*sq_ass_slice) FPROTO((object *, int, int, object *)); + inquiry sq_length; + binaryfunc sq_concat; + intargfunc sq_repeat; + intargfunc sq_item; + intintargfunc sq_slice; + intobjargproc sq_ass_item; + intintobjargproc sq_ass_slice; } sequence_methods; typedef struct { - int (*mp_length) FPROTO((object *)); - object *(*mp_subscript) FPROTO((object *, object *)); - int (*mp_ass_subscript) FPROTO((object *, object *, object *)); + inquiry mp_length; + binaryfunc mp_subscript; + objobjargproc mp_ass_subscript; } mapping_methods; +typedef void (*destructor) PROTO((object *)); +typedef int (*printfunc) PROTO((object *, FILE *, int)); +typedef object *(*getattrfunc) PROTO((object *, char *)); +typedef int (*setattrfunc) PROTO((object *, char *, object *)); +typedef int (*cmpfunc) PROTO((object *, object *)); +typedef object *(*reprfunc) PROTO((object *)); +typedef long (*hashfunc) PROTO((object *)); + typedef struct _typeobject { OB_VARHEAD char *tp_name; /* For printing */ @@ -182,12 +200,12 @@ typedef struct _typeobject { /* Methods to implement standard operations */ - void (*tp_dealloc) FPROTO((object *)); - int (*tp_print) FPROTO((object *, FILE *, int)); - object *(*tp_getattr) FPROTO((object *, char *)); - int (*tp_setattr) FPROTO((object *, char *, object *)); - int (*tp_compare) FPROTO((object *, object *)); - object *(*tp_repr) FPROTO((object *)); + destructor tp_dealloc; + printfunc tp_print; + getattrfunc tp_getattr; + setattrfunc tp_setattr; + cmpfunc tp_compare; + reprfunc tp_repr; /* Method suites for standard classes */ @@ -197,7 +215,8 @@ typedef struct _typeobject { /* More standard operations (at end for binary compatibility) */ - long (*tp_hash) FPROTO((object *)); + hashfunc tp_hash; + binaryfunc tp_call; #ifdef COUNT_ALLOCS /* these must be last */ int tp_alloc; @@ -327,6 +346,29 @@ extern object NoObject; /* Don't use this directly */ /* +A common programming style in Python requires the forward declaration +of static, initialized structures, e.g. for a typeobject that is used +by the functions whose address must be used in the initializer. +Some compilers (notably SCO ODT 3.0, I seem to remember early AIX as +well) botch this if you use the static keyword for both declarations +(they allocate two objects, and use the first, uninitialized one until +the second declaration is encountered). Therefore, the forward +declaration should use the 'forwardstatic' keyword. This expands to +static on most systems, but to extern on a few. The actual storage +and name will still be static because the second declaration is +static, so no linker visible symbols will be generated. (Standard C +compilers take offense to the extern forward declaration of a static +object, so I can't just put extern in all cases. :-( ) +*/ + +#ifdef BAD_STATIC_FORWARD +#define staticforward extern +#else +#define staticforward static +#endif /* BAD_STATIC_FORWARD */ + + +/* 123456789-123456789-123456789-123456789-123456789-123456789-123456789-12 More conventions |