Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cl-conspack.asd
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
(:file "indexes")
(:file "tmap")
(:file "array")
(:file "pathname")
(:file "encode")
(:file "decode")
(:file "explain")))
1 change: 1 addition & 0 deletions doc/SPEC
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/pathname.lisp
Original file line number Diff line number Diff line change
@@ -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)))
6 changes: 5 additions & 1 deletion t/encode-decode.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down