diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-04-16 22:26:12 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-04-16 22:26:12 -0700 |
commit | 307ddfe0bbb4ad7997cccbda5abb750b599b10be (patch) | |
tree | 824d8242bdac63f8234a596af1b71e2cb0bed9db /lib.h | |
parent | 8b50725da4d58aa77ba61c4270c5407438b2209d (diff) | |
download | txr-307ddfe0bbb4ad7997cccbda5abb750b599b10be.tar.gz txr-307ddfe0bbb4ad7997cccbda5abb750b599b10be.tar.bz2 txr-307ddfe0bbb4ad7997cccbda5abb750b599b10be.zip |
New buffer data type.
Work in progress.
* gc.c (finalize): Add cast to switch expression so gcc
flags when we are missing one of the enumerations.
Handle new BUF enum to free dynamic buffers.
(mark_obj): Mark len and size fields of buf, in case
they aren't just nil or integers.
* hash.c (hash_buf): New static function.
(equal_hash): Route BUF type to hash_buf.
* lib.c (buf_s): New symbol variable.
(code2type): Handle BUF.
(equal): Handle BUF using memcmp on the data.
(obj_init): Intern buf symbol and initialize buf_s.
* lib.h (type_t): New enum member BUF.
(struct buf): New type.
(union obj): New member b, of struct buf type.
(buf_s): Declared.
Diffstat (limited to 'lib.h')
-rw-r--r-- | lib.h | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -59,7 +59,7 @@ typedef int_ptr_t cnum; typedef enum type { NIL = TAG_PTR, NUM = TAG_NUM, CHR = TAG_CHR, LIT = TAG_LIT, CONS, STR, SYM, PKG, FUN, VEC, LCONS, LSTR, COBJ, ENV, - BGNUM, FLNUM, RNG, MAXTYPE = RNG + BGNUM, FLNUM, RNG, BUF, MAXTYPE = BUF /* If extending, check TYPE_SHIFT */ } type_t; @@ -279,6 +279,13 @@ struct range { val from, to; }; +struct buf { + obj_common; + mem_t *data; + val len; + val size; +}; + union obj { struct any t; struct cons c; @@ -295,6 +302,7 @@ union obj { struct bignum bn; struct flonum fl; struct range rn; + struct buf b; }; #if CONFIG_GEN_GC @@ -426,7 +434,7 @@ extern val null_s, t, cons_s, str_s, chr_s, fixnum_sl; extern val sym_s, pkg_s, fun_s, vec_s; extern val stream_s, hash_s, hash_iter_s, lcons_s, lstr_s, cobj_s, cptr_s; extern val atom_s, integer_s, number_s, sequence_s, string_s; -extern val env_s, bignum_s, float_s, range_s, rcons_s; +extern val env_s, bignum_s, float_s, range_s, rcons_s, buf_s; extern val var_s, expr_s, regex_s, chset_s, set_s, cset_s, wild_s, oneplus_s; extern val nongreedy_s; extern val quote_s, qquote_s, unquote_s, splice_s; |