Boost.Python:注册非Boost.Python转换器

时间:2012-10-06 23:41:33

标签: c++ python boost-python sfml

我有一个使用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类型?

0 个答案:

没有答案