ladybird icon indicating copy to clipboard operation
ladybird copied to clipboard

AK: Support capturing Objective-C block closures in AK::Function

Open ADKaster opened this issue 11 months ago • 2 comments

With a bit of gnarly preprocessor and if constexpr magic, we can get this to work the same way-ish that libc++'s std::function handles block closures.

cc @bugaevc , in case you have any objective-c wisdom :)

ADKaster avatar Mar 16 '25 07:03 ADKaster

/home/runner/work/ladybird/ladybird/AK/StdLibExtraDetails.h:148:43: error: blocks support disabled - compile with -fblocks or pick a deployment target that supports them 148 | inline constexpr bool IsBlockClosure<Ret (^)(Args...)> = true;

Oh great. Are we going to have to build our entire project with -fblocks on linux? Do distros even ship clang with block support and BlockRuntime enabled in compiler-rt?

ADKaster avatar Mar 16 '25 07:03 ADKaster

Oh and GCC doesn't support blocks at all, let alone ARC. So I guess adopting this patch would need some serious ifdef surgery to pretend blocks don't exist on gcc, or finally pull the trigger on dropping gcc :/

ADKaster avatar Mar 16 '25 07:03 ADKaster