[cffi-devel] defcstruct bz_stream

Hi, I was playing around with libbz2 with bindings generated from the cffi backend of SWIG, which latest cvs works very nicely now. Basic reading, writing has been a joy. The only thing is that cffi gave me an error (division-by-zero) when evaluating the following defcstruct: (defcstruct bz_stream (next_in :char) (avail_in :unsigned-int) (total_in_lo32 :unsigned-int) (total_in_hi32 :unsigned-int) (next_out :char) (avail_out :unsigned-int) (total_out_lo32 :unsigned-int) (total_out_hi32 :unsigned-int) (state :void) (bzalloc :void) (bzfree :void) (opaque :void)) Sorry, I dont think, I can really be helpful for solving this. Cheers, Kilian Sprotte

Kilian Sprotte wrote:
Hi,
I was playing around with libbz2 with bindings generated from the cffi backend of SWIG, which latest cvs works very nicely now. Basic reading, writing has been a joy.
The only thing is that cffi gave me an error (division-by-zero) when evaluating the following defcstruct:
(defcstruct bz_stream (next_in :char) (avail_in :unsigned-int) (total_in_lo32 :unsigned-int) (total_in_hi32 :unsigned-int) (next_out :char) (avail_out :unsigned-int) (total_out_lo32 :unsigned-int) (total_out_hi32 :unsigned-int) (state :void) (bzalloc :void) (bzfree :void) (opaque :void))
I'm not sure if my error was division-by-zero, but in libxml2, which I used SWIG/CFFI to bind, the :void types were actually void*, and so I switched all of them to :pointer. Maybe this would help you? BA

Brad Anderson <brad@sankaty.com> writes:
Kilian Sprotte wrote:
(defcstruct bz_stream (next_in :char) (avail_in :unsigned-int) (total_in_lo32 :unsigned-int) (total_in_hi32 :unsigned-int) (next_out :char) (avail_out :unsigned-int) (total_out_lo32 :unsigned-int) (total_out_hi32 :unsigned-int) (state :void) (bzalloc :void) (bzfree :void) (opaque :void))
I'm not sure if my error was division-by-zero, but in libxml2, which I used SWIG/CFFI to bind, the :void types were actually void*, and so I switched all of them to :pointer.
Yes, use :POINTER for these. The fact that CFFI even accepts :VOID here is a bug---I'll look into this. James

James Bielman <jamesjb@jamesjb.com> writes:
The fact that CFFI even accepts :VOID here is a bug
Should be fixed now, added an assertion to defcstruct and defcunion. -- Luís Oliveira luismbo (@) gmail (.) com Equipa Portuguesa do Translation Project http://www.iro.umontreal.ca/translation/registry.cgi?team=pt
participants (4)
-
Brad Anderson
-
James Bielman
-
Kilian Sprotte
-
Luís Oliveira