Coverage report: /home/ellis/comp/core/lib/obj/config.lisp
Kind | Covered | All | % |
expression | 5 | 23 | 21.7 |
branch | 0 | 0 | nil |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; obj/config.lisp --- Configuration flavors
6
;; The goal of this package is to make it easy to map an object in
7
;; memory to a 'user config interface' - which could be a
8
;; configuration file, a datagram, CLI flags, etc.
10
;; This package only provides the config protocol, for other packages to
17
(in-package :obj/config)
19
(defclass config () ()
20
(:documentation "Base class for configurable objects."))
21
(defgeneric make-config (obj &rest args &key &allow-other-keys)
22
(:documentation "Make a new configuration.")
23
(:method ((self t) &key ast)
25
(list (make-config (car ast) :path (cadr ast)))
26
(atom (make-config ast)))))
28
(defgeneric find-config (obj &rest args &key &allow-other-keys)
29
(:documentation "Find an existing configuration."))
30
(defgeneric config-find (obj key &key &allow-other-keys)
31
(:documentation "Find KEY in configuration OBJ."))
32
(defgeneric config-get (obj key)
33
(:documentation "Get value of KEY in configuration OBJ."))
34
(defgeneric (setf config-get) (obj key val))
35
(defgeneric configure (obj &rest args &key &allow-other-keys)
36
(:documentation "Configure an object with supplied args."))
38
(defmacro defconfig (name direct-superclasses direct-slots &rest options)
39
"DEFCLASS sugar for CONFIG objects."
41
(defclass ,name ,(append direct-superclasses '(obj/config::config))
45
;;; TODO 2024-10-27: Simple Config AST
46
(defmacro define-simple-config (name prototype &body accessors)
47
"Define a SIMPLE-CONFIG consisting of a MAKE-* function, a predicate, a type
48
definition, and an optional list of accessors.")