Coverage report: /home/ellis/comp/core/lib/organ/macs.lisp

KindCoveredAll%
expression044 0.0
branch00nil
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 (in-package :organ)
2
 
3
 (defmacro define-org-element (name slots &key documentation greater lesser)
4
   (let ((docstring (or documentation (format nil "Org ~a element class." name)))
5
         (sname (sym-to-org-class-name name)))
6
     (eval-always
7
       `(progn
8
          (defclass ,sname (,(or (when greater 'org-greater-element) 
9
                                 (when lesser 'org-lesser-element) 
10
                                 'org-element))
11
            ,slots
12
            (:documentation ,docstring))
13
          (defmethod org-create ((type (eql ,(sb-int:keywordicate name))) &rest initargs)
14
            (apply #'make-instance (sym-to-org-class-name type) initargs))
15
          (export '(,sname) :organ)))))
16
 
17
 (defmacro define-org-object (name slots &key include documentation)
18
   (let ((docstring (or documentation (format nil "Org ~a object structure." name)))
19
         (obj (sym-to-org-class-name name)))
20
     `(progn
21
        (defstruct (,obj ,@(when include (list `(:include ,(sym-to-org-class-name include))))) ,docstring ,@slots)
22
        (defmethod org-create ((type (eql ,(sb-int:keywordicate name))) &rest initargs)
23
            (apply #'make-instance (sym-to-org-class-name type) initargs))
24
        (export '(,obj) :organ))))
25
 
26
 ;; (macroexpand '(define-org-parser (headline) (print headline)))
27
 (defmacro define-org-parser ((name &key (from 'string)) &body body)
28
   "Define an ORG-PARSE method specializer for org type specifier NAME with body BODY."
29
   (let ((elt (sb-int:keywordicate name)))
30
     `(progn
31
        (defmethod org-parse ((type (eql ,elt)) (input ,from))
32
          ;;  NOTE 2023-12-27: (,name (org-create ,nvar)) == bad idea.
33
          ;; need parser to be fallible so shouldn't create an object
34
          ;; upfront. We should delay initialization until the last moment
35
          ;; -- match up front.
36
          ,@body))))
37
 
38
 ;; It's super helpful to have our objects printed with their contents
39
 ;; when reasonable
40
 (defmacro define-org-printer ())