Skip to content

Commit

Permalink
Merge pull request #1598 from A6GibKm/ffi-std
Browse files Browse the repository at this point in the history
ffi: Use std::ffi types instead of libc
  • Loading branch information
sdroege authored Sep 16, 2024
2 parents 06c4f19 + b1966c9 commit eddf3e7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
26 changes: 13 additions & 13 deletions src/analysis/ffi_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn ffi_inner(env: &Env, tid: TypeId, inner: &str) -> Result {
Type::Basic(fund) => {
use crate::library::Basic::*;
let inner = match fund {
None => "libc::c_void",
None => "std::ffi::c_void",
Boolean => return Ok(use_glib_if_needed(env, "ffi::gboolean").into()),
Int8 => "i8",
UInt8 => "u8",
Expand All @@ -82,18 +82,18 @@ fn ffi_inner(env: &Env, tid: TypeId, inner: &str) -> Result {
UInt32 => "u32",
Int64 => "i64",
UInt64 => "u64",
Char => "libc::c_char",
UChar => "libc::c_uchar",
Short => "libc::c_short",
UShort => "libc::c_ushort",
Int => "libc::c_int",
UInt => "libc::c_uint",
Long => "libc::c_long",
ULong => "libc::c_ulong",
Char => "std::ffi::c_char",
UChar => "std::ffi::c_uchar",
Short => "std::ffi::c_short",
UShort => "std::ffi::c_ushort",
Int => "std::ffi::c_int",
UInt => "std::ffi::c_uint",
Long => "std::ffi::c_long",
ULong => "std::ffi::c_ulong",
Size => "libc::size_t",
SSize => "libc::ssize_t",
Float => "libc::c_float",
Double => "libc::c_double",
Float => "std::ffi::c_float",
Double => "std::ffi::c_double",
TimeT => "libc::time_t",
OffT => "libc::off_t",
DevT => "libc::dev_t",
Expand All @@ -102,8 +102,8 @@ fn ffi_inner(env: &Env, tid: TypeId, inner: &str) -> Result {
SockLenT => "libc::socklen_t",
UidT => "libc::uid_t",
UniChar => "u32",
Utf8 => "libc::c_char",
Filename => "libc::c_char",
Utf8 => "std::ffi::c_char",
Filename => "std::ffi::c_char",
Type => return Ok(use_glib_if_needed(env, "ffi::GType").into()),
IntPtr => "libc::intptr_t",
UIntPtr => "libc::uintptr_t",
Expand Down
7 changes: 4 additions & 3 deletions src/codegen/sys/statics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ pub fn after_extern_crates(w: &mut dyn Write) -> Result<()> {
let v = vec![
"",
"#[allow(unused_imports)]",
"use libc::{c_int, c_char, c_uchar, c_float, c_uint, c_double,",
" c_short, c_ushort, c_long, c_ulong,",
" c_void, size_t, ssize_t, time_t, off_t, intptr_t, uintptr_t, FILE};",
"use std::ffi::{c_int, c_char, c_uchar, c_float, c_uint, c_double,",
" c_short, c_ushort, c_long, c_ulong, c_void};",
"#[allow(unused_imports)]",
"use libc::{size_t, ssize_t, time_t, off_t, intptr_t, uintptr_t, FILE};",
"#[cfg(unix)]",
"#[allow(unused_imports)]",
"use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t};",
Expand Down

0 comments on commit eddf3e7

Please sign in to comment.