fidlgen

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: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ObjectTypeNone = ObjectType(iota)
	ObjectTypeProcess
	ObjectTypeThread
	ObjectTypeVmo
	ObjectTypeChannel
	ObjectTypeEvent
	ObjectTypePort

	ObjectTypeInterrupt

	ObjectTypePciDevice
	ObjectTypeLog

	ObjectTypeSocket
	ObjectTypeResource
	ObjectTypeEventPair
	ObjectTypeJob
	ObjectTypeVmar
	ObjectTypeFifo
	ObjectTypeGuest
	ObjectTypeVcpu
	ObjectTypeTimer
	ObjectTypeIommu
	ObjectTypeBti
	ObjectTypeProfile
	ObjectTypePmt
	ObjectTypeSuspendToken
	ObjectTypePager
	ObjectTypeException
	ObjectTypeClock
)

Variables

This section is empty.

Functions

func ConstNameToAllCapsSnake

func ConstNameToAllCapsSnake(name string) string

Convert a const name from kCamelCase to ALL_CAPS_SNAKE style

func ConstNameToKCamelCase

func ConstNameToKCamelCase(name string) string

Convert a const name to kCamelCase style

func PrintableASCII

func PrintableASCII(s string) bool

PrintableASCII reports whether s is made of only printable ASCII runes.

func PrintableASCIIRune

func PrintableASCIIRune(r rune) bool

PrintableASCIIRune reports whether r is a printable ASCII rune, i.e. in the range 0x20 to 0x7E.

func RemoveLeadingK

func RemoveLeadingK(name string) string

Removes a leading 'k' if the second character is upper-case, otherwise returns the argument

func SingleQuote

func SingleQuote(s string) string

func TemplateFatalf

func TemplateFatalf(format string, a ...interface{})

TemplateFatalf exits the program with a formatted error message similar to Printf. It is meant to be used by helper functions invoked by the template engine, since normal panics are swallowed by it.

func ToFriendlyCase

func ToFriendlyCase(name string) string

Convert text to friendly case style (like snake case, but with spaces)

func ToLowerCamelCase

func ToLowerCamelCase(name string) string

Convert a name to lowerCamelCase style

func ToSnakeCase

func ToSnakeCase(name string) string

Convert text to snake_case style

func ToUpperCamelCase

func ToUpperCamelCase(name string) string

Convert a name to UpperCamelCase style

func WriteFileIfChanged

func WriteFileIfChanged(filename string, contents []byte) error

WriteFileIfChanged overwrite the filename with new contents unless the file already has those contents.

Types

type Attribute

type Attribute struct {
	Name Identifier     `json:"name"`
	Args []AttributeArg `json:"arguments,omitempty"`
}

func (Attribute) HasArg

func (el Attribute) HasArg(name Identifier) bool

func (Attribute) LookupArg

func (el Attribute) LookupArg(name Identifier) (AttributeArg, bool)

func (Attribute) LookupArgStandalone

func (el Attribute) LookupArgStandalone() (AttributeArg, bool)

type AttributeArg

type AttributeArg struct {
	Name  Identifier `json:"name"`
	Value Constant   `json:"value"`
}

func (AttributeArg) ValueString

func (el AttributeArg) ValueString() string

ValueString returns the attribute arg's value in string form. TODO(fxbug.dev/81390): Attribute values may only be string literals for now.

Make sure to fix this API once that changes to resolve the constant value
for all constant types.

type Attributes

type Attributes struct {
	Attributes []Attribute `json:"maybe_attributes,omitempty"`
}

Attributes represents a list of attributes. It conveniently implements the `Annotated` protocol, such that it can be embedded into other node structs which are annotated.

func (Attributes) BindingsDenylistIncludes

func (el Attributes) BindingsDenylistIncludes(targetLanguage string) bool

BindingsDenylistIncludes returns true if the comma-separated bindings_denylist attribute includes targetLanguage (meaning the bindings for targetLanguage should not emit this declaration).

func (Attributes) DocComments

func (el Attributes) DocComments() []string

func (Attributes) HasAttribute

