3e9db801d234

Clean up some of the middleware code
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 09 Apr 2016 21:13:26 +0000
parents 9cf977a17d89
children 7d0cd39ee703
branches/tags (none)
files src/middleware/core.lisp src/middleware/describe.lisp src/middleware/documentation.lisp

Changes

--- a/src/middleware/core.lisp	Sat Apr 09 21:04:26 2016 +0000
+++ b/src/middleware/core.lisp	Sat Apr 09 21:13:26 2016 +0000
@@ -5,12 +5,17 @@
 
 (defmacro handle-op (message op fallback &rest body)
   `(if (equal ,op (fset:lookup ,message "op"))
-     (progn ,@body)
-     (funcall ,fallback ,message)))
+    (progn ,@body)
+    (funcall ,fallback ,message)))
 
-(defmacro define-middleware (name op message-binding &rest body)
+(defmacro define-middleware (name op message-binding &body body)
+  "Define a middleware at the symbol `name` to handle `op`.
+
+  As the body is executing `message-binding` will be bound to the message map.
+
+  "
   (let ((fallback (gensym)))
-  `(defun ,name (,fallback)
-     (lambda (,message-binding)
-       (handle-op ,message-binding ,op ,fallback
-                  ,@body)))))
+    `(defun ,name (,fallback)
+      (lambda (,message-binding)
+        (handle-op ,message-binding ,op ,fallback
+                   ,@body)))))
--- a/src/middleware/describe.lisp	Sat Apr 09 21:04:26 2016 +0000
+++ b/src/middleware/describe.lisp	Sat Apr 09 21:13:26 2016 +0000
@@ -9,9 +9,11 @@
 (define-middleware wrap-describe "describe" message
   (respond message
            (make-map "status" '("done")
+                     ;; TODO: find actual versions
                      "versions" (make-map
                                   "lisp" (make-version-map 0 0 0)
                                   "cl-nrepl" (make-version-map 0 0 0))
+                     ;; TODO: fill in supported ops
                      "ops" (make-map))))
 
 
--- a/src/middleware/documentation.lisp	Sat Apr 09 21:04:26 2016 +0000
+++ b/src/middleware/documentation.lisp	Sat Apr 09 21:13:26 2016 +0000
@@ -20,21 +20,18 @@
       t)
     (values nil nil)))
 
-
 (defun find-symbol-harder (name)
   "Return the symbol object with the given `name`.
 
-  This should work with:
+  This should work with names like:
 
     FOO (assumes the current package)
     P:FOO (looks in package P)
 
-  TODO: add support for:
-
-    P::FOO
-    :KEYWORD
-
   "
+  ;; TODO: add support for:
+  ;;   P::FOO
+  ;;   :KEYWORD
   (flet ((split-string (s delim)
            (let ((idx (position delim s)))
              (if idx
@@ -46,6 +43,7 @@
                           (find-package pack)
                           *package*)))))
 
+
 (define-middleware wrap-documentation "documentation" message
   (let ((s (find-symbol-harder (fset:lookup message "symbol"))))
     (respond message