Skip to content

Commit

Permalink
automatically convert strings to ByteString in ccall. fixes #5673, cl…
Browse files Browse the repository at this point in the history
…oses #5677
  • Loading branch information
JeffBezanson committed Feb 18, 2014
1 parent c106c80 commit 4c72d02
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions base/base.jl
Expand Up @@ -18,8 +18,8 @@ ptr_arg_convert(::Type{Ptr{Void}}, x) = x
cconvert(T, x) = convert(T, x)
# use the code in ccall.cpp to safely allocate temporary pointer arrays
cconvert{T}(::Type{Ptr{Ptr{T}}}, a::Array) = a
# TODO: for some reason this causes a strange type inference problem
#cconvert(::Type{Ptr{Uint8}}, s::String) = bytestring(s)
# convert strings to ByteString to pass as pointers
cconvert{P<:Union(Int8,Uint8)}(::Type{Ptr{P}}, s::String) = bytestring(s)

abstract IO

Expand Down
2 changes: 1 addition & 1 deletion test/strings.jl
Expand Up @@ -857,7 +857,7 @@ bin_val = hex2bytes("07bf")

# issue #4586
@test rsplit(RevString("ailuj"),'l') == {"ju","ia"}
@test_throws float64(RevString("64"))
@test float64(RevString("64")) === 46.0

for T = (Uint8,Int8,Uint16,Int16,Uint32,Int32,Uint64,Int64,Uint128,Int128,BigInt),
b = 2:62, _ = 1:10
Expand Down

0 comments on commit 4c72d02

Please sign in to comment.