%typemapping of a C++ Library for Python Interface

前端 未结 2 441
不知归路
不知归路 2021-01-22 19:00

I want to create a python wrapper for my C++ library. It would be cool, if there is a automatic conversion of std::vector to python lists and the other way round. Unfortunatly

2条回答
  •  天命终不由人
    2021-01-22 19:35

    If you're going to define the %typemaps manually, you will also need a %typemap(check), something like:

    %typemap(typecheck) std::vector& {
        $1 = PySequence_Check($input) ? 1 : 0;
    }
    

    I believe the rule of thumb is that if you define a %typemap(in), you should also define a %typemap(check) --- otherwise, the generated code never gets to where it's put your %typemap(in).

提交回复
热议问题