Skip to content

Commit aa24418

Browse files
ararslanmartinholters
authored andcommitted
Add at-cfunction (#553)
1 parent e5f16d7 commit aa24418

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ Currently, the `@compat` macro supports the following syntaxes:
411411

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

414+
* `cfunction` is now `@cfunction` ([#26486]).
415+
414416
## New macros
415417

416418
* `@__DIR__` has been added ([#18380])
@@ -633,6 +635,7 @@ includes this fix. Find the minimum version from there.
633635
[#26369]: https://github.com/JuliaLang/julia/issues/26369
634636
[#26436]: https://github.com/JuliaLang/julia/issues/26436
635637
[#26442]: https://github.com/JuliaLang/julia/issues/26442
638+
[#26486]: https://github.com/JuliaLang/julia/issues/26486
636639
[#26660]: https://github.com/JuliaLang/julia/issues/26660
637640
[#26670]: https://github.com/JuliaLang/julia/issues/26670
638641
[#27077]: https://github.com/JuliaLang/julia/issues/27077

src/Compat.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,14 @@ end
18711871
const isletter = isalpha
18721872
end
18731873

1874+
# 0.7.0-DEV.4762
1875+
@static if !isdefined(Base, Symbol("@cfunction"))
1876+
macro cfunction(f, rt, tup)
1877+
:(Base.cfunction($f, $rt, Tuple{$tup...}))
1878+
end
1879+
export @cfunction
1880+
end
1881+
18741882
include("deprecated.jl")
18751883

18761884
end # module Compat

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,4 +1732,11 @@ end
17321732
@test isletter('β')
17331733
@test !isletter('3')
17341734

1735+
# 0.7.0-DEV.4762
1736+
let ptr = @cfunction(+, Int, (Int, Int))
1737+
@test ptr isa Ptr{Cvoid}
1738+
@test ptr != C_NULL
1739+
@test ccall(ptr, Int, (Int, Int), 2, 3) == 5
1740+
end
1741+
17351742
nothing

0 commit comments

Comments
 (0)