]> asedeno.scripts.mit.edu Git - cl-protobufs.git/commitdiff
define-proto: collect DEFTYPE forms before other forms
authorPaul Weiss <pgweiss@google.com>
Wed, 2 Jan 2013 17:00:53 +0000 (12:00 -0500)
committerAlejandro R Sedeño <asedeno@google.com>
Wed, 2 Jan 2013 17:05:17 +0000 (12:05 -0500)
Signed-off-by: Alejandro R Sedeño <asedeno@google.com>
define-proto.lisp

index d553623343adc645ae49178952a1deb0e2827561..5944fa8448289cbbdc231ecebb4d75d197547c02 100644 (file)
          ;; Only now can we bind *protobuf* to the new message
          (*protobuf* message))
     (with-collectors ((slots collect-slot)
-                      (forms collect-form))
+                      (forms collect-form)
+                      ;; The typedef needs to be first in forms otherwise ccl warns.
+                      ;; We'll collect them separately and splice them in first.
+                      (type-forms collect-type-form))
       (dolist (field fields)
         (case (car field)
           ((define-enum define-message define-extend define-extension define-group
         ;; If we've got an alias, define a a type that is the subtype of
         ;; the Lisp class that typep and subtypep work
         (unless (or (eq type alias-for) (find-class type nil))
-          (collect-form `(deftype ,type () ',alias-for)))
+          (collect-type-form `(deftype ,type () ',alias-for)))
         ;; If no alias, define the class now
-        (collect-form `(defclass ,type () (,@slots)
+        (collect-type-form `(defclass ,type () (,@slots)
                          ,@(and documentation `((:documentation ,documentation))))))
       `(progn
          define-message
          ,message
          ((with-proto-source-location (,type ,name protobuf-message ,@source-location)
+            ,@type-forms
             ,@forms))))))
 
 (defun conc-name-for-type (type conc-name)
          ;; Only now can we bind *protobuf* to the (group) message
          (*protobuf* message))
     (with-collectors ((slots collect-slot)
-                      (forms collect-form))
+                      (forms collect-form)
+                      ;; The typedef needs to be first in forms otherwise ccl warns.
+                      ;; We'll collect them separately and splice them in first.
+                      (type-forms collect-type-form))
       (dolist (field fields)
         (case (car field)
           ((define-enum define-message define-extend define-extension define-group
         ;; If we've got an alias, define a a type that is the subtype of
         ;; the Lisp class that typep and subtypep work
         (unless (or (eq type alias-for) (find-class type nil))
-          (collect-form `(deftype ,type () ',alias-for)))
+          (collect-type-form `(deftype ,type () ',alias-for)))
         ;; If no alias, define the class now
-        (collect-form `(defclass ,type () (,@slots)
+        (collect-type-form `(defclass ,type () (,@slots)
                          ,@(and documentation `((:documentation ,documentation))))))
       `(progn
          define-group
          ,message
          ((with-proto-source-location (,type ,name protobuf-message ,@source-location)
+            ,@type-forms
             ,@forms))
          ,mfield
          ,mslot))))