From 30c146f42e87550155882e2e2434f6507e28c53c Mon Sep 17 00:00:00 2001 From: Bohong Huang Date: Sat, 28 Sep 2024 11:31:40 +0800 Subject: [PATCH 1/2] Fix the incorrect SINGLE-FLOAT literal in the test --- t/encode-decode.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/encode-decode.lisp b/t/encode-decode.lisp index e4c422f..af1b569 100644 --- a/t/encode-decode.lisp +++ b/t/encode-decode.lisp @@ -18,7 +18,7 @@ (cycle (expt 2 31)) (cycle (expt 2 63)) (cycle (expt 2 127)) - (cycle 5s0) + (cycle 5f0) (cycle 10d0) (cycle #C(0 1)) (cycle 1/2) From 48d910e9f2c504d84ddc91a880ea0d80a43a7930 Mon Sep 17 00:00:00 2001 From: Bohong Huang Date: Sat, 28 Sep 2024 11:09:59 +0800 Subject: [PATCH 2/2] Add support for de/serializing pathnames --- cl-conspack.asd | 1 + doc/SPEC | 1 + src/pathname.lisp | 18 ++++++++++++++++++ t/encode-decode.lisp | 4 ++++ 4 files changed, 24 insertions(+) create mode 100644 src/pathname.lisp diff --git a/cl-conspack.asd b/cl-conspack.asd index 6c5292f..773df6f 100644 --- a/cl-conspack.asd +++ b/cl-conspack.asd @@ -27,6 +27,7 @@ (:file "indexes") (:file "tmap") (:file "array") + (:file "pathname") (:file "encode") (:file "decode") (:file "explain"))) diff --git a/doc/SPEC b/doc/SPEC index c2ee943..2062670 100644 --- a/doc/SPEC +++ b/doc/SPEC @@ -21,6 +21,7 @@ Conspack supports the following basic types: - Packages - Symbols - Indexes (i.e., externally-indexed symbols) + - Pathnames Containers can either contain arbitrary objects, which include their header, or a fixed type, which stores only the post-header data diff --git a/src/pathname.lisp b/src/pathname.lisp new file mode 100644 index 0000000..b75c0f1 --- /dev/null +++ b/src/pathname.lisp @@ -0,0 +1,18 @@ +(in-package #:conspack) + +;;;; This defines a simple encoding for pathnames via TMaps. + +(defmethod encode-object append ((object pathname) &key &allow-other-keys) + ;; Note that PATHNAME-HOST and PATHNAME-DEVICE are ignored since the + ;; types of them are implementation-dependent. + `((:directory . ,(pathname-directory object)) + (:name . ,(pathname-name object)) + (:type . ,(pathname-type object)) + (:version . ,(pathname-version object)))) + +(defmethod decode-object-allocate ((class (eql 'pathname)) alist + &key &allow-other-keys) + (apply #'make-pathname (alist-plist alist))) + +(defmethod decode-object-initialize progn ((pathname pathname) class alist &key &allow-other-keys) + (declare (ignore pathname class alist))) diff --git a/t/encode-decode.lisp b/t/encode-decode.lisp index af1b569..752bfbb 100644 --- a/t/encode-decode.lisp +++ b/t/encode-decode.lisp @@ -32,6 +32,10 @@ (cycle "ሰማይ አይታረስ ንጉሥ አይከሰስ።") (cycle "ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ")) +(5am:test pathnames + (cycle #P"path/to/file") + (cycle #P"/path/to/file")) + (5am:test containers (let ((hash (make-hash-table))) (setf (gethash 5 hash) 50