Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/python/module_init.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright David Abrahams 2002.
0002 // Distributed under the Boost Software License, Version 1.0. (See
0003 // accompanying file LICENSE_1_0.txt or copy at
0004 // http://www.boost.org/LICENSE_1_0.txt)
0005 #ifndef MODULE_INIT_DWA20020722_HPP
0006 # define MODULE_INIT_DWA20020722_HPP
0007 
0008 # include <boost/python/detail/prefix.hpp>
0009 # include <boost/preprocessor/cat.hpp>
0010 # include <boost/preprocessor/stringize.hpp>
0011 
0012 # ifndef BOOST_PYTHON_MODULE_INIT
0013 
0014 namespace boost { namespace python { namespace detail {
0015 
0016 #  if PY_VERSION_HEX >= 0x03000000
0017 
0018 BOOST_PYTHON_DECL PyObject* init_module(PyModuleDef&, void(*)());
0019 
0020 #else
0021 
0022 BOOST_PYTHON_DECL PyObject* init_module(char const* name, void(*)());
0023 
0024 #endif
0025 
0026 }}}
0027 
0028 #  if PY_VERSION_HEX >= 0x03000000
0029 
0030 #   define _BOOST_PYTHON_MODULE_INIT(name) \
0031   PyObject* BOOST_PP_CAT(PyInit_, name)()  \
0032   { \
0033     static PyModuleDef_Base initial_m_base = { \
0034         PyObject_HEAD_INIT(NULL) \
0035         0, /* m_init */ \
0036         0, /* m_index */ \
0037         0 /* m_copy */ };  \
0038     static PyMethodDef initial_methods[] = { { 0, 0, 0, 0 } }; \
0039  \
0040     static struct PyModuleDef moduledef = { \
0041         initial_m_base, \
0042         BOOST_PP_STRINGIZE(name), \
0043         0, /* m_doc */ \
0044         -1, /* m_size */ \
0045         initial_methods, \
0046         0,  /* m_reload */ \
0047         0, /* m_traverse */ \
0048         0, /* m_clear */ \
0049         0,  /* m_free */ \
0050     }; \
0051  \
0052     return boost::python::detail::init_module( \
0053         moduledef, BOOST_PP_CAT(init_module_, name) ); \
0054   } \
0055   void BOOST_PP_CAT(init_module_, name)()
0056 
0057 #  else
0058 
0059 #   define _BOOST_PYTHON_MODULE_INIT(name)              \
0060   void BOOST_PP_CAT(init,name)()                        \
0061 {                                                       \
0062     boost::python::detail::init_module(                 \
0063         BOOST_PP_STRINGIZE(name),&BOOST_PP_CAT(init_module_,name)); \
0064 }                                                       \
0065   void BOOST_PP_CAT(init_module_,name)()
0066 
0067 #  endif
0068 
0069 #  define BOOST_PYTHON_MODULE_INIT(name)                       \
0070   void BOOST_PP_CAT(init_module_,name)();                      \
0071 extern "C" BOOST_SYMBOL_EXPORT _BOOST_PYTHON_MODULE_INIT(name)
0072 
0073 # endif
0074 
0075 #endif // MODULE_INIT_DWA20020722_HPP