func (el Attributes) HasAttribute(name Identifier) bool

func (Attributes) LookupAttribute

func (el Attributes) LookupAttribute(name Identifier) (Attribute, bool)

func (Attributes) Transports

func (el Attributes) Transports() map[string]struct{}

type Bits

type Bits struct {
	Layout
	Type       Type         `json:"type"`
	Mask       string       `json:"mask"`
	Members    []BitsMember `json:"members"`
	Strictness `json:"strict"`
}

Bits represents a FIDL declaration of an bits.

type BitsMember

type BitsMember struct {
	Attributes
	Name  Identifier `json:"name"`
	Value Constant   `json:"value"`
}

BitsMember represents a single variant in a FIDL bits.

type CompoundIdentifier

type CompoundIdentifier struct {
	Library LibraryIdentifier
	Name    Identifier
	Member  Identifier
}

func (CompoundIdentifier) Encode

func (CompoundIdentifier) EncodeDecl

type Const

type Const struct {
	Decl
	Type  Type     `json:"type"`
	Value Constant `json:"value"`
}

Const represents a FIDL declaration of a named constant.

type Constant

type Constant struct {
	Kind       ConstantKind              `json:"kind"`
	Identifier EncodedCompoundIdentifier `json:"identifier,omitempty"`
	Literal    Literal                   `json:"literal,omitempty"`
	Value      string                    `json:"value"`
}

type ConstantKind

type ConstantKind string
const (
	IdentifierConstant ConstantKind = "identifier"
	LiteralConstant    ConstantKind = "literal"
	BinaryOperator     ConstantKind = "binary_operator"
)

type Decl

type Decl struct {
	Attributes
	Name EncodedCompoundIdentifier `json:"name"`
}

func (*Decl) GetName

func (d *Decl) GetName() EncodedCompoundIdentifier

type DeclInfo

type DeclInfo struct {
	Type DeclType `json:"kind"`
	// Present for structs, tables, and unions.
	*Resourceness `json:"resource,omitempty"`
}

type DeclInfoMap

type DeclInfoMap map[EncodedCompoundIdentifier]DeclInfo

type DeclType

type DeclType string
const (
	LibraryDeclType DeclType = "library"

	ConstDeclType    DeclType = "const"
	BitsDeclType     DeclType = "bits"
	EnumDeclType     DeclType = "enum"
	ProtocolDeclType DeclType = "interface"
	ServiceDeclType  DeclType = "service"
	StructDeclType   DeclType = "struct"
	TableDeclType    DeclType = "table"
	UnionDeclType    DeclType = "union"
)

func (DeclType) IsPrimitive

func (dt DeclType) IsPrimitive() bool

type Declaration

type Declaration interface {
	GetName() EncodedCompoundIdentifier
}

type EncodedCompoundIdentifier

type EncodedCompoundIdentifier string

func (EncodedCompoundIdentifier) DeclName

func (EncodedCompoundIdentifier) LibraryName

func (EncodedCompoundIdentifier) Parts

type EncodedLibraryIdentifier

type EncodedLibraryIdentifier string

func (EncodedLibraryIdentifier) Parts

func (EncodedLibraryIdentifier) PartsReversed

func (eli EncodedLibraryIdentifier) PartsReversed() []string

type Enum

type Enum struct {
	Layout
	Type            PrimitiveSubtype `json:"type"`
	Members         []EnumMember     `json:"members"`
	Strictness      `json:"strict"`
	RawUnknownValue int64OrUint64 `json:"maybe_unknown_value"`
}

Enum represents a FIDL declaration of an enum.

func (*Enum) UnknownValueAsInt64

func (enum *Enum) UnknownValueAsInt64() (int64, error)

UnknownValueAsInt64 retrieves the unknown value. Succeeds only for signed flexible enums.

func (*Enum) UnknownValueAsUint64

func (enum *Enum) UnknownValueAsUint64() (uint64, error)

UnknownValueAsUint64 retrieves the unknown value. Succeeds only for unsigned flexible enums.

func (*Enum) UnknownValueForTmpl

