]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.10/Include/intobject.h
AppPkg/Applications/Python/Python-2.7.10: Initial Checkin part 1/5.
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.10 / Include / intobject.h
CommitLineData
c8042e10
DM
1\r
2/* Integer object interface */\r
3\r
4/*\r
5PyIntObject represents a (long) integer. This is an immutable object;\r
6an integer cannot change its value after creation.\r
7\r
8There are functions to create new integer objects, to test an object\r
9for integer-ness, and to get the integer value. The latter functions\r
10returns -1 and sets errno to EBADF if the object is not an PyIntObject.\r
11None of the functions should be applied to nil objects.\r
12\r
13The type PyIntObject is (unfortunately) exposed here so we can declare\r
14_Py_TrueStruct and _Py_ZeroStruct in boolobject.h; don't use this.\r
15*/\r
16\r
17#ifndef Py_INTOBJECT_H\r
18#define Py_INTOBJECT_H\r
19#ifdef __cplusplus\r
20extern "C" {\r
21#endif\r
22\r
23typedef struct {\r
24 PyObject_HEAD\r
25 long ob_ival;\r
26} PyIntObject;\r
27\r
28PyAPI_DATA(PyTypeObject) PyInt_Type;\r
29\r
30#define PyInt_Check(op) \\r
31 PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_INT_SUBCLASS)\r
32#define PyInt_CheckExact(op) ((op)->ob_type == &PyInt_Type)\r
33\r
34PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int);\r
35#ifdef Py_USING_UNICODE\r
36PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, Py_ssize_t, int);\r
37#endif\r
38PyAPI_FUNC(PyObject *) PyInt_FromLong(long);\r
39PyAPI_FUNC(PyObject *) PyInt_FromSize_t(size_t);\r
40PyAPI_FUNC(PyObject *) PyInt_FromSsize_t(Py_ssize_t);\r
41PyAPI_FUNC(long) PyInt_AsLong(PyObject *);\r
42PyAPI_FUNC(Py_ssize_t) PyInt_AsSsize_t(PyObject *);\r
43PyAPI_FUNC(int) _PyInt_AsInt(PyObject *);\r
44PyAPI_FUNC(unsigned long) PyInt_AsUnsignedLongMask(PyObject *);\r
45#ifdef HAVE_LONG_LONG\r
46PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *);\r
47#endif\r
48\r
49PyAPI_FUNC(long) PyInt_GetMax(void);\r
50\r
51/* Macro, trading safety for speed */\r
52#define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival)\r
53\r
54/* These aren't really part of the Int object, but they're handy; the protos\r
55 * are necessary for systems that need the magic of PyAPI_FUNC and that want\r
56 * to have stropmodule as a dynamically loaded module instead of building it\r
57 * into the main Python shared library/DLL. Guido thinks I'm weird for\r
58 * building it this way. :-) [cjh]\r
59 */\r
60PyAPI_FUNC(unsigned long) PyOS_strtoul(char *, char **, int);\r
61PyAPI_FUNC(long) PyOS_strtol(char *, char **, int);\r
62\r
63/* free list api */\r
64PyAPI_FUNC(int) PyInt_ClearFreeList(void);\r
65\r
66/* Convert an integer to the given base. Returns a string.\r
67 If base is 2, 8 or 16, add the proper prefix '0b', '0o' or '0x'.\r
68 If newstyle is zero, then use the pre-2.6 behavior of octal having\r
69 a leading "0" */\r
70PyAPI_FUNC(PyObject*) _PyInt_Format(PyIntObject* v, int base, int newstyle);\r
71\r
72/* Format the object based on the format_spec, as defined in PEP 3101\r
73 (Advanced String Formatting). */\r
74PyAPI_FUNC(PyObject *) _PyInt_FormatAdvanced(PyObject *obj,\r
75 char *format_spec,\r
76 Py_ssize_t format_spec_len);\r
77\r
78#ifdef __cplusplus\r
79}\r
80#endif\r
81#endif /* !Py_INTOBJECT_H */\r