@@ -16,12 +16,22 @@ respectively.
16
16
"""
17
17
cglobal
18
18
19
- struct CFunction
19
+ """
20
+ CFunction struct
21
+
22
+ Garbage-collection handle for the return value from `@cfunction`
23
+ when the first argument is annotated with '\$ '.
24
+ Like all `cfunction` handles, it should be passed to `ccall` as a `Ptr{Cvoid}`,
25
+ and will be converted automatically at the call site to the appropriate type.
26
+
27
+ See [`@cfunction`](@ref).
28
+ """
29
+ struct CFunction <: Ref{Cvoid}
20
30
ptr:: Ptr{Cvoid}
21
31
f:: Any
22
32
_1:: Ptr{Cvoid}
23
33
_2:: Ptr{Cvoid}
24
- let construtor = false end
34
+ let constructor = false end
25
35
end
26
36
unsafe_convert (:: Type{Ptr{Cvoid}} , cf:: CFunction ) = cf. ptr
27
37
@@ -31,11 +41,12 @@ unsafe_convert(::Type{Ptr{Cvoid}}, cf::CFunction) = cf.ptr
31
41
32
42
Generate a C-callable function pointer from the Julia function `closure`
33
43
for the given type signature.
44
+ To pass the return value to a `ccall`, use the argument type `Ptr{Cvoid}` in the signature.
34
45
35
46
Note that the argument type tuple must be a literal tuple, and not a tuple-valued variable or expression
36
47
(although it can include a splat expression). And that these arguments will be evaluated in global scope
37
48
during compile-time (not deferred until runtime).
38
- Adding a ` \$ ` in front of the function argument changes this to instead create a runtime closure
49
+ Adding a ' \$ ' in front of the function argument changes this to instead create a runtime closure
39
50
over the local variable `callable`.
40
51
41
52
See [manual section on ccall and cfunction usage](@ref Calling-C-and-Fortran-Code).
0 commit comments