func (enum *Enum) UnknownValueForTmpl() interface{}

UnknownValueForTmpl retrieves the signed or unsigned unknown value. Panics if called on a strict enum.

type EnumMember

type EnumMember struct {
	Attributes
	Name  Identifier `json:"name"`
	Value Constant   `json:"value"`
}

EnumMember represents a single variant in a FIDL enum.

func (*EnumMember) IsUnknown

func (member *EnumMember) IsUnknown() bool

IsUnknown indicates whether this member represents a custom unknown flexible enum member.

type FieldShape

type FieldShape struct {
	Offset  int `json:"offset"`
	Padding int `json:"padding"`
}

FieldShape represents the shape of the field on the wire. See JSON IR schema, e.g. fidlc --json-schema

type Formatter

type Formatter interface {
	// Format formats source code.
	Format(source []byte) ([]byte, error)
}

Formatter formats generated source code

func NewFormatter

func NewFormatter(path string, args ...string) Formatter

NewFormatter creates a new external formatter.

The `path` needs to either * Point to an executable which formats stdin and outputs it to stdout; * An empty string, in which case no formatting will occur.

func NewFormatterWithSizeLimit

func NewFormatterWithSizeLimit(limit int, path string, args ...string) Formatter

NewFormatterWithSizeLimit creates a new external formatter that doesn't attempt to format sources over a specified size.

The `path` needs to either * Point to an executable which formats stdin and outputs it to stdout; * An empty string, in which case no formatting will occur.

type Generator

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

func NewGenerator

func NewGenerator(name string, templates fs.FS, formatter Formatter, funcs template.FuncMap) *Generator

func (*Generator) ExecuteTemplate

func (gen *Generator) ExecuteTemplate(tmpl string, data interface{}) ([]byte, error)

func (*Generator) GenerateFile

func (gen *Generator) GenerateFile(filename string, tmpl string, data interface{}) error

type HandleRights

type HandleRights uint32
const (
	HandleRightsNone HandleRights = 0

	HandleRightsDuplicate     HandleRights = 1 << 0
	HandleRightsTransfer      HandleRights = 1 << 1
	HandleRightsRead          HandleRights = 1 << 2
	HandleRightsWrite         HandleRights = 1 << 3
	HandleRightsExecute       HandleRights = 1 << 4
	HandleRightsMap           HandleRights = 1 << 5
	HandleRightsGetProperty   HandleRights = 1 << 6
	HandleRightsSetProperty   HandleRights = 1 << 7
	HandleRightsEnumerate     HandleRights = 1 << 8
	HandleRightsDestroy       HandleRights = 1 << 9
	HandleRightsSetPolicy     HandleRights = 1 << 10
	HandleRightsGetPolicy     HandleRights = 1 << 11
	HandleRightsSignal        HandleRights = 1 << 12
	HandleRightsSignalPeer    HandleRights = 1 << 13
	HandleRightsWait          HandleRights = 1 << 14
	HandleRightsInspect       HandleRights = 1 << 15
	HandleRightsManageJob     HandleRights = 1 << 16
	HandleRightsManageProcess HandleRights = 1 << 17
	HandleRightsManageThread  HandleRights = 1 << 18
	HandleRightsApplyProfile  HandleRights = 1 << 19

	HandleRightsSameRights HandleRights = 1 << 31

	HandleRightsBasic HandleRights = HandleRightsTransfer | HandleRightsDuplicate | HandleRightsWait | HandleRightsInspect
)

type HandleSubtype

