Skip to content
Snippets Groups Projects
Commit caf16546 authored by Jens Nolte's avatar Jens Nolte
Browse files

Implement message serialization

parent fa780fab
No related branches found
No related tags found
No related merge requests found
......@@ -182,7 +182,13 @@ isMessageInstanceD t msgs = instanceD (pure []) [t|IsMessage $t|] [opcodeNameD,
getMessageE :: Q Exp
getMessageE = applyA (conE (msg.msgConName)) ((\argT -> [|getArgument @($argT)|]) . argumentSpecType <$> msg.msgSpec.arguments)
putMessageD :: Q Dec
putMessageD = funD 'putMessage [clause [] (normalB [|undefined|]) []]
putMessageD = funD 'putMessage (putMessageClauseD <$> msgs)
putMessageClauseD :: MessageContext -> Q Clause
putMessageClauseD msg = clause [msgConP msg] (normalB (putMessageE msg.msgSpec.arguments)) []
where
putMessageE :: [ArgumentSpec] -> Q Exp
putMessageE [] = [|pure ()|]
putMessageE args = doE ((\arg -> noBindS [|putArgument @($(argumentSpecType arg)) $(msgArgE msg arg)|]) <$> args)
interfaceN :: InterfaceSpec -> Name
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment