summaryrefslogtreecommitdiffstats
path: root/struct.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-07-19 17:22:22 -0700
committerKaz Kylheku <kaz@kylheku.com>2024-07-19 17:22:22 -0700
commit1676d6a255354329bde19f9ab141ce672112a358 (patch)
tree19707f312ed035cbd46440469977ad6a15d9a093 /struct.h
parent8f026a4fc707243151faffb89586460354d41cd2 (diff)
downloadtxr-1676d6a255354329bde19f9ab141ce672112a358.tar.gz
txr-1676d6a255354329bde19f9ab141ce672112a358.tar.bz2
txr-1676d6a255354329bde19f9ab141ce672112a358.zip
oop: special methods to handle missing slots.
* struct.h (slotset_s, static_slot_s, static_slot_set_s): New symbol variables declared. (enum special_slot): New enum symbols: slot_m, slotset_m, static_slot_m, static_slot_set_m. * struct.c (slotset_s, static_slot_s, static_slot_set_s): New symbol variables. (special_sym): Associate new symbols with new enums. (struct_init): Intern slotset, static-slot and static-slot-set symbols, initializing the variables. Change the registrations of the same-named functions to use the variables. (slot, maybe_slot, slotset, static_slot, static_slot_set): In the no-such-slot case, check for the special method and call it. * tests/012/oop.tl: New tests. * txr.1: Documented.
Diffstat (limited to 'struct.h')
-rw-r--r--struct.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/struct.h b/struct.h
index 0b284ac0..e3d75221 100644
--- a/struct.h
+++ b/struct.h
@@ -28,7 +28,7 @@
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 slot_s, slotset_s, static_slot_s, static_slot_set_s, derived_s;
extern val lambda_set_s;
extern val iter_begin_s, iter_more_s, iter_item_s, iter_step_s, iter_reset_s;
@@ -39,7 +39,7 @@ enum special_slot {
equal_m, copy_m, nullify_m, from_list_m, lambda_m, lambda_set_m,
length_m, length_lt_m, car_m, cdr_m, rplaca_m, rplacd_m,
iter_begin_m, iter_more_m, iter_item_m, iter_step_m, iter_reset_m,
- plus_m,
+ plus_m, slot_m, slotset_m, static_slot_m, static_slot_set_m,
num_special_slots
};