Commit 6f453688 authored by Jonathan Beck's avatar Jonathan Beck

Use custom typemap for binary buffers as we want to hadle them as strings in python.

parent e6a0149e
......@@ -23,11 +23,26 @@ PListNode *allocate_plist_wrapper(plist_t plist, char should_keep_plist) {
}
%}
%include "stl.i"
%include "std_string.i"
#if SWIGPYTHON
%typemap(out) std::vector<char> {
$result = PyString_FromStringAndSize((const char*)&($1[0]),(int)($1.size()));
}
%typemap(in) (const std::vector<char>& v)
{
if (!PyString_Check($input)) {
PyErr_SetString(PyExc_ValueError,"Expected a string");
return NULL;
}
char* buffer = PyString_AsString($input);
int length = PyString_Size($input);
$1 = std::vector<char>(buffer, buffer + length);
}
#else
#endif
namespace std {
%template(vectorc) vector<char>;
};
%rename(__assign__) *::operator=;
%rename(__getitem__) *::operator[];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment