From 666c6302531ae0a3b07aeb47588fea3e7c7f70c6 Mon Sep 17 00:00:00 2001 From: Yury Date: Tue, 19 Nov 2024 06:48:15 +0300 Subject: [PATCH] ca::DisplayLink availability. --- cidre-macros/src/lib.rs | 6 ++++++ cidre/Cargo.toml | 6 ++++-- cidre/pomace/ca/ca.h | 3 ++- cidre/src/ca/display_link.rs | 5 +++-- .../src/vn/calculate_image_aesthetics_scores_request.rs | 9 +++++++-- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/cidre-macros/src/lib.rs b/cidre-macros/src/lib.rs index 6e9c3838..ce172407 100644 --- a/cidre-macros/src/lib.rs +++ b/cidre-macros/src/lib.rs @@ -1412,6 +1412,12 @@ fn try_replace_fn(tokens: &mut Vec, 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 { diff --git a/cidre/Cargo.toml b/cidre/Cargo.toml index 0ac682d0..251de682 100644 --- a/cidre/Cargo.toml +++ b/cidre/Cargo.toml @@ -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"] @@ -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"] diff --git a/cidre/pomace/ca/ca.h b/cidre/pomace/ca/ca.h index 5fd1d271..70679ad5 100644 --- a/cidre/pomace/ca/ca.h +++ b/cidre/pomace/ca/ca.h @@ -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]; diff --git a/cidre/src/ca/display_link.rs b/cidre/src/ca/display_link.rs index 864dc158..0fbd6663 100644 --- a/cidre/src/ca/display_link.rs +++ b/cidre/src/ca/display_link.rs @@ -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)] diff --git a/cidre/src/vn/calculate_image_aesthetics_scores_request.rs b/cidre/src/vn/calculate_image_aesthetics_scores_request.rs index c9d5f2f6..29d9be71 100644 --- a/cidre/src/vn/calculate_image_aesthetics_scores_request.rs +++ b/cidre/src/vn/calculate_image_aesthetics_scores_request.rs @@ -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) -> arc::R { 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 { - let mut block = vn::RequestCh::::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::::new2(f); + Self::with_ch(&mut block) + } } #[doc(alias = "VNCalculateImageAestheticsScoresRequestRevision1")]