From aebdc3d7c22820d7604f2c424cbc179d7ebb34d1 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 6 Sep 2019 06:58:48 -0700 Subject: lib: access special methods via special slot mechanism. * ffi.c (ffi_flex_struct_in): Use get_special_slot to obtain length method. * lib.c (nullify_s, from_list_s, lambda_set_s): Definitions removed from here. (seq_info, car, cdr, rplaca, rplacd, make_like, nullify, replace_obj, length, empty, sub, ref, refset, dwim_set): Use get_special_slot to obtain special method from object, rather than maybe_slot. (obj_init): Remove initializations of nullify_s, from_list_s and lambda_set_s from here. * struct.c (enum special_slot): Definition removed from here. (nullify_s, from_list_s, lambda_set_s): Definitions moved here from lib.c. (special_sym): New static array. (struct_init): Initializations of nullify_s, from_list_s and lambda_set_s moved here from lib.c. (get_special_slot): New function. * struct.h (lambda_set_s): Declared. (enum special_slot): Definition moved here. (get_special_slot): Declared. * txr.1: Added compat note, since get_special_slot behaves like maybe_slot under 224 compatibility. --- struct.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'struct.h') diff --git a/struct.h b/struct.h index d67ce3d7..385d8dd4 100644 --- a/struct.h +++ b/struct.h @@ -28,7 +28,16 @@ extern val struct_type_s, meth_s, print_s, make_struct_lit_s; extern val init_k, postinit_k; extern val slot_s, derived_s; +extern val lambda_set_s; + extern struct cobj_ops struct_inst_ops; + +enum special_slot { + equal_m, nullify_m, from_list_m, lambda_m, lambda_set_m, + length_m, car_m, cdr_m, rplaca_m, rplacd_m, + num_special_slots +}; + val make_struct_type(val name, val super, val static_slots, val slots, val static_initfun, val initfun, val boactor, @@ -77,5 +86,6 @@ val slot_types(val slot); val static_slot_types(val slot); val slot_type_reg(val slot, val strct); val static_slot_type_reg(val slot, val strct); +val get_special_slot(val obj, enum special_slot spidx); INLINE int obj_struct_p(val obj) { return obj->co.ops == &struct_inst_ops; } void struct_init(void); -- cgit v1.2.3