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

0.20 backports #1615

Merged
merged 4 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/analysis/bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,12 @@ fn find_error_type(env: &Env, function: &Function) -> Option<String> {
.iter()
.find(|param| param.direction.is_out() && param.is_error)?;
if let Type::Record(_) = env.type_(error_param.typ) {
return Some(
Some(
RustType::builder(env, error_param.typ)
.direction(error_param.direction)
.try_build()
.into_string(),
);
)
} else {
None
}
Expand Down
8 changes: 8 additions & 0 deletions src/analysis/rust_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ impl<'env> RustTypeBuilder<'env> {
Long => ok_and_use("libc::c_long"), // depends of target system
ULong => ok_and_use("libc::c_ulong"), // depends of target system

TimeT => ok_and_use("libc::time_t"), // depends of target system
OffT => ok_and_use("libc::off_t"), // depends of target system
DevT => ok_and_use("libc::dev_t"), // depends of target system
GidT => ok_and_use("libc::gid_t"), // depends of target system
PidT => ok_and_use("libc::pid_t"), // depends of target system
SockLenT => ok_and_use("libc::socklen_t"), // depends of target system
UidT => ok_and_use("libc::uid_t"), // depends of target system

Size => ok("usize"), // depends of target system
SSize => ok("isize"), // depends of target system

Expand Down
2 changes: 1 addition & 1 deletion src/analysis/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl IsIncomplete for Field {
}
}

impl<'a> IsIncomplete for &'a [Field] {
impl IsIncomplete for &[Field] {
fn is_incomplete(&self, lib: &Library) -> bool {
if self.is_empty() {
return true;
Expand Down
16 changes: 10 additions & 6 deletions src/codegen/function_body_chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl Builder {
)
} else if calls.iter().all(|c| c.scope.is_call()) {
format!(
"&({})",
"&mut ({})",
calls
.iter()
.map(|c| format!("{}_data", c.name))
Expand All @@ -312,11 +312,15 @@ impl Builder {
is_mut: false,
value: Box::new(Chunk::Custom(format!(
"{}{}_data",
if calls[0].scope.is_call() { "&" } else { "" },
if calls[0].scope.is_call() {
"&mut "
} else {
""
},
calls[0].name
))),
type_: Some(Box::new(Chunk::Custom(if calls[0].scope.is_call() {
format!("&{}", calls[0].bound_name)
format!("&mut {}", calls[0].bound_name)
} else {
format!("Box_<{}>", calls[0].bound_name)
}))),
Expand Down Expand Up @@ -390,7 +394,7 @@ impl Builder {
if full_type.is_none() {
if trampoline.scope.is_call() {
chunks.push(Chunk::Custom(format!(
"let {0}_data: {1} = {0};",
"let mut {0}_data: {1} = {0};",
trampoline.name, trampoline.bound_name
)));
} else {
Expand All @@ -401,7 +405,7 @@ impl Builder {
}
} else if trampoline.scope.is_call() {
chunks.push(Chunk::Custom(format!(
"let {0}_data: &{1} = &{0};",
"let mut {0}_data: &mut {1} = &mut {0};",
trampoline.name, trampoline.bound_name
)));
} else {
Expand Down Expand Up @@ -1005,7 +1009,7 @@ impl Builder {
Chunk::FfiCallParameter {
transformation_type: TransformationType::ToGlibDirect {
name: if all_call {
format!("super_callback{pos} as *const _ as *mut _")
format!("super_callback{pos} as *mut _ as *mut _")
} else {
format!("Box_::into_raw(super_callback{pos}) as *mut _")
},
Expand Down
2 changes: 1 addition & 1 deletion src/config/parameter_matchable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub trait ParameterMatchable {
fn matched_parameters(&self, parameter_name: &str) -> Vec<&Self::Parameter>;
}

impl<'a, U: AsRef<Ident>, T: Functionlike<Parameter = U>> ParameterMatchable for [&'a T] {
impl<U: AsRef<Ident>, T: Functionlike<Parameter = U>> ParameterMatchable for [&T] {
type Parameter = U;

fn matched_parameters(&self, parameter_name: &str) -> Vec<&Self::Parameter> {
Expand Down
4 changes: 2 additions & 2 deletions src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ impl Library {
self.namespace_mut(ns_id).versions.insert(version);
}

pub fn types<'a>(&'a self) -> Box<dyn Iterator<Item = (TypeId, &Type)> + 'a> {
pub fn types<'a>(&'a self) -> Box<dyn Iterator<Item = (TypeId, &'a Type)> + 'a> {
Box::new(self.namespaces.iter().enumerate().flat_map(|(ns_id, ns)| {
ns.types.iter().enumerate().filter_map(move |(id, type_)| {
let tid = TypeId {
Expand All @@ -1372,7 +1372,7 @@ impl Library {
pub fn namespace_types<'a>(
&'a self,
ns_id: u16,
) -> Box<dyn Iterator<Item = (TypeId, &Type)> + 'a> {
) -> Box<dyn Iterator<Item = (TypeId, &'a Type)> + 'a> {
let ns = self.namespace(ns_id);
Box::new(ns.index.values().map(move |&id| {
(
Expand Down
2 changes: 1 addition & 1 deletion src/xmlparser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl Element {
}
}

impl<'a> XmlParser<'a> {
impl XmlParser<'_> {
pub fn from_path(path: &Path) -> Result<XmlParser<'_>, String> {
match File::open(path) {
Err(e) => Err(format!("Can't open file \"{}\": {}", path.display(), e)),
Expand Down
Loading