]> asedeno.scripts.mit.edu Git - cl-protobufs.git/commitdiff
Whops 'proto:define-enum' should start enum indexes at 0.
authorScott McKay <swm@google.com>
Thu, 26 Apr 2012 20:18:03 +0000 (20:18 +0000)
committerScott McKay <swm@google.com>
Thu, 26 Apr 2012 20:18:03 +0000 (20:18 +0000)
Field naming convention is 'last_name', not 'lastName'.

git-svn-id: http://svn.internal.itasoftware.com/svn/ita/trunk/qres/lisp/quux/protobufs@541257 f8382938-511b-0410-9cdd-bb47b084005c

define-proto.lisp
utilities.lisp

index aea4f4fa0097d865dc73da3d9d1cd98449aa4699..ec884bc41df9355a101fccadc6ceecd58fece6cd 100644 (file)
                         collect (make-instance 'protobuf-option
                                   :name  key
                                   :value val)))
-         (index 0)
+         (index -1)
          (enum  (make-instance 'protobuf-enum
                   :class  type
                   :name   name
index a1da5e9280250061aea985fe69fdd013be68dc64..a93db0cb96deddc5d3f133616facf6277b91d2e5 100644 (file)
   (let* ((x (string-upcase (string x)))
          (x (if (and prefix (starts-with x prefix)) (subseq x (length prefix)) x)))
     (remove-if-not #'(lambda (x) (or (alphanumericp x) (eql x #\_)))
-                   (format nil "~{~A~^_~}" (split-string x :separators '(#\- #\_ #\/ #\. #\space))))))
+                   (format nil "~{~A~^_~}"
+                           (split-string x :separators '(#\- #\_ #\/ #\. #\space))))))
 
-;; "slot-name" -> "slotName"
+;; "slot-name" -> "slot_name" or "slotName"
+(defvar *camel-case-field-names* nil)
 (defun slot-name->proto (x)
   "Given a Lisp slot name, returns a Protobufs field name."
-  (remove-if-not #'alphanumericp
-                 (camel-case-but-one (format nil "~A" x) :separators '(#\- #\_ #\/ #\. #\space))))
+  (if *camel-case-field-names*
+    (remove-if-not #'alphanumericp
+                   (camel-case-but-one (format nil "~A" x) :separators '(#\- #\_ #\/ #\. #\space)))
+    (let ((x (string-downcase (string x))))
+      (remove-if-not #'(lambda (x) (or (alphanumericp x) (eql x #\_)))
+                     (format nil "~{~A~^_~}"
+                             (split-string x :separators '(#\- #\_ #\/ #\. #\space)))))))
 
 
 ;; "ClassName" -> "class-name"
 ;; "ENUM_VALUE" -> "enum-name"
 (defun proto->enum-name (x &optional package)
   "Given a Protobufs enum value name, returns a Lisp enum value name."
-  (let ((name (format nil "~{~A~^-~}" (split-string (string-upcase x) :separators '(#\_)))))
+  (let ((name (format nil "~{~A~^-~}"
+                      (split-string (string-upcase x) :separators '(#\_)))))
     (if package (intern name package) (make-symbol name))))
 
-;; "slotName" -> "slot-name", "slot_name" -> "slot-name"
+;; "slot_name" or "slotName" -> "slot-name"
 (defun proto->slot-name (x &optional package)
   "Given a Protobufs field value name, returns a Lisp slot name."
   (let ((name (format nil "~{~A~^-~}" (split-string (nstring-upcase (uncamel-case x)) :separators '(#\_)))))