From d6b25ed432136ce89217fc475ba63c95f292fb5d Mon Sep 17 00:00:00 2001 From: Kyle Tomsic Date: Wed, 2 Oct 2019 22:29:05 -0400 Subject: Use c_void from core when --use-core is specified `c_void` is available as `::std::os::raw::c_void` and `::core::ffi::c_void`. If the "--use-core" option is specified (but no --ctypes-prefix is provided), we should emit `::core::ffi::c_void` rather than the `std` one. --- src/codegen/helpers.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/codegen/helpers.rs') diff --git a/src/codegen/helpers.rs b/src/codegen/helpers.rs index b1cf2050..ec60742c 100644 --- a/src/codegen/helpers.rs +++ b/src/codegen/helpers.rs @@ -143,6 +143,27 @@ pub mod ast_ty { use proc_macro2::{self, TokenStream}; use std::str::FromStr; + pub fn c_void(ctx: &BindgenContext) -> TokenStream { + // ctypes_prefix takes precedence + match ctx.options().ctypes_prefix { + Some(ref prefix) => { + let prefix = TokenStream::from_str(prefix.as_str()).unwrap(); + quote! { + #prefix::c_void + } + } + None => { + if ctx.options().use_core && + ctx.options().rust_features.core_ffi_c_void + { + quote! { ::core::ffi::c_void } + } else { + quote! { ::std::os::raw::c_void } + } + } + } + } + pub fn raw_type(ctx: &BindgenContext, name: &str) -> TokenStream { let ident = ctx.rust_ident_raw(name); match ctx.options().ctypes_prefix { -- cgit v1.2.3