#161 ffi:c-struct corrupt since CVS foreign.d 1.62

lisp error
closed-fixed
ffi (23)
5
2003-05-03
2003-04-29
No

Hi,

it looks like the change in CVS saying
"do not print system structure definitions
do print full prototype for built-in functions"

which added options like :external and :typedef to
C-STRUCT declarations has some bug.

On a CVS-CLISP on Linux, [86]>
(ffi::parse-c-type '(c-ptr (c-struct list (a (c-array
long 2)) (s (c-array character 3)))))

#(C-PTR
#(C-STRUCT LIST (A (C-ARRAY LONG 2)) #(S)
#<SYSTEM-FUNCTION LIST>
#(C-ARRAY CHARACTER 3)))

Just by looking at it, that cannot be right!
Oddly enough, (ffi::deparse-c-type *) looks fine on
this example.

In v2.30, the result looked like this
#(C-PTR
#(C-STRUCT #(A S) #<SYSTEM-FUNCTION LIST> #(C-ARRAY
LONG 2)
#(C-ARRAY CHARACTER 3)))
but the format of #(c-struct ...) now has more fields,
so it is not anymore the exact output to expect.

Here's one testcase
(with-c-var (place '(c-ptr (c-struct list
(a (c-array long 2))
(s (c-array character
3))))
'(#(-3 -1) #(#\a #\b #\c)))
(slot (deref place) 's))
"abc"

Regards,
Jörg Höhle.

Discussion

  • Jörg Höhle

    Jörg Höhle - 2003-04-30

    Logged In: YES
    user_id=377168

    From impnotes, it's not clear to me what the use of the
    :typedef and :external keywords is -- please clarify.

    If it's only for .c file generation during compilation,
    maybe it would have been better to have def-c-struct manage
    the options and C output, instead of changing the internal
    #(C-STRUCT #)?
    Similarly, DEF-CALL-OUT is slightly different from
    (C-FUNCTION ...): DEF-CALL-OUT deals with C file generation,
    while the #(C-FUNCTION #) object describes how to invoke
    a function.

     
  • Sam Steingold

    Sam Steingold - 2003-04-30

    Logged In: YES
    user_id=5735

    the correrct form is:

    (parse-c-type '(c-struct list nil (a (c-array long 2)) (s
    (c-array character 3))))

    #(C-STRUCT LIST NIL #(A S) #<SYSTEM-FUNCTION LIST>
    #(C-ARRAY LONG 2) #(C-ARRAY CHARACTER 3))

     
  • Sam Steingold

    Sam Steingold - 2003-04-30

    Logged In: YES
    user_id=5735

    I think it would be better to be able to recreate
    def-c-struct from c-struct and
    def-call-out from c-function.
    you never know what options we might need to add in the future,
    some maybe affecting the access to the structure slots.

    see also
    <ftp://cvs2.cons.org/pub/lisp/clisp/snapshots/impnotes.html#c-struct>
    <ftp://cvs2.cons.org/pub/lisp/clisp/snapshots/impnotes.html#def-c-struct>

     
  • Jörg Höhle

    Jörg Höhle - 2003-04-30

    Logged In: YES
    user_id=377168

    I'm opposed to this incompatible change to c-struct which
    breaks code. The trick that you used to remain compatible on
    def-c-struct could be used on c-struct as well, e.g.
    (c-struct (class options) ...) and the old
    (c-struct class ...).

    This nicely parallels your modified def-c-stuct, instead of
    having two incompatible syntaxes to remember.

    What do you haev in mind about possible future options?

     
  • Sam Steingold

    Sam Steingold - 2003-05-03

    Logged In: YES
    user_id=5735

    thank you for your bug report.
    the bug has been fixed in the CVS tree.
    you can either wait for the next release (recommended)
    or check out the current CVS tree (see http://clisp.cons.org\)
    and build CLISP from the sources (be advised that between
    releases the CVS tree is very unstable and may not even build
    on your platform).

     
  • Sam Steingold

    Sam Steingold - 2003-05-03
    • milestone: 100334 --> lisp error
    • assigned_to: nobody --> sds
    • status: open --> closed-fixed
     
  • Sam Steingold

    Sam Steingold - 2003-05-03

    Logged In: YES
    user_id=5735

    future options may include access to C++ or Java objects,
    fancy padding &c

     
  • Sam Steingold

    Sam Steingold - 2003-05-03

    Logged In: YES
    user_id=5735

    future options may include access to C++ or Java objects,
    fancy padding &c

     
  • Sam Steingold

    Sam Steingold - 2003-05-03
    • labels: --> ffi
     
  • Sam Steingold

    Sam Steingold - 2003-05-03

    Logged In: YES
    user_id=5735

    thank you for your bug report.
    the bug has been fixed in the CVS tree.
    you can either wait for the next release (recommended)
    or check out the current CVS tree (see http://clisp.cons.org\)
    and build CLISP from the sources (be advised that between
    releases the CVS tree is very unstable and may not even build
    on your platform).

     

Log in to post a comment.