From: Olof-Joachim Frahm Date: Mon, 10 Jun 2013 21:40:15 +0000 (+0200) Subject: Simplify by using ALEXANDRIA. X-Git-Tag: 1.0.0~10 X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=76073a5348f43eda6e5d4256377c7bb85eacfdfa;p=cl-mock.git Simplify by using ALEXANDRIA. --- diff --git a/cl-mock.asd b/cl-mock.asd index 54861d6..c6aa5f6 100644 --- a/cl-mock.asd +++ b/cl-mock.asd @@ -7,7 +7,7 @@ :description "Mocking (generic) functions." :author "Olof-Joachim Frahm " :license "Simplified BSD License" - :depends-on (#:closer-mop) + :depends-on (#:closer-mop #:alexandria) :in-order-to ((asdf:test-op (asdf:load-op #:cl-mock-tests))) :perform (asdf:test-op :after (op c) (funcall (find-symbol (symbol-name '#:run!) '#:fiveam) diff --git a/src/methods.lisp b/src/methods.lisp index 7cdbd98..ec9bba7 100644 --- a/src/methods.lisp +++ b/src/methods.lisp @@ -55,21 +55,20 @@ (defmacro progm* (methods values &body body) `(call-with-method-bindings* ,methods ,values (lambda () ,@body))) +(defun classify (specializer) + (if (classp specializer) + specializer + (find-class specializer))) + (defun call-with-method-bindings (methods values function &optional previous) (let ((methods (mapcar (lambda (method) (destructuring-bind (generic-function qualifiers specializers) method (list - (if (functionp generic-function) - generic-function - (fdefinition generic-function)) + (ensure-function generic-function) qualifiers - (mapcar (lambda (specializer) - (if (classp specializer) - specializer - (find-class specializer))) - specializers)))) + (mapcar #'classify specializers)))) methods))) (call-with-method-bindings* methods values function (or previous (find-methods methods))))) diff --git a/src/package.lisp b/src/package.lisp index 8e8ef92..a41f543 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -3,7 +3,7 @@ (in-package #:cl-user) (defpackage #:cl-mock - (:use #:closer-common-lisp) + (:use #:closer-common-lisp #:alexandria) (:export ;;; regular functions #:dflet