Skip to content

Commit

Permalink
Merge pull request #676 from madsmtm/cf
Browse files Browse the repository at this point in the history
Add the `CoreFoundation` framework
  • Loading branch information
madsmtm authored Dec 9, 2024
2 parents f0f6a5b + 0320576 commit 00d6ecf
Show file tree
Hide file tree
Showing 78 changed files with 1,486 additions and 956 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions Cargo.lock

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

10 changes: 4 additions & 6 deletions crates/header-translator/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ pub struct Config {
}

fn uses_system_config(library_name: &str) -> bool {
match library_name {
"System" | "bitflags" | "block2" | "libc" | "objc2" => true,
// Temporary
"CoreFoundation" => true,
_ => false,
}
matches!(
library_name,
"System" | "bitflags" | "block2" | "libc" | "objc2"
)
}

impl Config {
Expand Down
8 changes: 8 additions & 0 deletions crates/header-translator/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ impl<'a> Context<'a> {
if path.starts_with("sys") {
return Some(Location::from_components(vec!["libc".into()]));
}
if path.starts_with("mach") {
// Will be moved to the `mach` crate in `libc` v1.0
return Some(Location::from_components(vec!["libc".into()]));
}
if path.starts_with("arm") {
// Temporary
return Some(Location::from_components(vec!["System".into()]));
}
}
}
}
Expand Down
18 changes: 6 additions & 12 deletions crates/header-translator/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ impl Location {
"block2" => LocationLibrary::Block2,
"libc" => LocationLibrary::Libc,
"objc2" => LocationLibrary::Objc2,
// Temporary
"CoreFoundation" => LocationLibrary::System,
library => {
if let Some(krate) = config.libraries.get(library).map(|lib| &*lib.krate) {
if library == emission_library {
Expand Down Expand Up @@ -186,7 +184,11 @@ impl Location {
}

pub fn assert_file(&self, file_name: &str) {
assert_eq!(self.file_name(), Some(file_name));
assert_eq!(
self.file_name(),
Some(file_name),
"expected {self:?} to be in {file_name:?}"
);
}
}

Expand Down Expand Up @@ -238,19 +240,11 @@ impl<N: ToOptionString> ItemIdentifier<N> {
}

pub fn with_name(name: N, entity: &Entity<'_>, context: &Context<'_>) -> Self {
let mut location = context.get_location(entity).unwrap_or_else(|| {
let location = context.get_location(entity).unwrap_or_else(|| {
warn!(?entity, "ItemIdentifier from unknown header");
Location::from_components(vec!["__Unknown__".into()])
});

// TODO: Get rid of these hacks
if let Some("CGFloat" | "CGPoint" | "CGRect" | "CGSize") = name.to_option() {
location = Location::from_components(vec!["Foundation".into(), "NSGeometry".into()]);
}
if let Some("CFTimeInterval") = name.to_option() {
location = Location::from_components(vec!["System".into()]);
}

Self { name, location }
}

Expand Down
5 changes: 4 additions & 1 deletion crates/header-translator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,10 @@ fn update_ci(workspace_dir: &Path, config: &Config) -> io::Result<()> {
.as_ref()
.is_some_and(|v| VersionReq::parse("<=10.0").unwrap().matches(v))
})?;
writer(&mut ci, config, "FRAMEWORKS_GNUSTEP", |lib| lib.gnustep)?;
writer(&mut ci, config, "FRAMEWORKS_GNUSTEP", |lib| {
// HACK: CoreFoundation uses mach types that GNUStep doesn't support
lib.gnustep && lib.krate != "objc2-core-foundation"
})?;

write!(&mut ci, " # END AUTOMATICALLY GENERATED{after}")?;

Expand Down
4 changes: 2 additions & 2 deletions crates/header-translator/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl MethodModifiers {
UnexposedAttr::UIActor => {
this.mainthreadonly = true;
}
attr => error!(?attr, "unknown attribute"),
attr => error!(?attr, "unknown attribute on method"),
}
}
}
Expand Down Expand Up @@ -429,7 +429,7 @@ impl Method {
UnexposedAttr::Sendable => sendable = Some(true),
UnexposedAttr::NonSendable => sendable = Some(false),
UnexposedAttr::NoEscape => no_escape = true,
attr => error!(?attr, "unknown attribute"),
attr => error!(?attr, "unknown attribute on method argument"),
}
}
}
Expand Down
Loading

0 comments on commit 00d6ecf

Please sign in to comment.