2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-19 16:32:16 +00:00
Files
python/shared_modules/m1.cpp
Ullrich Köthe 9374bca9a0 improved error reporting
[SVN r8400]
2000-12-08 00:56:11 +00:00

42 lines
796 B
C++

#include "boost/python/module_builder.hpp"
#include "boost/python/class_builder.hpp"
#include "shared.hpp"
#include "Python.h"
struct M1 : Shared
{
char const * name() const { return "M1"; }
};
namespace py = boost::python;
char const * test(Shared const & m)
{
return m.name();
}
extern "C" void initm1()
{
try {
py::module_builder m1("m1");
py::class_builder<M1> m1_class(m1, "M1");
m1_class.def(py::constructor<>());
try {
m1_class.declare_base(py::type<Shared>());
}
catch(std::runtime_error & )
{
throw std::runtime_error("You must load module `shared' before module `m1'");
}
m1.def(&test, "test");
}
catch(...)
{
py::handle_exception();
}
}