-
Notifications
You must be signed in to change notification settings - Fork 24
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
Follow standard for opaque types in case of SEXPREC
#205
Conversation
ensures that the opaque type doesn't implement `Send`, `Sync`, or `Pin`.
/bindings |
An example of the issues mentioned in #204 is here. What do I do now to showcase a PR? It breaks CI, so no-one will look. Even if the resulting bindings would work, if they were the ones saved and used in this PR. |
@yutannihilation, since this works now, I'd like your thoughts on this. |
Looks great, but let me confirm. In my understanding, pub type SEXP = *mut ::std::os::raw::c_void; |
I'm not sure. I don't think we should make I believe Opaque Type atleast implies that it is a type we don't know how to construct, and that we are not allowed to construct. In Rust, that's accomplished with a private field, thus making it impossible to construct the type outside of the defining module. Which is, in my opinion, the wrong definition. Because we can construct this. I don't think we should blindly trust what I'm not sure if this PR has any impact. I think we should maybe include this PR, just for correctness. |
After reading the Rustonomicon again, I found my understanding about the opaque type was wrong, sorry. It seems you are right. In this case, I'm still wondering if it's any better to expose the "type-safe" (JFYI, I decided to use |
Ok. Thanks for approval. |
This is the wrong approach. SEXPREC should be regarded as |
Since
SEXPREC
is an opaque type, that R doesn't want us to construct, or know anything about, or evenwant us to make assumptions about. But, currently, we do! We assume that it is Send, Sync and Pin.
(see
cargo doc
pictures below).I've made an issue about this rust-lang/rust-bindgen#2685, because
bindgen has an
opaque_type
, mechanism, and it is not producing a version with the!Send,!Sync,!Pin
. But the https://stackoverflow.com/questions/38315383/whats-the-rust-idiom-to-define-a-field-pointing-to-a-c-opaque-pointer, and https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs,explains how to do this:
Going from
to
Results of this code can only be read-off
cargo doc
, so see the images below:Currently:
Now:
Depends on: