summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-03-20 00:14:35 -0400
committerJoe Crayne <joe@jerkface.net>2019-03-20 00:14:35 -0400
commit5bfc85eaf313171c48860f41dd31ef10e0402b56 (patch)
treeac2312243e73f28d39c234a0e8baca4c18855991
parent8bb81e3c6c677c6118e804d03d57607f5869b29d (diff)
Stub-generation fixes.
-rw-r--r--monkeypatch.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/monkeypatch.hs b/monkeypatch.hs
index b5f76d4..7806f07 100644
--- a/monkeypatch.hs
+++ b/monkeypatch.hs
@@ -1044,8 +1044,9 @@ c2haskell opts cs cmodname missings incs (CTranslUnit edecls _) = do
1044 1044
1045-- TODO: make idempotent 1045-- TODO: make idempotent
1046makeStatic :: [CDeclarationSpecifier NodeInfo] -> [CDeclarationSpecifier NodeInfo] 1046makeStatic :: [CDeclarationSpecifier NodeInfo] -> [CDeclarationSpecifier NodeInfo]
1047makeStatic xs = CStorageSpec (CStatic undefNode) : xs 1047makeStatic xs = CStorageSpec (CStatic undefNode) : filter nonStorages xs
1048-- makeStatic xs = CStorageSpec (CStatic ()) : xs 1048 where nonStorages (CStorageSpec _) = False
1049 nonStorages _ = True
1049 1050
1050makePointer1 :: Maybe (CDeclarator NodeInfo) 1051makePointer1 :: Maybe (CDeclarator NodeInfo)
1051 -> Maybe (CDeclarator NodeInfo) 1052 -> Maybe (CDeclarator NodeInfo)
@@ -1170,12 +1171,15 @@ setBody bdy (CDeclExt (CDecl xs ys pos)) = (CFDefExt (CFunDef xs v [] bdy p
1170 (Just y,_,_):_ -> y 1171 (Just y,_,_):_ -> y
1171 _ -> CDeclr Nothing [] Nothing [] pos 1172 _ -> CDeclr Nothing [] Nothing [] pos
1172 1173
1174
1175doesReturnValue (CTypeSpec (CVoidType _):_) = False
1176doesReturnValue (x:xs) = doesReturnValue xs
1177doesReturnValue [] = True
1178
1173makeStub :: CExternalDeclaration NodeInfo 1179makeStub :: CExternalDeclaration NodeInfo
1174 -> CExternalDeclaration NodeInfo 1180 -> CExternalDeclaration NodeInfo
1175makeStub d = -- @(CDeclExt (CDecl xs ys pos)) = 1181makeStub d = -- @(CDeclExt (CDecl xs ys pos)) =
1176 let rval = case getReturnValue d of 1182 let rval = doesReturnValue $ getReturnValue d
1177 [ CTypeSpec (CVoidType _) ] -> False -- void function.
1178 _ -> True
1179 name = concatMap identToString $ take 1 $ catMaybes $ sym d 1183 name = concatMap identToString $ take 1 $ catMaybes $ sym d
1180 msg = "undefined: " ++ concatMap (HS.prettyPrint . makeAcceptableDecl) (take 1 $ sig d) ++ "\n" 1184 msg = "undefined: " ++ concatMap (HS.prettyPrint . makeAcceptableDecl) (take 1 $ sig d) ++ "\n"
1181 in case getArgList d of 1185 in case getArgList d of