diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-04-21 06:56:23 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-04-21 06:56:23 -0700 |
commit | 4e647f4d27827d2918e519cb3f52583d2bbb2a59 (patch) | |
tree | 4de914375260f4ccfdecef3ce64ec1de3adef575 /buf.h | |
parent | 0ba765092f20424828a520d6ccda1c313dab08f0 (diff) | |
download | txr-4e647f4d27827d2918e519cb3f52583d2bbb2a59.tar.gz txr-4e647f4d27827d2918e519cb3f52583d2bbb2a59.tar.bz2 txr-4e647f4d27827d2918e519cb3f52583d2bbb2a59.zip |
Continuing implementation of buffers.
* Makefile (OBJS): New objects itypes.o and buf.o.
* buf.c, buf.h: New files.
* itypes.c, itypes.h: New files.
* lib.c (obj_print_impl): Handle BUF via buf_print and
buf_pprint.
(init): Call itypes_init and buf_init.
* parser.h (end_of_buflit): Declared.
* parser.l (BUFLIT): New exclusive state.
(grammar): New rules for recognizing start of buffer
literal and its interior.
(end_of_buflit): New function.
* parser.y (HASH_B_QUOTE): New token.
(buflit, buflit_items, buflit_item): New nonterminals
and corresponding grammar rules.
(i_expr, n_expr): These symbols now generate a buflit;
a buffer literal is a kind of expression.
(yybadtoken): Handle HASH_B_QUOTE case.
Diffstat (limited to 'buf.h')
-rw-r--r-- | buf.h | 97 |
1 files changed, 97 insertions, 0 deletions
@@ -0,0 +1,97 @@ +/* Copyright 2017 + * Kaz Kylheku <kaz@kylheku.com> + * Vancouver, Canada + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +val make_buf(val len, val init_val, val alloc_size); +val make_borrowed_buf(val len, mem_t *data); +val buf_trim(val buf); +val buf_set_length(val obj, val len, val init_val); +val length_buf(val buf); + +#if HAVE_I8 +val buf_put_i8(val buf, val pos, val num); +val buf_put_u8(val buf, val pos, val num); +#endif + +#if HAVE_I16 +val buf_put_i16(val buf, val pos, val num); +val buf_put_u16(val buf, val pos, val num); +#endif + +#if HAVE_I32 +val buf_put_i32(val buf, val pos, val num); +val buf_put_u32(val buf, val pos, val num); +#endif + +#if HAVE_I64 +val buf_put_i64(val buf, val pos, val num); +val buf_put_u64(val buf, val pos, val num); +#endif + +val buf_put_char(val buf, val pos, val num); +val buf_put_uchar(val buf, val pos, val num); +val buf_put_short(val buf, val pos, val num); +val buf_put_ushort(val buf, val pos, val num); +val buf_put_int(val buf, val pos, val num); +val buf_put_uint(val buf, val pos, val num); +val buf_put_long(val buf, val pos, val num); +val buf_put_ulong(val buf, val pos, val num); +val buf_put_double(val buf, val pos, val num); + +#if HAVE_I8 +val buf_get_i8(val buf, val pos); +val buf_get_u8(val buf, val pos); +#endif + +#if HAVE_I16 +val buf_get_i16(val buf, val pos); +val buf_get_u16(val buf, val pos); +#endif + +#if HAVE_I32 +val buf_get_i32(val buf, val pos); +val buf_get_u32(val buf, val pos); +#endif + +#if HAVE_I64 +val buf_get_i64(val buf, val pos); +val buf_get_u64(val buf, val pos); +#endif + +val buf_get_char(val buf, val pos); +val buf_get_uchar(val buf, val pos); +val buf_get_short(val buf, val pos); +val buf_get_ushort(val buf, val pos); +val buf_get_int(val buf, val pos); +val buf_get_uint(val buf, val pos); +val buf_get_long(val buf, val pos); +val buf_get_ulong(val buf, val pos); +val buf_get_double(val buf, val pos); + +val buf_print(val buf, val stream); +val buf_pprint(val buf, val stream); + +void buf_init(void); |