modulo-1.5: Modular C code generator

PortabilityGHC
Stabilityexperimental
Maintainerhans@hanshoglund.se
Safe HaskellNone

Language.Modulo.C

Contents

Description

Renders module descriptions as C header files.

Synopsis

Styles

data GuardStyle Source

Constructors

Pragma

Write pragma guards

Ifndef

Write conditional guards

data ImportStyle Source

Constructors

SystemPath

Import external modules using system paths

LocalPath

Import external modules using local paths

data CStyle Source

Constructors

CStyle 

Fields

guardStyle :: GuardStyle

How to write guards

includeStyle :: ImportStyle

How to write import declarations

includeDirective :: String

Import directive, usually include.

guardMangler :: [String] -> String

Mangler for names of header guards

innerHeader :: [String] -> String -> String

Inner header mangler (components moduleDoc)

innerFooter :: [String] -> String

Inner footer mangler

typePrefixMangler :: [String] -> String

Prefix for types

valuePrefixMangler :: [String] -> String

Prefix for values

typeMangler :: [String] -> String

Mangler for implementation struct names

structFieldMangler :: [String] -> String

Mangler for struct fields

unionFieldMangler :: [String] -> String

Mangler for union fields

enumFieldMangler :: [String] -> String

Mangler for enum fields

constMangler :: [String] -> String

Mangler for constant values

globalMangler :: [String] -> String

Mangler for global variables

funcMangler :: [String] -> String

Mangler for global functions

Instances

Monoid CStyle

Left-biased Monoid instance.

Default CStyle

Default instance using stdStyle.

Semigroup CStyle

Left-biased Semigroup instance.

stdStyle :: CStyleSource

Style used in the C standard library.

  • Types: foo_bar_type_t
  • Functions: foo_bar_func
  • Constants: FOO_BAR_VAL
  • Fields: foo_bar

cairoStyle :: CStyleSource

Style used in Cairo.

  • Types: p_foo_bar_t
  • Opaques: _p_foo_bar_t
  • Functions: p_foo_bar
  • Constants: P_FOO_BAR
  • Fields: foo_bar

gtkStyle :: CStyleSource

Style used in GTK.

  • Types: PFooBar
  • Opaques: _PFooBar
  • Functions: p_foo_bar
  • Constants: P_FOO_BAR
  • Fields: foo_bar

Conversion

Rendering

printModule :: Module -> StringSource

Print a module using the default style.

renderModule :: Module -> (String, CTranslUnit, String)Source

Render a module using the default style.

Returns a C header file, represented as a CTranslUnit with enclosing header and footer strings.

printModuleStyle :: CStyle -> Module -> StringSource

Print a module using the specified style.

renderModuleStyle :: CStyle -> Module -> (String, CTranslUnit, String)Source

Render a module using the specified style.

Returns a C header file, represented as a CTranslUnit with enclosing header and footer strings.

printModuleComm :: Module -> StringSource

Print a module using the default style.