LibCURL.jl icon indicating copy to clipboard operation
LibCURL.jl copied to clipboard

struct testing...

Open ihnorton opened this issue 12 years ago • 3 comments

In case you are interested in trying to push this further with structs, I pushed a branch with generated Julia types for all the cURL structs (I didn't merge this stuff into the generator yet, needs a few tweaks still for more complicated structs):

https://github.com/ihnorton/libCURL.jl/tree/struct_test

There are (at least) three structs with unsupported field types (you can tell by searching for ::Void):

CURLMsg curl_fileinfo curl_sockaddr

If you need these, it will be necessary to use StrPack as discussed by @pao (https://groups.google.com/d/msg/julia-dev/p6DUUSdtY2A/CR3zeC3QyeIJ)

Also, for the other ones you may need to change "type" to "immutable" in the declarations in order to make sure isbits(type) == true (see: https://groups.google.com/d/msg/julia-dev/jiJpHlgLZkA/ftClOEROlLYJ )

If you have a chance to try it I will be very interested to see the results! (also any issues)

ihnorton avatar Mar 26 '13 04:03 ihnorton

I just pushed 3 patches to your branch.

Have noticed the following issues:

  • long ssl_version was generated as Int64 instead of Clong, and caused a struct mismatch on my 32-bit machine
  • for some reason CURLE_FTP_ACCEPT_FAILED was not generated as an enum. But this could be just a CURL environment difference between your and my machine. And when C macros are also supported by Clang.jl, it will not be an issue.
  • I have to define the following typedef's manually since they are in C stdlib headers and not curl (don't know why curl_off_t was not generated..)
@ctypedef time_t Int32
@ctypedef curl_off_t Int32   # Should have been defined...
@ctypedef size_t Csize_t

Since they refer to the @ctypedef macro, it will be good to have the macro definitions available in a separate file that I can include directly, instead of generating the same in lC_common.h

  • As suggested I had to make the type immutable, so may make sense to generate them as immutable?

amitmurthy avatar Mar 26 '13 10:03 amitmurthy

Output on my machine:

julia> using httpc

julia> httpc.print_curl_version_info()
3
7.27.0
0x00071b00
i686-pc-linux-gnu
50813
OpenSSL/1.0.1c
0
1.2.7
Ptr{Ptr{Uint8}} @0xb5de3f80
Not Found
0
1.25
0
Not Found
1-element curl_version_info_data Array:
 curl_version_info_data(3,Ptr{Uint8} @0xb5dd4153,0x00071b00,Ptr{Uint8} @0xb5dd415a,50813,Ptr{Uint8} @0xb5de5680,0,Ptr{Uint8} @0xb5d7ec8c,Ptr{Ptr{Uint8}} @0xb5de3f80,Ptr{Uint8} @0x00000000,0,Ptr{Uint8} @0xb5d31128,0,Ptr{Uint8} @0x00000000)

julia> 

amitmurthy avatar Mar 26 '13 10:03 amitmurthy

This is great, Thank you!

I won't be able to work on this until tonight, but the first two are definitely addressable. The third one is a little tricky because for now I would rather avoid pulling in every single typedef in all of the unrelated headers, but eventually I think I make the generator figure out which ones used.

ihnorton avatar Mar 26 '13 12:03 ihnorton