Commits

Leslie P. Polzer  committed 5e5b02d

Applied Ian Eslick's patch for custom serialization and deserialization of user data types.

Adapted from http://common-lisp.net/pipermail/cl-prevalence-devel/2009-February/000108.html

  • Participants
  • Parent commits 8296e11

Comments (0)

Files changed (1)

File src/serialization/xml.lisp

 		       (test (read-from-string (get-attribute-value :test attributes)))
 		       (size (parse-integer (get-attribute-value :size attributes))))
 		   (setf (gethash id *deserialized-objects*)
-			 (make-hash-table :test test :size size)))))
+			 (make-hash-table :test test :size size))))
+    (t (deserialize-xml-new-element-aux name attributes)))
   '())
 
+(defgeneric deserialize-xml-new-element-aux (name attributes)
+  (:documentation "Extend with your own types by overloading serialize-xml-internal
+                   and implementing deserialize aux functions")
+  (:method (name attributes)
+    (declare (ignore name attributes))
+    nil))
+
 (defun deserialize-xml-finish-element (name attributes parent-seed seed)
   (declare (special *deserialized-objects*))
   (cons (case name
                          (dolist (pair seed hash-table)
                            (setf (gethash (car pair) hash-table) (cadr pair)))))
           (:ref (let ((id (parse-integer (get-attribute-value :id attributes))))
-                  (gethash id *deserialized-objects*))))
+                  (gethash id *deserialized-objects*)))
+          (t (deserialize-xml-finish-element-aux name attributes parent-seed seed)))
         parent-seed))
 
+(defgeneric deserialize-xml-finish-element-aux (name attributes parent-seed seed)
+  (:documentation "Extend with your own types by overloading serialize-xml-internal
+                   and implementing deserialize aux functions")
+  (:method (name attributes parent-seed seed)
+    (declare (ignore name attributes parent-seed seed))
+    nil))
+
 (defun deserialize-xml-text (string seed)
   (declare (ignore seed))
   string)