From ee064377143aa9cefb503bf0c277929a7ca641a1 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 23 Jun 2017 06:21:14 -0700 Subject: ffi: add back-pointer into type structure. Upcoming work is going to benefit from a pointer for navigating from the txr_ffi_type structure to the Lisp object whose implementation is that structure. * ffi.c (struct txr_ffi_type): New member, self. (make_ffi_type_builtin, make_ffi_type_pointer, make_ffi_type_struct, make_ffi_type_array, make_ffi_type_enum): Initialize self pointer. --- ffi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ffi.c b/ffi.c index 1b8aaf7b..6bbcc035 100644 --- a/ffi.c +++ b/ffi.c @@ -158,6 +158,7 @@ struct smemb { }; struct txr_ffi_type { + val self; ffi_type *ft; ffi_type *elements[1]; val lt; @@ -2659,6 +2660,7 @@ static val make_ffi_type_builtin(val syntax, val lisp_type, val obj = cobj(coerce(mem_t *, tft), ffi_type_s, &ffi_type_builtin_ops); + tft->self = obj; tft->ft = ft; tft->syntax = syntax; tft->lt = lisp_type; @@ -2702,6 +2704,7 @@ static val make_ffi_type_pointer(val syntax, val lisp_type, val obj = cobj(coerce(mem_t *, tft), ffi_type_s, &ffi_type_ptr_ops); + tft->self = obj; tft->ft = &ffi_type_pointer; tft->syntax = syntax; tft->lt = lisp_type; @@ -2757,6 +2760,7 @@ static val make_ffi_type_struct(val syntax, val lisp_type, int bit_offs = 0; const unsigned bits_int = 8 * sizeof(int); + tft->self = obj; tft->ft = ft; tft->syntax = syntax; tft->lt = lisp_type; @@ -2890,6 +2894,7 @@ static val make_ffi_type_array(val syntax, val lisp_type, struct txr_ffi_type *etft = ffi_type_struct(eltype); + tft->self = obj; tft->ft = ft; tft->syntax = syntax; tft->lt = lisp_type; @@ -2945,6 +2950,7 @@ static val make_ffi_type_enum(val syntax, val enums, val self) val enum_env = make_env(nil, nil, nil); val shadow_menv = make_env(nil, nil, nil); + tft->self = obj; tft->ft = &ffi_type_sint; tft->syntax = syntax; tft->lt = sym_s; -- cgit v1.2.3