;; A parameterized list type for repeated fields
;; The elements aren't type-checked
(deftype list-of (type)
- (if (eq type 'nil) ; a list that cannot have any element (element-type nil) is null.
+ (if (eq type 'nil) ;a list that cannot have any element (element-type nil) is null
'null
'list))
;; The same, but use a (stretchy) vector
(deftype vector-of (type)
- (if (eq type 'nil); an array that cannot have any element (element-type nil) is of size 0.
+ (if (eq type 'nil) ;an array that cannot have any element (element-type nil) is of size 0
'(array * (0))
- '(array * (*)))) ;an 1-dimensional array of any type
+ '(array * (*)))) ;a 1-dimensional array of any type
;; This corresponds to the :bytes Protobufs type
(deftype byte-vector () '(array (unsigned-byte 8) (*)))
(deftype sfixed32 () '(signed-byte 32))
(deftype sfixed64 () '(signed-byte 64))
+;; Type expansion
+(defun type-expand (type)
+ #+allegro (excl:normalize-type type :default type)
+ #+ccl (ccl::type-expand type)
+ #+clisp (ext:type-expand type)
+ #+cmu (kernel:type-expand type)
+ #+lispworks (type:expand-user-type type)
+ #+sbcl (sb-ext:typexpand type)
+ #-(or allegro ccl clisp cmu lispworks sbcl) type)
;;; Code generation utilities
(excl:double-float-to-shorts x)
(logior (ash us1 16) us0)
(logior (ash us3 16) us2))
- #+ccl (ccl::double-float-bits x)
+ #+ccl (multiple-value-bind (high low)
+ (ccl::double-float-bits x)
+ (values low high))
#+cmu (values (kernel:double-float-low-bits x)
(kernel:double-float-high-bits x))
#+sbcl (values (sb-kernel:double-float-low-bits x)