* [PATCH] Complete bindat.el package for 64-bit unsigned int
@ 2022-11-29 18:10 Oscar Najera
2022-11-29 20:06 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Oscar Najera @ 2022-11-29 18:10 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 158 bytes --]
Hello,
I needed to read 64-bit unsigned ints. It is a small change, looking forward for any feedback.
It is the first time I submit a patch.
Cheers,
Oscar
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Complete-bindat.el-package-for-64-bit-unsigned-int.patch --]
[-- Type: text/x-patch, Size: 2347 bytes --]
From a63577cce6b0b47f2962cabfe35f1ca020b17057 Mon Sep 17 00:00:00 2001
From: Oscar Najera <hi@oscarnajera.com>
Date: Tue, 29 Nov 2022 18:35:44 +0100
Subject: [PATCH] Complete bindat.el package for 64-bit unsigned int
---
lisp/emacs-lisp/bindat.el | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lisp/emacs-lisp/bindat.el b/lisp/emacs-lisp/bindat.el
index 82d3c53..8946743 100644
--- a/lisp/emacs-lisp/bindat.el
+++ b/lisp/emacs-lisp/bindat.el
@@ -150,6 +150,9 @@
(defun bindat--unpack-u32 ()
(logior (ash (bindat--unpack-u16) 16) (bindat--unpack-u16)))
+(defun bindat--unpack-u64 ()
+ (logior (ash (bindat--unpack-u32) 32) (bindat--unpack-u32)))
+
(defun bindat--unpack-u16r ()
(logior (bindat--unpack-u8) (ash (bindat--unpack-u8) 8)))
@@ -159,6 +162,9 @@
(defun bindat--unpack-u32r ()
(logior (bindat--unpack-u16r) (ash (bindat--unpack-u16r) 16)))
+(defun bindat--unpack-u64r ()
+ (logior (bindat--unpack-u32r) (ash (bindat--unpack-u32r) 32)))
+
(defun bindat--unpack-str (len)
(let ((s (substring bindat-raw bindat-idx (+ bindat-idx len))))
(setq bindat-idx (+ bindat-idx len))
@@ -197,9 +203,11 @@
((or 'u16 'word 'short) (bindat--unpack-u16))
('u24 (bindat--unpack-u24))
((or 'u32 'dword 'long) (bindat--unpack-u32))
+ ('u64 (bindat--unpack-u64))
('u16r (bindat--unpack-u16r))
('u24r (bindat--unpack-u24r))
('u32r (bindat--unpack-u32r))
+ ('u64r (bindat--unpack-u64r))
('bits (bindat--unpack-bits len))
('str (bindat--unpack-str len))
('strz (bindat--unpack-strz len))
@@ -317,6 +325,7 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
(u16 . 2) (u16r . 2) (word . 2) (short . 2)
(u24 . 3) (u24r . 3)
(u32 . 4) (u32r . 4) (dword . 4) (long . 4)
+ (u64 . 8) (u64r . 8)
(ip . 4)))
(defun bindat--length-group (struct spec)
@@ -486,9 +495,11 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
((or 'u16 'word 'short) (bindat--pack-u16 v))
('u24 (bindat--pack-u24 v))
((or 'u32 'dword 'long) (bindat--pack-u32 v))
+ ('u64 (bindat--pack-u64 v))
('u16r (bindat--pack-u16r v))
('u24r (bindat--pack-u24r v))
('u32r (bindat--pack-u32r v))
+ ('u64r (bindat--pack-u64r v))
('bits (bindat--pack-bits len v))
('str (bindat--pack-str len v))
('strz (bindat--pack-strz len v))
--
2.38.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Complete bindat.el package for 64-bit unsigned int
2022-11-29 18:10 [PATCH] Complete bindat.el package for 64-bit unsigned int Oscar Najera
@ 2022-11-29 20:06 ` Stefan Monnier
2022-11-30 1:17 ` Oscar Najera
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2022-11-29 20:06 UTC (permalink / raw)
To: Oscar Najera; +Cc: emacs-devel
> I needed to read 64-bit unsigned ints. It is a small change, looking forward for any feedback.
> It is the first time I submit a patch.
Hmm... if you use `bindat-type` then the integer types take a "BITSIZE"
argument and you can make them any size you like (well, only multiples of
8, admittedly).
I'd rather encourage people to use `bindat-type` than add features to
the legacy API.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Complete bindat.el package for 64-bit unsigned int
2022-11-29 20:06 ` Stefan Monnier
@ 2022-11-30 1:17 ` Oscar Najera
2022-11-30 2:44 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Oscar Najera @ 2022-11-30 1:17 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
> I'd rather encourage people to use `bindat-type` than add features to
> the legacy API.
Fair enough, moving forward then. You can close this.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Complete bindat.el package for 64-bit unsigned int
2022-11-30 1:17 ` Oscar Najera
@ 2022-11-30 2:44 ` Stefan Monnier
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2022-11-30 2:44 UTC (permalink / raw)
To: Oscar Najera; +Cc: emacs-devel
>> I'd rather encourage people to use `bindat-type` than add features to
>> the legacy API.
> Fair enough, moving forward then. You can close this.
Let me know if you need help moving your code to `bindat-type`.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-30 2:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29 18:10 [PATCH] Complete bindat.el package for 64-bit unsigned int Oscar Najera
2022-11-29 20:06 ` Stefan Monnier
2022-11-30 1:17 ` Oscar Najera
2022-11-30 2:44 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).