Skip to content

Commit

Permalink
Merge pull request #200 from JuliaIO/fw/drop-v0.4
Browse files Browse the repository at this point in the history
Drop v0.4 support
  • Loading branch information
TotalVerb authored May 3, 2017
2 parents c3e5515 + 53492b2 commit 318657b
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ os:
- osx
- linux
julia:
- 0.4
- 0.5
- 0.6
- nightly
notifications:
email: false
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
julia 0.4
julia 0.5
Compat 0.24.0
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
environment:
matrix:
- JULIAVERSION: "julialang/bin/winnt/x86/0.4/julia-0.4-latest-win32.exe"
- JULIAVERSION: "julialang/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe"
- JULIAVERSION: "julialang/bin/winnt/x86/0.5/julia-0.5-latest-win32.exe"
- JULIAVERSION: "julialang/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe"
- JULIAVERSION: "julialang/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIAVERSION: "julialang/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe"
- JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe"

Expand Down
16 changes: 8 additions & 8 deletions src/Parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ end

# Throws an error message with an indicator to the source
function _error(message::AbstractString, ps::MemoryParserState)
orig = Compat.UTF8String(ps.utf8data)
orig = String(ps.utf8data)
lines = _count_before(orig, '\n', ps.s)
# Replace all special multi-line/multi-space characters with a space.
strnl = replace(orig, r"[\b\f\n\r\t\s]", " ")
Expand Down Expand Up @@ -279,7 +279,7 @@ function parse_string(ps::ParserState)
elseif c < SPACE
_error(E_BAD_CONTROL, ps)
elseif c == STRING_DELIM
return Compat.UTF8String(b)
return String(b)
end

push!(b, c)
Expand Down Expand Up @@ -366,12 +366,12 @@ end


function unparameterize_type{T}(::Type{T})
candidate = typeintersect(T, Associative{Compat.UTF8String, Any})
candidate = typeintersect(T, Associative{String, Any})
candidate <: Union{} ? T : candidate
end