type HandleSubtype string
const (
	Handle       HandleSubtype = "handle"
	Bti          HandleSubtype = "bti"
	Channel      HandleSubtype = "channel"
	Clock        HandleSubtype = "clock"
	DebugLog     HandleSubtype = "debuglog"
	Event        HandleSubtype = "event"
	Eventpair    HandleSubtype = "eventpair"
	Exception    HandleSubtype = "exception"
	Fifo         HandleSubtype = "fifo"
	Guest        HandleSubtype = "guest"
	Interrupt    HandleSubtype = "interrupt"
	Iommu        HandleSubtype = "iommu"
	Job          HandleSubtype = "job"
	Pager        HandleSubtype = "pager"
	PciDevice    HandleSubtype = "pcidevice"
	Pmt          HandleSubtype = "pmt"
	Port         HandleSubtype = "port"
	Process      HandleSubtype = "process"
	Profile      HandleSubtype = "profile"
	Resource     HandleSubtype = "resource"
	Socket       HandleSubtype = "socket"
	Stream       HandleSubtype = "stream"
	SuspendToken HandleSubtype = "suspendtoken"
	Thread       HandleSubtype = "thread"
	Time         HandleSubtype = "timer"
	Vcpu         HandleSubtype = "vcpu"
	Vmar         HandleSubtype = "vmar"
	Vmo          HandleSubtype = "vmo"
)

type Identifier

type Identifier string

type Layout

type Layout struct {
	Decl
	NamingContext []string `json:"naming_context"`
}

Layout represents data specific to bits/enums/structs/tables/unions. All layouts are decls, but not all decls are layouts (e.g. protocols).

func (*Layout) IsAnonymous

func (l *Layout) IsAnonymous() bool

type Library

type Library struct {
	Name  EncodedLibraryIdentifier `json:"name,omitempty"`
	Decls DeclInfoMap              `json:"declarations,omitempty"`
}

Library represents a FIDL dependency on a separate library.

type LibraryIdentifier

type LibraryIdentifier []Identifier

func (LibraryIdentifier) Encode

type LibraryName

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

LibraryName represents a FIDL library name, such as `fuchsia.mem` or `fuchsia.ui.scenic`.

func MustReadLibraryName

func MustReadLibraryName(fullyQualifiedName string) LibraryName

MustReadLibraryName reads a library name from a fully qualified name, and panics in case of error.

See https://fuchsia.dev/fuchsia-src/development/languages/fidl/reference/ftp/ftp-043#fully_qualified_names

func ReadLibraryName

func ReadLibraryName(fullyQualifiedName string) (LibraryName, error)

ReadLibraryName reads a library name from a fully qualified name.

See https://fuchsia.dev/fuchsia-src/development/languages/fidl/reference/ftp/ftp-043#fully_qualified_names

func (LibraryName) FullyQualifiedName

func (name LibraryName) FullyQualifiedName() string

FullyQualifiedName returns the fully qualified name, e.g. `fuchsia.mem` or `fuchsia.ui.scenic`.

See https://fuchsia.dev/fuchsia-src/development/languages/fidl/reference/ftp/ftp-043#fully_qualified_names

func (LibraryName) Parts

func (name LibraryName) Parts() []string

Parts returns the library name in parts, e.g. `fuchsia`, `mem` or `fuchsia`, `ui`, `scenic`.

func (LibraryName) String

func (name LibraryName) String() string

type Literal

type Literal struct {
	Kind  LiteralKind `json:"kind"`
	Value string      `json:"value,omitempty"`
}

type LiteralKind

type LiteralKind string
const (
	StringLiteral  LiteralKind = "string"
	NumericLiteral LiteralKind = "numeric"
	BoolLiteral    LiteralKind = "bool"
	DefaultLiteral LiteralKind = "default"
)

type Method

type Method struct {
	Attributes
	Ordinal         uint64     `json:"ordinal"`
	Name            Identifier `json:"name"`
	IsComposed      bool       `json:"is_composed"`
	HasRequest      bool       `json:"has_request"`
	RequestPayload  *Type      `json:"maybe_request_payload,omitempty"`
	RequestPadding  bool       `json:"maybe_request_has_padding,omitempty"`
	RequestFlexible bool       `json:"experimental_maybe_request_has_flexible_envelope,omitempty"`
	HasResponse     bool       `json:"has_response"`
	ResponsePayload *Type      `json:"maybe_response_payload,omitempty"`
	HasError        bool       `json:"has_error"`
	ResultType      *Type      `json:"maybe_response_result_type,omitempty"`
	ValueType       *Type      `json:"maybe_response_success_type,omitempty"`
	ValueStruct     *Struct    `json:"maybe_response_success_struct,omitempty"`
	ErrorType       *Type      `json:"maybe_response_err_type,omitempty"`
}

