Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52131 - in sandbox-branches/bhy/py3k: boost/python libs/python/src libs/python/src/object
From: divinekid_at_[hidden]
Date: 2009-04-02 11:27:54


Author: bhy
Date: 2009-04-02 11:27:53 EDT (Thu, 02 Apr 2009)
New Revision: 52131
URL: http://svn.boost.org/trac/boost/changeset/52131

Log:
More BPL .cpps compiled. A part of Python 3 module initilization support done.
Text files modified:
   sandbox-branches/bhy/py3k/boost/python/module_init.hpp | 5 ++++-
   sandbox-branches/bhy/py3k/libs/python/src/module.cpp | 19 +++++++++++++++++--
   sandbox-branches/bhy/py3k/libs/python/src/object/life_support.cpp | 7 +++----
   3 files changed, 24 insertions(+), 7 deletions(-)

Modified: sandbox-branches/bhy/py3k/boost/python/module_init.hpp
==============================================================================
--- sandbox-branches/bhy/py3k/boost/python/module_init.hpp (original)
+++ sandbox-branches/bhy/py3k/boost/python/module_init.hpp 2009-04-02 11:27:53 EDT (Thu, 02 Apr 2009)
@@ -11,10 +11,13 @@
 
 namespace boost { namespace python { namespace detail {
 
-BOOST_PYTHON_DECL void init_module(char const* name, void(*)());
+BOOST_PYTHON_DECL PyObject* init_module(char const* name, void(*)());
 
 }}}
 
+// TODO(bhy) Take care of this later.
+// But any reseaon we don't use BOOST_PYTHON_DECL here?
+
 # if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(BOOST_PYTHON_STATIC_MODULE)
 
 # define BOOST_PYTHON_MODULE_INIT(name) \

Modified: sandbox-branches/bhy/py3k/libs/python/src/module.cpp
==============================================================================
--- sandbox-branches/bhy/py3k/libs/python/src/module.cpp (original)
+++ sandbox-branches/bhy/py3k/libs/python/src/module.cpp 2009-04-02 11:27:53 EDT (Thu, 02 Apr 2009)
@@ -24,11 +24,25 @@
   PyMethodDef initial_methods[] = { { 0, 0, 0, 0 } };
 }
 
-BOOST_PYTHON_DECL void init_module(char const* name, void(*init_function)())
+BOOST_PYTHON_DECL PyObject* init_module(char const* name, void(*init_function)())
 {
-
+#if PY_VERSION_HEX >= 0x03000000
+ static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ name,
+ 0, /* m_doc */
+ -1, /* m_size */
+ initial_methods,
+ 0, /* m_reload */
+ 0, /* m_traverse */
+ 0, /* m_clear */
+ 0, /* m_free */
+ };
+ PyObject* m = PyModule_Create(&moduledef);
+#else
     PyObject* m
         = Py_InitModule(const_cast<char*>(name), initial_methods);
+#endif
 
     if (m != 0)
     {
@@ -38,6 +52,7 @@
         
         handle_exception(init_function);
     }
+ return m;
 }
 
 }}} // namespace boost::python::detail

Modified: sandbox-branches/bhy/py3k/libs/python/src/object/life_support.cpp
==============================================================================
--- sandbox-branches/bhy/py3k/libs/python/src/object/life_support.cpp (original)
+++ sandbox-branches/bhy/py3k/libs/python/src/object/life_support.cpp 2009-04-02 11:27:53 EDT (Thu, 02 Apr 2009)
@@ -36,8 +36,7 @@
 }
 
 PyTypeObject life_support_type = {
- PyObject_HEAD_INIT(0)//(&PyType_Type)
- 0,
+ PyVarObject_HEAD_INIT(NULL, 0)//(&PyType_Type)
     const_cast<char*>("Boost.Python.life_support"),
     sizeof(life_support),
     0,
@@ -92,9 +91,9 @@
     if (nurse == Py_None || nurse == patient)
         return nurse;
     
- if (life_support_type.ob_type == 0)
+ if (Py_TYPE(&life_support_type) == 0)
     {
- life_support_type.ob_type = &PyType_Type;
+ Py_TYPE(&life_support_type) = &PyType_Type;
         PyType_Ready(&life_support_type);
     }
     


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk