fidlgen_cpp

package
v0.0.0-...-bbc9ce3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2021 License: BSD-2-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Protocol related
	WireSyncClient            = fidlNs.member("WireSyncClient")
	WireClient                = fidlNs.member("WireClient")
	WireEventHandlerInterface = internalNs.member("WireEventHandlerInterface")
	WireSyncEventHandler      = fidlNs.member("WireSyncEventHandler")
	WireAsyncEventHandler     = fidlNs.member("WireAsyncEventHandler")
	WireServer                = fidlNs.member("WireServer")
	WireEventSender           = fidlNs.member("WireEventSender")
	WireWeakEventSender       = internalNs.member("WireWeakEventSender")
	WireClientImpl            = internalNs.member("WireClientImpl")
	WireSyncClientImpl        = internalNs.member("WireSyncClientImpl")
	WireSyncBufferClientImpl  = internalNs.member("WireSyncBufferClientImpl")
	WireServerDispatcher      = internalNs.member("WireServerDispatcher")

	// Method related
	WireRequest         = fidlNs.member("WireRequest")
	WireResponse        = fidlNs.member("WireResponse")
	WireResult          = fidlNs.member("WireResult")
	WireUnownedResult   = fidlNs.member("WireUnownedResult")
	WireResponseContext = fidlNs.member("WireResponseContext")
	WireCompleter       = internalNs.member("WireCompleter")
	WireCompleterBase   = internalNs.member("WireCompleterBase")
	WireMethodTypes     = internalNs.member("WireMethodTypes")
	WireRequestView     = internalNs.member("WireRequestView")
)

These correspond to templated classes forward-declared in //zircon/system/ulib/fidl/include/lib/fidl/llcpp/wire_messaging.h

View Source
var (
	DesignatedInitializationProxy = internalNs.member("DesignatedInitializationProxy")
	TypeTraits                    = internalNs.member("TypeTraits")
)

These correspond to templated classes forward-declared in //src/lib/fidl/include/lib/fidl/cpp/internal/natural_types.h

View Source
var FamilyKinds = namespacedEnum(familyKinds{}).(familyKinds)

FamilyKinds are general categories identifying what operation we should use to pass a value without a move (LLCPP). It also defines the way we should initialize a field.

View Source
var Kinds = namespacedEnum(declKinds{}).(declKinds)

Kinds are the different kinds of FIDL declarations. They are used in header/impl templates to select the correct decl-specific template.

View Source
var TypeKinds = namespacedEnum(typeKinds{}).(typeKinds)

TypeKinds are the kinds of C++ types (arrays, primitives, structs, ...).

View Source
var (
	WireTableFrame = fidlNs.member("WireTableFrame")
)

These correspond to templated classes forward-declared in //zircon/system/ulib/fidl/include/lib/fidl/llcpp/wire_types.h

Functions

func NameVariantsForPrimitive

func NameVariantsForPrimitive(val fidlgen.PrimitiveSubtype) nameVariants

NameVariantsForPrimitive returns the C++ name of a FIDL primitive type.

Types

type Attributes

type Attributes struct {
	fidlgen.Attributes
}

func (Attributes) Docs

func (a Attributes) Docs() string

Docs returns C++ documentation comments.

type Bits

type Bits struct {
	Attributes
	fidlgen.Strictness

	Type     nameVariants
	Mask     string
	MaskName nameVariants
	Members  []BitsMember
	// contains filtered or unexported fields
}

func (*Bits) Kind

func (*Bits) Kind() declKind

func (Bits) Name

func (dn Bits) Name() string

func (Bits) Namespace

func (dn Bits) Namespace() namespace

func (Bits) NoLeading

func (dn Bits) NoLeading() string

func (Bits) Self

func (dn Bits) Self() string

func (Bits) String

func (dn Bits) String() string

type BitsMember

type BitsMember struct {
	Attributes

	Value ConstantValue
	// contains filtered or unexported fields
}

func (BitsMember) Name

func (dn BitsMember) Name() string

func (BitsMember) Namespace

func (dn BitsMember) Namespace() namespace

func (BitsMember) NoLeading

func (dn BitsMember) NoLeading() string

func (BitsMember) Self

func (dn BitsMember) Self() string

func (BitsMember) String

func (dn BitsMember) String() string

type CmdlineFlags

type CmdlineFlags struct {
	// contains filtered or unexported fields
}

CmdlineFlags are the common command-line flags for all C++ backends.

func NewCmdlineFlags

func NewCmdlineFlags(name string, validExperiments []string) *CmdlineFlags

NewCmdlineFlags returns a new instance of CmdlineFlags, which holds the values for flags passed on the command-line to a C++ generating fidlgen. |name| is the name of the binding used in @bindings_denylist and elsewhere. |validExperiments| is a list of experiment names that are supported.

func (*CmdlineFlags) ExperimentEnabled

func (c *CmdlineFlags) ExperimentEnabled(experiment string) bool

func (*CmdlineFlags) ParseAndLoadIR

func (c *CmdlineFlags) ParseAndLoadIR() *Root

type Const

type Const struct {
	Attributes

	Extern    bool
	Decorator string
	Type      Type
	Value     ConstantValue
	// contains filtered or unexported fields
}

func (*Const) Kind

func (*Const) Kind() declKind

func (Const) Name

func (dn Const) Name() string

func (Const) Namespace

func (dn Const) Namespace() namespace

func (Const) NoLeading

func (dn Const) NoLeading() string

func (Const) Self

func (dn Const) Self() string

func (Const) String

func (dn Const) String() string

type ConstantValue

type ConstantValue struct {
	HLCPP string
	Wire  string
}

func (ConstantValue) IsSet

func (cv ConstantValue) IsSet() bool

func (ConstantValue) String

func (cv ConstantValue) String() string

type Enum

type Enum struct {
	Attributes
	fidlgen.Strictness

	Enum    fidlgen.Enum
	Type    nameVariants
	Members []EnumMember
	// contains filtered or unexported fields
}

func (*Enum) Kind

func (*Enum) Kind() declKind

func (Enum) Name

func (dn Enum) Name() string

func (Enum) Namespace

func (dn Enum) Namespace() namespace

func (Enum) NoLeading

func (dn Enum) NoLeading() string

func (Enum) Self

func (dn Enum) Self() string

func (Enum) String

func (dn Enum) String() string

func (Enum) UnknownValueForTmpl

func (e Enum) UnknownValueForTmpl() interface{}

type EnumMember

type EnumMember struct {
	Attributes

	Value      ConstantValue
	EnumMember fidlgen.EnumMember
	// contains filtered or unexported fields
}

func (EnumMember) IsUnknown

func (m EnumMember) IsUnknown() bool

func (EnumMember) Name

func (dn EnumMember) Name() string

func (EnumMember) Namespace

func (dn EnumMember) Namespace() namespace

func (EnumMember) NoLeading

func (dn EnumMember) NoLeading() string

func (EnumMember) Self

func (dn EnumMember) Self() string

func (EnumMember) String

func (dn EnumMember) String() string

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator(flags *CmdlineFlags, templates fs.FS, extraFuncs template.FuncMap) *Generator

func (*Generator) ExperimentEnabled

func (gen *Generator) ExperimentEnabled(experiment string) bool

func (*Generator) GenerateFiles

func (gen *Generator) GenerateFiles(tree *Root, files []string)

type HandleInformation

type HandleInformation struct {
	ObjectType string
	Rights     string
}

type Kinded

type Kinded interface {
	Kind() declKind
}

A Kinded value is a declaration in FIDL, for which we would like to generate some corresponding C++ code.

type Member

type Member interface {
	NameAndType() (string, Type)
}

type Method

type Method struct {
	OrdinalName         nameVariants
	Request             message
	Response            message
	CallbackType        *nameVariants
	ResponseHandlerType string
	ResponderType       string
	// Protocol is a reference to the containing protocol, for the
	// convenience of golang templates.
	Protocol *Protocol
	// contains filtered or unexported fields
}

Method should be created using newMethod.

func (*Method) CallbackWrapper

func (m *Method) CallbackWrapper() string

func (Method) CtsMethodAnnotation

func (m Method) CtsMethodAnnotation() string

CtsMethodAnnotation generates a comment containing information about the FIDL method that is covered by the C++ generated method. It is primarily meant to be parsed by machines, but can serve as human readable documentation too. For more information see fxbug.dev/84332.

func (Method) WireCompleterArg

func (m Method) WireCompleterArg() string

func (Method) WireRequestViewArg

func (m Method) WireRequestViewArg() string

type Parameter

type Parameter struct {
	Type              Type
	OffsetV1          int
	OffsetV2          int
	HandleInformation *HandleInformation
	// contains filtered or unexported fields
}

func (Parameter) Name

func (dn Parameter) Name() string

func (Parameter) NameAndType

func (p Parameter) NameAndType() (string, Type)

func (Parameter) Namespace

func (dn Parameter) Namespace() namespace

func (Parameter) NoLeading

func (dn Parameter) NoLeading() string

func (Parameter) Self

func (dn Parameter) Self() string

func (Parameter) String

func (dn Parameter) String() string

type Protocol

type Protocol struct {

	// OneWayMethods contains the list of one-way (i.e. fire-and-forget) methods
	// in the protocol.
	OneWayMethods []*Method

	// TwoWayMethods contains the list of two-way (i.e. has both request and
	// response) methods in the protocol.
	TwoWayMethods []*Method

	// ClientMethods contains the list of client-initiated methods (i.e. any
	// interaction that is not an event). It is the union of one-way and two-way
	// methods.
	ClientMethods []*Method

	// Events contains the list of events (i.e. initiated by servers)
	// in the protocol.
	Events []*Method

	// Generated struct holding variant-agnostic details about protocol.
	ProtocolDetails name
	// contains filtered or unexported fields
}

Protocol should be created using newProtocol.

func (Protocol) HLCPPType

func (p Protocol) HLCPPType() string

func (*Protocol) Kind

func (*Protocol) Kind() declKind

func (Protocol) WireType

func (p Protocol) WireType() string

func (Protocol) WithHlMessaging

func (p Protocol) WithHlMessaging() protocolWithHlMessaging

WithHlMessaging returns a new protocol IR where the HLCPP bindings details are promoted to the same naming scope as the protocol. This makes it easier to access the HLCPP details in golang templates.

type Result

type Result struct {
	ValueMembers    []Parameter
	ResultDecl      nameVariants
	ErrorDecl       nameVariants
	Error           Type
	ValueDecl       name
	ValueStructDecl nameVariants
	ValueTupleDecl  name
	Value           Type
}

Result holds information about error results on methods.

func (Result) ValueArity

func (r Result) ValueArity() int

type Root

type Root struct {
	HandleTypes  []string
	Library      fidlgen.LibraryIdentifier
	Decls        []Kinded
	Dependencies []fidlgen.LibraryIdentifier
}

func (*Root) Bits

func (r *Root) Bits() []Kinded

func (*Root) Consts

func (r *Root) Consts() []Kinded

func (*Root) Enums

func (r *Root) Enums() []Kinded

func (*Root) LegacyIncludeDir

func (r *Root) LegacyIncludeDir() string

func (*Root) Namespace

func (r *Root) Namespace() namespace

Namespace returns the C++ namespace for generated protocol types this FIDL library.

func (*Root) Protocols

func (r *Root) Protocols() []Kinded

func (*Root) ProtocolsForTransport

func (r *Root) ProtocolsForTransport() func(string) []*Protocol

func (*Root) Services

func (r *Root) Services() []Kinded

func (*Root) SingleComponentLibraryName

func (r *Root) SingleComponentLibraryName() bool

SingleComponentLibraryName returns if the FIDL library name only consists of a single identifier (e.g. "library foo;"). This is significant because the unified namespace and the natural namespace are identical when the library only has one component.

func (*Root) Structs

func (r *Root) Structs() []Kinded

func (*Root) Tables

func (r *Root) Tables() []Kinded

func (*Root) UnifiedIncludeDir

func (r *Root) UnifiedIncludeDir() string

func (*Root) Unions

func (r *Root) Unions() []Kinded

type ScopedLayout

type ScopedLayout struct {
	// contains filtered or unexported fields
}

ScopedLayout represents the definition of a scoped name for an anonymous layout. It consists of the scoped name (defined within the parent layout), and the flattened name (defined at the top level)

func (ScopedLayout) FlattenedName

func (s ScopedLayout) FlattenedName() string

