Skip to content

Commit

Permalink
Fix QuartzCore and Photos feature names
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Feb 2, 2024
1 parent 8a723c1 commit 0f1479b
Show file tree
Hide file tree
Showing 11 changed files with 233 additions and 253 deletions.
17 changes: 2 additions & 15 deletions crates/header-translator/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,6 @@ impl Config {
.and_then(|data| data.renamed.clone())
.unwrap_or(name)
}

pub fn get_library_alias(&self, library_name: String) -> String {
self.libraries
.iter()
.find_map(|(n, data)| {
if let Some(name) = &data.name {
if n == &library_name {
return Some(name.clone());
}
}
None
})
.unwrap_or(library_name)
}
}

fn get_version<'de, D: serde::Deserializer<'de>>(
Expand Down Expand Up @@ -99,8 +85,9 @@ fn get_version<'de, D: serde::Deserializer<'de>>(
#[derive(Deserialize, Debug, Default, Clone, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub struct LibraryData {
#[serde(rename = "pretty-name")]
#[serde(default)]
pub name: Option<String>,
pub pretty_name: Option<String>,
pub imports: Vec<String>,
#[serde(rename = "gnustep-library")]
#[serde(default)]
Expand Down
2 changes: 1 addition & 1 deletion crates/header-translator/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct File {
impl File {
pub fn new(library_name: &str, context: &Context<'_>) -> Self {
Self {
library_name: context.get_library_alias(library_name.to_string()),
library_name: library_name.to_string(),
imports: context
.libraries
.get(library_name)
Expand Down
2 changes: 1 addition & 1 deletion crates/header-translator/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl<N: ToOptionString> ItemIdentifier<N> {

Self {
name,
library: context.get_library_alias(library_name),
library: library_name,
file_name,
}
}
Expand Down
15 changes: 9 additions & 6 deletions crates/header-translator/src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ fn prepare_for_docs(s: &str) -> String {

impl fmt::Display for Library {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let name = self.data.name.as_deref().unwrap_or(&self.link_name);
writeln!(
f,
"// This file has been automatically generated by `objc2`'s `header-translator`."
)?;
writeln!(f, "// DO NOT EDIT")?;
writeln!(f)?;
writeln!(f, "//! # Bindings to the `{name}` framework")?;
writeln!(
f,
"//! # Bindings to the `{}` framework",
self.data.pretty_name.as_deref().unwrap_or(&self.link_name)
)?;
if !self.data.extra_docs.is_empty() {
writeln!(f, "//!")?;
writeln!(f, "//! {}.", prepare_for_docs(&self.data.extra_docs))?;
Expand All @@ -86,19 +89,19 @@ impl fmt::Display for Library {
writeln!(f, "//! ```")?;
}
}
if self.data.name.is_some() {
writeln!(f, "#![doc(alias = \"{}\")]", self.link_name)?;
if let Some(pretty_name) = &self.data.pretty_name {
writeln!(f, "#![doc(alias = \"{pretty_name}\")]")?;
}
writeln!(f)?;

if self.data.has_additions {
writeln!(f, "#[path = \"../../additions/{name}/mod.rs\"]")?;
writeln!(f, "#[path = \"../../additions/{}/mod.rs\"]", self.link_name)?;
writeln!(f, "mod additions;")?;
writeln!(f, "pub use self::additions::*;")?;
}
writeln!(f)?;
if self.data.has_fixes {
writeln!(f, "#[path = \"../../fixes/{name}/mod.rs\"]")?;
writeln!(f, "#[path = \"../../fixes/{}/mod.rs\"]", self.link_name)?;
writeln!(f, "mod fixes;")?;
writeln!(f, "pub use self::fixes::*;")?;
}
Expand Down
10 changes: 3 additions & 7 deletions crates/header-translator/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ impl Output {
.collect();
let mut gnustep_features: BTreeSet<String> = vec![].into_iter().collect();

for (mut library_name, library) in &config.libraries {
if let Some(alias) = &library.name {
library_name = alias;
}
for (library_name, library) in &config.libraries {
let library_features = library
.imports
.iter()
Expand Down Expand Up @@ -145,8 +142,7 @@ impl Output {
);

for (library_name, library) in &self.libraries {
let library_alias = config.get_library_alias(library_name.clone());
let mut library_features = BTreeSet::from([library_alias.clone()]);
let mut library_features = BTreeSet::from([library_name.clone()]);

for file in library.files.values() {
for stmt in &file.stmts {
Expand Down Expand Up @@ -182,7 +178,7 @@ impl Output {
}

let _ = features.insert(
format!("{library_alias}_all"),
format!("{library_name}_all"),
library_features.into_iter().collect::<Vec<_>>(),
);
}
Expand Down
11 changes: 7 additions & 4 deletions crates/header-translator/translation-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ maccatalyst = "13.0"
ios = "13.0"

[library.Photos]
name = "PhotoKit"
pretty-name = "PhotoKit"
imports = ["AppKit", "CoreLocation", "Foundation"]
macos = "10.11"
maccatalyst = "13.0"
Expand All @@ -399,7 +399,7 @@ imports = ["AppKit", "Foundation"]
macos = "10.4"

[library.QuartzCore]
name = "CoreAnimation"
pretty-name = "CoreAnimation"
fixes = true
extra-docs = """
This actually lives in the `QuartzCore` framework, but `CoreAnimation` is
Expand Down Expand Up @@ -1213,11 +1213,14 @@ skipped = true
[class.MTKTextureLoader.methods.newTextureWithCGImage_options_error]
skipped = true
[class.MTKView.methods]
# Needs `CAMetalDrawable`
currentDrawable = { skipped = true }
# Needs `CGColorSpaceRef`
colorspace = { skipped = true }
setColorspace = { skipped = true }
# Needs `CAMetalDrawable`
[class.MTKView.methods.currentDrawable]
skipped = true
[class.CAMetalDisplayLinkUpdate.methods.drawable]
skipped = true
# Needs `Component` from Core Services / Carbon Core / Component Manager
[class.OSALanguage.methods]
initWithComponent = { skipped = true }
Expand Down
5 changes: 3 additions & 2 deletions crates/icrate/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Deprecated
* Deprecated `MainThreadMarker::run_on_main`, use the new free-standing function
`run_on_main` instead.
* Deprecated `CATransaction::batch`. This is still in beta, according to the
documentation.

### Removed
* Removed private functionality in the `Speech` framework. This was never
Expand All @@ -33,6 +31,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
This is technically a breaking change, but will be allowed in a minor
version since it isn't supported by Apple.

### Fixed
* Fixed the `QuartzCore` and `Photos` frameworks not being loaded correctly.

## icrate 0.1.0 - 2023-12-23

### Added
Expand Down

0 comments on commit 0f1479b

Please sign in to comment.