there's the uint8_t problem (mostly) sorted

This commit is contained in:
Meredith L. Patterson 2013-11-18 21:50:28 -06:00
parent b979f66c21
commit 2d459282d4
2 changed files with 19 additions and 7 deletions

View file

@ -11,6 +11,20 @@
%typemap(out) uint8_t* {
$result = PyString_FromString((char*)$1);
}
%typemap(in) uint8_t {
if (PyInt_Check($input)) {
$1 = PyInt_AsLong($input);
}
else if (!PyString_Check($input)) {
PyErr_SetString(PyExc_ValueError, "Expecting a string");
return NULL;
} else {
$1 = *(uint8_t*)PyString_AsString($input);
}
}
%typemap(out) HBytes* {
$result = PyString_FromStringAndSize((char*)$1->token, $1->len);
}
#else
#warning no uint8_t* typemaps defined
#endif
@ -24,5 +38,3 @@
%include "allocator.h"
%include "hammer.h"