Skip to content

Commit

Permalink
Make objc2 optional in core-graphics-types
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jul 31, 2023
1 parent 7383217 commit cc744a2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cocoa-foundation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ block2 = "0.2.0"
bitflags = "1.0"
libc = "0.2"
core-foundation = { path = "../core-foundation", version = "0.9" }
core-graphics-types = { path = "../core-graphics-types", version = "0.1" }
core-graphics-types = { path = "../core-graphics-types", version = "0.1", features = ["objc2"] }
objc2 = "0.4.0"
2 changes: 1 addition & 1 deletion core-graphics-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "MIT OR Apache-2.0"
bitflags = "1.0"
core-foundation = { path = "../core-foundation", version = "0.9" }
libc = "0.2"
objc2 = "0.4.0"
objc2 = { version = "0.4.0", optional = true }

[package.metadata.docs.rs]
default-target = "x86_64-apple-darwin"
5 changes: 5 additions & 0 deletions core-graphics-types/src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use base::CGFloat;
use core_foundation::base::TCFType;
use core_foundation::dictionary::CFDictionary;
#[cfg(feature = "objc2")]
use objc2::encode::{Encode, Encoding};

pub const CG_ZERO_POINT: CGPoint = CGPoint { x: 0.0, y: 0.0 };
Expand Down Expand Up @@ -40,6 +41,7 @@ pub struct CGSize {
pub height: CGFloat,
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CGSize {
const ENCODING: Encoding = Encoding::Struct("CGSize", &[CGFloat::ENCODING, CGFloat::ENCODING]);
}
Expand All @@ -66,6 +68,7 @@ pub struct CGPoint {
pub y: CGFloat,
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CGPoint {
const ENCODING: Encoding = Encoding::Struct("CGPoint", &[CGFloat::ENCODING, CGFloat::ENCODING]);
}
Expand All @@ -89,6 +92,7 @@ pub struct CGRect {
pub size: CGSize,
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CGRect {
const ENCODING: Encoding = Encoding::Struct("CGRect", &[CGPoint::ENCODING, CGSize::ENCODING]);
}
Expand Down Expand Up @@ -158,6 +162,7 @@ pub struct CGAffineTransform {
pub ty: CGFloat,
}

#[cfg(feature = "objc2")]
unsafe impl Encode for CGAffineTransform {
const ENCODING: Encoding = Encoding::Struct(
"CGAffineTransform",
Expand Down
1 change: 1 addition & 0 deletions core-graphics-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// except according to those terms.

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

pub mod base;
Expand Down

0 comments on commit cc744a2

Please sign in to comment.