<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>60612</integer>
    </number>
    <user>
      <string>johnny</string>
    </user>
    <title>
      <string>macros</string>
    </title>
    <contents>
      <string>my custom macro syntax:

(define-binary-class ether ()
    ((dst :initarg :dst :binary-type (raw-bytes :length 6)
                        :documentation &quot;Destination ethernet address.&quot;
                        :initform nil)
     (src :initarg :src :binary-type (raw-bytes :length 6)
                        :documentation &quot;Source ethernet address.&quot;
                        :initform nil)
     (type :initarg :type :binary-type (raw-bytes :length 2)
                          :documentation &quot;Ethernet type.&quot;
                          :initform nil)))

generates this:

(PROGN
 (EVAL-WHEN (:COMPILE-TOPLEVEL :LOAD-TOPLEVEL :EXECUTE)
   (SETF (GET 'ETHER 'SLOTS) '(DST SRC TYPE))
   (SETF (GET 'ETHER 'SUPERCLASSES) 'NIL))
 (DEFCLASS ETHER NIL
           ((DST :INITARG :DST :DOCUMENTATION &quot;Destination ethernet address.&quot;
             :INITFORM NIL)
            (SRC :INITARG :SRC :DOCUMENTATION &quot;Source ethernet address.&quot;
             :INITFORM NIL)
            (TYPE :INITARG :TYPE :DOCUMENTATION &quot;Ethernet type.&quot; :INITFORM
             NIL)))
 (DEFMETHOD READ-OBJECT PROGN ((#:OBJECTVAR ETHER) #:STREAMVAR)
            (WITH-SLOTS (DST SRC TYPE) #:OBJECTVAR
                        (SETF DST
                                (READ-VALUE 'RAW-BYTES #:STREAMVAR :LENGTH 6))
                        (SETF SRC
                                (READ-VALUE 'RAW-BYTES #:STREAMVAR :LENGTH 6))
                        (SETF TYPE
                                (READ-VALUE 'RAW-BYTES #:STREAMVAR :LENGTH
                                            2))))
 (DEFMETHOD WRITE-OBJECT PROGN ((#:OBJECTVAR ETHER) #:STREAMVAR)
            (WITH-SLOTS (DST SRC TYPE) #:OBJECTVAR
                        (WRITE-VALUE 'RAW-BYTES #:STREAMVAR DST :LENGTH 6)
                        (WRITE-VALUE 'RAW-BYTES #:STREAMVAR SRC :LENGTH 6)
                        (WRITE-VALUE 'RAW-BYTES #:STREAMVAR TYPE :LENGTH 2))))


and is this:

(defmacro define-binary-class (name (&amp;rest superclasses) slots &amp;rest options)
  &quot;Define a class with additional :BINARY-TYPE property for every slot.&quot;
  (with-gensyms (objectvar streamvar)
    `(progn
       (eval-when (:compile-toplevel :load-toplevel :execute)
         (setf (get ',name 'slots) ',(mapcar #'first slots))
         (setf (get ',name 'superclasses) ',superclasses))
       (defclass ,name ,superclasses
         ,(mapcar #'generate-defclass-slot slots)
         ,@options)
       (defmethod read-object progn ((,objectvar ,name) ,streamvar)
         (with-slots ,(new-class-all-slots slots superclasses) ,objectvar
           ,@(mapcar #'(lambda (x) (generate-read-value x streamvar)) slots)))
       (defmethod write-object progn ((,objectvar ,name) ,streamvar)
         (with-slots ,(new-class-all-slots slots superclasses) ,objectvar
           ,@(mapcar #'(lambda (x) (generate-write-value x streamvar))
                     slots))))))
</string>
    </contents>
    <universal-time>
      <integer>3419544379</integer>
    </universal-time>
    <channel>
      <string>None</string>
    </channel>
    <colorization-mode>
      <string></string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <keyword>TRUE</keyword>
    </is-unicode>
  </paste>
</paste-with-annotations>