Skip to content

Commit

Permalink
Merge pull request #54 from JuliaRobotics/tk/fix-lcmtypesetup
Browse files Browse the repository at this point in the history
Fix lcmtype macro to avoid precompilation issues in BotCoreLCMTypes.
  • Loading branch information
rdeits authored Sep 4, 2018
2 parents 82b1864 + 59c73fe commit 081592f
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/lcmtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -402,39 +402,39 @@ macro lcmtypesetup(lcmt, dimensioninfos...)
dims = dimensioninfo.args[3].args
quote
let dimtuple = tuple($(LCMCore.makedim.(dims)...))
LCMCore.dimensions(::Type{$lcmt}, ::Val{$(QuoteNode(vecfieldname))}) = dimtuple
LCMCore.dimensions(::Type{$(esc(lcmt))}, ::Val{$(QuoteNode(vecfieldname))}) = dimtuple
end
end
end

# LCMCore.dimensions methods for constant dimensions
makeconstdimmethods = :(LCMCore.make_fixed_dimensions_methods($lcmt))
makeconstdimmethods = quote
let T = $(esc(lcmt))
for field in fieldnames(T)
F = fieldtype(T, field)
if F <: Array
# skip
elseif F <: StaticArray
let dimtuple = LCMCore.makedim.(size(F))
LCMCore.dimensions(::Type{T}, ::Val{field}) = dimtuple
end
else
LCMCore.dimensions(::Type{T}, ::Val{field}) = ()
end
end
end
end

# LCMCore.fingerprint method
fingerprint = quote
let hash = reinterpret(Int64, LCMCore.computehash($lcmt, DataType[]))
LCMCore.fingerprint(::Type{$lcmt}) = hash
let hash = reinterpret(Int64, LCMCore.computehash($(esc(lcmt)), DataType[]))
LCMCore.fingerprint(::Type{$(esc(lcmt))}) = hash
end
end

esc(quote
quote
$(vardimmethods...)
$makeconstdimmethods
$fingerprint
end)
end

function make_fixed_dimensions_methods(::Type{T}) where T<:LCMType
for field in fieldnames(T)
F = fieldtype(T, field)
if F <: Array
# skip
elseif F <: StaticArray
@eval let dimtuple = LCMCore.makedim.(size($F))
LCMCore.dimensions(::Type{$T}, ::Val{$(QuoteNode(field))}) = dimtuple
end
else
@eval LCMCore.dimensions(::Type{$T}, ::Val{$(QuoteNode(field))}) = ()
end
end
end

0 comments on commit 081592f

Please sign in to comment.