diff options
Diffstat (limited to 'src/Language/Fiddle/Compiler/Backend/C.hs')
-rw-r--r-- | src/Language/Fiddle/Compiler/Backend/C.hs | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/Language/Fiddle/Compiler/Backend/C.hs b/src/Language/Fiddle/Compiler/Backend/C.hs index e9989a0..4b4b3ea 100644 --- a/src/Language/Fiddle/Compiler/Backend/C.hs +++ b/src/Language/Fiddle/Compiler/Backend/C.hs @@ -42,8 +42,8 @@ newtype CBackendFlags = CBackendFlags data SIntfF = SIntfF - { sIntfFValue :: Text, - sIntfFComemnts :: FormattedWriter () + { _sIntfFValue :: Text, + _sIntfFComemnts :: FormattedWriter () } newtype SIntf @@ -220,15 +220,6 @@ transpile Text.replace "/" "_" $ Text.pack headerFile -class IsText t where - toText :: t -> Text - -instance IsText String where - toText = Text.pack - -instance IsText Text where - toText = id - qualifiedPathToIdentifier :: QualifiedPath String -> Text qualifiedPathToIdentifier = Text.pack . qualifiedPathToString "__" "_" @@ -400,8 +391,9 @@ writeBitsGet structName regmeta fullPath offset typeRef docComms = do unless (null shiftArguments) $ text ", " - text $ Text.intercalate ", " $ - zipWith (\f _ -> "int " <> f) (tail setterArgumentNames) shiftArguments + text $ + Text.intercalate ", " $ + zipWith (\f _ -> "int " <> f) (tail setterArgumentNames) shiftArguments text ") {\n" @@ -715,6 +707,20 @@ structBody structName (ObjTypeBody _ decls _) = do checkout iF $ (if regIsUnnamed regMetadata then id else sIntfSingleton i) <$> writeImplementation structName regMetadata mod bod ann + BufferDecl + { bufIdent = Guaranteed (identToString -> i), + bufSize = (trueValue -> size), + bufAnnot = ann + } -> do + textM $ do + emitDocComments ann + tell "uint8_t " + tell (Text.pack i) + tell "[" + tell $ Text.pack (show size) + tell "];\n" + + return mempty TypeSubStructure { subStructureBody = Identity bod, subStructureName = mname @@ -864,7 +870,7 @@ emitEnum (qualifiedPathToIdentifier -> ident) consts = do transpileWalk :: FilePath -> (forall t. (Walk t, Typeable t) => t I A -> () -> M (WalkContinuation ())) -transpileWalk headerFile t _ = case () of +transpileWalk _headerFile t _ = case () of () | Just ( ObjTypeDecl |