blob: d4afdaf76bfef1b777d299d081d63e2720b6ddb2 [file] [log] [blame]
Guido van Rossumd27b4f21997-05-02 04:00:11 +00001#ifndef Py_PYTHON_H
2#define Py_PYTHON_H
Guido van Rossum174f95a1997-05-02 03:55:52 +00003/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
4
Guido van Rossum174f95a1997-05-02 03:55:52 +00005
Marc-André Lemburg295b1bb2000-07-07 11:24:49 +00006/* Enable compiler features; switching on C lib defines doesn't work
7 here, because the symbols haven't necessarily been defined yet. */
Marc-André Lemburg82249c82000-07-05 08:53:18 +00008#ifndef _GNU_SOURCE
9# define _GNU_SOURCE 1
10#endif
Marc-André Lemburg295b1bb2000-07-07 11:24:49 +000011
12/* Forcing SUSv2 compatibility still produces problems on some
Michael W. Hudsone5df1052002-05-27 14:05:31 +000013 platforms, True64 and SGI IRIX being two of them, so for now the
Marc-André Lemburg295b1bb2000-07-07 11:24:49 +000014 define is switched off. */
15#if 0
Marc-André Lemburg82249c82000-07-05 08:53:18 +000016#ifndef _XOPEN_SOURCE
17# define _XOPEN_SOURCE 500
18#endif
Marc-André Lemburg295b1bb2000-07-07 11:24:49 +000019#endif
Marc-André Lemburg82249c82000-07-05 08:53:18 +000020
Guido van Rossum174f95a1997-05-02 03:55:52 +000021/* Include nearly all Python header files */
22
Guido van Rossumf1176c41999-01-03 12:40:24 +000023#include "patchlevel.h"
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +000024#include "pyconfig.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +000025
Tim Peters943382c2002-07-07 03:59:34 +000026/* Cyclic gc is always enabled, starting with release 2.3a1. Supply the
27 * old symbol for the benefit of extension modules written before then
28 * that may be conditionalizing on it. The core doesn't use it anymore.
29 */
30#ifndef WITH_CYCLE_GC
31#define WITH_CYCLE_GC 1
32#endif
33
Fred Draked5fadf72000-09-26 05:46:01 +000034#ifdef HAVE_LIMITS_H
35#include <limits.h>
36#endif
37
Guido van Rossum90ce8481998-05-26 18:38:07 +000038#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE)
39#define _SGI_MP_SOURCE
40#endif
41
Guido van Rossum174f95a1997-05-02 03:55:52 +000042#include <stdio.h>
Tim Peters4826a892000-09-10 01:02:41 +000043#ifndef NULL
44# error "Python.h requires that stdio.h define NULL."
45#endif
46
Guido van Rossum174f95a1997-05-02 03:55:52 +000047#include <string.h>
48#include <errno.h>
49#ifdef HAVE_STDLIB_H
50#include <stdlib.h>
51#endif
Martin v. Löwiscdc44512002-01-12 11:05:12 +000052#ifdef HAVE_UNISTD_H
53#include <unistd.h>
54#endif
Guido van Rossumb2c075b2001-07-15 16:58:05 +000055
Tim Peters5defb172001-12-04 20:06:11 +000056/* CAUTION: Build setups should ensure that NDEBUG is defined on the
57 * compiler command line when building Python in release mode; else
58 * assert() calls won't be removed.
59 */
Tim Peters8315ea52000-07-23 19:28:35 +000060#include <assert.h>
61
Martin v. Löwis1e1fcef2002-05-15 18:24:06 +000062#include "pyport.h"
63
Jason Tishlerbc488262002-06-04 15:07:08 +000064/* pyconfig.h or pyport.h may or may not define DL_IMPORT */
65#ifndef DL_IMPORT /* declarations for DLL import/export */
66#define DL_IMPORT(RTYPE) RTYPE
67#endif
68#ifndef DL_EXPORT /* declarations for DLL import/export */
69#define DL_EXPORT(RTYPE) RTYPE
70#endif
71
Tim Petersddea2082002-03-23 10:03:50 +000072/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG.
73 * PYMALLOC_DEBUG is in error if pymalloc is not in use.
74 */
75#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG)
76#define PYMALLOC_DEBUG
77#endif
78#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC)
79#error "PYMALLOC_DEBUG requires WITH_PYMALLOC"
80#endif
Peter Schneider-Kamp25f68942000-07-31 22:19:30 +000081#include "pymem.h"
82
Guido van Rossum174f95a1997-05-02 03:55:52 +000083#include "object.h"
84#include "objimpl.h"
85
86#include "pydebug.h"
87
Guido van Rossum9e896b32000-04-05 20:11:21 +000088#include "unicodeobject.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +000089#include "intobject.h"
Guido van Rossum77f6a652002-04-03 22:41:51 +000090#include "boolobject.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +000091#include "longobject.h"
92#include "floatobject.h"
93#ifndef WITHOUT_COMPLEX
94#include "complexobject.h"
95#endif
96#include "rangeobject.h"
97#include "stringobject.h"
Guido van Rossum2e19bd71998-10-07 14:36:10 +000098#include "bufferobject.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +000099#include "tupleobject.h"
100#include "listobject.h"
Guido van Rossum2ec90311997-05-13 21:23:32 +0000101#include "dictobject.h"
Guido van Rossum7dab2422002-04-26 19:40:56 +0000102#include "enumobject.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +0000103#include "methodobject.h"
104#include "moduleobject.h"
105#include "funcobject.h"
106#include "classobject.h"
107#include "fileobject.h"
108#include "cobject.h"
109#include "traceback.h"
110#include "sliceobject.h"
Jeremy Hyltonfbd849f2001-01-25 20:04:14 +0000111#include "cellobject.h"
Guido van Rossum59d1d2b2001-04-20 19:13:02 +0000112#include "iterobject.h"
Tim Peters6d6c1a32001-08-02 04:15:00 +0000113#include "descrobject.h"
Fred Drake19bc5782001-10-05 21:55:19 +0000114#include "weakrefobject.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +0000115
Guido van Rossumbd7dfbc2000-03-10 22:34:00 +0000116#include "codecs.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +0000117#include "pyerrors.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +0000118
Guido van Rossum618af4b1997-07-18 23:59:26 +0000119#include "pystate.h"
120
Guido van Rossum174f95a1997-05-02 03:55:52 +0000121#include "modsupport.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +0000122#include "pythonrun.h"
Tim Peters5ba58662001-07-16 02:29:45 +0000123#include "ceval.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +0000124#include "sysmodule.h"
125#include "intrcheck.h"
126#include "import.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +0000127
Guido van Rossum174f95a1997-05-02 03:55:52 +0000128#include "abstract.h"
129
Raymond Hettinger0ae0c072002-06-20 22:23:15 +0000130/* _Py_Mangle is defined in compile.c */
131extern DL_IMPORT(int) _Py_Mangle(char *p, char *name, \
132 char *buffer, size_t maxlen);
133
Neal Norwitz1543c072002-03-25 22:21:58 +0000134/* PyArg_GetInt is deprecated and should not be used, use PyArg_Parse(). */
Guido van Rossum174f95a1997-05-02 03:55:52 +0000135#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a))
Neal Norwitz3a6f9782002-03-25 20:46:46 +0000136
137/* PyArg_NoArgs should not be necessary.
138 Set ml_flags in the PyMethodDef to METH_NOARGS. */
Guido van Rossum174f95a1997-05-02 03:55:52 +0000139#define PyArg_NoArgs(v) PyArg_Parse(v, "")
140
141/* Convert a possibly signed character to a nonnegative int */
142/* XXX This assumes characters are 8 bits wide */
143#ifdef __CHAR_UNSIGNED__
144#define Py_CHARMASK(c) (c)
145#else
146#define Py_CHARMASK(c) ((c) & 0xff)
147#endif
148
149#include "pyfpe.h"
150
Greg Ward95811442000-05-28 20:29:48 +0000151/* These definitions must match corresponding definitions in graminit.h.
Guido van Rossumb05a5c71997-05-07 17:46:13 +0000152 There's code in compile.c that checks that they are the same. */
153#define Py_single_input 256
154#define Py_file_input 257
155#define Py_eval_input 258
156
Guido van Rossum9e8181b2000-09-19 00:46:46 +0000157#ifdef HAVE_PTH
Guido van Rossum07bd90e2000-05-08 13:41:38 +0000158/* GNU pth user-space thread support */
159#include <pth.h>
160#endif
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +0000161
162/* Define macros for inline documentation. */
163#define PyDoc_VAR(name) static char name[]
164#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
165#ifdef WITH_DOC_STRINGS
166#define PyDoc_STR(str) str
167#else
168#define PyDoc_STR(str) ""
169#endif
170
Guido van Rossumd27b4f21997-05-02 04:00:11 +0000171#endif /* !Py_PYTHON_H */