Python.h 4.08 KB
Newer Older
1 2
#ifndef Py_PYTHON_H
#define Py_PYTHON_H
3 4 5 6
/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */

/* Include nearly all Python header files */

7
#include "patchlevel.h"
8
#include "pyconfig.h"
9

10 11 12 13 14 15 16 17
/* Cyclic gc is always enabled, starting with release 2.3a1.  Supply the
 * old symbol for the benefit of extension modules written before then
 * that may be conditionalizing on it.  The core doesn't use it anymore.
 */
#ifndef WITH_CYCLE_GC
#define WITH_CYCLE_GC 1
#endif

18 19
#include <limits.h>

20 21 22 23 24
#ifndef UCHAR_MAX
#error "Something's broken.  UCHAR_MAX should be defined in limits.h."
#endif

#if UCHAR_MAX != 255
25
#error "Python's source code assumes C's unsigned char is an 8-bit type."
26 27
#endif

28 29 30 31
#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE)
#define _SGI_MP_SOURCE
#endif

32
#include <stdio.h>
33 34 35 36
#ifndef NULL
#   error "Python.h requires that stdio.h define NULL."
#endif

37 38 39
#include <string.h>
#include <errno.h>
#include <stdlib.h>
40 41 42
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
43

44 45 46 47 48
/* For uintptr_t, intptr_t */
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif

49 50 51 52
/* CAUTION:  Build setups should ensure that NDEBUG is defined on the
 * compiler command line when building Python in release mode; else
 * assert() calls won't be removed.
 */
53 54
#include <assert.h>

Martin v. Löwis's avatar
Martin v. Löwis committed
55 56
#include "pyport.h"

57 58 59 60 61 62 63 64
/* pyconfig.h or pyport.h may or may not define DL_IMPORT */
#ifndef DL_IMPORT	/* declarations for DLL import/export */
#define DL_IMPORT(RTYPE) RTYPE
#endif
#ifndef DL_EXPORT	/* declarations for DLL import/export */
#define DL_EXPORT(RTYPE) RTYPE
#endif

65 66 67 68 69 70 71 72 73
/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG.
 *  PYMALLOC_DEBUG is in error if pymalloc is not in use.
 */
#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG)
#define PYMALLOC_DEBUG
#endif
#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC)
#error "PYMALLOC_DEBUG requires WITH_PYMALLOC"
#endif
74 75
#include "pymem.h"

76 77 78 79 80
#include "object.h"
#include "objimpl.h"

#include "pydebug.h"

81
#include "unicodeobject.h"
82
#include "intobject.h"
83
#include "boolobject.h"
84 85 86 87 88 89 90
#include "longobject.h"
#include "floatobject.h"
#ifndef WITHOUT_COMPLEX
#include "complexobject.h"
#endif
#include "rangeobject.h"
#include "stringobject.h"
91
#include "bufferobject.h"
92 93
#include "tupleobject.h"
#include "listobject.h"
94
#include "dictobject.h"
95
#include "enumobject.h"
96
#include "setobject.h"
97 98 99 100 101 102 103 104
#include "methodobject.h"
#include "moduleobject.h"
#include "funcobject.h"
#include "classobject.h"
#include "fileobject.h"
#include "cobject.h"
#include "traceback.h"
#include "sliceobject.h"
Jeremy Hylton's avatar
Jeremy Hylton committed
105
#include "cellobject.h"
106
#include "iterobject.h"
107
#include "genobject.h"
108
#include "descrobject.h"
109
#include "weakrefobject.h"
110

111
#include "codecs.h"
112 113
#include "pyerrors.h"

114 115
#include "pystate.h"

116 117
#include "modsupport.h"
#include "pythonrun.h"
118
#include "ceval.h"
119 120 121 122 123 124
#include "sysmodule.h"
#include "intrcheck.h"
#include "import.h"

#include "abstract.h"

125 126 127
#include "compile.h"
#include "eval.h"

128 129
#include "pystrtod.h"

130
/* _Py_Mangle is defined in compile.c */
131
PyAPI_FUNC(int) _Py_Mangle(char *p, char *name, \
132 133
				 char *buffer, size_t maxlen);

134
/* PyArg_GetInt is deprecated and should not be used, use PyArg_Parse(). */
135
#define PyArg_GetInt(v, a)	PyArg_Parse((v), "i", (a))
136 137 138

/* PyArg_NoArgs should not be necessary.
   Set ml_flags in the PyMethodDef to METH_NOARGS. */
139 140 141 142 143 144 145 146 147 148 149 150
#define PyArg_NoArgs(v)		PyArg_Parse(v, "")

/* Convert a possibly signed character to a nonnegative int */
/* XXX This assumes characters are 8 bits wide */
#ifdef __CHAR_UNSIGNED__
#define Py_CHARMASK(c)		(c)
#else
#define Py_CHARMASK(c)		((c) & 0xff)
#endif

#include "pyfpe.h"

Greg Ward's avatar
Greg Ward committed
151
/* These definitions must match corresponding definitions in graminit.h.
152 153 154 155 156
   There's code in compile.c that checks that they are the same. */
#define Py_single_input 256
#define Py_file_input 257
#define Py_eval_input 258

157
#ifdef HAVE_PTH
158 159 160
/* GNU pth user-space thread support */
#include <pth.h>
#endif
161 162 163 164 165 166 167 168 169 170

/* Define macros for inline documentation. */
#define PyDoc_VAR(name) static char name[]
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
#ifdef WITH_DOC_STRINGS
#define PyDoc_STR(str) str
#else
#define PyDoc_STR(str) ""
#endif

171
#endif /* !Py_PYTHON_H */