summaryrefslogtreecommitdiff
path: root/lib/GSL/Special/auto.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/GSL/Special/auto.hs')
-rw-r--r--lib/GSL/Special/auto.hs35
1 files changed, 22 insertions, 13 deletions
diff --git a/lib/GSL/Special/auto.hs b/lib/GSL/Special/auto.hs
index 42829bb..a6a0f9a 100644
--- a/lib/GSL/Special/auto.hs
+++ b/lib/GSL/Special/auto.hs
@@ -3,7 +3,7 @@
3import Text.ParserCombinators.Parsec 3import Text.ParserCombinators.Parsec
4import System 4import System
5import Data.List(intersperse, isPrefixOf) 5import Data.List(intersperse, isPrefixOf)
6import Data.Char(toUpper) 6import Data.Char(toUpper,isUpper,toLower)
7 7
8data Type = Normal Ident | Pointer Ident deriving (Eq, Show) 8data Type = Normal Ident | Pointer Ident deriving (Eq, Show)
9 9
@@ -53,7 +53,7 @@ main = do
53 --mapM (\(Header _ n _) -> putStrLn (drop 7 n ++",")) parsed 53 --mapM (\(Header _ n _) -> putStrLn (drop 7 n ++",")) parsed
54 --putStrLn "" 54 --putStrLn ""
55 --mapM_ (putStrLn.showFull (name ++".h")) parsed 55 --mapM_ (putStrLn.showFull (name ++".h")) parsed
56 let exports = rep (")",") where") $ rep ("(\n","(\n ") $ rep (",\n",", ") $ unlines $ ["("]++intersperse "," (map (\(Header _ n _) -> drop 7 n) (filter safe parsed))++[")"] 56 let exports = rep (")",") where") $ rep ("(\n","(\n ") $ rep (",\n",", ") $ unlines $ ["("]++intersperse "," (map (\(Header _ n _) -> hName n) (filter safe parsed))++[")"]
57 let defs = unlines $ map (showFull (name ++".h")) parsed 57 let defs = unlines $ map (showFull (name ++".h")) parsed
58 let imports = "\nimport Foreign(Ptr)\nimport GSL.Special.Internal\n" 58 let imports = "\nimport Foreign(Ptr)\nimport GSL.Special.Internal\n"
59 let mod = modhead name ++ "module GSL.Special."++ upperFirst name++exports++imports++defs 59 let mod = modhead name ++ "module GSL.Special."++ upperFirst name++exports++imports++defs
@@ -189,22 +189,31 @@ boiler h@(Header t n args) | fst (last args) == Pointer "gsl_sf_result" = boiler
189isMode (Normal "gsl_mode_t",_) = True 189isMode (Normal "gsl_mode_t",_) = True
190isMode _ = False 190isMode _ = False
191 191
192hName n = f $ drop 7 n
193 where f (s:ss) = toLower s : ss
194
192 195
193boilerResult h@(Header t n args) = 196boilerResult h@(Header t n args) =
194 drop 7 n++" :: "++ (fixmd1 $ concat $ intersperse" -> "$ map showHa (init args)) ++" -> " ++ "(Double,Double)\n" ++ 197 hName n++" :: "++ (fixmd1 $ concat $ intersperse" -> "$ map showHa (init args)) ++" -> " ++ "(Double,Double)\n" ++
195 drop 7 n ++ " "++(unwords (map snd (init args)))++ 198 hName n ++ " "++ initArgs args ++
196 " = createSFR \""++ drop 7 n ++"\" $ " ++ n ++ " "++(fixmd2 $ unwords (map snd (init args))) 199 " = createSFR \""++ hName n ++"\" $ " ++ n ++ " "++ (fixmd2 $ initArgs args)
197 200
198boilerResultE10 h@(Header t n args) = 201boilerResultE10 h@(Header t n args) =
199 drop 7 n++" :: "++ (fixmd1 $ concat $ intersperse" -> "$ map showHa (init args)) ++" -> " ++ "(Double,Int,Double)\n" ++ 202 hName n++" :: "++ (fixmd1 $ concat $ intersperse" -> "$ map showHa (init args)) ++" -> " ++ "(Double,Int,Double)\n" ++
200 drop 7 n ++ " "++(unwords (map snd (init args)))++ 203 hName n ++ " "++ initArgs args ++
201 " = createSFR_E10 \""++ drop 7 n ++"\" $ " ++ n ++ " "++(fixmd2 $ unwords (map snd (init args))) 204 " = createSFR_E10 \""++ hName n ++"\" $ " ++ n ++ " "++ (fixmd2 $ initArgs args)
202 205
203boilerBasic h@(Header t n args) = 206boilerBasic h@(Header t n args) =
204 drop 7 n++" :: "++ (fixmd1 $ concat $ intersperse" -> "$map showHa args) ++" -> " ++showHt t ++ "\n" ++ 207 hName n++" :: "++ (fixmd1 $ concat $ intersperse" -> "$map showHa args) ++" -> " ++showHt t ++ "\n" ++
205 drop 7 n ++ " = " ++fixmd2 n 208 hName n ++ " = " ++fixmd2 n
206 209
207boilerMode h@(Header t n args) = 210boilerMode h@(Header t n args) =
208 drop 7 n++" :: "++ (fixmd1 $ concat $ intersperse" -> "$ map showHa args) ++" -> " ++ showHt t++"\n" ++ 211 hName n++" :: "++ (fixmd1 $ concat $ intersperse" -> "$ map showHa args) ++" -> " ++ showHt t++"\n" ++
209 drop 7 n ++ " "++(unwords (map snd args))++ 212 hName n ++ " "++ allArgs args ++
210 " = " ++ n ++ " "++(fixmd2 $ unwords (map snd args)) 213 " = " ++ n ++ " "++ (fixmd2 $ allArgs args)
214
215cVar (v:vs) | isUpper v = toLower v : v : vs
216 | otherwise = v:vs
217
218allArgs args = unwords (map (cVar.snd) args)
219initArgs args = unwords (map (cVar.snd) (init args)) \ No newline at end of file