Skip to content

Commit

Permalink
Add the CoreGraphics framework
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Dec 10, 2024
1 parent e8ea581 commit eaf268d
Show file tree
Hide file tree
Showing 44 changed files with 688 additions and 376 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

28 changes: 28 additions & 0 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 crates/header-translator/src/availability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ impl Availability {
*introduced = availability.introduced;
*deprecated = availability.deprecated;

// TODO: Unsure how we would handle these if they exist
if availability.obsoleted.is_some() {
error!("availability attribute contained `obsoleted`");
// TODO: Handle obsoletions somehow, maybe by cfg-ing
// obsoleted things out?
}

if let Some(m) = availability.message {
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 @@ -241,7 +241,7 @@ 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(|| {
warn!(?entity, "ItemIdentifier from unknown header");
error!(?entity, "ItemIdentifier from unknown header");
Location::from_components(vec!["__Unknown__".into()])
});

Expand Down
2 changes: 1 addition & 1 deletion crates/header-translator/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl MemoryManagement {
{
Self::Normal
} else {
error!(?modifiers, "invalid MemoryManagement attributes");
warn!(?modifiers, "invalid MemoryManagement attributes");
Self::Normal
}
}
Expand Down
18 changes: 18 additions & 0 deletions crates/header-translator/src/rust_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1723,11 +1723,29 @@ impl Ty {
})
}

fn fn_contains_bool_argument(&self) -> bool {
if let Self::Pointer { pointee, .. } = self {
if let Self::Fn { arguments, .. } = &**pointee {
if arguments
.iter()
.any(|arg| matches!(arg, Self::Primitive(Primitive::C99Bool)))
{
return true;
}
}
}
false
}

pub(crate) fn struct_encoding(&self) -> impl fmt::Display + '_ {
FormatterFn(move |f| match self {
Self::Primitive(Primitive::C99Bool) => write!(f, "Encoding::Bool"),
Self::Primitive(Primitive::Long) => write!(f, "Encoding::C_LONG"),
Self::Primitive(Primitive::ULong) => write!(f, "Encoding::C_ULONG"),
// TODO: Make all function pointers be encode, regardless of arguments
Self::TypeDef { to, .. } if to.fn_contains_bool_argument() => {
write!(f, "Encoding::Pointer(&Encoding::Unknown)")
}
_ => write!(f, "<{}>::ENCODING", self.struct_()),
})
}
Expand Down
9 changes: 9 additions & 0 deletions crates/header-translator/src/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ fn parse_fn_param_children(parent: &Entity<'_>, context: &Context<'_>) -> Option
EntityKind::NSConsumed => {
error!("found NSConsumed, which requires manual handling");
}
// For some reason we recurse into array types
EntityKind::IntegerLiteral => {}
kind => error!(?parent, ?kind, "unknown"),
});

