Skip to content

Commit 1029fcc

Browse files
committed
Handle GL_NONE typing confusion. Improved logging.
1 parent 1901c85 commit 1029fcc

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

RegistryProcessor/src/Main.hs

+22-5
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ printGroups api registry = do
136136
es = getGroupEnums api registry g
137137
hRender h $ Comment ""
138138
hRender h $ Comment ("=== #" ++ ugn ++ "# " ++ ugn)
139-
hRender h $ Comment (groupHeader es)
139+
hRender h $ Comment (groupHeader gn es)
140140
hRender h $ Comment ""
141141
-- TODO: Improve the alias computation below. It takes quadratic time and
142142
-- is very naive about what is the canonical name and what is an alias.
@@ -175,16 +175,33 @@ getGroupEnums api registry g =
175175
, api `matches` enumAPI e
176176
]
177177

178-
groupHeader :: [Enum'] -> String
179-
groupHeader es =
180-
case sortUnique (map enumType es)
178+
groupHeader :: GroupName -> [Enum'] -> String
179+
groupHeader gn es =
180+
case sortUnique (map enumTypeWithFix es)
181181
-- There are 2 empty groups: DataType and FfdMaskSGIX.
182182
of
183183
[] -> "There are no values defined for this enumeration group."
184184
[t]
185185
| isMask t -> "A bitwise combination of several of the following values:"
186186
| otherwise -> "One of the following values:"
187-
tys -> error $ "Contradicting enumerant types " ++ show tys
187+
tys ->
188+
error $
189+
"Contradicting enumerant types " ++
190+
L.intercalate " and " (map unTypeName tys) ++
191+
" in group " ++
192+
unGroupName gn ++
193+
":\n" ++
194+
unlines
195+
[ " " ++ unEnumName (enumName e) ++ " :: " ++ unTypeName (enumType e)
196+
| e <- es
197+
]
198+
-- NV_path_rendering screws up typing: It uses GL_NONE as a bitfield, and this
199+
-- leads to a collision in the PathFontStyle group. :-/
200+
where
201+
enumTypeWithFix e
202+
| gn == GroupName "PathFontStyle" && enumName e == EnumName "GL_NONE" =
203+
TypeName "GLbitfield"
204+
| otherwise = enumType e
188205

189206
-- Calulate a map from compact signature to short names.
190207
signatureMap :: Registry -> M.Map String String

0 commit comments

Comments
 (0)