codegen

package
v0.0.0-...-9b5a675 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Decode = generic.DefineFunc("Decode(dst interface{}, src interface{})").
	Param("EXT", "user provided extension").
	Param("DT", "the dst type to copy into").
	Param("ST", "the src type to copy from").
	ImportPackage("reflect").
	Declare("var typeOf = reflect.TypeOf").
	ImportFunc(decodeAnything).
	Source(`
{{ $decode := expand "DecodeAnything" "EXT" .EXT "DT" .DT "ST" .ST }}
iter := src.({{.ST|name}})
{{ range $extType := .EXT.ExtTypes }} 
	if iter.GetDecoder("{{$extType|name}}") == nil {
		iter.PrepareDecoder(reflect.TypeOf((*{{$extType|name}})(nil)).Elem())
	}
{{ end }}
{{$decode}}(dst.({{.DT|name}}), iter)
`)
View Source
var Encode = generic.DefineFunc("Encode(dst interface{}, src interface{})").
	Param("EXT", "user provided extension").
	Param("DT", "the dst type to copy into").
	Param("ST", "the src type to copy from").
	ImportFunc(encodeAnything).
	ImportPackage("reflect").
	Declare("var typeOf = reflect.TypeOf").
	Source(`
{{ $decode := expand "EncodeAnything" "EXT" .EXT "DT" .DT "ST" .ST }}
stream := dst.({{.DT|name}})
{{ range $extType := .EXT.ExtTypes }} 
	if stream.GetEncoder("{{$extType|name}}") == nil {
		stream.PrepareEncoder(reflect.TypeOf((*{{$extType|name}})(nil)).Elem())
	}
{{ end }}
{{$decode}}(stream, src.({{.ST|name}}))
`)

Functions

This section is empty.

Types

type Extension

type Extension struct {
	spi.Extension
	ExtTypes []reflect.Type
}

func (*Extension) MangledName

func (ext *Extension) MangledName() string

Jump to

Keyboard shortcuts

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