forked from thodg/cl-uri-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
uri-environment.lisp
35 lines (28 loc) · 964 Bytes
/
uri-environment.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
;; cl-uri-templates
;; Extensive URI-Templates implementation in Common-Lisp.
;;
;; Copyright 2009 Thomas de Grivel <[email protected]>
;; Copyright (c) 2007, 2008, 2009 Vladimir Sedach
;;
;; This software is provided "AS IS".
;; Please see COPYING for details.
(in-package #:cl-uri-templates)
(defvar *uri-environment*)
(defmacro with-uri-environment (&body body)
`(let (*uri-environment*)
,@body))
(defun uri-var (name)
(ignore-errors
(getf *uri-environment* name)))
(defsetf uri-var (name) (value)
`(setf (getf *uri-environment* ,name) ,value))
(defmacro with-uri-variables (variables &body body)
`(symbol-macrolet ,(loop
for var in variables
collect `(,var (uri-var ',var)))
,@body))
(defmacro uri-variables-setq (&rest variables)
"This macro sets values of bound variables from uri environment"
(loop
for var in variables
collect `(setq ,var (uri-var ',var))))