mirror of
https://github.com/boostorg/python.git
synced 2026-02-02 09:02:15 +00:00
added support for sharing of extension_classes across modules
[SVN r8399]
This commit is contained in:
28
shared_modules/m1.cpp
Normal file
28
shared_modules/m1.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#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()
|
||||
{
|
||||
py::module_builder m1("m1");
|
||||
|
||||
|
||||
py::class_builder<M1> m1_class(m1, "M1");
|
||||
m1_class.def(py::constructor<>());
|
||||
m1_class.declare_base(py::type<Shared>());
|
||||
|
||||
m1.def(&test, "test");
|
||||
}
|
||||
Reference in New Issue
Block a user