Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Zulu-Inuoe committed Aug 28, 2023
2 parents 628ac48 + 06f3c55 commit 062f171
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 9 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## PENDING v1.1.3

Changes relative to [v1.1.2](#v112)

## v1.1.2

Changes relative to [v1.1.1](#v111)

* Fix printing non-square multidimensional arrays https://github.com/Zulu-Inuoe/jzon/issues/43
* Fix serializing CLOS objects on LispWorks https://github.com/Zulu-Inuoe/jzon/issues/49
* `jzon:span` support for `cl:stream`
* Fix serializing non-square multidimensional arrays https://github.com/Zulu-Inuoe/jzon/pull/44
* Can now test jzon via `asdf:test-system` https://github.com/Zulu-Inuoe/jzon/pull/51

## v1.1.1

Changes relative to [v1.1.0](#v110)
Expand Down
3 changes: 2 additions & 1 deletion src/com.inuoe.jzon.asd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(defsystem #:com.inuoe.jzon
:version "1.1.1"
:version "1.1.2"
:description "A correct and safe(er) JSON RFC 8259 parser with sane defaults."
:author "Wilfredo Velázquez-Rodríguez <zulu.inuoe@gmail.com>"
:license "MIT"
Expand All @@ -8,6 +8,7 @@
(:feature (:not :ecl) #:float-features)
#:trivial-gray-streams
#:uiop)
:in-order-to ((test-op (test-op "com.inuoe.jzon-tests")))
:components ((:file "eisel-lemire")
(:file "ratio-to-double")
(:file "schubfach")
Expand Down
22 changes: 14 additions & 8 deletions src/jzon.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -1687,16 +1687,22 @@ see `write-values'"
(:method ((writer writer) (value array))
(let ((dimensions (array-dimensions value)))
(if (null dimensions)
(write-value writer (aref value))
(labels ((recurse (dimensions acc)
(write-value writer (aref value))
(labels ((recurse (dimensions head tail)
(if (null dimensions)
(write-value writer (apply #'aref value head))
(destructuring-bind (d . rest) dimensions
(with-array writer
(if (null rest)
(loop :for i :below d
:do (write-value writer (row-major-aref value (+ acc i))))
(loop :for i :below d
:do (recurse rest (+ acc (* i d)))))))))
(recurse dimensions 0)))))
(let ((cell (setf (cdr tail) (cons 0 nil))))
(dotimes (i d)
(setf (car cell) i)
(recurse rest head cell))))))))
(destructuring-bind (d . rest) dimensions
(with-array writer
(let ((cell (cons 0 nil)))
(dotimes (i d)
(setf (car cell) i)
(recurse rest cell cell)))))))))

;;; Sequence support
(:method ((writer writer) (value sequence))
Expand Down
3 changes: 3 additions & 0 deletions src/schubfach.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
(the (values null &optional)
(let ((q0 q)
(pos p))
(declare (type (signed-byte 32) q0))
(loop :while (> pos pos-lim)
:do (let* ((q1 (%int32 (%>>64 (* q0 1374389535) 37)))
(d (aref ds (- q0 (* q1 100)))))
Expand All @@ -183,6 +184,7 @@
(let* ((q0 q)
(q1 0)
(pos p))
(declare (type (signed-byte 32) q0))
(loop :while (let ((qp (%int64 (* q0 1374389535))))
(setf q1 (%int32 (%>>64 qp 37)))
(zerop (logand qp #x1FC0000000)))
Expand Down Expand Up @@ -219,6 +221,7 @@
(type (simple-array (unsigned-byte 16) (100)) ds))
(let ((q0 q)
(pos p))
(declare (type (signed-byte 32) q0))
(loop
(setf pos (- pos 2))
(when (< q0 100)
Expand Down
2 changes: 2 additions & 0 deletions test/com.inuoe.jzon-tests.asd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
:license "MIT"
:components
((:file "jzon-tests"))
:perform
(test-op (o c) (symbol-call '#:com.inuoe.jzon-tests '#:run))
:depends-on
(#:alexandria
#:fiveam
Expand Down
6 changes: 6 additions & 0 deletions test/jzon-tests.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,12 @@
(test stringify-multidimensional-array
(is (string= "[[1,2],[3,4]]" (jzon:stringify #2A((1 2) (3 4))))))

(test stringify-non-square-multidimensional-arrays-2×3
(is (string= "[[0,1,2],[3,4,5]]" (jzon:stringify #2A((0 1 2) (3 4 5))))))

(test stringify-non-square-multidimensional-arrays-3x2
(is (string= "[[0,1],[2,3],[4,5]]" (jzon:stringify #2A((0 1) (2 3) (4 5))))))

(test 0-dimension-array
(is (string= "42" (jzon:stringify #0A42))))

Expand Down

0 comments on commit 062f171

Please sign in to comment.