summaryrefslogtreecommitdiff
path: root/src/tg
diff options
context:
space:
mode:
Diffstat (limited to 'src/tg')
-rw-r--r--src/tg/method-macros.lisp9
-rw-r--r--src/tg/type-macros.lisp6
2 files changed, 11 insertions, 4 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
diff --git a/src/tg/type-macros.lisp b/src/tg/type-macros.lisp
index b9d649c..390781f 100644
--- a/src/tg/type-macros.lisp
+++ b/src/tg/type-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/type-macros 3(defpackage :ukkoclot/tg/type-macros
4 (:documentation "Macros for easy defining TG types.")
4 (:use :c2cl :iterate) 5 (:use :c2cl :iterate)
6 (:import-from :com.dieggsy.f-string :enable-f-strings)
5 (:import-from :ukkoclot/serializing :parse-value) 7 (:import-from :ukkoclot/serializing :parse-value)
6 (:import-from :ukkoclot/hash-tables :gethash-lazy) 8 (:import-from :ukkoclot/hash-tables :gethash-lazy)
7 (:import-from :ukkoclot/strings :lisp->snake-case) 9 (:import-from :ukkoclot/strings :lisp->snake-case)
@@ -10,6 +12,8 @@
10 (:export :define-tg-type)) 12 (:export :define-tg-type))
11(in-package :ukkoclot/tg/type-macros) 13(in-package :ukkoclot/tg/type-macros)
12 14
15(enable-f-strings)
16
13(eval-when (:compile-toplevel :load-toplevel :execute) 17(eval-when (:compile-toplevel :load-toplevel :execute)
14 (defstruct (field (:constructor make-field%)) name type default skip-if-default) 18 (defstruct (field (:constructor make-field%)) name type default skip-if-default)
15 19
@@ -20,7 +24,7 @@
20 &optional (default +unique+) 24 &optional (default +unique+)
21 &key (skip-if-default (not (eq default +unique+)))) 25 &key (skip-if-default (not (eq default +unique+))))
22 (let ((default (if (eq default +unique+) 26 (let ((default (if (eq default +unique+)
23 `(error ,(format nil "No value given for ~A" name)) 27 `(error ,#f"No value given for {name}")
24 default))) 28 default)))
25 (make-field% :name name 29 (make-field% :name name
26 :type type 30 :type type