Skip to content

Commit

Permalink
ca::DisplayLink availability.
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Nov 19, 2024
1 parent f05c428 commit 666c630
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
6 changes: 6 additions & 0 deletions cidre-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,12 @@ fn try_replace_fn(tokens: &mut Vec<TokenTree>, make_result_optional: &mut bool)
let mut body_stream = g.stream().into_iter();

match body_stream.next().unwrap() {
TokenTree::Group(scope) => {
if scope.delimiter() == Delimiter::Brace {
*make_result_optional = true;
return true;
}
}
TokenTree::Ident(ident) => match ident.to_string().as_str() {
"unsafe" => {
let Some(TokenTree::Group(g)) = body_stream.next() else {
Expand Down
6 changes: 4 additions & 2 deletions cidre/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ macos_15_0 = ["macos_14_2"]
macos_15_2 = ["macos_15_0"]

maccatalyst_13_0 = []
maccatalyst_14_0 = ["maccatalyst_13_0"]
maccatalyst_13_1 = ["maccatalyst_13_0"]
maccatalyst_14_0 = ["maccatalyst_13_1"]
maccatalyst_16_0 = ["maccatalyst_14_0"]
maccatalyst_16_1 = ["maccatalyst_16_0"]
maccatalyst_17_0 = ["maccatalyst_16_1"]
Expand All @@ -160,7 +161,8 @@ maccatalyst_18_2 = ["maccatalyst_18_0"]

ios_2_0 = []
ios_3_0 = ["ios_2_0"]
ios_4_0 = ["ios_3_0"]
ios_3_1 = ["ios_3_0"]
ios_4_0 = ["ios_3_1"]
ios_5_0 = ["ios_4_0"]
ios_6_0 = ["ios_5_0"]
ios_7_0 = ["ios_6_0"]
Expand Down
3 changes: 2 additions & 1 deletion cidre/pomace/ca/ca.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ static void ca_initializer(void)

CA_ANIMATION = [CAAnimation class];
CA_MEDIA_TIMING_FUNCTION = [CAMediaTimingFunction class];
CA_DISPLAY_LINK = [CADisplayLink class];
CA_DISPLAY_LINK = NSClassFromString(@"CADisplayLink");
// CA_DISPLAY_LINK = [CADisplayLink class];
CA_LAYER = [CALayer class];
CA_METAL_LAYER = [CAMetalLayer class];
CA_RENDERER = [CARenderer class];
Expand Down
5 changes: 3 additions & 2 deletions cidre/src/ca/display_link.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::{arc, ca, cf, define_obj_type, ns, objc};
use crate::{api, arc, ca, cf, define_obj_type, ns, objc};

define_obj_type!(
#[doc(alias = "CADisplayLink")]
pub DisplayLink(ns::Id),
CA_DISPLAY_LINK
CA_DISPLAY_LINK,
#[api::available(macos = 14.0, maccatalyst = 13.1, ios = 3.1, tvos = 9.0, visionos = 1.0)]
);

#[objc::protocol(CidreTarget)]
Expand Down
9 changes: 7 additions & 2 deletions cidre/src/vn/calculate_image_aesthetics_scores_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ define_obj_type!(
);

impl CalcImageAestheticsScoresRequest {
#[api::available(macos = 15.0, ios = 18.0, tvos = 18.0, visionos = 2.0)]
pub fn with_ch(ch: &mut vn::RequestCh<Self>) -> arc::R<Self> {
Self::alloc().init_with_ch(Some(ch))
}

#[api::available(macos = 15.0, ios = 18.0, tvos = 18.0, visionos = 2.0)]
pub fn with(f: impl FnMut(&mut Self, Option<&ns::Error>) + 'static) -> arc::R<Self> {
let mut block = vn::RequestCh::<Self>::new2(f);
Self::with_ch(&mut block)
// this scope is marker for api::available to make result optional and skip body
{
let mut block = vn::RequestCh::<Self>::new2(f);
Self::with_ch(&mut block)
}
}

#[doc(alias = "VNCalculateImageAestheticsScoresRequestRevision1")]
Expand Down

0 comments on commit 666c630

Please sign in to comment.