From 76073a5348f43eda6e5d4256377c7bb85eacfdfa Mon Sep 17 00:00:00 2001 From: Olof-Joachim Frahm Date: Mon, 10 Jun 2013 23:40:15 +0200 Subject: [PATCH] Simplify by using ALEXANDRIA. --- cl-mock.asd | 2 +- src/methods.lisp | 15 +++++++-------- src/package.lisp | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) 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 -- 1.7.10.4