Method represents the declaration of a FIDL method.

func (*Method) GetRequestPayloadIdentifier

func (m *Method) GetRequestPayloadIdentifier() (EncodedCompoundIdentifier, bool)

GetRequestPayloadIdentifier retrieves the identifier that points to the declaration of the request payload.

func (*Method) GetResponsePayloadIdentifier

func (m *Method) GetResponsePayloadIdentifier() (EncodedCompoundIdentifier, bool)

GetResponsePayloadIdentifier retrieves the identifier that points to the declaration of the response payload.

func (*Method) IsTransitional

func (m *Method) IsTransitional() bool

IsTransitional returns whether this method has the `Transitional` attribute.

type Name

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

Name represents a FIDL declaration name, consisting of a FIDL library, and a FIDL declration such as `fuchsia.mem` and `Buffer`.

func MustReadName

func MustReadName(fullyQualifiedName string) Name

MustReadName reads a name from a fully qualified name, and panics in case of error.

See https://fuchsia.dev/fuchsia-src/development/languages/fidl/reference/ftp/ftp-043#fully_qualified_names

func ReadName

func ReadName(fullyQualifiedName string) (Name, error)

ReadName reads a name from a fully qualified name.

See https://fuchsia.dev/fuchsia-src/development/languages/fidl/reference/ftp/ftp-043#fully_qualified_names

func (Name) DeclarationName

func (name Name) DeclarationName() string

DeclarationName returns the declaration name, e.g. `Buffer`.

func (Name) FullyQualifiedName

func (name Name) FullyQualifiedName() string

FullyQualifiedName returns the fully qualified name, e.g. `fuchsia.mem/Buffer`.

See https://fuchsia.dev/fuchsia-src/development/languages/fidl/reference/ftp/ftp-043#fully_qualified_names

func (Name) LibraryName

func (name Name) LibraryName() LibraryName

LibraryName returns the library name, e.g. `fuchsia.mem`.

func (Name) String

func (name Name) String() string

type NameContext

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

func NewNameContext

func NewNameContext() NameContext

func (NameContext) IsReserved

func (nc NameContext) IsReserved(name string) bool

func (NameContext) ReserveNames

func (nc NameContext) ReserveNames(names []string)

type ObjectType

type ObjectType uint32

TODO(fxb/64629): Remove, source of truth is library zx.

One complication is that GIDL parses nice handle subtypes in its grammar, e.g. `#0 = event(rights: execute + write )`. And some GIDL backends care about the object type. This means that we need to duplicate this mapping :/ It would be cleaner to limit this to GIDL and GIDL backends, rather than offer that in the general purpose lib/fidlgen.

func ObjectTypeFromHandleSubtype

func ObjectTypeFromHandleSubtype(val HandleSubtype) ObjectType

type PrimitiveSubtype

type PrimitiveSubtype string
const (
	Bool    PrimitiveSubtype = "bool"
	Int8    PrimitiveSubtype = "int8"
	Int16   PrimitiveSubtype = "int16"
	Int32   PrimitiveSubtype = "int32"
	Int64   PrimitiveSubtype = "int64"
	Uint8   PrimitiveSubtype = "uint8"
	Uint16  PrimitiveSubtype = "uint16"
	Uint32  PrimitiveSubtype = "uint32"
	Uint64  PrimitiveSubtype = "uint64"
	Float32 PrimitiveSubtype = "float32"
	Float64 PrimitiveSubtype = "float64"
)

func (PrimitiveSubtype) IsSigned

func (typ PrimitiveSubtype) IsSigned() bool

IsSigned indicates whether this subtype represents a signed number such as `int16`, or `float32`.

func (PrimitiveSubtype) IsUnsigned

func (typ PrimitiveSubtype) IsUnsigned() bool

IsUnsigned indicates whether this subtype represents an unsigned number such as `uint16`.

type Protocol

