-
Notifications
You must be signed in to change notification settings - Fork 4
/
protocol.lisp
35 lines (29 loc) · 1.32 KB
/
protocol.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
(in-package :fwoar.cl-git.protocol)
(defgeneric -extract-object-of-type (type s repository &key &allow-other-keys)
(:method :around (type s repository &key hash)
(let ((result (call-next-method)))
(prog1 result
(when (typep result 'fwoar.cl-git:git-object)
(setf (fwoar.cl-git:hash result) hash)))))
(:method ((type (eql :tag)) s repository &key)
s))
(defgeneric component (component object)
(:argument-precedence-order object component)
(:method (component (object fwoar.cl-git.ref:ref))
(component component (fwoar.cl-git:extract-object object)))
(:method ((component sequence) object)
(reduce (lambda (cur next)
(component next cur))
component
:initial-value object)))
(defmacro defcomponent (component &body body)
(declare (ignore component body))
(error "defcomponent not available on its own"))
(defmacro defcomponents (class (object-sym component-sym) &body clauses)
`(macrolet ((defcomponent (component &body component-body)
`(defmethod component ((,',component-sym ,component)
(,',object-sym ,',class))
,@component-body)))
,@(loop for (component . component-body) in clauses
collect `(defcomponent ,component
,@component-body))))