abac0-leakabac0-meicompt_changesgec13mei-idmei-rt0-nmei_rt0mei_rt2mei_rt2_fix_1meiyap-rt1meiyap1rt2tvf-new-xml
Last change
on this file since df3fe37 was
df3fe37,
checked in by Mike Ryan <mikeryan@…>, 13 years ago
|
always return a string for chunk_t
|
-
Property mode set to
100644
|
File size:
765 bytes
|
Rev | Line | |
---|
[a5a8234] | 1 | // bytearrays are new as of 2.6 |
---|
| 2 | %{ |
---|
| 3 | #if (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 6) || PY_MAJOR_VERSION > 2 |
---|
| 4 | #define MODERN_PYTHON |
---|
| 5 | #endif |
---|
| 6 | %} |
---|
| 7 | |
---|
| 8 | // abac_chunk_t is a bytearray or a string |
---|
| 9 | %typemap(in) abac_chunk_t %{ |
---|
[bc62c32] | 10 | if (PyString_Check($input)) |
---|
| 11 | PyString_AsStringAndSize( |
---|
| 12 | $input, |
---|
| 13 | (char **)&$1.ptr, |
---|
| 14 | &$1.len |
---|
| 15 | ); |
---|
[a5a8234] | 16 | #ifdef MODERN_PYTHON |
---|
[bc62c32] | 17 | else if (PyByteArray_Check($input)) { |
---|
| 18 | $1.ptr = (unsigned char *)PyByteArray_AS_STRING($input); |
---|
| 19 | $1.len = PyByteArray_GET_SIZE($input); |
---|
| 20 | } |
---|
[a5a8234] | 21 | #endif |
---|
[bc62c32] | 22 | else |
---|
| 23 | SWIG_exception(SWIG_TypeError, "Expected string or byte array"); |
---|
[a5a8234] | 24 | %} |
---|
| 25 | |
---|
| 26 | %typemap(out) abac_chunk_t %{ |
---|
| 27 | $result = PyString_FromStringAndSize( |
---|
| 28 | (const char *)$1.ptr, |
---|
| 29 | $1.len |
---|
| 30 | ); |
---|
| 31 | %} |
---|
Note: See
TracBrowser
for help on using the repository browser.