2
0
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:
Stefan Seefeld
2005-08-17 13:04:42 +00:00
parent 9205f507b0
commit 126a3efb92
14 changed files with 462 additions and 199 deletions

25
src/import.cpp Normal file
View 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