diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-05-02 20:32:43 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-05-02 20:32:43 -0700 |
commit | f1d1bd225fc3fe149dfae02533605e0f78b5e882 (patch) | |
tree | 8582fdcb8c46a7152f24a15a19ea918333b0da11 /ffi.c | |
parent | bcf26b725e2b1efdf9575639fdbce6219e2343c4 (diff) | |
download | txr-f1d1bd225fc3fe149dfae02533605e0f78b5e882.tar.gz txr-f1d1bd225fc3fe149dfae02533605e0f78b5e882.tar.bz2 txr-f1d1bd225fc3fe149dfae02533605e0f78b5e882.zip |
ffi: remove ffi-copy-type.
We don't need type copying because the need for this
was driven by the rtvec implementation, which assigned
a unique rtidx to the nodes in a type tree, requiring
like types to be separately instantiated.
* ffi.c (struct txr_ffi_type): Remove member dup.
(ffi_struct_dup, ffi_ptr_dup): Function removed.
(make_ffi_type_builtin, make_ffi_type_struct,
make_ffi_type_array): Don't initialize dup.
(ffi_copy_type): Function removed.
(ffi_type_compile): don't call ffi_copy_type.
(ffi_init): ffi-copy-type intrinsic removed.
* ffi.h (ffi_copy_type): Declaration removed.
Diffstat (limited to 'ffi.c')
-rw-r--r-- | ffi.c | 38 |
1 files changed, 1 insertions, 37 deletions
@@ -98,7 +98,6 @@ struct txr_ffi_type { void (*out)(struct txr_ffi_type *, int copy, val obj, mem_t *dest, val self); mem_t *(*alloc)(struct txr_ffi_type *, val obj, val self); void (*free)(void *); - void (*dup)(struct txr_ffi_type *); }; static struct txr_ffi_type *ffi_type_struct(val obj) @@ -1054,24 +1053,6 @@ static val ffi_array_get(struct txr_ffi_type *tft, mem_t *src, val self) } } -static void ffi_struct_dup(struct txr_ffi_type *tft) -{ - cnum nelem = c_num(length_list(tft->mtypes)); - tft->mtypes = mapcar_listout(func_n1(ffi_copy_type), tft->mtypes); - if (tft->ft) { - ffi_type **elements = coerce(ffi_type **, - chk_copy_obj(coerce(mem_t *, - tft->ft->elements), - sizeof *elements * (nelem + 1))); - tft->ft->elements = elements; - } -} - -static void ffi_ptr_dup(struct txr_ffi_type *tft) -{ - tft->mtypes = ffi_copy_type(tft->mtypes); -} - static val make_ffi_type_builtin(val syntax, val lisp_type, cnum size, ffi_type *ft, void (*put)(struct txr_ffi_type *, @@ -1126,7 +1107,6 @@ static val make_ffi_type_pointer(val syntax, val lisp_type, tft->out = out; tft->alloc = ffi_fixed_alloc; tft->free = free; - tft->dup = ffi_ptr_dup; return obj; } @@ -1159,7 +1139,6 @@ static val make_ffi_type_struct(val syntax, val lisp_type, tft->in = ffi_struct_in; tft->alloc = ffi_fixed_alloc; tft->free = free; - tft->dup = ffi_struct_dup; for (i = 0; i < nmemb; i++) { val type = pop(&types); @@ -1216,7 +1195,6 @@ static val make_ffi_type_array(val syntax, val lisp_type, tft->in = ffi_array_in; tft->alloc = ffi_fixed_alloc; tft->free = free; - tft->dup = ffi_struct_dup; for (i = 0; i < nelem; i++) { val eltype = pop(&eltypes); @@ -1487,7 +1465,7 @@ val ffi_type_compile(val syntax) val sub = gethash(ffi_typedef_hash, syntax); if (sub != nil) - return ffi_copy_type(sub); + return sub; uw_throwf(error_s, lit("~a: unrecognized type specifier: ~!~s"), self, syntax, nao); @@ -1701,19 +1679,6 @@ static val cptr_make(val n) return if3(missingp(n), cptr(0), cptr(coerce(mem_t *, c_num(n)))); } -val ffi_copy_type(val type) -{ - struct txr_ffi_type *tft = ffi_type_struct_checked(type); - struct txr_ffi_type *tft_cp = coerce(struct txr_ffi_type *, - chk_copy_obj(coerce(mem_t *, tft), - sizeof *tft)); - val type_cp = cobj(coerce(mem_t *, tft_cp), ffi_type_s, type->co.ops); - if (tft_cp->dup) - tft_cp->dup(tft_cp); - gc_hint(type); - return type_cp; -} - val ffi_typedef(val name, val type) { return sethash(ffi_typedef_hash, name, type); @@ -1763,7 +1728,6 @@ void ffi_init(void) reg_fun(intern(lit("ffi-call"), user_package), func_n3(ffi_call_wrap)); reg_fun(intern(lit("ffi-make-closure"), user_package), func_n2(ffi_make_closure)); reg_fun(intern(lit("cptr"), user_package), func_n1o(cptr_make, 0)); - reg_fun(intern(lit("ffi-copy-type"), user_package), func_n1(ffi_copy_type)); reg_fun(intern(lit("ffi-typedef"), user_package), func_n2(ffi_typedef)); reg_varl(intern(lit("cptr-null"), user_package), cptr(0)); ffi_typedef_hash = make_hash(nil, nil, nil); |