function parse{T<:Associative}(str::AbstractString; dicttype::Type{T}=Dict{Compat.UTF8String,Any})
ps = MemoryParserState(Vector{UInt8}(Compat.UTF8String(str)), 1)
function parse{T<:Associative}(str::AbstractString; dicttype::Type{T}=Dict{String,Any})
ps = MemoryParserState(Vector{UInt8}(String(str)), 1)
v = parse_value(ps, unparameterize_type(T))
chomp_space!(ps)
if hasmore(ps)
Expand All @@ -380,15 +380,15 @@ function parse{T<:Associative}(str::AbstractString; dicttype::Type{T}=Dict{Compa
v
end

function parse{T<:Associative}(io::IO; dicttype::Type{T}=Dict{Compat.UTF8String,Any})
function parse{T<:Associative}(io::IO; dicttype::Type{T}=Dict{String,Any})
ps = StreamingParserState(io)
parse_value(ps, unparameterize_type(T))
end

function parsefile{T<:Associative}(filename::AbstractString; dicttype::Type{T}=Dict{Compat.UTF8String, Any}, use_mmap=true)
function parsefile{T<:Associative}(filename::AbstractString; dicttype::Type{T}=Dict{String, Any}, use_mmap=true)
sz = filesize(filename)
open(filename) do io
s = use_mmap ? Compat.UTF8String(Mmap.mmap(io, Vector{UInt8}, sz)) : readstring(io)
s = use_mmap ? String(Mmap.mmap(io, Vector{UInt8}, sz)) : readstring(io)
parse(s; dicttype=dicttype)
end
end
Expand Down
12 changes: 3 additions & 9 deletions src/Writer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@ function lower(a)
end
end

if isdefined(Base, :Dates)
lower(s::Base.Dates.TimeType) = string(s)
end

if VERSION < v"0.5.0-dev+2396"
lower(f::Function) = "function at $(f.fptr)"
end
lower(s::Base.Dates.TimeType) = string(s)

# To avoid allocating an intermediate string, we directly define `show_json`
# for this type instead of lowering it to a string first (which would
Expand Down Expand Up @@ -258,7 +252,7 @@ end
function show_json(io::SC, s::CS, x::Union{Integer, AbstractFloat})
# workaround for issue in Julia 0.5.x where Float32 values are printed as
# 3.4f-5 instead of 3.4e-5
@static if v"0.5-" <= VERSION < v"0.6.0-dev.788"
@static if VERSION < v"0.6.0-dev.788"
if isa(x, Float32)
return show_json(io, s, Float64(x))
end
Expand Down Expand Up @@ -313,7 +307,7 @@ function show_json{T,n}(io::SC, s::CS, A::AbstractArray{T,n})
begin_array(io)
newdims = ntuple(_ -> :, Val{n - 1})
for j in 1:size(A, n)
show_element(io, s, Compat.view(A, newdims..., j))
show_element(io, s, view(A, newdims..., j))
end
end_array(io)
end
Expand Down
2 changes: 1 addition & 1 deletion src/specialized.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function parse_string(ps::MemoryParserState)
parse_string(ps, b)
end

Compat.UTF8String(b)
String(b)
end

"""
Expand Down
1 change: 0 additions & 1 deletion test/lowering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ using JSON
using Base.Test
using Compat
using FixedPointNumbers: Fixed
import Compat: String

if isdefined(Base, :Dates)
@test JSON.json(Date(2016, 8, 3)) == "\"2016-08-03\""
Expand Down
17 changes: 4 additions & 13 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using JSON
using Base.Test
using Compat
import Compat: String

import DataStructures

Expand All @@ -24,9 +23,9 @@ validate_c(c) = begin
validate_e(e) = begin
j=JSON.parse(e)
@test j != nothing
@test typeof(j) == Dict{Compat.UTF8String, Any}
@test typeof(j) == Dict{String, Any}
@test length(j) == 1
@test typeof(j["menu"]) == Dict{Compat.UTF8String, Any}
@test typeof(j["menu"]) == Dict{String, Any}
@test length(j["menu"]) == 2
@test j["menu"]["header"] == "SVG\tViewerα"
@test isa(j["menu"]["items"], Vector{Any})
Expand All @@ -50,11 +49,7 @@ validate_unicode(unicode) = begin
end
# -------

if VERSION >= v"0.5.0-dev+1343"
finished_async_tests = RemoteChannel()
else
finished_async_tests = RemoteRef()
end
finished_async_tests = RemoteChannel()

@async begin
s = listen(7777)
Expand Down Expand Up @@ -174,7 +169,7 @@ json_zeros = json(zeros)


# Printing an empty array or Dict shouldn't cause a BoundsError
@test json(Compat.ASCIIString[]) == "[]"
@test json(String[]) == "[]"
@test json(Dict()) == "{}"

#test for issue 26
Expand Down Expand Up @@ -274,10 +269,6 @@ end
@test Float32(JSON.parse(json(2.1f-8))) == 2.1f-8

# Check printing of more exotic objects
if VERSION < v"0.5.0-dev+2396"
# Test broken in v0.5, code is using internal structure of Function type!
@test sprint(JSON.print, sprint) == string("\"function at ", sprint.fptr, "\"")
end
@test sprint(JSON.print, Float64) == string("\"Float64\"")
@test_throws ArgumentError sprint(JSON.print, JSON)

Expand Down
3 changes: 1 addition & 2 deletions test/serializer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module TestSerializer
using JSON
using Base.Test
using Compat
import Compat: String

# to define a new serialization behaviour, import these first
import JSON.Serializations: CommonSerialization, StandardSerialization
Expand Down Expand Up @@ -45,7 +44,7 @@ JSON.show_json(io::SC, ::NaNSerialization, f::AbstractFloat) =
# issue #170: Print JavaScript functions directly
immutable JSSerialization <: CS end
immutable JSFunction
data::Compat.UTF8String
data::String
end

function JSON.show_json(io::SC, ::JSSerialization, f::JSFunction)
Expand Down

0 comments on commit 318657b

Please sign in to comment.