Mercurial > cpython-lru_cache-weakref
annotate Include/intobject.h @ 58765:2ba7677bfa95 legacy-trunk
testCopysign was defined twice in test_math; combine the definitions
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Sat, 06 Feb 2010 23:11:25 +0000 |
| parents | 0738119c1ef8 |
| children | d544873d62e9 |
| rev | line source |
|---|---|
| 145 | 1 |
| 6 | 2 /* Integer object interface */ |
| 3 | |
| 4 /* | |
|
2129
05360cd616ae
The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents:
2058
diff
changeset
|
5 PyIntObject represents a (long) integer. This is an immutable object; |
| 6 | 6 an integer cannot change its value after creation. |
| 7 | |
| 8 There are functions to create new integer objects, to test an object | |
| 9 for integer-ness, and to get the integer value. The latter functions | |
|
2129
05360cd616ae
The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents:
2058
diff
changeset
|
10 returns -1 and sets errno to EBADF if the object is not an PyIntObject. |
| 6 | 11 None of the functions should be applied to nil objects. |
| 12 | |
|
2129
05360cd616ae
The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents:
2058
diff
changeset
|
13 The type PyIntObject is (unfortunately) exposed here so we can declare |
|
33856
60c60dc75c77
Wrote down the invariants of some common objects whose structure is
Armin Rigo <arigo@tunes.org>
parents:
28652
diff
changeset
|
14 _Py_TrueStruct and _Py_ZeroStruct in boolobject.h; don't use this. |
| 6 | 15 */ |
| 16 | |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
17 #ifndef Py_INTOBJECT_H |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
18 #define Py_INTOBJECT_H |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
19 #ifdef __cplusplus |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
20 extern "C" { |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
21 #endif |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
22 |
| 6 | 23 typedef struct { |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
24 PyObject_HEAD |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
25 long ob_ival; |
|
2129
05360cd616ae
The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents:
2058
diff
changeset
|
26 } PyIntObject; |
| 6 | 27 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22785
diff
changeset
|
28 PyAPI_DATA(PyTypeObject) PyInt_Type; |
| 6 | 29 |
|
40908
d01bd37bf5ce
Variation of patch # 1624059 to speed up checking if an object is a subclass
Neal Norwitz <nnorwitz@gmail.com>
parents:
36501
diff
changeset
|
30 #define PyInt_Check(op) \ |
|
d01bd37bf5ce
Variation of patch # 1624059 to speed up checking if an object is a subclass
Neal Norwitz <nnorwitz@gmail.com>
parents:
36501
diff
changeset
|
31 PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_INT_SUBCLASS) |
|
19837
5158e4789459
SF bug #460020: bug or feature: unicode() and subclasses.
Tim Peters <tim.peters@gmail.com>
parents:
19550
diff
changeset
|
32 #define PyInt_CheckExact(op) ((op)->ob_type == &PyInt_Type) |
| 6 | 33 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22785
diff
changeset
|
34 PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int); |
|
19343
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
35 #ifdef Py_USING_UNICODE |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
33856
diff
changeset
|
36 PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, Py_ssize_t, int); |
|
19343
7257e87e0720
Patch #445762: Support --disable-unicode
Martin v. Löwis <martin@v.loewis.de>
parents:
14375
diff
changeset
|
37 #endif |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22785
diff
changeset
|
38 PyAPI_FUNC(PyObject *) PyInt_FromLong(long); |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
33856
diff
changeset
|
39 PyAPI_FUNC(PyObject *) PyInt_FromSize_t(size_t); |
|
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
33856
diff
changeset
|
40 PyAPI_FUNC(PyObject *) PyInt_FromSsize_t(Py_ssize_t); |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22785
diff
changeset
|
41 PyAPI_FUNC(long) PyInt_AsLong(PyObject *); |
|
36501
7fdc639bc5b4
Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents:
33856
diff
changeset
|
42 PyAPI_FUNC(Py_ssize_t) PyInt_AsSsize_t(PyObject *); |
|
28652
28a2975514cd
SF # 595026: support for masks in getargs.c.
Thomas Heller <theller@ctypes.org>
parents:
27001
diff
changeset
|
43 PyAPI_FUNC(unsigned long) PyInt_AsUnsignedLongMask(PyObject *); |
|
28a2975514cd
SF # 595026: support for masks in getargs.c.
Thomas Heller <theller@ctypes.org>
parents:
27001
diff
changeset
|
44 #ifdef HAVE_LONG_LONG |
|
28a2975514cd
SF # 595026: support for masks in getargs.c.
Thomas Heller <theller@ctypes.org>
parents:
27001
diff
changeset
|
45 PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *); |
|
28a2975514cd
SF # 595026: support for masks in getargs.c.
Thomas Heller <theller@ctypes.org>
parents:
27001
diff
changeset
|
46 #endif |
|
28a2975514cd
SF # 595026: support for masks in getargs.c.
Thomas Heller <theller@ctypes.org>
parents:
27001
diff
changeset
|
47 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22785
diff
changeset
|
48 PyAPI_FUNC(long) PyInt_GetMax(void); |
| 6 | 49 |
| 50 /* Macro, trading safety for speed */ | |
|
5918
780b68df4560
Add cast to PyInt_AS_LONG macro, as suggested by Marc Lemburg.
Guido van Rossum <guido@python.org>
parents:
5861
diff
changeset
|
51 #define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival) |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
52 |
|
9623
fa8f9fe0a33d
Add prototypes for PyOS_strto[u]l -- Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
9586
diff
changeset
|
53 /* These aren't really part of the Int object, but they're handy; the protos |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22785
diff
changeset
|
54 * are necessary for systems that need the magic of PyAPI_FUNC and that want |
|
9623
fa8f9fe0a33d
Add prototypes for PyOS_strto[u]l -- Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
9586
diff
changeset
|
55 * to have stropmodule as a dynamically loaded module instead of building it |
|
fa8f9fe0a33d
Add prototypes for PyOS_strto[u]l -- Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
9586
diff
changeset
|
56 * into the main Python shared library/DLL. Guido thinks I'm weird for |
|
fa8f9fe0a33d
Add prototypes for PyOS_strto[u]l -- Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
9586
diff
changeset
|
57 * building it this way. :-) [cjh] |
|
fa8f9fe0a33d
Add prototypes for PyOS_strto[u]l -- Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
9586
diff
changeset
|
58 */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22785
diff
changeset
|
59 PyAPI_FUNC(unsigned long) PyOS_strtoul(char *, char **, int); |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
22785
diff
changeset
|
60 PyAPI_FUNC(long) PyOS_strtol(char *, char **, int); |
|
9623
fa8f9fe0a33d
Add prototypes for PyOS_strto[u]l -- Chris Herborth.
Guido van Rossum <guido@python.org>
parents:
9586
diff
changeset
|
61 |
| 45143 | 62 /* free list api */ |
|
47897
0738119c1ef8
- Issue #2862: Make int and float freelist management consistent with other
Gregory P. Smith <greg@mad-scientist.com>
parents:
47392
diff
changeset
|
63 PyAPI_FUNC(int) PyInt_ClearFreeList(void); |
| 45143 | 64 |
|
45262
86906a5ceca6
Added PyNumber_ToBase and supporting routines _PyInt_Format and
Eric Smith <eric@trueblade.com>
parents:
45143
diff
changeset
|
65 /* Convert an integer to the given base. Returns a string. |
|
86906a5ceca6
Added PyNumber_ToBase and supporting routines _PyInt_Format and
Eric Smith <eric@trueblade.com>
parents:
45143
diff
changeset
|
66 If base is 2, 8 or 16, add the proper prefix '0b', '0o' or '0x'. |
|
86906a5ceca6
Added PyNumber_ToBase and supporting routines _PyInt_Format and
Eric Smith <eric@trueblade.com>
parents:
45143
diff
changeset
|
67 If newstyle is zero, then use the pre-2.6 behavior of octal having |
|
86906a5ceca6
Added PyNumber_ToBase and supporting routines _PyInt_Format and
Eric Smith <eric@trueblade.com>
parents:
45143
diff
changeset
|
68 a leading "0" */ |
|
86906a5ceca6
Added PyNumber_ToBase and supporting routines _PyInt_Format and
Eric Smith <eric@trueblade.com>
parents:
45143
diff
changeset
|
69 PyAPI_FUNC(PyObject*) _PyInt_Format(PyIntObject* v, int base, int newstyle); |
|
86906a5ceca6
Added PyNumber_ToBase and supporting routines _PyInt_Format and
Eric Smith <eric@trueblade.com>
parents:
45143
diff
changeset
|
70 |
|
47392
47ef9a806ce9
Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Eric Smith <eric@trueblade.com>
parents:
45262
diff
changeset
|
71 /* Format the object based on the format_spec, as defined in PEP 3101 |
|
47ef9a806ce9
Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Eric Smith <eric@trueblade.com>
parents:
45262
diff
changeset
|
72 (Advanced String Formatting). */ |
|
47ef9a806ce9
Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Eric Smith <eric@trueblade.com>
parents:
45262
diff
changeset
|
73 PyAPI_FUNC(PyObject *) _PyInt_FormatAdvanced(PyObject *obj, |
|
47ef9a806ce9
Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Eric Smith <eric@trueblade.com>
parents:
45262
diff
changeset
|
74 char *format_spec, |
|
47ef9a806ce9
Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Eric Smith <eric@trueblade.com>
parents:
45262
diff
changeset
|
75 Py_ssize_t format_spec_len); |
|
47ef9a806ce9
Refactor and clean up str.format() code (and helpers) in advance of optimizations.
Eric Smith <eric@trueblade.com>
parents:
45262
diff
changeset
|
76 |
|
1329
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
77 #ifdef __cplusplus |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
78 } |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
79 #endif |
|
519c25039c6a
* Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
80 #endif /* !Py_INTOBJECT_H */ |
