aboutsummaryrefslogtreecommitdiff
path: root/gnu/gnunet/utils
Commit message (Collapse)AuthorAge
* records: Correct constructor->constructor*.Maxime Devos2023-03-04
| | | | | | | | Looks like the 'in the next commit' of the previous commit can't be done yet. * gnu/gnunet/utils/records.scm (process)[copy*]: Resolve TODO about apparent bug: ignore the docstring.
* records: Correct calling convention for constructor.Maxime Devos2023-03-04
| | | | | | | | | | | Oops another bug ... The constructor now sometimes expects keyword arguments! * gnu/gnunet/utils/records.scm (process)[keywordify]: New procedure. (process)[copy*]: Use it, and add a TODO about apparent bug. (process)[constructor/copy*]: Use it.
* records: Use default values correctly.Maxime Devos2023-03-04
| | | | | | * gnu/gnunet/utils/records.scm (process)[constructor-keyword-arguments*/different]: Change '(i . value)' to '(i value)'.
* records: Check for keywords correctly.Maxime Devos2023-03-04
| | | | | | | | Oops committed too early ... * gnu/gnunet/utils/records.scm (process)[constructor-keyword-arguments*/different]: Convert syntax into a datum before using 'keyword?'.
* records: Fix let-binding syntax in lambda*/define*.Maxime Devos2023-03-04
| | | | | | | Oops committed too early ... * gnu/gnunet/utils/records.scm (process)[constructor-keyword-arguments*/different]: Don't splice it.
* records: Support keyword arguments in the constructor.Maxime Devos2023-03-04
| | | | | | | | | This will be used by the DHT code in the next commit. * gnu/gnunet/utils/records.scm (constructor-keyword-arguments*): New variable, used in generated syntax. (constructor-keyword-arguments*/different): Likewise.
* utils/records: Give preprocessors access to previous fields.Maxime Devos2023-02-09
| | | | * gnu/gnunet/utils/records.scm (process): Implement it.
* utils/records: Support copying when #:read-only-slice-wrapper=#false.Maxime Devos2023-02-08
| | | | * gnu/gnunet/utils/records.scm (preprocess): Support more cases.
* utils/records: Fix auto-generated constructor/copy docstring.Maxime Devos2023-02-08
| | | | | | | | Previously, ony a single value was returned, while two were needed. * gnu/gnunet/utils/records.scm (copy*, copy-docstring): Set the docstring to #false if 'copy' is unset and constructor/copy is set.
* utils/records: Raise &missing-capabilities exceptions.Maxime Devos2023-02-02
| | | | | | | Addressed a tests/distributed-hash-table.scm test failure. * gnu/gnunet/util/records.scm (process)[fields*]{predicate}: Remove 'slice-readable?' check.
* records: New API for record types, specialised to bytevector slices.Maxime Devos2023-01-30
| | | | | | | | | | | | | | | | This simplifies many record definitions and is less prone to errors -- if there is an error in the generation code, it will likely impact multiple record types, so tests for one record type also partially test other record types. It also reduces the amount of code to be written -- reducing boilerplate, in other words. * gnu/gnunet/utils/records.scm: New module. * Makefile.am (modules): Add it. * gnu/gnunet/cadet/client.scm: Use it. * gnu/gnunet/hashcode.scm: Likewise. * gnu/gnunet/fs/uri.scm: Likewise.
* bv-slice: Add procedure for comparing slices.Maxime Devos2023-01-15
| | | | | | | | | | | | | | | | | | | | | | * doc/scheme-gnunet.tm: Update copyright line. * doc/bytevector-slices.scm (slice-contents-equal?): Document new procedure. * NEWS: Mention new procedure. * gnu/gnunet/utils/bv-slice.scm (slice-contents-equal?): New procedure. * tests/bv-slice.scm ("first argument of slice-contents-equal? must be readable"): ("second argument of slice-contents-equal? must be readable"): ("slice-contents-equal? is reflexive") ("slice-contents-equal? is reflexive (read-only)") ("slice-contents-equal? #true backed by same bytevector but different offset") ("slice-contents-equal? #false backed by same bytevector but different offset") ("slice-contents-equal? #false backed by same bytevector but different length") ("slice-contents-equal? #false, same offset and length") ("copies are slice-contents-equal?") ("copies are slice-contents-equal? (read-only)") ("copies are slice-contents-equal? (one offset)"): New tests. (make-a-bv): Helper procedure for tests.
* bv-slice-quickcheck: Implement xform.Maxime Devos2022-12-03
| | | | | | | | | (Untested) * gnu/gnunet/utils/bv-slice.scm ($arbitrary-lift): Remove. ($sized-bytevector,$sized-bytevector-slice/read-write) ($sized-bytevector-slice/read-only): Replace $arbitrary-lift with $record.
* Define arbitraries for generating bytevector slices.Maxime Devos2022-12-02
| | | | | | | | | * tests/cadet.scm ($sized-bytevector, $sized-bytevector-slice/read-write, $sized-bytevector-slice/read-only): Move to ... * gnu/gnunet/utils/bv-slice-quickcheck.scm: ... new module. * Makefile.am (modules): Register new module. * doc/bytevecto-slices.tm (Quickcheck integration): Document in new section.
* bv-slice: Implement slice-copy/bytevector.Maxime Devos2022-09-19
| | | | | | | | | | | | * gnu/gnunet/utils/bv-slice.scm (slice-copy/bytevector): New procedure. * doc/bytevector-slice.tm (slice-copy/read-write,slice-copy/read-only,slice-copy/bytevector): New documentation. * tests/bv-slice.scm ("return value of slice-copy/bytevector independent of original") ("source of slice-copy/bytevector must be readable"): New tests.
* bv-slice: Define read-only and write-only variants of bv-slice/read-write.Maxime Devos2022-09-10
| | | | | | | | Documentation, tests and uses will come later. * gnu/gnunet/utils/bv-slice.scm (make-bv-slicer): New procedure. (bv-slice/read-write): Use it. (bv-slice/read-only,bv-slice/write-only): New procedures.
* Add ;#!r6rs comments.Maxime Devos2022-09-03
|
* hat-let: Port to Racket Scheme.Maxime Devos2022-09-03
| | | | * gnu/gnunet/utils/hat-lets.scm: Add phasing, and check for _ differently.
* hat-let: Allow both _.Maxime Devos2022-08-29
|
* utils/bv-slice: Define ‘slice-independent’ procedure.Maxime Devos2022-02-22
| | | | | | | | | | | | | | | * gnu/gnunet/utils/bv-slice.scm (slice-independent?): New procedure. * tests/bv-slice.scm (slice-independent?): Remove. ("empty slices are independent") ("empty slices are independent, even if using the same bytevector") ("empty slices are independent, even when using offsets (1)") ("empty slices are independent, even when using offsets (2)") ("empty slices are independent, even if eq?") ("slice-independent? is irreflexive (assuming non-empty) and ignores capabilities (1)") ("slice-independent? is irreflexive (assuming non-empty) and ignores capabilities (2)") ("empty slice is independent, even if inside the other slice") ("non-overlapping ranges are independent") ("overlapping ranges are dependent"): New tests.
* utils/bv-slice: Define copying procedures.Maxime Devos2022-02-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | * gnu/gnunet/utils/bv-slice.scm (slice-copy/read-write,slice-copy/read-only): New procedures. * gnu/gnunet/dht/client.scm (slice-copy): Remove. (copy-datum,copy-query,copy-search-result): Use new procedures. * tests/bv-slice.scm (slice-independent?): New procedure. ("source of slice-copy/read-write must be readable") ("even if the length is zero") ("return value of slice-copy/read-write is read-write") ("return value of slice-copy/read-write is read-write, even if length is zero") ("return value of slice-copy/read-write independent of original") ("return value of slice-copy/read-write is fresh even if length is zero") ("slice-copy/read-write returns something with the same contents (1)") ("slice-copy/read-write returns something with the same contents (2)") ("source of slice-copy/read-only must be readable") ("even if the size is zero") ("return value of slice-copy/read-only is read-only") ("return value of slice-copy/read-only is read-only, even if length is zero") ("return value of slice-copy/read-only independent of original") ("return value of slice-copy/read-only is fresh even if length is zero (1)") ("return value of slice-copy/read-only is fresh even if length is zero (2)") ("slice-copy/read-only returns something with the same contents (1)") ("slice-copy/read-only returns something with the same contents (2)"): New tests.
* Make uses of 'set%!' less verbose.Maxime Devos2022-02-11
| | | | | | | | * gnu/gnunet/utils/cut-syntax.scm: New module. * Makefile.am: Add it. * gnu/gnunet/dht/client.scm: Use it. * tests/mq.scm: Likewise. * tests/network-size.scm: Likewise.
* Add SPDX license headers.Maxime Devos2022-02-04
|
* Correct SPDX-License-Identifier.Maxime Devos2022-02-04
| | | | AGPL3.0-or-later is bogus, AGPL-3.0-or-later is correct.
* bv-slice: Let slice-u8-ref and friends raise &missing-capabilities.Maxime Devos2022-02-03
| | | | | | | | | | | | | | | | This makes error messages a little more useful. * gnu/gnunet/utils/bv-slice.scm (wrap-rnrs-ref): Replace 'ok?' by 'verify'. (slice-u8-ref,slice-u16-ref,slice-u32-ref,slice-u64-ref) (slice-s8-ref,slice-s16-ref,slice-s32-ref,slice-s64-ref) (slice-u8-set!,slice-u16-set!,slice-u32-set!,slice-u64-set!) (slice-s8-set!,slice-s16-set!,slice-s32-set!,slice-s64-set!) (slice-ieee-double-ref,slice-ieee-double-set!): Adjust calls to 'wrap-rnrs-ref'. * NEWS (Features): Document new behaviour. Fixes: <https://notabug.org/maximed/scheme-gnunet/issues/22>
* utils/hat-let: New ^! construct.Maxime Devos2022-01-21
| | | | | | It will be used by the DHT code. * gnu/gnunet/utils/hat-let.scm (let^)[^!]: New case.
* dht/client: Improve and test <datum> records.Maxime Devos2022-01-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | * gnu/gnunet/utils/bv-slice.scm (make-verify-slice-cap,verify-slice-readable,verify-slice-writable): New procedures. (slice-zero!,slice-copy!): Use them. * gnu/gnunet/dht/client.scm (validate-key): Use 'verify-slice-readable' for nicer exceptions. (%max-message-size,%max-datum-value-length): New variables. (&overly-large-datum): New condition. (make-datum): Throw new condition when appropriate. (canonical-block-type): Detect non-exact integers. * tests/distributed-hash-table.scm (test-missing-caps,test-overly-large-datum,datum-key-test,datum-value-test): New macros for tests. (make-a-datum,test-datum-overly-large): New procedures for tests. ("datum?", "not a datum", "datum-key", "datum-key, read-only is sufficient", "datum key must be readable", "datum-value, length 0", "datum-value, maximal length", "datum-value", "datum-value, too large (1, numeric type)", "datum-value, too large (2, numeric type)", "datum-value, too large (1, symbolic type)", "datum-key, symbolic type (1)", "datum-key, symbolic type (2)", "datum-key, known numeric type (1)", "datum-key, known numeric type (2)", "datum-key, unknown numeric type", "datum-type, out-of-bounds", "datum-type, wrong enumeration", "datum-type, wrong type (1)", "datum-type, wrong type (2)"): New tests.
* bv-slice: Create a condition type for capability mismatches.Maxime Devos2022-01-11
| | | | | | | | | | | | | | | | It is not truly necessary but it makes error messages in tests a little neater. * gnu/gnunet/utils/bv-slice.scm (&missing-capabilities): New condition. (verify-slice-cap): New procedure. (make-select-capabilities): Use new procedure. (slice-zero!, slice-copy!): Likewise. * tests/bv-slice.scm (test-missing-caps): New macro. ("destination of slice-copy! must be writable") ("source of slice-copy! must be readable"): Also check the exception.
* bv-slice: Don't print bytes in unreadable slices.Maxime Devos2022-01-11
| | | | | | | | * gnu/gnunet/utils/bv-slice.scm (print-slice): When not readable, only print the length and not the actual bytes. * tests/bv-slice.scm ("slice to string, read-write", "slice to string, read-only") ("slice to string, write-only"): Test print-slice.
* Merge branch 'master' into dhtMaxime Devos2021-09-21
|\
| * Update copyright notices.Maxime Devos2021-09-21
| |
* | bv-slice: Support signed integers.Maxime Devos2021-09-21
|/ | | | | | | | | | | | | * gnu/gnunet/utils/bv-slice.scm (slice-s8-ref,slice-s16-ref,slice-s32-ref,slice-s64-ref) (slice-s8-set!,slice-s16-set!,slice-s32-set!,slice-s64-set!): New procedures. * tests/bv-slice.scm (some-numbers): New procedure. (sizes/u,sizes/s): New variables. ("slice-uN-ref/set! rount-trips"): New tests. ("slice-sN-ref/set! rount-trips"): New tests. ("two's complement is used"): New test.
* hat-let: Allow (dotted) variable lists with <--.Maxime Devos2021-09-21
| | | | | * gnu/gnunet/utils/hat-let.scm (let^): Recognise (dotted) variable lists with <--.
* bv-slice: Support IEEE doubles.Maxime Devos2021-09-21
| | | | | * gnu/gnunet/utils/bv-slice.scm (slice-ieee-double-ref, slice-ieee-double-set!): New variables.
* utils: tokeniser: Implement 'add-from-port!'.Maxime Devos2021-09-21
| | | | | | | | | | | | | | This will be used in the generic message queue implementation. * gnu/gnunet/utils/tokeniser.scm (add-from-port!): New procedure. * tests/tokeniser.scm (no-return/done-eof, no-return/premature-eof): New procedures for tests. ("eof detected", "eof detected (complete data)") ("premature eof detected") ("add-from-port! and partial messages (split at header)") ("kaput tokeniser and add-from-port!"): New tests for new procedure.
* utils: tokeniser: Some extra documentation.Maxime Devos2021-09-21
| | | | | * gnu/gnunet/utils/tokeniser.scm: Add some explanation I forgot.
* Merge branch 'master' into proper-mqMaxime Devos2021-09-21
|\ | | | | | | The 'hat-let' fix wil be used.
| * utils: hat-let: Fix inline procedure definitions.Maxime Devos2021-09-21
| | | | | | | | | | | | | | | | | | The syntax for procedure bindings needs to match before the syntax for generic bindings. * gnu/gnunet/utils/hat-let.scm (let^): Move the code for inline procedure definitions a little upwards.
* | utils: tokeniser: Split message streams into individual messages.Maxime Devos2021-09-21
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile.am (modules): Add new module (gnu gnunet utils tokeniser). (SCM_TESTS): Add new test tests/tokeniser.scm. * README.org (Message queues): Describe new module. * gnu/gnunet/util/struct.scm (/:message-header): Note that the new module depends on the exact layout. * gnu/gnunet/utils/tokeniser.scm (make-tokeniser, tokeniser?, <tokeniser>): New record type. (&interrupted-tokeniser-volation) make-interrupted-tokeniser-violation) interrupted-tokeniser-violation?): New condition type. (&kaput-tokeniser-error, make-tokeniser-error, kaput-tokeniser-error?): New condition type. (add-bytevector!): New procedure. * tests/tokeniser.scm (fluffed-bytevector, no-return/overly-small, no-return/done) (no-handle/message, merge-bytevectors, catch-errors): New procedures for tests. (choose-message, choose-many-message, positions->ranges) (choose-split-positions): New QuickCheck generators for tests. ($messages-and-ranges): New QuickCheck arbitrary for tests. ("[prop] complete messages are passed through") ("message fragmented on header/data boundary reassembled") ("message fragmented in size field and after message header, some data") ("[prop] all fragmented & multiple messages received") ("overly small message error (complete header)") ("overly small message error (header split in size field)") ("huge message, split early") ("re-entrancy from message handler is detected (complete message)") ("tokeniser becomes kaput, split after size field") ("tokeniser becomes kaput, split inside size field"): New tests. (huge-bv): New variable. * tests/utils.scm (calls-in-tail-position?): New buggy procedure for tests.
* hat-let: Drop incorrect copyright notices.Maxime Devos2021-09-21
| | | | | * gnu/gnunet/utils/hat-let.scm: Don't state GNUnet e.V. has copyright, as that would be incorrect.
* hat-let: Avoid having to import '_' from (rnrs base).Maxime Devos2021-09-21
| | | | | * gnu/gnunet/utils/hat-let.scm (let^): Do not refer to the identifier '_' from (rnrs base).
* utils: hat-let: Add <--, a variant on <-.Maxime Devos2021-09-21
| | | | | | | | | | | The old <- accepts a thunk expression instead of a raw expression, which is a historical mistake. * gnu/gnunet/utils/hat-let.scm (let^)[<-]: Deprecate. (let^)[<--]: Define a variant that accepts expressions to evaluate instead. (Mini changelog): Bump the version number.
* utils: Define module for defining platform-specifing enumerations.Maxime Devos2021-09-21
| | | | | | | | | | | | (gnu extractor enum) is not suitable as it assumes the enumeration values are the same on all target platforms. * gnu/gnunet/utils/platform-enum.scm (that-platform?): Define syntax for writing platform-specific code. (define-platform-enumeration): Define syntax for defining platform-specific C-style enumerations compactly. * Makefile.am (modules): Compile the new module. * README.org (modules): Note this module exists.
* utils: bv-slice: Define a record printer.Maxime Devos2021-09-21
| | | | | | * gnu/gnunet/utils/bv-slice.scm (print-slice): Define a procedure for printing slices to a port and use it as the record printer for slices.
* bv-slice: Correct offset calculation in slice-slice.Maxime Devos2021-09-21
| | | | | | | * gnu/gnunet/utils/bv-slice.scm (slice-slice): Add the requested additional offset to the original offset when two arguments are passed. Previously, the original offset was ignored.
* Define slice-copy! and slice-zero!.Maxime Devos2021-09-21
| | | | | | | | | | | | These will be used for the ancillary message parsing code, which will be used to generate more detailed network error messages than what can be interferenced from the errno. * tests/bv-slice.scm: New test file, testing slice-copy! and slice-zero! * gnu/gnunet/utils/bv-slice.scm (slice-zero!, slice-copy!): New procedures. Also comment the module more. * Makefile.am (SCM_TESTS): Register tests/bv-slice.scm.
* utils: correct definition of unsigned integersMaxime Devos2021-09-21
| | | | | | | | | * gnu/gnunet/utils/netstruct.scm (define-unsigned-N-bytes): pass the index to slice-ref and slice-set!, and use slice-ref and slice-set! instead of slice-u8-ref and slice-u8-set! (u32/big, u32/little, u64/big, u64/little): use correct slice-ref procedure.
* fix netstruct, and implement wrap-reader-setterMaxime Devos2021-09-21
|
* Define library for structuresMaxime Devos2021-09-21
|
* Define bytevector slicesMaxime Devos2021-09-21
|