Skip to content

Commit e519db3

Browse files
authored
Merge pull request #31 from tkoolen/tk/ease-transition
Ease transition to new LCMType functionality.
2 parents f5c6195 + 862e23c commit e519db3

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/LCMCore.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export LCM,
2323
encode,
2424
decode,
2525
decode!,
26+
size_fields, # deprecated
27+
check_valid, # deprecated
28+
fingerprint, # will soon no longer be exported
2629
subscribe,
2730
unsubscribe,
2831
handle,

src/lcmtype.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ end
158158
end
159159

160160
function checkfingerprint(io::IO, ::Type{T}) where T<:LCMType
161-
decodefield(io, Int64) == fingerprint(T) || throw(FingerprintException(T))
161+
fp = fingerprint(T)
162+
fpint = fp isa Int64 ? fp : ntoh(reinterpret(Int64, Vector(fp))[1]) # TODO: remove for next release; fingerprints are now Int64s
163+
decodefield(io, Int64) == fpint || throw(FingerprintException(T))
162164
end
163165

164166
# Resizing
@@ -193,13 +195,13 @@ end
193195
end
194196
end
195197

196-
# checkvalid
198+
# check_valid
197199
"""
198-
checkvalid(x::LCMType)
200+
check_valid(x::LCMType)
199201
200202
Check that `x` is a valid LCM type. For example, check that array lengths are correct.
201203
"""
202-
@generated function checkvalid(x::T) where T<:LCMType
204+
@generated function check_valid(x::T) where T<:LCMType
203205
exprs = Expr[]
204206
for fieldname in fieldnames(T)
205207
F = fieldtype(T, fieldname)
@@ -315,7 +317,7 @@ end
315317
encode_exprs[i] = :(encodefield(io, x.$fieldname))
316318
end
317319
quote
318-
checkvalid(x)
320+
check_valid(x)
319321
$(encode_exprs...)
320322
io
321323
end
@@ -447,3 +449,7 @@ macro lcmtypesetup(lcmt, dimensioninfos...)
447449
$fingerprint
448450
end)
449451
end
452+
453+
# Deprecations and transition methods
454+
Base.@deprecate size_fields(::Type{T}) where {T<:LCMType} sizefields(T)
455+
sizefields(::Type{T}) where {T} = size_fields(T)

0 commit comments

Comments
 (0)