[UFFI-Users] get-slot-value and nested structures

rif rif at MIT.EDU
Wed Sep 1 11:21:55 MDT 2004


Kevin,

Thank you for your reply.  Allow me to refocus my question, in an
attempt to be more specific, as I do think there is a bit more to
this.  Consider the following simple code fragment:

(use-package :uffi)
 
(def-struct i-s
    (df :double))
 
(def-struct holder
    (is i-s))
 
(defvar *f* (allocate-foreign-object 'holder))
 
(setf (get-slot-value (get-slot-value *f* 'holder 'i-s) 
		      'i-s
		      'df) 
      3.0d0)

At heart, my question is, "Is this 'correct' UFFI?"  Will this work on
all UFFI-supported platforms?

According to my current understanding, the above is 'wrong,' in that
the docs for get-slot-value state that I am implying that
(get-slot-value *f* 'holder 'i-s) is a pointer-to-i-s, when it's
actually an i-s itself, at least under CMU, and this works under CMU
only by accident, because the type is ignored.  Furthermore, my
current understanding is also that there is no 'correct' way to access
nested structures in UFFI --- there is no syntax that allows me to
take an i-s, rather than a pointer-to-i-s, and get the df out.  Am I
misunderstanding this?

Clearly, I can use uffi:def-type and cl:declare to get the non-consing
behavior I want, but this would still be 'wrong', in that I would have
to declare the intermediate result to be an 'i-s, while I'm implicitly
declaring it (in the call to get-slot-value) to be a pointer-to-i-s.
Perhaps I am being too picky and should just live with this?  Perhaps
the issue is that the intermediate result is an i-s on some platforms
(CMUCL) and a pointer-to-is on others?

Cheers,

rif


More information about the UFFI-Users mailing list