]> asedeno.scripts.mit.edu Git - cl-protobufs.git/blobdiff - parser.lisp
Merge branch 'master' of git://common-lisp.net/projects/qitab/cl-protobufs
[cl-protobufs.git] / parser.lisp
index dd8a2931ef89d466d3b0574294dab9f38a525dba..cdd093ff62035a33627491357b713a368d27a473 100644 (file)
                               :start-pos start :end-pos end)))
 
 (defgeneric resolve-lisp-names (protobuf)
-  (:documentation "Second pass of schema parsing which recursively resolves protobuf type names to
-                   lisp type names in all messages and services contained within 'protobuf'.  No
-                   return value."))
+  (:documentation
+   "Second pass of schema parsing which recursively resolves Protobuf type names
+    to Lisp type names in all messages and services contained within 'protobuf'.
+    No return value."))
 
 ;; The syntax for Protocol Buffers is so simple that it doesn't seem worth
 ;; writing a sophisticated parser
     (setq *protobuf-package* package)))
 
 (defmethod resolve-lisp-names ((schema protobuf-schema))
-  "Recursively resolves protobuf type names to lisp type names in the messages and services in
-   'schema'."
+  "Recursively resolves Protobuf type names to Lisp type names in the messages and services in 'schema'."
   (map () #'resolve-lisp-names (proto-messages schema))
   (map () #'resolve-lisp-names (proto-services schema)))
 
                              ((or (digit-char-p ch) (member ch '(#\- #\+ #\.)))
                               (parse-number stream))
                              ((eql ch #\{)
-                              ;;---bwagner: this is incorrect -- we need to find the field name in
-                              ;;   the locally-extended version of
+                              ;;---bwagner: This is incorrect
+                              ;;   We need to find the field name in the locally-extended version of
                               ;;   google.protobuf.[File,Message,Field,Enum,EnumValue,Service,Method]Options
                               ;;   and get its type
                               (let ((message (find-message (or protobuf *protobuf*) key)))
                       token (file-position stream))))))))
 
 (defmethod resolve-lisp-names ((message protobuf-message))
-  "Recursively resolves protobuf type names to lisp type names in nested messages and fields of
-   'message'."
+  "Recursively resolves protobuf type names to lisp type names in nested messages and fields of 'message'."
   (map () #'resolve-lisp-names (proto-messages message))
   (map () #'resolve-lisp-names (proto-fields message)))
 
          (name (prog1 (parse-token stream)
                  (expect-char stream #\{ () "extend")
                  (maybe-skip-comments stream)))
-         ;;---bwagner: is 'extend' allowed to use a forward reference to a message?
+         ;;---bwagner: Is 'extend' allowed to use a forward reference to a message?
          (message (find-message protobuf name))
          (extends (and message
                        (make-instance 'protobuf-message
                         (find-enum (proto-parent field) type)))))
     (unless (or ptype message)
       (error 'undefined-field-type
-             :type-name type
-             :field field))
+        :type-name type
+        :field field))
     (setf (proto-class field) (or ptype (proto-class message))))
   nil)
 
   "Resolves input, output, and streams protobuf type names to lisp type names and sets
    `proto-input-type', `proto-output-type', and, if `proto-streams-name' is set,
    `proto-streams-type' on 'method'."
-  (let* ((input-name (proto-input-name method))
-         (output-name (proto-output-name method))
+  (let* ((input-name   (proto-input-name method))
+         (output-name  (proto-output-name method))
          (streams-name (proto-streams-name method))
          (service (proto-parent method))
-         (schema (proto-parent service))
-         (input-message (find-message schema input-name))
-         (output-message (find-message schema output-name))
+         (schema  (proto-parent service))
+         (input-message   (find-message schema input-name))
+         (output-message  (find-message schema output-name))
          (streams-message (and streams-name
-                               ;; this is supposed to be the fully-qualified name, but we don't
-                               ;; require that
+                               ;; This is supposed to be the fully-qualified name,
+                               ;; but we don't require that
                                (find-message schema streams-name))))
     (unless input-message
       (error 'undefined-input-type
-             :type-name input-name
-             :method method))
+        :type-name input-name
+        :method method))
     (unless output-message
       (error 'undefined-output-type
-             :type-name output-name
-             :method method))
+        :type-name output-name
+        :method method))
     (setf (proto-input-type method) (proto-class input-message))
     (setf (proto-output-type method) (proto-class output-message))
     (when streams-name
       (unless streams-message
         (error 'undefined-stream-type
-               :type-name streams-name
-               :method method))
+          :type-name streams-name
+          :method method))
       (setf (proto-streams-type method) (proto-class streams-message))))
   nil)