From cb4496f15f5fad35ab42c1061746ee7753e0d3f8 Mon Sep 17 00:00:00 2001 From: Matthias Benkard Date: Sat, 4 Aug 2007 17:56:15 +0200 Subject: Implement the public function INVOKE. darcs-hash:682c1fbf416e7a5192560d02c9a3343a98eb5c02 --- Lisp/method-invocation.lisp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'Lisp/method-invocation.lisp') diff --git a/Lisp/method-invocation.lisp b/Lisp/method-invocation.lisp index 63f3e24..c7e8810 100644 --- a/Lisp/method-invocation.lisp +++ b/Lisp/method-invocation.lisp @@ -4,9 +4,35 @@ ;;; (@* "Method invocation") (defun invoke (receiver message-start &rest message-components) "FIXME" - (flet ((message-component->string (component) - ())) - (do ((message-string ()))))) + (flet ((message-component->string (symbol) + (let* ((components (split-sequence #\- (symbol-name symbol) + :remove-empty-subseqs t)) + (acc-string + (reduce #'(lambda (x y) (concatenate 'string x y)) + (mapcar #'(lambda (x) + (concatenate 'string + (string (char x 0)) + (string-downcase (subseq x 1)))) + (subseq components 1)) + :initial-value (string-downcase (first components))))) + (if (eql (find-package '#:keyword) + (symbol-package symbol)) + (concatenate 'string acc-string ":") + acc-string)))) + (do* ((components-left (cons message-start message-components) + (cddr components-left)) + (message-string (message-component->string message-start) + (concatenate 'string + message-string + (message-component->string (first components-left)))) + (arglist (if (null (rest components-left)) + nil + (list (second components-left))) + (if (null (rest components-left)) + arglist + (cons (second components-left) arglist)))) + ((null (cddr components-left)) + (apply #'invoke-by-name receiver message-string (nreverse arglist)))))) (defun invoke-by-name (receiver method-name &rest args) -- cgit v1.2.3