]> asedeno.scripts.mit.edu Git - cl-protobufs.git/commitdiff
Rudimentary support for 'allow_alias' in enums
authorScott McKay <swmckay@gmail.com>
Mon, 15 Jul 2013 12:11:18 +0000 (17:41 +0530)
committerScott McKay <swmckay@gmail.com>
Mon, 15 Jul 2013 12:11:18 +0000 (17:41 +0530)
define-proto.lisp
printer.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
index 99354131fed0c07b3675d7ba2ab8fac58d18593f..87ea5973da3af72b5cb7fd723fdd9e067842b174 100644 (file)
@@ -86,7 +86,8 @@
                                ("lisp_class"   string 195805)
                                ("lisp_slot"    string 195806)))
 
-(defparameter *option-types* '(("ctype"                 symbol)
+(defparameter *option-types* '(("allow_alias"          boolean)
+                               ("ctype"                 symbol)
                                ("deadline"               float)
                                ("deprecated"            symbol)
                                ("optimize_for"          symbol)