From bca00c65dddb926df9aa7488502e16ea20020cb3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 23 Apr 2016 01:30:35 +0200 Subject: [PATCH] Implement cdata typemaps for C Just use the struct directly in the C wrappers. --- Examples/test-suite/c/Makefile.in | 1 - Lib/cdata.i | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/c/Makefile.in b/Examples/test-suite/c/Makefile.in index c3175ae5d..b4b80a2d3 100644 --- a/Examples/test-suite/c/Makefile.in +++ b/Examples/test-suite/c/Makefile.in @@ -33,7 +33,6 @@ FAILING_C_TESTS := \ function_typedef \ lextype \ li_carrays \ - li_cdata \ li_cpointer \ nested \ nested_extend_c \ diff --git a/Lib/cdata.i b/Lib/cdata.i index b9b8e1887..23e552cf9 100644 --- a/Lib/cdata.i +++ b/Lib/cdata.i @@ -21,6 +21,28 @@ typedef struct SWIGCDATA { } %typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); +#elif SWIGC + +%insert("cheader") { +typedef struct SWIGCDATA { + char *data; + int len; +} SWIGCDATA; +} + +%typemap(ctype) SWIGCDATA "SWIGCDATA" +%typemap(cppouttype) SWIGCDATA "SWIGCDATA" + +%typemap(out) SWIGCDATA { + $result = $1; +} + +%typemap(ctype) (const void *indata, int inlen) "const SWIGCDATA*" +%typemap(in) (const void *indata, int inlen) { + $1 = $input->data; + $2 = $input->len; +} + #elif SWIGCHICKEN %typemap(out) SWIGCDATA {