hoppy-generator-0.8.0: C++ FFI generator - Code generator
Safe HaskellNone
LanguageHaskell2010

Foreign.Hoppy.Generator.Hook

Description

Hooks for controlling various parts of generators.

Synopsis

Documentation

data Hooks Source #

These hooks can be used to customize the behaviour of a Hoppy generator.

Constructors

Hooks 

Fields

  • hookEvaluateEnums :: EnumEvaluator

    This hook is invoked once for an interface when the generator needs information about some enums beyond what's been baked into the interface (for example, to compute the enum's numeric type or entry values, see EvaluatedEnumData). This will be called at most once per interface per invocation of the generator.

defaultHooks :: Hooks Source #

The default set of hooks associated with an interface. This sets hookEvaluateEnums to evaluateEnumsWithDefaultCompiler.

Enum evaluation

type EnumEvaluator = EnumEvaluatorArgs -> IO (Maybe EnumEvaluatorResult) Source #

A function that answers with representation information about an enum (e.g. entries' numeric values) for a given request. On success, it returns the requested data. On failure, it prints a message to standard error and returns Nothing.

data EnumEvaluatorArgs Source #

Inputs to the process of automatically evaluting enums.

Constructors

EnumEvaluatorArgs 

Fields

data EnumEvaluatorEntry Source #

An entry in an enumeration. This also tracks whether the entry came from a scoped enum, for assertion reasons.

Constructors

EnumEvaluatorEntry 

Fields

data EnumEvaluatorResult Source #

Raw outputs parsed from the output of an enum evaluator.

Constructors

EnumEvaluatorResult 

Fields

evaluateEnumsWithCompiler :: Compiler a => a -> EnumEvaluator Source #

Evaluate enums using a specified compiler.

evaluateEnumsWithDefaultCompiler :: EnumEvaluator Source #

Calculates enum values using an interface's compiler.

makeCppSourceToEvaluateEnums :: EnumEvaluatorArgs -> ByteString Source #

Constructs the C++ source program to evaluate enums.

interpretOutputToEvaluateEnums :: EnumEvaluatorArgs -> String -> Either String EnumEvaluatorResult Source #

Interprets the output of a program generated by makeCppSourceToEvaluateEnums, returning parsed values if successful, and an error string otherwise.

Internal

pickNumericType :: Int -> Integer -> Integer -> Maybe NumericTypeInfo Source #

Selects the preferred numeric type for holding numeric values in the given range.

internalEvaluateEnumsForInterface :: Interface -> Maybe FilePath -> Bool -> IO (Map ExtName EvaluatedEnumData) Source #

Collects all of the enum values that need calculating in an interface, runs the hook to evaluate them, and stores the result in the interface. This won't recalculate enum data if it's already been calculated.