From 7587ff45b8a04a8f9adf55c3977681dc3897d9bb Mon Sep 17 00:00:00 2001 From: Olof-Joachim Frahm Date: Thu, 6 Jun 2013 22:57:14 +0200 Subject: [PATCH] Don't throw an error on variable sized members. This just means that the whole struct doesn't have a fixed size. --- binary-types.lisp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/binary-types.lisp b/binary-types.lisp index 72300c3..b540d74 100644 --- a/binary-types.lisp +++ b/binary-types.lisp @@ -672,6 +672,14 @@ read are returned." ',type-name))))))) +(defun calculate-sizeof (slot-types) + (loop + for slot-type in slot-types + for sizeof = (sizeof slot-type) + when (null sizeof) + do (return) + sum sizeof)) + (defmacro define-binary-struct (name-and-options dummy-options &rest doc-slot-descriptions) (declare (ignore dummy-options)) ; clisp seems to require this.. (let (embedded-declarations) @@ -732,7 +740,7 @@ read are returned." (setf (find-binary-type ',type-name) (make-instance 'binary-struct 'name ',type-name - 'sizeof (loop for s in ',slot-types sum (sizeof s)) + 'sizeof (calculate-sizeof ',slot-types) 'slots ',binslots 'offset 0 'constructor (find-symbol (format nil "~A-~A" '#:make ',type-name)))) -- 1.7.10.4