library: cl-annot

macro_name: export-slots

context_lines:
ass-definition-form))))
                  ,class-definition-form)))
       (t class-definition-form)))
   class-definition-form))

(defmacro export-class (class-definition-form)
  `(annot.std:export*
(export-slots
(export-accessors
      ,class-definition-form))))

(defmacro export-structure (class-definition-form)
  `(annot.std:export*
    (export-slots
     (export-accessors
      (export-constructors


context_lines:
class (class-definition-form)
  `(annot.std:export*
    (export-slots
     (export-accessors
      ,class-definition-form))))

(defmacro export-structure (class-definition-form)
  `(annot.std:export*
(export-slots
(export-accessors
      (export-constructors
       ,class-definition-form)))))


macro_name: export-accessors

context_lines:
m))))
                  ,class-definition-form)))
       (t class-definition-form)))
   class-definition-form))

(defmacro export-class (class-definition-form)
  `(annot.std:export*
    (export-slots
(export-accessors
,class-definition-form))))

(defmacro export-structure (class-definition-form)
  `(annot.std:export*
    (export-slots
     (export-accessors
      (export-constructors
       ,class-definition


context_lines:
ition-form)
  `(annot.std:export*
    (export-slots
     (export-accessors
      ,class-definition-form))))

(defmacro export-structure (class-definition-form)
  `(annot.std:export*
    (export-slots
(export-accessors
(export-constructors
       ,class-definition-form)))))


macro_name: export-constructors

context_lines:
td:export*
    (export-slots
     (export-accessors
      ,class-definition-form))))

(defmacro export-structure (class-definition-form)
  `(annot.std:export*
    (export-slots
     (export-accessors
(export-constructors
,class-definition-form)))))


macro_name: def-slot-annotation

call_form: (def-slot-annotation optional (init-form) (unless (plist-member slot-options :initarg) (setf (getf slot-options :initarg) (make-keyword slot-name))) (unless (plist-member slot-options :initform) (setf (getf slot-options :initform) init-form)))

context_lines:
ind (slot-name . slot-options)
           (if (consp ,slot-specifier)
               ,slot-specifier
               (list ,slot-specifier))
         ,@body
         (cons slot-name slot-options)))))
(def-slot-annotation optional (init-form)
(unless (plist-member slot-options :initarg)
    (setf (getf slot-options :initarg)
          (make-keyword slot-name)))
  (unless (plist-member slot-options :initform)
    (setf (getf slot-options


call_form: (def-slot-annotation required () (when (plist-member slot-options :initform) (error "Required slot ~A must not have :initform" slot-name)) (unless (plist-member slot-options :initarg) (setf (getf slot-options :initarg) (make-keyword slot-name))) (setf (getf slot-options :initform) `(required-argument ,(getf slot-options :initarg))))

context_lines:
lot-options :initarg)
    (setf (getf slot-options :initarg)
          (make-keyword slot-name)))
  (unless (plist-member slot-options :initform)
    (setf (getf slot-options :initform) init-form)))
(def-slot-annotation required ()
(when (plist-member slot-options :initform)
    (error "Required slot ~A must not have :initform" slot-name))
  (unless (plist-member slot-options :initarg)
    (setf (getf slot-options :initarg)


macro_name: %annotation

call_form: (%annotation ,annot ,@args)

context_lines:
nline-p))

(defun (setf annotation-inline-p) (inline-p annot)
  (setf (get annot 'annotation-inline-p) inline-p))

(defun annotation-form (annot args)
  "Make an annotation-form with ANNOT and ARGS."
`(%annotation ,annot ,@args))
(defun annotation-form-p (form)
  "Return non-nil if FORM is an annotation-form."
  (and (consp form)
       (consp (cdr form))
       (eq (car form) '%annotation)))


macro_name: defannotation

call_form: (defannotation metaclass (metaclass class-definition-form) (:arity 2) (progn-form-replace-last (lambda (class-definition-form) (if (get-class-option :metaclass class-definition-form) (error ":metaclass is not empty") (append class-definition-form `((:metaclass ,metaclass))))) class-definition-form))

