summaryrefslogtreecommitdiffstats
path: root/buf.h
Commit message (Collapse)AuthorAgeFilesLines
* ffi: rethink passing and alloc scheme for bufs.Kaz Kylheku2017-05-071-1/+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.
* ffi: correct treatment of (ptr buf).Kaz Kylheku2017-04-291-0/+1
| | | | | | | | | | | | | | 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/+3
| | | | | | | | | | | | | | | | * 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/+4
| | | | | | | | | | | | | * 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.
* Continuing implementation of buffers.Kaz Kylheku2017-04-211-0/+97
* 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.