h_sequence, h_choice and HCountedSequence are all having weird issues, but tests are in a workable format now
This commit is contained in:
parent
2d459282d4
commit
5ced9fe9d5
2 changed files with 98 additions and 78 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue