feat: created first high level API, initialize and close a dict and work with it through a macro
This commit is contained in:
parent
a645000d0d
commit
15911d6e49
2 changed files with 18 additions and 1 deletions
|
|
@ -1 +1,17 @@
|
|||
(in-package :monastery)
|
||||
|
||||
|
||||
;; useful macros
|
||||
(defmacro with-dict ((dict filepath) &body body)
|
||||
"opens the dictionary path, executes the operations and closes automatically"
|
||||
`(let ((,dict (dict-init ,filepath)))
|
||||
(unwind-protect (progn ,@body)
|
||||
(dict-close ,dict))))
|
||||
|
||||
|
||||
;; functions
|
||||
(defun dict-init (filepath)
|
||||
"receives the dictionary filepath and opens the file")
|
||||
|
||||
(defun dict-close (dict)
|
||||
"receives the dictionary instance and closes it")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
(defpackage :monastery
|
||||
(:use #:cl #:cffi #:cffi-ops))
|
||||
(:use #:cl #:cffi #:cffi-ops)
|
||||
(:export #:dict-init #:dict-close #:with-dict))
|
||||
|
||||
|
||||
(in-package :monastery)
|
||||
|
|
|
|||
Loading…
Reference in a new issue