2015-05-27 19:19:32 +00:00
|
|
|
#![crate_type = "dylib"]
|
|
|
|
|
|
|
|
#[macro_use] extern crate cpython;
|
|
|
|
|
2016-03-05 22:20:53 +00:00
|
|
|
py_module_initializer!(inheritance, initinheritance, PyInit_inheritance, |py, m| {
|
2015-10-26 22:52:18 +00:00
|
|
|
try!(m.add(py, "__doc__", "Module documentation string"));
|
2015-06-24 22:02:56 +00:00
|
|
|
let base_class = try!(
|
2015-10-26 22:52:18 +00:00
|
|
|
m.add_type::<()>(py, "BaseClass")
|
2015-05-27 19:19:32 +00:00
|
|
|
.doc("Type doc string")
|
|
|
|
.finish());
|
|
|
|
for i in 1..10 {
|
|
|
|
try!(
|
2015-10-26 22:52:18 +00:00
|
|
|
m.add_type::<()>(py, &format!("C{}", i))
|
2015-06-24 22:02:56 +00:00
|
|
|
.base(&base_class)
|
2015-05-27 19:19:32 +00:00
|
|
|
.doc(&format!("Derived class #{}", i))
|
|
|
|
.finish());
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
});
|
|
|
|
|