Permalink
Browse files

delete UB*REF/* implementation; import the symbols from nibbles instead

  • Loading branch information...
1 parent 229ddfe commit 66313cd106a5cc470c8794725e22ef912daa7e94 @froydnj committed Mar 21, 2012
Showing with 4 additions and 42 deletions.
  1. +0 −42 src/common.lisp
  2. +4 −0 src/package.lisp
View
42 src/common.lisp
@@ -66,48 +66,6 @@
(nibbles::byte-ref-fun-name bitsize nil big-endian-p))
) ; EVAL-WHEN
-(macrolet ((define-fetcher (bitsize &optional big-endian)
- (let ((name (ubref-fun-name bitsize big-endian))
- (bytes (truncate bitsize 8)))
- `(progn
- (declaim (inline ,name))
- (defun ,name (buffer index)
- (declare (type simple-octet-vector buffer))
- (declare (type (integer 0 ,(- array-dimension-limit bytes)) index))
- (logand ,(1- (ash 1 bitsize))
- ,(loop for i from 0 below bytes
- collect (let* ((offset (if big-endian
- i
- (- bytes i 1)))
- (shift (if big-endian
- (* (- bytes i 1) 8)
- (* offset 8))))
- `(ash (aref buffer (+ index ,offset)) ,shift)) into forms
- finally (return `(logior ,@forms))))))))
- (define-storer (bitsize &optional big-endian)
- (let ((name (ubref-fun-name bitsize big-endian))
- (bytes (truncate bitsize 8)))
- `(progn
- (declaim (inline (setf ,name)))
- (defun (setf ,name) (value buffer index)
- (declare (type simple-octet-vector buffer))
- (declare (type (integer 0 ,(- array-dimension-limit bytes)) index))
- (declare (type (unsigned-byte ,bitsize) value))
- ,@(loop for i from 1 to bytes
- collect (let ((offset (if big-endian
- (- bytes i)
- (1- i))))
- `(setf (aref buffer (+ index ,offset))
- (,(read-from-string (format nil "~:R-~A" i '#:byte)) value))))
- (values)))))
- (define-fetchers-and-storers (bitsize)
- `(progn
- (define-fetcher ,bitsize) (define-fetcher ,bitsize t)
- (define-storer ,bitsize) (define-storer ,bitsize t))))
- (define-fetchers-and-storers 16)
- (define-fetchers-and-storers 32)
- (define-fetchers-and-storers 64))
-
;;; efficient 32-bit arithmetic, which a lot of algorithms require
View
4 src/package.lisp
@@ -2,6 +2,10 @@
(:use :cl)
(:nicknames :crypto)
(:shadow null)
+ (:import-from #:nibbles
+ #:ub16ref/le #:ub16ref/be
+ #:ub32ref/le #:ub32ref/be
+ #:ub64ref/le #:ub64ref/be)
(:export
;; referencing multiple-octet values in an octet vector (SETF-able)
#:ub16ref/be #:ub16ref/le #:ub32ref/be #:ub32ref/le #:ub64ref/le #:ub64ref/be

0 comments on commit 66313cd

Please sign in to comment.