(setf (gethash (make-pathname :type nil :defaults path) *all-schemas*) schema))))))
(defmethod print-object ((s protobuf-schema) stream)
- (print-unreadable-object (s stream :type t :identity t)
- (format stream "~@[~S~]~@[ (package ~A)~]"
- (when (slot-boundp s 'class) (proto-class s)) (proto-package s))))
+ (if *print-escape*
+ (print-unreadable-object (s stream :type t :identity t)
+ (format stream "~@[~S~]~@[ (package ~A)~]"
+ (and (slot-boundp s 'class) (proto-class s)) (proto-package s)))
+ (format stream "~S" (and (slot-boundp s 'class) (proto-class s)))))
(defgeneric make-qualified-name (proto name)
(:documentation
(make-load-form-saving-slots o :environment environment))
(defmethod print-object ((o protobuf-option) stream)
- (print-unreadable-object (o stream :type t :identity t)
- (format stream "~A~@[ = ~S~]" (proto-name o) (proto-value o))))
+ (if *print-escape*
+ (print-unreadable-object (o stream :type t :identity t)
+ (format stream "~A~@[ = ~S~]" (proto-name o) (proto-value o)))
+ (format stream "~A" (proto-name o))))
(defgeneric find-option (protobuf name)
(:documentation
(make-load-form-saving-slots e :environment environment))
(defmethod print-object ((e protobuf-enum) stream)
- (print-unreadable-object (e stream :type t :identity t)
- (format stream "~S~@[ (alias for ~S)~]"
- (when (slot-boundp e 'class) (proto-class e)) (proto-alias-for e))))
+ (if *print-escape*
+ (print-unreadable-object (e stream :type t :identity t)
+ (format stream "~S~@[ (alias for ~S)~]"
+ (and (slot-boundp e 'class) (proto-class e)) (proto-alias-for e)))
+ (format stream "~S"
+ (and (slot-boundp e 'class) (proto-class e)))))
(defmethod make-qualified-name ((enum protobuf-enum) name)
;; The qualified name is the enum name "dot" the name
(make-load-form-saving-slots v :environment environment))
(defmethod print-object ((v protobuf-enum-value) stream)
- (print-unreadable-object (v stream :type t :identity t)
- (format stream "~A = ~D"
- (proto-name v) (proto-index v))))
+ (if *print-escape*
+ (print-unreadable-object (v stream :type t :identity t)
+ (format stream "~A = ~D"
+ (proto-name v) (proto-index v)))
+ (format stream "~A" (proto-name v))))
;; A Protobufs message
(setf (gethash name *all-messages*) message)))))
(defmethod print-object ((m protobuf-message) stream)
- (print-unreadable-object (m stream :type t :identity t)
- (format stream "~S~@[ (alias for ~S)~]~@[ (group~*)~]~@[ (extended~*)~]"
- (when (slot-boundp m 'class) (proto-class m))
- (proto-alias-for m)
- (eq (proto-message-type m) :group)
- (eq (proto-message-type m) :extends))))
+ (if *print-escape*
+ (print-unreadable-object (m stream :type t :identity t)
+ (format stream "~S~@[ (alias for ~S)~]~@[ (group~*)~]~@[ (extended~*)~]"
+ (and (slot-boundp m 'class) (proto-class m))
+ (proto-alias-for m)
+ (eq (proto-message-type m) :group)
+ (eq (proto-message-type m) :extends)))
+ (format stream "~S" (and (slot-boundp m 'class) (proto-class m)))))
(defmethod proto-package ((message protobuf-message))
(and (proto-parent message)
(make-load-form-saving-slots f :environment environment))
(defmethod print-object ((f protobuf-field) stream)
- (print-unreadable-object (f stream :type t :identity t)
- (format stream "~S :: ~S = ~D~@[ (group~*)~]~@[ (extended~*)~]"
- (proto-value f)
- (when (slot-boundp f 'class) (proto-class f))
- (proto-index f)
- (eq (proto-message-type f) :group)
- (eq (proto-message-type f) :extends))))
+ (if *print-escape*
+ (print-unreadable-object (f stream :type t :identity t)
+ (format stream "~S :: ~S = ~D~@[ (group~*)~]~@[ (extended~*)~]"
+ (proto-value f)
+ (and (slot-boundp f 'class) (proto-class f))
+ (proto-index f)
+ (eq (proto-message-type f) :group)
+ (eq (proto-message-type f) :extends)))
+ (format stream "~S" (proto-value f))))
;; The 'value' slot really holds the name of the slot,
;; so let's give it a better name
(defmethod print-object ((e protobuf-extension) stream)
(print-unreadable-object (e stream :type t :identity t)
(format stream "~D - ~D"
- (proto-extension-from e) (proto-extension-from e))))
+ (proto-extension-from e) (proto-extension-to e))))
;; A Protobufs service
(make-load-form-saving-slots s :environment environment))
(defmethod print-object ((s protobuf-service) stream)
- (print-unreadable-object (s stream :type t :identity t)
- (format stream "~A"
- (proto-name s))))
+ (if *print-escape*
+ (print-unreadable-object (s stream :type t :identity t)
+ (format stream "~S" (proto-name s)))
+ (format stream "~S" (proto-name s))))
(defgeneric find-method (service name)
(:documentation
(make-load-form-saving-slots m :environment environment))
(defmethod print-object ((m protobuf-method) stream)
- (print-unreadable-object (m stream :type t :identity t)
- (format stream "~S (~S) => (~S)"
- (proto-class m)
- (when (slot-boundp m 'itype) (proto-input-type m))
- (when (slot-boundp m 'otype) (proto-output-type m)))))
+ (if *print-escape*
+ (print-unreadable-object (m stream :type t :identity t)
+ (format stream "~S (~S) => (~S)"
+ (proto-class m)
+ (and (slot-boundp m 'itype) (proto-input-type m))
+ (and (slot-boundp m 'otype) (proto-output-type m))))
+ (format stream "~S" (proto-class m))))
;;; Lisp-only extensions
(make-load-form-saving-slots m :environment environment))
(defmethod print-object ((m protobuf-type-alias) stream)
- (print-unreadable-object (m stream :type t :identity t)
- (format stream "~S (maps ~S to ~S)"
- (proto-class m)
- (proto-lisp-type m) (proto-proto-type m))))
+ (if *print-escape*
+ (print-unreadable-object (m stream :type t :identity t)
+ (format stream "~S (maps ~S to ~S)"
+ (proto-class m)
+ (proto-lisp-type m) (proto-proto-type m)))
+ (format stream "~S" (proto-class m))))
(defgeneric find-type-alias (protobuf type)
(:documentation
:conc-name nil)))
(parse-message-with-field-type (type)
(parse-schema-containing (format nil "message MessageWithUndefinedFieldType {~%~
- ~& optional ~a bar = 1;~%~
+ ~& optional ~A bar = 1;~%~
}~%" type)))
(parse-service-with-rpc (rpc)
(parse-schema-containing (format nil "service ServiceWithUndefinedMethodType {~%~
- ~& ~a~%~
+ ~& ~A~%~
}~%" rpc)))
(poor-mans-assert-regex-equal (expected-strings actual-string)
(assert-true
(let ((condition (assert-error undefined-field-type
(parse-message-with-field-type field-type))))
(poor-mans-assert-regex-equal
- (list "Undefined type: Field #<"
- "PROTOBUF-FIELD PROTOBUFS-TEST::BAR :: NIL = 1"
- "in message #<"
- "PROTOBUF-MESSAGE PROTOBUFS-TEST::MESSAGE-WITH-UNDEFINED-FIELD-TYPE"
- (format nil "has unknown type \"~a\"." field-type))
+ (list "Undefined type: Field "
+ "BAR"
+ "in message "
+ "MESSAGE-WITH-UNDEFINED-FIELD-TYPE"
+ (format nil "has unknown type ~A" field-type))
(princ-to-string condition))
(assert-equal field-type (error-type-name condition))
(assert-equal "bar" (proto-name (error-field condition)))))
(method-test-assertions (condition where method-lisp-name method-proto-name type)
(poor-mans-assert-regex-equal
- (list (format nil "Undefined type: ~a type for rpc #<" where)
- (format nil "PROTOBUF-METHOD PROTOBUFS-TEST::~a" method-lisp-name)
- "in service #<"
- "PROTOBUF-SERVICE ServiceWithUndefinedMethodType"
- (format nil "has unknown type \"~a\"." type))
+ (list (format nil "Undefined type: ~A type for RPC " where)
+ (format nil "~A" method-lisp-name)
+ "in service "
+ "ServiceWithUndefinedMethodType"
+ (format nil "has unknown type ~A" type))
(princ-to-string condition))
(assert-equal type (error-type-name condition))
(assert-equal method-proto-name (proto-name (error-method condition))))
(do-method-input-test (input-type)
(let ((condition (assert-error undefined-input-type
(parse-service-with-rpc
- (format nil "rpc MethodWithUndefinedInput (~a) ~
+ (format nil "rpc MethodWithUndefinedInput (~A) ~
returns (DefinedMessage);" input-type)))))
(method-test-assertions condition "Input" "METHOD-WITH-UNDEFINED-INPUT"
"MethodWithUndefinedInput" input-type)))
(let ((condition (assert-error undefined-output-type
(parse-service-with-rpc
(format nil "rpc MethodWithUndefinedOutput (DefinedMessage) ~
- returns (~a);" output-type)))))
+ returns (~A);" output-type)))))
(method-test-assertions condition "Output" "METHOD-WITH-UNDEFINED-OUTPUT"
"MethodWithUndefinedOutput" output-type)))
(do-method-stream-test (stream-type)
(parse-service-with-rpc
(format nil "rpc MethodWithUndefinedStream (DefinedMessage) ~
returns (DefinedMessage) {~
- ~& option stream_type = \"~a\";~
+ ~& option stream_type = \"~A\";~
~& };" stream-type)))))
(method-test-assertions condition "Stream" "METHOD-WITH-UNDEFINED-STREAM"
"MethodWithUndefinedStream" stream-type))))