Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct testing... #1

Open
ihnorton opened this issue Mar 26, 2013 · 3 comments · May be fixed by #102
Open

struct testing... #1

ihnorton opened this issue Mar 26, 2013 · 3 comments · May be fixed by #102

Comments

@ihnorton
Copy link
Contributor

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)

@amitmurthy
Copy link
Contributor

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
Copy link
Contributor

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> 

@ihnorton
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants