I am trying to wrap a large GUI library called JUCE. I want to generate separate DLLs for separate subsystems and for this I have got separate BOOST_PYTHON_MODULE() statement in visual studio. The projects are separate.
Currently I have 2 projects:
JUCE:
BOOST_PYTHON_MODULE(JUCE)
{
class_<String>("String", init<char*>())
.def("toStdString", &String::toStdString);
def("mainLoop", &mainLoop);
def("quit", &quit);
}
and COMPONENT:
BOOST_PYTHON_MODULE(COMPONENT)
{
class_<PyJuceComponent, boost::noncopyable>("Component")
.def(init<std::string>())
.def("setName", &PyJuceComponent::setName)
.def("getName", &PyJuceComponent::getName, return_value_policy<return_by_value>())
.def("getComponentID", &PyJuceComponent::getComponentID, return_value_policy<return_by_value>())
.def("setOpaque", &PyJuceComponent::setOpaque)
.def("setVisible", &PyJuceComponent::setVisible)
.def("addToDesktop", &PyJuceComponent::addToDesktop)
.def("centreWithSize", &PyJuceComponent::centreWithSize)
.def("userTriedToCloseWindow", &PyJuceComponent::userTriedToCloseWindow)
;
// enums
enum_<ComponentPeer::StyleFlags>("StyleFlags")
.value("windowAppearsOnTaskbar", ComponentPeer::windowAppearsOnTaskbar)
.value("windowHasTitleBar", ComponentPeer::windowHasTitleBar)
.value("windowIsResizable", ComponentPeer::windowIsResizable)
.value("windowHasMinimiseButton", ComponentPeer::windowHasMinimiseButton)
.value("windowHasMaximiseButton", ComponentPeer::windowHasMaximiseButton)
.value("windowHasCloseButton", ComponentPeer::windowHasCloseButton)
.value("windowHasDropShadow", ComponentPeer::windowHasDropShadow)
;
}
The String class is the problem. I want to declare the String class in JUCE but I do want to use it with Component as it is the same class.
However this does not seem to work:
str = JUCE.String("hallo")
comp = new COMPONENT.Component()
comp.setName(str) <---------------------- fails with type mismatch !!
If I add the String class in the COMPONENT module then I can do :
str = COMPONENT.String("hallo")
comp = new COMPONENT.Component()
comp.setName(str)
But this is non-intuitive. I want to only have JUCE.String() and use it with the other classes, even though they are from different .pyd files (it is the same library and file in the end)
In fact I want to share it as its a very common class used in all parts of the library.