mirror of
https://github.com/boostorg/python.git
synced 2026-01-21 05:02:17 +00:00
Added scope
[SVN r14593]
This commit is contained in:
@@ -9,13 +9,18 @@
|
||||
#include <boost/python/detail/module_base.hpp>
|
||||
#include <boost/python/object/function.hpp>
|
||||
#include <boost/python/cast.hpp>
|
||||
#include <boost/python/scope.hpp>
|
||||
#include <boost/python/borrowed.hpp>
|
||||
#include <boost/python/object.hpp>
|
||||
#include <boost/python/detail/raw_pyobject.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace detail {
|
||||
|
||||
module_base::module_base(const char* name)
|
||||
: m_module(
|
||||
python::borrowed(Py_InitModule(const_cast<char*>(name), initial_methods))
|
||||
)
|
||||
allow_null(python::borrowed(
|
||||
scope::get().ptr()
|
||||
)))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -59,4 +64,36 @@ void module_base::add_class(type_handle const& class_obj)
|
||||
|
||||
PyMethodDef module_base::initial_methods[] = { { 0, 0, 0, 0 } };
|
||||
|
||||
namespace
|
||||
{
|
||||
PyMethodDef initial_methods[] = { { 0, 0, 0, 0 } };
|
||||
}
|
||||
|
||||
BOOST_PYTHON_DECL void init_module(char const* name, void(*init_function)())
|
||||
{
|
||||
|
||||
PyObject* m
|
||||
= Py_InitModule(const_cast<char*>(name), initial_methods);
|
||||
|
||||
if (m != 0)
|
||||
{
|
||||
;
|
||||
|
||||
// Create the current module scope
|
||||
scope current_module(
|
||||
(object(
|
||||
((borrowed_reference_t*)m)
|
||||
))
|
||||
);
|
||||
|
||||
handle_exception(init_function);
|
||||
}
|
||||
}
|
||||
|
||||
}}} // namespace boost::python::detail
|
||||
|
||||
namespace boost { namespace python {
|
||||
|
||||
BOOST_PYTHON_DECL PyObject* scope::current_scope;
|
||||
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user