emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Complete bindat.el package for 64-bit unsigned int


From: Oscar Najera
Subject: [PATCH] Complete bindat.el package for 64-bit unsigned int
Date: Tue, 29 Nov 2022 19:10:02 +0100

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

>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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]