@@ -9,6 +9,7 @@ import qualified Data.Set as S
99import qualified System.Console.GetOpt as G
1010import qualified System.Environment as E
1111import MangledRegistry
12+ import ManPages
1213
1314data Option
1415 = PrintFeature
@@ -64,7 +65,7 @@ main = do
6465 putStrLn " --"
6566 putStrLn " --------------------------------------------------------------------------------"
6667 putStrLn " "
67- let (ts,es,cs) = getTyEnCo api version profile registry
68+ let (ts,es,cs) = fixedGetTyEnCo api version profile registry
6869 putStrLn $ " module " ++ modName ++ " ("
6970 CM. unless (null ts) $ do
7071 putStrLn " -- * Types"
@@ -144,14 +145,23 @@ main = do
144145 putStrLn " throwIfNullFunPtr :: String -> IO (FunPtr a) -> IO (FunPtr a)"
145146 putStrLn " throwIfNullFunPtr = throwIf (== nullFunPtr) . const"
146147 putStrLn " "
147- mapM_ (putStrLn . showCommand) (M. elems (commands registry))
148+ mapM_ (putStrLn . showCommand api ) (M. elems (commands registry))
148149
149150capitalize :: String -> String
150151capitalize str = C. toUpper (head str) : tail str
151152
152153separate :: (a -> String ) -> [a ] -> String
153154separate f = L. intercalate " ,\n " . map (" " ++ ) . map f
154155
156+ -- Annoyingly enough, the OpenGL registry doesn't contain any enums for
157+ -- OpenGL 1.0, so let's just use the OpenGL 1.1 ones.
158+ fixedGetTyEnCo :: API -> Version -> ProfileName -> Registry -> ([TypeName ],[Enum' ],[Command ])
159+ fixedGetTyEnCo api version profile registry
160+ | api == API " gl" && version == read " 1.0" = (ts, es11, cs)
161+ | otherwise = tec
162+ where tec@ (ts, _, cs) = getTyEnCo api version profile registry
163+ (_, es11, _) = getTyEnCo api (read " 1.1" ) profile registry
164+
155165getTyEnCo :: API -> Version -> ProfileName -> Registry -> ([TypeName ],[Enum' ],[Command ])
156166getTyEnCo api version profile registry = (ts', es, cs)
157167 where ts = [ n | TypeElement n <- lst ]
@@ -194,10 +204,12 @@ convertEnum e =
194204 , n ++ " = " ++ unEnumValue (enumValue e) ]
195205 where n = unEnumName . enumName $ e
196206
197- showCommand :: Command -> String
198- showCommand c =
207+ showCommand :: API -> Command -> String
208+ showCommand api c =
199209 showString (take 80 (" -- " ++ name ++ " " ++ repeat ' -' ) ++ " \n\n " ) .
200210
211+ showString url .
212+
201213 showString (name ++ " \n " ) .
202214 showString (" :: " ++ signature True ) .
203215 showString (name ++ " = " ++ dyn_name ++ " " ++ ptr_name ++ " \n\n " ) .
@@ -221,6 +233,9 @@ showCommand c =
221233 L. intercalate ((if withComment then " " else " " ) ++ " -> " )
222234 ([showSignatureElement withComment False t | t <- paramTypes c] ++
223235 [showSignatureElement withComment True (resultType c)])
236+ url = maybe " " (\ u -> " -- | Manual page: <" ++ u ++ " >\n " ) $
237+ M. lookup (api, CommandName name) manPageURLs
238+
224239
225240showSignatureElement :: Bool -> Bool -> SignatureElement -> String
226241showSignatureElement withComment isResult sigElem = el ++ comment
0 commit comments