Skip to content

Commit

Permalink
track JuliaLang change for names -> fieldnames
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmaykm committed Feb 27, 2015
1 parent 81ca055 commit d6d4f6f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/ProtoBuf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ end
if isless(Base.VERSION, v"0.4.0-")
import Base.rsplit
rsplit{T<:String}(str::T, splitter; limit::Integer=0, keep::Bool=true) = rsplit(str, splitter, limit, keep)
fieldnames(t) = names(t)
end

if isless(Base.VERSION, v"0.4.0-")
Expand All @@ -44,7 +45,7 @@ function copy!(to::Any, from::Any)
fromtype = typeof(from)
(totype != fromtype) && error("Can't copy a type $fromtype to $totype")
fillunset(to)
for name in totype.names
for name in fieldnames(totype)
if isfilled(from, name)
setfield!(to, name, getfield(from, name))
fillset(to, name)
Expand Down
6 changes: 3 additions & 3 deletions src/codec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ function meta(typ::Type, required::Array{Symbol,1}, numbers::Array{Int,1}, defau
cache ? (_metacache[typ] = m) : m

attribs = ProtoMetaAttribs[]
names = typ.names
names = fieldnames(typ)
types = typ.types
for fldidx in 1:length(names)
fldtyp = types[fldidx]
Expand Down Expand Up @@ -409,7 +409,7 @@ function filled(obj)
haskey(_fillcache, oid) && return _fillcache[oid]

fill = Symbol[]
for fldname in names(typeof(obj))
for fldname in fieldnames(typeof(obj))
isdefined(obj, fldname) && push!(fill, fldname)
end
if !isimmutable(obj)
Expand Down Expand Up @@ -443,7 +443,7 @@ end
abstract ProtoEnum

function lookup(en::ProtoEnum, val::Integer)
for name in typeof(en).names
for name in fieldnames(typeof(en))
(val == getfield(en, name)) && return name
end
error("Enum $(typeof(en)) has no value: $val")
Expand Down

0 comments on commit d6d4f6f

Please sign in to comment.