On Wed, Apr 24, 2013 at 4:35 AM, Willem Rein Oudshoorn <woudshoo@xs4all.nl> wrote:
Thank you for all your work and the time to answer my questions.
Ah, ok, I am a bit struggling to convert the old way to the new way. It
Liam Healy <lnp@healy.washington.dc.us> writes:
> Willem,
>
> Thanks for the report.
>
> My thinking is that with-foreign-slots is intended to expose the value (and
> not the pointer), and therefore, expands to foreign-slot-value, so the
> behavior you're seeing is correct. Your fix to your code is the correct way
> to access the pointer. I think with-foreign-slots is provided as a
> convenient shortcut to get all the values; since it doesn't do what you
> need, you need to use the actual access form (foreign-slot-pointer in your
> case).
probably has nothing to do with (with-foreign-slots ...), but just my
mis understanding and trying to quickly convert old code to new.
> For your second question: if the argument is actually a pointer to the
> structure, :pointer is the right thing to use. Are you sure it is a pointer
> argument? Check the .h file where it is defined.
>
Ah, I do not have an issue with passing it to the c library.
What I meant was that in my mind the following confused me:
(let ((c-oid (foreing-alloc '(:struct git-oid))))
;;; I think of c-oid, conceptually as type
;;; (:pointer (:struct git-oid))
;;;; later:
(foreign-slot-pointer c-oid '(:struct git-oid) 'id)
;;; I thought that because c-oid is of type
;;; (:pointer (:struct git-oid))
;;; I thought I needed to put here
;;; '(:pointer (:struct git-oid)) instead of
;;; '(:struct git-oid)
Does this make sense?
Now I have a small additional question.
I have a struct like:
(defcstruct (git-index-time :class index-time-struct)
....)
Now the (translate-from-foreign value (type index-time-struct))
works if I use as type:
(:struct git-index-time)
So everyting works. However, if I do:
(defctype struct-index-time (:struct git-index-time))
And use as type:
struct-index-time
The `translate-from-foreign` is not called and I end up
with untranslated values.
I thought that (defctype ...) worked as a typedef and
naively expected the type translation to still work.
Is this as expected?