Skip to content

Commit

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

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion crates/header-translator/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ impl Expr {
(EntityKind::BinaryOperator, [_, _]) => Self::parse_from_tokens(entity, context),
(EntityKind::IntegerLiteral, []) => Self::parse_from_tokens(entity, context),
(EntityKind::FloatingLiteral, []) => Self::parse_from_tokens(entity, context),
// Remove unnecessary cast
// Remove unnecessary casts
(EntityKind::CStyleCastExpr, [_type, child]) => Self::parse(child, context),
(EntityKind::CStyleCastExpr, [child]) => Self::parse_from_tokens(child, context),
(EntityKind::UnexposedExpr, _) => Self::parse_from_tokens(entity, context),
(EntityKind::CharacterLiteral, []) => Self::parse_from_tokens(entity, context),
(_, children) => panic!("unknown expr: {entity:?}, {children:#?}"),
Expand Down
28 changes: 15 additions & 13 deletions crates/header-translator/src/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,17 @@ impl Stmt {
EntityKind::TypedefDecl => {
let id = ItemIdentifier::new(entity, context);
let availability = Availability::parse(entity, context);

if context
.library(id.library_name())
.typedef_data
.get(&id.name)
.map(|data| data.skipped)
.unwrap_or_default()
{
return vec![];
}

let mut kind = None;

immediate_children(entity, |entity, _span| match entity.get_kind() {
Expand All @@ -1040,20 +1051,11 @@ impl Stmt {
| EntityKind::ObjCProtocolRef
| EntityKind::TypeRef
| EntityKind::ParmDecl
| EntityKind::EnumDecl => {}
| EntityKind::EnumDecl
| EntityKind::IntegerLiteral => {}
_ => error!("unknown"),
});

if context
.library(id.library_name())
.typedef_data
.get(&id.name)
.map(|data| data.skipped)
.unwrap_or_default()
{
return vec![];
}

let ty = entity
.get_typedef_underlying_type()
.expect("typedef underlying type");
Expand Down Expand Up @@ -1417,11 +1419,11 @@ impl Stmt {
}
EntityKind::UnionDecl => {
let id = ItemIdentifier::new_optional(entity, context);
error!(
warn!(
?id,
has_attributes = ?entity.has_attributes(),
children = ?entity.get_children(),
"union",
"skipping union",
);
vec![]
}
Expand Down
7 changes: 7 additions & 0 deletions crates/header-translator/src/unexposed_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ impl UnexposedAttr {
| "CIKL_DEPRECATED"
| "CK_UNAVAILABLE"
| "CK_NEWLY_UNAVAILABLE"
| "CT_AVAILABLE"
| "CT_DEPRECATED"
| "CT_DEPRECATED_WITH_REPLACEMENT"
| "CT_ENUM_AVAILABLE"
| "CT_ENUM_DEPRECATED"
| "CT_ENUM_UNAVAILABLE"
| "CT_UNAVAILABLE"
| "COREVIDEO_GL_DEPRECATED"
| "FPUI_AVAILABLE"
| "MLCOMPUTE_AVAILABLE_STARTING"
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 @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- `CoreAudioTypes` / `objc2-core-audio-types`.
- `CoreGraphics` / `objc2-core-graphics`.
- `CoreFoundation` / `objc2-core-foundation`.
- `CoreText` / `objc2-core-text`.
- `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 @@ -27,6 +27,7 @@
| `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/) |
| `CoreMotion` | [![`objc2-core-motion`](https://badgen.net/crates/v/objc2-core-motion)](https://crates.io/crates/objc2-core-motion) | [![docs.rs](https://docs.rs/objc2-core-motion/badge.svg)](https://docs.rs/objc2-core-motion/) |
| `CoreText` | [![`objc2-core-text`](https://badgen.net/crates/v/objc2-core-text)](https://crates.io/crates/objc2-core-text) | [![docs.rs](https://docs.rs/objc2-core-text/badge.svg)](https://docs.rs/objc2-core-text/) |
| `CoreVideo` | [![`objc2-core-video`](https://badgen.net/crates/v/objc2-core-video)](https://crates.io/crates/objc2-core-video) | [![docs.rs](https://docs.rs/objc2-core-video/badge.svg)](https://docs.rs/objc2-core-video/) |
| `CoreWLAN` | [![`objc2-core-wlan`](https://badgen.net/crates/v/objc2-core-wlan)](https://crates.io/crates/objc2-core-wlan) | [![docs.rs](https://docs.rs/objc2-core-wlan/badge.svg)](https://docs.rs/objc2-core-wlan/) |
| `DataDetection` | [![`objc2-data-detection`](https://badgen.net/crates/v/objc2-data-detection)](https://crates.io/crates/objc2-data-detection) | [![docs.rs](https://docs.rs/objc2-data-detection/badge.svg)](https://docs.rs/objc2-data-detection/) |
Expand Down
2 changes: 1 addition & 1 deletion framework-crates/objc2-app-kit/translation-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class.NSWorkspaceOpenConfiguration.methods."setArchitecture:".skipped = true
# Needs INIntent from Intents
protocol.NSApplicationDelegate.methods."application:handlerForIntent:".skipped = true

# Needs CoreText
# We don't really want objc2-app-kit to depend on objc2-core-text
class.NSAdaptiveImageGlyph.skipped-protocols = ["CTAdaptiveImageProviding"]

# header-translator crashes when trying to figure out the return type of this.
Expand Down
182 changes: 182 additions & 0 deletions framework-crates/objc2-core-text/Cargo.toml

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

14 changes: 14 additions & 0 deletions framework-crates/objc2-core-text/README.md

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

1 change: 1 addition & 0 deletions framework-crates/objc2-core-text/src/generated

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

25 changes: 25 additions & 0 deletions framework-crates/objc2-core-text/src/invalid.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#![allow(non_upper_case_globals)]

#[cfg(feature = "CTFont")]
impl crate::CTFontUIFontType {
pub const kCTFontUIFontNone: Self = Self(u32::MAX);
}

#[cfg(feature = "CTRubyAnnotation")]
impl crate::CTRubyAlignment {
pub const kCTRubyAlignmentInvalid: Self = Self(u8::MAX);
}

#[cfg(feature = "CTRubyAnnotation")]
impl crate::CTRubyOverhang {
pub const kCTRubyOverhangInvalid: Self = Self(u8::MAX);
}

#[cfg(feature = "SFNTLayoutTypes")]
pub const kMORTLigLastAction: core::ffi::c_int = 0x80000000u32 as _;

#[cfg(feature = "SFNTLayoutTypes")]
pub const kMORXCoverVertical: core::ffi::c_int = 0x80000000u32 as _;

#[cfg(feature = "SFNTLayoutTypes")]
pub const kKERXVertical: core::ffi::c_int = 0x80000000u32 as _;
37 changes: 37 additions & 0 deletions framework-crates/objc2-core-text/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//! # Bindings to the `CoreText` framework
//!
//! See [Apple's docs][apple-doc] and [the general docs on framework crates][framework-crates] for more information.
//!
//! [apple-doc]: https://developer.apple.com/documentation/coretext/
//! [framework-crates]: https://docs.rs/objc2/latest/objc2/topics/about_generated/index.html
#![no_std]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
// Update in Cargo.toml as well.
#![doc(html_root_url = "https://docs.rs/objc2-core-text/0.2.2")]

#[cfg(feature = "alloc")]
extern crate alloc;

#[cfg(feature = "std")]
extern crate std;

mod generated;
mod invalid;
#[cfg(feature = "SFNTLayoutTypes")]
mod sfnt_lookup_header;

#[allow(unused_imports, unreachable_pub)]
pub use self::generated::*;
#[cfg(feature = "SFNTLayoutTypes")]
pub use self::invalid::{kKERXVertical, kMORTLigLastAction, kMORXCoverVertical};
#[cfg(feature = "SFNTLayoutTypes")]
pub use self::sfnt_lookup_header::SFNTLookupFormatSpecificHeader;

#[allow(dead_code)]
pub(crate) type Fixed = i32;
#[allow(dead_code)]
pub(crate) type FourCharCode = u32;
#[allow(dead_code)]
pub(crate) type ConstStr255Param = *const core::ffi::c_char;
#[allow(dead_code)]
pub(crate) type UniChar = u16;
Loading

0 comments on commit bfd6600

Please sign in to comment.