@@ -336,38 +336,42 @@ thriftTy here t = case t of
336
336
HasKey {} -> error " thriftTy: HasKey"
337
337
ElementsOf {} -> error " thriftTy: ElementsOf"
338
338
339
- mkField :: [Text ] -> Text -> Int -> Name -> Text -> Text
340
- mkField annots structOrUnion i p t =
341
- allowReservedIdentifierAnnotation p
342
- <> showt i <> " : " <> t <> " " <> p <> annotText <> " ;"
339
+ mkField :: [Text ] -> [ Text ] -> Text -> Int -> Name -> Text -> Text
340
+ mkField structuredAnnots unstructuredAnnots structOrUnion i p t =
341
+ structuredAnnotText <> allowReservedIdentifierAnnotation p
342
+ <> showt i <> " : " <> t <> " " <> p <> unstructuredAnnotText <> " ;"
343
343
where
344
+ structuredAnnotText =
345
+ Text. concat $ map (\ annot -> annot <> newline <> " " ) structuredAnnots
346
+
344
347
-- The java.swift codegen likes to strip underscores from the end of
345
348
-- names for some reason.
346
- javaAnnot
349
+ javaUnstructuredAnnot
347
350
| " _" `Text.isSuffixOf` p = [" java.swift.name = \" " <> p <> " \" " ]
348
351
| otherwise = []
349
352
350
- py3Annot
353
+ py3UnstructuredAnnot
351
354
| p == " from" = [" py3.name = \" from_\" " ]
352
355
| p == " type" && structOrUnion == " union" = [" py3.name = \" type_\" " ]
353
356
| p == " name" && structOrUnion == " union" = [" py3.name = \" name_\" " ]
354
357
| p == " value" && structOrUnion == " union" = [" py3.name = \" value_\" " ]
355
358
| otherwise = []
356
359
357
- allAnnots = javaAnnot ++ py3Annot ++ annots
360
+ allUnstructuredAnnots =
361
+ javaUnstructuredAnnot ++ py3UnstructuredAnnot ++ unstructuredAnnots
358
362
359
- annotText
360
- | null allAnnots = " "
361
- | otherwise = " (" <> Text. intercalate " , " allAnnots <> " )"
363
+ unstructuredAnnotText
364
+ | null allUnstructuredAnnots = " "
365
+ | otherwise = " (" <> Text. intercalate " , " allUnstructuredAnnots <> " )"
362
366
363
367
makeField :: Text -> Int -> Name -> Text -> Text
364
- makeField = mkField []
368
+ makeField = mkField [] []
365
369
366
370
makeRefField :: Text -> Int -> Name -> Text -> Text
367
371
makeRefField = mkField
372
+ [ " @rust.Box" ]
368
373
[ " cpp.ref = \" true\" "
369
374
, " cpp2.ref = \" true\" "
370
- , " rust.box"
371
375
, " swift.recursive_reference = \" true\" "
372
376
]
373
377
@@ -442,7 +446,7 @@ genPred here PredicateDef{..} = do
442
446
, [ allowReservedIdentifierAnnotation name
443
447
<> structOrUnion <> " " <> name <> " {" ]
444
448
, indentLines . catMaybes . zipWith (flip ($) ) [1 .. ] $
445
- [ \ i -> Just $ mkField [" hs.strict" ] structOrUnion i " id" type_id
449
+ [ \ i -> Just $ mkField [] [ " hs.strict" ] structOrUnion i " id" type_id
446
450
, key, val ]
447
451
, [ " }" ]
448
452
]
0 commit comments