func (ScopedLayout) ScopedName

func (s ScopedLayout) ScopedName() string

type Service

type Service struct {
	Attributes

	ServiceName string
	Members     []ServiceMember
	// contains filtered or unexported fields
}

func (*Service) Kind

func (*Service) Kind() declKind

func (Service) Name

func (dn Service) Name() string

func (Service) Namespace

func (dn Service) Namespace() namespace

func (Service) NoLeading

func (dn Service) NoLeading() string

func (Service) Self

func (dn Service) Self() string

func (Service) String

func (dn Service) String() string

type ServiceMember

type ServiceMember struct {
	Attributes

	ProtocolType nameVariants
	// contains filtered or unexported fields
}

func (ServiceMember) Name

func (dn ServiceMember) Name() string

func (ServiceMember) Namespace

func (dn ServiceMember) Namespace() namespace

func (ServiceMember) NoLeading

func (dn ServiceMember) NoLeading() string

func (ServiceMember) Self

func (dn ServiceMember) Self() string

func (ServiceMember) String

func (dn ServiceMember) String() string

type Struct

type Struct struct {
	Attributes
	fidlgen.Resourceness

	AnonymousChildren   []ScopedLayout
	CodingTableType     string
	Members             []StructMember
	BackingBufferTypeV1 string
	BackingBufferTypeV2 string
	Result              *Result
	// Full decls needed to check if a type is memcpy compatible.
	// Only set if it may be possible for a type to be memcpy compatible,
	// e.g. has no padding.
	// See the struct template for usage.
	FullDeclMemcpyCompatibleDeps []string

	TypeShapeV1 TypeShape
	TypeShapeV2 TypeShape

	// DesignatedInitializationProxy is the name of the internal aggregate
	// type associated with this struct in natural domain objects,
	// to support designated initialization.
	DesignatedInitializationProxy name

	// TypeTraits contains information about a natural domain object.
	TypeTraits name
	// contains filtered or unexported fields
}

func (*Struct) IsRequestOrResponse

func (s *Struct) IsRequestOrResponse() bool

IsRequestOrResponse indicates whether this struct is used as a method request/response.

func (*Struct) Kind

func (*Struct) Kind() declKind

func (Struct) Name

func (dn Struct) Name() string

func (Struct) Namespace

func (dn Struct) Namespace() namespace

func (Struct) NoLeading

func (dn Struct) NoLeading() string

func (Struct) Self

func (dn Struct) Self() string

func (Struct) String

func (dn Struct) String() string

type StructMember

type StructMember struct {
	Attributes

	Type              Type
	DefaultValue      ConstantValue
	OffsetV1          int
	OffsetV2          int
	HandleInformation *HandleInformation
	// contains filtered or unexported fields
}

func (StructMember) AsParameter

func (m StructMember) AsParameter() Parameter

func (StructMember) Name

func (dn StructMember) Name() string

func (StructMember) NameAndType

func (sm StructMember) NameAndType() (string, Type)

func (StructMember) Namespace

func (dn StructMember) Namespace() namespace

func (StructMember) NoLeading

func (dn StructMember) NoLeading() string

func (StructMember) Self

func (dn StructMember) Self() string

func (StructMember) String

func (dn StructMember) String() string

type Table

type Table struct {
	Attributes
	fidlgen.Resourceness

	AnonymousChildren   []ScopedLayout
	CodingTableType     string
	Members             []TableMember
	BiggestOrdinal      int
	BackingBufferTypeV1 string
	BackingBufferTypeV2 string
	TypeShapeV1         TypeShape
	TypeShapeV2         TypeShape

	// WireTableFrame is the name of the table frame type associated with
	// this table in wire domain objects.
	WireTableFrame name
	// FrameItems stores the members in ordinal order; "null" for reserved.
	FrameItems []TableFrameItem
	// contains filtered or unexported fields
}

func (*Table) Kind

func (*Table) Kind() declKind

func (Table) Name

func (dn Table) Name() string

func (Table) Namespace

func (dn Table) Namespace() namespace

func (Table) NoLeading

func (dn Table) NoLeading() string

func (Table) Self

func (dn Table) Self() string

func (Table) String

func (dn Table) String() string

type TableFrameItem

type TableFrameItem *TableMember

