annotate DEPENDENCIES/generic/include/boost/python/detail/wrap_python.hpp @ 125:34e428693f5d vext

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