diff options
Diffstat (limited to 'lib/GSL/Special/auto.hs')
-rw-r--r-- | lib/GSL/Special/auto.hs | 35 |
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 @@ | |||
3 | import Text.ParserCombinators.Parsec | 3 | import Text.ParserCombinators.Parsec |
4 | import System | 4 | import System |
5 | import Data.List(intersperse, isPrefixOf) | 5 | import Data.List(intersperse, isPrefixOf) |
6 | import Data.Char(toUpper) | 6 | import Data.Char(toUpper,isUpper,toLower) |
7 | 7 | ||
8 | data Type = Normal Ident | Pointer Ident deriving (Eq, Show) | 8 | data 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 | |||
189 | isMode (Normal "gsl_mode_t",_) = True | 189 | isMode (Normal "gsl_mode_t",_) = True |
190 | isMode _ = False | 190 | isMode _ = False |
191 | 191 | ||
192 | hName n = f $ drop 7 n | ||
193 | where f (s:ss) = toLower s : ss | ||
194 | |||
192 | 195 | ||
193 | boilerResult h@(Header t n args) = | 196 | boilerResult 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 | ||
198 | boilerResultE10 h@(Header t n args) = | 201 | boilerResultE10 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 | ||
203 | boilerBasic h@(Header t n args) = | 206 | boilerBasic 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 | ||
207 | boilerMode h@(Header t n args) = | 210 | boilerMode 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 | |||
215 | cVar (v:vs) | isUpper v = toLower v : v : vs | ||
216 | | otherwise = v:vs | ||
217 | |||
218 | allArgs args = unwords (map (cVar.snd) args) | ||
219 | initArgs args = unwords (map (cVar.snd) (init args)) \ No newline at end of file | ||