type Protocol struct {
	Decl
	Methods []Method `json:"methods"`
}

Protocol represents the declaration of a FIDL protocol.

func (*Protocol) GetServiceName

func (d *Protocol) GetServiceName() string

type Resourceness

type Resourceness bool

Resourceness represents whether a FIDL object may contain any resource types, such as handles. See https://fuchsia.dev/fuchsia-src/contribute/governance/fidl/ftp/ftp-057 for more information.

const (
	IsResourceType Resourceness = true
	IsValueType    Resourceness = false
)

func (Resourceness) IsResourceType

func (r Resourceness) IsResourceType() bool

IsResourceType indicates whether this type is marked as a resource type

func (Resourceness) IsValueType

func (r Resourceness) IsValueType() bool

IsValueType indicates whether this type is not marked as a resource type

type Root

type Root struct {
	Name      EncodedLibraryIdentifier    `json:"name,omitempty"`
	Consts    []Const                     `json:"const_declarations,omitempty"`
	Bits      []Bits                      `json:"bits_declarations,omitempty"`
	Enums     []Enum                      `json:"enum_declarations,omitempty"`
	Protocols []Protocol                  `json:"interface_declarations,omitempty"`
	Services  []Service                   `json:"service_declarations,omitempty"`
	Structs   []Struct                    `json:"struct_declarations,omitempty"`
	Tables    []Table                     `json:"table_declarations,omitempty"`
	Unions    []Union                     `json:"union_declarations,omitempty"`
	DeclOrder []EncodedCompoundIdentifier `json:"declaration_order,omitempty"`
	Decls     DeclMap                     `json:"declarations,omitempty"`
	Libraries []Library                   `json:"library_dependencies,omitempty"`
	// contains filtered or unexported fields
}

Root is the top-level object for a FIDL library. It contains lists of all declarations and dependencies within the library.

func DecodeJSONIr

func DecodeJSONIr(r io.Reader) (Root, error)

DecodeJSONIr reads the JSON content from a reader.

func ReadJSONIr

func ReadJSONIr(filename string) (Root, error)

ReadJSONIr reads a JSON IR file.

func ReadJSONIrContent

func ReadJSONIrContent(b []byte) (Root, error)

ReadJSONIrContent reads JSON IR content.

func (*Root) DeclsWithDependencies

func (r *Root) DeclsWithDependencies() DeclInfoMap

DeclsWithDependencies returns a single DeclInfoMap containing the FIDL library's declarations and those of its dependencies.

func (*Root) ForBindings

func (r *Root) ForBindings(language string) Root

ForBindings filters out declarations that should be omitted in the given language bindings based on BindingsDenylist attributes. It returns a new Root and does not modify r.

func (*Root) LookupDecl

func (r *Root) LookupDecl(i EncodedCompoundIdentifier) Declaration

type Service

type Service struct {
	Decl
	Members []ServiceMember `json:"members"`
}

Service represents the declaration of a FIDL service.

func (*Service) GetServiceName

func (s *Service) GetServiceName() string

type ServiceMember

type ServiceMember struct {
	Attributes
	Name Identifier `json:"name"`
	Type Type       `json:"type"`
}

ServiceMember represents the declaration of a field in a FIDL service.

type Strictness

type Strictness bool

Strictness represents whether a FIDL object is strict or flexible. See <https://fuchsia.dev/fuchsia-src/development/languages/fidl/reference/ftp/ftp-033> for more information.

const (
	IsFlexible Strictness = false
	IsStrict   Strictness = true
)

func (Strictness) IsFlexible

func (s Strictness) IsFlexible() bool

IsFlexible indicates whether this type is flexible.

func (Strictness) IsStrict

func (s Strictness) IsStrict() bool

IsStrict indicates whether this type is strict.

type Struct

type Struct struct {
	Layout
	IsRequestOrResponse bool           `json:"is_request_or_response"`
	Members             []StructMember `json:"members"`
	Resourceness        `json:"resource"`
	TypeShapeV1         TypeShape `json:"type_shape_v1"`
	TypeShapeV2         TypeShape `json:"type_shape_v2"`
}

