From dbc71a294d7fd2f5f530b90a7bccf3e0d5a7f384 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Sun, 22 Apr 2012 17:56:00 +0200 Subject: [PATCH] handle macro-less inline procedures --- PrepareHeaders.hs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/PrepareHeaders.hs b/PrepareHeaders.hs index 12005bc21c..64f1d15585 100644 --- a/PrepareHeaders.hs +++ b/PrepareHeaders.hs @@ -45,15 +45,28 @@ balancedText stopAtComma = fmap (foldr ($) "") $ trim = dropWhile isSpace . reverse . dropWhile isSpace . reverse cleanup = unwords . words . trim +returnType = do + t <- identifier tp + ptrs <- many (reservedOp tp "*" >> return '*') + return $ t ++ ptrs + externApiDeclaration = do - reserved tp "EXTERN_API" - rettype <- fmap trim $ parens tp (balancedText False) + rettype <- (reserved tp "EXTERN_API" >> (fmap trim $ parens tp (balancedText False))) + <|> (reserved tp "pascal" >> returnType) name <- identifier tp arguments <- fmap (map cleanup) $ parens tp (commaSep tp $ balancedText True) - inlines <- option [] $ do - inlinekey <- identifier tp - guard ("WORDINLINE" `isSuffixOf` inlinekey) - parens tp (commaSep tp hexword) + + let hexwords = commaSep tp hexword + macroinline = do + inlinekey <- identifier tp + guard ("WORDINLINE" `isSuffixOf` inlinekey) + parens tp hexwords + plaininline = do + reservedOp tp "=" + braces tp hexwords + + inlines <- macroinline <|> plaininline <|> return [] + semi tp let arguments' | arguments == ["void"] = [] | otherwise = arguments