diff options
Diffstat (limited to 'lib/GSL/Special/auto.hs')
-rw-r--r-- | lib/GSL/Special/auto.hs | 11 |
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 | ||
40 | fixC s = rep ("gsl_mode_t","int") $ rep ("gsl_sf_result","double") $ s | 41 | fixC s = rep ("gsl_mode_t","int") $ rep ("gsl_sf_result","double") $ rep ("gsl_sf_result_e10","double") $ s |
41 | 42 | ||
42 | main = do | 43 | main = 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 | ||
156 | pure (Header _ _ args) | fst (last args) == Pointer "gsl_sf_result" = False | 157 | pure (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 | ||
159 | showC (Header t n args) = showCt t ++ " " ++ n ++ "(" ++ (concat $ intersperse "," $ map showCa args) ++ ");" | 161 | showC (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 | ||
170 | showHt (Normal (s:ss)) = toUpper s : ss | 172 | showHt (Normal (s:ss)) = toUpper s : ss |
171 | showHt (Pointer "gsl_sf_result") = "Ptr Double" | 173 | showHt (Pointer "gsl_sf_result") = "Ptr Double" |
174 | showHt (Pointer "gsl_sf_result_e10") = "Ptr ()" | ||
172 | showHt (Pointer (s:ss)) = "Ptr "++toUpper s : ss | 175 | showHt (Pointer (s:ss)) = "Ptr "++toUpper s : ss |
173 | 176 | ||
174 | showHa (t,a) = showHt t | 177 | showHa (t,a) = showHt t |
@@ -179,6 +182,7 @@ fixmd1 = rep ("Gsl_mode_t","Precision") | |||
179 | fixmd2 = rep ("mode"," (precCode mode)") | 182 | fixmd2 = rep ("mode"," (precCode mode)") |
180 | 183 | ||
181 | boiler h@(Header t n args) | fst (last args) == Pointer "gsl_sf_result" = boilerResult h | 184 | boiler 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 | ||
198 | boilerResultE10 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 | |||
194 | boilerBasic h@(Header t n args) = | 203 | boilerBasic 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 |