Skip to content

Commit ce41bf0

Browse files
committed
Add at-cfunction
1 parent c5527e9 commit ce41bf0

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

README.md

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

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

416+
* `cfunction` is now `@cfunction` ([#26486]).
417+
416418
## New macros
417419

418420
* `@__DIR__` has been added ([#18380])
@@ -637,6 +639,7 @@ includes this fix. Find the minimum version from there.
637639
[#26369]: https://github.com/JuliaLang/julia/issues/26369
638640
[#26436]: https://github.com/JuliaLang/julia/issues/26436
639641
[#26442]: https://github.com/JuliaLang/julia/issues/26442
642+
[#26486]: https://github.com/JuliaLang/julia/issues/26486
640643
[#26660]: https://github.com/JuliaLang/julia/issues/26660
641644
[#26670]: https://github.com/JuliaLang/julia/issues/26670
642645
[#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
@@ -1891,6 +1891,14 @@ end
18911891
const isletter = isalpha
18921892
end
18931893

1894+
# 0.7.0-DEV.4762
1895+
@static if !isdefined(Base, Symbol("@cfunction"))
1896+
macro cfunction(f, rt, tup)
1897+
:(Base.cfunction($f, $rt, Tuple{$tup...}))
1898+
end
1899+
export @cfunction
1900+
end
1901+
18941902
include("deprecated.jl")
18951903

18961904
end # module Compat

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,4 +1757,10 @@ end
17571757
@test isletter('β')
17581758
@test !isletter('3')
17591759

1760+
# 0.7.0-DEV.4762
1761+
let ptr = @cfunction(+, Int, (Int, Int))
1762+
@test ptr isa Ptr{Cvoid}
1763+
@test ptr != C_NULL
1764+
end
1765+
17601766
nothing

0 commit comments

Comments
 (0)