signature

package
Version: v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2021 License: BSD-3-Clause Imports: 2 Imported by: 21

Documentation

Overview

Package signature defines types representing interface and method signatures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MethodNames

func MethodNames(sig []Interface) []string

MethodNames returns a sorted list of all method names from x.

Types

type Arg

type Arg struct {
	Name string
	Doc  string
	Type *vdl.Type // Type of the argument.
}

Arg describes the signature of a single argument.

func CopyArgs

func CopyArgs(x []Arg) []Arg

CopyArgs returns a deep copy of x.

func (Arg) VDLIsZero

func (x Arg) VDLIsZero() bool

func (*Arg) VDLRead

func (x *Arg) VDLRead(dec vdl.Decoder) error

func (Arg) VDLReflect

func (Arg) VDLReflect(struct {
	Name string `vdl:"signature.Arg"`
})

func (Arg) VDLWrite

func (x Arg) VDLWrite(enc vdl.Encoder) error

type Embed

type Embed struct {
	Name    string
	PkgPath string
	Doc     string
}

Embed describes the signature of an embedded interface.

func CopyEmbeds

func CopyEmbeds(x []Embed) []Embed

CopyEmbeds returns a deep copy of x.

func (Embed) VDLIsZero

func (x Embed) VDLIsZero() bool

func (*Embed) VDLRead

func (x *Embed) VDLRead(dec vdl.Decoder) error

func (Embed) VDLReflect

func (Embed) VDLReflect(struct {
	Name string `vdl:"signature.Embed"`
})

func (Embed) VDLWrite

func (x Embed) VDLWrite(enc vdl.Encoder) error

type Interface

type Interface struct {
	Name    string
	PkgPath string
	Doc     string
	Embeds  []Embed  // No special ordering.
	Methods []Method // Ordered by method name.
}

Interface describes the signature of an interface.

func CleanInterfaces

func CleanInterfaces(sig []Interface) []Interface

CleanInterfaces returns a cleaned version of sig. Duplicate interfaces are merged, duplicate embeds and methods are dropped, and all methods are sorted by name.

func CopyInterface

func CopyInterface(x Interface) Interface

CopyInterface returns a deep copy of x.

func CopyInterfaces

func CopyInterfaces(x []Interface) []Interface

CopyInterfaces returns a deep copy of x.

func (*Interface) FindMethod

func (s *Interface) FindMethod(name string) (Method, bool)

FindMethod returns the signature of the method with the given name and true iff the method exists, otherwise returns an empty signature and false.

func (Interface) VDLIsZero

func (x Interface) VDLIsZero() bool

func (*Interface) VDLRead

func (x *Interface) VDLRead(dec vdl.Decoder) error

func (Interface) VDLReflect

func (Interface) VDLReflect(struct {
	Name string `vdl:"signature.Interface"`
})

func (Interface) VDLWrite

func (x Interface) VDLWrite(enc vdl.Encoder) error

type Method

type Method struct {
	Name      string
	Doc       string
	InArgs    []Arg        // Input arguments
	OutArgs   []Arg        // Output arguments
	InStream  *Arg         // Input stream (optional)
	OutStream *Arg         // Output stream (optional)
	Tags      []*vdl.Value // Method tags
}

Method describes the signature of an interface method.

func CopyMethod

func CopyMethod(x Method) Method

CopyMethod returns a deep copy of x.

func CopyMethods

func CopyMethods(x []Method) []Method

CopyMethods returns a deep copy of x.

func FirstMethod

func FirstMethod(sig []Interface, name string) (Method, bool)

FirstMethod returns the signature of the method with the given name and true iff the method exists, otherwise returns an empty signature and false. If the method exists in more than one interface, we return the method from the the first interface with the given method name.

func (Method) VDLIsZero

func (x Method) VDLIsZero() bool

func (*Method) VDLRead

func (x *Method) VDLRead(dec vdl.Decoder) error

func (Method) VDLReflect

func (Method) VDLReflect(struct {
	Name string `vdl:"signature.Method"`
})

func (Method) VDLWrite

func (x Method) VDLWrite(enc vdl.Encoder) error

type SortableMethods

type SortableMethods []Method

SortableMethods implements sort.Interface, ordering by method name.

func (SortableMethods) Len

func (s SortableMethods) Len() int

func (SortableMethods) Less

func (s SortableMethods) Less(i, j int) bool

func (SortableMethods) Swap

func (s SortableMethods) Swap(i, j int)

Jump to

Keyboard shortcuts

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