h_sequence, h_choice and HCountedSequence are all having weird issues, but tests are in a workable format now

This commit is contained in:
Meredith L. Patterson 2013-11-19 00:18:25 -06:00
parent 2d459282d4
commit 5ced9fe9d5
2 changed files with 98 additions and 78 deletions

View file

@ -1,10 +1,11 @@
%module hammer
%include "stdint.i"
%include "typemaps.i"
%apply char [ANY] { uint8_t [ANY] };
//%include "typemaps.i"
//%apply char [ANY] { uint8_t [ANY] };
#if defined(SWIGPYTHON)
%ignore HCountedArray_;
%typemap(in) uint8_t* {
$1 = (uint8_t*)PyString_AsString($input);
}
@ -22,9 +23,23 @@
$1 = *(uint8_t*)PyString_AsString($input);
}
}
/*
%typemap(out) uint8_t {
$result = PyString_FromString(&$1);
}
*/
%typemap(out) HBytes* {
$result = PyString_FromStringAndSize((char*)$1->token, $1->len);
}
%typemap(out) struct HCountedArray_* {
int i;
$result = PyList_New($1->used);
for (i=0; i<$1->used; i++) {
HParsedToken *t = $1->elements[i];
PyObject *o = SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_HParsedToken_, 0 | 0);
PyList_SetItem($result, i, o);
}
}
#else
#warning no uint8_t* typemaps defined
#endif