-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconstance.scm
More file actions
26 lines (24 loc) · 916 Bytes
/
constance.scm
File metadata and controls
26 lines (24 loc) · 916 Bytes
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
(define-syntax define-constance
(lambda (e rename c)
(let* ((constance-name (cadr e))
(c-headers (caddr e))
(pairs (cadddr e))
(results (get-value-pairs-from-c constance-name c-headers pairs)))
`(,(rename 'begin)
,@(map (lambda (pair)
`(,(rename 'define) ,(string->symbol (first pair))
,(second pair)))
results)))))
;; (define-constance constance-name
;; (headers ...)
;; ((id c-macro)
;; (id2 c-macro2)
;; ...))
;; =>
;; (begin (define id value)
;; (define id2 value2))
;; where value is the value of c-macro in the environment of a c program with
;; the header files specified by c-headers
;; NOTE: constance-name MUST BE UNIQUE within a project (specifically, amongst
;; any DEFINE-CONSTANCE forms which have the same working directory at macro
;; expansion time