Documentation ¶
Index ¶
- func MarshalBuiltin(kind schema.BuiltinKind, value *Statement) Code
- func MarshalBuiltinList(kind schema.BuiltinKind, value *Statement) Code
- func Q(info *pkginfo.PkgDeclInfo) *Statement
- func UnmarshallerTypeName() *Statement
- type Helper
- func (g *Helper) Builtin(pos gotoken.Pos, kind schema.BuiltinKind) *Statement
- func (g *Helper) GoToJen(pos gotoken.Pos, val any) *Statement
- func (g *Helper) Initialize(typ schema.Type) *Statement
- func (g *Helper) NewTypeUnmarshaller(objName string) *TypeUnmarshaller
- func (g *Helper) Type(typ schema.Type) *Statement
- func (g *Helper) TypeToString(typ schema.Type) string
- func (g *Helper) Zero(typ schema.Type) *Statement
- type TypeUnmarshaller
- func (u *TypeUnmarshaller) Err() *Statement
- func (u *TypeUnmarshaller) HasError() *Statement
- func (u *TypeUnmarshaller) IncNonEmpty() *Statement
- func (u *TypeUnmarshaller) Init() *Statement
- func (u *TypeUnmarshaller) NumNonEmptyValues() *Statement
- func (u *TypeUnmarshaller) ParseJSON(fieldName string, iteratorExpr *Statement, dstExpr *Statement) *Statement
- func (u *TypeUnmarshaller) ReadBody(bodyExpr *Statement) *Statement
- func (u *TypeUnmarshaller) UnmarshalBuiltin(kind schema.BuiltinKind, fieldName string, value *Statement, required bool) *Statement
- func (u *TypeUnmarshaller) UnmarshalBuiltinList(kind schema.BuiltinKind, fieldName string, value *Statement, required bool) *Statement
- func (u *TypeUnmarshaller) UnmarshalSingleOrList(typ schema.Type, fieldName string, singleValue, listOfValues *Statement, ...) *Statement
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalBuiltin ¶
func MarshalBuiltin(kind schema.BuiltinKind, value *Statement) Code
MarshalBuiltin generates the code to marshal a builtin type. The resulting code if an expression of type string.
func MarshalBuiltinList ¶
func MarshalBuiltinList(kind schema.BuiltinKind, value *Statement) Code
MarshalBuiltinList generates the code to marshal a list of builtins. The resulting code is an expression of type []string.
func Q ¶
func Q(info *pkginfo.PkgDeclInfo) *Statement
Q returns a qualified name (using [jen.Qual]) for the given info.
func UnmarshallerTypeName ¶
func UnmarshallerTypeName() *Statement
UnmarshallerTypeName returns a type expression for the etype.Unmarshaller type in the runtime, in the form "*etype.Unmarshaller".
Types ¶
type Helper ¶
func (*Helper) Builtin ¶
func (g *Helper) Builtin(pos gotoken.Pos, kind schema.BuiltinKind) *Statement
func (*Helper) Initialize ¶
Initialize returns a jen expression for initializing the given type. If the type is a pointer type it returns new(Foo), and make(Foo) for slices and maps.
Certain types like function types and interfaces return "nil" as there is no canonical way to initialize them to a non-zero value.
func (*Helper) NewTypeUnmarshaller ¶
func (g *Helper) NewTypeUnmarshaller(objName string) *TypeUnmarshaller
func (*Helper) TypeToString ¶
TypeToString converts a schema.Type to a string.
type TypeUnmarshaller ¶
type TypeUnmarshaller struct {
// contains filtered or unexported fields
}
func (*TypeUnmarshaller) Err ¶
func (u *TypeUnmarshaller) Err() *Statement
func (*TypeUnmarshaller) HasError ¶
func (u *TypeUnmarshaller) HasError() *Statement
func (*TypeUnmarshaller) IncNonEmpty ¶ added in v1.16.0
func (u *TypeUnmarshaller) IncNonEmpty() *Statement
IncNonEmpty returns a statement to increment the number of non-empty values the unmarshaller has processed.
func (*TypeUnmarshaller) Init ¶
func (u *TypeUnmarshaller) Init() *Statement
func (*TypeUnmarshaller) NumNonEmptyValues ¶
func (u *TypeUnmarshaller) NumNonEmptyValues() *Statement
NumNonEmptyValues returns an integer expression that reports the number of non-empty values the unmarshaller has processed.
func (*TypeUnmarshaller) ParseJSON ¶
func (u *TypeUnmarshaller) ParseJSON(fieldName string, iteratorExpr *Statement, dstExpr *Statement) *Statement
ParseJSON returns an expression to parse json. It uses the iterator accessed through the given iteratorExpr to parse JSON into the given dstExpr. The dstExpr must be a pointer value. The field name is only used for error reporting.
func (*TypeUnmarshaller) ReadBody ¶
func (u *TypeUnmarshaller) ReadBody(bodyExpr *Statement) *Statement
ReadBody returns an expression to read the full request body into a []byte.
func (*TypeUnmarshaller) UnmarshalBuiltin ¶
func (u *TypeUnmarshaller) UnmarshalBuiltin(kind schema.BuiltinKind, fieldName string, value *Statement, required bool) *Statement
func (*TypeUnmarshaller) UnmarshalBuiltinList ¶
func (u *TypeUnmarshaller) UnmarshalBuiltinList(kind schema.BuiltinKind, fieldName string, value *Statement, required bool) *Statement
UnmarshalBuiltinList unmarshals a list of builtins.
func (*TypeUnmarshaller) UnmarshalSingleOrList ¶
func (u *TypeUnmarshaller) UnmarshalSingleOrList(typ schema.Type, fieldName string, singleValue, listOfValues *Statement, required bool) *Statement
UnmarshalSingleOrList returns the code to unmarshal a supported type. The type must be a builtin or a list of builtins.