Skip to content

Commit

Permalink
@cfunction: swap at, rt (#33267)
Browse files Browse the repository at this point in the history
swap at (types of arguments) and rt (return value type).
  • Loading branch information
pemryan authored and KristofferC committed Dec 16, 2019
1 parent 3e8f257 commit d295d35
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions base/c.jl
Expand Up @@ -61,20 +61,20 @@ julia> @cfunction(foo, Int, (Int, Int))
Ptr{Cvoid} @0x000000001b82fcd0
```
"""
macro cfunction(f, at, rt)
if !(isa(rt, Expr) && rt.head === :tuple)
macro cfunction(f, rt, at)
if !(isa(at, Expr) && at.head === :tuple)
throw(ArgumentError("@cfunction argument types must be a literal tuple"))
end
rt.head = :call
pushfirst!(rt.args, GlobalRef(Core, :svec))
at.head = :call
pushfirst!(at.args, GlobalRef(Core, :svec))
if isa(f, Expr) && f.head === :$
fptr = f.args[1]
typ = CFunction
else
fptr = QuoteNode(f)
typ = Ptr{Cvoid}
end
cfun = Expr(:cfunction, typ, fptr, at, rt, QuoteNode(:ccall))
cfun = Expr(:cfunction, typ, fptr, rt, at, QuoteNode(:ccall))
return esc(cfun)
end

Expand Down

0 comments on commit d295d35

Please sign in to comment.