blob: 9a5f5018a3e1d25a952a0635c33ef887cf2f2435 [file] [log] [blame]
Guido van Rossum85a5fbb1990-10-14 12:07:46 +00001/* Integer object interface */
2
3/*
4123456789-123456789-123456789-123456789-123456789-123456789-123456789-12
5
6intobject represents a (long) integer. This is an immutable object;
7an integer cannot change its value after creation.
8
9There are functions to create new integer objects, to test an object
10for integer-ness, and to get the integer value. The latter functions
11returns -1 and sets errno to EBADF if the object is not an intobject.
12None of the functions should be applied to nil objects.
13
14The type intobject is (unfortunately) exposed bere so we can declare
15TrueObject and FalseObject below; don't use this.
16*/
17
18typedef struct {
19 OB_HEAD
20 long ob_ival;
21} intobject;
22
23extern typeobject Inttype;
24
25#define is_intobject(op) ((op)->ob_type == &Inttype)
26
27extern object *newintobject PROTO((long));
28extern long getintvalue PROTO((object *));
29
30
31/*
32123456789-123456789-123456789-123456789-123456789-123456789-123456789-12
33
34False and True are special intobjects used by Boolean expressions.
35All values of type Boolean must point to either of these; but in
36contexts where integers are required they are integers (valued 0 and 1).
37Hope these macros don't conflict with other people's.
38
39Don't forget to apply INCREF() when returning True or False!!!
40*/
41
42extern intobject FalseObject, TrueObject; /* Don't use these directly */
43
44#define False ((object *) &FalseObject)
45#define True ((object *) &TrueObject)
46
47/* Macro, trading safety for speed */
48#define GETINTVALUE(op) ((op)->ob_ival)