From a63577cce6b0b47f2962cabfe35f1ca020b17057 Mon Sep 17 00:00:00 2001 From: Oscar Najera 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