From d65958d2eab530755c2a8c5d89b57b8917df7af6 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 1 May 2017 05:25:28 -0700 Subject: ffi: allow get for ptr-in and ptr-in-d. This supports some benign ambiguity, allowing the user to specify an extracted ptr return value as ptr-in or ptr-in-d, and have it work. --- ffi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ffi.c b/ffi.c index 901688d8..16bedd40 100644 --- a/ffi.c +++ b/ffi.c @@ -894,7 +894,7 @@ static void ffi_ptr_out_put(struct txr_ffi_type *tft, val s, mem_t *dst, } } -static val ffi_ptr_out_get(struct txr_ffi_type *tft, mem_t *src, val self) +static val ffi_ptr_get(struct txr_ffi_type *tft, mem_t *src, val self) { val tgttype = tft->mtypes; struct txr_ffi_type *tgtft = ffi_type_struct(tgttype); @@ -902,7 +902,7 @@ static val ffi_ptr_out_get(struct txr_ffi_type *tft, mem_t *src, val self) return ptr ? tgtft->get(tgtft, ptr, self) : nil; } -static val ffi_ptr_out_d_get(struct txr_ffi_type *tft, mem_t *src, val self) +static val ffi_ptr_d_get(struct txr_ffi_type *tft, mem_t *src, val self) { val tgttype = tft->mtypes; struct txr_ffi_type *tgtft = ffi_type_struct(tgttype); @@ -1365,31 +1365,31 @@ val ffi_type_compile(val syntax) val target_type = ffi_type_compile(cadr(syntax)); return make_ffi_type_pointer(syntax, cptr_s, sizeof (mem_t *), &ffi_type_pointer, - ffi_ptr_in_put, ffi_void_get, + ffi_ptr_in_put, ffi_ptr_get, ffi_ptr_in_in, target_type); } else if (sym == ptr_in_d_s) { val target_type = ffi_type_compile(cadr(syntax)); return make_ffi_type_pointer(syntax, cptr_s, sizeof (mem_t *), &ffi_type_pointer, - ffi_ptr_in_d_put, ffi_void_get, + ffi_ptr_in_d_put, ffi_ptr_d_get, 0, target_type); } else if (sym == ptr_out_s) { val target_type = ffi_type_compile(cadr(syntax)); return make_ffi_type_pointer(syntax, cptr_s, sizeof (mem_t *), &ffi_type_pointer, - ffi_ptr_out_put, ffi_ptr_out_get, + ffi_ptr_out_put, ffi_ptr_get, ffi_ptr_out_in, target_type); } else if (sym == ptr_out_d_s) { val target_type = ffi_type_compile(cadr(syntax)); return make_ffi_type_pointer(syntax, cptr_s, sizeof (mem_t *), &ffi_type_pointer, - ffi_ptr_out_put, ffi_ptr_out_d_get, + ffi_ptr_out_put, ffi_ptr_d_get, ffi_ptr_out_in, target_type); } else if (sym == ptr_s) { val target_type = ffi_type_compile(cadr(syntax)); return make_ffi_type_pointer(syntax, cptr_s, sizeof (mem_t *), &ffi_type_pointer, - ffi_ptr_put, ffi_ptr_out_get, + ffi_ptr_put, ffi_ptr_get, ffi_ptr_out_in, target_type); } else if (sym == buf_s || sym == buf_d_s) { cnum nelem = c_num(cadr(syntax)); -- cgit v1.2.3