Skip to content

Commit

Permalink
Handle builtin NSObject differently
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jan 10, 2023
1 parent 2d55538 commit d614bd4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 7 additions & 2 deletions crates/header-translator/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ impl Output {
// since the rest will be enabled transitively.
if let Some(superclass) = superclasses.first() {
let feature = format!("{}_{}", ty.library, ty.name);
let superclass_feature = format!("{}_{}", superclass.library, superclass.name);
if let Some(existing) = features.insert(feature, vec![superclass_feature]) {
let superclass_features = (superclass.library != "Foundation" && superclass.name != "NSObject")
.then(|| format!("{}_{}", superclass.library, superclass.name))
.into_iter()
.collect::<Vec<_>>();
if let Some(existing) =
features.insert(feature, superclass_features)
{
error!(?existing, "duplicate feature");
}
}
Expand Down
6 changes: 4 additions & 2 deletions crates/header-translator/src/rust_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ impl IdType {
}
}

#[allow(dead_code)]
fn library(&self) -> Option<&str> {
match self {
Self::Class { library, .. } => Some(library),
Expand Down Expand Up @@ -419,7 +418,10 @@ impl IdType {

fn visit_required_features(&self, f: &mut impl FnMut(&str, &str)) {
if let Some(library) = self.library() {
f(&library, self.name());
let name = self.name();
if library != "Foundation" && name != "NSObject" {
f(&library, name);
}
}

if let Self::Class {
Expand Down

0 comments on commit d614bd4

Please sign in to comment.