Initial revision
[sbcl.git] / src / compiler / generic / early-vm-macs.lisp
1 ;;;; This software is part of the SBCL system. See the README file for
2 ;;;; more information.
3 ;;;;
4 ;;;; This software is derived from the CMU CL system, which was
5 ;;;; written at Carnegie Mellon University and released into the
6 ;;;; public domain. The software is in the public domain and is
7 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
8 ;;;; files for more information.
9
10 (in-package "SB!VM")
11
12 (file-comment
13   "$Header$")
14
15 (defmacro defenum ((&key (prefix "") (suffix "") (start 0) (step 1))
16                    &rest identifiers)
17   (let ((results nil)
18         (index 0)
19         (start (eval start))
20         (step (eval step)))
21     (dolist (id identifiers)
22       (when id
23         (multiple-value-bind (root docs)
24             (if (consp id)
25                 (values (car id) (cdr id))
26                 (values id nil))
27           (push `(defconstant ,(intern (concatenate 'simple-string
28                                                     (string prefix)
29                                                     (string root)
30                                                     (string suffix)))
31                    ,(+ start (* step index))
32                    ,@docs)
33                 results)))
34       (incf index))
35     `(eval-when (:compile-toplevel :load-toplevel :execute)
36        ,@(nreverse results))))