diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2019-03-23 13:33:52 -0500 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2019-03-23 13:33:52 -0500 |
| commit | 454403b9fe96788534ade09631d3546edc418add (patch) | |
| tree | ace5ca6a855967036caea8997ab280aa8a4b7ffc /tests | |
| parent | 28e2d7bb872c94ca0f25ba0e018b5d6132dc8fbc (diff) | |
| download | nimterop-454403b9fe96788534ade09631d3546edc418add.tar.gz nimterop-454403b9fe96788534ade09631d3546edc418add.zip | |
Double pointer support
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/include/test.c | 4 | ||||
| -rw-r--r-- | tests/include/test.h | 15 | ||||
| -rw-r--r-- | tests/tnimterop_c.nim | 16 |
3 files changed, 35 insertions, 0 deletions
diff --git a/tests/include/test.c b/tests/include/test.c index 0312b4f..8990df9 100644 --- a/tests/include/test.c +++ b/tests/include/test.c @@ -60,6 +60,10 @@ void *test_call9() { return NULL; } +void **test_call10(int **param1) { + return NULL; +} + void multiline1(void) {} void *multiline2(void) { diff --git a/tests/include/test.h b/tests/include/test.h index e85acfd..9dba8ba 100644 --- a/tests/include/test.h +++ b/tests/include/test.h @@ -108,6 +108,7 @@ unsigned char test_call_param6(UNION2 param1); int test_call_param7(union UNION1 param1); float test_call_param8(int *param1); void *test_call9(); +void **test_call10(int **param1); // Issue #58 void @@ -131,6 +132,20 @@ UNION3 test_call_etype_ptr3(); typedef struct _Kernel { char name; } *Kernel; +// Double pointers +typedef void **DVOIDPTR; +typedef int **DINTPTR; + +struct dstruct { + int **field1; +}; + +typedef struct dstruct2 { + char **field1; + float **field2; + void **(*tcv)(int **param1); +} DSTRUCT2; + #ifdef __cplusplus } #endif
\ No newline at end of file diff --git a/tests/tnimterop_c.nim b/tests/tnimterop_c.nim index 86ac0fd..3fc33b9 100644 --- a/tests/tnimterop_c.nim +++ b/tests/tnimterop_c.nim @@ -145,3 +145,19 @@ when false: doAssert foobar1(3) == OSDEF * 3 when false: # Error: undeclared identifier: 'foobar2' doAssert foobar2(3) == 3 + 1 + +# Double pointer +var + dv: DVOIDPTR + di: DINTPTR + ds: dstruct + cstr = "Hello".cstring + ds2: DSTRUCT2 + +dv = addr vptr +di = addr iptr + +ds.field1 = di +ds2.field1 = addr cstr +ds2.tcv = test_call10 +check ds2.tcv(di) == nil
\ No newline at end of file |
