OLD | NEW |
(Empty) | |
| 1 /* ----------------------------------------------------------------------------- |
| 2 * See the LICENSE file for information on copyright, usage and redistribution |
| 3 * of SWIG, and the README file for authors - http://www.swig.org/release.html. |
| 4 * |
| 5 * cdata.swg |
| 6 * |
| 7 * This library file contains macros for manipulating raw C data as strings. |
| 8 * -----------------------------------------------------------------------------
*/ |
| 9 |
| 10 %{ |
| 11 typedef struct SWIGCDATA { |
| 12 char *data; |
| 13 size_t len; |
| 14 } SWIGCDATA; |
| 15 %} |
| 16 |
| 17 /* ----------------------------------------------------------------------------- |
| 18 * Typemaps for returning binary data |
| 19 * -----------------------------------------------------------------------------
*/ |
| 20 |
| 21 %typemap(out,noblock=1,fragment="SWIG_FromCharPtrAndSize") SWIGCDATA { |
| 22 %set_output(SWIG_FromCharPtrAndSize($1.data,$1.len)); |
| 23 } |
| 24 %typemap(in) (const void *indata, int inlen) = (char *STRING, int SIZE); |
| 25 |
| 26 |
| 27 /* ----------------------------------------------------------------------------- |
| 28 * %cdata(TYPE [, NAME]) |
| 29 * |
| 30 * Convert raw C data to a binary string. |
| 31 * -----------------------------------------------------------------------------
*/ |
| 32 |
| 33 %define %cdata(TYPE,NAME...) |
| 34 |
| 35 %insert("header") { |
| 36 #ifdef __cplusplus |
| 37 extern "C" { |
| 38 #endif |
| 39 #if #NAME == "" |
| 40 static SWIGCDATA cdata_##TYPE(TYPE *ptr, size_t nelements) |
| 41 #else |
| 42 static SWIGCDATA cdata_##NAME(TYPE *ptr, size_t nelements) |
| 43 #endif |
| 44 { |
| 45 SWIGCDATA d; |
| 46 d.data = (char *) ptr; |
| 47 #if #TYPE != "void" |
| 48 d.len = nelements*sizeof(TYPE); |
| 49 #else |
| 50 d.len = nelements; |
| 51 #endif |
| 52 return d; |
| 53 } |
| 54 #ifdef __cplusplus |
| 55 } |
| 56 #endif |
| 57 } |
| 58 |
| 59 #ifdef __cplusplus |
| 60 extern "C" |
| 61 #endif |
| 62 #if #NAME == "" |
| 63 SWIGCDATA cdata_##TYPE(TYPE *ptr, size_t nelements = 1); |
| 64 #else |
| 65 SWIGCDATA cdata_##NAME(TYPE *ptr, size_t nelements = 1); |
| 66 #endif |
| 67 %enddef |
| 68 |
| 69 %rename(cdata) ::cdata_void(void *ptr, size_t nelements = 1); |
| 70 |
| 71 %cdata(void); |
| 72 |
| 73 /* Memory move function */ |
| 74 void memmove(void *data, const void *indata, size_t inlen); |
| 75 |
| 76 |
| 77 |
| 78 |
OLD | NEW |