typemap to fix conversion from python strings to uint8_t*

This commit is contained in:
Meredith L. Patterson 2013-11-18 17:19:46 -06:00 committed by Dan Hirsch
parent 4bd2fc9e72
commit eba8ecc6c3

View file

@ -1,7 +1,16 @@
%module hammer %module hammer
%include "typemaps.i"
%include "stdint.i" %include "stdint.i"
%include "typemaps.i"
%apply char [ANY] { uint8_t [ANY] };
#if defined(SWIGPYTHON)
%typemap(in) uint8_t* {
$1 = (uint8_t*)PyString_AsString($input);
}
#else
#warning no "in" typemap defined
#endif
// All the include paths are relative to the build, i.e., ../../. If you need to build these manually (i.e., not with scons), keep that in mind. // All the include paths are relative to the build, i.e., ../../. If you need to build these manually (i.e., not with scons), keep that in mind.
%{ %{
@ -12,5 +21,5 @@
%include "allocator.h" %include "allocator.h"
%include "hammer.h" %include "hammer.h"
%apply const char* { const uint8_t* }