Last active
April 20, 2022 20:37
-
-
Save theoknock/2bd4f3559636689f589cac81ff548dfa to your computer and use it in GitHub Desktop.
Block_copy + CFBridgingRetain/Release
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Functors invoked with an argument supplied by the destination | |
*/ | |
typedef const float (^ const __strong blk)(const float); | |
blk b = ^ const float (const float f) { | |
return f; | |
}; | |
typedef const void * (^ const __strong blk_t)(blk); | |
blk_t b_ptr = ^ (blk b) { | |
return Block_copy((const void *)CFBridgingRetain(b)); | |
}; | |
typedef blk (^ const __strong functor)(const void *); | |
functor f = ^ (const void * functor_t) { | |
return (blk)CFBridgingRelease((__bridge CFTypeRef _Nullable)((__bridge blk)(functor_t))); | |
}; | |
/* | |
Functors invoked with an argument supplied at the source (returns the uninvoked functor, which can be invoked with 'void' instead of the argument required by the functor) | |
*/ | |
typedef const float (^(^blk_pack)(const float))(void); | |
blk_pack bp = ^ (const float f_) { | |
return (^ (const float f) { | |
return ^ const float { | |
return f; | |
}; | |
})(f_); | |
}; | |
typedef const void * (^ const __strong blk_pack_t)(blk_pack); | |
blk_pack_t bp_t = ^ (blk_pack bp) { | |
return Block_copy((const void *)CFBridgingRetain(bp)); | |
}; | |
typedef blk_pack (^ const __strong functor_pack)(const void *); | |
functor_pack fp = ^ (const void * functor_pack_t) { | |
return (blk_pack)CFBridgingRelease((__bridge CFTypeRef _Nullable)((__bridge blk_pack)(functor_pack_t))); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment