Permalink
Browse files

Adds a simple verification of the interface.

  • Loading branch information...
1 parent 84857a0 commit 3cf34cae4a1b3fd356407bd08c562393b016effc @Laar committed Mar 27, 2013
Showing with 20 additions and 1 deletion.
  1. +1 −1 OpenGLRawgenBase
  2. +18 −0 src/Interface/Module.hs
  3. +1 −0 src/Main.hs
View
@@ -1,10 +1,12 @@
module Interface.Module (
moduleToInterface, writeModuleInterface,
writePackageInterface,
+ verifyInterface,
) where
import Language.Haskell.Exts.Syntax
import Data.List
+import qualified Data.Foldable as F
import qualified Data.Set as S
import Language.OpenGLRaw.Interface.Serialize
@@ -47,3 +49,19 @@ addModulePart p m = case p of
addReExport r = m{modReExports = S.insert r $ modReExports m}
unName (Ident i) = i
unName (Symbol s) = s
+
+verifyInterface :: RawGenIO ()
+verifyInterface = do
+ logMessage "Verifying interface files"
+ iDir <- asksOptions interfaceDir
+ mpack <- liftMaybe "package not readable" =<< liftIO (readPackage iDir)
+ F.mapM_ verifyModule $ rawMods mpack
+
+verifyModule :: ModuleName -> RawGenIO ()
+verifyModule mn = do
+ iDir <- asksOptions interfaceDir
+ _ <- liftMaybe errMsg =<< liftIO (readModule iDir mn)
+ return ()
+ where
+ errMsg = "Module interface parsing failed for: " ++ mName
+ (ModuleName mName) = mn
View
@@ -62,6 +62,7 @@ rmain = do
let lMap'' = cleanupSpec opts lMap'
modules <- liftRawGen $ makeRaw (lMap'', vMap)
outputModules modules
+ verifyInterface
-- | Parse and process the reuse files. It generates no warning if there is
-- no reuse file to parse

0 comments on commit 3cf34ca

Please sign in to comment.