changeset 6:2d904b2f35ff tip

add support for doubles, depend on parse-number
author John Leuner <jewel@subvert-the-dominant-paradigm.net>
date Mon, 02 Jun 2008 02:46:39 +0530
parents 10bb32fe1122
children
files lisp/slurp.asd lisp/slurp.lisp
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/slurp.asd	Thu May 29 05:08:30 2008 +0530
+++ b/lisp/slurp.asd	Mon Jun 02 02:46:39 2008 +0530
@@ -4,5 +4,5 @@
   :author "John Leuner"
   :licence "MIT License"
   :components ((:file "slurp" ))
-  :depends-on (flexi-streams))
+  :depends-on (flexi-streams parse-number))
 
--- a/lisp/slurp.lisp	Thu May 29 05:08:30 2008 +0530
+++ b/lisp/slurp.lisp	Mon Jun 02 02:46:39 2008 +0530
@@ -13,11 +13,13 @@
 (defconstant +unsigned-integer+ 2)
 (defconstant +signed-integer+ 3)
 (defconstant +unicode-string+ 4)
+(defconstant +real+ 5)
 (defconstant +cons+ 7)
 (defconstant +key-value+ 8)
 (defconstant +nil+ 9)
 (defconstant +object+ 10) ; used for object array
 
+
 (defconstant +array-mask+ 16)
 
 (defconstant +byte-array+ (logior +byte+ +array-mask+))
@@ -135,6 +137,9 @@
 			 ))
 	    (integer (progn (write-datum stream +unsigned-integer+ +unsigned-integer+)
 			    (write-datum stream +unsigned-integer+ object)))
+	    (real (progn
+		    (write-datum stream +unsigned-integer+ +real+)
+		    (write-datum stream +unicode-string+ (format nil "~S" object))))
 	    (symbol (progn (write-datum stream +unsigned-integer+ +unicode-string+)
 			   (write-datum stream +unicode-string+ (string object))))
 	    (string (progn (write-datum stream +unsigned-integer+ +unicode-string+)
@@ -287,6 +292,9 @@
 (defmethod read-datum (stream (data-type (eql +byte+)))
   (read-byte stream))
 
+(defmethod read-datum (stream (data-type (eql +real+)))
+  (parse-number:parse-real-number (read-datum stream +unicode-string+)))
+
 (defmethod write-datum (stream (data-type (eql +byte+)) obj)
   (write-byte obj stream))