Documentation ¶
Index ¶
- func Visit(visitor ValueVisitor, value interface{}, decl Declaration)
- type ArrayDecl
- type BitsDecl
- type BoolDecl
- type Declaration
- type EnumDecl
- type FloatDecl
- type HandleDecl
- type IntegerDecl
- type ListDeclaration
- type NamedDeclaration
- type NeverNullable
- type PrimitiveDeclaration
- type RecordDeclaration
- type Schema
- type StringDecl
- type StructDecl
- type TableDecl
- type UnionDecl
- type ValueVisitor
- type VectorDecl
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Visit ¶
func Visit(visitor ValueVisitor, value interface{}, decl Declaration)
Visit is the entry point into visiting a value, it dispatches appropriately into the visitor.
Types ¶
type ArrayDecl ¶
type ArrayDecl struct { NeverNullable // contains filtered or unexported fields }
func (*ArrayDecl) Elem ¶
func (decl *ArrayDecl) Elem() Declaration
type BitsDecl ¶
type BitsDecl struct { NeverNullable Underlying IntegerDecl // contains filtered or unexported fields }
func (*BitsDecl) IsFlexible ¶
type BoolDecl ¶
type BoolDecl struct {
NeverNullable
}
func (*BoolDecl) Subtype ¶
func (decl *BoolDecl) Subtype() fidl.PrimitiveSubtype
type Declaration ¶
type Declaration interface { // IsNullable returns true for nullable types. For example, it returns false // for string and true for string?. IsNullable() bool // contains filtered or unexported methods }
Declaration is the GIDL-level concept of a FIDL type. It is more convenient to work with in GIDL backends than fidl.Type. It also provides logic for testing if a GIDL value conforms to the declaration.
type EnumDecl ¶
type EnumDecl struct { NeverNullable Underlying IntegerDecl // contains filtered or unexported fields }
func (*EnumDecl) IsFlexible ¶
type FloatDecl ¶
type FloatDecl struct { NeverNullable // contains filtered or unexported fields }
func (*FloatDecl) Subtype ¶
func (decl *FloatDecl) Subtype() fidl.PrimitiveSubtype
type HandleDecl ¶
type HandleDecl struct {
// contains filtered or unexported fields
}
func (*HandleDecl) IsNullable ¶
func (decl *HandleDecl) IsNullable() bool
func (*HandleDecl) Subtype ¶
func (decl *HandleDecl) Subtype() fidl.HandleSubtype
type IntegerDecl ¶
type IntegerDecl struct { NeverNullable // contains filtered or unexported fields }
func (*IntegerDecl) Subtype ¶
func (decl *IntegerDecl) Subtype() fidl.PrimitiveSubtype
type ListDeclaration ¶
type ListDeclaration interface { Declaration // Elem returns the declaration for the list's element type. Elem() Declaration }
type NamedDeclaration ¶
type NamedDeclaration interface { Declaration // Name returns the fully qualified name of this declaration, e.g. // "the.library.name/TheTypeName". // TODO(fxbug.dev/39407): Return common.DeclName. Name() string }
type NeverNullable ¶
type NeverNullable struct{}
Helper struct for implementing IsNullable on types that are never nullable.
func (NeverNullable) IsNullable ¶
func (NeverNullable) IsNullable() bool
type PrimitiveDeclaration ¶
type PrimitiveDeclaration interface { Declaration // Subtype returns the primitive subtype (bool, uint32, float64, etc.). Subtype() fidl.PrimitiveSubtype }
type RecordDeclaration ¶
type RecordDeclaration interface { NamedDeclaration // IsResourceType returns true if the type is marked as a resource, meaning // it may contain handles. IsResourceType() bool // AllFields returns the names of all fields in the type. FieldNames() []string // Field returns the declaration for the field with the given name. It // returns false if no field with that name exists. Field(name string) (Declaration, bool) }
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is the GIDL-level concept of a FIDL library. It provides functions to lookup types and return the corresponding Declaration.
func BuildSchema ¶
BuildSchema builds a Schema from a FIDL library and handle definitions. Note: The returned schema contains pointers into fidl.
func (Schema) ExtractDeclaration ¶
func (s Schema) ExtractDeclaration(value interface{}, handleDefs []gidlir.HandleDef) (*StructDecl, error)
ExtractDeclaration extract the top-level declaration for the provided value, and ensures the value conforms to the schema. It also takes a list of handle definitions in scope, which can be nil if there are no handles.
func (Schema) ExtractDeclarationByName ¶
func (s Schema) ExtractDeclarationByName(unqualifiedName string) (*StructDecl, error)
ExtractDeclarationByName extracts the top-level declaration for the given unqualified type name. This is used in cases where only the type name is provided in the test (e.g. decoding-only tests).
func (Schema) ExtractDeclarationUnsafe ¶
func (s Schema) ExtractDeclarationUnsafe(value interface{}) (*StructDecl, error)
ExtractDeclarationUnsafe extracts the top-level declaration for the provided value, but does not ensure the value conforms to the schema. This is used in cases where conformance is too strict (e.g. failure cases).
type StringDecl ¶
type StringDecl struct {
// contains filtered or unexported fields
}
func (*StringDecl) IsNullable ¶
func (decl *StringDecl) IsNullable() bool
type StructDecl ¶
type StructDecl struct {
// contains filtered or unexported fields
}
StructDecl describes a struct declaration.
func (*StructDecl) Field ¶
func (decl *StructDecl) Field(name string) (Declaration, bool)
func (*StructDecl) FieldNames ¶
func (decl *StructDecl) FieldNames() []string
func (*StructDecl) IsNullable ¶
func (decl *StructDecl) IsNullable() bool
func (*StructDecl) IsResourceType ¶
func (decl *StructDecl) IsResourceType() bool
func (*StructDecl) Name ¶
func (decl *StructDecl) Name() string
type TableDecl ¶
type TableDecl struct { NeverNullable // contains filtered or unexported fields }
TableDecl describes a table declaration.
func (*TableDecl) FieldNames ¶
func (*TableDecl) IsResourceType ¶
type UnionDecl ¶
type UnionDecl struct {
// contains filtered or unexported fields
}
UnionDecl describes a union declaration.
func (*UnionDecl) FieldNames ¶
func (*UnionDecl) IsNullable ¶
func (*UnionDecl) IsResourceType ¶
type ValueVisitor ¶
type ValueVisitor interface { OnBool(value bool) OnInt64(value int64, typ fidl.PrimitiveSubtype) OnUint64(value uint64, typ fidl.PrimitiveSubtype) OnFloat64(value float64, typ fidl.PrimitiveSubtype) OnString(value string, decl *StringDecl) OnHandle(value gidlir.Handle, decl *HandleDecl) OnBits(value interface{}, decl *BitsDecl) OnEnum(value interface{}, decl *EnumDecl) OnStruct(value gidlir.Record, decl *StructDecl) OnTable(value gidlir.Record, decl *TableDecl) OnUnion(value gidlir.Record, decl *UnionDecl) OnArray(value []interface{}, decl *ArrayDecl) OnVector(value []interface{}, decl *VectorDecl) OnNull(decl Declaration) }
ValueVisitor is an API that walks GIDL values.
type VectorDecl ¶
type VectorDecl struct {
// contains filtered or unexported fields
}
func (*VectorDecl) Elem ¶
func (decl *VectorDecl) Elem() Declaration
func (*VectorDecl) IsNullable ¶
func (decl *VectorDecl) IsNullable() bool
func (*VectorDecl) MaxSize ¶
func (decl *VectorDecl) MaxSize() (int, bool)