Documentation
¶
Index ¶
- func JenFunc(name string, in def.Vars, out def.Types, body *jen.Statement) *jen.Statement
- func MethodDef(name string, in def.Types, out def.Types) def.Method
- func Q(pkg string, name string) def.Q
- func RemoveSelfImport(file string)
- func StmtChan() stmtChan
- func StmtChanSized(size int) stmtChan
- func T(prototypes ...interface{}) def.Types
- func V(name string, prototype interface{}) def.Var
- func Vars(vars ...def.Var) def.Vars
- type Djent
- func (j Djent) Bytes() []byte
- func (j Djent) Embeddable(function interface{}) *jen.Statement
- func (j Djent) ExternalGenerator(dir string, injects def.Vars, body *jen.Statement, params ...string)
- func (j Djent) ImplFunc(name string, in def.Vars, out def.Types, body *jen.Statement)
- func (j Djent) ImplFuncOf(name string, function interface{}, body *jen.Statement)
- func (j Djent) ImplInterface(iface reflect.Type, name string, ...)
- func (j Djent) ImplMethod(receiver def.Var, name string, in def.Vars, out def.Types, body *jen.Statement)
- func (j Djent) ImplTest(name string, body *jen.Statement)
- func (j Djent) Interface(name string, methods ...def.Method)
- func (j Djent) Iota(name string, values []string)
- func (j Djent) Jen(code ...jen.Code) *jen.Statement
- func (j Djent) PostGen(dir string, qualifier def.Q, postGenHook PostGenHook, params ...string)
- func (j Djent) Render(writer io.Writer) error
- func (j Djent) Save(file string) error
- func (j Djent) Struct(name string, fields ...def.Var)
- type PostGenHook
- type StatementChanOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RemoveSelfImport ¶
func RemoveSelfImport(file string)
func StmtChanSized ¶
func StmtChanSized(size int) stmtChan
func T ¶
T Makes List of Types for given prototypes, Q (Qualifier) or reflect.Type Think of interface method parameters and return parameters Use where method has def.Types parameter
T("", (*error)(nil)) // (string, error) T(Address{}, (*error)(nil)) // (Address, error) T(false) // (bool) T(reflect.TypeOf("stringval")) // (string) T(reflect.TypeOf(reflect.TypeOf("stringval"))) // (reflect.Type) T(Q("reflect","Type")) // (reflect.Type)
TODO: make warning when something like T("reflect","Type") gets called
func V ¶
V is anything that has name and type. prototype can be value of some type, reflect.T value or pair Q(name, pkg)
V("name","") // name string V("age", int8(0)) // age int8 V("location", Location{}) //location Location V("c", Q("context","Context") // pair Q(name, pkg) when you don't have type in runtime. V("reflected", reflect.TypeOf(Location{})) // When you have reflection of type V("location", Location{}).Ptr() //Now it's a pointer
Types ¶
type Djent ¶
func (Djent) Embeddable ¶
Embeddable use to embed body of the method to generated code. tries it's best to import stuff. !!!!! Don't use unnamed functions (for now) !!!!!
func (Djent) ExternalGenerator ¶
func (j Djent) ExternalGenerator(dir string, injects def.Vars, body *jen.Statement, params ...string)
ExternalGenerator runs generated generation code in separate process. TODO: find better way See: TestExternalGenerator as example of usage
func (Djent) ImplFuncOf ¶
ImplFuncOf implements function with given name, signature type or prototype
f := func() string {} j.ImplFuncOf("returnHello", f, jen.Return().Lit("Hello!"))
func (Djent) ImplInterface ¶
func (j Djent) ImplInterface(iface reflect.Type, name string, bodyGenerator func(method reflect.Method) *jen.Statement)
Implements given interface
Usage: j.ImplInterface(reflect.TypeOf((*Writer)(nil)), "emptyWriter", jen.Empty())
func (Djent) ImplMethod ¶
func (j Djent) ImplMethod(receiver def.Var, name string, in def.Vars, out def.Types, body *jen.Statement)
ImplMethod Implements method
func (Djent) Iota ¶
Create Iota
d.Iota(Direction, []string{"North","East","South","West"})
const (
North Direction = iota East South West
)
type PostGenHook ¶
PostGenHook receives new type that was generated has metadata needed for further generation. also string parameters
var val *grpc.TestServiceServer valType := reflect.TypeOf(val).Elem() params := []string{ "param1", }
type StatementChanOpts ¶
type StatementChanOpts uint
const ( IndentLine StatementChanOpts = iota IndentComma IndentSpace )