;;; ;;;
;;; Free Software published under an MIT-like license. See LICENSE ;;;
;;; ;;;
-;;; Copyright (c) 2012 Google, Inc. All rights reserved. ;;;
+;;; Copyright (c) 2012-2013 Google, Inc. All rights reserved. ;;;
;;; ;;;
;;; Original author: Scott McKay ;;;
;;; ;;;
options)
:documentation documentation))
(*protobuf* schema)
- (*protobuf-package* (or (find-proto-package lisp-pkg) *package*)))
+ (*protobuf-package* (or (find-proto-package lisp-pkg) *package*))
+ (*protobuf-rpc-package* (or (find-proto-package (format nil "~A-~A" lisp-pkg 'rpc)) *package*)))
(process-imports schema imports)
(with-collectors ((forms collect-form))
(dolist (msg messages)
collect (make-instance 'protobuf-option
:name (if (symbolp key) (slot-name->proto key) key)
:value val)))
- (package *protobuf-package*)
- (client-fn function)
- (server-fn (intern (format nil "~A-~A" 'do function) package))
+ (package *protobuf-rpc-package*)
+ (client-fn (intern (format nil "~A-~A" 'call function) package))
+ (server-fn (intern (format nil "~A-~A" function 'impl) package))
(method (make-instance 'protobuf-method
:class function
:name (or name (class-name->proto function))
;;; ;;;
;;; Free Software published under an MIT-like license. See LICENSE ;;;
;;; ;;;
-;;; Copyright (c) 2012 Google, Inc. All rights reserved. ;;;
+;;; Copyright (c) 2012-2013 Google, Inc. All rights reserved. ;;;
;;; ;;;
;;; Original author: Scott McKay ;;;
;;; ;;;
(defvar *protobuf-package* nil
"The Lisp package in which the Protobufs schema is being defined.")
+(defvar *protobuf-rpc-package* nil
+ "The Lisp package in which the Protobufs schema's service definitions are being defined.")
+
(defvar *protobuf-conc-name* nil
"A global conc-name to use for all the messages in this schema. This controls
the name of the accessors the fields of each message.
;;; ;;;
;;; Free Software published under an MIT-like license. See LICENSE ;;;
;;; ;;;
-;;; Copyright (c) 2012 Google, Inc. All rights reserved. ;;;
+;;; Copyright (c) 2012-2013 Google, Inc. All rights reserved. ;;;
;;; ;;;
;;; Original author: Scott McKay ;;;
;;; ;;;
:name name))
(*protobuf* schema)
*protobuf-package*
+ *protobuf-rpc-package*
(*protobuf-conc-name* conc-name))
- (flet ((ensure-package ()
- "Find a fallback for our Lisp package if we don't have an obvious one already.
- * java_package
- * *package*"
- (unless *protobuf-package*
- (let ((java-package (find-option schema "java_package")))
- (if java-package
- (set-lisp-package schema java-package)
- (setq *protobuf-package* *package*))))))
+ (labels ((ensure-package ()
+ "Find a fallback for our Lisp package if we don't have an obvious one already.
+ * java_package
+ * *package*"
+ (unless *protobuf-package*
+ (let ((java-package (find-option schema "java_package")))
+ (if java-package
+ (set-lisp-package schema java-package)
+ (setq *protobuf-package* *package*)))))
+ (ensure-rpc-package ()
+ (ensure-package)
+ (unless *protobuf-rpc-package*
+ (let ((rpc-package-name (format nil "~A-~A" (package-name *protobuf-package*) 'rpc)))
+ (setq *protobuf-rpc-package*
+ (or (find-proto-package rpc-package-name)
+ (make-package (string-upcase rpc-package-name) :use ())))))))
(loop
(skip-whitespace stream)
(maybe-skip-comments stream)
(ensure-package)
(parse-proto-message stream schema))
((string= token "service")
- (ensure-package)
+ (ensure-rpc-package)
(parse-proto-service stream schema)))))
(t
(error "Syntax error at position ~D" (file-position stream)))))))))
(stub (or (and name (make-lisp-symbol name))
stub)))
(setf (proto-class method) stub
- (proto-client-stub method) stub
- (proto-server-stub method) (intern (format nil "~A-~A" 'do stub) *protobuf-package*)))
+ (proto-client-stub method) (intern (format nil "~A-~A" 'call stub) *protobuf-rpc-package*)
+ (proto-server-stub method) (intern (format nil "~A-~A" stub 'impl) *protobuf-rpc-package*)))
(let ((strm (find-option method "stream_type")))
(when strm
(setf (proto-streams-name method) strm)))
;;; ;;;
;;; Free Software published under an MIT-like license. See LICENSE ;;;
;;; ;;;
-;;; Copyright (c) 2012 Google, Inc. All rights reserved. ;;;
+;;; Copyright (c) 2012-2013 Google, Inc. All rights reserved. ;;;
;;; ;;;
;;; Original author: Scott McKay ;;;
;;; ;;;
(proto-options schema)))
(pkg (and package (if (stringp package) package (string package))))
(lisp-pkg (and lisp-package (if (stringp lisp-package) lisp-package (string lisp-package))))
+ (rpc-pkg (and (or lisp-pkg pkg)
+ (format nil "~A-~A" (or lisp-pkg pkg) 'rpc)))
(*show-lisp-enum-indexes* show-enum-indexes)
(*show-lisp-field-indexes* show-field-indexes)
(*use-common-lisp-package* use-common-lisp)
(*protobuf-package* (find-proto-package lisp-pkg))
+ (*protobuf-rpc-package* (find-proto-package rpc-pkg))
;; If *protobuf-package* has not been defined, print symbols
;; from :common-lisp if *use-common-lisp-package* is true; or
;; :keyword otherwise. This ensures that all symbols will be
;; Keywords are always printed as :keyword.)
(*package* (or *protobuf-package*
(when *use-common-lisp-package* (find-package :common-lisp))
- (find-package :keyword))))
+ (find-package :keyword)))
+ (exports (collect-exports schema)))
+ (when rpc-pkg
+ (let* ((pkg (string-upcase rpc-pkg))
+ (rpc-exports (remove-if-not
+ #'(lambda (sym)
+ (string=
+ (package-name (symbol-package sym))
+ pkg))
+ exports))
+ (*package* (or *protobuf-rpc-package*
+ (when *use-common-lisp-package* (find-package :common-lisp))
+ (find-package :keyword))))
+ (when rpc-exports
+ (format stream "~&(cl:eval-when (:execute :compile-toplevel :load-toplevel)~
+ ~% (cl:unless (cl:find-package \"~A\")~
+ ~% (cl:defpackage ~A (:use~@[ ~(~S~)~]))))~
+ ~%(cl:in-package \"~A\")~
+ ~%(cl:export '(~{~A~^~% ~}))~%~%"
+ pkg pkg (and *use-common-lisp-package* :common-lisp) pkg
+ rpc-exports))))
(when (or lisp-pkg pkg)
(let ((pkg (string-upcase (or lisp-pkg pkg))))
(format stream "~&(cl:eval-when (:execute :compile-toplevel :load-toplevel)~
(string=
(package-name (symbol-package sym))
pkg))
- (collect-exports schema)))))
+ exports))))
(when documentation
(write-schema-documentation type documentation stream :indentation indentation))
(format stream "~&(proto:define-schema ~(~A~)" (or class name))