summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
...
* FFI: elemtype as type operator, not just macro.Kaz Kylheku2019-07-261-4/+30
| | | | | | | | * ffi.c (elemtype_s): New symbol variable. (ffi_type_compile): Handle elemtype. (ffi_init): Initialize elemtype_s. * txr.1: Document elemtype.
* FFI: document: elemsize and elemtype work on enums.Kaz Kylheku2019-07-261-8/+14
| | | | | | | | * ffi.c (ffi_elemsize, ffi_elemtype): Fix error messages to include enum among possible argument types. * txr.1: Extend documentation for ffi-elemsize and ffi-elemtype to include base integer type of enumerations.
* FFI: allow member type reference using referencing dot.Kaz Kylheku2019-07-261-0/+43
| | | | | | * ffi.c (ffi_type_compile): New case handling qref_s symbol. * txr.1: Documented.
* Version 221.txr-221Kaz Kylheku2019-07-231-3/+3
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: Latin overhaul.Kaz Kylheku2019-07-221-16/+27
| | | | | | * txr.1: Ensure all instances of vice versa are spellled consistently without a dash and italicized. Italicize every et cetera and one a priori.
* doc: remove "of course".Kaz Kylheku2019-07-221-47/+42
| | | | * txr.1: All instances of the hedge phrase "of course" are removed.
* doc: improvements tied to "very".Kaz Kylheku2019-07-221-31/+34
| | | | | | | * txr.1: A smattering of wording improvements motivated by a search for the fluff adjective "very". Most instances of "very" are deleted, and in some cases the surrounding wording is improved.
* doc: @(merge) improvement.Kaz Kylheku2019-07-221-6/+6
| | | | | * txr.1: Description of @(merge) is improved by eliminating fluff wording.
* doc: eliminate example uses of obsolete txr-path.Kaz Kylheku2019-07-221-3/+4
| | | | | | | | | * txr.1: In the --args example, don't use txr-path, but txr-exe-path. Also, path-cat instead of plain string catenation. The example for save-exe was additionally doing something wrong: taking the dir-name of txr-path, which would calculate the parent of the executable directory. This example is harmonized with the --args one.
* doc: wording under dir-name.Kaz Kylheku2019-07-221-1/+1
| | | | | * txr.1: the term "raw directory path" has not been introduced; it is a typo for "raw directory prefix".
* ffi: support flexible structures.Kaz Kylheku2019-07-201-3/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds support for working with foreign structures which use the C99 "flexible array member", or possibly the old "C struct hack". Some improvements are made in the FFI code the area of incomplete types and bitfields. * ffi.c (struct txr_ffi_type): New flag members incomplete and bitfield. (ffi_varray_dynsize): Check incomplete type flag rather than for zero size. (ffi_flex_dynsize, ffi_flex_alloc, ffi_flex_struct_in): New static functions. (ffi_struct_in): Call ffi_flex_struct_in when doing by-value semantics on a flexible structure, just before converting last member. This checks for the length method, calls it, and adjusts the last member object as documented. (ffi_struct_get): Likewise. (bitfield_syntax_p): Static function removed; there is a flag for this now in the type, so no need to parse its syntax. (make_ffi_type_pointer): Test bitfield flag rather than using bitfield_syntax_p. (make_ffi_type_struct): Take new argument indicating that the struct is flexible. Wire in appropriate virtual functions based on this flag, and set the type's incomplete flag accordingly. Check bitfield flag rather than using bitfield_syntax_p for detecting bitfield members. Calculate the size of flexible struct differently: it is the offset of the last member. (make_ffi_type_union): Test bitfield flag rather than using bitfield_syntax_p. (ffi_struct_compile): Renamed to ffi_membs_compile. (ffi_membs_compile): New pointer parameter for returning an indication whether the member list specifies a flexible struct. Test the incomplete flag of a member type rather than size being zero. (ffi_type_compile): Follow rename of ffi_struct_compile to ffi_membs_compile. Pass down the flag obtained from ffi_membs_compile into make_ffi_type_struct so that a flexible struct type is created when necessary. Disallow arrays of bitfields. Set bitfield flag on bitfield types. (ffi_init_types): Set incomplete flag on void type. (ffi_make_call_desc): Test for incomplete and bitfield types using new flags. (ffi_typedef, ffi_size, ffi_alignof): Test for bitfield type using new bitfield flag. (carray_elem_check): New static function. (carray_buf, carray_pun, carray_unum, carray_num): Use new carray_elem_check to check for bad array element type. This uses the incomplete flag rather than checking for zero size, and also disallows bitfields. * lib.h (length_s): Declared. * txr.1: Flexible structs documented in new section. Also section on incomplete types. Description of sizeof operator gives more detaild about incomplete types including flexible structs.
* doc: document ffi-out.Kaz Kylheku2019-07-181-0/+53
| | | | * txr.1: Add missing documentation for ffi-out.
* doc: ffi-in: wrong direction word.Kaz Kylheku2019-07-181-1/+1
| | | | * txr.1: ffi-in is a decoding not an encoding action.
* doc: ffi-in offset argument description missing.Kaz Kylheku2019-07-181-1/+9
| | | | * txr.1: Document the offset argument of the ffi-in operation.
* relate: optimize with hashes.Kaz Kylheku2019-07-171-0/+5
| | | | | | | | | | | * lib.c (do_relate_hash, do_relate_hash_dfl): New static functions. (relate): If the number of keys and values is the same, and there are more than ten, then use hashing. If the default value is specified, and it is nil, then a hash table can be returned directly, instead of a function. * txr.1: Note added that relate may return a hash.
* New function: hash-zip.Kaz Kylheku2019-07-171-0/+30
| | | | | | | | | * hash.c (hash_zip): New function. (hash_init): hash-zip intrinsic registered. * hash.h (hash_zip): Declared. * txr.1: Documented.
* ffi: two-argument form of sizeof.Kaz Kylheku2019-07-111-5/+28
| | | | | | | | | | | | | | | If sizeof is given an extra argument (an expression which evaluates to an object), it can calculate the dynamic size of the FFI type in relation to representing that object. * ffi.c (dyn_size): New static function. (ffi_init): Register sys:dyn-size intrinsic. * share/txr/stdlib/ffi.tl (sizeof): Support additional argument, avoiding run-time compilation of the type expression with the help of load-time. * txr.1: Update documentation for sizeof macro.
* ffi: handle variable length types in buffer ops.Kaz Kylheku2019-07-111-3/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The motivating bug here is that (ffi-put #(1 2 3 5) (ffi (array int))) perpetrates a buffer overrun. The size of (array int) is zero, and so a zero-length buffer is allocated. But then an array of five ints is stored. This is made to work correctly: allocating a buffer large enough. A new virtual function is introduced into the txr_ffi_type structure to calculate a type's dynamic size, from a prototype Lisp object. * ffi.c (struct txr_ffi_type): New function pointer member, dynsize. (ffi_fixed_dynsize, ffi_varray_dynsize): New static functions. (make_ffi_type_builtin, make_ffi_type_pointer, make_ffi_type_struct, make_ffi_type_union, make_ffi_type_array): Initialize new dynsize member of type structure with pointer to ffi_fixed_dynsize. (ffi_type_compile): Initialize the dynsize pointer of variable array types to ffi_varray_dynsize. (ffi_put_into, ffi_put, ffi_in, ffi_out): Use dynsize to calculate the real size required to store or extract the given object. * txr.1: Update doc for ffi-put, ffi-put-into and ffi-in. Looks like we are missing ffi-out; it is not documented!
* Version 220.txr-220Kaz Kylheku2019-07-081-3/+3
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: op: incorrect example.Kaz Kylheku2019-07-061-5/+14
| | | | | | * txr.1: Switch op example to ap and move under description of ap, which needs an example anyway. Add new examples for op. Reported by user vapnik spaknik.
* replace: deal with overlapping.Kaz Kylheku2019-07-051-0/+12
| | | | | | | | | | | | | * buf.c (replace_buf): In the same-type case, use memmove rather than memcpy in case the objects overlap, so we don't invoke C undefined behavior. * lib.c (replace_str, replace_vec): Likewise. * txr.1: Specify that if the replacement sequence overlaps with the target range of the destination sequence, or with any portion that has to be relocated if range changes size, then the behavior is unspecified.
* replace: third argument is a sequence.Kaz Kylheku2019-07-051-1/+1
| | | | | * txr.1: The index-list argument of replace can be a sequence of any kind, not just a list or vector.
* New function: buf-put-buf.Kaz Kylheku2019-07-051-0/+29
| | | | | | | | | | * buf.c (buf_move_bytes): New static function. (buf_put_buf): New function. (buf_init): Register buf-put-buf intrinsic. * buf.h (buf_put_buf): Declared. * txr.1: Documented.
* sha256: allow application to specify digest buffer.Kaz Kylheku2019-07-041-4/+16
| | | | | | | | | | | | | | | | | | | | | * chksum.c (sha256_stream_impl): New static function, formed out of bulk of sha256_stream. Takes a pointer to a buffer where the digest is stored. (sha256_ensure_buf): New static function. (sha256_stream): Take buf argument; use sha256_ensure_buf to allocate a buffer if necessary, and to obtain the low-level buffer pointer. Implementation moved into sha256_stream_impl. (sha256_buf, sha256_str): Take pointer to digest buffer; don't allocate a buf object, don't return anything. (sha256): Take buf argument; use sha256_ensure_buf to allocate a buffer if necessary, and to obtain the low-level buffer pointer, which is passed to sha256_buf and sha256_str. (chksum_init): Update registrations of intrinsics with new optional parameters. * chksum.h (sha256_stream, sha256): Declarations updated. * txr.1: Updated.
* Expose make-byte-input-stream.Kaz Kylheku2019-07-041-0/+31
| | | | | | | * stream.c (stream_init): Register make-byte-input-stream intrinsic. * txr.1: Documented.
* doc: mistakes in dot position funcalls examples.Kaz Kylheku2019-07-031-2/+2
| | | | | * txr.1: Two examples have a comment claiming an incorrect return value. Reported by user vapnik spaknik.
* Version 219.txr-219Kaz Kylheku2019-07-011-3/+3
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* defset: bind new-val-sym to temporary variable.Kaz Kylheku2019-06-281-10/+0
| | | | | | | | | | | | | | | | | | | | | | Users of defset no longer have to ensure that in the store form, the symbol which gives the new value to be stored is inserted only once. * share/txr/stdlib/defset.tl (defset-expander): Transform the store form by inserting a temporary variable using alet. (sub-list, sub-vec, sub-str): These place forms no longer require a local gensym. * txr.1: Updated doc. * tests/012/defset.tl: The expected output for the inc case now incorporates a gensym that comes from the compiled defset macro. Since we can't control that by means of the gensym counter, we resort to extracting it from the expansion itself, then check the test case against a template which incorporates that gensym. We check that the extracted item really is a gensym: it's a symbol with no home package whose name starts with "g".
* seq-begin: bugfix: non-lists don't work.Kaz Kylheku2019-06-281-0/+8
| | | | | | | | | | | | | * lib.c (seq_begin): Do not null out si->inf.obj; it's needed for accessing hashes and vector-like objects. This bug means that seq-begin iteration has only worked correctly for lists. The original motivation was not to have spurious retention of the head of a lazy list, which is hereby reintroduced. But iterators can be rewound. Let's just document this away and leave it as a to-do item. * txr.1: Document the limitation of seq-begin w.r.t. lazy lists.
* doc: put-buf/fill-buf clarification of pos.Kaz Kylheku2019-06-271-0/+2
| | | | | * txr.1: The pos argument of put-buff and fill-buf is a position within the buffer (not the stream).
* doc: update syntactic places.Kaz Kylheku2019-06-271-3/+10
| | | | | * txr.1: Update the list of syntactic places to list all the new places that have been added, plus a few additional edits.
* in: allow hash with keyfun and testfun.Kaz Kylheku2019-06-251-3/+28
| | | | | | | * lib.c (in): A simple check and fallthrough lets this function process hash tables more generally in this function. * txr.1: Documented.
* doc: clarify nullify.Kaz Kylheku2019-06-251-5/+26
| | | | | | * txr.1: Clarify that nullify also just returns its argument if it is not a sequence at all. Clarify that nullify works on objects via the nullify method only.
* seqp: expand definition of sequences.Kaz Kylheku2019-06-251-1/+16
| | | | | | | * lib.c (seqp): Use seq_info to classify the object as a sequence. * txr.1: Update description of seqp.
* New: CRC-32 functions.Kaz Kylheku2019-06-241-0/+43
| | | | | | | | | | | | * Makefile (OBJS): Add chksums/crc32.o. * chksum.c (crc32_stream, crc32): New functions. (chksum_init): Register crc32-stream and crc32 intrinsic functions. * chksums/crc32.c, chksums/crc32.h: New files. * txr.1: Documented.
* * Makefile (OBJS): New objects chksum.o and chksums/sha256.o.Kaz Kylheku2019-06-231-0/+45
| | | | | | | | | | * chksum.c, chksum.h, chksums/sha256.c, chksums/sha256.h: New files. * lib.c (init): Call chksum_init. * txr.1: Documented. * LICENSE: Add SHA-256 copyright notice.
* doc: move buffers out of dynamic lib section.Kaz Kylheku2019-06-231-1341/+1343
| | | | | | | | * txr.1: Buffers are now documented after strings and vectors. Buffer streams are in the I/O section. Note: the diff between this and the previous commit needs to be generated with git diff --minimal. Otherwise it looks like over 30,000 lines of changes.
* base64: integrate with buffers.Kaz Kylheku2019-06-211-7/+22
| | | | | | | | | | | | | | | * filter.c (base64_encode): Handle an object of either string or buffer type by using make_byte_input_stream. (base64_decode_buf): New function. (filter_init): Register base64-decode-buf intrinsic. * filter.h (base64_decode_buf): Declared. * stream.c (make_byte_input_stream): New function. * stream.h (make_byte_input_stream): Declared. * txr.1: Updated.
* doc: minor grammar problems in Lisp CompilationKaz Kylheku2019-06-211-2/+2
| | | | | * txr.1: Two issues fixed while proof-reading: missing "a" article and a missing plural.
* doc: cure that-is-itis.Kaz Kylheku2019-06-211-3/+3
| | | | | * txr.1: In two places, fix an awkward "; that is, has ..." and "; that is, is ..." grammatical curiosity.
* doc: dump-compiled-objects: wrong number.Kaz Kylheku2019-06-201-1/+1
| | | | * txr.1: "following three expressions" should be "two".
* Version 218.txr-218Kaz Kylheku2019-06-191-3/+3
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* New function: bitset.Kaz Kylheku2019-06-181-0/+58
| | | | | | | | | | | * arith.c (bitset_s): New symbol variable. (bitset): New function. (arith_init): bitset_s initialized, bitset intrinsic registered. * lib.h (bitset): Declared. * txr.1: Documented bitset function and method.
* sub-list, sub-vec, sub-str: becoming accessors.Kaz Kylheku2019-06-171-4/+91
| | | | | | | | | | | * lisplib.c (defset_instantiate): Add sub-list, sub-vec and sub-str symbols as autoload triggers for defset.tl. * share/txr/stdlib/defset.tl (sub-list, sub-vec, sub-str): New syntactic places defined with defset. * txr.1: sub-list, sub-vec and sub-str documented as accessors.
* buffers: sub-buf becomes accessor.Kaz Kylheku2019-06-171-1/+17
| | | | | | | | | | * lisplib.c (ffi_set_entries): Register autoload for sub-buf symbol. * share/txr/stdlib/ffi.tl (sub-buf): Syntactic place defined via defset. * txr.1: Updated sub-buf documentation.
* doc: sub place semantics described wrongly.Kaz Kylheku2019-06-171-4/+36
| | | | | | * txr.1: Documentatation for sub accessor fails to specify that the seq variable is updated with the value returned by replace.
* carray-sub: improved accessor.Kaz Kylheku2019-06-171-3/+12
| | | | | | | | | | | | | * share/txr/stdlib/ffi.tl (carray-sub): We use defset to define a carray-sub place that updates via carray-replace, rather than using a place macro to defer to the generic sub accessor. This results in a more efficient implementation. This new accessor doesn't require the carray argument to be a place; unlike sub, it doesn't have to capture the return value of carray-replace and store it back into the carray variable. * txr.1: Updated doc.
* doc: defset short form is like define-accessorKaz Kylheku2019-06-161-3/+17
| | | | | | * txr.1: Add mentions of the forgotten define-accessor macro in text that lists ways of defiing places. Cross-reference short form of defset and define-accessor.
* doc: nftw typo.Kaz Kylheku2019-06-161-1/+1
| | | | * txr.1: Fix ftw function being mistakenly called nftw.
* doc: reduce amount of "This function" wording.Kaz Kylheku2019-06-161-26/+76
| | | | | | * txr.1: Numerous library functions whose Description paragraph begins with "This function" are now introduced by their name.