Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lcmtype macro to avoid precompilation issues in BotCoreLCMTypes. #54

Merged
merged 1 commit into from
Sep 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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