-
Notifications
You must be signed in to change notification settings - Fork 68
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
callback to support possible vararg definitions? #17
Comments
Related to #7. Since Julia supports varargs in ccall, I think I can support this without generating multiple type-distinct function signatures. I just need to detect it and pass the correct incantation to ccall. Would this be sufficient? |
Should work. Do note that libCURL header files use an ellipsis (...) to specify varargs (http://en.wikipedia.org/wiki/Variadic_function#C.2C_Objective-C.2C_C.2B.2B.2C_and_D) . As long as clang has the same behavior for both an ellipsis as well as the older "va_list" argument type, it should be OK. |
A |
Ah, ok. Thanks for the explanation. I didn't dig into this yet - had thought va_list was fully supported and didn't realize there was another kind. So I guess even generating unique signature/ccall pairings will not work. "cantfix" for now. |
Generating unique ccall pairings will work in the context of libCURL at least. For example my module file looks like this
where I would not be able to use libCURL without the extra definitions for curl_easy_setopt and curl_easy_getinfo, but I can get by by defining the few functions that require the same manually. A work in progress but you can check it out at https://github.com/amitmurthy/libCURL.jl |
The x64 ABI states that this will not necessarily generate valid code, unless you declare that this is a varargs call (with ...). Notably the RAX register may contain an invalid value. |
Thanks.
works. Notice I had to put a But I am having problems specifying an ellipsis for |
I'm not sure if that means that same thing with |
You might have to write that out completely at the moment... I can't check on this right now, but I doubt it will work with the macro as-is. I will (very soon) make the generator print all types without nested symbols, then the @c macro will be able to take all arguments literally (eliminating the eval funny business). At that point it should be possible to use the macro directly for this. |
Cool. Thanks. |
win: update package name to libcurl4. Fixes JuliaInterop#14 JuliaInterop#15
Can wrap_c.init() take in an additional callback function which can be used to support varargs? i.e, can the callback function specify a list of possible vararg sets?
For example:
results in the wrong wrapper for curl_easy_setopt, i.e., a definition that takes in only the first 2 parameters. But this is mostly harmless.
But, it would be great if I could specify additional possible usage definitions like by providing a list of possible argument types (for the varargs) as sublists like this - [[Int32, Ptr{:Uint8}], [Int32], [ Ptr{:Uint8}]].
For example the possible actual usage scenarios for curl_easy_setopt are
So, in the above case I could just specify the possibilities for the 3rd parameter.
The text was updated successfully, but these errors were encountered: