]> asedeno.scripts.mit.edu Git - cl-protobufs.git/blobdiff - define-proto.lisp
Rudimentary support for 'allow_alias' in enums
[cl-protobufs.git] / define-proto.lisp
index 9183af87a96456889ffead30067cbdfd1dc46593..96c5f2f3d00d48517437a37361cab6fc5974d062 100644 (file)
                             :parent enum)))
           (collect-val val-name)
           (appendf (proto-values enum) (list enum-val))))
+      (multiple-value-bind (allow bool foundp) (find-option options "allow_alias")
+        (declare (ignore bool))
+        (when (and foundp (not (boolean-true-p allow)))
+          (dolist (v1 (proto-values enum))
+            (dolist (v2 (proto-values enum))
+              (unless (or (eq v1 v2)
+                          (not (eql (proto-index v1) (proto-index v2))))
+                (error "The enum values ~S and ~S in ~S have the same index and you have not used 'option allow_alias = true'"
+                       (proto-name v1) (proto-name v2) (proto-class enum)))))))
       (if alias-for
         ;; If we've got an alias, define a a type that is the subtype of
         ;; the Lisp enum so that typep and subtypep work