| 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 | #include <boost/python/scope.hpp> |
|---|
| 10 | #include <boost/python/object/add_to_namespace.hpp> |
|---|
| 11 | |
|---|
| 12 | namespace boost { namespace python { namespace detail { |
|---|
| 13 | |
|---|
| 14 | BOOST_PYTHON_DECL void scope_setattr_doc(char const* name, object const& x, char const* doc) |
|---|
| 15 | { |
|---|
| 16 | // Use function::add_to_namespace to achieve overloading if |
|---|
| 17 | // appropriate. |
|---|
| 18 | scope current; |
|---|
| 19 | objects::add_to_namespace(current, name, x, doc); |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | namespace |
|---|
| 23 | { |
|---|
| 24 | PyMethodDef initial_methods[] = { { 0, 0, 0, 0 } }; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | BOOST_PYTHON_DECL void init_module(char const* name, void(*init_function)()) |
|---|
| 28 | { |
|---|
| 29 | |
|---|
| 30 | PyObject* m |
|---|
| 31 | = Py_InitModule(const_cast<char*>(name), initial_methods); |
|---|
| 32 | |
|---|
| 33 | if (m != 0) |
|---|
| 34 | { |
|---|
| 35 | // Create the current module scope |
|---|
| 36 | object m_obj(((borrowed_reference_t*)m)); |
|---|
| 37 | scope current_module(m_obj); |
|---|
| 38 | |
|---|
| 39 | handle_exception(init_function); |
|---|
| 40 | } |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | }}} // namespace boost::python::detail |
|---|
| 44 | |
|---|
| 45 | namespace boost { namespace python { |
|---|
| 46 | |
|---|
| 47 | namespace detail |
|---|
| 48 | { |
|---|
| 49 | BOOST_PYTHON_DECL PyObject* current_scope = 0; |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | }} |
|---|