Does pybindgen support cross module inheritance?
Is it possible to use pybindgen to expose a C++ inheritance hierarchy where the base class is wrapped in one python module and the derived class in another? As an example suppose I have the following classes in a header "classes.hh":
#include <iostream>
class Base {
public:
Base() { std::cerr << "Base::Base()" << std::endl; }
virtual ~Base() { std::cerr << "Base::~Base()" << std::endl; }
virtual void do_something() const { std::cerr << "Base::
};
class Derived: public Base {
public:
Derived(): Base() { std::cerr << "Derived:
virtual ~Derived() { std::cerr << "Derived:
virtual void do_something() const { std::cerr << "Derived:
};
I expose the "Base" class in one pybindgen generated python module like so:
from pybindgen import *
# Module
mod = Module("A")
mod.add_
# Base
Base = mod.add_
Base.add_
Base.add_
I would like to wrap the "Derived" class in a separate module like the following:
from pybindgen import *
import A
# Module
mod = Module("B")
mod.add_
# Derived
Derived = mod.add_
Derived.
Derived.
When I try and do this however, the code generated for module "B" above contains references to things that are defined in the code generated for "A" (not surprisingly), and so of course it doesn't compile. Is there some simple way to accomplish this kind of cross module inheritance with pybindgen?
Thanks!
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- PyBindGen Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Mike Owen for more information if necessary.