Skip to content

Commit

Permalink
Allow swig typemap to recognize any std::vector<char> as a python str…
Browse files Browse the repository at this point in the history
…ing.
  • Loading branch information
Glenn Washburn authored and nikias committed Sep 26, 2011
1 parent da9f709 commit 567a749
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions swig/plist.i
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
%include "stdint.i"

%typemap(out) std::vector<char> {
$result = SWIG_FromCharPtrAndSize((const char*)&($1[0]),(int)($1.size()));
$result = SWIG_FromCharPtrAndSize((const char*)&($1[0]),(size_t)($1.size()));
}

%typemap(in) (const std::vector<char>& v)
%typemap(in) (const std::vector<char>&)
{
char* buffer = NULL;
int length = 0;
size_t length = 0;
SWIG_AsCharPtrAndSize($input, &buffer, &length, NULL);
$1 = std::vector<char>(buffer, buffer + length);
$1 = new std::vector<char>(buffer, buffer + length - 1);
}

#if SWIGPYTHON
Expand Down

0 comments on commit 567a749

Please sign in to comment.