summaryrefslogtreecommitdiffstats
path: root/buf.c
Commit message (Collapse)AuthorAgeFilesLines
* ffi and buf porting: stdarg.h needed.Kaz Kylheku2017-05-111-0/+1
| | | | * buf.c, ffi.c: Must include <stdarg.h> for va_list.
* buffers: correct length check in buf-put- functions.Kaz Kylheku2017-05-081-2/+3
| | | | | | | * buf.c (buf_put_bytes): We must extend the buffer based on looking at the end position of the data transfer, not the start position, so the buffer is large enough to old the entire transfer.
* buffers: don't let a buffer shrink to zero.Kaz Kylheku2017-05-081-4/+6
| | | | | | | * buf.c (buf_shrink): If a buffer has zero length, don't shrink the allocation size all the way down to zero, because that value indicates a non-resizeable buffer.
* ffi: rethink passing and alloc scheme for bufs.Kaz Kylheku2017-05-071-6/+0
| | | | | | | | | | | | | | | | | Backing out of the scheme of (ptr buf) passing the address of the internal pointer within buf objects. Also giving buf in handlers, to prevent the fallback on get. * buf.c (buf_addr_of): Function removed. * buf.h (buf_addr_of): Declaration removed. * ffi.c (ffi_buf_in, ffi_buf_d_in): New functions. (ffi_buf_alloc): Function removed. (ffi_type_compile, ffi_init_types): Remove specialty alloc and free functions from buffers, so the regular fixed allocator is used. Give buffers the new in functions.
* buf: fix memory leak.Kaz Kylheku2017-04-301-1/+1
| | | | | | * buf.c (make_duplicate_buf): A duplicated buf is dynamic, so the size must not be nil, which indicates a static or borrowed one. Set the size properly, so finalize will free it.
* ffi: correct treatment of (ptr buf).Kaz Kylheku2017-04-291-0/+6
| | | | | | | | | | | | | | The buf FFI type's alloc virtual should return a pointer to the buffer's pointer, not the buffer itself. What's currently going on is something silly, whereby the pointer to the buffer is stored into the buffer itself. * buf.c (buf_addr_of): New function. * buf.c (buf_addr_of): Declared. * ffi.c (ffi_buf_alloc): Use buf_addr_of instead of buf_get.
* ffi: support buf objects.Kaz Kylheku2017-04-261-0/+24
| | | | | | | | | | | | | | | | * buf.c (make_duplicate_buf, buf_get, buf_fill): New functions. * buf.h (make_duplicate_buf, buf_get, buf_fill): Declared. * ffi.c (struct txr_ffi_type): New member, nelem. Keeps track of number of elements, for types that are FFI pointers. This lets us support the get method so that a buf can be a C function return value, if its size is declared in our FFI type system. (ffi_buf_put, ffi_buf_get, ffi_buf_fill): New functions. (ffi_type_compile): Handle two new cases of syntax for buffers: (buf <size>) and buf.
* Buffers: missing float and cptr.Kaz Kylheku2017-04-241-0/+42
| | | | | | | | | | | | | * buf.c (buf_put_float, buf_put_cptr, buf_get_float, buf_get_cptr, align_float, align_cptr, size_float, size_cptr): New functions. (buf_init): Registered intrinsics buf-put-float, buf-put-cptr, buf-get-float, buf-get-cptr, align-float, align-cptr, size-float, size_cptr. * buf.h (buf_put_float, buf_put_cptr, buf_get_float, buf_get_cptr, align_float, align_cptr, size_float, size_cptr): Declared.
* Buffers implementation, part three: get functions.Kaz Kylheku2017-04-211-17/+117
| | | | | | | | | | | | | * arith.c (unum): New function. * arith.h (unum): Declared. * buf.c (buf_get_bytes): New static function. (buf_get_i8, buf_get_u8, buf_get_i16, buf_get_u16, buf_get_i32, buf_get_u32, buf_get_i64, buf_get_u64, buf_get_char, buf_get_uchar, buf_get_short, buf_get_ushort, buf_get_int, buf_get_uint, buf_get_long, buf_get_ulong, buf_get_double): Stubs implemented.
* Continuing implementation of buffers.Kaz Kylheku2017-04-211-0/+544
* 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.