我有一个使用Boost.Python和SFML的项目。我的许多对象都暴露了SFML类型,为了不再生成轮子,我想从我自己的绑定中返回由SFML的Python绑定包装的对象。例如,我有这个类:
class MyThing
{
public:
sf::Image& image() { return _image; }
private:
sf::Image _image;
};
绑定看起来像这样:
class_<MyThing>("MyThing")
.add_property("image", make_function(&MyThing::image, return_internal_reference<1>()))
;
当然,实际上尝试从Python访问mything.image
会产生TypeError: No Python class registered for C++ class sf::Image
,因为Boost.Python的转换注册表不知道sf::Image
(SFML的Python绑定是用Cython完成的)
有没有办法告诉Boost.Python转换注册表使用SFML的Python绑定包装sf::Image
类型?