From 797bc62a9b31ab7d063ced4d3285fde1c50fea05 Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Sat, 18 Oct 2025 07:16:59 +0300 Subject: Add com.dieggsy.f-string, replace simple formats with #f"strings" --- src/tg/method-macros.lisp | 9 ++++++--- src/tg/type-macros.lisp | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src/tg') 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 @@ ;; SPDX-License-Identifier: EUPL-1.2 ;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs (defpackage :ukkoclot/tg/method-macros + (:documentation "Macros for easy defining TG methods." (:use :c2cl :iterate) + (:import-from :com.dieggsy.f-string :enable-f-strings) (:import-from :serapeum :take) (:import-from :ukkoclot/state :bot) (:import-from :ukkoclot/strings :ends-with :lisp->camel-case) @@ -9,6 +11,8 @@ (:export :define-tg-method)) (in-package :ukkoclot/tg/method-macros) +(enable-f-strings) + (eval-when (:compile-toplevel :load-toplevel :execute) (defstruct (param (:constructor make-param%)) name type default skip-if-default) @@ -19,7 +23,7 @@ &optional (default +unique+) &key (skip-if-default (not (eq default +unique+)))) (let ((default (if (eq default +unique+) - `(error ,(format nil "No value given for ~A" name)) + `(error ,#f"No value given for {name}") default))) (make-param% :name name :type type @@ -67,8 +71,7 @@ ,return-type) ,name)))) -(defmacro define-tg-method ( - (name type &optional (method :POST)) +(defmacro define-tg-method ((name type &optional (method :POST)) &body param-specs) (let ((params (parse-param-specs param-specs))) `(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 @@ ;; SPDX-License-Identifier: EUPL-1.2 ;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs (defpackage :ukkoclot/tg/type-macros + (:documentation "Macros for easy defining TG types.") (:use :c2cl :iterate) + (:import-from :com.dieggsy.f-string :enable-f-strings) (:import-from :ukkoclot/serializing :parse-value) (:import-from :ukkoclot/hash-tables :gethash-lazy) (:import-from :ukkoclot/strings :lisp->snake-case) @@ -10,6 +12,8 @@ (:export :define-tg-type)) (in-package :ukkoclot/tg/type-macros) +(enable-f-strings) + (eval-when (:compile-toplevel :load-toplevel :execute) (defstruct (field (:constructor make-field%)) name type default skip-if-default) @@ -20,7 +24,7 @@ &optional (default +unique+) &key (skip-if-default (not (eq default +unique+)))) (let ((default (if (eq default +unique+) - `(error ,(format nil "No value given for ~A" name)) + `(error ,#f"No value given for {name}") default))) (make-field% :name name :type type -- cgit v1.2.3