Skip to content

Commit

Permalink
Fix various header-translator errors
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Dec 11, 2024
1 parent 898daec commit 9a085ee
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 4 deletions.
6 changes: 5 additions & 1 deletion crates/header-translator/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,15 @@ impl<N: ToOptionString> ItemIdentifier<N> {
}

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

if let Some("IOSurfaceRef") = name.to_option() {
location = Location::from_components(vec!["IOSurface".into(), "IOSurfaceRef".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 @@ -136,7 +136,10 @@ fn main() -> Result<(), BoxError> {
let mut includes_file = fs::File::create(&includes).unwrap();
// Make sure that we pick the IOSurfaceRef that IOSurface defines,
// instead of the one that CoreGraphics defines.
writeln!(&mut includes_file, "#import <IOSurface/IOSurface.h>")?;
if platform_config_filter(&config.libraries["IOSurface"]) {
writeln!(&mut includes_file, "#include <IOSurface/IOSurfaceRef.h>")?;
writeln!(&mut includes_file, "#include <IOSurface/IOSurfaceObjC.h>")?;
}
// Part of .modulemap
writeln!(&mut includes_file, "#import <CoreFoundation/CFPluginCOM.h>")?;
for lib in config.libraries.values() {
Expand Down
6 changes: 5 additions & 1 deletion crates/header-translator/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,11 @@ pub(crate) fn handle_reserved(name: &str) -> String {
ident.to_string()
}
// translate whatever remains unchanged (needed for, e.g., `_`)
else {
else if name == "self" {
"self_".into()
} else if name == "super" {
"super_".into()
} else {
name.into()
}
}
1 change: 1 addition & 0 deletions crates/header-translator/src/unexposed_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ impl UnexposedAttr {
"CF_SWIFT_NAME"
| "CF_SWIFT_UNAVAILABLE_FROM_ASYNC"
| "DISPATCH_SWIFT_NAME"
| "IOSFC_SWIFT_NAME"
| "NS_REFINED_FOR_SWIFT_ASYNC"
| "NS_SWIFT_ASYNC_NAME"
| "NS_SWIFT_ASYNC_THROWS_ON_FALSE"
Expand Down
1 change: 1 addition & 0 deletions crates/objc2/src/topics/about_generated/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- `CoreFoundation` / `objc2-core-foundation`.
- `CoreText` / `objc2-core-text`.
- `CoreVideo` / `objc2-core-video`.
- `IOSurface` / `objc2-io-surface`.
- `ScreenSaver` / `objc2-screen-saver`.

### Changed
Expand Down
4 changes: 4 additions & 0 deletions framework-crates/objc2-io-surface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ pub use self::generated::*;
pub(crate) type Boolean = u8;
#[allow(dead_code)]
pub(crate) type OSType = u32;

/// [Apple's documentation](https://developer.apple.com/documentation/iosurface/iosurfaceref?language=objc)
#[cfg(feature = "IOSurfaceRef")]
pub type IOSurfaceRef = *mut core::ffi::c_void;
3 changes: 3 additions & 0 deletions framework-crates/objc2-io-surface/translation-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ fn.IOSurfaceLookupFromXPCObject.skipped = true

# Needs task_id_token_t
fn.IOSurfaceSetOwnershipIdentity.skipped = true

# Defined in other crates too, so needs manual definition
typedef.IOSurfaceRef.skipped = true
2 changes: 1 addition & 1 deletion generated

0 comments on commit 9a085ee

Please sign in to comment.