Skip to content

Commit

Permalink
Move documentation of Ptr and Ref to more relevant source files.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Oct 11, 2016
1 parent 7ae71ac commit a10f61d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
22 changes: 0 additions & 22 deletions base/c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,6 @@ import Core.Intrinsics: cglobal, box

cfunction(f::Function, r, a) = ccall(:jl_function_ptr, Ptr{Void}, (Any, Any, Any), f, r, a)

"""
Ptr{T}
A memory address referring to data of type `T`. However, there is no guarantee that the
memory is actually valid, or that it actually represents data of the specified type.
"""
Ptr

"""
Ref{T}
An object that safely references data of type `T`. This type is guaranteed to point to
valid, Julia-allocated memory of the correct type. The underlying data is protected from
freeing by the garbage collector as long as the `Ref` itself is referenced.
When passed as a `ccall` argument (either as a `Ptr` or `Ref` type), a `Ref` object will be
converted to a native pointer to the data it references.
There is no invalid (NULL) `Ref`.
"""
Ref

if ccall(:jl_is_char_signed, Ref{Bool}, ())
typealias Cchar Int8
else
Expand Down
8 changes: 8 additions & 0 deletions base/pointer.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# This file is a part of Julia. License is MIT: http://julialang.org/license

"""
Ptr{T}
A memory address referring to data of type `T`. However, there is no guarantee that the
memory is actually valid, or that it actually represents data of the specified type.
"""
Ptr

## converting pointers to an appropriate unsigned ##

"""
Expand Down
14 changes: 14 additions & 0 deletions base/refpointer.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# This file is a part of Julia. License is MIT: http://julialang.org/license

"""
Ref{T}
An object that safely references data of type `T`. This type is guaranteed to point to
valid, Julia-allocated memory of the correct type. The underlying data is protected from
freeing by the garbage collector as long as the `Ref` itself is referenced.
When passed as a `ccall` argument (either as a `Ptr` or `Ref` type), a `Ref` object will be
converted to a native pointer to the data it references.
There is no invalid (NULL) `Ref`.
"""
Ref

# C NUL-terminated string pointers; these can be used in ccall
# instead of Ptr{Cchar} and Ptr{Cwchar_t}, respectively, to enforce
# a check for embedded NUL chars in the string (to avoid silent truncation).
Expand Down

0 comments on commit a10f61d

Please sign in to comment.