From 51def94e9c0ce81511ce1364c9adf2cd047a38bc Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sat, 11 Jun 2022 11:55:27 -0400 Subject: Bindat: Document `sint`; add `le` arg to `uint`; deprecate `uintr` * lisp/emacs-lisp/bindat.el (bindat--type) : Add `le` optional arg. (bindat--type) : Delete method. (uintr): Re-define as a bindat-macro instead. (bindat-type): Update docstring accordingly. (bindat--primitives): Update. (sint): Simplify. * doc/lispref/processes.texi (Bindat Types): Update `uint`, add `sint`, and remove `uintr`. * test/lisp/emacs-lisp/bindat-tests.el (data-bindat-spec): Use the new `le` arg of `uint` instead of `uintr`. --- test/lisp/emacs-lisp/bindat-tests.el | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'test/lisp/emacs-lisp') diff --git a/test/lisp/emacs-lisp/bindat-tests.el b/test/lisp/emacs-lisp/bindat-tests.el index 48170727525..1ce402977f5 100644 --- a/test/lisp/emacs-lisp/bindat-tests.el +++ b/test/lisp/emacs-lisp/bindat-tests.el @@ -36,7 +36,7 @@ (bindat-type (type u8) (opcode u8) - (length uintr 16) ;; little endian order + (length uint 16 'le) ;; little endian order (id strz 8) (data vec length) (_ align 4))) @@ -128,18 +128,17 @@ (r (zerop (% kind 2)))) (dotimes (_ 100) (let* ((n (random (ash 1 bitlen))) - (i (- n (ash 1 (1- bitlen))))) + (i (- n (ash 1 (1- bitlen)))) + (stype (bindat-type sint bitlen r)) + (utype (bindat-type if r (uintr bitlen) (uint bitlen)))) (should (equal (bindat-unpack - (bindat-type sint bitlen r) - (bindat-pack (bindat-type sint bitlen r) i)) + stype + (bindat-pack stype i)) i)) (when (>= i 0) - (should (equal (bindat-pack - (bindat-type if r (uintr bitlen) (uint bitlen)) i) - (bindat-pack (bindat-type sint bitlen r) i))) - (should (equal (bindat-unpack - (bindat-type if r (uintr bitlen) (uint bitlen)) - (bindat-pack (bindat-type sint bitlen r) i)) + (should (equal (bindat-pack utype i) + (bindat-pack stype i))) + (should (equal (bindat-unpack utype (bindat-pack stype i)) i)))))))) (defconst bindat-test--LEB128 -- cgit v1.2.3