Skip to content

Commit 9503255

Browse files
committed
Use OpenGL 1.1 tokens for the missing OpenGL 1.0 ones. Show man page URLs.
1 parent 8b062fe commit 9503255

File tree

6 files changed

+3249
-5
lines changed

6 files changed

+3249
-5
lines changed

OpenGLRaw.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ extra-source-files:
3535
RegistryProcessor/Setup.hs
3636
RegistryProcessor/src/DeclarationParser.hs
3737
RegistryProcessor/src/Main.hs
38+
RegistryProcessor/src/ManPages.hs
3839
RegistryProcessor/src/MangledRegistry.hs
3940
RegistryProcessor/src/Registry.hs
4041

RegistryProcessor/RegistryProcessor.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cabal-version: >=1.10
2020

2121
executable RegistryProcessor
2222
main-is: Main.hs
23-
other-modules: MangledRegistry Registry
23+
other-modules: DeclarationParser ManPages MangledRegistry Registry
2424
build-depends: base >= 3 && < 5, containers >= 0.5 && < 0.6, hxt >= 9.3
2525
hs-source-dirs: src
2626
default-language: Haskell2010

RegistryProcessor/src/Main.hs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import qualified Data.Set as S
99
import qualified System.Console.GetOpt as G
1010
import qualified System.Environment as E
1111
import MangledRegistry
12+
import ManPages
1213

1314
data 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

149150
capitalize :: String -> String
150151
capitalize str = C.toUpper (head str) : tail str
151152

152153
separate :: (a -> String) -> [a] -> String
153154
separate 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+
155165
getTyEnCo :: API -> Version -> ProfileName -> Registry -> ([TypeName],[Enum'],[Command])
156166
getTyEnCo 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

225240
showSignatureElement :: Bool -> Bool -> SignatureElement -> String
226241
showSignatureElement withComment isResult sigElem = el ++ comment

0 commit comments

Comments
 (0)