summaryrefslogtreecommitdiffstats
path: root/struct.h
Commit message (Collapse)AuthorAgeFilesLines
* Introducing lazy structs.Kaz Kylheku2015-11-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | * share/txr/stdlib/struct.tl (lnew): New macro. * struct.c (struct_type): Turn id into a bitfield one bit smaller than cnum. New Boolean bitfield lazy. (struct_init): Register make-lazy-struct intrinsic. (make_struct): Initialize lazy bitfield to zero. (lazy_struct_init, check_init_lazy_struct): New static functions. (make_lazy_struct): New function. (copy_struct, clear_struct, replace_struct, reset_struct, lookup_slot, struct_inst_equal, struct_inst_hash): Call check_init_lazy_struct on all structures involved. (lookup_slot): Call check_init_lazy_struct. (struct_inst_mark): If the struct is lazy, it has one instance slot which must be marked, holding the argfun function passed into make_lazy_struct. * struct.h (make_lazy_struct): Declared. * txr.1: Documented lnew and make-lazy-struct.
* New uslot function and usl macro.Kaz Kylheku2015-11-201-0/+1
| | | | | | | | | | | | | | * struct.c (struct_init): Register uslot intrinsic function. (uslot_fun): New static function. (uslot): New function. * struct.h (uslot): Declared. * share/txr/stdlib/struct.tl (usl): New macro. * lisplib.c (struct_set_entries): Add usl macro. * txr.1: Documented uslot and usl.
* Adding defmeth macro and static-slot-ensure.Kaz Kylheku2015-10-161-0/+1
| | | | | | | | | | | | | | | | | * share/txr/stdlib/struct.tl (defmeth): New macro. * struct.c (struct struct_type): New member, dvtypes. (struct_init): Register static-slot-ensure intrinsic. (make_struct_type): Initialize dvtypes of newly instantiated struct_type struct. If a super is specified, add new type to the super's dvtypes. (struct_type_mark): Mark st->dvtypes. (static_slot_ensure): New function. * struct.h (static_slot_ensure): Declared. * txr.1: Documented defmeth and static-slot-ensure.
* New function: reset-struct.Kaz Kylheku2015-10-061-0/+1
| | | | | | | | | * struct.c (reset_struct): New function. (struct_init): Register reset_struct intrinsic. * struct.h (reset_struct): Declared. * txr.1: documented reset-struct.
* New function: replace-struct.Kaz Kylheku2015-10-061-0/+1
| | | | | | | | | * struct.c (replace_struct): New function. (struct_init): Register replace_struct intrinsic. * struct.h (replace_struct): Declared. * txr.1: documented replace-struct.
* New function: clear-struct.Kaz Kylheku2015-10-061-0/+1
| | | | | | | | | * struct.c (clear_struct): New function. (struct_init): Register clear-struct intrinsic. * struct.h (struct_init): Declared. * txr.1: documented clear-struct.
* slot-p renamed to slotp, conforming with Lisp conventions.Kaz Kylheku2015-10-031-1/+1
| | | | | | | | | | | | | | * share/txr/stdlib/struct.tl (sys:prune-nil-inits): Use of slot-p renamed. * struct.c (struct_init): Register slotp, and make registration of slot-p conditional on compatibility option. (slot_p): Function renamed to slotp. * struct.h (slot_p): Declaration renamed. * txr.1: References to slot-p fixed to slotp. Compat notes added.
* New umeth and umethod macro and function.Kaz Kylheku2015-10-031-0/+1
| | | | | | | | | | * share/txr/stdlib/struct.tl (umeth): New macro. * struct.c (struct_init): Registered umethod intrinsic. (umethod_fun): New static function. (umethod): New function. * txr.1: Documented.
* New super-method function.Kaz Kylheku2015-10-011-1/+2
| | | | | | | | | * struct.c (struct_init): Register super-method. (super_method): New function. * struct.h (super_method): Declared. * txr.1: Documented.
* Implementation of static slots for structures.Kaz Kylheku2015-09-291-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * share/txr/stdlib/struct.tl (sys:bad-slot-syntax): New helper function. (defstruct): Macro revamped with new slot specifier syntax for writing static slots as well as methods. * struct.c (STATIC_SLOT_BASE): New preprocessor symbol. (struct struct_type): New members, nstslots, stinitfun, stslot. (make_struct_type_compat): New static function. (struct_init): Register make-struct-type to make_struct_type_compat if compatibility is 117 or lower. Register new intrinsics static-slot, static-slot-set, call-super-method, call-super-fun, slot-p and static-slot-p. (call_stinitfun_chain): New static function. (make_struct_type): Two new arguments for specifying static slots and an initialization function for them. Logic added for setting up static slots and handling inheritance. (struct_type_destroy): New static function. (struct_type_mark): Mark the new stinitfun member of struct type. Also iterate over the static slots in the new stslot array and mark them. (lookup_slot): Altered to return a loc instead of a raw pointer, and also to accept the instance object as a member. Now resolves static slots: it can return a loc which references a static slot in the structure type, or an instance slot in the structure. (lookup_static_slot): New static function. (slot, slotset): Implementation adjusted due to new lookup_slot interface. (static_slot, static_slot_set, slot_p, static_slot_p): New functions. (call_super_method, call_super_fun): New static functions. (struct_inst_print): This function can no longer assume that the slots list lines up with the array of slots, since it contains a mixture of static and instance slots. Earnest slot lookup has to be performed. (struct_type_ops): Point the destroy function to struct_type_destroy instead of cobj_destroy_free_op. A structure type now has an array of static slots to free. * struct.h (make_struct_type): Declaration updated. (static_slot, static_slot_set, slot_p, static_slot_p): Declared. * lib.c (time_init): Update call to make_struct_type with new arguments. * sysif.c (sysif_init): Likewise. * tests/012/struct.tl: Update defstruct macro expansion test. * txr.1: Documented static slots and new functions.
* Introducing structs.Kaz Kylheku2015-09-021-0/+39
* args.c (args_cat_zap): New function. * args.h: (args_cat_zap): Declared. * eval.c (struct_lit_s): New symbol variable. (eval_init): Initialize struct_lit_s. * eval.h (struct_lit_s): Declared. * gc.c (finalize): If a symbol has a struct slot hash attached to it, we must free it when the symbol is reclaimed. * lib.c (make_sym): Initialize symbol's slot_cache pointer to null. (copy): Copy structure objects. (init): Call struct_init to initialize struct module. * lib.h (SLOT_CACHE_SIZE): New preprocessor symbol (slot_cache_line_t, slot_cache_t): New typedefs. (struct sym): New member, slot_cache. * lisplib.c (struct_set_entries, struct_instantiate): New static functions. (liplib_init): Register new functions in dl_table. parser.y (HASH_S): New terminal symbol. (struct): New grammar rule. (n_expr): Derive struct. (yybadtoken): Map HASH_S to #S string. parser.l (grammar): Recognize #S and return HASH_S token. share/txr/stdlib/place.tl (slot): New defplace. share/txr/stdlib/struct.tl: New file. struct.c: New file. struct.h: New file. * Makefile (OBJS): Adding struct.o.