Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/python/detail/wrap_python.hpp @ 35

Last change on this file since 35 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 4.9 KB
Line 
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 >= 740
52#  undef _POSIX_C_SOURCE
53#  undef _XOPEN_SOURCE
54#  undef HAVE_STDINT_H // undo Python 2.5.1 define
55# endif
56
57//
58// Python's LongObject.h helpfully #defines ULONGLONG_MAX for us,
59// which confuses Boost's config
60//
61#include <limits.h>
62#ifndef ULONG_MAX
63# define BOOST_PYTHON_ULONG_MAX_UNDEFINED
64#endif
65#ifndef LONGLONG_MAX
66# define BOOST_PYTHON_LONGLONG_MAX_UNDEFINED
67#endif
68#ifndef ULONGLONG_MAX
69# define BOOST_PYTHON_ULONGLONG_MAX_UNDEFINED
70#endif
71
72//
73// Get ahold of Python's version number
74//
75#include <patchlevel.h>
76
77#if PY_MAJOR_VERSION<2 || PY_MAJOR_VERSION==2 && PY_MINOR_VERSION<2
78#error Python 2.2 or higher is required for this version of Boost.Python.
79#endif
80
81//
82// Some things we need in order to get Python.h to work with compilers other
83// than MSVC on Win32
84//
85#if defined(_WIN32) || defined(__CYGWIN__)
86# if defined(__GNUC__) && defined(__CYGWIN__)
87
88#  define SIZEOF_LONG 4
89
90#  if PY_MAJOR_VERSION < 2 || PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION <= 2
91
92typedef int pid_t;
93
94#   define WORD_BIT 32
95#   define hypot _hypot
96#   include <stdio.h>
97
98#   if PY_MAJOR_VERSION < 2
99#    define HAVE_CLOCK
100#    define HAVE_STRFTIME
101#    define HAVE_STRERROR
102#   endif
103
104#   define NT_THREADS
105
106#   ifndef NETSCAPE_PI
107#    define USE_SOCKET
108#   endif
109
110#   ifdef USE_DL_IMPORT
111#    define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE
112#   endif
113
114#   ifdef USE_DL_EXPORT
115#    define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE
116#    define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
117#   endif
118
119#   define HAVE_LONG_LONG 1
120#   define LONG_LONG long long
121#  endif
122
123# elif defined(__MWERKS__)
124
125#  ifndef _MSC_VER
126#   define PY_MSC_VER_DEFINED_FROM_WRAP_PYTHON_H 1
127#   define _MSC_VER 900
128#  endif
129
130#  undef hypot // undo the evil #define left by Python.
131
132# elif defined(__BORLANDC__)
133#  undef HAVE_HYPOT
134#  define HAVE_HYPOT 1
135# endif
136
137#endif // _WIN32
138
139#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 2 && PY_MICRO_VERSION < 2
140# include <boost/python/detail/python22_fixed.h>
141#else
142# include <Python.h>
143#endif
144
145#ifdef BOOST_PYTHON_ULONG_MAX_UNDEFINED
146# undef ULONG_MAX
147# undef BOOST_PYTHON_ULONG_MAX_UNDEFINED
148#endif
149
150#ifdef BOOST_PYTHON_LONGLONG_MAX_UNDEFINED
151# undef LONGLONG_MAX
152# undef BOOST_PYTHON_LONGLONG_MAX_UNDEFINED
153#endif
154
155#ifdef BOOST_PYTHON_ULONGLONG_MAX_UNDEFINED
156# undef ULONGLONG_MAX
157# undef BOOST_PYTHON_ULONGLONG_MAX_UNDEFINED
158#endif
159
160#ifdef PY_MSC_VER_DEFINED_FROM_WRAP_PYTHON_H
161# undef _MSC_VER
162#endif
163
164#ifdef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
165# undef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
166# define _DEBUG
167# ifdef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H
168#  undef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H
169#  undef _CRT_NOFORCE_MANIFEST
170# endif
171#endif
172
173#if !defined(PY_MAJOR_VERSION) || PY_MAJOR_VERSION < 2
174# define PyObject_INIT(op, typeobj) \
175        ( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
176#endif
177
178#ifdef __MWERKS__
179# pragma warn_possunwant off
180#elif _MSC_VER
181# pragma warning(disable:4786)
182#endif
183
184#if defined(HAVE_LONG_LONG)
185# if defined(PY_LONG_LONG)
186#  define BOOST_PYTHON_LONG_LONG PY_LONG_LONG
187# elif defined(LONG_LONG)
188#  define BOOST_PYTHON_LONG_LONG LONG_LONG
189# else
190#  error "HAVE_LONG_LONG defined but not PY_LONG_LONG or LONG_LONG"
191# endif
192#endif
Note: See TracBrowser for help on using the repository browser.