From 59c73fe5777aa85315d764e992b664aa35caa42a Mon Sep 17 00:00:00 2001 From: Twan Koolen Date: Tue, 4 Sep 2018 15:09:27 -0400 Subject: [PATCH] Fix lcmtype macro to avoid precompilation issues in BotCoreLCMTypes. --- src/lcmtype.jl | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/lcmtype.jl b/src/lcmtype.jl index 821c7a0..15b8acd 100644 --- a/src/lcmtype.jl +++ b/src/lcmtype.jl @@ -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