bond-0.10.1.0: 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_types.cpp containing definitions of helper functions and schema metadata static variables.

reflection_h :: Maybe String -> 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

ProtocolReader String

Name of the class implementing the protocol reader.

ProtocolWriter String

Name of the class implementing the protocol writer.

C++ Comm

comm_h :: Maybe String -> MappingContext -> String -> [Import] -> [Declaration] -> (String, Text) Source #

Codegen template for generating base_name_comm.h containing declarations of of service interface and proxy.

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

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

grpc_h :: Maybe String -> MappingContext -> String -> [Import] -> [Declaration] -> (String, Text) Source #

Codegen template for generating base_name_grpc.h containing declarations of of service interface and proxy.

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

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

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

data StructMapping Source #

C# representation of schema structs

Constructors

Class

public partial class

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.

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

Codegen template for generating code containing declarations of of services including interfaces, proxies and services files.

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

Codegen template for generating code containing declarations of of services including proxies and services files for gRPC integration.