bond-0.4.0.1: Bond schema compiler and code generator

Copyright(c) Microsoft
LicenseMIT
Maintaineradamsap@microsoft.com
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Language.Bond.Codegen.Templates

Contents

Description

The module exports the built-in code generation templates.

Synopsis

Templates

All codegen templates take at least the following arguments:

  • MappingContext which determines mapping of Bond types to types in the target language
  • base file name, typically the name of the schema definition file without the extension
  • list of Imports from the parsed schema definition
  • list of Declarations from the parsed schema definition

Some templates are parameterized with additional options for customizing the generated code.

The templates return the name suffix for the target file and lazy Text with the generated code.

C++

types_h Source

Arguments

:: [String]

list of optional header files to be #include'ed by the generated code

-> Bool

True to generate enum definitions into a separate file base_name_enum.h

-> Maybe String

optional custom allocator to be used in the generated code

-> MappingContext 
-> String 
-> [Import] 
-> [Declaration] 
-> (String, Text) 

Codegen template for generating base_name_type.h containing definitions of C++ types representing the schema.

types_cpp :: MappingContext -> String -> [Import] -> [Declaration] -> (String, Text) Source

Codegen template for generating base_name_type.cpp containing definitions of helper functions and schema metadata static variables.

reflection_h :: MappingContext -> String -> [Import] -> [Declaration] -> (String, Text) Source

Codegen template for generating base_name_reflection.h containing schema metadata definitions.

enum_h :: MappingContext -> String -> [Import] -> [Declaration] -> (String, Text) Source

Codegen template for generating base_name_enum.h containing definitions of enums. Generated by gbc with --enum-header flag.

apply_h Source

Arguments

:: [Protocol]

List of protocols for which Apply overloads should be generated

-> Maybe String

Optional attribute to decorate the Apply function declarations

-> MappingContext 
-> String 
-> [Import] 
-> [Declaration] 
-> (String, Text) 

Codegen template for generating base_name_apply.h containing declarations of Apply function overloads for the specified protocols.

apply_cpp Source

Arguments

:: [Protocol]

List of protocols for which Apply overloads should be generated

-> MappingContext 
-> String 
-> [Import] 
-> [Declaration] 
-> (String, Text) 

Codegen template for generating base_name_apply.cpp containing definitions of the Apply function overloads for the specified protocols.

data Protocol Source

Protocol data type is used to specify what protocols the Apply function overloads should be generated for.

Constructors

Protocol 

Fields

protocolReader :: String

Name of the class implementing the protocol reader.

protocolWriter :: String

Name of the class implementing the protocol writer.

C#

data FieldMapping Source

Representation of schema fields in the generated C# types

Constructors

PublicFields

public fields

Properties

auto-properties

ReadOnlyProperties

auto-properties with private setter

Instances

data StructMapping Source

C# representation of schema structs

Constructors

Class

public partial class

Instances

types_cs Source

Arguments

:: StructMapping

Specifies how to represent schema structs

-> FieldMapping

Specifies how to represent schema fields

-> MappingContext 
-> String 
-> [Import] 
-> [Declaration] 
-> (String, Text) 

Codegen template for generating definitions of C# types representing the schema.