source: trunk/include/python2.4/intobject.h @ 125

Last change on this file since 125 was 88, checked in by cxsong, 19 years ago

copied from /opt/rappture/include

File size: 1.9 KB
Line 
1
2/* Integer object interface */
3
4/*
5PyIntObject represents a (long) integer.  This is an immutable object;
6an integer cannot change its value after creation.
7
8There are functions to create new integer objects, to test an object
9for integer-ness, and to get the integer value.  The latter functions
10returns -1 and sets errno to EBADF if the object is not an PyIntObject.
11None of the functions should be applied to nil objects.
12
13The type PyIntObject is (unfortunately) exposed here so we can declare
14_Py_TrueStruct and _Py_ZeroStruct in boolobject.h; don't use this.
15*/
16
17#ifndef Py_INTOBJECT_H
18#define Py_INTOBJECT_H
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23typedef struct {
24    PyObject_HEAD
25    long ob_ival;
26} PyIntObject;
27
28PyAPI_DATA(PyTypeObject) PyInt_Type;
29
30#define PyInt_Check(op) PyObject_TypeCheck(op, &PyInt_Type)
31#define PyInt_CheckExact(op) ((op)->ob_type == &PyInt_Type)
32
33PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int);
34#ifdef Py_USING_UNICODE
35PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, int, int);
36#endif
37PyAPI_FUNC(PyObject *) PyInt_FromLong(long);
38PyAPI_FUNC(long) PyInt_AsLong(PyObject *);
39PyAPI_FUNC(unsigned long) PyInt_AsUnsignedLongMask(PyObject *);
40#ifdef HAVE_LONG_LONG
41PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);
42#endif
43
44PyAPI_FUNC(long) PyInt_GetMax(void);
45
46/* Macro, trading safety for speed */
47#define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival)
48
49/* These aren't really part of the Int object, but they're handy; the protos
50 * are necessary for systems that need the magic of PyAPI_FUNC and that want
51 * to have stropmodule as a dynamically loaded module instead of building it
52 * into the main Python shared library/DLL.  Guido thinks I'm weird for
53 * building it this way.  :-)  [cjh]
54 */
55PyAPI_FUNC(unsigned long) PyOS_strtoul(char *, char **, int);
56PyAPI_FUNC(long) PyOS_strtol(char *, char **, int);
57
58#ifdef __cplusplus
59}
60#endif
61#endif /* !Py_INTOBJECT_H */
Note: See TracBrowser for help on using the repository browser.