mirror of
https://github.com/boostorg/python.git
synced 2026-01-23 17:52:17 +00:00
Add basic embedding support.
[SVN r30601]
This commit is contained in:
25
src/import.cpp
Normal file
25
src/import.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright Stefan Seefeld 2005.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/python/import.hpp>
|
||||
#include <boost/python/borrowed.hpp>
|
||||
#include <boost/python/extract.hpp>
|
||||
#include <boost/python/handle.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace python
|
||||
{
|
||||
|
||||
object import(str name)
|
||||
{
|
||||
// should be 'char const *' but older python versions don't use 'const' yet.
|
||||
char *n = python::extract<char *>(name);
|
||||
python::handle<> module(python::borrowed(PyImport_AddModule(n)));
|
||||
return python::object(module);
|
||||
}
|
||||
|
||||
} // namespace boost::python
|
||||
} // namespace boost
|
||||
Reference in New Issue
Block a user