mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-28 10:20:05 +00:00
Implementes the block ABI.2010.3.16 natively via the objc_block intrinsic and the Objc_Block builtin type.
See: https://clang.llvm.org/docs/Block-ABI-Apple.html
This commit is contained in:
@@ -5,6 +5,11 @@ import "base:intrinsics"
|
||||
@builtin
|
||||
Maybe :: union($T: typeid) {T}
|
||||
|
||||
/*
|
||||
Represents an Objective-C block with a given procedure signature T
|
||||
*/
|
||||
@builtin
|
||||
Objc_Block :: struct($T: typeid) where intrinsics.type_is_proc(T) { using _: intrinsics.objc_object }
|
||||
|
||||
/*
|
||||
Recovers the containing/parent struct from a pointer to one of its fields.
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#+private
|
||||
package runtime
|
||||
|
||||
@(priority_index=-1e6)
|
||||
@(priority_index=-1e5)
|
||||
foreign import ObjC "system:objc"
|
||||
|
||||
@(priority_index=-1e6)
|
||||
foreign import libSystem "system:System"
|
||||
|
||||
import "base:intrinsics"
|
||||
|
||||
objc_id :: ^intrinsics.objc_object
|
||||
@@ -34,3 +37,10 @@ foreign ObjC {
|
||||
object_getClass :: proc "c" (obj: objc_id) -> objc_Class ---
|
||||
}
|
||||
|
||||
foreign libSystem {
|
||||
_NSConcreteGlobalBlock: intrinsics.objc_class
|
||||
_NSConcreteStackBlock: intrinsics.objc_class
|
||||
|
||||
_Block_object_assign :: proc "c" (rawptr, rawptr, i32) ---
|
||||
_Block_object_dispose :: proc "c" (rawptr, i32) ---
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user