Skip to content

Commit ebdb47e

Browse files
authored
Support more function forms with at-autorelease. (#34)
1 parent 51098b1 commit ebdb47e

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ObjectiveC"
22
uuid = "e86c9b32-1129-44ac-8ea0-90d5bb39ded9"
3-
version = "2.1.0"
3+
version = "2.1.1"
44

55
[deps]
66
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"

src/foundation.jl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,21 @@ macro autoreleasepool(ex...)
513513
end
514514
f = unsafe ? NSUnsafeAutoreleasePool : NSAutoreleasePool
515515

516-
if Meta.isexpr(code, :function)
517-
# function definition
516+
if Meta.isexpr(code, :(=)) &&
517+
(Meta.isexpr(code.args[1], :call) || Meta.isexpr(code.args[1], :where))
518+
# function definition, short form
519+
sig, body = code.args
520+
@assert Meta.isexpr(body, :block)
521+
managed_body = quote
522+
$f() do
523+
$body
524+
end
525+
end
526+
esc(Expr(:(=), sig, managed_body))
527+
elseif Meta.isexpr(code, :function)
528+
# function definition, long form
518529
sig = code.args[1]
519-
@assert Meta.isexpr(sig, :call)
530+
@assert Meta.isexpr(sig, :call) || Meta.isexpr(sig, :where)
520531
body = code.args[2]
521532
@assert Meta.isexpr(body, :block)
522533
managed_body = quote

0 commit comments

Comments
 (0)