type TableMember

type TableMember struct {
	Attributes

	Type               Type
	DefaultValue       ConstantValue
	Ordinal            int
	FieldPresenceIsSet string
	FieldPresenceSet   string
	FieldPresenceClear string
	FieldDataName      string
	MethodHasName      string
	MethodClearName    string
	ValueUnionName     string
	HandleInformation  *HandleInformation
	// contains filtered or unexported fields
}

func (TableMember) Name

func (dn TableMember) Name() string

func (TableMember) NameAndType

func (tm TableMember) NameAndType() (string, Type)

func (TableMember) Namespace

func (dn TableMember) Namespace() namespace

func (TableMember) NoLeading

func (dn TableMember) NoLeading() string

func (TableMember) Self

func (dn TableMember) Self() string

func (TableMember) String

func (dn TableMember) String() string

type Type

type Type struct {
	WirePointer bool

	// Defines what operation we should use to pass a value without a move (LLCPP). It also
	// defines the way we should initialize a field.
	WireFamily familyKind

	// NeedsDtor indicates whether this type needs to be destructed explicitely
	// or not.
	NeedsDtor bool

	Kind typeKind

	IsResource bool
	Nullable   bool

	DeclarationName fidlgen.EncodedCompoundIdentifier

	// Set iff IsArray || IsVector
	ElementType *Type
	// Valid iff IsArray
	ElementCount int

	InlineInEnvelope bool
	// contains filtered or unexported fields
}

func (*Type) IsPrimitiveType

func (t *Type) IsPrimitiveType() bool

IsPrimitiveType returns true if this type is primitive.

func (Type) Name

func (dn Type) Name() string

func (Type) Namespace

func (dn Type) Namespace() namespace

func (Type) NoLeading

func (dn Type) NoLeading() string

func (Type) Self

func (dn Type) Self() string

func (Type) String

func (dn Type) String() string

func (*Type) WireArgumentDeclaration

func (t *Type) WireArgumentDeclaration(n string) string

WireArgumentDeclaration returns the argument declaration for this type for the wire variant.

func (*Type) WireInitMessage

func (t *Type) WireInitMessage(n string) string

WireInitMessage returns message field initialization for the wire variant.

type TypeShape

type TypeShape struct {
	fidlgen.TypeShape
}

func (TypeShape) HasPointer

func (ts TypeShape) HasPointer() bool

func (TypeShape) MaxTotalSize

func (ts TypeShape) MaxTotalSize() int

type Union

type Union struct {
	Attributes
	fidlgen.Strictness
	fidlgen.Resourceness

	CodingTableType     string
	AnonymousChildren   []ScopedLayout
	TagEnum             nameVariants
	TagUnknown          nameVariants
	TagInvalid          nameVariants
	WireOrdinalEnum     name
	WireInvalidOrdinal  name
	Members             []UnionMember
	BackingBufferTypeV1 string
	BackingBufferTypeV2 string
	Result              *Result
	TypeShapeV1         TypeShape
	TypeShapeV2         TypeShape
	// contains filtered or unexported fields
}

func (*Union) Kind

func (*Union) Kind() declKind

func (Union) Name

func (dn Union) Name() string

func (Union) Namespace

func (dn Union) Namespace() namespace

func (Union) NoLeading

func (dn Union) NoLeading() string

func (Union) Self

func (dn Union) Self() string

func (Union) String

func (dn Union) String() string

type UnionMember

type UnionMember struct {
	Attributes

	Ordinal           uint64
	Type              Type
	StorageName       name
	TagName           nameVariants
	WireOrdinalName   name
	Offset            int
	HandleInformation *HandleInformation
	// contains filtered or unexported fields
}

func (UnionMember) Name

func (dn UnionMember) Name() string

func (UnionMember) NameAndType

func (um UnionMember) NameAndType() (string, Type)

func (UnionMember) Namespace

func (dn UnionMember) Namespace() namespace

func (UnionMember) NoLeading

func (dn UnionMember) NoLeading() string

func (UnionMember) Self

func (dn UnionMember) Self() string

func (UnionMember) String

func (dn UnionMember) String() string

func (UnionMember) UpperCamelCaseName

func (um UnionMember) UpperCamelCaseName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL