From sross at common-lisp.net Tue Mar 15 09:59:42 2005 From: sross at common-lisp.net (Sean Ross) Date: Tue, 15 Mar 2005 10:59:42 +0100 (CET) Subject: [cl-store-cvs] CVS update: cl-store/ChangeLog cl-store/cl-store.asd cl-store/default-backend.lisp cl-store/tests.lisp cl-store/utils.lisp Message-ID: <20050315095942.ED18F88669@common-lisp.net> Update of /project/cl-store/cvsroot/cl-store In directory common-lisp.net:/tmp/cvs-serv21207 Modified Files: ChangeLog cl-store.asd default-backend.lisp tests.lisp utils.lisp Log Message: Changelog 2005-03-15 Date: Tue Mar 15 10:59:40 2005 Author: sross Index: cl-store/ChangeLog diff -u cl-store/ChangeLog:1.25 cl-store/ChangeLog:1.26 --- cl-store/ChangeLog:1.25 Fri Feb 18 14:51:14 2005 +++ cl-store/ChangeLog Tue Mar 15 10:59:38 2005 @@ -1,3 +1,15 @@ +2005-03-15 Sean Ross + * default-backend.lisp, utils.lisp: Changed reference + to array-dimension-limit in array storing to + array-total-size limit. + * default-backend.lisp: Added an implementation specific + test to determine whether or not a string contains unicode + characters. + +2005-02-26 Sean Ross + * default-backend.lisp: Fixed internal-store-object + for the hash-table class (argument order was messed). + 2005-02-18 Sean Ross Version 0.5 Release. * utils.lisp, package.lisp: Took a lesson from the MOP Index: cl-store/cl-store.asd diff -u cl-store/cl-store.asd:1.24 cl-store/cl-store.asd:1.25 --- cl-store/cl-store.asd:1.24 Fri Feb 18 12:11:00 2005 +++ cl-store/cl-store.asd Tue Mar 15 10:59:39 2005 @@ -40,7 +40,7 @@ :name "CL-STORE" :author "Sean Ross " :maintainer "Sean Ross " - :version "0.5" + :version "0.5.2" :description "Serialization package" :long-description "Portable CL Package to serialize data types" :licence "MIT" Index: cl-store/default-backend.lisp diff -u cl-store/default-backend.lisp:1.23 cl-store/default-backend.lisp:1.24 --- cl-store/default-backend.lisp:1.23 Fri Feb 18 12:11:00 2005 +++ cl-store/default-backend.lisp Tue Mar 15 10:59:39 2005 @@ -418,8 +418,7 @@ (store-object (class-name obj) stream)) #-ecl ;; for some reason this doesn't work with ecl -(defmethod internal-store-object ((obj (eql (find-class 'hash-table))) stream - (backend cl-store)) +(defmethod internal-store-object ((backend cl-store) (obj (eql (find-class 'hash-table))) stream) (output-type-code +built-in-class-code+ stream) (store-object 'cl:hash-table stream)) @@ -462,7 +461,7 @@ :element-type element-type :adjustable adjustable :fill-pointer fill-pointer))) - (declare (type cons dimensions) (type array-size size)) + (declare (type cons dimensions) (type array-tot-size size)) (when displaced-to (adjust-array res dimensions :displaced-to displaced-to :displaced-index-offset displaced-offset)) @@ -497,12 +496,15 @@ (defvar *char-marker* (code-char 255) "Largest character that can be represented in 8 bits") +(defun unicode-string-p (string) + #+lispworks (typep string 'lw:16-bit-string) + #+cmu nil + #-(or lispworks cmu) (some #'(lambda (x) (char> x *char-marker*)) string)) + (defun store-simple-string (obj stream) (declare (type simple-string obj) (optimize speed)) - ;; must be a better test than this. - (cond ((some #'(lambda (x) (char> x *char-marker*)) obj) - ;; contains wide characters + (cond ((unicode-string-p obj) (output-type-code +unicode-string-code+ stream) (dump-string #'dump-int obj stream)) (t (output-type-code +simple-string-code+ stream) Index: cl-store/tests.lisp diff -u cl-store/tests.lisp:1.16 cl-store/tests.lisp:1.17 --- cl-store/tests.lisp:1.16 Fri Feb 18 12:11:00 2005 +++ cl-store/tests.lisp Tue Mar 15 10:59:39 2005 @@ -326,6 +326,11 @@ (deftestit pathname.3 (make-pathname :name "foo" :type "bar")) +; built-in classes +(deftestit built-in.1 (find-class 'hash-table)) +(deftestit built-in.2 (find-class 'integer)) + + ;; circular objects (defvar circ1 (let ((x (list 1 2 3 4))) (setf (cdr (last x)) x))) @@ -497,11 +502,11 @@ (deftestit function.1 #'restores) (deftestit function.2 #'car) -#-(or clisp lispworks allegro openmcl ecl) -(deftestit function.3 #'(setf car)) (deftestit gfunction.1 #'cl-store:restore) (deftestit gfunction.2 #'cl-store:store) +#-clisp +(deftestit gfunction.3 #'(setf get-y)) (deftest nocirc.1 Index: cl-store/utils.lisp diff -u cl-store/utils.lisp:1.14 cl-store/utils.lisp:1.15 --- cl-store/utils.lisp:1.14 Fri Feb 18 12:11:00 2005 +++ cl-store/utils.lisp Tue Mar 15 10:59:39 2005 @@ -86,8 +86,13 @@ `(signed-byte 32)) (deftype array-size () - "The maximum size of an array" - `(integer 0 ,array-dimension-limit)) + "The maximum size of a vector" + `(integer 0 , array-dimension-limit)) + +(deftype array-tot-size () + "The maximum total size of an array" + `(integer 0 , array-total-size-limit)) + (defun store-32-bit (obj stream) From sross at common-lisp.net Thu Mar 17 12:07:59 2005 From: sross at common-lisp.net (Sean Ross) Date: Thu, 17 Mar 2005 13:07:59 +0100 (CET) Subject: [cl-store-cvs] CVS update: cl-store/ChangeLog cl-store/circularities.lisp Message-ID: <20050317120759.5524F8866B@common-lisp.net> Update of /project/cl-store/cvsroot/cl-store In directory common-lisp.net:/tmp/cvs-serv1333 Modified Files: ChangeLog circularities.lisp Log Message: Changelog 2005-03-17 Date: Thu Mar 17 13:07:58 2005 Author: sross Index: cl-store/ChangeLog diff -u cl-store/ChangeLog:1.26 cl-store/ChangeLog:1.27 --- cl-store/ChangeLog:1.26 Tue Mar 15 10:59:38 2005 +++ cl-store/ChangeLog Thu Mar 17 13:07:58 2005 @@ -1,3 +1,7 @@ +2005-03-17 Sean Ross + * doc/cl-store.texi: Fixed up to work + properly with makeinfo. + 2005-03-15 Sean Ross * default-backend.lisp, utils.lisp: Changed reference to array-dimension-limit in array storing to Index: cl-store/circularities.lisp diff -u cl-store/circularities.lisp:1.16 cl-store/circularities.lisp:1.17 --- cl-store/circularities.lisp:1.16 Fri Feb 18 12:10:59 2005 +++ cl-store/circularities.lisp Thu Mar 17 13:07:58 2005 @@ -92,7 +92,7 @@ (defvar *stored-counter*) (defvar *stored-values*) -(defvar *store-hash-size* 1000) +(defvar *store-hash-size* 20) (defmethod backend-store ((backend resolving-backend) (place stream) (obj t)) @@ -148,7 +148,7 @@ (defvar *restore-counter*) (defvar *need-to-fix*) (defvar *restored-values*) -(defvar *restore-hash-size* 1000) +(defvar *restore-hash-size* 20) (defmethod backend-restore ((backend resolving-backend) (place stream)) "Restore an object from PLACE using BACKEND. Does the setup for From sross at common-lisp.net Thu Mar 17 12:08:00 2005 From: sross at common-lisp.net (Sean Ross) Date: Thu, 17 Mar 2005 13:08:00 +0100 (CET) Subject: [cl-store-cvs] CVS update: cl-store/doc/cl-store.texi Message-ID: <20050317120800.8C85688698@common-lisp.net> Update of /project/cl-store/cvsroot/cl-store/doc In directory common-lisp.net:/tmp/cvs-serv1333/doc Modified Files: cl-store.texi Log Message: Changelog 2005-03-17 Date: Thu Mar 17 13:07:59 2005 Author: sross Index: cl-store/doc/cl-store.texi diff -u cl-store/doc/cl-store.texi:1.8 cl-store/doc/cl-store.texi:1.9 --- cl-store/doc/cl-store.texi:1.8 Fri Feb 18 12:11:03 2005 +++ cl-store/doc/cl-store.texi Thu Mar 17 13:07:59 2005 @@ -131,7 +131,7 @@ CL-STORE uses @uref{http://cliki.net/asdf,,asdf} as it's system definition tool and is required whenever you load the package. You will need to download it, or if you have @uref{http://sbcl.org,,sbcl} - at lisp (require 'asdf) @end lisp + at code{(require 'asdf)} @section Downloading @@ -139,7 +139,7 @@ @item ASDF-INSTALL CL-STORE is available through asdf-install. If you are new to Common Lisp this is the suggested download method. With asdf-install loaded run - at lisp (asdf-install:install :cl-store) @end lisp + at code{(asdf-install:install :cl-store)} This will download and install the package for you. Asdf-install will try to verify that the package signature is correct and that you trust the author. If the key is not found or the trust level is not sufficient a continuable error will be signalled. @@ -163,16 +163,14 @@ @section Installing Once downloaded and symlinked you can load CL-STORE at anytime using - at lisp (asdf:oos 'asdf:load-op :cl-store) @end lisp + at code{(asdf:oos 'asdf:load-op :cl-store)} This will compile CL-STORE the first time it is loaded. @section Testing Once installed you can run the regression tests for it. The tests depend on the @uref{http://cliki.net/rt,,Regression Tests} asdf package which is asdf-installable. The tests can be run be executing - at lisp -(asdf:oos 'asdf:test-op :cl-store) - at end lisp + at code{(asdf:oos 'asdf:test-op :cl-store)} If any tests fail please send a message to one of the Mailing Lists. @@ -181,21 +179,21 @@ @chapter API @section Variables - at anchor {Variable *nuke-existing-classes*} + at anchor{Variable *nuke-existing-classes*} @vindex *nuke-existing-classes* @deftp {Variable} *nuke-existing-classes* @emph{Default NIL} Determines wether or not to override existing classes when restoring a CLOS Class. If @code{*nuke-existing-classes*} is not NIL the current definition will be overridden. @end deftp - at anchor {Variable *store-class-superclasses*} + at anchor{Variable *store-class-superclasses*} @vindex *store-class-superclasses* @deftp {Variable} *store-class-superclasses* @emph{Default NIL} If @code{*store-class-superclasses*} is not NIL when storing a CLOS Class all superclasses will be stored. @end deftp - at anchor {Variable *store-class-slots*} + at anchor{Variable *store-class-slots*} @vindex *store-class-slots* @deftp {Variable} *store-class-slots* @emph{Default T} If @code{*store-class-slots*} is NIL slots which are class allocated will @@ -203,14 +201,14 @@ @end deftp - at anchor {Variable *nuke-existing-packages*} + at anchor{Variable *nuke-existing-packages*} @vindex *nuke-existing-packages* @deftp {Variable} *nuke-existing-packages* @emph{Default NIL} If @code{*nuke-existing-packages*} is non-nil then packages which already exist will be deleted when restoring packages. @end deftp - at anchor {Variable *store-used-packages*} + at anchor{Variable *store-used-packages*} @vindex *store-used-packages* @deftp {Variable} *store-used-packages* @emph{Default NIL} The variable determines the how packages on a package use @@ -218,7 +216,7 @@ be fully serialized, otherwise only the name will be stored. @end deftp - at anchor {Variable *store-hash-size*} + at anchor{Variable *store-hash-size*} @vindex *store-hash-size* @deftp {Variable} *store-hash-size* @emph{Default 1000} The default size of the hash-table created to keep track of @@ -227,7 +225,7 @@ involved by rehashing hash-tables. @end deftp - at anchor {Variable *restore-hash-size*} + at anchor{Variable *restore-hash-size*} @vindex *restore-hash-size* @deftp {Variable} *restore-hash-size* @emph{Default 1000} The default size of the hash-table created to keep track of @@ -237,7 +235,7 @@ @end deftp - at anchor {Variable *check-for-circs*} + at anchor{Variable *check-for-circs*} @vindex *check-for-circs* @deftp {Variable} *check-for-circs* @emph{Default t} Binding this variable to nil when storing or restoring @@ -249,7 +247,7 @@ your data (eg spam-filter hash-tables). @end deftp - at anchor {Variable *default-backend*} + at anchor{Variable *default-backend*} @vindex *default-backend* @deftp {Variable} *default-backend* The backend that will be used by default. @@ -257,7 +255,7 @@ @section Functions - at anchor {Generic store} + at anchor{Generic store} @deffn {Generic} store object place &optional (backend *default-backend*) Stores @emph{object} into @emph{place} using @emph{backend}. @emph{Place} must be either a @code{stream} or a @code{pathname-designator}. All @@ -265,7 +263,7 @@ If the @code{store-error} is not handled the causing error will be signalled. @end deffn - at anchor {Generic restore} + at anchor{Generic restore} @deffn {Generic} restore place &optional (backend *default-backend*) Restores an object serialized using @code{store} from @emph{place} using @emph{backend}. @emph{Place} must be either a @code{stream} or a @code{pathname-designator}. @@ -279,19 +277,19 @@ @end deffn - at anchor {Function find-backend} + at anchor{Function find-backend} @deffn {Function} find-backend name Returns the backend named by @emph{name} or nil if it does not exist. @end deffn - at anchor {Function caused-by} + at anchor{Function caused-by} @deffn {Function} caused-by cl-store-error Returns the @code{condition} which caused @code{cl-store-error} to be signalled. @end deffn @section Macros - at anchor {Macro with-backend} + at anchor{Macro with-backend} @deffn {Macro} with-backend backend &body body Execute @emph{body} with @code{*default-backend*} bound to the backend designated by @emph{backend}. @@ -299,7 +297,7 @@ @section Conditions - at anchor {Condition cl-store-error} + at anchor{Condition cl-store-error} @deftp {Condition} cl-store-error Class Precedence: @code{condition} @@ -307,22 +305,22 @@ can be handled by catching @code{cl-store-error} @end deftp - at anchor {Condition store-error} + at anchor{Condition store-error} @deftp {Condition} store-error Class Precedence: @code{cl-store-error} A @code{store-error} will be signalled when an error occurs within @code{store} or @code{multiple-value-store}. The causing error can be -obtained using @lisp (caused-by condition) @end lisp +obtained using @code{(caused-by condition)} @end deftp - at anchor {Condition restore-error} + at anchor{Condition restore-error} @deftp {Condition} restore-error Class Precedence: @code{cl-store-error} A @code{restore-error} will be signalled when an error occurs within @code{restore}. The causing error can be obtained using - at lisp (caused-by condition) @end lisp + at code{(caused-by condition)} @end deftp @@ -377,7 +375,7 @@ will be similar in structure. @subsection Functions - at anchor {Function register-code} + at anchor{Function register-code} @deffn {Function} register-code code name &optional (errorp t) Registers @emph{name} under the code @emph{code} into the cl-store-backend. The backend will use this mapping when restoring values. @@ -385,50 +383,50 @@ Currently codes 1 through 33 are in use. @end deffn - at anchor {Function output-type-code} + at anchor{Function output-type-code} @deffn {Function} output-type-code type-code stream Writes @emph{type-code} into @emph{stream}. This must be done when writing out objects so that the type of the object can be identified on deserialization. @end deffn - at anchor {Function store-32-bit} + at anchor{Function store-32-bit} @deffn {Function} store-32-bit integer stream Outputs the the low 32 bits from @emph{integer} into @emph{stream}. @end deffn - at anchor {Function read-32-bit} + at anchor{Function read-32-bit} @deffn {Function} read-32-bit stream Reads a 32-bit integer from @emph{stream}. @end deffn - at anchor {Generic store-object} + at anchor{Generic store-object} @deffn {Generic} store-object object place Stores @emph{object} into @emph{place}. This should be used inside @code{defstore-cl-store} to output parts of objects. @code{store} should not be used. @end deffn - at anchor {Generic restore-object} + at anchor{Generic restore-object} @deffn {Generic} restore-object place Restore an object, written out using @code{store-object} from @emph{place}. @end deffn - at anchor {Generic get-slot-details} + at anchor{Generic get-slot-details} @deffn {Generic} get-slot-details slot-definition Generic function which returns a list of slots details which can be used as an argument to @code{ensure-class}. Currently it is only specialized on slot-definition @end deffn - at anchor {Generic serializable-slots} + at anchor{Generic serializable-slots} @deffn {Generic} serializable-slots object Method which returns a list of slot-definition objects which will be serialized for @emph{object}. The default is to call @code{serializable-slots-using-class}. @end deffn - at anchor {Generic serializable-slots-using-class} + at anchor{Generic serializable-slots-using-class} @deffn {Generic} serializable-slots-using-class object class Returns a list of slot-definition objects which will be serialized for object and class. @@ -449,7 +447,7 @@ @vskip 0pt plus 1filll @subsection Macros - at anchor {Macro defstore-cl-store} + at anchor{Macro defstore-cl-store} @deffn {Macro} defstore-cl-store (var type stream &key qualifier) &body body Create a custom storing mechanism for @emph{type} which must be a legal Class Name. @emph{Body} will be called when an object of class @emph{type} @@ -466,7 +464,7 @@ @end lisp @end deffn - at anchor {Macro defrestore-cl-store} + at anchor{Macro defrestore-cl-store} @deffn {Macro} defrestore-cl-store (type stream) &body body Create a custom restoring mechanism for the @emph{type} registered using @code{register-code}. at emph{Body} will be executed with @@ -480,7 +478,7 @@ @end lisp @end deffn - at anchor {Macro resolving-object} + at anchor{Macro resolving-object} @deffn {Macro} resolving-object (var create) &body body Executes @emph{body} resolving circularities detected in @emph{object}. Resolving-object works by creating a closure, containing code to set a @@ -498,7 +496,7 @@ @vskip 0pt plus 1filll - at anchor {Macro setting} + at anchor{Macro setting} @deffn {Macro} setting place get This macro can only be used inside @code{resolving-object}. It sets the value designated by @emph{place} to @emph{get} for the object that is being resolved. @@ -518,7 +516,7 @@ @end lisp @end deffn - at anchor {Macro setting-hash} + at anchor{Macro setting-hash} @deffn {Macro} setting-hash getting-key getting-value @code{setting-hash} works identically to setting although it is used exclusively on hash-tables due to the fact that both the key and the value @@ -692,33 +690,33 @@ @section API @subsection Functions - at anchor {Generic backend-restore} + at anchor{Generic backend-restore} @deffn {Generic} backend-restore backend place Restore the object found in stream @emph{place} using backend @emph{backend}. Checks the magic-number and invokes @code{backend-restore-object}. Called by @code{restore}, override for custom restoring. @end deffn - at anchor {Generic backend-restore-object} + at anchor{Generic backend-restore-object} @deffn {Generic} backend-restore backend place Find the next function to call to restore the next object with @emph{backend} and invoke it with @emph{place}. Called by @code{restore-object}, override this method to do custom restoring (see @file{circularities.lisp} for an example). @end deffn - at anchor {Generic backend-store} + at anchor{Generic backend-store} @deffn {Generic} backend-store backend place obj Stores the backend code and calls @code{store-object}. This is called by @code{store}. Override for custom storing. @end deffn - at anchor {Generic backend-store-object} + at anchor{Generic backend-store-object} @deffn {Generic} backend-store-object backend obj place Called by @code{store-object}, override this to do custom storing (see @file{circularities.lisp} for an example). @end deffn - at anchor {Generic get-next-reader} + at anchor{Generic get-next-reader} @deffn {Generic} get-next-reader backend place Method which must be specialized for @emph{backend} to return the next symbol designating a @code{defrestore} instance to restore an object from @emph{place}. @@ -727,9 +725,9 @@ @subsection Macros - at anchor {Macro defbackend} + at anchor{Macro defbackend} @deffn {Macro} defbackend name &key (stream-type (required-arg "stream-type")) magic-number fields (extends 'backend) old-magic-numbers -eg. @lisp (defbackend pickle :stream-type 'character) @end lisp +eg. @code{(defbackend pickle :stream-type 'character)} This creates a new backend called @emph{name}, @emph{stream-type} describes the type of stream that the backend will serialize to which must be suitable as an argument to open. @emph{Magic-number}, when present, must be of type (unsigned-byte 32) which will be written as a verifier for the backend. @emph{Fields} are extra fields to be From sross at common-lisp.net Wed Mar 23 12:58:47 2005 From: sross at common-lisp.net (Sean Ross) Date: Wed, 23 Mar 2005 13:58:47 +0100 (CET) Subject: [cl-store-cvs] CVS update: cl-store/ChangeLog cl-store/backends.lisp cl-store/circularities.lisp cl-store/cl-store.asd cl-store/default-backend.lisp cl-store/plumbing.lisp cl-store/tests.lisp Message-ID: <20050323125847.034978866D@common-lisp.net> Update of /project/cl-store/cvsroot/cl-store In directory common-lisp.net:/tmp/cvs-serv19156 Modified Files: ChangeLog backends.lisp circularities.lisp cl-store.asd default-backend.lisp plumbing.lisp tests.lisp Log Message: Changelog 2005-03-23 Date: Wed Mar 23 13:58:43 2005 Author: sross Index: cl-store/ChangeLog diff -u cl-store/ChangeLog:1.27 cl-store/ChangeLog:1.28 --- cl-store/ChangeLog:1.27 Thu Mar 17 13:07:58 2005 +++ cl-store/ChangeLog Wed Mar 23 13:58:43 2005 @@ -1,6 +1,12 @@ +2005-03-23 Sean Ross + * backends.lisp: Fix up for type specifications + for the old-magic-numbers and stream-type slots + for class backend. + * circularities.lisp: Changed *store-hash-size* and + *restore-hash-size* to more reasonable values (50). + 2005-03-17 Sean Ross - * doc/cl-store.texi: Fixed up to work - properly with makeinfo. + * doc/cl-store.texi: Fixed up to work properly with makeinfo. 2005-03-15 Sean Ross * default-backend.lisp, utils.lisp: Changed reference Index: cl-store/backends.lisp diff -u cl-store/backends.lisp:1.8 cl-store/backends.lisp:1.9 --- cl-store/backends.lisp:1.8 Fri Feb 11 13:00:31 2005 +++ cl-store/backends.lisp Wed Mar 23 13:58:43 2005 @@ -15,8 +15,8 @@ ((name :accessor name :initform "Unknown" :initarg :name :type symbol) (magic-number :accessor magic-number :initarg :magic-number :type integer) (old-magic-numbers :accessor old-magic-numbers :initarg :old-magic-numbers - :type integer) - (stream-type :accessor stream-type :initarg :stream-type :type symbol + :type cons) + (stream-type :accessor stream-type :initarg :stream-type :type (or symbol cons) :initform (required-arg "stream-type"))) (:documentation "Core class which custom backends must extend")) Index: cl-store/circularities.lisp diff -u cl-store/circularities.lisp:1.17 cl-store/circularities.lisp:1.18 --- cl-store/circularities.lisp:1.17 Thu Mar 17 13:07:58 2005 +++ cl-store/circularities.lisp Wed Mar 23 13:58:43 2005 @@ -92,7 +92,7 @@ (defvar *stored-counter*) (defvar *stored-values*) -(defvar *store-hash-size* 20) +(defvar *store-hash-size* 50) (defmethod backend-store ((backend resolving-backend) (place stream) (obj t)) @@ -148,7 +148,7 @@ (defvar *restore-counter*) (defvar *need-to-fix*) (defvar *restored-values*) -(defvar *restore-hash-size* 20) +(defvar *restore-hash-size* 50) (defmethod backend-restore ((backend resolving-backend) (place stream)) "Restore an object from PLACE using BACKEND. Does the setup for Index: cl-store/cl-store.asd diff -u cl-store/cl-store.asd:1.25 cl-store/cl-store.asd:1.26 --- cl-store/cl-store.asd:1.25 Tue Mar 15 10:59:39 2005 +++ cl-store/cl-store.asd Wed Mar 23 13:58:43 2005 @@ -40,7 +40,7 @@ :name "CL-STORE" :author "Sean Ross " :maintainer "Sean Ross " - :version "0.5.2" + :version "0.5.4" :description "Serialization package" :long-description "Portable CL Package to serialize data types" :licence "MIT" Index: cl-store/default-backend.lisp diff -u cl-store/default-backend.lisp:1.24 cl-store/default-backend.lisp:1.25 --- cl-store/default-backend.lisp:1.24 Tue Mar 15 10:59:39 2005 +++ cl-store/default-backend.lisp Wed Mar 23 13:58:43 2005 @@ -483,11 +483,11 @@ (res (make-array size))) (declare (type array-size size)) (resolving-object (obj res) - (loop for i from 0 to (1- size) do - ;; we need to copy the index so that - ;; it's value is preserved for after the loop. - (let ((x i)) - (setting (aref obj x) (restore-object stream))))) + (dotimes (i size) + ;; we need to copy the index so that + ;; it's value at this time is preserved. + (let ((x i)) + (setting (aref obj x) (restore-object stream))))) res)) ;; Dumping (unsigned-byte 32) for each character seems @@ -497,6 +497,7 @@ "Largest character that can be represented in 8 bits") (defun unicode-string-p (string) + "An implementation specific test for a unicode string." #+lispworks (typep string 'lw:16-bit-string) #+cmu nil #-(or lispworks cmu) (some #'(lambda (x) (char> x *char-marker*)) string)) Index: cl-store/plumbing.lisp diff -u cl-store/plumbing.lisp:1.12 cl-store/plumbing.lisp:1.13 --- cl-store/plumbing.lisp:1.12 Fri Feb 18 12:11:00 2005 +++ cl-store/plumbing.lisp Wed Mar 23 13:58:43 2005 @@ -160,11 +160,6 @@ (with-open-file (s place :element-type element-type :direction :input) (backend-restore backend s)))) -(defclass values-object () - ((vals :accessor vals :initarg :vals)) - (:documentation "Backends supporting multiple return values -should define a custom storer and restorer for this class")); - (defun (setf restore) (new-val place) (store new-val place)) @@ -177,7 +172,7 @@ (declare (type ub32 val)) (cond ((= val magic-number) nil) ((member val (old-magic-numbers backend) :test #'=) - (restore-error "Stream contains an object stored with a ~ + (restore-error "Stream contains an object stored with an ~ incompatible version of backend ~A." (name backend))) (t (restore-error "Stream does not contain a stored object~ for backend ~A." Index: cl-store/tests.lisp diff -u cl-store/tests.lisp:1.17 cl-store/tests.lisp:1.18 --- cl-store/tests.lisp:1.17 Tue Mar 15 10:59:39 2005 +++ cl-store/tests.lisp Wed Mar 23 13:58:43 2005 @@ -159,6 +159,13 @@ (deftestit symbol.4 'cl-store-tests::foo) (deftestit symbol.5 'make-hash-table) +(deftest gensym.1 (progn + (store (gensym "Foobar") *test-file*) + (let ((new (restore *test-file*))) + (list (symbol-package new) + (mismatch "Foobar" (symbol-name new))))) + (nil 6)) + ;; cons @@ -210,7 +217,7 @@ (make-array 1 :initial-element (find-symbol "BAR" "FOO"))))) ; unfortunately it's difficult to portably test the internal symbols -; in a package so we just have to assume that it's OK. +; in a package so we just assume that it's OK. (deftest package.2 (package-restores) ("FOO" ("COMMON-LISP") ("FOOBAR") t t)) From sross at common-lisp.net Thu Mar 24 08:25:20 2005 From: sross at common-lisp.net (Sean Ross) Date: Thu, 24 Mar 2005 09:25:20 +0100 (CET) Subject: [cl-store-cvs] CVS update: cl-store/ChangeLog cl-store/circularities.lisp cl-store/cl-store.asd cl-store/default-backend.lisp cl-store/package.lisp cl-store/plumbing.lisp cl-store/tests.lisp Message-ID: <20050324082520.182F688678@common-lisp.net> Update of /project/cl-store/cvsroot/cl-store In directory common-lisp.net:/tmp/cvs-serv21588 Modified Files: ChangeLog circularities.lisp cl-store.asd default-backend.lisp package.lisp plumbing.lisp tests.lisp Log Message: Changelog 2005-03-24 Date: Thu Mar 24 09:25:17 2005 Author: sross Index: cl-store/ChangeLog diff -u cl-store/ChangeLog:1.28 cl-store/ChangeLog:1.29 --- cl-store/ChangeLog:1.28 Wed Mar 23 13:58:43 2005 +++ cl-store/ChangeLog Thu Mar 24 09:25:16 2005 @@ -1,3 +1,12 @@ +2005-03-24 Sean Ross + * backends.lisp, circularities.lisp, tests.lisp: + Added test gensym.2 which crashed in previous + versions (pre 0.5.7). Symbols are now tested + for equality when storing. + int-sym-or-char-p renamed to int-or-char-p. + * plumbing.lisp: Added error to the superclasses + of restore-error and store-error. + 2005-03-23 Sean Ross * backends.lisp: Fix up for type specifications for the old-magic-numbers and stream-type slots Index: cl-store/circularities.lisp diff -u cl-store/circularities.lisp:1.18 cl-store/circularities.lisp:1.19 --- cl-store/circularities.lisp:1.18 Wed Mar 23 13:58:43 2005 +++ cl-store/circularities.lisp Thu Mar 24 09:25:17 2005 @@ -116,7 +116,7 @@ (deftype not-circ () "Type grouping integer, characters and symbols, which we don't bother to check if they have been stored before" - '(or integer character symbol)) + '(or integer character)) (defun needs-checkp (obj) "Do we need to check if this object has been stored before?" @@ -131,9 +131,10 @@ (defun get-ref (obj) (if (needs-checkp obj) - (aif (seen obj) - it - (update-seen obj)) + (multiple-value-bind (val win) (seen obj) + (if (or val win) + val + (update-seen obj))) nil)) (defmethod backend-store-object ((backend resolving-backend) (obj t) (place t)) @@ -179,7 +180,7 @@ (cond ((referrerp backend reader) (incf *restore-counter*) (new-val (internal-restore-object backend reader place))) - ((not (int-sym-or-char-p backend reader)) + ((not (int-or-char-p backend reader)) (handle-normal backend reader place)) (t (new-val (internal-restore-object backend reader place)))))) @@ -189,18 +190,25 @@ (handle-restore place backend) (call-next-method))) -(defgeneric int-sym-or-char-p (backend fn) +; This used to be called int-sym-or-char-p +; but was renamed to handle eq symbols (gensym's mainly). +; The basic concept is that we don't bother +; checking for circularities with integers or +; characters since these aren't gauraunteed to be eq +; even if they are the same object. +; (notes for eq in CLHS). +(defgeneric int-or-char-p (backend fn) (:method ((backend backend) (fn symbol)) - "Is function FN registered to restore an integer, character or symbol - in BACKEND." - (member fn '(integer character symbol)))) + "Is function FN registered to restore an integer or character in BACKEND." + (member fn '(integer character)))) (defun new-val (val) "Tries to get a referred value to reduce unnecessary cirularity fixing." (if (referrer-p val) - (aif (referred-value val *restored-values*) - it - val) + (multiple-value-bind (new-val win) (referred-value val *restored-values*) + (if (or new-val win) + new-val + val)) val)) ;; EOF Index: cl-store/cl-store.asd diff -u cl-store/cl-store.asd:1.26 cl-store/cl-store.asd:1.27 --- cl-store/cl-store.asd:1.26 Wed Mar 23 13:58:43 2005 +++ cl-store/cl-store.asd Thu Mar 24 09:25:17 2005 @@ -40,7 +40,7 @@ :name "CL-STORE" :author "Sean Ross " :maintainer "Sean Ross " - :version "0.5.4" + :version "0.5.8" :description "Serialization package" :long-description "Portable CL Package to serialize data types" :licence "MIT" Index: cl-store/default-backend.lisp diff -u cl-store/default-backend.lisp:1.25 cl-store/default-backend.lisp:1.26 --- cl-store/default-backend.lisp:1.25 Wed Mar 23 13:58:43 2005 +++ cl-store/default-backend.lisp Thu Mar 24 09:25:17 2005 @@ -103,8 +103,8 @@ ;; so we we have a little optimization for it ;; We need this for circularity stuff. -(defmethod int-sym-or-char-p ((backend cl-store) (type symbol)) - (find type '(integer character 32-bit-integer symbol))) +(defmethod int-or-char-p ((backend cl-store) (type symbol)) + (find type '(integer character 32-bit-integer))) (defstore-cl-store (obj integer stream) (if (typep obj 'sb32) @@ -545,8 +545,8 @@ (store-object (mapcar (if *store-used-packages* #'identity #'package-name) (package-use-list obj)) stream) - (store-object (package-shadowing-symbols obj) stream) (store-object (internal-symbols obj) stream) + (store-object (package-shadowing-symbols obj) stream) (store-object (external-symbols obj) stream)) (defun remove-remaining (times stream) @@ -578,14 +578,14 @@ acc)) (defun restore-package (package-name stream &key force) - (when force + (when (and force (find-package package-name)) (delete-package package-name)) (let ((package (make-package package-name :nicknames (restore-object stream) :use (restore-object stream)))) - (shadow (restore-object stream) package) (loop for symbol across (restore-object stream) do (import symbol package)) + (shadow (restore-object stream) package) (loop for symbol across (restore-object stream) do (export symbol package)) package)) Index: cl-store/package.lisp diff -u cl-store/package.lisp:1.20 cl-store/package.lisp:1.21 --- cl-store/package.lisp:1.20 Fri Feb 18 09:15:49 2005 +++ cl-store/package.lisp Thu Mar 24 09:25:17 2005 @@ -13,7 +13,7 @@ #:restore #:backend-store #:store-backend-code #:store-object #:backend-store-object #:get-class-details #:get-array-values #:restore #:backend-restore #:cl-store #:referrerp - #:check-magic-number #:get-next-reader #:int-sym-or-char-p + #:check-magic-number #:get-next-reader #:int-or-char-p #:restore-object #:backend-restore-object #:serializable-slots #:defstore-cl-store #:defrestore-cl-store #:register-code #:output-type-code #:store-referrer #:resolving-object Index: cl-store/plumbing.lisp diff -u cl-store/plumbing.lisp:1.13 cl-store/plumbing.lisp:1.14 --- cl-store/plumbing.lisp:1.13 Wed Mar 23 13:58:43 2005 +++ cl-store/plumbing.lisp Thu Mar 24 09:25:17 2005 @@ -45,11 +45,11 @@ (:report cl-store-report) (:documentation "Root cl-store condition")) -(define-condition store-error (cl-store-error) +(define-condition store-error (error cl-store-error) () (:documentation "Error thrown when storing an object fails.")) -(define-condition restore-error (cl-store-error) +(define-condition restore-error (error cl-store-error) () (:documentation "Error thrown when restoring an object fails.")) Index: cl-store/tests.lisp diff -u cl-store/tests.lisp:1.18 cl-store/tests.lisp:1.19 --- cl-store/tests.lisp:1.18 Wed Mar 23 13:58:43 2005 +++ cl-store/tests.lisp Thu Mar 24 09:25:17 2005 @@ -166,6 +166,13 @@ (mismatch "Foobar" (symbol-name new))))) (nil 6)) +; This failed in cl-store < 0.5.5 +(deftest gensym.2 (let ((x (gensym))) + (store (list x x) *test-file*) + (let ((new (restore *test-file*))) + (eq (car new) (cadr new)))) + t) + ;; cons @@ -205,16 +212,17 @@ (:export bar)) (defun package-restores () - (store (find-package :foo) *test-file*) - (delete-package :foo) - (restore *test-file*) - (list (package-name (find-package :foo)) - (mapcar #'package-name (package-use-list :foo)) - (package-nicknames :foo) - (equalp (remove-duplicates (package-shadowing-symbols :foo)) - (list (find-symbol "FORMAT" "FOO"))) - (equalp (cl-store::external-symbols (find-package :foo)) - (make-array 1 :initial-element (find-symbol "BAR" "FOO"))))) + (let (( *nuke-existing-packages* t)) + (store (find-package :foo) *test-file*) + (delete-package :foo) + (restore *test-file*) + (list (package-name (find-package :foo)) + (mapcar #'package-name (package-use-list :foo)) + (package-nicknames :foo) + (equalp (remove-duplicates (package-shadowing-symbols :foo)) + (list (find-symbol "FORMAT" "FOO"))) + (equalp (cl-store::external-symbols (find-package :foo)) + (make-array 1 :initial-element (find-symbol "BAR" "FOO")))))) ; unfortunately it's difficult to portably test the internal symbols ; in a package so we just assume that it's OK. From sross at common-lisp.net Thu Mar 24 08:25:22 2005 From: sross at common-lisp.net (Sean Ross) Date: Thu, 24 Mar 2005 09:25:22 +0100 (CET) Subject: [cl-store-cvs] CVS update: cl-store/doc/cl-store.texi Message-ID: <20050324082522.CA481886F9@common-lisp.net> Update of /project/cl-store/cvsroot/cl-store/doc In directory common-lisp.net:/tmp/cvs-serv21588/doc Modified Files: cl-store.texi Log Message: Changelog 2005-03-24 Date: Thu Mar 24 09:25:20 2005 Author: sross Index: cl-store/doc/cl-store.texi diff -u cl-store/doc/cl-store.texi:1.9 cl-store/doc/cl-store.texi:1.10 --- cl-store/doc/cl-store.texi:1.9 Thu Mar 17 13:07:59 2005 +++ cl-store/doc/cl-store.texi Thu Mar 24 09:25:20 2005 @@ -218,7 +218,7 @@ @anchor{Variable *store-hash-size*} @vindex *store-hash-size* - at deftp {Variable} *store-hash-size* @emph{Default 1000} + at deftp {Variable} *store-hash-size* @emph{Default 50} The default size of the hash-table created to keep track of objects which have already been stored. By binding the variable to a suitable value you can avoid the consing @@ -227,7 +227,7 @@ @anchor{Variable *restore-hash-size*} @vindex *restore-hash-size* - at deftp {Variable} *restore-hash-size* @emph{Default 1000} + at deftp {Variable} *restore-hash-size* @emph{Default 50} The default size of the hash-table created to keep track of objects which have already been restored. By binding the variable to a suitable value you can avoid the consing From sross at common-lisp.net Thu Mar 24 08:29:50 2005 From: sross at common-lisp.net (Sean Ross) Date: Thu, 24 Mar 2005 09:29:50 +0100 (CET) Subject: [cl-store-cvs] CVS update: cl-store/ChangeLog cl-store/circularities.lisp Message-ID: <20050324082950.A5F6E88678@common-lisp.net> Update of /project/cl-store/cvsroot/cl-store In directory common-lisp.net:/tmp/cvs-serv21713 Modified Files: ChangeLog circularities.lisp Log Message: Changelog 2005-03-24 Date: Thu Mar 24 09:29:49 2005 Author: sross Index: cl-store/ChangeLog diff -u cl-store/ChangeLog:1.29 cl-store/ChangeLog:1.30 --- cl-store/ChangeLog:1.29 Thu Mar 24 09:25:16 2005 +++ cl-store/ChangeLog Thu Mar 24 09:29:48 2005 @@ -10,7 +10,7 @@ 2005-03-23 Sean Ross * backends.lisp: Fix up for type specifications for the old-magic-numbers and stream-type slots - for class backend. + for class backend, reported by Kilian Sprotte. * circularities.lisp: Changed *store-hash-size* and *restore-hash-size* to more reasonable values (50). Index: cl-store/circularities.lisp diff -u cl-store/circularities.lisp:1.19 cl-store/circularities.lisp:1.20 --- cl-store/circularities.lisp:1.19 Thu Mar 24 09:25:17 2005 +++ cl-store/circularities.lisp Thu Mar 24 09:29:48 2005 @@ -114,7 +114,7 @@ nil) (deftype not-circ () - "Type grouping integer, characters and symbols, which we + "Type grouping integers and characters, which we don't bother to check if they have been stored before" '(or integer character)) @@ -194,7 +194,7 @@ ; but was renamed to handle eq symbols (gensym's mainly). ; The basic concept is that we don't bother ; checking for circularities with integers or -; characters since these aren't gauraunteed to be eq +; characters since these aren't gauranteed to be eq ; even if they are the same object. ; (notes for eq in CLHS). (defgeneric int-or-char-p (backend fn) From sross at common-lisp.net Thu Mar 24 08:46:34 2005 From: sross at common-lisp.net (Sean Ross) Date: Thu, 24 Mar 2005 09:46:34 +0100 (CET) Subject: [cl-store-cvs] CVS update: cl-store/README Message-ID: <20050324084634.2DF7588678@common-lisp.net> Update of /project/cl-store/cvsroot/cl-store In directory common-lisp.net:/tmp/cvs-serv22998 Modified Files: README Log Message: Changelog 2005-03-24 Date: Thu Mar 24 09:46:33 2005 Author: sross Index: cl-store/README diff -u cl-store/README:1.14 cl-store/README:1.15 --- cl-store/README:1.14 Thu Dec 2 11:31:54 2004 +++ cl-store/README Thu Mar 24 09:46:32 2005 @@ -1,7 +1,7 @@ README for Package CL-STORE. Author: Sean Ross Homepage: http://www.common-lisp.net/project/cl-store/ -Version: 0.4.2 +Version: 0.5.8 0. About. CL-STORE is an portable serialization package which @@ -13,7 +13,7 @@ 1. Usage The main entry points are - - [Method] cl-store:store (obj place &optional (backend *default-backend*)) i + - [Method] cl-store:store (obj place &optional (backend *default-backend*)) => obj Where place is a path designator or stream and backend is one of the registered backends. @@ -22,10 +22,6 @@ => restored-objects Where place and backend is as above. - - [Macro] cl-store:multiple-value-store (values-form place &optional (backend *default-backend*)) - => objects - Stores all the values returned by VALUES-FORM into place as per cl-store:store. - - cl-store:restore is setfable, which I think makes for a great serialized hit counter. eg. (incf (restore place)) @@ -45,7 +41,7 @@ - *store-hash-size* and *restore-hash-size At the beginning of storing and restoring an eq hash-table is created with a - default size of 1000 to track objects which have been (re)stored. On large objects however + default size of 50 to track objects which have been (re)stored. On large objects however the rehashing of these hash-tables imposes a severe drain on performance. By binding these two variables to appropriately large values about (100010 for a hash-table with 100000 int->string mappings) you