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"));
|
2016-03-06 09:29:28 +00:00
|
|
|
let mut base_class_builder = m.add_type::<()>(py, "BaseClass");
|
|
|
|
base_class_builder.doc("Type doc string");
|
|
|
|
let base_class = try!(base_class_builder.finish());
|
2015-05-27 19:19:32 +00:00
|
|
|
for i in 1..10 {
|
2016-03-06 09:29:28 +00:00
|
|
|
let mut class_builder = m.add_type::<()>(py, &format!("C{}", i)).base(&base_class);
|
|
|
|
class_builder.doc(&format!("Derived class #{}", i));
|
|
|
|
try!(class_builder.finish());
|
2015-05-27 19:19:32 +00:00
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
});
|
|
|
|
|