context_lines:
xport-class)
  (:import-from :alexandria
                :ensure-list
                :curry
                :compose
                :if-let
                :symbolicate))
(in-package :annot.class)
(defannotation metaclass (metaclass class-definition-form)
(:arity 2)
  (progn-form-replace-last
   (lambda (class-definition-form)
     (if (get-class-option :metaclass class-definition-form)
         (error ":metaclass is not empty")
         (append c


call_form: (defannotation doc (docstring definition-form) (:arity 2) "Add DOCSTRING documentation for DEFINITION-FORM." (progn-form-replace-last (lambda (definition-form) (case (definition-form-type definition-form) ((defvar defparameter defconstant defun defmethod defmacro deftype define-compiler-macro) (destructuring-bind (def name arg . body) definition-form `(,def ,name ,arg ,docstring ,@body))) ((defstruct) (destructuring-bind (def name-and-options . slots) definition-form `(,def ,name-and-options ,docstring ,@slots))) ((defclass define-condition) (destructuring-bind (def name supers slots . opts) definition-form (pushnew `(:documentation ,docstring) opts :key #'car) `(,def ,name ,supers ,slots ,@opts))) ((defgeneric) (destructuring-bind (def name args . opts) definition-form (pushnew `(:documentation ,docstring) opts :key #'car) `(,def ,name ,args ,@opts))) (t (error "Documentation not supported: ~a" definition-form)))) definition-form))

context_lines:
(in-package :cl-user)
(defpackage cl-annot.doc
  (:nicknames :annot.doc)
  (:use :cl
        :annot.util
        :annot.helper)
  (:export :doc))
(in-package :annot.doc)
(defannotation doc (docstring definition-form)
(:arity 2)
  "Add DOCSTRING documentation for DEFINITION-FORM."
  (progn-form-replace-last
   (lambda (definition-form)
     (case (definition-form-type definition-form)
       ((defvar defparame


call_form: (defannotation ,name ,(append args (list slot-specifier)) (:inline t :arity ,(1+ (length args))) (destructuring-bind (slot-name . slot-options) (if (consp ,slot-specifier) ,slot-specifier (list ,slot-specifier)) ,@body (cons slot-name slot-options)))

context_lines:
:required))
(in-package :annot.slot)

(defun required-argument (name)
  (error "Must supply ~S" name))

(defmacro def-slot-annotation (name args &body body)
  (with-gensyms (slot-specifier)
`(defannotation ,name ,(append args (list slot-specifier))
(:inline t :arity ,(1+ (length args)))
       (destructuring-bind (slot-name . slot-options)
           (if (consp ,slot-specifier)
               ,slot-specifier
               (list ,slot-


call_form: (defannotation export* (definition-form) (:alias export) "Export the definition symbol of DEFINITION-FORM." (let ((name (definition-form-symbol definition-form))) (if name `(progn (export ',name) ,definition-form) definition-form)))

context_lines:
:ignorable*
		   :dynamic-extent*
		   :declaration*
		   :special*
           :type*
           :ftype*
           :optimize*
           :inline*
           :notinline*))
(in-package :annot.std)
(defannotation export* (definition-form)
(:alias export)
  "Export the definition symbol of DEFINITION-FORM."
  (let ((name (definition-form-symbol definition-form)))
    (if name
        `(progn
           (export ',name)
           ,d


context_lines:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; simple one-or-more variables
;;;;

(defun %declare-list-or-symbol (vars sym)
  (if (listp vars)
      `(declare (,sym ,@vars))
      `(declare (,sym ,vars))))
(defannotation ignore* (vars) (:alias ignore :inline t)
"Shorthand for (DECLARE (IGNORE ...))."
  (%declare-list-or-symbol vars 'ignore))

(defannotation ignorable* (vars) (:alias ignorable :inline t)
  "Shorthand for (DECLARE (IGNORABLE ...))."
  (%dec


context_lines:
s) (:alias special :inline t)
  "Shorthand for (DECLARE (SPECIAL ...))."
  (%declare-list-or-symbol vars 'special))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; others
;;;;
(defannotation type* (typespec name)
(:alias type :arity 2 :inline t)
  "Shorthand for (DECLARE (TYPE ...))."
  (if (consp name)
      ;; TODO
      ()
      `(declare (type ,typespec ,name))))

(defannotation ftype* (typespec name)


context_lines:
(defannotation type* (typespec name)
    (:alias type :arity 2 :inline t)
  "Shorthand for (DECLARE (TYPE ...))."
  (if (consp name)
      ;; TODO
      ()
      `(declare (type ,typespec ,name))))
(defannotation ftype* (typespec name)
(:alias ftype :arity 2 :inline t)
  "Shorthand for (DECLARE (FTYPE ...))."
  (if (consp name)
      ;; TODO
      ()
      `(declare (ftype ,typespec ,name))))

(defannotation optimize* (quality)


context_lines:
fannotation ftype* (typespec name)
    (:alias ftype :arity 2 :inline t)
  "Shorthand for (DECLARE (FTYPE ...))."
  (if (consp name)
      ;; TODO
      ()
      `(declare (ftype ,typespec ,name))))
(defannotation optimize* (quality)
(:alias optimize :inline t)
  "Shorthand for (DECLARE (OPTIMIZE ...))."
  `(declare (optimize ,quality)))

(defannotation inline* (name)
    (:alias inline :inline t)
  "Shorthand for (DECLARE (I


call_form: (defannotation inline* (name) (:alias inline :inline t) "Shorthand for (DECLARE (INLINE ...))." (let ((symbol (definition-form-symbol name)) (type (definition-form-type name))) (if (and symbol (member type '(defun defmethod))) `(progn (declaim (inline ,symbol)) ,name) `(declare (inline ,name)))))

context_lines:
()
      `(declare (ftype ,typespec ,name))))

(defannotation optimize* (quality)
    (:alias optimize :inline t)
  "Shorthand for (DECLARE (OPTIMIZE ...))."
  `(declare (optimize ,quality)))
(defannotation inline* (name)
(:alias inline :inline t)
  "Shorthand for (DECLARE (INLINE ...))."
  (let ((symbol (definition-form-symbol name))
        (type (definition-form-type name)))
    (if (and symbol
             (me


call_form: (defannotation notinline* (name) (:alias notinline :inline t) "Shorthand for (DECLARE (NOTINLINE ...))." (let ((symbol (definition-form-symbol name)) (type (definition-form-type name))) (if (and symbol (member type '(defun defmethod))) `(progn (declaim (notinline ,symbol)) ,name) `(declare (notinline ,name)))))

context_lines:
)
    (if (and symbol
             (member type
                     '(defun defmethod)))
        `(progn
           (declaim (inline ,symbol))
           ,name)
        `(declare (inline ,name)))))
(defannotation notinline* (name)
(:alias notinline :inline t)
  "Shorthand for (DECLARE (NOTINLINE ...))."
  (let ((symbol (definition-form-symbol name))
        (type (definition-form-type name)))
    (if (and symbol


call_form: (defannotation annotation (options function-definition-form) (:arity 2) (let ((name (definition-form-symbol (progn-form-last function-definition-form)))) `(progn (set-annotation-options ',name ',options) ,function-definition-form)))

context_lines:
tf (annotation-inline-p name) t)))

(defmacro defannotation (name lambda-list options &body body)
  `(progn
     (set-annotation-options ',name ',options)
     (defmacro ,name ,lambda-list ,@body)))
(defannotation annotation (options function-definition-form)
(:arity 2)
  (let ((name (definition-form-symbol
                  (progn-form-last function-definition-form))))
    `(progn
       (set-annotation-options ',name ',options)
       ,function-defi


macro_name: fun

call_form: (functionp last)

context_lines:
mal-form progn-form)))
    (if (and (consp progn-form)
             (eq (car progn-form) 'progn))
        `(,@(butlast progn-form)
            ,(progn-form-replace-last last (car (last progn-form))))
(if (functionp last)
(funcall last progn-form)
            last))))

(defun definition-form-symbol (definition-form)
  "Return the symbol of DEFINITION-FORM."
  (let* ((form (progn-form-last definition-form))


call_form: (funcall last progn-form)

context_lines:
f (and (consp progn-form)
             (eq (car progn-form) 'progn))
        `(,@(butlast progn-form)
            ,(progn-form-replace-last last (car (last progn-form))))
        (if (functionp last)
(funcall last progn-form)
last))))

(defun definition-form-symbol (definition-form)
  "Return the symbol of DEFINITION-FORM."
  (let* ((form (progn-form-last definition-form))
         (second (when (consp form)


call_form: (function function-definition-form)

context_lines:
tion-form-type (definition-form)
  "Return the type of DEFINITION-FORM."
  (let* ((form (progn-form-last definition-form))
         (type (when (consp form)
                 (car form))))
    type))
(defun replace-function-body (function function-definition-form)
"Replace the body of FUNCTION-DEFINITION-FORM by calling FUNCTION
with name, lambda-list and the body as arguments."
  (progn-form-replace-last
   (lambda (function-definition-form)
     (destructu


call_form: (function-definition-form)

context_lines:
ace-function-body (function function-definition-form)
  "Replace the body of FUNCTION-DEFINITION-FORM by calling FUNCTION
with name, lambda-list and the body as arguments."
  (progn-form-replace-last
(lambda (function-definition-form)
(destructuring-bind (type name lambda-list . body)
         function-definition-form
       (let (header)
         (when (and (stringp (car body))
                    (cdr body))
           (set


context_lines:
en (and (stringp (car body))
                    (cdr body))
           (setf header (list (car body))
                 body (cdr body)))
         `(,type ,name ,lambda-list
                 ,@header
,(funcall function name lambda-list body)))))
function-definition-form))

(defun slot-specifiers (class-definition-form)
  "Return class-specifiers of CLASS-DEFINITION-FORM."
  (case (first class-definition-form)
    (defclass (nth 3 (progn-f


call_form: (function class-definition-form)

context_lines:
fetch the slots after it
		   (nthcdr 3 (progn-form-last class-definition-form))
		   ;; There's no documentation string, fetch the slots
		   (nthcdr 2 (progn-form-last class-definition-form))))))
(defun replace-slot-specifiers (function class-definition-form)
"Replace slot-specifiers of CLASS-DEFINITION-FORM with FUNCTION. The
result value will be a class definition form also."
  (progn-form-replace-last
   (lambda (class-definition-form)
     (destruct


macro_name: mac

call_form: (macroexpand-some `(,annot ,@args))

context_lines:
))
(in-package :annot.expand)

(defun expand-annotation (annot args)
  "Expand ANNOT. ARGS will be expanded prior to this
form (call-by-value)."
  (let ((args (mapcar #'expand-annotation-form args)))
(values (macroexpand-some `(,annot ,@args)))))
(defun expand-annotation-form (form)
  "Expand annotation FORM if possible."
  (if (annotation-form-p form)
      (expand-annotation (cadr form) (cddr form))
      form))

(defmacro %annotation (ann


call_form: (macro-function symbol)

context_lines:
ed PROP."
  (loop for (name value) on plist by #'cddr
        if (string= prop name)
          collect value))

(defun macrop (symbol)
  "Return non-nil if SYMBOL is a macro."
  (and (symbolp symbol)
(macro-function symbol)
t))

(defun macroexpand-some (form)
  "Expand FORM once. The result form won't be nil."
  (multiple-value-bind (new-form expanded-p)
      (macroexpand-1 form)
    (if (or (not expanded-p) (nu


call_form: (macroexpand-1 form)

context_lines:
ro."
  (and (symbolp symbol)
       (macro-function symbol)
       t))

(defun macroexpand-some (form)
  "Expand FORM once. The result form won't be nil."
  (multiple-value-bind (new-form expanded-p)
(macroexpand-1 form)
(if (or (not expanded-p) (null new-form))
        (values form nil)
        (values new-form expanded-p))))

(defun macroexpand-until-normal-form (form)
  "Expand FORM until it brecomes normal-fo


call_form: (macrop (car form))

context_lines:
(null new-form))
        (values form nil)
        (values new-form expanded-p))))

(defun macroexpand-until-normal-form (form)
  "Expand FORM until it brecomes normal-form."
  (if (and (consp form)
(macrop (car form))
(let ((package (symbol-package (car form))))
             (and package
                  (member package
                          (list (find-package :cl)


context_lines:
r package
                          (list (find-package :cl)
                                #+clisp (find-package :clos))))))
      (values form nil)
      (multiple-value-bind (new-form expanded-p)
(macroexpand-1 form)
(if (or (not expanded-p) (null new-form))
            (values form nil)
            (values (macroexpand-until-normal-form new-form) t)))))

(defun progn-form-last (progn-form)
  "Return the


context_lines:
age :clos))))))
      (values form nil)
      (multiple-value-bind (new-form expanded-p)
          (macroexpand-1 form)
        (if (or (not expanded-p) (null new-form))
            (values form nil)
(values (macroexpand-until-normal-form new-form) t)))))
(defun progn-form-last (progn-form)
  "Return the last form of PROGN-FORM which should be evaluated at
last. If macro forms seen, the macro forms will be expanded using
MACROEXPAND-UNTIL-NORMAL-FORM


context_lines:
defun progn-form-last (progn-form)
  "Return the last form of PROGN-FORM which should be evaluated at
last. If macro forms seen, the macro forms will be expanded using
MACROEXPAND-UNTIL-NORMAL-FORM."
(let ((progn-form (macroexpand-until-normal-form progn-form)))
(if (and (consp progn-form)
             (eq (car progn-form) 'progn))
        (progn-form-last (car (last progn-form)))
        progn-form)))

(defun progn-form-replace-last (last progn-form)


context_lines:
RM with LAST. If LAST is a
function, the function will be called with the last form and used for
replacing. If macro forms seen, the macro forms will be expanded using
MACROEXPAND-UNTIL-NORMAL-FORM."
(let ((progn-form (macroexpand-until-normal-form progn-form)))
(if (and (consp progn-form)
             (eq (car progn-form) 'progn))
        `(,@(butlast progn-form)
            ,(progn-form-replace-last last (car (last progn-form))))
        (if (functionp


call_form: (macroexpand '@export (defun x ()))

context_lines:
mbol-status :m)
    :external
    "method exported?")
(is-type @export (defclass c () ())
         'standard-class
         "export class")
(is (symbol-status :c)
    :external
    "class exported?")
(is (macroexpand '@export (defun x ()))
'(progn
      (export 'x)
      (defun x ()))
    "@export expansion 1")
(is (macroexpand '@export (fun))
    '(progn
      (export 'f)
      (fun))
    "@export expansion 2")
(is-type @export (d


call_form: (macroexpand '@export (fun))

context_lines:
"export class")
(is (symbol-status :c)
    :external
    "class exported?")
(is (macroexpand '@export (defun x ()))
    '(progn
      (export 'x)
      (defun x ()))
    "@export expansion 1")
(is (macroexpand '@export (fun))
'(progn
      (export 'f)
      (fun))
    "@export expansion 2")
(is-type @export (defstruct s ())
         'symbol
         "export structure")
(is (symbol-status :s)
    :external
    "structu