Coverage report: /home/ellis/comp/core/lib/syn/gen/rs/util.lisp
Kind | Covered | All | % |
expression | 0 | 75 | 0.0 |
branch | 0 | 6 | 0.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; util.lisp --- GEN/RS Utils
6
(in-package :syn/gen/rs)
8
(defvar *rs-macros* nil)
9
(defvar *default-cargo-target-directory* (merge-pathnames "target/" *default-pathname-defaults*))
11
(defmacro rs-defmacro (name args &body body)
12
"Define a macro which can be used within the body of a 'with-rs' form."
14
(defmacro ,name ,@(mapcar #`(,a1) args) ,@body)
15
(push ',name *rs-macros*)))
17
(defun rs-mod-form (crate &optional mods pub)
18
"Generate a basic mod form (CRATE . [MODS] [PUB])"
21
(defmacro with-rs-env (imports &body body)
22
"Generate an environment for use within a Rust generator macro."
23
`(let ((imports ,(mapcar #'rs-mod-form imports)))
24
(format nil "~A~&~A" imports ',body)))
26
(defun rs-use (crate &optional mods pub)
27
"Generate a single Rust use statement."
35
(lambda (x y) (format nil "~A,~A" x y))
40
(defun rs-mod (mod &optional pub)
41
"Generate a single Rust mod statement."
47
(defun rs-imports (&rest imports)
48
"Generate a string of Rust 'use' statements."
51
(mapcar (lambda (x) (apply #'rs-use (apply #'rs-mod-form x))) imports))
54
(defmacro rs-extern-c-fn (name args &optional pub unsafe no-mangle &body body)
55
"Generate a Rust extern 'C' fn."
58
,(when no-mangle (format nil "#[no_mangle]~&"))
60
,(when unsafe "unsafe ")
61
"extern \"C\" fn " ,name "("
63
((consp args) (reduce (lambda (x y) (format nil "~A,~A" x y)) args))
67
;; (defun rs-macroexpand-1 (form &optional env))
69
;; (defun rs-macroexpand (env &rest body)