]> asedeno.scripts.mit.edu Git - cl-protobufs.git/commitdiff
Beef up the generated client-side stub so that calls into an RPC
authorScott McKay <swm@google.com>
Tue, 26 Jun 2012 19:52:07 +0000 (19:52 +0000)
committerScott McKay <swm@google.com>
Tue, 26 Jun 2012 19:52:07 +0000 (19:52 +0000)
package, if it has been loaded.

Passes 'precheckin' with the new Protobufs unit tests in place.
CL-Stubby tests pass in Google3 environment.

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

asdf-support.lisp
define-proto.lisp
pkgdcl.lisp

index 4731c31f9e7dfd72e2541b1c63207b3e7becd84e..adfd7c79bda53bad40511481fd414a49065ca27b 100644 (file)
                 (nconc (proto-imported-schemas schema) (list imported)))
           (return-from import-one))
         (dolist (path search-path (error "Could not import ~S" import))
-          (let* ((base-path (asdf:merge-pathnames* import path))
+          (let* ((base-path  (asdf:merge-pathnames* import path))
                  (proto-file (make-pathname :name import-name :type "proto"
                                             :defaults base-path))
                  (lisp-file  (if output-path
                                               :directory (pathname-directory output-path))
                                (make-pathname :type "lisp" :defaults base-path)))
                  (fasl-file  (compile-file-pathname lisp-file))
-                 (asdf:*asdf-verbose* nil) ;; for safe-file-write-date
+                 (asdf:*asdf-verbose* nil)      ;for safe-file-write-date
                  (proto-date (asdf::safe-file-write-date proto-file))
                  (lisp-date  (asdf::safe-file-write-date lisp-file))
                  (fasl-date  (asdf::safe-file-write-date fasl-file)))
index 00219e6f19267c271f52234544ffe67b9b6b62b3..2d8b8d07d9eb9464823e1da5552a03fb040f2eee 100644 (file)
                           :documentation documentation)))
             (values field cslot idx)))))))
 
+(defparameter *rpc-package* nil
+  "The Lisp package that implements RPC.")
+(defparameter *rpc-call-function* nil
+  "The Lisp function that implements RPC client-side calls.")
+
 ;; Define a service named 'type' with generic functions declared for
 ;; each of the methods within the service
 (defmacro define-service (type (&key name options documentation)
               ;; asynchronous calls simpler.
               (collect-form `(defgeneric ,client-fn (,vchannel ,vinput ,voutput &key ,vcallback)
                                ,@(and documentation `((:documentation ,documentation)))
-                               #-sbcl (declare (values ,output-type))))
+                               #-sbcl (declare (values ,output-type))
+                               (:method (,vchannel (,vinput ,input-type) (,voutput ,output-type) &key ,vcallback)
+                                 (declare (ignorable ,vchannel ,vcallback))
+                                 (let ((call (and *rpc-package* *rpc-call-function*
+                                                  (find-symbol *rpc-call-function* *rpc-package*))))
+                                   (assert call ()
+                                           "There is no RPC package loaded!")
+                                   (funcall call ,vchannel ',method ,vinput ,voutput
+                                            :callback ,vcallback)))))
               ;; The server side stub, e.g., 'do-read-air-reservation'.
               ;; The expectation is that the server-side program will implement
               ;; a method with the business logic for this on each kind of channel
index fb4922dccffc5ff77a9537a3832cb156a4ddcbe1..d02fe1f679ed51006b4264d8a6cae743488e4b49 100644 (file)
 
    ;; Stuff for ASDF
    "PARSE-PROTOBUF-FILE"
-   "PROCESS-IMPORTS"))
+   "PROCESS-IMPORTS"
+
+   ;; Stuff for RPC stubs
+   "*RPC-PACKAGE*"
+   "*RPC-CALL-FUNCTION*"))