Skip to content

Instantly share code, notes, and snippets.

@W-Net-AI
Created August 15, 2014 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save W-Net-AI/54fb86306b132140e900 to your computer and use it in GitHub Desktop.
Save W-Net-AI/54fb86306b132140e900 to your computer and use it in GitHub Desktop.
;; DMATCH
(define-foreign-type dmatch ()
((garbage-collect :reader garbage-collect :initform nil :initarg
:garbage-collect))
(:actual-type :pointer)
(:simple-parser dmatch))
(defclass cv-dmatch ()
((c-pointer :reader c-pointer :initarg :c-pointer)))
(defmethod translate-to-foreign ((lisp-value cv-dmatch) (c-type dmatch))
(values (c-pointer lisp-value) lisp-value))
(defmethod translate-from-foreign (c-pointer (c-type dmatch))
(let ((dmatch (make-instance 'cv-dmatch :c-pointer c-pointer)))
(when (garbage-collect c-type)
(tg:finalize dmatch (lambda () (del-dmatch c-pointer))))
dmatch))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment