wild(carded)-module component class for asdf

Rahul Jain <[email protected]>
Newsgroups gmane.lisp.cclan.general
Message-ID <[email protected]>
I've implemented a module class which has its component names
specified by a wild-pathname. It was surprisingly easy to implement,
once I added the :parent arg to the make-instance for the
sub-components. Good work, Dan. :)

Attached is the file that has the implementation as well as a simple
test and script to run that test.



-- 
-> -/                        - Rahul Jain -                        \- <-
-> -\  http://linux.rice.edu/~rahul -=-  mailto:[email protected]   /- <-
-> -X "Structure is nothing if it is all you got. Skeletons spook  X- <-
-> -/  people if [they] try to walk around on their own. I really  \- <-
-> -\  wonder why XML does not." -- Erik Naggum, comp.lang.lisp    /- <-
|--|--------|--------------|----|-------------|------|---------|-----|-|
   (c)1996-2002, All rights reserved. Disclaimer available upon request.
wild-modules.lisp (text/x-lisp, 1.6 KB)
(in-package :asdf)

(defclass wild-module (module)
  ((component-class :accessor wild-module-component-class
                    :initform 'static-file :initarg :component-class)
   (component-options :accessor wild-module-component-options
                      :initform nil :initarg :component-options)))

(defmethod (setf module-components) (new-value (module wild-module))
  (declare (ignore new-value))
  (sysdef-error "Cannot explicitly set wild-module ~A's components. Please ~
use a wild pathname instead." module))

(defmethod reinitialize-instance :after ((self wild-module) &key)
  (let ((pathname (slot-value self 'relative-pathname)))
    (and pathname
         (not (wild-pathname-p pathname))
         (sysdef-error "Wild-module ~A specified with non-wild pathname ~A."
                       self pathname))
    (setf (slot-value self 'components)
          (let* ((*default-pathname-defaults* (component-parent-pathname self))
                 (files (directory (merge-pathnames (component-relative-pathname self))))
                 (class (wild-module-component-class self))
                 (options (wild-module-component-options self)))
            (mapcar (lambda (file)
                      (apply #'make-instance class
                             :name (file-namestring file)
                                        ;; XXX fails when wildcards are in
                                        ;; the directory or higher parts.
                             :pathname file
                             :parent self
                             options))
                    files)))))

(export '(wild-module))
wild-module.asd (wild-modules.lisp, 152 B) - not displayed
wild-module.script (text/x-lisp, 161 B)
;;; -*- Lisp -*-

(load "../asdf")
(load "../wild-modules")

(setf asdf:*central-registry* '(*default-pathname-defaults*))
(asdf:oos 'asdf:load-op 'wild-module)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.