14 Mar 2007 05:57
Passing Lisp values into and back out of C?
Peter Seibel <peter <at> gigamonkeys.com>
2007-03-14 04:57:54 GMT
2007-03-14 04:57:54 GMT
This must either be really trivial or completely impossible: suppose I need to create an instance of a C structure that has a void* slot. I want to fill that slot with (some representation of) an arbitrary Lisp value so that when that structure is handed back to my Lisp code I can get back to the Lisp object. Other than keeping my own integer->object mapping and passing the integer to C and translating it back to the object when I get it back, is there some easier way to do this in CFFI? -Peter -- -- Peter Seibel : peter <at> gigamonkeys.com Gigamonkeys Consulting : http://www.gigamonkeys.com/
You can, however, make good use of CFFI's type system!
(use-package :cffi)
(define-foreign-type lisp-object-type ()
((weakp :initarg :weakp))
(:actual-type :unsigned-int))
(define-parse-method lisp-object (&key weak-mapping)
(make-instance 'lisp-object-type :weakp weak-mapping))
(defvar *regular-hashtable* (make-hash-table))
RSS Feed