Expand Down Expand Up @@ -1385,6 +1387,13 @@ impl Stmt {
let ty = Ty::parse_function_argument(ty, attr, context);
arguments.push((name, ty))
}
EntityKind::WarnUnusedResultAttr => {
// TODO: Emit `#[must_use]` on this
}
EntityKind::PureAttr => {
// Ignore, we currently have no way of marking
// external functions as pure in Rust.
}
EntityKind::VisibilityAttr => {
// CG_EXTERN or UIKIT_EXTERN
}
Expand Down
6 changes: 5 additions & 1 deletion crates/header-translator/src/unexposed_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ impl UnexposedAttr {
| "OBJC_SWIFT_UNAVAILABLE"
| "OPENGL_DEPRECATED"
| "OPENGLES_DEPRECATED"
| "SCREEN_CAPTURE_OBSOLETE"
| "SOCIAL_CLASS_AVAILABLE"
| "SOCIAL_CLASS_AVAILABLE_IOS"
| "SOCIAL_CLASS_AVAILABLE_MAC"
Expand All @@ -193,7 +194,9 @@ impl UnexposedAttr {
// For some reason we don't need to extract the arguments for
// these, perhaps because they simply delegate to other macros.
"AS_API_AVAILABLE" | "AS_HEADER_AUDIT_BEGIN" => None,
"__IOS_PROHIBITED"
"__CG_DEPRECATED_ENUMERATOR"
| "__CG_DEPRECATED"
| "__IOS_PROHIBITED"
| "__IOS_UNAVAILABLE"
| "__OSX_UNAVAILABLE"
| "__TVOS_PROHIBITED"
Expand All @@ -206,6 +209,7 @@ impl UnexposedAttr {
| "CB_CM_API_AVAILABLE"
| "MP_INIT_UNAVAILABLE"
| "CF_AUTOMATED_REFCOUNT_UNAVAILABLE"
| "CG_OBSOLETE"
| "NS_AUTOMATED_REFCOUNT_UNAVAILABLE"
| "NS_AUTOMATED_REFCOUNT_WEAK_UNAVAILABLE"
| "NS_UNAVAILABLE"
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 @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
querying the underlying data.
* Added new framework crates:
- `CoreAudioTypes` / `objc2-core-audio-types`.
- `CoreGraphics` / `objc2-core-graphics`.
- `CoreFoundation` / `objc2-core-foundation`.
- `CoreVideo` / `objc2-core-video`.
- `ScreenSaver` / `objc2-screen-saver`.
Expand Down
1 change: 1 addition & 0 deletions crates/objc2/src/topics/about_generated/list_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
| `CoreBluetooth` | [![`objc2-core-bluetooth`](https://badgen.net/crates/v/objc2-core-bluetooth)](https://crates.io/crates/objc2-core-bluetooth) | [![docs.rs](https://docs.rs/objc2-core-bluetooth/badge.svg)](https://docs.rs/objc2-core-bluetooth/) |
| `CoreData` | [![`objc2-core-data`](https://badgen.net/crates/v/objc2-core-data)](https://crates.io/crates/objc2-core-data) | [![docs.rs](https://docs.rs/objc2-core-data/badge.svg)](https://docs.rs/objc2-core-data/) |
| `CoreFoundation` | [![`objc2-core-foundation`](https://badgen.net/crates/v/objc2-core-foundation)](https://crates.io/crates/objc2-core-foundation) | [![docs.rs](https://docs.rs/objc2-core-foundation/badge.svg)](https://docs.rs/objc2-core-foundation/) |
| `CoreGraphics` | [![`objc2-core-graphics`](https://badgen.net/crates/v/objc2-core-graphics)](https://crates.io/crates/objc2-core-graphics) | [![docs.rs](https://docs.rs/objc2-core-graphics/badge.svg)](https://docs.rs/objc2-core-graphics/) |
| `CoreImage` | [![`objc2-core-image`](https://badgen.net/crates/v/objc2-core-image)](https://crates.io/crates/objc2-core-image) | [![docs.rs](https://docs.rs/objc2-core-image/badge.svg)](https://docs.rs/objc2-core-image/) |
| `CoreLocation` | [![`objc2-core-location`](https://badgen.net/crates/v/objc2-core-location)](https://crates.io/crates/objc2-core-location) | [![docs.rs](https://docs.rs/objc2-core-location/badge.svg)](https://docs.rs/objc2-core-location/) |
| `CoreML` | [![`objc2-core-ml`](https://badgen.net/crates/v/objc2-core-ml)](https://crates.io/crates/objc2-core-ml) | [![docs.rs](https://docs.rs/objc2-core-ml/badge.svg)](https://docs.rs/objc2-core-ml/) |
Expand Down
19 changes: 13 additions & 6 deletions framework-crates/objc2-accessibility/Cargo.toml

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

6 changes: 0 additions & 6 deletions framework-crates/objc2-accessibility/translation-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,3 @@ ios = "14.0"
tvos = "14.0"
watchos = "7.0"
visionos = "1.0"

# Needs `CGImageRef`
class.AXBrailleMap.methods."presentImage:".skipped = true

# Needs `CGColorRef`
fn.AXNameFromColor.skipped = true
Loading

0 comments on commit eaf268d

Please sign in to comment.