summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
* ffi: bool type.Kaz Kylheku2017-06-201-0/+60
| | | | | | | | | | | | * ffi.c (bool_s): New symbol variable. (ffi_bool_put, ffi_bool_get): New static functions. (ffi_type_compile): Handle (bool <type>) parametrized type. (ffi_init_types): Register bool typedef for (bool uchar). (ffi_init): Initialize bool_s. * ffi.h (bool_s): Declared. * txr.1: Documented.
* cptr-int and cptr-obj can make typed cptr objects.Kaz Kylheku2017-06-191-3/+113
| | | | | | | | | | | | | | | | | * eval.c (eval_init): Update registration of cptr-int and cptr-obj with one optional argument. * lib.c (cptr_int): New type symbol argument, defaulting to nil. Also, don't bother defaulting the integer argument; the function isn't registered for that being optional. (cptr_obj): New type symbol argument, defaulting to nil. * lib.h (cptr_int, cptr_obj): Declarations updated. * txr.1: Documented cptr-int and cptr-obj function changes. Added discussion of type tag to introductory paragraph. Also added neglected documentation of the FFI cptr type, both unparametrized and parametrized.
* awk macro: bugfix: :output file stream not closed.Kaz Kylheku2017-06-191-0/+32
| | | | | | | | | | | | | | | | | | In the case when the :output clause of the awk macro opens a stream, it isn't closing it. Why don't we treat such a stream uniformly with redirections. * share/txr/stdlib/awk.tl (sys:awk-state :postinit): If a file is opened for output, then don't just install this file as self.output. Also place it into the self.streams hash, identified by using the key (:outf <name>), just like a (-> "name") redirection. This ensures that it will be closed when the awk macro terminates. It's also potentially useful in that output redirections referring to the name will use the same stream. * txr.1: Documented that streams opened by :output are closed, and that they are treated uniformly with redirections.
* Version 179.txr-179Kaz Kylheku2017-06-181-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* listener: inform linenoise of incomplete syntax.Kaz Kylheku2017-06-161-6/+19
| | | | | | | | | | | | | | Multi-line expressions can now be entered just using Enter for line breaks without Ctrl-V. Multi-line mode becomes default. * parser.c (is_balanced_line): New static function. (repl): Install is_balanced_line as enter callback in linenoise object. (parse_init): Default *listener-multi-line-p* variable to t. * txr.1: Documentation about multi-line mode updated.
* New length method on structures.Kaz Kylheku2017-06-161-2/+48
| | | | | | | | | | | | | | | | With this change, nreverse is possible on a struct, if it has lambda, lambda-set and length methods. * lib.c (length_s): New symbol variable. (length): Check for length method and call it, in preference to checking for car method and falling back on cdr-based length. (empty): If object has a length method, call it and compare result to zero. (obj_init): Initialize length_s. * txr.1: Documented. We now have the concepts of structs being vector-like sequences or list-like sequences.
* Support ref, refset on structs via lambda, lambda-set.Kaz Kylheku2017-06-161-0/+18
| | | | | | | | | | | * lib.c (ref, refset): Check for lambda and lambda-set, respectively, and use it. * txr.1: Documented. * tests/012/aseq.tl (add lambda): Fix previously unused broken method which now causes test to go into infinite recursion.
* ffi: copy-carray, hooked into copy.Kaz Kylheku2017-06-151-0/+25
| | | | | | | | | | | | * ffi.c (copy_carray): New function (ffi_init): Register copy-carray intrinsic. * ffi.h (copy_carray): Declared. * lib.c (copy): Call copy_array for carray objects. * txr.1: Documented copy-carray and updated copy description.
* ffi: new put-carray and fill-carray functions.Kaz Kylheku2017-06-151-0/+39
| | | | | | | | | | * ffi.c (put_carray, fill_carray): New functions. (ffi_init): put-carray and fill-carray intrinsics registered. * ffi.h (put_carray, fill_carray): Declared. * txr.1: Documented.
* ffi: new integer-carray conversion functions.Kaz Kylheku2017-06-141-0/+97
| | | | | | | | | | | | * ffi.c (carray_unum, carray_num, unum_carray, num_carray): New functions. (ffi_init): New intrinsics registered: carray-unum, carray-num, unum-carray, num-carray. * ffi.h (carray_unum, carray_num, unum_carray, num_carray): Declared. * txr.1: Documented.
* ffi: turn carray-sub into accessor.Kaz Kylheku2017-06-131-1/+8
| | | | | | | | | | | | | | | | * lisplib.c (ffi_set_entries): Register carray-sub for autoload. * share/txr/stdlib/ffi.tl (carray-sub): New place macro, aliases to sub. This is not 100% correct since that means it will admit non-carray objects, but the alternative is to clone the entire sub expander with a few changes, or else factor out sub expansion into a shared routine. Bleh ... * txr.1: Documented. We don't cover up the ruse we perpetrated, and reveal that it's just a place macro targetting sub.
* Version 178.txr-178Kaz Kylheku2017-06-121-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* buf: new bufp function.Kaz Kylheku2017-06-121-0/+16
| | | | | | | | | * buf.c (bufp): New function. (buf_init): Registered bufp intrisic. * buf.h (bufp): Declared. * txr.1: Documented.
* awk macro: new fconv conversions c and cz.Kaz Kylheku2017-06-121-3/+18
| | | | | | | | | | * share/txr/stdlib/conv.tl (sys:conv-let): New local functions c and cz, using the new #\c radix conversion. * txr.1: Documented new extension under the fconv awk macro. Also fixed a typo here; the b conversion was exemplified as (c str).
* int-str: allow radix to be #\c for C conventions.Kaz Kylheku2017-06-121-4/+28
| | | | | | | | | * lib.c (int_str): Support #\c base, recognizing 0x as hex and leading 0 as octal. We don't rely on the wcstol function's ability to do this conversion, but scan it ourselves. * txr.1: Documented.
* doc: document bracket notation for carray and buf.Kaz Kylheku2017-06-121-1/+25
| | | | | * txr.1: Put carray and buf cases into the description of the indexing notation under the dwim operator.
* ffi: add carrayp function.Kaz Kylheku2017-06-121-0/+16
| | | | | | | | | * ffi.c (carrayp): New function. (ffi_init): Register carrayp intrinsic. * ffi.h (carrayp): Declared. * txr.1: Documented.
* ffi: new carray-replace function.Kaz Kylheku2017-06-111-0/+77
| | | | | | | | | | | | | | Thanks to this (set [ca from..to] list) works. * ffi.c (carray_replace): New function. (ffi_init): Register carray-replace intrinsic. * ffi.h (carray_replace): Declared. * ffi.c (replace): Hook in carray_replace. * txr.1: Mention carray under replace, and document carray-replace.
* ffi: new function, carray-pun.Kaz Kylheku2017-06-111-0/+38
| | | | | | | | | * ffi.c (carray_pun): New function. (ffi_init): Registered carray-pun intrinsic. * ffi.h (carray_pun): Declared. * txr.1: Documented.
* ffi: handle sub operation in carray.Kaz Kylheku2017-06-111-1/+90
| | | | | | | | | | | | | | | | Thus, [ca 3..5] syntax works for slice extraction. However, this works referentially, not by making a copy. The extracted subarray points to the original memory, until carray-dup is invoked on it. * ffi.c (carray_sub): New function. (ffi_init): carray-sub intrinsic registered. * ffi.h (carray_sub): Declared. * lib.c (sub): Handle carray via carray_sub. * txr.1: Documented changes in sub.
* ffi: support sel operation on carray.Kaz Kylheku2017-06-111-7/+18
| | | | | | | | | | | | | | | | | | | | Thus (select ca '(0 3 4 ...)) works and so does the sytnax [ca '(0 3 4 ...)]. This is inefficiently implemented. The selected elements are extracted to a list which is then converted to a carray of the same kind agan. * ffi.c (carray_list): New function. (ffi_init): Register carray-list intrinsic. * ffi.h (carray_list): Declared. * lib.c (make_like): Add carray case, so we can turn a list into a carray based on an example carray. This uses carray_list, with the type pulled from the original carray. The target isn't null terminated. (sel): Handle carray via vector case. * txr.1: Document changes in select and make-like.
* length function supports carray.Kaz Kylheku2017-06-111-0/+6
| | | | | | * lib.c (length): Handle COBJ of carray type. * txr.1: Documented.
* doc: document length for buf.Kaz Kylheku2017-06-111-10/+13
| | | | | * txr.1: Restructure the length documentation to use definition-style paragraphs, and add buf.
* ffi: new carray-get and carray-put functions.Kaz Kylheku2017-06-101-0/+62
| | | | | | | | | | | | | | | | | * ffi.c (struct carray): New member, artype. (carray_mark_op): Mark artype member. (make_carray): Initialize artype to nil. (carray_ensure_artype, carray_get_common, carray_put_common): New static functions. (carray_get, carray_getz, carray_put, carray_putz): New functions. (ffi_init): Register intrinsics carray-get, carray-getz, carray-put, carray-putz. * ffi.h (carray_get, carray_getz, carray_put, carray_putz): Declared. * txr.1: Documented new functions.
* doc: carray corrections.Kaz Kylheku2017-06-091-7/+12
| | | | | * txr.1: forgotten documentation added: the carray-own function can't be used on a carray which references a buf.
* awk macro: fix broken rng.Kaz Kylheku2017-06-071-0/+7
| | | | | | | | | | | | | | | Bug: rng fails to activate when the to and from condition are true for the same record. * share/txr/stdlib/awk.tl (sys:awk-mac-let): Rename the flag-new gensym holder to flag-act, since it indicates whether the range is active, either from before or due to being activated by the current record. A new gensym is added to indicate whether the range is being deactivated in this record. The inclusive rng range refers to this variable rather than flag-old. But a bug emulation is provided to refer to the wrong variable. * txr.1: Added compatibility note.
* Version 177.txr-177Kaz Kylheku2017-06-071-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* ffi: conform to GCC's bitfield layout algorithm.Kaz Kylheku2017-06-071-44/+112
| | | | | | | | | | | The way bitfields are laid out must be changed. The requirements were reverse-engineered by experimentation. * ffi.c (make_ffi_type_struct): Member allocation loop substantially rewritten. * txr.1: Documentation rewritten. Description of the bitfield allocation algorithm moved to a separate paragraph.
* ffi: support bitfields on types narrower than int.Kaz Kylheku2017-06-061-6/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * ffi.c (bit_s): New symbol variable. (ffi_generic_sbit_put, ffi_generic_sbit_get, ffi_generic_ubit_put, ffi_generic_ubit_get): New static functions. (bitfield_syntax_p): Include bit symbol in the check. (make_ffi_type_pointer): Zero size is no longer an early rejection test for bitfields; don't rely on it. (make_ffi_type_struct): Revise the member calculating loop to handle bitfields of various sizes. If a bitfield follows one of a different size, it starts a new cell even if the previous one has room, et cetera. The masking and shifting is set up to work on cells of int size; however, the new ffi_generic_s?bit_{put,get} functions use a temporary buffer and transfer just the right number of bytes to and from the actual buffer. (ffi_struct_compile): The check against incomplete type members only needs to test size zero; bitfields have nonzero size now, which is the true size of the underlying storage unit. They also have true alignment, which is used in make_ffi_type_struct rather than hard-coding to alignof (int). New syntax (bit width type) is now handled, where type can be any of the signed and unsigned integral types up to int32 and int. The endian types are not supported for now. (ffi_typedef, ffi_size, ffi_alignof): Zero size is no longer an early rejection test for bitfields; don't rely on it. (ffi_init): Initialize bit_s. * ffi.h (bit_s): Declared. * txr.1: Documented.
* buffers: improve put-buf and fill-buf.Kaz Kylheku2017-06-051-21/+39
| | | | | | | | | | | | | | | | | | | | * stream.h (struct strm_ops): put_buf and fill_buf function pointers get third argument to indicate starting position of read and write. (put_buf, fill_buf): Declarations updated. * stream.c (unimpl_put_buf, unimpl_fill_buf): Third argument added. (generic_put_buf, generic_fill_buf, stdio_put_buf, stdio_fill_buf): Implement position argument. (delegate_put_buf, delegate_fill_buf): Take third argument, pass it down. (put_buf, fill_buf): New position argument in second position. Defaulted to zero. Passed down. (stream_init): Updated registration of put-buf and fill-buf. * txr.1: Updated documentation.
* buffers: doc: put-buf, fill-buf.Kaz Kylheku2017-06-051-0/+78
| | | | * txr.1: Documented put-buf and fill-buf.
* ffi: doc: endian typesKaz Kylheku2017-06-051-0/+69
| | | | * txr.1: Documented the endian types.
* ffi: doc: align operator.Kaz Kylheku2017-06-051-0/+45
| | | | * txr.1: Documented align type operator.
* ffi: use expressions for bit field width also.Kaz Kylheku2017-06-031-4/+5
| | | | | | | * ffi.c (ffi_type_compile): Evaluate width argument of sbit and ubit type as as expression. * txr.1: Documented.
* ffi: evaluate expressions in type notation.Kaz Kylheku2017-06-021-10/+29
| | | | | | | | | | | | | | | | | | | | | | | | | Places where an integer constant was previously allowed now allow an expression. The way enum syntax works is now different. A temporary lexical environment is created, and each enumeration is bound in that environment. The value expressions are evaluated in that environment. The decision to allow keyword symbols to be enumeration contants is retracted. * eval.h (special_s): Declared. * ffi.c (ffi_eval_expr): New static function. (make_ffi_type_enum): Enums are introduced into a temporary environment, in which the value expressions are evaluated. By this means, the expressions can refer can refer to previous enums and do arbitrary computation. Also, we drop the requirement that enums can be keyword symbols. (ffi_type_compile): Array dimension and buf size are evaluated as expresions. Array and buffer syntax is transformed by substitution of the evaluated size. * txr.1: Documented use of expressions in FFI type notation.
* ffi: functions and macros for basic type properties.Kaz Kylheku2017-06-021-10/+252
| | | | | | | | | | | | | | | | | | * ffi.c (ffi_alignof, ffi_offsetof, ffi_arraysize, ffi_elemsize, ffi_elemtype): New functions. (ffi_init): Registered intrinsics ffi-alignof, ffi-offsetof, ffi-arraysize, ffi-elemsize, ffi-elemtype. * ffi.h (ffi_alignof, ffi_offsetof, ffi_arraysize, ffi_elemsize, ffi_elemtype): Declared. * lisplib.c (ffi_set_entries): New autoload entries alignof, offsetof, arraysize, elemsize, elemtype. * share/txr/stdlib/ffi.tl (alignof, offsetof, arraysize, elemsize, elemtype): New macros. * txr.1: Documented new functions and macros.
* mkstring char argument is optional.Kaz Kylheku2017-06-011-1/+5
| | | | | | | | | * eval.c (eval_init): Update registration of mkstring intrinsic to make second argument optional. * lib.c (mkstring): Default second argument to space. * txr.1: Documentation of mkstring updated.
* ffi: new feature: enums.Kaz Kylheku2017-05-311-0/+60
| | | | | | | | | | | | | | | | * ffi.c (enum_s): New symbol variable. (struct txr_ffi_type): New member, sym_num, num_sym. (ffi_enum_type_mark): New static function. (ffi_type_enum_ops): New static structure. (ffi_enum_put, ffi_enum_get, ffi_enum_rput, ffi_enum_rget): New static functions. (make_ffi_type_enum): New static function. (ffi_type_compile): Extend with enum syntax. (ffi_init): Initialize enum_s with new interned symbol. * ffi.c (enum_s): Declared. * txr.1: Documented.
* Refactoring hash bang support; hash bang null hack.Kaz Kylheku2017-05-301-4/+182
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The hash bang mechanism is handled in one place, and disentangled from all parsing logic. It is also endowed with special powers. * eval.c (load): Pass one less argument to read_eval_stream. * match.c (v_load): Likewise. * parser.c (read_eval_stream): hash_bang_support Boolean argument removed. Hash bang logic removed. (load_rcfile): Pass only two arguments to read_eval_stream. * parser.h (read_eval_stream): Declaration updated. * txr.c (remove_hash_bang_line): Function removed. (check_hash_bang): New static function. (txr_main): Recognize the script file name while still inside the argument processing loop. Open the file, and check for a hash bang line, doing the special processing which can generate more arguments from material after a null byte in the hash bang line. The parse_stream variable is now initialized to nil and doubles as a Boolean indicating whether a stream has been opened. After the loop, we remove the script file from the arguments, if we have an open stream and the spec_file_str matches. read_eval_stream is called only with two arguments. * txr.1: Revised existing documentation and described new features.
* command line: --eargs semantics change.Kaz Kylheku2017-05-301-10/+26
| | | | | | | | | | | | | | | | | The --eargs mechanism won't perform a blind substring replacement of {} with the following argument. Only arguments which match {} exactly are replaced. * eval.c (retf): Static function becomes extern. * eval.h (retf): Declared. * txr.c (txr_main): Replace the filtering logic on the split eargs argument list to just look for items equal to the string "{}" and replace with the following argument. * txr.1: Updated --eargs documentation.
* New variable: *args-eff*.Kaz Kylheku2017-05-301-7/+33
| | | | | | | | | | | | * txr.c (txr_main): As arguments are processed, collect them into a list called the effective arg list, which is eventually visible as the *args-eff* variable. This is the argument list which reflects the expansions that have been applied by --args or --eargs. Those two options take special care to remove themselves from that list. * txr.1: Documented *args-eff*.
* doc: grammar in ffi.Kaz Kylheku2017-05-261-6/+7
| | | | * txr.1: Smattering of grammar fixes in ffi section.
* doc: wrong word under ffi buf description.Kaz Kylheku2017-05-261-1/+1
| | | | * txr.1: buf and buf-d are "types" not "parts".
* ffi: bitfield support.Kaz Kylheku2017-05-251-0/+129
| | | | | | | | | | | | | | | | | | | | | | | * ffi.c (sbit_s, ubit_s): New symbol variables. (struct txr_ffi_type): New members, shift and mask. (ffi_sbit_put, ffi_sbit_get, ffi_ubit_put, ffi_ubit_get, bitfield_syntax_p): New static functions. (make_ffi_type_pointer): Disallow pointers to bitfields. (make_ffi_type_struct): Process bitfield members and set up shifts and masks accordingly. Recently introduced bug fixed here at the same time: the alignment calculation for each member must be done top-of-loop. (ffi_struct_compile): Exclude bitfields from the check against members with zero type. Compile the bitfield syntax. (ffi_typedef): Do not allow typedefs of bitfield type. Not only doesn't this make sense, but bitfield types are destructively modified in make_ffi_type_struct: they are imbued with a mask and offset tied to their position in a particular struct. * ffi.h (sbit_s, ubit_s): Delared. * txr.1: Documented bitfields.
* doc: clean up description of bident and lident.Kaz Kylheku2017-05-241-7/+20
| | | | | | | | * txr.1: Fix false, contradictory text claiming that an underscore may be part of a bident but not sident. (Reported by user "death" on Reddit). Add clarifying text explaining that only the slash character may be in a lident but not bident, and improve some surrounding text.
* ffi: sanity check on object in ffi_val_get.Kaz Kylheku2017-05-241-0/+6
| | | | | | | | | | | | | | | | | * ffi.c (ffi_val_get): Throw an exception if the object doesn't appear valid. * gc.c (valid_object_p): New function. Invalid objects are those that are pointers, but either not into a heap, or else to a freed object or to an object that is marked by the garbage collector (should only be seen while GC is running). All others are valid. There can be false positives here: a value with the LIT tag is in fact a pointer, but we don't check whether that is valid. * gc.c (valid_object_p): Declared. * txr.1: Remarks added to documentation of FFI val type.
* doc: point out relationship between juxt and callf.Kaz Kylheku2017-05-241-0/+22
| | | | | * txr.1: Under callf, give equivalence to juxt. Also refer to callf from juxt.
* doc: C code formatting issue.Kaz Kylheku2017-05-231-2/+6
| | | | | * txr.1: typeset couple of example printf calls properly in discussion of variadic FFI call descriptors.
* ffi: val type.Kaz Kylheku2017-05-231-0/+18
| | | | | | | | | | | * ffi.c (val_s): New symbol variable. (ffi_val_put, ffi_val_get): New functions. (ffi_init_types): Register val type. (ffi_init): Initialize val_s. * ffi.h (val_s): Declared. * txr.1: Documented.
* Version 176.txr-176Kaz Kylheku2017-05-211-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.