@@ -52,11 +52,10 @@ main = do
52
52
Left msg -> putStrLn msg
53
53
Right registry -> do
54
54
CM. when (PrintFeature `elem` opts) $ do
55
- let modName = " Graphics.Rendering.OpenGL.Raw." ++
56
- capitalize (unProfileName profile) ++
55
+ let relName = capitalize (unProfileName profile) ++
57
56
show (major version) ++ show (minor version)
58
- (ts,es,cs) = fixedReplay api version profile registry
59
- printMod modName ts es cs
57
+ modName = buildModulePath Nothing [relName]
58
+ printMod modName $ fixedReplay api version profile registry
60
59
CM. when (PrintTokens `elem` opts) $ do
61
60
putStrLn " --------------------------------------------------------------------------------"
62
61
putStrLn " -- |"
@@ -126,39 +125,44 @@ main = do
126
125
| ext <- extensions registry
127
126
, api `supports` extensionSupported ext
128
127
, nameAndMods@ (_,(_: _)) <- [nameAndModifications api ext] ]
129
-
130
- let (profileDependent, profileIndependent) =
131
- L. partition (any (DM. isJust . modificationProfile) . snd ) supportedExtensions
132
- putStrLn " ======================================== profile-dependent extensions"
133
- CM. forM_ [" core" , " compatibility" ] $ \ prof -> do
134
- CM. forM_ profileDependent $ \ (n,mods) -> do
135
- let (_vendor, modName) = mangleExtensionName (extendExtensionName n (ProfileName prof))
136
- (ts,es,cs) = executeModifications api (ProfileName prof) registry mods
137
- printMod modName ts es cs
138
-
139
- putStrLn " ======================================== profile-independent extensions"
140
- CM. forM_ profileIndependent $ \ (n,mods) -> do
141
- let (_vendor, modName) = mangleExtensionName n
142
- (ts,es,cs) = executeModifications api profile registry mods
143
- printMod modName ts es cs
144
-
145
- extendExtensionName :: ExtensionName -> ProfileName -> ExtensionName
128
+ CM. forM_ supportedExtensions $ \ (n,mods) -> do
129
+ let profileAndModName =
130
+ if isProfileDependent (n,mods)
131
+ then [(ProfileName p, extendExtensionName n p)
132
+ | p <- [" core" , " compatibility" ] ]
133
+ else [(profile, n)]
134
+ CM. forM_ profileAndModName $ \ (prof, modName) -> do
135
+ printMod (mangleExtensionName modName) $
136
+ executeModifications api prof registry mods
137
+
138
+ isProfileDependent :: (ExtensionName , [Modification ]) -> Bool
139
+ isProfileDependent = any (DM. isJust . modificationProfile) . snd
140
+
141
+ extendExtensionName :: ExtensionName -> String -> ExtensionName
146
142
extendExtensionName n profile =
147
- ExtensionName . (++ (" _" ++ unProfileName profile)). unExtensionName $ n
143
+ ExtensionName . (++ (" _" ++ profile)). unExtensionName $ n
144
+
145
+ mangleExtensionName :: ExtensionName -> String
146
+ mangleExtensionName n = buildModulePath (Just vendor) extWords
147
+ where (" GL" : vendor: extWords) = splitBy (== ' _' ) (unExtensionName n)
148
+
149
+ buildModulePath :: Maybe String -> [String ] -> String
150
+ buildModulePath mbVendor extWords =
151
+ modulePath ++ " ." ++
152
+ maybe " " (\ vendor -> fixVendor vendor ++ " ." ) mbVendor ++
153
+ concat (zipWith fixExtensionWord extWords [0 .. ])
148
154
149
- mangleExtensionName :: ExtensionName -> (String ,String )
150
- mangleExtensionName n = (vendor, modName)
151
- where (" GL" : vendor: rest) = splitBy (== ' _' ) (unExtensionName n)
152
- modName = " Graphics.Rendering.OpenGL.Raw." ++ fixVendor vendor ++ " ." ++ concatMap fixExtensionWord rest
155
+ modulePath :: String
156
+ modulePath = " Graphics.Rendering.OpenGL.Raw"
153
157
154
158
fixVendor :: String -> String
155
159
fixVendor v = case v of
156
160
" 3DFX" -> " ThreeDFX"
157
161
_ -> v
158
162
159
- fixExtensionWord :: String -> String
160
- fixExtensionWord w = case w of
161
- " 422" -> " FourTwoTwo" -- !!!!!!!!!!!!!!!!!!!
163
+ fixExtensionWord :: String -> Int -> String
164
+ fixExtensionWord w pos = case w of
165
+ " 422" | pos == 0 -> " FourTwoTwo"
162
166
" 64bit" -> " 64Bit"
163
167
" ES2" -> " ES2"
164
168
" ES3" -> " ES3"
@@ -182,11 +186,11 @@ fixExtensionWord w = case w of
182
186
" rg" -> " RG"
183
187
" rgb" -> " RGB"
184
188
" rgb10" -> " RGB10"
189
+ " rgb32" -> " RGB32"
185
190
" rgtc" -> " RGTC"
186
191
" s3tc" -> " S3TC"
187
192
" sRGB" -> " SRGB"
188
193
" snorm" -> " SNorm"
189
- " tbuffer" -> " TBuffer"
190
194
" texture3D" -> " Texture3D"
191
195
" texture4D" -> " Texture4D"
192
196
" vdpau" -> " VDPAU"
@@ -212,8 +216,8 @@ capitalize str = C.toUpper (head str) : map C.toLower (tail str)
212
216
separate :: (a -> String ) -> [a ] -> String
213
217
separate f = L. intercalate " ,\n " . map (" " ++ ) . map f
214
218
215
- printMod :: String -> [TypeName ] -> [Enum' ] -> [Command ] -> IO ()
216
- printMod modName ts es cs= do
219
+ printMod :: String -> ( [TypeName ], [Enum' ], [Command ]) -> IO ()
220
+ printMod modName (ts, es, cs) = do
217
221
putStrLn " --------------------------------------------------------------------------------"
218
222
putStrLn " -- |"
219
223
putStrLn $ " -- Module : " ++ modName
@@ -251,7 +255,7 @@ printMod modName ts es cs= do
251
255
-- Annoyingly enough, the OpenGL registry doesn't contain any enums for
252
256
-- OpenGL 1.0, so let's just use the OpenGL 1.1 ones. Furthermore, features
253
257
-- don't explicitly list the types referenced by commands, so we add them.
254
- fixedReplay :: API -> Version -> ProfileName -> Registry -> ([TypeName ],[Enum' ],[Command ])
258
+ fixedReplay :: API -> Version -> ProfileName -> Registry -> ([TypeName ], [Enum' ], [Command ])
255
259
fixedReplay api version profile registry
256
260
| api == API " gl" && version == read " 1.0" = (ts', es11, cs)
257
261
| otherwise = (ts', es, cs)
@@ -261,7 +265,7 @@ fixedReplay api version profile registry
261
265
262
266
-- Here is the heart of the feature construction logic: Chronologically replay
263
267
-- the whole version history for the given API/version/profile triple.
264
- replay :: API -> Version -> ProfileName -> Registry -> ([TypeName ],[Enum' ],[Command ])
268
+ replay :: API -> Version -> ProfileName -> Registry -> ([TypeName ], [Enum' ], [Command ])
265
269
replay api version profile registry =
266
270
executeModifications api profile registry modifications
267
271
where modifications = concatMap modificationsFor history
0 commit comments