I try to make smart struct support in my project. It works.
Now i can have foreign struct in lisp as lisp structures (defclass/defstruct).
The only problem for me is mem-ref. When there is an array of structs, I need
to use something like cffi::aggregatep to set fact, that struct are positioned
in row, not pointers to them.
But in that case I cannot set translator, because in cffi::mem-ref
110 (if (aggregatep ptype)
111 (inc-pointer ptr offset)
112 (let ((ctype (canonicalize ptype)))
113 #+cffi-sys::no-long-long
114 (when (or (eq ctype :long-long) (eq ctype :unsigned-long-long))
115 (return-from mem-ref
116 (translate-from-foreign (%emulated-mem-ref-64 ptr ctype offset)
117 ptype)))
118 ;; normal branch
119 (translate-from-foreign (%mem-ref ptr ctype offset) ptype)))))
Can we change
(inc-pointer ptr offset)
to (translate-from-foreign (inc-pointer ptr offset) ptype) ?
If it is really pointer it remains unchanged, but if translate-from is overrided
for particular type one can get any information out, not just pointers.
--
Клочков Роман