about summary refs log tree commit diff
path: root/tests/codegen-llvm/auxiliary/darwin_objc_aux.rs
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-09-17 14:56:44 +1000
committerGitHub <noreply@github.com>2025-09-17 14:56:44 +1000
commit6ad98750e0d2261aa123806c69a133b2fbd18d88 (patch)
tree53152bd7a544941557844f85b18cc1a1ba9ee527 /tests/codegen-llvm/auxiliary/darwin_objc_aux.rs
parentf21a9c94cf39cdb26a15ea0967501629f3156958 (diff)
parent1ebf69d1b1a94e99c01680514571c41d0b864c15 (diff)
downloadrust-6ad98750e0d2261aa123806c69a133b2fbd18d88.tar.gz
rust-6ad98750e0d2261aa123806c69a133b2fbd18d88.zip
Rollup merge of #145660 - jbatez:darwin_objc, r=jdonszelmann,madsmtm,tmandry
initial implementation of the darwin_objc unstable feature

Tracking issue: https://github.com/rust-lang/rust/issues/145496

This feature makes it possible to reference Objective-C classes and selectors using the same ABI used by native Objective-C on Apple/Darwin platforms. Without it, Rust code interacting with Objective-C must resort to loading classes and selectors using costly string-based lookups at runtime. With it, these references can be loaded efficiently at dynamic load time.

r? ```@tmandry```

try-job: `*apple*`
try-job: `x86_64-gnu-nopt`
Diffstat (limited to 'tests/codegen-llvm/auxiliary/darwin_objc_aux.rs')
-rw-r--r--tests/codegen-llvm/auxiliary/darwin_objc_aux.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/codegen-llvm/auxiliary/darwin_objc_aux.rs b/tests/codegen-llvm/auxiliary/darwin_objc_aux.rs
new file mode 100644
index 00000000000..3c35d003c8a
--- /dev/null
+++ b/tests/codegen-llvm/auxiliary/darwin_objc_aux.rs
@@ -0,0 +1,27 @@
+#![crate_type = "lib"]
+#![feature(darwin_objc)]
+
+use std::os::darwin::objc;
+
+#[link(name = "Foundation", kind = "framework")]
+unsafe extern "C" {}
+
+#[inline(always)]
+pub fn inline_get_object_class() -> objc::Class {
+    objc::class!("NSObject")
+}
+
+#[inline(always)]
+pub fn inline_get_alloc_selector() -> objc::SEL {
+    objc::selector!("alloc")
+}
+
+#[inline(never)]
+pub fn never_inline_get_string_class() -> objc::Class {
+    objc::class!("NSString")
+}
+
+#[inline(never)]
+pub fn never_inline_get_init_selector() -> objc::SEL {
+    objc::selector!("init")
+}