fsvb and foreign-typedefs with aggregate types

Madhu enometh at meer.net
Thu Feb 20 09:31:15 UTC 2020


*  Luís Oliveira <CAB-HnLSGQUdZzNc_KN6nZkMvMMp-qOxR_OfHTuC-y7jfe39FPA at mail.gmail.com>
Wrote on Sat, 15 Feb 2020 15:35:00 +0000

> Thanks for testing. Could you send a pull request?

[Sorry for the delay - I was waiting to figure out how to use github
v4 to clone the repository into my space so I could submit a PR. I
finally figured out I couldn't]

Unfortunately I didn't run the tests before I sent my message. Now
that I did run them I notice that proposed fix introduces 9 unexpected
failures: STRUCT.NESTED-SETF, STRUCT.ALIGNMENT.1-8

struct s_s_ch the_s_s_ch = { 2, { 1 } };
(defcvar "the_s_s_ch" s-s-ch) -> *s-s-ch* gets translated to a list.

So fixing DEFCTYPE probably wouldn't cut it.

The earlier proposal of a TRANSLATE-FROM-FOREIGN method on
FOREIGN-TYPEDEF works.  But the questions I had regardingthat are
still unanswered.

Here is is a test in structs.lisp for to test that:

;; Test if a field defined by a typedef is translated by default to a
;; lisp object
(defcstruct struct-pair-plus-one-a
  (p (:struct struct-pair))
  (c :int))

(defcstruct struct-pair-plus-one-b
  (p struct-pair-typedef1)
  (c :int))

(defcfun ("make_pair_plus_one" make-pair-plus-one-a)
    (:struct struct-pair-plus-one-a)
  (a :int) (b :int) (c :int))

(defcfun ("make_pair_plus_one" make-pair-plus-one-b)
    (:struct struct-pair-plus-one-b)
  (a :int) (b :int) (c :int))

(deftest struct-values.fsbv.1
    (let ((a (make-pair-plus-one-a 1 2 3)))
      (values (getf a 'p) (getf a 'c)))
  (1 . 2) 3)

(deftest struct-values.fsbv.2
    (let ((b (make-pair-plus-one-b 1 2 3)))
      (values (getf b 'p) (getf b 'c)))
  (1 . 2) 3)

Let me know what you think


> On Sat, Feb 15, 2020, 1:40 PM Madhu <enometh at meer.net> wrote:
>
>> *  Luís Oliveira Wrote on Fri, 14 Feb 2020 11:24:08 +0000
>> > I can't check right now, but I wonder if the TYPEP check in DEFCTYPE
>> > should be checking for TRANSLATABLE-FOREIGN-TYPE instead of
>> > ENHANCED-FOREIGN-TYPE?
>>
>> Yes, making that change also fixes the problem.
>> Impressive. Thanks,



More information about the cffi-devel mailing list