Struct represents a declaration of a FIDL struct.

type StructMember

type StructMember struct {
	Attributes
	Type              Type       `json:"type"`
	Name              Identifier `json:"name"`
	MaybeDefaultValue *Constant  `json:"maybe_default_value,omitempty"`
	MaxHandles        int        `json:"max_handles"`
	FieldShapeV1      FieldShape `json:"field_shape_v1"`
	FieldShapeV2      FieldShape `json:"field_shape_v2"`
}

StructMember represents the declaration of a field in a FIDL struct.

func EmptyStructMember

func EmptyStructMember(name string) StructMember

EmptyStructMember returns a StructMember that's suitable as the sole member of an empty struct.

type Table

type Table struct {
	Layout
	Members      []TableMember `json:"members"`
	Resourceness `json:"resource"`
	TypeShapeV1  TypeShape `json:"type_shape_v1"`
	TypeShapeV2  TypeShape `json:"type_shape_v2"`
}

Table represents a declaration of a FIDL table.

func (*Table) SortedMembersNoReserved

func (t *Table) SortedMembersNoReserved() []TableMember

SortedMembersNoReserved returns the table's members sorted by ordinal, excluding reserved members.

type TableMember

type TableMember struct {
	Attributes
	Reserved          bool       `json:"reserved"`
	Type              Type       `json:"type"`
	Name              Identifier `json:"name"`
	Ordinal           int        `json:"ordinal"`
	MaybeDefaultValue *Constant  `json:"maybe_default_value,omitempty"`
	MaxOutOfLine      int        `json:"max_out_of_line"`
}

TableMember represents the declaration of a field in a FIDL table.

type Type

type Type struct {
	Kind             TypeKind
	ElementType      *Type
	ElementCount     *int
	HandleSubtype    HandleSubtype
	HandleRights     HandleRights
	RequestSubtype   EncodedCompoundIdentifier
	PrimitiveSubtype PrimitiveSubtype
	Identifier       EncodedCompoundIdentifier
	Nullable         bool
	ObjType          uint32
	TypeShapeV1      TypeShape
	TypeShapeV2      TypeShape
}

func (*Type) UnmarshalJSON

func (t *Type) UnmarshalJSON(b []byte) error

UnmarshalJSON customizes the JSON unmarshalling for Type.

type TypeKind

type TypeKind string
const (
	ArrayType      TypeKind = "array"
	VectorType     TypeKind = "vector"
	StringType     TypeKind = "string"
	HandleType     TypeKind = "handle"
	RequestType    TypeKind = "request"
	PrimitiveType  TypeKind = "primitive"
	IdentifierType TypeKind = "identifier"
)

type TypeShape

type TypeShape struct {
	InlineSize          int  `json:"inline_size"`
	Alignment           int  `json:"alignment"`
	Depth               int  `json:"depth"`
	MaxHandles          int  `json:"max_handles"`
	MaxOutOfLine        int  `json:"max_out_of_line"`
	HasPadding          bool `json:"has_padding"`
	HasFlexibleEnvelope bool `json:"has_flexible_envelope"`
}

TypeShape represents the shape of the type on the wire. See JSON IR schema, e.g. fidlc --json-schema

type Union

type Union struct {
	Layout
	Members      []UnionMember `json:"members"`
	Strictness   `json:"strict"`
	Resourceness `json:"resource"`
	TypeShapeV1  TypeShape `json:"type_shape_v1"`
	TypeShapeV2  TypeShape `json:"type_shape_v2"`
}

Union represents the declaration of a FIDL union.

type UnionMember

type UnionMember struct {
	Attributes
	Reserved     bool       `json:"reserved"`
	Ordinal      int        `json:"ordinal"`
	Type         Type       `json:"type"`
	Name         Identifier `json:"name"`
	Offset       int        `json:"offset"`
	MaxOutOfLine int        `json:"max_out_of_line"`
}

UnionMember represents the declaration of a field in a FIDL extensible union.

Jump to

Keyboard shortcuts

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