From 3d802132da357708bfab35fcd05b37335d870c68 Mon Sep 17 00:00:00 2001 From: Lars Corbijn Date: Sat, 3 Mar 2012 11:30:29 +0100 Subject: [PATCH 01/12] Use the normal, non compatibility modules. --- Text/OpenGL/Spec.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Text/OpenGL/Spec.hs b/Text/OpenGL/Spec.hs index 83e7e19..0b37d57 100644 --- a/Text/OpenGL/Spec.hs +++ b/Text/OpenGL/Spec.hs @@ -49,9 +49,9 @@ module Text.OpenGL.Spec ( import Numeric (readHex, showHex) import Data.Char (toUpper) import Control.Applicative -import Text.ParserCombinators.Parsec hiding - (many, optional, (<|>), token) - +import Text.Parsec hiding + (many, optional, (<|>), token) +import Text.Parsec.String ---------------------------------------------------------------------- -- From 23202ef5abe1cc1584ec41f537515d5b8e1c2dd4 Mon Sep 17 00:00:00 2001 From: Lars Corbijn Date: Sat, 3 Mar 2012 14:49:50 +0100 Subject: [PATCH 02/12] Changes P to one that doesn't need the TypeSynonyms extension. --- Text/OpenGL/Spec.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Text/OpenGL/Spec.hs b/Text/OpenGL/Spec.hs index 0b37d57..284ddca 100644 --- a/Text/OpenGL/Spec.hs +++ b/Text/OpenGL/Spec.hs @@ -1,4 +1,3 @@ -{-# Language TypeSynonymInstances #-} -- | -- Code to represent and parse the enumext.spec file of the OpenGL -- registry. It works on the revision: 11742 (dated Tue, 15 Jun 2010), @@ -142,7 +141,7 @@ enumLines = parse (many pEnumLine <* eof) "enumLines" enumLine :: String -> Either ParseError EnumLine enumLine = parse pEnumLine "enumLine" -type P a = GenParser Char () a +type P = Parser pEnumLine :: P EnumLine pEnumLine = choice From 9aaf67fef8e2a79534726084c6e18c565064afdc Mon Sep 17 00:00:00 2001 From: Lars Corbijn van Willenswaard Date: Mon, 12 Mar 2012 21:12:01 +0100 Subject: [PATCH 03/12] Adds changes to compile with GHC 7.4.1 --- Text/OpenGL/Spec.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Text/OpenGL/Spec.hs b/Text/OpenGL/Spec.hs index 284ddca..28ea543 100644 --- a/Text/OpenGL/Spec.hs +++ b/Text/OpenGL/Spec.hs @@ -321,7 +321,7 @@ showValue v = case v of Deci i -> show i Identifier x -> x -showHex' :: Integral a => Int -> a -> String +showHex' :: (Show a, Integral a) => Int -> a -> String showHex' l i = replicate (l - length h) '0' ++ h where h = map toUpper (showHex i "") From 030b4ac9e717803e266a55804fc8e5991c4b85a6 Mon Sep 17 00:00:00 2001 From: Lars Corbijn Date: Fri, 24 Aug 2012 16:13:48 +0200 Subject: [PATCH 04/12] Updates the cabal file --- opengl-api.cabal | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/opengl-api.cabal b/opengl-api.cabal index b1624a9..b87173f 100644 --- a/opengl-api.cabal +++ b/opengl-api.cabal @@ -21,9 +21,9 @@ executable opengl-api build-depends: base >= 4 && < 5, parsec >= 3.1 && < 3.2, - cmdargs >= 0.6 && < 0.8 + cmdargs >= 0.6 && < 0.11 - ghc-options: -Wall + ghc-options: -Wall -O2 Library Exposed-modules: Text.OpenGL.Spec, @@ -35,4 +35,4 @@ Library parsec >= 3.1 && < 3.2, containers >= 0.3 && < 0.5 - ghc-options: -Wall + ghc-options: -Wall -O2 From 4a9453cc90353510204ff4906fcdf28c5e00cdab Mon Sep 17 00:00:00 2001 From: Lars Corbijn Date: Fri, 24 Aug 2012 16:43:32 +0200 Subject: [PATCH 05/12] Must have mised one --- Text/OpenGL/ExtHeader.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Text/OpenGL/ExtHeader.hs b/Text/OpenGL/ExtHeader.hs index ca4b5ac..25c28b6 100644 --- a/Text/OpenGL/ExtHeader.hs +++ b/Text/OpenGL/ExtHeader.hs @@ -149,7 +149,7 @@ showValue v = case v of Spec.Deci i -> show i Spec.Identifier x -> x -showHex' :: Integral a => Int -> a -> String +showHex' :: (Show a, Integral a) => Int -> a -> String showHex' l i = replicate (l - length h) '0' ++ h where h = map toUpper (showHex i "") From 895dcabb68a646d933041b013e3ec44eb73fc926 Mon Sep 17 00:00:00 2001 From: Lars Corbijn Date: Tue, 9 Oct 2012 20:39:31 +0200 Subject: [PATCH 06/12] Update the containers dependency --- opengl-api.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opengl-api.cabal b/opengl-api.cabal index b1624a9..c0dab53 100644 --- a/opengl-api.cabal +++ b/opengl-api.cabal @@ -33,6 +33,6 @@ Library Build-depends: base >= 4 && < 5, parsec >= 3.1 && < 3.2, - containers >= 0.3 && < 0.5 + containers >= 0.3 && < 0.6 ghc-options: -Wall From f951f93da250da1ec5e174d7ea63fae161dab8c8 Mon Sep 17 00:00:00 2001 From: Lars Corbijn Date: Sun, 30 Dec 2012 16:14:15 +0100 Subject: [PATCH 07/12] Updates the parser to handle new spec files New in the spec files are - Profiles (only compatibility at the moment) - Returntypes: Float32, Path and UInt64 - Dlflag: prepad --- Text/OpenGL/Api.hs | 8 +++++++ Text/OpenGL/ExtHeader.hs | 4 ++++ Text/OpenGL/GenChecks.hs | 1 + Text/OpenGL/Spec.hs | 51 ++++++++++++++++++++++++++++++++++++---- 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/Text/OpenGL/Api.hs b/Text/OpenGL/Api.hs index 89945ee..64559e1 100644 --- a/Text/OpenGL/Api.hs +++ b/Text/OpenGL/Api.hs @@ -13,6 +13,7 @@ data Function = Function , funName :: String , funParameters :: [Parameter] , funCategory :: Category + , funProfile :: (Maybe Profile) , funOldCategory :: Maybe Category , funSubcategory :: Maybe String , funVersion :: Maybe (Int,Int) @@ -47,6 +48,7 @@ mkFunction a b (Spec.Return r:ps) = , funName = a , funParameters = args , funCategory = c + , funProfile = extractProfile ps'' , funOldCategory = c' , funSubcategory = extractSubcategory ps'' , funVersion = extractFVersion ps'' @@ -114,6 +116,12 @@ extractSubcategory l = case filter isSubcategory l of [Spec.Subcategory s] -> Just s _ -> error "More than one element" +extractProfile :: [Spec.Prop] -> Maybe Profile +extractProfile l = case filter isProfile l of + [] -> Nothing + [Spec.FProfile p] -> Just p + _ -> error "More than one element" + extractFVersion :: [Spec.Prop] -> Maybe (Int, Int) extractFVersion l = case filter isFVersion l of [] -> Nothing diff --git a/Text/OpenGL/ExtHeader.hs b/Text/OpenGL/ExtHeader.hs index 25c28b6..01c7440 100644 --- a/Text/OpenGL/ExtHeader.hs +++ b/Text/OpenGL/ExtHeader.hs @@ -5,6 +5,8 @@ -- of using the one provided by Text.OpenGL.Api). This is necessary as -- the passthru lines get output to the glext.h file (the representation -- used in Text.OpenGL.Api drops those lines). +-- +-- TODO: The profiles are dropped, is this correct module Text.OpenGL.ExtHeader where import Data.List (intersperse, nubBy) @@ -162,9 +164,11 @@ groupEnums xs = go xs go (Spec.Passthru _ : _) = error "encountering a Passthru before a Start" go (Spec.Enum _ _ _ : _) = error "encoutering an Enum before a Start" go (Spec.Use _ _ : _) = error "encoutering a Use before a Start" + go (Spec.Profile _ : _) = error "encountering a Profile before a Start" go [] = [] goS e (Spec.Comment _ : zs) = goS e zs goS e (Spec.BlankLine : zs) = goS e zs + goS e (Spec.Profile _ : zs) = goS e zs goS e (Spec.Start se _ : zs) = e : goS (se, []) zs goS (se, es) (Spec.Passthru str : zs) = goS (se, (es++[EPassthru str])) zs diff --git a/Text/OpenGL/GenChecks.hs b/Text/OpenGL/GenChecks.hs index 08aa866..025f58b 100644 --- a/Text/OpenGL/GenChecks.hs +++ b/Text/OpenGL/GenChecks.hs @@ -130,6 +130,7 @@ cFormat tm (Parameter _ t _ p) = t' GLbyte -> "%d" GLchar -> "%d" GLcharARB -> "%d" + GLcharStarConst -> "%p" GLclampd -> "%f" GLclampf -> "%f" GLdouble -> "%f" diff --git a/Text/OpenGL/Spec.hs b/Text/OpenGL/Spec.hs index 28ea543..c0b2e22 100644 --- a/Text/OpenGL/Spec.hs +++ b/Text/OpenGL/Spec.hs @@ -7,7 +7,7 @@ -- There is also some code to print the result back to something -- close to the original representation, for checking purpose. module Text.OpenGL.Spec ( - EnumLine(..), Category(..), Value(..), Extension(..), + EnumLine(..), Category(..), Value(..), Extension(..), Profile(..), enumLines, enumLine, parseAndShow, reparse, showCategory, pCategory, @@ -27,6 +27,7 @@ module Text.OpenGL.Spec ( isParam, isCategory, isSubcategory, + isProfile, isFVersion, isGlxropcode, isOffset, @@ -74,6 +75,8 @@ data EnumLine = -- ^ A single blanck line. | Start Category (Maybe String) -- ^ The beginning of an enumeration. + | Profile Profile + -- ^ The signal for a new profile | Passthru String -- ^ A passthru line with its comment. | Enum String Value (Maybe String) @@ -98,6 +101,10 @@ data Value = Hex Integer Int (Maybe HexSuffix) | Deci Int | Identifier String data HexSuffix = U | Ull deriving (Eq, Show) +data Profile + = Compatibility + deriving (Eq, Show) + -- Note: what for FfdMaskSGIX? This will be a Name. -- | The different kinds of extension used to start an enumeration. data Extension = @@ -150,6 +157,7 @@ pEnumLine = choice , try pStart , try pPassthru , try pEnum + , try pProfile , pUse ] @@ -221,6 +229,14 @@ pEnum = Enum <$> (char '=' *> blanks *> value) <*> (optional $ blanks *> char '#' *> blanks *> many1 (noneOf "\n")) <* eol +pProfile :: P EnumLine +pProfile = Profile <$> + (token "profile:" *> blanks *> pProfileVal <* eol) + +pProfileVal :: P Profile +pProfileVal = + Compatibility <$ string "compatibility" + pUse :: P EnumLine pUse = Use <$> (blanks1 *> token "use" *> pCategory <* blanks1) <*> @@ -300,8 +316,13 @@ showEnumLine el = case el of Passthru x -> "passthru: /* " ++ x ++ "*/" Enum a b Nothing -> "\t" ++ a ++ tabstop 55 a ++ "= " ++ showValue b Enum a b (Just x) -> "\t" ++ a ++ tabstop 55 a ++ "= " ++ showValue b ++ " # " ++ x + Profile p -> "profile: " ++ showProfile p Use a b -> "\tuse " ++ showCategory a ++ tabstop 39 (showCategory a ++ " ") ++ " " ++ b +showProfile :: Profile -> String +showProfile p = case p of + Compatibility -> "compatibility" + tabstop :: Int -> String -> String tabstop t a = replicate ((t - length a) `div` 8) '\t' @@ -371,6 +392,7 @@ data TmType = | GLbyte | GLchar | GLcharARB + | GLcharStarConst | GLclampd | GLclampf | GLdouble @@ -437,6 +459,7 @@ pTmType = choice $ map try , ConstGLubyte <$ token "const GLubyte" , UnderscoreGLfuncptr <$ token "_GLfuncptr" , GLvoidStarConst <$ token "GLvoid* const" + , GLcharStarConst <$ token "GLchar* const" , GLboolean <$ token "GLboolean" , GLcharARB <$ token "GLcharARB" , GLchar <$ token "GLchar" @@ -495,6 +518,8 @@ data Property = -- ^ Could have been hardcoded too. | DeprecatedProp [(Int,Int)] -- ^ Could have been hardcoded too. Only 3.1 for now. + | ProfileProp [Profile] + -- ^ only compatibility for now. | GlxsingleProp -- ^ Hardcoded counter part: * | GlxropcodeProp @@ -530,6 +555,7 @@ data Prop = -- ^ This pairs the name of a parameter with its type. | Category Category (Maybe Category) -- ^ The Maybe is a commented old value. + | FProfile Profile | Subcategory String | FVersion Int Int | Glxropcode Question @@ -562,14 +588,17 @@ data ReturnType = Boolean | BufferOffset | ErrorCode + | Float32 | FramebufferStatus | GLEnum | HandleARB | Int32 | List + | Path | String | Sync | UInt32 + | UInt64 | Void | VoidPointer | VdpauSurfaceNV @@ -598,7 +627,7 @@ data Wglflag = WglClientHandcode | WglServerHandcode | WglSmallData | WglBatchable deriving (Eq, Show) -data Dlflag = DlNotlistable | DlHandcode +data Dlflag = DlNotlistable | DlHandcode | DlPrepad deriving (Eq, Show) data Glxflag = @@ -662,7 +691,7 @@ pProperty = Property <$> choice (map try [ RequiredProps <$ string "required-props:" , ParamProp <$ (token "param:" *> token "retval" *> string "retained") , DlflagsProp <$ (token "dlflags:" *> token "notlistable" *> - string "handcode") + string "handcode" *> optional (blanks *> string "prepad")) , GlxflagsProp <$ (token "glxflags:" *> token "client-intercept" *> token "client-handcode" *> token "server-handcode" *> token "EXT" *> token "SGI" *> @@ -671,6 +700,7 @@ pProperty = Property <$> choice (map try , CategoryProp <$> (token "category:" *> many (pCategory <* blanks)) , VersionProp <$> (token "version:" *> many (version <* blanks)) , DeprecatedProp <$> (token "deprecated:" *> many (version <* blanks)) + , ProfileProp <$> (token "profile:" *> many (pProfileVal <* blanks)) , GlxsingleProp <$ (token "glxsingle:" *> string "*") , GlxropcodeProp <$ (token "glxropcode:" *> string "*") , GlxvendorprivProp <$ (token "glxvendorpriv:" *> string "*") @@ -701,6 +731,7 @@ pProp = Prop <$> choice [ try pReturn , try pParam , try pCategory' + , try pFProfile , try pVersion , try pGlxropcode , try pOffset @@ -731,14 +762,17 @@ pReturnType = choice [ try $ Boolean <$ string "Boolean" , BufferOffset <$ string "BufferOffset" , ErrorCode <$ string "ErrorCode" + , try $ Float32 <$ string "Float32" , FramebufferStatus <$ string "FramebufferStatus" , GLEnum <$ string "GLenum" , HandleARB <$ string "handleARB" , Int32 <$ string "Int32" , List <$ string "List" + , Path <$ string "Path" , try $ String <$ string "String" , Sync <$ string "sync" - , UInt32 <$ string "UInt32" + , try $ UInt32 <$ string "UInt32" + , try $ UInt64 <$ string "UInt64" , try $ Void <$ string "void" , VoidPointer <$ string "VoidPointer" , VdpauSurfaceNV <$ string "vdpauSurfaceNV" @@ -775,6 +809,10 @@ pCategory' = Category <$> (optional $ token "# old:" *> pCategory) <* eol +pFProfile :: P Prop +pFProfile = FProfile <$> + (field "profile" *> pProfileVal) <* eol + pVersion :: P Prop pVersion = FVersion <$> (field "version" *> digit' <* char '.') <*> digit' <* eol @@ -803,6 +841,7 @@ pDlflag :: P Dlflag pDlflag = choice [ DlNotlistable <$ string "notlistable" , DlHandcode <$ string "handcode" + , DlPrepad <$ string "prepad" ] pGlxflags :: P Prop @@ -899,6 +938,10 @@ isSubcategory :: Prop -> Bool isSubcategory (Subcategory _) = True isSubcategory _ = False +isProfile :: Prop -> Bool +isProfile (FProfile _) = True +isProfile _ = False + isFVersion :: Prop -> Bool isFVersion (FVersion _ _) = True isFVersion _ = False From c08389a6865ff16f18e14aa3b3c8662f8a03527a Mon Sep 17 00:00:00 2001 From: Lars Corbijn Date: Sun, 30 Dec 2012 17:11:16 +0100 Subject: [PATCH 08/12] Adds the KHR extension --- Text/OpenGL/Spec.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Text/OpenGL/Spec.hs b/Text/OpenGL/Spec.hs index c0b2e22..77d230f 100644 --- a/Text/OpenGL/Spec.hs +++ b/Text/OpenGL/Spec.hs @@ -119,6 +119,7 @@ data Extension = | IBM | INGR | INTEL + | KHR | MESA | MESAX | NV @@ -269,6 +270,7 @@ pExt = choice $ map (fmap r . try . string) , "IBM" , "INGR" , "INTEL" + , "KHR" , "MESAX" , "MESA" , "NV" From daf57e92db97f375d27cef554fca470f5be13ce9 Mon Sep 17 00:00:00 2001 From: Lars Corbijn Date: Mon, 31 Dec 2012 16:37:46 +0100 Subject: [PATCH 09/12] Even more additions for the new spec files. --- Text/OpenGL/Api.hs | 18 ++++++++++++------ Text/OpenGL/GenChecks.hs | 1 + Text/OpenGL/Spec.hs | 2 ++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Text/OpenGL/Api.hs b/Text/OpenGL/Api.hs index 64559e1..400085c 100644 --- a/Text/OpenGL/Api.hs +++ b/Text/OpenGL/Api.hs @@ -1,6 +1,6 @@ module Text.OpenGL.Api where -import Data.List (partition) +import Data.List (partition, find) import qualified Data.Map as M import qualified Text.OpenGL.Spec as Spec @@ -75,11 +75,17 @@ mkFunction a b (Spec.Return r:ps) = f _ = False h (Spec.Category _ _) = True h _ = False - args = zipWith g b params - g x0 (Spec.Param x1 (Spec.ParamType x y z)) - | x0 == x1 = Parameter x0 x y z - | otherwise = error "argument and parameter don't match" - g _ _ = error "can't happen" + args = map (lookupParam params) b + lookupParam pars arg = + case find (\(Spec.Param x1 _) -> x1 == arg) pars of + Just (Spec.Param _ (Spec.ParamType x y z)) -> Parameter arg x y z + Nothing -> error $ "opengl-api -> mkFunction: parameter not found " ++ arg ++ " for function " ++ a + Just _ -> error "opengl-api -> mkFunction: impossible" +-- args = zipWith g b params +-- g x0 (Spec.Param x1 (Spec.ParamType x y z)) +-- | x0 == x1 = Parameter x0 x y z +-- | otherwise = error "argument and parameter don't match" +-- g _ _ = error "can't happen" mkFunction _ _ _ = error "The list of properties doesn't begin with the return type." diff --git a/Text/OpenGL/GenChecks.hs b/Text/OpenGL/GenChecks.hs index 025f58b..69f692a 100644 --- a/Text/OpenGL/GenChecks.hs +++ b/Text/OpenGL/GenChecks.hs @@ -162,6 +162,7 @@ cFormat tm (Parameter _ t _ p) = t' UnderscoreGLfuncptr -> "%p" GLvoidStarConst -> "%p" GLvdpauSurfaceNV -> "%td" -- typedef GLintptr GLvdpauSurfaceNV; + GLdebugproc -> "GLDEBUGPROC" GLdebugprocAMD -> "GLDEBUGPROCAMD" GLdebugprocARB -> "GLDEBUGPROCARB" diff --git a/Text/OpenGL/Spec.hs b/Text/OpenGL/Spec.hs index 77d230f..71702df 100644 --- a/Text/OpenGL/Spec.hs +++ b/Text/OpenGL/Spec.hs @@ -426,6 +426,7 @@ data TmType = | GLvoid | GLvoidStarConst | GLvdpauSurfaceNV + | GLdebugproc | GLdebugprocAMD | GLdebugprocARB deriving (Eq, Read, Show) @@ -474,6 +475,7 @@ pTmType = choice $ map try , GLvdpauSurfaceNV <$ token "GLvdpauSurfaceNV" , GLdebugprocAMD <$ token "GLDEBUGPROCAMD" , GLdebugprocARB <$ token "GLDEBUGPROCARB" + , GLdebugproc <$ token "GLDEBUGPROC" , read <$> identifier ] From 5a94f0e6f2c56e31e3f6ddf2362dfcc9d0168e69 Mon Sep 17 00:00:00 2001 From: Lars Corbijn Date: Thu, 21 Feb 2013 11:32:23 +0100 Subject: [PATCH 10/12] Add travis build config --- .travis.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..999bd37 --- /dev/null +++ b/.travis.yml @@ -0,0 +1 @@ +language: haskell From 841d688856f3e8d399cac7f0c8f9d926df90efef Mon Sep 17 00:00:00 2001 From: Lars Corbijn Date: Thu, 21 Feb 2013 11:41:26 +0100 Subject: [PATCH 11/12] Adds travis build image --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 542bcb1..9f13889 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Build Status](https://travis-ci.org/Laar/opengl-api.png)](https://travis-ci.org/Laar/opengl-api) # opengl-api Represent and parse spec files from the OpenGL [registry][]. From 7e2165f91b0ca91046585d1816811ca4fbc391db Mon Sep 17 00:00:00 2001 From: Lars Corbijn Date: Thu, 21 Feb 2013 12:23:30 +0100 Subject: [PATCH 12/12] Adds a gitignore --- .gitignore | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0a93c25 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +*.[oa] +*.hi +dist/ +Setup.* +Setup +!Setup.hs +*~ +*.swp +cabal-dev