llvm-ffi-tools 0.0.1 → 0.0.2
raw patch · 2 files changed
+14/−13 lines, 2 filesdep ~containers
Dependency ranges changed: containers
Files
- llvm-ffi-tools.cabal +4/−4
- src/FunctionMangulation.hs +10/−9
llvm-ffi-tools.cabal view
@@ -1,5 +1,5 @@ Name: llvm-ffi-tools-Version: 0.0.1+Version: 0.0.2 License: BSD3 License-File: LICENSE Synopsis: Tools for maintaining the llvm-ffi package@@ -23,7 +23,7 @@ Location: https://hub.darcs.net/thielema/llvm-ffi-tools/ Source-Repository this- Tag: 0.0.1+ Tag: 0.0.2 Type: darcs Location: https://hub.darcs.net/thielema/llvm-ffi-tools/ @@ -31,7 +31,7 @@ Build-Depends: utility-ht >=0.0.9 && <0.1, regex-posix >=0.95 && <0.97,- containers >=0.4 && <0.7,+ containers >=0.4 && <0.9, base >=4.5 && <5 Hs-Source-Dirs: src@@ -44,7 +44,7 @@ Build-Depends: utility-ht >=0.0.9 && <0.1, regex-posix >=0.95 && <0.97,- containers >=0.4 && <0.7,+ containers >=0.4 && <0.9, base >=4.5 && <5 Hs-Source-Dirs: src
src/FunctionMangulation.hs view
@@ -1,28 +1,29 @@-module FunctionMangulation- (- pattern- , rewrite- , rewriteFunction- ) where+-- ToDo: filter out "const" using regexes+module FunctionMangulation (+ pattern,+ rewrite,+ rewriteFunction,+ ) where import Text.Regex.Posix ((=~), (=~~)) import Control.Monad (forM) import qualified Data.List.HT as ListHT+import Data.String.HT (trim) import Data.Char (toLower) import Data.List.HT (maybePrefixOf)-import Data.String.HT (trim) import Data.List (intercalate) pattern :: String-pattern = "^([A-Za-z0-9_ ]+ ?\\*?)[ \t\n]*" +++pattern = "^(LLVM_C_ABI +|)([A-Za-z0-9_ ]+ ?\\*?)[ \t\n]*" ++ "LLVM([A-Za-z0-9_]+)\\(([][a-zA-Z0-9_*, \t\n]+)\\);" renameType :: String -> String renameType t = case maybePrefixOf "LLVM" t of+ -- ToDo: we need two variants of rename Just suffix -> rename suffix Nothing -> rename t @@ -71,5 +72,5 @@ rewrite :: String -> [[String]] rewrite s = do matches <- s =~~ pattern- forM matches $ \(_:cret:cname:cparams:_) ->+ forM matches $ \(_:_cabi:cret:cname:cparams:_) -> return (rewriteFunction cret cname cparams)