To which type does SWIG maps C++ signed char * type in Python? -
i need pass non null terminating buffer python c++. i'm using parameter of signed char* type instead of char* since latter converted null terminating string. python interface generated using swig (2.0.1). no typemaps applied swig should use default mapping. when i'm trying use method following error:
notimplementederror: wrong number or type of arguments overloaded function
as buffer tried passing both string , bytearray objects. in both cases mentioned error.
so if have function in c++ type of object should pass in python ?
void set_value(signed char *buffer, int size)
you might able inline wrapper accepts c++ string (which not null terminated), this:
%include <std_string.i> %inline %{ void set_value_str(const std::string& str) { set_value(str.c_str(), str.size()); } %}
the std_string.i
defines typemaps allow call set_value_str
python string argument. don't know if typemap uses char array version of std::string
constructor, invalidate approach if buffer can contain null bytes.
note: can name wrapper set_value
, doesn't have different name.
Comments
Post a Comment