1 | // (C) Copyright David Abrahams 2000.
|
---|
2 | // Distributed under the Boost Software License, Version 1.0. (See
|
---|
3 | // accompanying file LICENSE_1_0.txt or copy at
|
---|
4 | // http://www.boost.org/LICENSE_1_0.txt)
|
---|
5 | //
|
---|
6 | // The author gratefully acknowleges the support of Dragon Systems, Inc., in
|
---|
7 | // producing this work.
|
---|
8 |
|
---|
9 | // This file serves as a wrapper around <Python.h> which allows it to be
|
---|
10 | // compiled with GCC 2.95.2 under Win32 and which disables the default MSVC
|
---|
11 | // behavior so that a program may be compiled in debug mode without requiring a
|
---|
12 | // special debugging build of the Python library.
|
---|
13 |
|
---|
14 |
|
---|
15 | // To use the Python debugging library, #define BOOST_DEBUG_PYTHON on the
|
---|
16 | // compiler command-line.
|
---|
17 |
|
---|
18 | // Revision History:
|
---|
19 | // 05 Mar 01 Suppress warnings under Cygwin with Python 2.0 (Dave Abrahams)
|
---|
20 | // 04 Mar 01 Rolled in some changes from the Dragon fork (Dave Abrahams)
|
---|
21 | // 01 Mar 01 define PyObject_INIT() for Python 1.x (Dave Abrahams)
|
---|
22 |
|
---|
23 | #ifdef _DEBUG
|
---|
24 | # ifndef BOOST_DEBUG_PYTHON
|
---|
25 | # ifdef _MSC_VER
|
---|
26 | // VC8.0 will complain if system headers are #included both with
|
---|
27 | // and without _DEBUG defined, so we have to #include all the
|
---|
28 | // system headers used by pyconfig.h right here.
|
---|
29 | # include <stddef.h>
|
---|
30 | # include <stdarg.h>
|
---|
31 | # include <stdio.h>
|
---|
32 | # include <stdlib.h>
|
---|
33 | # include <assert.h>
|
---|
34 | # include <errno.h>
|
---|
35 | # include <ctype.h>
|
---|
36 | # include <wchar.h>
|
---|
37 | # include <basetsd.h>
|
---|
38 | # include <io.h>
|
---|
39 | # include <limits.h>
|
---|
40 | # include <float.h>
|
---|
41 | # include <string.h>
|
---|
42 | # include <math.h>
|
---|
43 | # include <time.h>
|
---|
44 | # endif
|
---|
45 | # undef _DEBUG // Don't let Python force the debug library just because we're debugging.
|
---|
46 | # define DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
|
---|
47 | # endif
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | # include <pyconfig.h>
|
---|
51 | # if defined(_SGI_COMPILER_VERSION) && _SGI_COMPILER_VERSION == 741
|
---|
52 | # undef _POSIX_C_SOURCE
|
---|
53 | # undef _XOPEN_SOURCE
|
---|
54 | # endif
|
---|
55 |
|
---|
56 | //
|
---|
57 | // Python's LongObject.h helpfully #defines ULONGLONG_MAX for us,
|
---|
58 | // which confuses Boost's config
|
---|
59 | //
|
---|
60 | #include <limits.h>
|
---|
61 | #ifndef ULONG_MAX
|
---|
62 | # define BOOST_PYTHON_ULONG_MAX_UNDEFINED
|
---|
63 | #endif
|
---|
64 | #ifndef LONGLONG_MAX
|
---|
65 | # define BOOST_PYTHON_LONGLONG_MAX_UNDEFINED
|
---|
66 | #endif
|
---|
67 | #ifndef ULONGLONG_MAX
|
---|
68 | # define BOOST_PYTHON_ULONGLONG_MAX_UNDEFINED
|
---|
69 | #endif
|
---|
70 |
|
---|
71 | //
|
---|
72 | // Get ahold of Python's version number
|
---|
73 | //
|
---|
74 | #include <patchlevel.h>
|
---|
75 |
|
---|
76 | #if PY_MAJOR_VERSION<2 || PY_MAJOR_VERSION==2 && PY_MINOR_VERSION<2
|
---|
77 | #error Python 2.2 or higher is required for this version of Boost.Python.
|
---|
78 | #endif
|
---|
79 |
|
---|
80 | //
|
---|
81 | // Some things we need in order to get Python.h to work with compilers other
|
---|
82 | // than MSVC on Win32
|
---|
83 | //
|
---|
84 | #if defined(_WIN32) || defined(__CYGWIN__)
|
---|
85 | # if defined(__GNUC__) && defined(__CYGWIN__)
|
---|
86 |
|
---|
87 | # define SIZEOF_LONG 4
|
---|
88 |
|
---|
89 | # if PY_MAJOR_VERSION < 2 || PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 2
|
---|
90 |
|
---|
91 | typedef int pid_t;
|
---|
92 |
|
---|
93 | # define WORD_BIT 32
|
---|
94 | # define hypot _hypot
|
---|
95 | # include <stdio.h>
|
---|
96 |
|
---|
97 | # if PY_MAJOR_VERSION < 2
|
---|
98 | # define HAVE_CLOCK
|
---|
99 | # define HAVE_STRFTIME
|
---|
100 | # define HAVE_STRERROR
|
---|
101 | # endif
|
---|
102 |
|
---|
103 | # define NT_THREADS
|
---|
104 |
|
---|
105 | # ifndef NETSCAPE_PI
|
---|
106 | # define USE_SOCKET
|
---|
107 | # endif
|
---|
108 |
|
---|
109 | # ifdef USE_DL_IMPORT
|
---|
110 | # define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE
|
---|
111 | # endif
|
---|
112 |
|
---|
113 | # ifdef USE_DL_EXPORT
|
---|
114 | # define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE
|
---|
115 | # define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
|
---|
116 | # endif
|
---|
117 |
|
---|
118 | # define HAVE_LONG_LONG 1
|
---|
119 | # define LONG_LONG long long
|
---|
120 | # endif
|
---|
121 |
|
---|
122 | # elif defined(__MWERKS__)
|
---|
123 |
|
---|
124 | # ifndef _MSC_VER
|
---|
125 | # define PY_MSC_VER_DEFINED_FROM_WRAP_PYTHON_H 1
|
---|
126 | # define _MSC_VER 900
|
---|
127 | # endif
|
---|
128 |
|
---|
129 | # undef hypot // undo the evil #define left by Python.
|
---|
130 |
|
---|
131 | # elif defined(__BORLANDC__)
|
---|
132 | # undef HAVE_HYPOT
|
---|
133 | # define HAVE_HYPOT 1
|
---|
134 | # endif
|
---|
135 |
|
---|
136 | #endif // _WIN32
|
---|
137 |
|
---|
138 | #if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 2 && PY_MICRO_VERSION < 2
|
---|
139 | # include <boost/python/detail/python22_fixed.h>
|
---|
140 | #else
|
---|
141 | # include <Python.h>
|
---|
142 | #endif
|
---|
143 |
|
---|
144 | #ifdef BOOST_PYTHON_ULONG_MAX_UNDEFINED
|
---|
145 | # undef ULONG_MAX
|
---|
146 | # undef BOOST_PYTHON_ULONG_MAX_UNDEFINED
|
---|
147 | #endif
|
---|
148 |
|
---|
149 | #ifdef BOOST_PYTHON_LONGLONG_MAX_UNDEFINED
|
---|
150 | # undef LONGLONG_MAX
|
---|
151 | # undef BOOST_PYTHON_LONGLONG_MAX_UNDEFINED
|
---|
152 | #endif
|
---|
153 |
|
---|
154 | #ifdef BOOST_PYTHON_ULONGLONG_MAX_UNDEFINED
|
---|
155 | # undef ULONGLONG_MAX
|
---|
156 | # undef BOOST_PYTHON_ULONGLONG_MAX_UNDEFINED
|
---|
157 | #endif
|
---|
158 |
|
---|
159 | #ifdef PY_MSC_VER_DEFINED_FROM_WRAP_PYTHON_H
|
---|
160 | # undef _MSC_VER
|
---|
161 | #endif
|
---|
162 |
|
---|
163 | #ifdef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
|
---|
164 | # undef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
|
---|
165 | # define _DEBUG
|
---|
166 | # ifdef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H
|
---|
167 | # undef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H
|
---|
168 | # undef _CRT_NOFORCE_MANIFEST
|
---|
169 | # endif
|
---|
170 | #endif
|
---|
171 |
|
---|
172 | #if !defined(PY_MAJOR_VERSION) || PY_MAJOR_VERSION < 2
|
---|
173 | # define PyObject_INIT(op, typeobj) \
|
---|
174 | ( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
|
---|
175 | #endif
|
---|
176 |
|
---|
177 | #ifdef __MWERKS__
|
---|
178 | # pragma warn_possunwant off
|
---|
179 | #elif _MSC_VER
|
---|
180 | # pragma warning(disable:4786)
|
---|
181 | #endif
|
---|
182 |
|
---|
183 | #if defined(HAVE_LONG_LONG)
|
---|
184 | # if defined(PY_LONG_LONG)
|
---|
185 | # define BOOST_PYTHON_LONG_LONG PY_LONG_LONG
|
---|
186 | # elif defined(LONG_LONG)
|
---|
187 | # define BOOST_PYTHON_LONG_LONG LONG_LONG
|
---|
188 | # else
|
---|
189 | # error "HAVE_LONG_LONG defined but not PY_LONG_LONG or LONG_LONG"
|
---|
190 | # endif
|
---|
191 | #endif
|
---|