summaryrefslogtreecommitdiff
path: root/src/tg/method-macros.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tg/method-macros.lisp')
-rw-r--r--src/tg/method-macros.lisp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/tg/method-macros.lisp b/src/tg/method-macros.lisp
index e614db9..817a3e3 100644
--- a/src/tg/method-macros.lisp
+++ b/src/tg/method-macros.lisp
@@ -1,7 +1,9 @@
1;; SPDX-License-Identifier: EUPL-1.2 1;; SPDX-License-Identifier: EUPL-1.2
2;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com> 2;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com>
3(defpackage :ukkoclot/tg/method-macros 3(defpackage :ukkoclot/tg/method-macros
4 (:documentation "Macros for easy defining TG methods."
4 (:use :c2cl :iterate) 5 (:use :c2cl :iterate)
6 (:import-from :com.dieggsy.f-string :enable-f-strings)
5 (:import-from :serapeum :take) 7 (:import-from :serapeum :take)
6 (:import-from :ukkoclot/state :bot) 8 (:import-from :ukkoclot/state :bot)
7 (:import-from :ukkoclot/strings :ends-with :lisp->camel-case) 9 (:import-from :ukkoclot/strings :ends-with :lisp->camel-case)
@@ -9,6 +11,8 @@
9 (:export :define-tg-method)) 11 (:export :define-tg-method))
10(in-package :ukkoclot/tg/method-macros) 12(in-package :ukkoclot/tg/method-macros)
11 13
14(enable-f-strings)
15
12(eval-when (:compile-toplevel :load-toplevel :execute) 16(eval-when (:compile-toplevel :load-toplevel :execute)
13 (defstruct (param (:constructor make-param%)) name type default skip-if-default) 17 (defstruct (param (:constructor make-param%)) name type default skip-if-default)
14 18
@@ -19,7 +23,7 @@
19 &optional (default +unique+) 23 &optional (default +unique+)
20 &key (skip-if-default (not (eq default +unique+)))) 24 &key (skip-if-default (not (eq default +unique+))))
21 (let ((default (if (eq default +unique+) 25 (let ((default (if (eq default +unique+)
22 `(error ,(format nil "No value given for ~A" name)) 26 `(error ,#f"No value given for {name}")
23 default))) 27 default)))
24 (make-param% :name name 28 (make-param% :name name
25 :type type 29 :type type
@@ -67,8 +71,7 @@
67 ,return-type) 71 ,return-type)
68 ,name)))) 72 ,name))))
69 73
70(defmacro define-tg-method ( 74(defmacro define-tg-method ((name type &optional (method :POST))
71 (name type &optional (method :POST))
72 &body param-specs) 75 &body param-specs)
73 (let ((params (parse-param-specs param-specs))) 76 (let ((params (parse-param-specs param-specs)))
74 `(progn 77 `(progn