diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-05-02 20:29:59 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-05-02 20:29:59 -0700 |
commit | bcf26b725e2b1efdf9575639fdbce6219e2343c4 (patch) | |
tree | 1fadf2786b10d6b9d9c063334682f056a655b49d /ffi.c | |
parent | 138852dc2210b46ef3e4607d21cd4ebdbb596751 (diff) | |
download | txr-bcf26b725e2b1efdf9575639fdbce6219e2343c4.tar.gz txr-bcf26b725e2b1efdf9575639fdbce6219e2343c4.tar.bz2 txr-bcf26b725e2b1efdf9575639fdbce6219e2343c4.zip |
ffi: remove rtidx, rtsize, walk.
Remove features related to the supporting the removed
rtvec mechanism.
* ffi.c (struct txr_ffi_type): Member rtidx, rtsize and walk
removed.
(ffi_ptr_walk, ffi_struct_walk, ffi_type_walk,
assign_rtindices_visit, ffi_type_assign_rtindices,
ffi_compile_toplevel): Functions removed.
(make_ffi_type_pointer, make_ffi_type_struct,
make_ffi_type_array): Don't initialize rtsize and walk.
(ffi_type_compile): Don't initialize a type's rtsize.
(ffi_init): ffi-type-compile registereed to ffi_type_compile
rather than ffi_type_compile_toplevel, as was originally
the case.
Diffstat (limited to 'ffi.c')
-rw-r--r-- | ffi.c | 65 |
1 files changed, 1 insertions, 64 deletions
@@ -89,12 +89,9 @@ struct txr_ffi_type { val mtypes; cnum size, align; cnum nelem; - int rtidx, rtsize; unsigned null_term : 1; unsigned char_conv : 1; unsigned wchar_conv : 1; - void (*walk)(struct txr_ffi_type *, mem_t *ctx, - void (*visit)(struct txr_ffi_type *, mem_t *ctx)); void (*put)(struct txr_ffi_type *, val obj, mem_t *dst, val self); val (*get)(struct txr_ffi_type *, mem_t *src, val self); void (*in)(struct txr_ffi_type *, mem_t *src, val obj, val self); @@ -687,16 +684,6 @@ static void ffi_closure_put(struct txr_ffi_type *tft, val ptr, mem_t *dst, memcpy(dst, &p, sizeof p); } -static void ffi_ptr_walk(struct txr_ffi_type *tft, mem_t *ctx, - void (*visit)(struct txr_ffi_type *, mem_t *ctx)) -{ - val tgttype = tft->mtypes; - struct txr_ffi_type *tgtft = ffi_type_struct(tgttype); - if (tgtft->walk) - tgtft->walk(tgtft, ctx, visit); - visit(tgtft, ctx); -} - static void ffi_ptr_in_in(struct txr_ffi_type *tft, mem_t *src, val obj, val self) { @@ -815,20 +802,6 @@ static void ffi_ptr_put(struct txr_ffi_type *tft, val s, mem_t *dst, val self) } } -static void ffi_struct_walk(struct txr_ffi_type *tft, mem_t *ctx, - void (*visit)(struct txr_ffi_type *, mem_t *ctx)) -{ - val types = tft->mtypes; - - while (types) { - val type = pop(&types); - struct txr_ffi_type *mtft = ffi_type_struct(type); - if (mtft->walk != 0) - mtft->walk(mtft, ctx, visit); - visit(mtft, ctx); - } -} - static void ffi_struct_in(struct txr_ffi_type *tft, mem_t *src, val strct, val self) { @@ -1146,8 +1119,6 @@ static val make_ffi_type_pointer(val syntax, val lisp_type, tft->lt = lisp_type; tft->mnames = tft->mtypes = nil; tft->size = tft->align = size; - tft->rtsize = (in != 0); - tft->walk = ffi_ptr_walk; tft->put = put; tft->get = get; tft->mtypes = tgtype; @@ -1183,7 +1154,6 @@ static val make_ffi_type_struct(val syntax, val lisp_type, tft->lt = lisp_type; tft->mnames = slots; tft->mtypes = types; - tft->walk = ffi_struct_walk; tft->put = ffi_struct_put; tft->get = ffi_struct_get; tft->in = ffi_struct_in; @@ -1241,7 +1211,6 @@ static val make_ffi_type_array(val syntax, val lisp_type, tft->lt = lisp_type; tft->mnames = nil; tft->mtypes = eltypes; - tft->walk = ffi_struct_walk; tft->put = ffi_array_put; tft->get = ffi_array_get; tft->in = ffi_array_in; @@ -1270,15 +1239,6 @@ static val make_ffi_type_array(val syntax, val lisp_type, return obj; } -static void ffi_type_walk(val type, mem_t *ctx, - void (*visit)(struct txr_ffi_type *, mem_t *ctx)) -{ - struct txr_ffi_type *tft = ffi_type_struct(type); - if (tft->walk != 0) - tft->walk(tft, ctx, visit); - visit(tft, ctx); -} - static val ffi_struct_compile(val membs, val *ptypes, val self) { list_collect_decl (slots, pstail); @@ -1492,7 +1452,6 @@ val ffi_type_compile(val syntax) ffi_str_put, ffi_str_get); struct txr_ffi_type *tft = ffi_type_struct(type); tft->in = ffi_freeing_in; - tft->rtsize = 1; return type; } else if (syntax == str_d_s) { val type = make_ffi_type_builtin(syntax, str_s, sizeof (mem_t *), @@ -1535,28 +1494,6 @@ val ffi_type_compile(val syntax) } } -static void assign_rtindices_visit(struct txr_ffi_type *tft, mem_t *ctx) -{ - int *counter = coerce(int *, ctx); - if (tft->rtsize != 0) - tft->rtidx = (*counter)++; -} - -static void ffi_type_assign_rtindices(val type) -{ - struct txr_ffi_type *tft = ffi_type_struct(type); - int counter = 0; - ffi_type_walk(type, coerce(mem_t *, &counter), assign_rtindices_visit); - tft->rtsize = counter; -} - -val ffi_type_compile_toplevel(val syntax) -{ - val type = ffi_type_compile(syntax); - ffi_type_assign_rtindices(type); - return type; -} - struct txr_ffi_call_desc { ffi_cif cif; ffi_type **args; @@ -1821,7 +1758,7 @@ void ffi_init(void) ffi_type_s = intern(lit("ffi-type"), user_package); ffi_call_desc_s = intern(lit("ffi-call-desc"), user_package); ffi_closure_s = intern(lit("ffi-closure"), user_package); - reg_fun(intern(lit("ffi-type-compile"), user_package), func_n1(ffi_type_compile_toplevel)); + reg_fun(intern(lit("ffi-type-compile"), user_package), func_n1(ffi_type_compile)); reg_fun(intern(lit("ffi-make-call-desc"), user_package), func_n4(ffi_make_call_desc)); 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)); |