summaryrefslogtreecommitdiff
path: root/lib/GSL/Special/auto.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-07-28 18:35:00 +0000
committerAlberto Ruiz <aruiz@um.es>2007-07-28 18:35:00 +0000
commit8731b5e093e0014472e870bf5166e2d074d206c1 (patch)
tree76c49133991b25e6587d617185236a8c789e7023 /lib/GSL/Special/auto.hs
parent774924233c87a20c31a3232cbd01d9bf5170a951 (diff)
GSL.Special.Exp.hs
Diffstat (limited to 'lib/GSL/Special/auto.hs')
-rw-r--r--lib/GSL/Special/auto.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/GSL/Special/auto.hs b/lib/GSL/Special/auto.hs
index f047bcb..42829bb 100644
--- a/lib/GSL/Special/auto.hs
+++ b/lib/GSL/Special/auto.hs
@@ -33,11 +33,12 @@ safe (Header _ _ args) = all ok args
33 where ok ((Normal s),_) | s `elem` ["double","float","int","gsl_mode_t"] = True 33 where ok ((Normal s),_) | s `elem` ["double","float","int","gsl_mode_t"] = True
34 ok _ = False 34 ok _ = False
35 kn ((Pointer "gsl_sf_result"),_) = True 35 kn ((Pointer "gsl_sf_result"),_) = True
36 kn ((Pointer "gsl_sf_result_e10"),_) = True
36 kn _ = False 37 kn _ = False
37 38
38 39
39 40
40fixC s = rep ("gsl_mode_t","int") $ rep ("gsl_sf_result","double") $ s 41fixC s = rep ("gsl_mode_t","int") $ rep ("gsl_sf_result","double") $ rep ("gsl_sf_result_e10","double") $ s
41 42
42main = do 43main = do
43 args <- getArgs 44 args <- getArgs
@@ -154,6 +155,7 @@ t2 = do
154 return (Pointer t,n) 155 return (Pointer t,n)
155 156
156pure (Header _ _ args) | fst (last args) == Pointer "gsl_sf_result" = False 157pure (Header _ _ args) | fst (last args) == Pointer "gsl_sf_result" = False
158 | fst (last args) == Pointer "gsl_sf_result_e10" = False
157 | otherwise = True 159 | otherwise = True
158 160
159showC (Header t n args) = showCt t ++ " " ++ n ++ "(" ++ (concat $ intersperse "," $ map showCa args) ++ ");" 161showC (Header t n args) = showCt t ++ " " ++ n ++ "(" ++ (concat $ intersperse "," $ map showCa args) ++ ");"
@@ -169,6 +171,7 @@ showH hc h@(Header t n args) = "foreign import ccall \""++hc++" "++n++"\" "++n++
169 171
170showHt (Normal (s:ss)) = toUpper s : ss 172showHt (Normal (s:ss)) = toUpper s : ss
171showHt (Pointer "gsl_sf_result") = "Ptr Double" 173showHt (Pointer "gsl_sf_result") = "Ptr Double"
174showHt (Pointer "gsl_sf_result_e10") = "Ptr ()"
172showHt (Pointer (s:ss)) = "Ptr "++toUpper s : ss 175showHt (Pointer (s:ss)) = "Ptr "++toUpper s : ss
173 176
174showHa (t,a) = showHt t 177showHa (t,a) = showHt t
@@ -179,6 +182,7 @@ fixmd1 = rep ("Gsl_mode_t","Precision")
179fixmd2 = rep ("mode"," (precCode mode)") 182fixmd2 = rep ("mode"," (precCode mode)")
180 183
181boiler h@(Header t n args) | fst (last args) == Pointer "gsl_sf_result" = boilerResult h 184boiler h@(Header t n args) | fst (last args) == Pointer "gsl_sf_result" = boilerResult h
185 | fst (last args) == Pointer "gsl_sf_result_e10" = boilerResultE10 h
182 | any isMode args = boilerMode h 186 | any isMode args = boilerMode h
183 | otherwise = boilerBasic h 187 | otherwise = boilerBasic h
184 188
@@ -191,6 +195,11 @@ boilerResult h@(Header t n args) =
191 drop 7 n ++ " "++(unwords (map snd (init args)))++ 195 drop 7 n ++ " "++(unwords (map snd (init args)))++
192 " = createSFR \""++ drop 7 n ++"\" $ " ++ n ++ " "++(fixmd2 $ unwords (map snd (init args))) 196 " = createSFR \""++ drop 7 n ++"\" $ " ++ n ++ " "++(fixmd2 $ unwords (map snd (init args)))
193 197
198boilerResultE10 h@(Header t n args) =
199 drop 7 n++" :: "++ (fixmd1 $ concat $ intersperse" -> "$ map showHa (init args)) ++" -> " ++ "(Double,Int,Double)\n" ++
200 drop 7 n ++ " "++(unwords (map snd (init args)))++
201 " = createSFR_E10 \""++ drop 7 n ++"\" $ " ++ n ++ " "++(fixmd2 $ unwords (map snd (init args)))
202
194boilerBasic h@(Header t n args) = 203boilerBasic h@(Header t n args) =
195 drop 7 n++" :: "++ (fixmd1 $ concat $ intersperse" -> "$map showHa args) ++" -> " ++showHt t ++ "\n" ++ 204 drop 7 n++" :: "++ (fixmd1 $ concat $ intersperse" -> "$map showHa args) ++" -> " ++showHt t ++ "\n" ++
196 drop 7 n ++ " = " ++fixmd2 n 205 drop 7 n ++ " = " ++fixmd2 n