summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Version 229.txr-229Kaz Kylheku2019-12-147-972/+1014
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* ffi: new type zcharKaz Kylheku2019-12-142-21/+126
| | | | | | | | | | | | | | | | | | | The zchar type, when used as an array element, specifies an optionally null-terminated or padded field, which is subject to UTF-8 conversion. * ffi.c (zchar_s): New symbol variable. (enum char_conv): New member, conv_zchar. (ffi_zchar_array_get): New static function. (ffi_array_in, ffi_array_get_common): Handle conv_zchar via ffi_zchar_array_get. (ffi_array_put): Handle conv_char together with conv_zchar. (ffi_type_compile): Handle zchar array element type, mapping to conv_zchar. (ffi_init_types): Register zhar type. (ffi_init): Initialize zchar_s symbol variable. * txr.1: Documented.
* ffi: turn char conversion flags into enum.Kaz Kylheku2019-12-141-52/+85
| | | | | | | | | | | | | | | | | | The three flags controlling character array conversion semantics are mutually exclusive. Let's turn them into an enumeration, so we can (1) test that a conversion is in effect by testing a single value and (2) switch on the conversion type instead of successively testing the flags and (3) assure the aforementioned mutual exclusion. * ffi.c (enum char_conv): New enum. (struct txr_ffi_type): Members char_conv, wchar_conv and bchar_conv gone, replaced by ch_conv. (ffi_array_in, ffi_array_put, ffi_array_out, ffi_array_get_common, ffi_array_release_common, ffi_varray_null_term_get, ffi_type_compile, carray_ensure_artype): Work with ch_conv instead of three flags.
* listener: C++ enum issue.Kaz Kylheku2019-12-131-1/+1
| | | | | | * parser.c (is_balanced_line): don't initialize an "enum state" variable with 0, but with the equivalent enum constant.
* doc: doubled word in compat note.Kaz Kylheku2019-12-131-1/+1
| | | | | * txr.1: fix "invoked invoked" in compatibility note for compat value 151.
* doc: make-buf: document default value.Kaz Kylheku2019-12-131-2/+5
| | | | | * txr.1: documnt that the default value of the optional alloc-size parameter is taken from the len parameter.
* multiple-inheritance: test static-slot-home.Kaz Kylheku2019-12-132-1/+6
| | | | | | | * tests/012/oop-mi.tl: Add some coverage for static-slot-home function. * tests/012/oop-mi.expected: Updated.
* multiple-inheritance: super-method loose ends.Kaz Kylheku2019-12-134-41/+87
| | | | | | | | | | | | | | | | | * struct.c (do_super): New function. Now the common implementation for call_super_method, call_super_fun and super_method. (call_super_method, call_super_fun): Reduced to small wrappers around do_super. (super_method): Drill into the object to geet the struct_type handle, and then use do_super to get the method. * tests/012/oop-mi.tl: New tests for call-super-fun and call-super-method. * tests/012/oop-mi.expected: Updated. * txr.1: Updated.
* define-option-struct: use multiple inheritanceKaz Kylheku2019-12-131-14/+22
| | | | | | | | | | | | * share/txr/stdlib/getopts.tl (sys:option-base): New struct type, holding the boiler-plate methods and slots that were generated into the user-defined struct by define-option-struct. (define-option-struct): Inject the required properties by inheritance from sys:option-base, greatly reducing code bloat in the macro. The slot hash and opt-desc-list static slots have to be redefined in the derived structure so that type has its own instance of them.
* OOP: implementing multiple inheritance.Kaz Kylheku2019-12-117-94/+344
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Multiple inheritance is too useful to ignore any longer. * lib.c (subtypep): Perform subtypep calculation between two struct types via the new struct_subtype_p function. It's too complicated now to do with ad hoc code outside of struct.c. * share/txr/stdlib/struct.tl (defstruct): This macro now needs to deal with the super argument being possibly a list of base types instead of a single one. * strut.c (struct struct_type): Member super and super_handle are removed. New member nsupers, supers, and sus. (struct_init): The super function re-registered; it has an optional argument. (call_stinitfun_chain): The compat code here must now access the supertype differently. We don't bother dealing with multiple inheritance in the compat case; programs requesting compatibility with TXR 151 shoudn't be trying to use multiple inheritance. (get_struct_handles, count_super_stslots, get_super_slots, find_super_for_slot): New static functions, to off-load some new complexity from make_struct_type. (make_struct_type): Handle the increased complexity due to multiple inheritance. (super): Takes an additional argument now, to request which supertype to retrieve. Defaults to zero: the first one. (struct_type_destroy): Free the sus array. (struct_type_mark): Mark the supers slot. (call_initfun_chain): Call init functions of all bases, in right-to-left order. (call_postinitfun_chain): Likewise for postinit functions. (call_super_method, call_super_fun, super_method): Use the first base as the supertype. This requirement feels bad; it needs to be revisited. (do_struct_subtype_p): New static function. (struct_subtype_p): New function. (ancestor_with_static_slot): New static function. (method_name): Revised for multiple inheritance; now relies on ancestor_with_static_slot to find the original ancestor that has brought in a method, so we can use that type in the method name. * struct.h (super): Declaration updated. (struct_subtype_p): Declared. * tests/012/oop-mi.expected: New file. * tests/012/oop-mi.tl: New test cases. * txr.1: Revised in order to document multiple inheritance.
* doc: clarify inheritance of static slot value.Kaz Kylheku2019-12-091-0/+31
| | | | | | | | | * txr.1: In relation of the previous bugfix, a certain situation is worth clarifying. A static slot does not inherit the value of a grandparent type's static slot of the same name, if the supertype has specified that slot as an instance slot. Inheritance of the static slot value is from the direct supertype only.
* structs: bugfix: crash in static slot inheritance.Kaz Kylheku2019-12-091-1/+1
| | | | | | | | | | | | | * struct.c (make_struct_type): When a struct defines a static slot that exists as an instancee slot in the supertype, there is a crash. This is because the code assumes that the supertype's slot is static. The index value m ends up negative due to subtracting STATIC_SLOT_BASE from an instance slot index, and so the code tries to copy the value of a negatively indexed static slot from the supertype into the new static slot. We can fix this by not doing the copy when a negative index has been calculated. That way we treat the situation as if the supertype didn't have that slot at all.
* New function: path-dir-empty.Kaz Kylheku2019-12-093-0/+38
| | | | | | | | | | * lisplib.c (path_test_set_entries): Autoload entry for path-dir-empty. * share/txr/stdlib/path-test.tl (path-dir-empty): New function. * txr.1: Documented.
* Add hyperbolic functions: sinh, cosh, and others.Kaz Kylheku2019-12-074-0/+146
| | | | | | | | | | | | | | | | | | | | * arith.c (sinh_s, cosh_s, tanh_s, asinh_s, acosh_s, atanh_s): New symbol variables. (sinh, cosh, tanh, asinh, acosh, atanh): New static functions. (sineh, cosih, tangh, asineh, acosih, atangh): New functions. (arith_init): Register sinh, cosh, tanh, asinh, acosh and atanh intrinsic functions, and initialize the new symbol variables. * configure: Detect availability of hyperbolic functions in math library and defne HAVE_HYPERBOLICS as 1 in config.h accordingly. * lib.h (sineh, cosih, tangh, asineh, acosih, atangh): Declared. * txr.1: Documented new hyperbolic functions and their method counterparts that a numeric struct can implement.
* ffi: allow init-forms for slots.Kaz Kylheku2019-12-062-11/+80
| | | | | | | | | | | | | | | * ffi.c (ffi_memb_compile): Don't complain about three-argument slot specifiers, only about longer ones. (ffi_struct_init): New static function. (ffi_type_compile): Deal with third element in the slot syntax. If there are any non-nil initializing expressions, then we when we call make_struct_type, we specify an initfun, which will plant the values into the slots, using logic similar to that of the initfun generated defstruct, except that the init-forms are reduced to values up-front. * txr.1: Specify optional init-form for slots in FFI struct syntax.
* unwind: new function uw_warningf.Kaz Kylheku2019-12-062-0/+23
| | | | | | | | Convenience function for throwing warnings. * unwind.c (uw_warningf): New function. * unwind.h (uw_warningf): Declared.
* disassemble: d and t regs in decimal.Kaz Kylheku2019-11-291-2/+2
| | | | | | | | * share/txr/stdlib/asm.tl (operand-to-sym): Use decimal with no leading zeros for t and d registers. Only the v registers use hex, because that helps unravel their level structure. The data table is dumped with decimal numbering, so the d registers being decimal makes it easier to cross-ref.
* load: bug: source loc gathered for .tlo files.Kaz Kylheku2019-11-291-1/+3
| | | | | | | | | | | | Contrary to the belief expressed in the commit message of June 2018's 46480c25e62f60c761088c561d90b0f2f5a3143f, source location info is being recorded during the loading of compiled files. The reason is that the function used for processing the forms, lisp_parse_impl, overrides it. * parser.c (read_file_common): Use lisp_parse_impl directly, rather than lisp_parse. Specify that function's rlcp_p argument as false when processing compiled code.
* getopt: tweak multi-line literals in help textKaz Kylheku2019-11-291-26/+25
| | | | | | | | | * share/txr/stdlib/getopts.tl (opthelp): Use a different line breaking approach for literals: the escaped space is now at the end of the previous line, rather than at the start of the next line, which looks nicer. We don't do this for the option type legend, because that has some instances of leading space alignment, which requires a leading backslash.
* getopts: new define-option-struct macro.Kaz Kylheku2019-11-293-2/+159
| | | | | | | | | | | | This provides more streamlined option processing. * lisplib.c (getopts_set_entries): Add auto-load entry for define-option-struct. * share/txr/stdlib/getopts.tl (define-option-struct): New macro. * txr.1: Documented.
* doc: getopt: long and short options appear in index.Kaz Kylheku2019-11-291-0/+17
| | | | | | | | * txr.1: Document that in the parsed opts object returned by getopts, an option which has two names (long and short form) is indexed under both names if it has occurred in the command line, regardless of whether it has occurred under the short or long name.
* getopts: rename add method to add-opt.Kaz Kylheku2019-11-291-5/+5
| | | | | | | | | | | | | The reason for this rename is that add is a public symbol in the usr package, thanks to the build macro. This will interfere with an upcoming feature under which options appear directly as struct slots, defined by symbols. If a user defines an --add option using the symbol add, it will clash with the add method. But add-opt will be sys:add-opt. * share/txr/stdlib/getopts.tl (opts add): Rename to add-opt. (sys:opt-processor parse-long, sys:opt-processor parse-shorts): Follow rename.
* intern-fb: bugfix: optional argument handling.Kaz Kylheku2019-11-281-1/+1
| | | | | | | | | * lib.c (intern_fallback_intrinsic): The missing_ok parameter of get_package must be given a true argument, because package_in is optional. When it is missing, it is represented by the colon symbol, and if missing_ok is false, then get_package treats this colon symbol as the package name "" (the name of that symbol).
* intern-fb: use correct name in diagnostics.Kaz Kylheku2019-11-281-2/+2
| | | | | * lib.c (intern_fallback, intern_fallback_intrinsic): Use intern-fb name, not intern-fallback.
* getopts: move opts object into opt-processor.Kaz Kylheku2019-11-281-20/+24
| | | | | | | | | | | | | | | | | | | | | | | | | The methods of sys:opt-processor pass down an argument called out which is an opts instance that is created in parse-opts. In this patch, we move that argument into a new slot of the sys:opt-processor object, named opts. We instantiate the opts structure in the getopts function instead. The motivation here is that (meth sys:opt-processor parse-opts) doesn't know which type of opts object it is working with; its user is now responsible for instantiating the object and installing it as the opts slot. * share/txr/stdlib/getopts.tl (sys:opt-processor): New slot, opts. (sys:opt-processor (parse-long, parse-shorts): Drop out argument; refer to me.opts instead of it. (sys:opt-processor parse-opts): Don't instantiate opts object here, and don't pass it to parse-long and parse-shorts which no longer take that argument. Rather, rely on it already being installed into the opts slot. (getopts): Instantiate opts here, and specify it as the opts slot of the sys:opt-processor object also being instantiated here.
* getopts: remove unused opt-processor slot from opts.Kaz Kylheku2019-11-281-3/+2
| | | | | | | | * share/txr/stdlib/getopts.tl (opts): opt-processor slot removed. (sys:opt-processor parse-opts): When instantiating opts, do not initialize the opt-processor slot with a backpointer to self object. It is not referenced anywhere.
* getopts: print types in help without colon.Kaz Kylheku2019-11-281-2/+2
| | | | | | | | * share/txr/stdlib/getopts.tl (opthelp): Use symbol-name to get the string representation of type keywords instead of tostringp, so there is no leading colon. In the type legend, we don't have any colon. For instance --gravity=FLOAT rather than --gravity=:FLOAT.
* getopts: simplify build-hash.Kaz Kylheku2019-11-281-5/+3
| | | | | | share/txr/stdlib/getopts.tl (sys:opt-processor build-hash): Don't construct (list od.long od.short) twice and iterate through it twice; make just one and process it in one pass.
* doc: ffi-make-callback doesn't exist.Kaz Kylheku2019-11-251-1/+1
| | | | | * txr.1: Under deffi-cb, correcting a reference to nonexistent ff-make-callback to ffi-make-closure.
* listener: fix buggy balanced line check.Kaz Kylheku2019-11-241-2/+7
| | | | | | | | | | * parser.c (is_balanced_line): When handling the closing characters, we must look for the state type which matches the character type, not state[sp]. Of course state[sp] == match, since we initialized it that way, and so state[sp] != match is always false. We want match to be derived from the character ch, not from state[sp]. Also, the polarity in the match-not-found return case is wrong; we must return 0.
* buffers: support list operations.Kaz Kylheku2019-11-201-0/+18
| | | | | * lib.c (car, cdr, rplaca, rplacd, make_like): Handle BUF type.
* New function: buf-list.Kaz Kylheku2019-11-203-0/+39
| | | | | | | | | * buf.c (buf_list): New function. (buf_init): buf-list intrinsic registered. * buf.h (buf_list): Declared. * txr.1: Documented.
* parser: forgotten top-level .? cases.Kaz Kylheku2019-11-191-0/+8
| | | | | | * parser.y (hash_semi_or_n_expr, hash_semi_or_i_expr): We need to handle OREFDOT here so that .?sym can parse as a top-level expression. Issue reported by vapnik spaknik.
* parser: missing cases in yybadtoken.Kaz Kylheku2019-11-191-0/+3
| | | | | | * parser.y (yybadtoken): Add missing cases for UREFDOT, OREFDOT and UOREFDOT, so these don't fall through to being reported as a junk character.
* parser: merge cases in yybadtoken.Kaz Kylheku2019-11-191-1/+1
| | | | | * parser.y (yybadtoken): Merge CONSDOT and LAMBDOT cases since they have identical code.
* doc: macro-time update.Kaz Kylheku2019-11-191-23/+74
| | | | | | | * txr.1: Update outdated documentation. macro-date is not required any more in the indicated situations. But it can still be required sometimes, and has some interesting uses. More detail added.
* Version 228.txr-228Kaz Kylheku2019-11-187-1122/+1192
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* identity*: fix wrong argument index type.Kaz Kylheku2019-11-181-1/+1
| | | | | * lib.c (identity_star): The args_more function requires an index which is a cnum, not int.
* hash: bugfix: bad memset size in hash-reset.Kaz Kylheku2019-11-181-1/+1
| | | | | * hash.c (hash_reset): Clear the whole structure, not just a pointer-sized region at its base.
* ffi: rename functions in the carray-num group.Kaz Kylheku2019-11-183-30/+61
| | | | | | | | | | | | | | * ffi.c (carray_unum, carray_num, unum_carray, num_carray): Functions renamed to carray_uint, carray_int, uint_carray, int_carray. (ffi_init): Functions registered under new names: carray-uint, carray-int, uint-carray, int-carray. Compat values of 227 or less provide the old old names. * ffi.h (carray_unum, carray_num, unum_carray, num_carray): Declarations renamed. * txr.1: Updated to new names; compat note added.
* op: fix wrong compat version value.Kaz Kylheku2019-11-181-1/+1
| | | | | | * share/txr/stdlib/op.tl (sys:op-expand): The compatibility version check should be against 225, not against the not yet existent 255.
* ffi: carray-num using wrong function name.Kaz Kylheku2019-11-181-1/+1
| | | | | * ffi.c (carray_num): Use the correct name carray-num rather than carray-unum in diagnostics.
* doc: wrong word under stream sockets.Kaz Kylheku2019-11-181-1/+1
| | | | | * txr.1: The word "times" appeared in place of "types". Reported by vapnik spaknik.
* doc: inaccurate apf/ipf description.Kaz Kylheku2019-11-181-6/+13
| | | | | | | * txr.1: User vapnik spaknik pointed out the poor documentation for apf, which stated that it takes one argument which is a list, when in fact it more generally takes and works with apply-like arguments.
* doc: various copy and paste mistakes.Kaz Kylheku2019-11-181-4/+4
| | | | | | * txr.1: Fix copy and paste errors affecting flo-zero, struct sockaddr-in6, sockaddr-unix and sock-bind. Reported by user vapnik spaknik.
* doc: incorrect partition* example.Kaz Kylheku2019-11-181-1/+1
| | | | | * txr.1: Fix incorrect return value. Reported by user vapnik spaknik.
* doc: wrong argument reference under regsub.Kaz Kylheku2019-11-181-3/+3
| | | | | | * txr.1: Fix wording that refers to first argument as the second argument. It is the second form element, of course, but the first argument. Reported by user vapnik spaknik.
* doc: formatting under Special Structure Functions.Kaz Kylheku2019-11-181-2/+2
| | | | | * txr.1: Use .mets instead of .meti on the syntax; this produces an indentation.
* New functions for buf <--> integer conversion.Kaz Kylheku2019-11-182-0/+192
| | | | | | | | | * buf.c (buf_int, buf_uint, int_buf, uint_buf): New static functions. (buf_init): buf-int, buf-uint, int-buf and uint-buf intrinsic functions registered. * txr.1: Documented.
* eval: bugfix: expansion wrongly always in null env.Kaz Kylheku2019-11-181-5/+34
| | | | | | | | | | | | | | | | | | | | | | The eval function uses a null macro environment for expanding a form, even when it's given an environment object. This causes spurious warnings about unbound variables/functions. For instance: (let ((env (make-env '((x . 42)) nil nil))) (eval '(+ x x) env)) ;; warning: unbound variable x To fix this, we have to create a macro version of the incoming environment and expand with that. * eval.c (env_to_menv): Take an evaluation environment chain and convert it to a (flattened) macro environment. (expand_eval): Take a macro environment parameter and use that for expanding the form to be evaluated, rather than nil. (eval_intrinsic): Calculate a macro environment corresponding to the given evaluation environment. Use that for the macroexpand call, and also pass it down to expand_eval to be used for the full expansion.