From 166bf2025c37cf0c2f181333adf277479a8b3d1d Mon Sep 17 00:00:00 2001 From: Scott McKay Date: Tue, 26 Jun 2012 19:52:07 +0000 Subject: [PATCH] Beef up the generated client-side stub so that calls into an RPC 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 | 4 ++-- define-proto.lisp | 15 ++++++++++++++- pkgdcl.lisp | 6 +++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/asdf-support.lisp b/asdf-support.lisp index 4731c31..adfd7c7 100644 --- a/asdf-support.lisp +++ b/asdf-support.lisp @@ -186,7 +186,7 @@ (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 @@ -194,7 +194,7 @@ :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))) diff --git a/define-proto.lisp b/define-proto.lisp index 00219e6..2d8b8d0 100644 --- a/define-proto.lisp +++ b/define-proto.lisp @@ -635,6 +635,11 @@ :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) @@ -704,7 +709,15 @@ ;; 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 diff --git a/pkgdcl.lisp b/pkgdcl.lisp index fb4922d..d02fe1f 100644 --- a/pkgdcl.lisp +++ b/pkgdcl.lisp @@ -278,4 +278,8 @@ ;; Stuff for ASDF "PARSE-PROTOBUF-FILE" - "PROCESS-IMPORTS")) + "PROCESS-IMPORTS" + + ;; Stuff for RPC stubs + "*RPC-PACKAGE*" + "*RPC-CALL-FUNCTION*")) -- 2.45.2