summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2025-10-24 08:09:46 +0300
committerGravatar Uko Kokņevičs2025-10-24 08:09:46 +0300
commit69d775b3d3a8f5bdb920630c7bdf6ec1b264b203 (patch)
tree8e9be882f3d690abed0f37e9a29c9dfd7686e9e8 /src
parentUpdate f-string (diff)
downloadukkoclot-69d775b3d3a8f5bdb920630c7bdf6ec1b264b203.tar.gz
ukkoclot-69d775b3d3a8f5bdb920630c7bdf6ec1b264b203.tar.xz
ukkoclot-69d775b3d3a8f5bdb920630c7bdf6ec1b264b203.zip
Configure a custom readtable explicitly
Diffstat (limited to 'src')
-rw-r--r--src/inline-bots.lisp6
-rw-r--r--src/main.lisp6
-rw-r--r--src/readtable.lisp14
-rw-r--r--src/rw-lock.lisp8
-rw-r--r--src/state.lisp6
-rw-r--r--src/tg/method-macros.lisp7
-rw-r--r--src/tg/type-macros.lisp9
7 files changed, 34 insertions, 22 deletions
diff --git a/src/inline-bots.lisp b/src/inline-bots.lisp
index f4d8a8d..db9d8ff 100644
--- a/src/inline-bots.lisp
+++ b/src/inline-bots.lisp
@@ -3,16 +3,16 @@
3(defpackage :ukkoclot/src/inline-bots 3(defpackage :ukkoclot/src/inline-bots
4 (:documentation "This package deals with removing unwanted inline bot usage") 4 (:documentation "This package deals with removing unwanted inline bot usage")
5 (:use :c2cl :ukkoclot/src/tg) 5 (:use :c2cl :ukkoclot/src/tg)
6 (:import-from :com.dieggsy.f-string :enable-f-strings)
7 (:import-from :conf) 6 (:import-from :conf)
8 (:import-from :log) 7 (:import-from :log)
8 (:import-from :named-readtables :in-readtable)
9 (:import-from :serapeum :->) 9 (:import-from :serapeum :->)
10 (:import-from :state) 10 (:import-from :state)
11 (:import-from :ukkoclot/src/readtable :readtable)
11 (:local-nicknames (:db :ukkoclot/src/db)) 12 (:local-nicknames (:db :ukkoclot/src/db))
12 (:export :blacklist-inline-bot :on-inline-bot :whitelist-inline-bot)) 13 (:export :blacklist-inline-bot :on-inline-bot :whitelist-inline-bot))
13(in-package :ukkoclot/src/inline-bots) 14(in-package :ukkoclot/src/inline-bots)
14 15(in-readtable readtable)
15(enable-f-strings)
16 16
17(-> blacklist-inline-bot (integer) (values &optional)) 17(-> blacklist-inline-bot (integer) (values &optional))
18(defun blacklist-inline-bot (inline-bot-id) 18(defun blacklist-inline-bot (inline-bot-id)
diff --git a/src/main.lisp b/src/main.lisp
index 13da5af..f435bf3 100644
--- a/src/main.lisp
+++ b/src/main.lisp
@@ -5,12 +5,13 @@
5 (:nicknames :ukkoclot) 5 (:nicknames :ukkoclot)
6 (:use :c2cl :iterate :ukkoclot/src/inline-bots :ukkoclot/src/tg) 6 (:use :c2cl :iterate :ukkoclot/src/inline-bots :ukkoclot/src/tg)
7 (:import-from :alexandria :when-let) 7 (:import-from :alexandria :when-let)
8 (:import-from :com.dieggsy.f-string :enable-f-strings)
9 (:import-from :conf) 8 (:import-from :conf)
10 (:import-from :log) 9 (:import-from :log)
10 (:import-from :named-readtables :in-readtable)
11 (:import-from :serapeum :-> :drop) 11 (:import-from :serapeum :-> :drop)
12 (:import-from :state :*state* :make-state) 12 (:import-from :state :*state* :make-state)
13 (:import-from :str) 13 (:import-from :str)
14 (:import-from :ukkoclot/src/readtable :readtable)
14 (:import-from :ukkoclot/src/db :with-db) 15 (:import-from :ukkoclot/src/db :with-db)
15 (:import-from :ukkoclot/src/serializing :fixup-value) 16 (:import-from :ukkoclot/src/serializing :fixup-value)
16 (:import-from :ukkoclot/src/strings :escape-xml :is-tg-whitespace :is-tg-whitespace-str) 17 (:import-from :ukkoclot/src/strings :escape-xml :is-tg-whitespace :is-tg-whitespace-str)
@@ -18,8 +19,7 @@
18 (:jzon :com.inuoe.jzon)) 19 (:jzon :com.inuoe.jzon))
19 (:export :main)) 20 (:export :main))
20(in-package :ukkoclot/src/main) 21(in-package :ukkoclot/src/main)
21 22(in-readtable readtable)
22(enable-f-strings)
23 23
24(defvar *in-prod* nil) 24(defvar *in-prod* nil)
25 25
diff --git a/src/readtable.lisp b/src/readtable.lisp
new file mode 100644
index 0000000..ee5af0a
--- /dev/null
+++ b/src/readtable.lisp
@@ -0,0 +1,14 @@
1;; SPDX-License-Identifier: EUPL-1.2
2;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com>
3(defpackage :ukkoclot/src/readtable
4 (:documentation "Defines the custom readtable used within this project.")
5 (:use :c2cl)
6 (:import-from :named-readtables :defreadtable)
7 (:import-from :com.dieggsy.f-string :f-string-reader)
8 (:export :readtable))
9(in-package :ukkoclot/src/readtable)
10
11(defreadtable readtable
12 (:merge :standard)
13 (:dispatch-macro-char #\# #\f #'f-string-reader)
14 (:case :upcase))
diff --git a/src/rw-lock.lisp b/src/rw-lock.lisp
index b8d08b1..2a5e2c3 100644
--- a/src/rw-lock.lisp
+++ b/src/rw-lock.lisp
@@ -4,10 +4,12 @@
4 (:documentation "Implementation of a shared/read-write lock.") 4 (:documentation "Implementation of a shared/read-write lock.")
5 (:use :c2cl :bt2 :iterate) 5 (:use :c2cl :bt2 :iterate)
6 (:import-from :alexandria :whichever :with-gensyms) 6 (:import-from :alexandria :whichever :with-gensyms)
7 (:import-from :com.dieggsy.f-string :enable-f-strings) 7 (:import-from :named-readtables :in-readtable)
8 ;; These imports make this SBCL-dependent, but technically speaking we could live without them.
8 (:import-from :sb-sys 9 (:import-from :sb-sys
9 :allow-with-interrupts :with-local-interrupts :without-interrupts) 10 :allow-with-interrupts :with-local-interrupts :without-interrupts)
10 (:import-from :serapeum :->) 11 (:import-from :serapeum :->)
12 (:import-from :ukkoclot/src/readtable :readtable)
11 (:export 13 (:export
12 #:rw-lock 14 #:rw-lock
13 #:rw-lock-p 15 #:rw-lock-p
@@ -19,9 +21,7 @@
19 #:release-write-lock 21 #:release-write-lock
20 #:with-write-lock)) 22 #:with-write-lock))
21(in-package :ukkoclot/src/rw-lock) 23(in-package :ukkoclot/src/rw-lock)
22 24(in-readtable readtable)
23(eval-when (:compile-toplevel :load-toplevel :execute)
24 (enable-f-strings))
25 25
26;; TODO: Use atomic-integer in best-case for read locks to decrease contention 26;; TODO: Use atomic-integer in best-case for read locks to decrease contention
27(defstruct (rw-lock (:constructor make-rw-lock%)) 27(defstruct (rw-lock (:constructor make-rw-lock%))
diff --git a/src/state.lisp b/src/state.lisp
index 9f1a38f..e2052e3 100644
--- a/src/state.lisp
+++ b/src/state.lisp
@@ -4,10 +4,11 @@
4 (:documentation "Holds the global state") 4 (:documentation "Holds the global state")
5 (:nicknames :state) 5 (:nicknames :state)
6 (:use :c2cl :ukkoclot/src/rw-lock) 6 (:use :c2cl :ukkoclot/src/rw-lock)
7 (:import-from :com.dieggsy.f-string :enable-f-strings)
8 (:import-from :conf :config :*config* :bot-token) 7 (:import-from :conf :config :*config* :bot-token)
8 (:import-from :named-readtables :in-readtable)
9 (:import-from :serapeum :->) 9 (:import-from :serapeum :->)
10 (:import-from :ukkoclot/src/db :db) 10 (:import-from :ukkoclot/src/db :db)
11 (:import-from :ukkoclot/src/readtable :readtable)
11 (:export 12 (:export
12 #:*state* 13 #:*state*
13 #:state 14 #:state
@@ -22,8 +23,7 @@
22 #:id% 23 #:id%
23 #:set-id%)) 24 #:set-id%))
24(in-package :ukkoclot/src/state) 25(in-package :ukkoclot/src/state)
25 26(in-readtable readtable)
26(enable-f-strings)
27 27
28(defstruct (state (:constructor make-state%)) 28(defstruct (state (:constructor make-state%))
29 (lock (make-rw-lock :name "state's lock") :type rw-lock :read-only t) 29 (lock (make-rw-lock :name "state's lock") :type rw-lock :read-only t)
diff --git a/src/tg/method-macros.lisp b/src/tg/method-macros.lisp
index 9ab9e89..17903df 100644
--- a/src/tg/method-macros.lisp
+++ b/src/tg/method-macros.lisp
@@ -4,16 +4,15 @@
4 (:documentation "Macros for easy defining TG methods.") 4 (:documentation "Macros for easy defining TG methods.")
5 (:use :c2cl :iterate) 5 (:use :c2cl :iterate)
6 (:import-from :alexandria :make-keyword :with-gensyms) 6 (:import-from :alexandria :make-keyword :with-gensyms)
7 (:import-from :com.dieggsy.f-string :enable-f-strings) 7 (:import-from :named-readtables :in-readtable)
8 (:import-from :serapeum :-> :take) 8 (:import-from :serapeum :-> :take)
9 (:import-from :state) 9 (:import-from :state)
10 (:import-from :str) 10 (:import-from :str)
11 (:import-from :ukkoclot/src/readtable :readtable)
11 (:import-from :ukkoclot/src/transport :do-call :http-method) 12 (:import-from :ukkoclot/src/transport :do-call :http-method)
12 (:export :define-tg-method)) 13 (:export :define-tg-method))
13(in-package :ukkoclot/src/tg/method-macros) 14(in-package :ukkoclot/src/tg/method-macros)
14 15(in-readtable readtable)
15(eval-when (:compile-toplevel :load-toplevel :execute)
16 (enable-f-strings))
17 16
18(eval-when (:compile-toplevel :load-toplevel :execute) 17(eval-when (:compile-toplevel :load-toplevel :execute)
19 (defstruct (param (:constructor make-param%)) name type default skip-if-default) 18 (defstruct (param (:constructor make-param%)) name type default skip-if-default)
diff --git a/src/tg/type-macros.lisp b/src/tg/type-macros.lisp
index 02437ec..97cce1c 100644
--- a/src/tg/type-macros.lisp
+++ b/src/tg/type-macros.lisp
@@ -4,18 +4,17 @@
4 (:documentation "Macros for easy defining TG types.") 4 (:documentation "Macros for easy defining TG types.")
5 (:use :c2cl :iterate) 5 (:use :c2cl :iterate)
6 (:import-from :alexandria :make-keyword :symbolicate :with-gensyms) 6 (:import-from :alexandria :make-keyword :symbolicate :with-gensyms)
7 (:import-from :com.dieggsy.f-string :enable-f-strings) 7 (:import-from :named-readtables :in-readtable)
8 (:import-from :serapeum :->) 8 (:import-from :serapeum :->)
9 (:import-from :str) 9 (:import-from :str)
10 (:import-from :ukkoclot/src/serializing :parse-value)
11 (:import-from :ukkoclot/src/hash-tables :gethash-lazy) 10 (:import-from :ukkoclot/src/hash-tables :gethash-lazy)
11 (:import-from :ukkoclot/src/readtable :readtable)
12 (:import-from :ukkoclot/src/serializing :parse-value)
12 (:local-nicknames 13 (:local-nicknames
13 (:jzon :com.inuoe.jzon)) 14 (:jzon :com.inuoe.jzon))
14 (:export :define-tg-type)) 15 (:export :define-tg-type))
15(in-package :ukkoclot/src/tg/type-macros) 16(in-package :ukkoclot/src/tg/type-macros)
16 17(in-readtable readtable)
17(eval-when (:compile-toplevel :load-toplevel :execute)
18 (enable-f-strings))
19 18
20(eval-when (:compile-toplevel :load-toplevel :execute) 19(eval-when (:compile-toplevel :load-toplevel :execute)
21 (defstruct (field (:constructor make-field%)) name type default skip-if-default) 20 (defstruct (field (:constructor make-field%)) name type default skip-if-default)