Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adds documentation and styling.

  • Loading branch information...
commit 6dccf872375331a65a95658bfed1eb8f7d1291cf 1 parent fd727e9
Lars Corbijn authored

Showing 1 changed file with 29 additions and 0 deletions. Show diff stats Hide diff stats

  1. +29 0 src/Interface/Module.hs
29 src/Interface/Module.hs
... ... @@ -1,9 +1,26 @@
  1 +-----------------------------------------------------------------------------
  2 +--
  3 +-- Module : Interface.Module
  4 +-- Copyright : (c) 2013 Lars Corbijn
  5 +-- License : BSD-style (see the file /LICENSE)
  6 +--
  7 +-- Maintainer :
  8 +-- Stability :
  9 +-- Portability :
  10 +--
  11 +-- | The interface writing part of the generator.
  12 +--
  13 +-----------------------------------------------------------------------------
  14 +
1 15 module Interface.Module (
2 16 moduleToInterface, writeModuleInterface,
3 17 writePackageInterface,
4 18 verifyInterface,
5 19 ) where
6 20
  21 +-----------------------------------------------------------------------------
  22 +
  23 +
7 24 import Control.Monad
8 25 import Language.Haskell.Exts.Syntax
9 26 import Data.List
@@ -17,17 +34,22 @@ import Main.Monad
17 34 import Main.Options
18 35 import Modules.Types
19 36
  37 +-----------------------------------------------------------------------------
  38 +
  39 +-- | Writes the package/index interface file.
20 40 writePackageInterface :: [RawModule] -> RawGenIO ()
21 41 writePackageInterface modus = do
22 42 let inter = OpenGLRawI . S.fromList $ map rawModuleName modus
23 43 path <- asksOptions interfaceDir
24 44 liftIO $ writePackage path inter
25 45
  46 +-- | Writes the interface file for a single `RawModule`.
26 47 writeModuleInterface :: RawModule -> RawGenIO ()
27 48 writeModuleInterface modu = do
28 49 path <- asksOptions interfaceDir
29 50 liftIO . writeModule path $ moduleToInterface modu
30 51
  52 +-- | Converts a single module to its interface representation.
31 53 moduleToInterface :: RawModule -> ModuleI
32 54 moduleToInterface rm =
33 55 let baseModule
@@ -36,6 +58,7 @@ moduleToInterface rm =
36 58 S.empty S.empty S.empty
37 59 in foldl' (flip addModulePart) baseModule $ rawModuleParts rm
38 60
  61 +-- | Adds a `ModulePart` to the interface of a module.
39 62 addModulePart :: ModulePart -> ModuleI -> ModuleI
40 63 addModulePart p m = case p of
41 64 DefineEnum n gln t _ -> addEnum $ EnumI gln (unName n) t
@@ -51,6 +74,9 @@ addModulePart p m = case p of
51 74 unName (Ident i) = i
52 75 unName (Symbol s) = s
53 76
  77 +-----------------------------------------------------------------------------
  78 +
  79 +-- | Performs some simple checks on the interface files.
54 80 verifyInterface :: [RawModule] -> RawGenIO ()
55 81 verifyInterface rmods = do
56 82 let rmodNames = S.fromList $ map rawModuleName rmods
@@ -69,6 +95,7 @@ verifyInterface rmods = do
69 95 where
70 96 unmodName (ModuleName mn) = mn
71 97
  98 +-- | Verification of a single module from the interface.
72 99 verifyModule :: ModuleName -> RawGenIO ()
73 100 verifyModule mn = do
74 101 iDir <- asksOptions interfaceDir
@@ -77,3 +104,5 @@ verifyModule mn = do
77 104 where
78 105 errMsg = "Module interface parsing failed for: " ++ mName
79 106 (ModuleName mName) = mn
  107 +
  108 +-----------------------------------------------------------------------------

0 comments on commit 6dccf87

Please sign in to comment.
Something went wrong with that request. Please try again.