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

Implement macro for opaque struct + CastPtr + BoxCastPtr #151

Closed
jsha opened this issue Oct 15, 2021 · 1 comment · Fixed by #404
Closed

Implement macro for opaque struct + CastPtr + BoxCastPtr #151

jsha opened this issue Oct 15, 2021 · 1 comment · Fixed by #404

Comments

@jsha
Copy link
Collaborator

jsha commented Oct 15, 2021

We have a recurring pattern in this repository:

pub struct rustls_server_config_builder {
    // We use the opaque struct pattern to tell C about our types without
    // telling them what's inside.
    // https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
    _private: [u8; 0],
}

impl CastPtr for rustls_server_config_builder {
    type RustType = ServerConfig;
}

impl BoxCastPtr for rustls_server_config_builder {}

We should define a macro such that we can simply all this boilerplate to:

c_type!(rustls_server_config_builder, ServerConfig);

Or, to include BoxCastPtr:

c_type_boxed!(rustls_server_config_builder, ServerConfig);

We should make sure that doccomments right above the macro invocation wind up in crustls.h associated with the struct declaration.

@jsha
Copy link
Collaborator Author

jsha commented Nov 9, 2021

I started work on this. One significant problem is that if we put a doccomment above the macro call, rustdoc treats that as an attempt to document the macro call (which it doesn't support), rather than an attempt to document the first item generated by the macro call. Perhaps we need the macro to accept doccomments as part of its input.

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.

1 participant