7 /***********************************************************
8 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
13 Permission to use, copy, modify, and distribute this software and its
14 documentation for any purpose and without fee is hereby granted,
15 provided that the above copyright notice appear in all copies and that
16 both that copyright notice and this permission notice appear in
17 supporting documentation, and that the names of Stichting Mathematisch
18 Centrum or CWI or Corporation for National Research Initiatives or
19 CNRI not be used in advertising or publicity pertaining to
20 distribution of the software without specific, written prior
23 While CWI is the initial source for this software, a modified version
24 is made available by the Corporation for National Research Initiatives
25 (CNRI) at the Internet address ftp://ftp.python.org.
27 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
28 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
29 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
30 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
31 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
32 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
33 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
34 PERFORMANCE OF THIS SOFTWARE.
36 ******************************************************************/
38 /* Integer object interface */
41 123456789-123456789-123456789-123456789-123456789-123456789-123456789-12
43 PyIntObject represents a (long) integer. This is an immutable object;
44 an integer cannot change its value after creation.
46 There are functions to create new integer objects, to test an object
47 for integer-ness, and to get the integer value. The latter functions
48 returns -1 and sets errno to EBADF if the object is not an PyIntObject.
49 None of the functions should be applied to nil objects.
51 The type PyIntObject is (unfortunately) exposed here so we can declare
52 _Py_TrueStruct and _Py_ZeroStruct below; don't use this.
60 extern DL_IMPORT(PyTypeObject
) PyInt_Type
;
62 #define PyInt_Check(op) ((op)->ob_type == &PyInt_Type)
64 extern DL_IMPORT(PyObject
*) PyInt_FromString
Py_PROTO((char*, char**, int));
65 extern DL_IMPORT(PyObject
*) PyInt_FromLong
Py_PROTO((long));
66 extern DL_IMPORT(long) PyInt_AsLong
Py_PROTO((PyObject
*));
67 extern DL_IMPORT(long) PyInt_GetMax
Py_PROTO((void));
71 123456789-123456789-123456789-123456789-123456789-123456789-123456789-12
73 False and True are special intobjects used by Boolean expressions.
74 All values of type Boolean must point to either of these; but in
75 contexts where integers are required they are integers (valued 0 and 1).
76 Hope these macros don't conflict with other people's.
78 Don't forget to apply Py_INCREF() when returning True or False!!!
81 extern DL_IMPORT(PyIntObject
) _Py_ZeroStruct
, _Py_TrueStruct
; /* Don't use these directly */
83 #define Py_False ((PyObject *) &_Py_ZeroStruct)
84 #define Py_True ((PyObject *) &_Py_TrueStruct)
86 /* Macro, trading safety for speed */
87 #define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival)
89 /* These aren't really part of the Int object, but they're handy; the protos
90 * are necessary for systems that need the magic of DL_IMPORT and that want
91 * to have stropmodule as a dynamically loaded module instead of building it
92 * into the main Python shared library/DLL. Guido thinks I'm weird for
93 * building it this way. :-) [cjh]
95 extern DL_IMPORT(unsigned long) PyOS_strtoul
Py_PROTO((char *, char **, int));
96 extern DL_IMPORT(long) PyOS_strtol
Py_PROTO((char *, char **, int));
101 #endif /* !Py_INTOBJECT_H */