Skip to content

Commit

Permalink
Add at-cfunction (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan authored and martinholters committed May 30, 2018
1 parent e5f16d7 commit aa24418
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ Currently, the `@compat` macro supports the following syntaxes:

* `isalpha` is now `isletter` ([#27077]).

* `cfunction` is now `@cfunction` ([#26486]).

## New macros

* `@__DIR__` has been added ([#18380])
Expand Down Expand Up @@ -633,6 +635,7 @@ includes this fix. Find the minimum version from there.
[#26369]: https://github.com/JuliaLang/julia/issues/26369
[#26436]: https://github.com/JuliaLang/julia/issues/26436
[#26442]: https://github.com/JuliaLang/julia/issues/26442
[#26486]: https://github.com/JuliaLang/julia/issues/26486
[#26660]: https://github.com/JuliaLang/julia/issues/26660
[#26670]: https://github.com/JuliaLang/julia/issues/26670
[#27077]: https://github.com/JuliaLang/julia/issues/27077
8 changes: 8 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,14 @@ end
const isletter = isalpha
end

# 0.7.0-DEV.4762
@static if !isdefined(Base, Symbol("@cfunction"))
macro cfunction(f, rt, tup)
:(Base.cfunction($f, $rt, Tuple{$tup...}))
end
export @cfunction
end

include("deprecated.jl")

end # module Compat
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1732,4 +1732,11 @@ end
@test isletter('β')
@test !isletter('3')

# 0.7.0-DEV.4762
let ptr = @cfunction(+, Int, (Int, Int))
@test ptr isa Ptr{Cvoid}
@test ptr != C_NULL
@test ccall(ptr, Int, (Int, Int), 2, 3) == 5
end

nothing

0 comments on commit aa24418

Please sign in to comment.