;;; ;;;
;;; Free Software published under an MIT-like license. See LICENSE ;;;
;;; ;;;
-;;; Copyright (c) 2012 Google, Inc. All rights reserved. ;;;
+;;; Copyright (c) 2012-2013 Google, Inc. All rights reserved. ;;;
;;; ;;;
;;; Original author: Scott McKay ;;;
;;; ;;;
(type (and message (proto-class message))))
(assert message ()
"There is no Protobufs message for the class ~S" class)
- (let ((visited (make-hash-table)))
+ (let ((visited (make-size-cache object type)))
(object-size object type visited)))))
;; This is simpler than 'serialize-object', but doesn't fully support aliasing
(:documentation
"Serialize 'object' into 'buffer' using the wire format, starting at the index
'start' and going no farther than 'end'. 'object' is an object whose Lisp class
- corresponds to a Protobufs message.")
+ corresponds to a Protobufs message.
+ Returns two values, the final index and the buffer.")
(:method ((object standard-object) &optional buffer (start 0) end)
(declare (ignore end))
(let* ((class (type-of object))
(type (and message (proto-class message))))
(assert message ()
"There is no Protobufs message for the class ~S" class)
- (let* ((visited (make-hash-table))
+ (let* ((visited (make-size-cache object type))
(size (object-size object type visited))
(start (or start 0))
(buffer (or buffer (make-byte-vector size))))
(multiple-value-bind (nbuf nend)
(serialize-object object type buffer start visited)
(declare (ignore nbuf))
- nend)))))
+ (values nend buffer))))))
(defgeneric merge-from-array (object buffer &optional start end)
(:documentation