在python中使用C ++类实例而不包装

时间:2018-06-04 19:47:34

标签: c++ boost boost-python

我正在为我的C ++类编写一个Boost python包装器。我的一个成员函数有一个参数,它是我在另一个文件中定义的结构类型。这个结构非常大,为这个类编写一个单独的包装器需要很长时间。我不需要在python中输出这个类的任何数据成员。有没有更有效的方法来使用我的成员函数而不必包装参数struct type?

包装课程:

#include <complicated_class.hh>

class outer_class
{
    public:
        get_object(complicated_class object){
            do_something();
        }
}

升压:

BOOST_PYTHON_MODULE(module)
{
    py::class_<outer_class>("outer")
        .def("get_object", &outer_class::get_object);
}

0 个答案:

没有答案