Skip to content

Commit 6113172

Browse files
authored
Merge pull request #11 from JuliaComputing/jq/0.6-0.7compat
Updates for 0.6/0.7
2 parents 9491451 + f8700f4 commit 6113172

File tree

13 files changed

+231
-196
lines changed

13 files changed

+231
-196
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ sudo: required
44
os:
55
- linux
66
julia:
7-
- 0.5
87
- 0.6
8+
- nightly
99
services:
1010
- rabbitmq
1111
notifications:

REQUIRE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
julia 0.5
2-
Compat 0.17.0
1+
julia 0.6
2+
Compat 0.41.0

spec/gen.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function gen_spec(specfile)
116116
methidx = parse(Int, attribute(meth, "index"))
117117
methargs = Pair{Symbol,Type}[]
118118
methrespelem = find_element(meth, "response")
119-
methresp = (methrespelem === nothing) ? :Void : Symbol(name2sym(attribute(methrespelem, "name")))
119+
methresp = (methrespelem === nothing) ? :Nothing : Symbol(name2sym(attribute(methrespelem, "name")))
120120
println(methindent, methsep, "$methidx => MethodSpec($methidx, :$methname, :$methresp, Pair{Symbol,DataType}[")
121121
isempty(methsep) && (methsep = ", ")
122122

src/AMQPClient.jl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ using Compat
66
using Base.I18n
77
import Base: write, read, read!, close, convert, show, isopen
88

9-
# enable logging only during debugging
10-
#using Logging
11-
#function __init__()
12-
# #Logging.configure(filename="AMQPClient.log", level=DEBUG)
13-
# Logging.configure(level=DEBUG)
14-
#end
15-
#macro logmsg(s)
16-
# quote
17-
# debug("[", myid(), "-", "] ", $(esc(s)))
18-
# end
19-
#end
20-
macro logmsg(s)
9+
if !isdefined(Base, Symbol("@debug"))
10+
# 0.6: enable logging only during debugging
11+
const DEBUG = false
12+
macro debug(s)
13+
esc(:(DEBUG && println("[ Debug: ", $s)))
14+
end
15+
else
16+
# 0.7: use builtin logging by enabling following statement
17+
# Base.CoreLogging.global_logger(Base.CoreLogging.SimpleLogger(STDERR, Base.CoreLogging.Debug))
18+
end
19+
20+
if !isdefined(Base, :popfirst!)
21+
const popfirst! = shift!
2122
end
2223

2324
# Client property info that gets sent to the server on connection startup

src/convert.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
convert{T<:Union{TAMQPShortStr,TAMQPLongStr}}(::Type{Any}, s::T) = convert(String, s)
2-
convert{T<:Union{TAMQPShortStr,TAMQPLongStr}}(::Type{String}, s::T) = String(convert(Array{UInt8,1}, s.data))
3-
convert{T<:Union{TAMQPShortStr,TAMQPLongStr}}(::Type{T}, s::AbstractString) = T(length(s), Vector{UInt8}(s))
1+
convert(::Type{Any}, s::T) where {T<:Union{TAMQPShortStr,TAMQPLongStr,TAMQPByteArray}} = convert(String, s)
2+
convert(::Type{String}, s::T) where {T<:Union{TAMQPShortStr,TAMQPLongStr,TAMQPByteArray}} = String(convert(Vector{UInt8}, s.data))
3+
convert(::Type{T}, s::AbstractString) where {T<:Union{TAMQPShortStr,TAMQPLongStr,TAMQPByteArray}} = T(length(s), Vector{UInt8}(s))
44
convert(::Type{TAMQPLongStr}, d::Vector{UInt8}) = TAMQPLongStr(length(d), d)
5+
convert(::Type{TAMQPByteArray}, d::Vector{UInt8}) = TAMQPByteArray(length(d), d)
56

6-
convert{T}(::Type{TAMQPFieldValue{T}}, v::T) = TAMQPFieldValue{T}(FieldIndicatorMap[T], v)
7+
convert(::Type{TAMQPFieldValue{T}}, v::T) where {T} = TAMQPFieldValue{T}(FieldIndicatorMap[T], v)
78

8-
as_fval{T}(v::T) = convert(TAMQPFieldValue{T}, v)
9+
as_fval(v::T) where {T} = convert(TAMQPFieldValue{T}, v)
910
as_fval(v::Dict{String,Any}) = convert(TAMQPFieldValue{TAMQPFieldTable}, convert(TAMQPFieldTable, v))
1011
as_fval(v::String) = convert(TAMQPFieldValue{TAMQPLongStr}, convert(TAMQPLongStr, v))
1112

1213
convert(::Type{Any}, t::TAMQPFieldTable) = convert(Dict{Any,Any}, t)
13-
convert{K,V}(::Type{Dict{K,V}}, t::TAMQPFieldTable) = Dict{K,V}(f.name => f.val for f in t.data)
14+
convert(::Type{Dict{K,V}}, t::TAMQPFieldTable) where {K, V} = Dict{K,V}(f.name => f.val for f in t.data)
1415
function convert(::Type{TAMQPFieldTable}, d::Dict{String,Any})
15-
#@logmsg("converting to TAMQPFieldTable")
1616
data = TAMQPFieldValuePair[]
1717
for (n,v) in d
1818
push!(data, TAMQPFieldValuePair(convert(TAMQPShortStr,n), as_fval(v)))
@@ -21,8 +21,8 @@ function convert(::Type{TAMQPFieldTable}, d::Dict{String,Any})
2121
end
2222

2323
convert(::Type{Any}, t::TAMQPFieldArray) = convert(Vector, t)
24-
convert{T}(::Type{Vector{T}}, t::TAMQPFieldArray) = convert(Vector{T}, t.data)
24+
convert(::Type{Vector{T}}, t::TAMQPFieldArray) where {T} = convert(Vector{T}, t.data)
2525

2626
convert(::Type{Bool}, b::TAMQPBit) = Bool(b.val & 0x1)
2727
convert(::Type{TAMQPBit}, b::Bool) = TAMQPBit(convert(UInt8, b))
28-
convert{T<:Integer}(::Type{TAMQPBit}, b::T) = convert(TAMQPBit, Bool(b))
28+
convert(::Type{TAMQPBit}, b::T) where {T<:Integer} = convert(TAMQPBit, Bool(b))

src/message.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
immutable PropertySpec
1+
struct PropertySpec
22
name::Symbol
33
typ::Type
44
mask::UInt16
@@ -27,7 +27,7 @@ const PROPERTIES = Dict{Symbol, PropertySpec}(
2727
const SORTED_PROPERTY_NAMES = [:content_type, :content_encoding, :headers, :delivery_mode, :priority, :correlation_id, :reply_to, :expiration, :message_id, :timestamp, :message_type, :user_id, :app_id, :cluster_id]
2828
const SORTED_PROPERTIES = [PROPERTIES[k] for k in SORTED_PROPERTY_NAMES]
2929

30-
type Message
30+
mutable struct Message
3131
data::Vector{UInt8}
3232
properties::Dict{Symbol,TAMQPField}
3333

0 commit comments

Comments
 (0)