reflectshape

package module
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2021 License: MIT Imports: 9 Imported by: 9

README

reflectshape

reflect shape

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dump added in v0.3.4

func Dump(s Shape) error

func Fdump added in v0.3.4

func Fdump(w io.Writer, s Shape) error

Types

type Container

type Container struct {
	*Info
	Args ShapeList `json:"args"`
}

for generics

func (Container) Clone

func (s Container) Clone() Shape

func (Container) Format

func (v Container) Format(f fmt.State, c rune)

type Extractor

type Extractor struct {
	Seen map[reflect.Type]Shape

	ArglistLookup  *arglist.Lookup
	RevisitArglist bool
	// contains filtered or unexported fields
}

func NewExtractor added in v0.2.0

func NewExtractor() *Extractor

func (*Extractor) Extract

func (e *Extractor) Extract(ob interface{}) Shape

type FieldMetadata

type FieldMetadata struct {
	Anonymous bool // embedded?
	FieldName string
	Required  bool
}

type Function

type Function struct {
	*Info
	Params  ShapeMap `json:"params"`  // for function's In
	Returns ShapeMap `json:"returns"` // for function's Out
}

func (Function) Clone

func (s Function) Clone() Shape

func (Function) Format

func (v Function) Format(f fmt.State, c rune)

type FunctionSet added in v0.3.2

type FunctionSet struct {
	Names     []string            `json:"names"`
	Functions map[string]Function `json:"values"`
}

func (*FunctionSet) Get added in v0.3.3

func (m *FunctionSet) Get(k string) (Function, bool)

func (*FunctionSet) Len added in v0.3.2

func (m *FunctionSet) Len() int

type Identity added in v0.2.0

type Identity string

type Info

type Info struct {
	Kind    Kind   `json:"kind"`
	Name    string `json:"name"`
	Lv      int    `json:"lv"` // v is 0, *v is 1
	Package string `json:"package"`
	// contains filtered or unexported fields
}

func (*Info) Clone

func (v *Info) Clone() *Info

func (*Info) GetFullName

func (v *Info) GetFullName() string

func (*Info) GetIdentity added in v0.2.0

func (v *Info) GetIdentity() Identity

func (*Info) GetLv

func (v *Info) GetLv() int

func (*Info) GetName

func (v *Info) GetName() string

func (*Info) GetPackage

func (v *Info) GetPackage() string

func (*Info) GetReflectKind

func (v *Info) GetReflectKind() reflect.Kind

func (*Info) GetReflectType

func (v *Info) GetReflectType() reflect.Type

func (*Info) GetReflectValue

func (v *Info) GetReflectValue() reflect.Value

func (*Info) ResetName

func (v *Info) ResetName(name string)

func (*Info) ResetPackage

func (v *Info) ResetPackage(name string)

func (*Info) ResetReflectType added in v0.2.0

func (v *Info) ResetReflectType(rt reflect.Type)

func (*Info) Shape

func (v *Info) Shape() string

type Interface

type Interface struct {
	*Info
	Methods ShapeMap `json:"methods"`
}

func (Interface) Clone

func (s Interface) Clone() Shape

func (Interface) Format

func (v Interface) Format(f fmt.State, c rune)

type Kind

type Kind reflect.Kind

func (Kind) MarshalJSON

func (k Kind) MarshalJSON() ([]byte, error)

func (Kind) String

func (k Kind) String() string

type Primitive

type Primitive struct {
	*Info
}

func (Primitive) Clone

func (v Primitive) Clone() Shape

func (Primitive) Format

func (v Primitive) Format(f fmt.State, c rune)

type Shape

type Shape interface {
	Shape() string

	GetName() string
	GetFullName() string
	GetPackage() string
	GetLv() int

	ResetName(string)
	ResetPackage(string)
	ResetReflectType(reflect.Type)

	GetReflectKind() reflect.Kind
	GetReflectType() reflect.Type
	GetReflectValue() reflect.Value

	GetIdentity() Identity

	Clone() Shape
	// contains filtered or unexported methods
}

func Extract

func Extract(ob interface{}) Shape

type ShapeList

type ShapeList []Shape

type ShapeMap

type ShapeMap struct {
	Keys   []string `json:"keys"`
	Values []Shape  `json:"values"`
}

func (*ShapeMap) Get added in v0.3.3

func (m *ShapeMap) Get(k string) (Shape, bool)

func (*ShapeMap) Len added in v0.2.0

func (m *ShapeMap) Len() int

type Struct

type Struct struct {
	*Info
	Fields   ShapeMap `json:"fields"`
	Tags     []reflect.StructTag
	Metadata []FieldMetadata
}

func (Struct) Clone

func (s Struct) Clone() Shape

func (*Struct) FieldName

func (v *Struct) FieldName(i int) string

func (Struct) Format

func (v Struct) Format(f fmt.State, c rune)

func (*Struct) Methods added in v0.3.2

func (v *Struct) Methods() FunctionSet

type Unknown

type Unknown struct {
	*Info
}

func (Unknown) Clone

func (s Unknown) Clone() Shape

func (Unknown) Format

func (v Unknown) Format(f fmt.State, c rune)

Directories

Path Synopsis
_examples
cmd

Jump to

Keyboard shortcuts

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