Commit 2f7df511 authored by Eric Myhre's avatar Eric Myhre

All the other scalars.

It's possible these could be dedup'd... a lot, honestly.  I'm wondering
if they actually need a discrete type per kind at all, anymore; it's
seeming much more tractable to try to turn that into a "no" after all
the other successful work this morning abstracting things.

But I have some other things I want to ship and do demos and prototypes
of that's a lot more interesting than shaving more lines off today.
So just gonna roll with the existing convention and stamp these out.
Might deserve a revisit in the future.  Might not.  Time will tell.
parent 7754ce08
package gengo
import (
"io"
"github.com/ipld/go-ipld-prime/schema"
"github.com/ipld/go-ipld-prime/schema/gen/go/mixins"
)
type boolGenerator struct {
AdjCfg *AdjunctCfg
mixins.BoolTraits
PkgName string
Type schema.TypeBool
}
// --- native content and specializations --->
func (g boolGenerator) EmitNativeType(w io.Writer) {
emitNativeType_scalar(w, g.AdjCfg, g)
}
func (g boolGenerator) EmitNativeAccessors(w io.Writer) {
emitNativeAccessors_scalar(w, g.AdjCfg, g)
}
func (g boolGenerator) EmitNativeBuilder(w io.Writer) {
emitNativeBuilder_scalar(w, g.AdjCfg, g)
}
func (g boolGenerator) EmitNativeMaybe(w io.Writer) {
emitNativeMaybe(w, g.AdjCfg, g)
}
// --- type info --->
func (g boolGenerator) EmitTypeConst(w io.Writer) {
doTemplate(`
// TODO EmitTypeConst
`, w, g.AdjCfg, g)
}
// --- TypedNode boolerface satisfaction --->
func (g boolGenerator) EmitTypedNodeMethodType(w io.Writer) {
doTemplate(`
func ({{ .Type | TypeSymbol }}) Type() schema.Type {
return nil /*TODO:typelit*/
}
`, w, g.AdjCfg, g)
}
func (g boolGenerator) EmitTypedNodeMethodRepresentation(w io.Writer) {
emitTypicalTypedNodeMethodRepresentation(w, g.AdjCfg, g)
}
// --- Node boolerface satisfaction --->
func (g boolGenerator) EmitNodeType(w io.Writer) {
// No additional types needed. Methods all attach to the native type.
}
func (g boolGenerator) EmitNodeTypeAssertions(w io.Writer) {
emitNodeTypeAssertions_typical(w, g.AdjCfg, g)
}
func (g boolGenerator) EmitNodeMethodAsBool(w io.Writer) {
emitNodeMethodAsKind_scalar(w, g.AdjCfg, g)
}
func (g boolGenerator) EmitNodeMethodStyle(w io.Writer) {
emitNodeMethodStyle_typical(w, g.AdjCfg, g)
}
func (g boolGenerator) EmitNodeStyleType(w io.Writer) {
emitNodeStyleType_typical(w, g.AdjCfg, g)
}
// --- NodeBuilder and NodeAssembler --->
func (g boolGenerator) GetNodeBuilderGenerator() NodeBuilderGenerator {
return boolBuilderGenerator{
g.AdjCfg,
mixins.BoolAssemblerTraits{
g.PkgName,
g.TypeName,
"_" + g.AdjCfg.TypeSymbol(g.Type) + "__",
},
g.PkgName,
g.Type,
}
}
type boolBuilderGenerator struct {
AdjCfg *AdjunctCfg
mixins.BoolAssemblerTraits
PkgName string
Type schema.TypeBool
}
func (boolBuilderGenerator) IsRepr() bool { return false } // hbool used in some generalized templates.
func (g boolBuilderGenerator) EmitNodeBuilderType(w io.Writer) {
emitEmitNodeBuilderType_typical(w, g.AdjCfg, g)
}
func (g boolBuilderGenerator) EmitNodeBuilderMethods(w io.Writer) {
emitNodeBuilderMethods_typical(w, g.AdjCfg, g)
}
func (g boolBuilderGenerator) EmitNodeAssemblerType(w io.Writer) {
emitNodeAssemblerType_scalar(w, g.AdjCfg, g)
}
func (g boolBuilderGenerator) EmitNodeAssemblerMethodAssignNull(w io.Writer) {
emitNodeAssemblerMethodAssignNull_scalar(w, g.AdjCfg, g)
}
func (g boolBuilderGenerator) EmitNodeAssemblerMethodAssignBool(w io.Writer) {
emitNodeAssemblerMethodAssignKind_scalar(w, g.AdjCfg, g)
}
func (g boolBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w io.Writer) {
emitNodeAssemblerMethodAssignNode_scalar(w, g.AdjCfg, g)
}
func (g boolBuilderGenerator) EmitNodeAssemblerOtherBits(w io.Writer) {
// Nothing needed here for bool kinds.
}
package gengo
import (
"io"
"github.com/ipld/go-ipld-prime/schema"
"github.com/ipld/go-ipld-prime/schema/gen/go/mixins"
)
var _ TypeGenerator = &boolReprBoolGenerator{}
func NewBoolReprBoolGenerator(pkgName string, typ schema.TypeBool, adjCfg *AdjunctCfg) TypeGenerator {
return boolReprBoolGenerator{
boolGenerator{
adjCfg,
mixins.BoolTraits{
pkgName,
string(typ.Name()),
adjCfg.TypeSymbol(typ),
},
pkgName,
typ,
},
}
}
type boolReprBoolGenerator struct {
boolGenerator
}
func (g boolReprBoolGenerator) GetRepresentationNodeGen() NodeGenerator {
return boolReprBoolReprGenerator{
g.AdjCfg,
g.Type,
}
}
type boolReprBoolReprGenerator struct {
AdjCfg *AdjunctCfg
Type schema.TypeBool
}
func (g boolReprBoolReprGenerator) EmitNodeType(w io.Writer) {
// Since this is a "natural" representation... there's just a type alias here.
// No new functions are necessary.
doTemplate(`
type _{{ .Type | TypeSymbol }}__Repr = _{{ .Type | TypeSymbol }}
`, w, g.AdjCfg, g)
}
func (g boolReprBoolReprGenerator) EmitNodeTypeAssertions(w io.Writer) {
doTemplate(`
var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{}
`, w, g.AdjCfg, g)
}
func (boolReprBoolReprGenerator) EmitNodeMethodReprKind(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodLookupString(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodLookup(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodLookupIndex(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodLookupSegment(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodMapIterator(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodListIterator(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodLength(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodIsUndefined(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodIsNull(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodAsBool(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodAsInt(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodAsFloat(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodAsString(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodAsBytes(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodAsLink(io.Writer) {}
func (boolReprBoolReprGenerator) EmitNodeMethodStyle(io.Writer) {}
func (g boolReprBoolReprGenerator) EmitNodeStyleType(w io.Writer) {
// Since this is a "natural" representation... there's just a type alias here.
// No new functions are necessary.
doTemplate(`
type _{{ .Type | TypeSymbol }}__ReprStyle = _{{ .Type | TypeSymbol }}__Style
`, w, g.AdjCfg, g)
}
func (g boolReprBoolReprGenerator) GetNodeBuilderGenerator() NodeBuilderGenerator {
return boolReprBoolReprBuilderGenerator{g.AdjCfg, g.Type}
}
type boolReprBoolReprBuilderGenerator struct {
AdjCfg *AdjunctCfg
Type schema.TypeBool
}
func (boolReprBoolReprBuilderGenerator) EmitNodeBuilderType(io.Writer) {}
func (boolReprBoolReprBuilderGenerator) EmitNodeBuilderMethods(io.Writer) {}
func (g boolReprBoolReprBuilderGenerator) EmitNodeAssemblerType(w io.Writer) {
// Since this is a "natural" representation... there's just a type alias here.
// No new functions are necessary.
doTemplate(`
type _{{ .Type | TypeSymbol }}__ReprAssembler = _{{ .Type | TypeSymbol }}__Assembler
`, w, g.AdjCfg, g)
}
func (boolReprBoolReprBuilderGenerator) EmitNodeAssemblerMethodBeginMap(io.Writer) {}
func (boolReprBoolReprBuilderGenerator) EmitNodeAssemblerMethodBeginList(io.Writer) {}
func (boolReprBoolReprBuilderGenerator) EmitNodeAssemblerMethodAssignNull(io.Writer) {}
func (boolReprBoolReprBuilderGenerator) EmitNodeAssemblerMethodAssignBool(io.Writer) {}
func (boolReprBoolReprBuilderGenerator) EmitNodeAssemblerMethodAssignInt(io.Writer) {}
func (boolReprBoolReprBuilderGenerator) EmitNodeAssemblerMethodAssignFloat(io.Writer) {}
func (boolReprBoolReprBuilderGenerator) EmitNodeAssemblerMethodAssignString(io.Writer) {}
func (boolReprBoolReprBuilderGenerator) EmitNodeAssemblerMethodAssignBytes(io.Writer) {}
func (boolReprBoolReprBuilderGenerator) EmitNodeAssemblerMethodAssignLink(io.Writer) {}
func (boolReprBoolReprBuilderGenerator) EmitNodeAssemblerMethodAssignNode(io.Writer) {}
func (boolReprBoolReprBuilderGenerator) EmitNodeAssemblerMethodStyle(io.Writer) {}
func (boolReprBoolReprBuilderGenerator) EmitNodeAssemblerOtherBits(io.Writer) {}
package gengo
import (
"io"
"github.com/ipld/go-ipld-prime/schema"
"github.com/ipld/go-ipld-prime/schema/gen/go/mixins"
)
type bytesGenerator struct {
AdjCfg *AdjunctCfg
mixins.BytesTraits
PkgName string
Type schema.TypeBytes
}
// --- native content and specializations --->
func (g bytesGenerator) EmitNativeType(w io.Writer) {
emitNativeType_scalar(w, g.AdjCfg, g)
}
func (g bytesGenerator) EmitNativeAccessors(w io.Writer) {
emitNativeAccessors_scalar(w, g.AdjCfg, g)
}
func (g bytesGenerator) EmitNativeBuilder(w io.Writer) {
emitNativeBuilder_scalar(w, g.AdjCfg, g)
}
func (g bytesGenerator) EmitNativeMaybe(w io.Writer) {
emitNativeMaybe(w, g.AdjCfg, g)
}
// --- type info --->
func (g bytesGenerator) EmitTypeConst(w io.Writer) {
doTemplate(`
// TODO EmitTypeConst
`, w, g.AdjCfg, g)
}
// --- TypedNode byteserface satisfaction --->
func (g bytesGenerator) EmitTypedNodeMethodType(w io.Writer) {
doTemplate(`
func ({{ .Type | TypeSymbol }}) Type() schema.Type {
return nil /*TODO:typelit*/
}
`, w, g.AdjCfg, g)
}
func (g bytesGenerator) EmitTypedNodeMethodRepresentation(w io.Writer) {
emitTypicalTypedNodeMethodRepresentation(w, g.AdjCfg, g)
}
// --- Node byteserface satisfaction --->
func (g bytesGenerator) EmitNodeType(w io.Writer) {
// No additional types needed. Methods all attach to the native type.
}
func (g bytesGenerator) EmitNodeTypeAssertions(w io.Writer) {
emitNodeTypeAssertions_typical(w, g.AdjCfg, g)
}
func (g bytesGenerator) EmitNodeMethodAsBytes(w io.Writer) {
emitNodeMethodAsKind_scalar(w, g.AdjCfg, g)
}
func (g bytesGenerator) EmitNodeMethodStyle(w io.Writer) {
emitNodeMethodStyle_typical(w, g.AdjCfg, g)
}
func (g bytesGenerator) EmitNodeStyleType(w io.Writer) {
emitNodeStyleType_typical(w, g.AdjCfg, g)
}
// --- NodeBuilder and NodeAssembler --->
func (g bytesGenerator) GetNodeBuilderGenerator() NodeBuilderGenerator {
return bytesBuilderGenerator{
g.AdjCfg,
mixins.BytesAssemblerTraits{
g.PkgName,
g.TypeName,
"_" + g.AdjCfg.TypeSymbol(g.Type) + "__",
},
g.PkgName,
g.Type,
}
}
type bytesBuilderGenerator struct {
AdjCfg *AdjunctCfg
mixins.BytesAssemblerTraits
PkgName string
Type schema.TypeBytes
}
func (bytesBuilderGenerator) IsRepr() bool { return false } // hbytes used in some generalized templates.
func (g bytesBuilderGenerator) EmitNodeBuilderType(w io.Writer) {
emitEmitNodeBuilderType_typical(w, g.AdjCfg, g)
}
func (g bytesBuilderGenerator) EmitNodeBuilderMethods(w io.Writer) {
emitNodeBuilderMethods_typical(w, g.AdjCfg, g)
}
func (g bytesBuilderGenerator) EmitNodeAssemblerType(w io.Writer) {
emitNodeAssemblerType_scalar(w, g.AdjCfg, g)
}
func (g bytesBuilderGenerator) EmitNodeAssemblerMethodAssignNull(w io.Writer) {
emitNodeAssemblerMethodAssignNull_scalar(w, g.AdjCfg, g)
}
func (g bytesBuilderGenerator) EmitNodeAssemblerMethodAssignBytes(w io.Writer) {
emitNodeAssemblerMethodAssignKind_scalar(w, g.AdjCfg, g)
}
func (g bytesBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w io.Writer) {
emitNodeAssemblerMethodAssignNode_scalar(w, g.AdjCfg, g)
}
func (g bytesBuilderGenerator) EmitNodeAssemblerOtherBits(w io.Writer) {
// Nothing needed here for bytes kinds.
}
package gengo
import (
"io"
"github.com/ipld/go-ipld-prime/schema"
"github.com/ipld/go-ipld-prime/schema/gen/go/mixins"
)
var _ TypeGenerator = &bytesReprBytesGenerator{}
func NewBytesReprBytesGenerator(pkgName string, typ schema.TypeBytes, adjCfg *AdjunctCfg) TypeGenerator {
return bytesReprBytesGenerator{
bytesGenerator{
adjCfg,
mixins.BytesTraits{
pkgName,
string(typ.Name()),
adjCfg.TypeSymbol(typ),
},
pkgName,
typ,
},
}
}
type bytesReprBytesGenerator struct {
bytesGenerator
}
func (g bytesReprBytesGenerator) GetRepresentationNodeGen() NodeGenerator {
return bytesReprBytesReprGenerator{
g.AdjCfg,
g.Type,
}
}
type bytesReprBytesReprGenerator struct {
AdjCfg *AdjunctCfg
Type schema.TypeBytes
}
func (g bytesReprBytesReprGenerator) EmitNodeType(w io.Writer) {
// Since this is a "natural" representation... there's just a type alias here.
// No new functions are necessary.
doTemplate(`
type _{{ .Type | TypeSymbol }}__Repr = _{{ .Type | TypeSymbol }}
`, w, g.AdjCfg, g)
}
func (g bytesReprBytesReprGenerator) EmitNodeTypeAssertions(w io.Writer) {
doTemplate(`
var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{}
`, w, g.AdjCfg, g)
}
func (bytesReprBytesReprGenerator) EmitNodeMethodReprKind(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodLookupString(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodLookup(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodLookupIndex(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodLookupSegment(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodMapIterator(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodListIterator(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodLength(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodIsUndefined(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodIsNull(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodAsBool(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodAsInt(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodAsFloat(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodAsString(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodAsBytes(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodAsLink(io.Writer) {}
func (bytesReprBytesReprGenerator) EmitNodeMethodStyle(io.Writer) {}
func (g bytesReprBytesReprGenerator) EmitNodeStyleType(w io.Writer) {
// Since this is a "natural" representation... there's just a type alias here.
// No new functions are necessary.
doTemplate(`
type _{{ .Type | TypeSymbol }}__ReprStyle = _{{ .Type | TypeSymbol }}__Style
`, w, g.AdjCfg, g)
}
func (g bytesReprBytesReprGenerator) GetNodeBuilderGenerator() NodeBuilderGenerator {
return bytesReprBytesReprBuilderGenerator{g.AdjCfg, g.Type}
}
type bytesReprBytesReprBuilderGenerator struct {
AdjCfg *AdjunctCfg
Type schema.TypeBytes
}
func (bytesReprBytesReprBuilderGenerator) EmitNodeBuilderType(io.Writer) {}
func (bytesReprBytesReprBuilderGenerator) EmitNodeBuilderMethods(io.Writer) {}
func (g bytesReprBytesReprBuilderGenerator) EmitNodeAssemblerType(w io.Writer) {
// Since this is a "natural" representation... there's just a type alias here.
// No new functions are necessary.
doTemplate(`
type _{{ .Type | TypeSymbol }}__ReprAssembler = _{{ .Type | TypeSymbol }}__Assembler
`, w, g.AdjCfg, g)
}
func (bytesReprBytesReprBuilderGenerator) EmitNodeAssemblerMethodBeginMap(io.Writer) {}
func (bytesReprBytesReprBuilderGenerator) EmitNodeAssemblerMethodBeginList(io.Writer) {}
func (bytesReprBytesReprBuilderGenerator) EmitNodeAssemblerMethodAssignNull(io.Writer) {}
func (bytesReprBytesReprBuilderGenerator) EmitNodeAssemblerMethodAssignBool(io.Writer) {}
func (bytesReprBytesReprBuilderGenerator) EmitNodeAssemblerMethodAssignInt(io.Writer) {}
func (bytesReprBytesReprBuilderGenerator) EmitNodeAssemblerMethodAssignFloat(io.Writer) {}
func (bytesReprBytesReprBuilderGenerator) EmitNodeAssemblerMethodAssignString(io.Writer) {}
func (bytesReprBytesReprBuilderGenerator) EmitNodeAssemblerMethodAssignBytes(io.Writer) {}
func (bytesReprBytesReprBuilderGenerator) EmitNodeAssemblerMethodAssignLink(io.Writer) {}
func (bytesReprBytesReprBuilderGenerator) EmitNodeAssemblerMethodAssignNode(io.Writer) {}
func (bytesReprBytesReprBuilderGenerator) EmitNodeAssemblerMethodStyle(io.Writer) {}
func (bytesReprBytesReprBuilderGenerator) EmitNodeAssemblerOtherBits(io.Writer) {}
package gengo
import (
"io"
"github.com/ipld/go-ipld-prime/schema"
"github.com/ipld/go-ipld-prime/schema/gen/go/mixins"
)
type float64Generator struct {
AdjCfg *AdjunctCfg
mixins.FloatTraits
PkgName string
Type schema.TypeFloat
}
// --- native content and specializations --->
func (g float64Generator) EmitNativeType(w io.Writer) {
emitNativeType_scalar(w, g.AdjCfg, g)
}
func (g float64Generator) EmitNativeAccessors(w io.Writer) {
emitNativeAccessors_scalar(w, g.AdjCfg, g)
}
func (g float64Generator) EmitNativeBuilder(w io.Writer) {
emitNativeBuilder_scalar(w, g.AdjCfg, g)
}
func (g float64Generator) EmitNativeMaybe(w io.Writer) {
emitNativeMaybe(w, g.AdjCfg, g)
}
// --- type info --->
func (g float64Generator) EmitTypeConst(w io.Writer) {
doTemplate(`
// TODO EmitTypeConst
`, w, g.AdjCfg, g)
}
// --- TypedNode float64erface satisfaction --->
func (g float64Generator) EmitTypedNodeMethodType(w io.Writer) {
doTemplate(`
func ({{ .Type | TypeSymbol }}) Type() schema.Type {
return nil /*TODO:typelit*/
}
`, w, g.AdjCfg, g)
}
func (g float64Generator) EmitTypedNodeMethodRepresentation(w io.Writer) {
emitTypicalTypedNodeMethodRepresentation(w, g.AdjCfg, g)
}
// --- Node float64erface satisfaction --->
func (g float64Generator) EmitNodeType(w io.Writer) {
// No additional types needed. Methods all attach to the native type.
}
func (g float64Generator) EmitNodeTypeAssertions(w io.Writer) {
emitNodeTypeAssertions_typical(w, g.AdjCfg, g)
}
func (g float64Generator) EmitNodeMethodAsFloat(w io.Writer) {
emitNodeMethodAsKind_scalar(w, g.AdjCfg, g)
}
func (g float64Generator) EmitNodeMethodStyle(w io.Writer) {
emitNodeMethodStyle_typical(w, g.AdjCfg, g)
}
func (g float64Generator) EmitNodeStyleType(w io.Writer) {
emitNodeStyleType_typical(w, g.AdjCfg, g)
}
// --- NodeBuilder and NodeAssembler --->
func (g float64Generator) GetNodeBuilderGenerator() NodeBuilderGenerator {
return float64BuilderGenerator{
g.AdjCfg,
mixins.FloatAssemblerTraits{
g.PkgName,
g.TypeName,
"_" + g.AdjCfg.TypeSymbol(g.Type) + "__",
},
g.PkgName,
g.Type,
}
}
type float64BuilderGenerator struct {
AdjCfg *AdjunctCfg
mixins.FloatAssemblerTraits
PkgName string
Type schema.TypeFloat
}
func (float64BuilderGenerator) IsRepr() bool { return false } // hfloat64 used in some generalized templates.
func (g float64BuilderGenerator) EmitNodeBuilderType(w io.Writer) {
emitEmitNodeBuilderType_typical(w, g.AdjCfg, g)
}
func (g float64BuilderGenerator) EmitNodeBuilderMethods(w io.Writer) {
emitNodeBuilderMethods_typical(w, g.AdjCfg, g)
}
func (g float64BuilderGenerator) EmitNodeAssemblerType(w io.Writer) {
emitNodeAssemblerType_scalar(w, g.AdjCfg, g)
}
func (g float64BuilderGenerator) EmitNodeAssemblerMethodAssignNull(w io.Writer) {
emitNodeAssemblerMethodAssignNull_scalar(w, g.AdjCfg, g)
}
func (g float64BuilderGenerator) EmitNodeAssemblerMethodAssignFloat(w io.Writer) {
emitNodeAssemblerMethodAssignKind_scalar(w, g.AdjCfg, g)
}
func (g float64BuilderGenerator) EmitNodeAssemblerMethodAssignNode(w io.Writer) {
emitNodeAssemblerMethodAssignNode_scalar(w, g.AdjCfg, g)
}
func (g float64BuilderGenerator) EmitNodeAssemblerOtherBits(w io.Writer) {
// Nothing needed here for float64 kinds.
}
package gengo
import (
"io"
"github.com/ipld/go-ipld-prime/schema"
"github.com/ipld/go-ipld-prime/schema/gen/go/mixins"
)
var _ TypeGenerator = &float64ReprFloatGenerator{}
func NewFloatReprFloatGenerator(pkgName string, typ schema.TypeFloat, adjCfg *AdjunctCfg) TypeGenerator {
return float64ReprFloatGenerator{
float64Generator{
adjCfg,
mixins.FloatTraits{
pkgName,
string(typ.Name()),
adjCfg.TypeSymbol(typ),
},
pkgName,
typ,
},
}
}
type float64ReprFloatGenerator struct {
float64Generator
}
func (g float64ReprFloatGenerator) GetRepresentationNodeGen() NodeGenerator {
return float64ReprFloatReprGenerator{
g.AdjCfg,
g.Type,
}
}
type float64ReprFloatReprGenerator struct {
AdjCfg *AdjunctCfg
Type schema.TypeFloat
}
func (g float64ReprFloatReprGenerator) EmitNodeType(w io.Writer) {
// Since this is a "natural" representation... there's just a type alias here.
// No new functions are necessary.
doTemplate(`
type _{{ .Type | TypeSymbol }}__Repr = _{{ .Type | TypeSymbol }}
`, w, g.AdjCfg, g)
}
func (g float64ReprFloatReprGenerator) EmitNodeTypeAssertions(w io.Writer) {
doTemplate(`
var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{}
`, w, g.AdjCfg, g)
}
func (float64ReprFloatReprGenerator) EmitNodeMethodReprKind(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodLookupString(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodLookup(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodLookupIndex(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodLookupSegment(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodMapIterator(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodListIterator(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodLength(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodIsUndefined(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodIsNull(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodAsBool(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodAsInt(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodAsFloat(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodAsString(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodAsBytes(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodAsLink(io.Writer) {}
func (float64ReprFloatReprGenerator) EmitNodeMethodStyle(io.Writer) {}
func (g float64ReprFloatReprGenerator) EmitNodeStyleType(w io.Writer) {
// Since this is a "natural" representation... there's just a type alias here.
// No new functions are necessary.
doTemplate(`
type _{{ .Type | TypeSymbol }}__ReprStyle = _{{ .Type | TypeSymbol }}__Style
`, w, g.AdjCfg, g)
}
func (g float64ReprFloatReprGenerator) GetNodeBuilderGenerator() NodeBuilderGenerator {
return float64ReprFloatReprBuilderGenerator{g.AdjCfg, g.Type}
}
type float64ReprFloatReprBuilderGenerator struct {
AdjCfg *AdjunctCfg
Type schema.TypeFloat
}
func (float64ReprFloatReprBuilderGenerator) EmitNodeBuilderType(io.Writer) {}
func (float64ReprFloatReprBuilderGenerator) EmitNodeBuilderMethods(io.Writer) {}
func (g float64ReprFloatReprBuilderGenerator) EmitNodeAssemblerType(w io.Writer) {
// Since this is a "natural" representation... there's just a type alias here.
// No new functions are necessary.
doTemplate(`
type _{{ .Type | TypeSymbol }}__ReprAssembler = _{{ .Type | TypeSymbol }}__Assembler
`, w, g.AdjCfg, g)
}
func (float64ReprFloatReprBuilderGenerator) EmitNodeAssemblerMethodBeginMap(io.Writer) {}
func (float64ReprFloatReprBuilderGenerator) EmitNodeAssemblerMethodBeginList(io.Writer) {}
func (float64ReprFloatReprBuilderGenerator) EmitNodeAssemblerMethodAssignNull(io.Writer) {}
func (float64ReprFloatReprBuilderGenerator) EmitNodeAssemblerMethodAssignBool(io.Writer) {}
func (float64ReprFloatReprBuilderGenerator) EmitNodeAssemblerMethodAssignInt(io.Writer) {}
func (float64ReprFloatReprBuilderGenerator) EmitNodeAssemblerMethodAssignFloat(io.Writer) {}
func (float64ReprFloatReprBuilderGenerator) EmitNodeAssemblerMethodAssignString(io.Writer) {}
func (float64ReprFloatReprBuilderGenerator) EmitNodeAssemblerMethodAssignBytes(io.Writer) {}
func (float64ReprFloatReprBuilderGenerator) EmitNodeAssemblerMethodAssignLink(io.Writer) {}
func (float64ReprFloatReprBuilderGenerator) EmitNodeAssemblerMethodAssignNode(io.Writer) {}
func (float64ReprFloatReprBuilderGenerator) EmitNodeAssemblerMethodStyle(io.Writer) {}
func (float64ReprFloatReprBuilderGenerator) EmitNodeAssemblerOtherBits(io.Writer) {}
package gengo
import (
"io"
"github.com/ipld/go-ipld-prime/schema"
"github.com/ipld/go-ipld-prime/schema/gen/go/mixins"
)
type linkGenerator struct {
AdjCfg *AdjunctCfg
mixins.LinkTraits
PkgName string
Type schema.TypeLink
}
// --- native content and specializations --->
func (g linkGenerator) EmitNativeType(w io.Writer) {
emitNativeType_scalar(w, g.AdjCfg, g)
}
func (g linkGenerator) EmitNativeAccessors(w io.Writer) {
emitNativeAccessors_scalar(w, g.AdjCfg, g)
}
func (g linkGenerator) EmitNativeBuilder(w io.Writer) {
emitNativeBuilder_scalar(w, g.AdjCfg, g)
}
func (g linkGenerator) EmitNativeMaybe(w io.Writer) {
emitNativeMaybe(w, g.AdjCfg, g)
}
// --- type info --->
func (g linkGenerator) EmitTypeConst(w io.Writer) {
doTemplate(`
// TODO EmitTypeConst
`, w, g.AdjCfg, g)
}
// --- TypedNode linkerface satisfaction --->
func (g linkGenerator) EmitTypedNodeMethodType(w io.Writer) {
doTemplate(`
func ({{ .Type | TypeSymbol }}) Type() schema.Type {
return nil /*TODO:typelit*/
}
`, w, g.AdjCfg, g)
}
func (g linkGenerator) EmitTypedNodeMethodRepresentation(w io.Writer) {
emitTypicalTypedNodeMethodRepresentation(w, g.AdjCfg, g)
}
// --- Node linkerface satisfaction --->
func (g linkGenerator) EmitNodeType(w io.Writer) {
// No additional types needed. Methods all attach to the native type.
}
func (g linkGenerator) EmitNodeTypeAssertions(w io.Writer) {
emitNodeTypeAssertions_typical(w, g.AdjCfg, g)
}
func (g linkGenerator) EmitNodeMethodAsLink(w io.Writer) {
emitNodeMethodAsKind_scalar(w, g.AdjCfg, g)
}
func (g linkGenerator) EmitNodeMethodStyle(w io.Writer) {
emitNodeMethodStyle_typical(w, g.AdjCfg, g)
}
func (g linkGenerator) EmitNodeStyleType(w io.Writer) {
emitNodeStyleType_typical(w, g.AdjCfg, g)
}
// --- NodeBuilder and NodeAssembler --->
func (g linkGenerator) GetNodeBuilderGenerator() NodeBuilderGenerator {
return linkBuilderGenerator{
g.AdjCfg,
mixins.LinkAssemblerTraits{
g.PkgName,
g.TypeName,
"_" + g.AdjCfg.TypeSymbol(g.Type) + "__",
},
g.PkgName,
g.Type,
}
}
type linkBuilderGenerator struct {
AdjCfg *AdjunctCfg
mixins.LinkAssemblerTraits
PkgName string
Type schema.TypeLink
}
func (linkBuilderGenerator) IsRepr() bool { return false } // hlink used in some generalized templates.
func (g linkBuilderGenerator) EmitNodeBuilderType(w io.Writer) {
emitEmitNodeBuilderType_typical(w, g.AdjCfg, g)
}
func (g linkBuilderGenerator) EmitNodeBuilderMethods(w io.Writer) {
emitNodeBuilderMethods_typical(w, g.AdjCfg, g)
}
func (g linkBuilderGenerator) EmitNodeAssemblerType(w io.Writer) {
emitNodeAssemblerType_scalar(w, g.AdjCfg, g)
}
func (g linkBuilderGenerator) EmitNodeAssemblerMethodAssignNull(w io.Writer) {
emitNodeAssemblerMethodAssignNull_scalar(w, g.AdjCfg, g)
}
func (g linkBuilderGenerator) EmitNodeAssemblerMethodAssignLink(w io.Writer) {
emitNodeAssemblerMethodAssignKind_scalar(w, g.AdjCfg, g)
}
func (g linkBuilderGenerator) EmitNodeAssemblerMethodAssignNode(w io.Writer) {
emitNodeAssemblerMethodAssignNode_scalar(w, g.AdjCfg, g)
}
func (g linkBuilderGenerator) EmitNodeAssemblerOtherBits(w io.Writer) {
// Nothing needed here for link kinds.
}
package gengo
import (
"io"
"github.com/ipld/go-ipld-prime/schema"
"github.com/ipld/go-ipld-prime/schema/gen/go/mixins"
)
var _ TypeGenerator = &linkReprLinkGenerator{}
func NewLinkReprLinkGenerator(pkgName string, typ schema.TypeLink, adjCfg *AdjunctCfg) TypeGenerator {
return linkReprLinkGenerator{
linkGenerator{
adjCfg,
mixins.LinkTraits{
pkgName,
string(typ.Name()),
adjCfg.TypeSymbol(typ),
},
pkgName,
typ,
},
}
}
type linkReprLinkGenerator struct {
linkGenerator
}
func (g linkReprLinkGenerator) GetRepresentationNodeGen() NodeGenerator {
return linkReprLinkReprGenerator{
g.AdjCfg,
g.Type,
}
}
type linkReprLinkReprGenerator struct {
AdjCfg *AdjunctCfg
Type schema.TypeLink
}
func (g linkReprLinkReprGenerator) EmitNodeType(w io.Writer) {
// Since this is a "natural" representation... there's just a type alias here.
// No new functions are necessary.
doTemplate(`
type _{{ .Type | TypeSymbol }}__Repr = _{{ .Type | TypeSymbol }}
`, w, g.AdjCfg, g)
}
func (g linkReprLinkReprGenerator) EmitNodeTypeAssertions(w io.Writer) {
doTemplate(`
var _ ipld.Node = &_{{ .Type | TypeSymbol }}__Repr{}
`, w, g.AdjCfg, g)
}
func (linkReprLinkReprGenerator) EmitNodeMethodReprKind(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodLookupString(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodLookup(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodLookupIndex(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodLookupSegment(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodMapIterator(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodListIterator(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodLength(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodIsUndefined(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodIsNull(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodAsBool(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodAsInt(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodAsFloat(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodAsString(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodAsBytes(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodAsLink(io.Writer) {}
func (linkReprLinkReprGenerator) EmitNodeMethodStyle(io.Writer) {}
func (g linkReprLinkReprGenerator) EmitNodeStyleType(w io.Writer) {
// Since this is a "natural" representation... there's just a type alias here.
// No new functions are necessary.
doTemplate(`
type _{{ .Type | TypeSymbol }}__ReprStyle = _{{ .Type | TypeSymbol }}__Style
`, w, g.AdjCfg, g)
}
func (g linkReprLinkReprGenerator) GetNodeBuilderGenerator() NodeBuilderGenerator {
return linkReprLinkReprBuilderGenerator{g.AdjCfg, g.Type}
}
type linkReprLinkReprBuilderGenerator struct {
AdjCfg *AdjunctCfg
Type schema.TypeLink
}
func (linkReprLinkReprBuilderGenerator) EmitNodeBuilderType(io.Writer) {}
func (linkReprLinkReprBuilderGenerator) EmitNodeBuilderMethods(io.Writer) {}
func (g linkReprLinkReprBuilderGenerator) EmitNodeAssemblerType(w io.Writer) {
// Since this is a "natural" representation... there's just a type alias here.
// No new functions are necessary.
doTemplate(`
type _{{ .Type | TypeSymbol }}__ReprAssembler = _{{ .Type | TypeSymbol }}__Assembler
`, w, g.AdjCfg, g)
}
func (linkReprLinkReprBuilderGenerator) EmitNodeAssemblerMethodBeginMap(io.Writer) {}
func (linkReprLinkReprBuilderGenerator) EmitNodeAssemblerMethodBeginList(io.Writer) {}
func (linkReprLinkReprBuilderGenerator) EmitNodeAssemblerMethodAssignNull(io.Writer) {}
func (linkReprLinkReprBuilderGenerator) EmitNodeAssemblerMethodAssignBool(io.Writer) {}
func (linkReprLinkReprBuilderGenerator) EmitNodeAssemblerMethodAssignInt(io.Writer) {}
func (linkReprLinkReprBuilderGenerator) EmitNodeAssemblerMethodAssignFloat(io.Writer) {}
func (linkReprLinkReprBuilderGenerator) EmitNodeAssemblerMethodAssignString(io.Writer) {}
func (linkReprLinkReprBuilderGenerator) EmitNodeAssemblerMethodAssignBytes(io.Writer) {}
func (linkReprLinkReprBuilderGenerator) EmitNodeAssemblerMethodAssignLink(io.Writer) {}
func (linkReprLinkReprBuilderGenerator) EmitNodeAssemblerMethodAssignNode(io.Writer) {}
func (linkReprLinkReprBuilderGenerator) EmitNodeAssemblerMethodStyle(io.Writer) {}
func (linkReprLinkReprBuilderGenerator) EmitNodeAssemblerOtherBits(io.Writer) {}
......@@ -19,10 +19,18 @@ func Generate(pth string, pkgName string, ts schema.TypeSystem, adjCfg *AdjunctC
withFile(filepath.Join(pth, "t"+typ.Name().String()+".go"), func(f io.Writer) {
EmitFileHeader(pkgName, f)
switch t2 := typ.(type) {
case schema.TypeBool:
EmitEntireType(NewBoolReprBoolGenerator(pkgName, t2, adjCfg), f)
case schema.TypeInt:
EmitEntireType(NewIntReprIntGenerator(pkgName, t2, adjCfg), f)
case schema.TypeFloat:
EmitEntireType(NewFloatReprFloatGenerator(pkgName, t2, adjCfg), f)
case schema.TypeString:
EmitEntireType(NewStringReprStringGenerator(pkgName, t2, adjCfg), f)
case schema.TypeBytes:
EmitEntireType(NewBytesReprBytesGenerator(pkgName, t2, adjCfg), f)
case schema.TypeLink:
EmitEntireType(NewLinkReprLinkGenerator(pkgName, t2, adjCfg), f)
case schema.TypeStruct:
switch t2.RepresentationStrategy().(type) {
case schema.StructRepresentation_Map:
......
package mixins
import (
"io"
ipld "github.com/ipld/go-ipld-prime"
)
type BoolTraits struct {
PkgName string
TypeName string // see doc in kindTraitsGenerator
TypeSymbol string // see doc in kindTraitsGenerator
}
func (BoolTraits) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Bool
}
func (g BoolTraits) EmitNodeMethodReprKind(w io.Writer) {
doTemplate(`
func ({{ .TypeSymbol }}) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Bool
}
`, w, g)
}
func (g BoolTraits) EmitNodeMethodLookupString(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bool}.emitNodeMethodLookupString(w)
}
func (g BoolTraits) EmitNodeMethodLookup(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bool}.emitNodeMethodLookup(w)
}
func (g BoolTraits) EmitNodeMethodLookupIndex(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bool}.emitNodeMethodLookupIndex(w)
}
func (g BoolTraits) EmitNodeMethodLookupSegment(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bool}.emitNodeMethodLookupSegment(w)
}
func (g BoolTraits) EmitNodeMethodMapIterator(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bool}.emitNodeMethodMapIterator(w)
}
func (g BoolTraits) EmitNodeMethodListIterator(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bool}.emitNodeMethodListIterator(w)
}
func (g BoolTraits) EmitNodeMethodLength(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bool}.emitNodeMethodLength(w)
}
func (g BoolTraits) EmitNodeMethodIsUndefined(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bool}.emitNodeMethodIsUndefined(w)
}
func (g BoolTraits) EmitNodeMethodIsNull(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bool}.emitNodeMethodIsNull(w)
}
func (g BoolTraits) EmitNodeMethodAsInt(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bool}.emitNodeMethodAsInt(w)
}
func (g BoolTraits) EmitNodeMethodAsFloat(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bool}.emitNodeMethodAsFloat(w)
}
func (g BoolTraits) EmitNodeMethodAsString(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bool}.emitNodeMethodAsString(w)
}
func (g BoolTraits) EmitNodeMethodAsBytes(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bool}.emitNodeMethodAsBytes(w)
}
func (g BoolTraits) EmitNodeMethodAsLink(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bool}.emitNodeMethodAsLink(w)
}
type BoolAssemblerTraits struct {
PkgName string
TypeName string // see doc in kindAssemblerTraitsGenerator
AppliedPrefix string // see doc in kindAssemblerTraitsGenerator
}
func (BoolAssemblerTraits) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Bool
}
func (g BoolAssemblerTraits) EmitNodeAssemblerMethodBeginMap(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bool}.emitNodeAssemblerMethodBeginMap(w)
}
func (g BoolAssemblerTraits) EmitNodeAssemblerMethodBeginList(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bool}.emitNodeAssemblerMethodBeginList(w)
}
func (g BoolAssemblerTraits) EmitNodeAssemblerMethodAssignNull(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bool}.emitNodeAssemblerMethodAssignNull(w)
}
func (g BoolAssemblerTraits) EmitNodeAssemblerMethodAssignInt(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bool}.emitNodeAssemblerMethodAssignInt(w)
}
func (g BoolAssemblerTraits) EmitNodeAssemblerMethodAssignFloat(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bool}.emitNodeAssemblerMethodAssignFloat(w)
}
func (g BoolAssemblerTraits) EmitNodeAssemblerMethodAssignString(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bool}.emitNodeAssemblerMethodAssignString(w)
}
func (g BoolAssemblerTraits) EmitNodeAssemblerMethodAssignBytes(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bool}.emitNodeAssemblerMethodAssignBytes(w)
}
func (g BoolAssemblerTraits) EmitNodeAssemblerMethodAssignLink(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bool}.emitNodeAssemblerMethodAssignLink(w)
}
func (g BoolAssemblerTraits) EmitNodeAssemblerMethodStyle(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bool}.emitNodeAssemblerMethodStyle(w)
}
package mixins
import (
"io"
ipld "github.com/ipld/go-ipld-prime"
)
type BytesTraits struct {
PkgName string
TypeName string // see doc in kindTraitsGenerator
TypeSymbol string // see doc in kindTraitsGenerator
}
func (BytesTraits) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Bytes
}
func (g BytesTraits) EmitNodeMethodReprKind(w io.Writer) {
doTemplate(`
func ({{ .TypeSymbol }}) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Bytes
}
`, w, g)
}
func (g BytesTraits) EmitNodeMethodLookupString(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bytes}.emitNodeMethodLookupString(w)
}
func (g BytesTraits) EmitNodeMethodLookup(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bytes}.emitNodeMethodLookup(w)
}
func (g BytesTraits) EmitNodeMethodLookupIndex(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bytes}.emitNodeMethodLookupIndex(w)
}
func (g BytesTraits) EmitNodeMethodLookupSegment(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bytes}.emitNodeMethodLookupSegment(w)
}
func (g BytesTraits) EmitNodeMethodMapIterator(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bytes}.emitNodeMethodMapIterator(w)
}
func (g BytesTraits) EmitNodeMethodListIterator(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bytes}.emitNodeMethodListIterator(w)
}
func (g BytesTraits) EmitNodeMethodLength(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bytes}.emitNodeMethodLength(w)
}
func (g BytesTraits) EmitNodeMethodIsUndefined(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bytes}.emitNodeMethodIsUndefined(w)
}
func (g BytesTraits) EmitNodeMethodIsNull(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bytes}.emitNodeMethodIsNull(w)
}
func (g BytesTraits) EmitNodeMethodAsBool(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bytes}.emitNodeMethodAsBool(w)
}
func (g BytesTraits) EmitNodeMethodAsInt(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bytes}.emitNodeMethodAsInt(w)
}
func (g BytesTraits) EmitNodeMethodAsFloat(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bytes}.emitNodeMethodAsFloat(w)
}
func (g BytesTraits) EmitNodeMethodAsString(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bytes}.emitNodeMethodAsString(w)
}
func (g BytesTraits) EmitNodeMethodAsLink(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Bytes}.emitNodeMethodAsLink(w)
}
type BytesAssemblerTraits struct {
PkgName string
TypeName string // see doc in kindAssemblerTraitsGenerator
AppliedPrefix string // see doc in kindAssemblerTraitsGenerator
}
func (BytesAssemblerTraits) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Bytes
}
func (g BytesAssemblerTraits) EmitNodeAssemblerMethodBeginMap(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bytes}.emitNodeAssemblerMethodBeginMap(w)
}
func (g BytesAssemblerTraits) EmitNodeAssemblerMethodBeginList(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bytes}.emitNodeAssemblerMethodBeginList(w)
}
func (g BytesAssemblerTraits) EmitNodeAssemblerMethodAssignNull(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bytes}.emitNodeAssemblerMethodAssignNull(w)
}
func (g BytesAssemblerTraits) EmitNodeAssemblerMethodAssignBool(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bytes}.emitNodeAssemblerMethodAssignBool(w)
}
func (g BytesAssemblerTraits) EmitNodeAssemblerMethodAssignInt(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bytes}.emitNodeAssemblerMethodAssignInt(w)
}
func (g BytesAssemblerTraits) EmitNodeAssemblerMethodAssignFloat(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bytes}.emitNodeAssemblerMethodAssignFloat(w)
}
func (g BytesAssemblerTraits) EmitNodeAssemblerMethodAssignString(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bytes}.emitNodeAssemblerMethodAssignString(w)
}
func (g BytesAssemblerTraits) EmitNodeAssemblerMethodAssignLink(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bytes}.emitNodeAssemblerMethodAssignLink(w)
}
func (g BytesAssemblerTraits) EmitNodeAssemblerMethodStyle(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Bytes}.emitNodeAssemblerMethodStyle(w)
}
package mixins
import (
"io"
ipld "github.com/ipld/go-ipld-prime"
)
type FloatTraits struct {
PkgName string
TypeName string // see doc in kindTraitsGenerator
TypeSymbol string // see doc in kindTraitsGenerator
}
func (FloatTraits) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Float
}
func (g FloatTraits) EmitNodeMethodReprKind(w io.Writer) {
doTemplate(`
func ({{ .TypeSymbol }}) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Float
}
`, w, g)
}
func (g FloatTraits) EmitNodeMethodLookupString(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Float}.emitNodeMethodLookupString(w)
}
func (g FloatTraits) EmitNodeMethodLookup(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Float}.emitNodeMethodLookup(w)
}
func (g FloatTraits) EmitNodeMethodLookupIndex(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Float}.emitNodeMethodLookupIndex(w)
}
func (g FloatTraits) EmitNodeMethodLookupSegment(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Float}.emitNodeMethodLookupSegment(w)
}
func (g FloatTraits) EmitNodeMethodMapIterator(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Float}.emitNodeMethodMapIterator(w)
}
func (g FloatTraits) EmitNodeMethodListIterator(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Float}.emitNodeMethodListIterator(w)
}
func (g FloatTraits) EmitNodeMethodLength(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Float}.emitNodeMethodLength(w)
}
func (g FloatTraits) EmitNodeMethodIsUndefined(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Float}.emitNodeMethodIsUndefined(w)
}
func (g FloatTraits) EmitNodeMethodIsNull(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Float}.emitNodeMethodIsNull(w)
}
func (g FloatTraits) EmitNodeMethodAsBool(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Float}.emitNodeMethodAsBool(w)
}
func (g FloatTraits) EmitNodeMethodAsInt(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Float}.emitNodeMethodAsInt(w)
}
func (g FloatTraits) EmitNodeMethodAsString(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Float}.emitNodeMethodAsString(w)
}
func (g FloatTraits) EmitNodeMethodAsBytes(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Float}.emitNodeMethodAsBytes(w)
}
func (g FloatTraits) EmitNodeMethodAsLink(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Float}.emitNodeMethodAsLink(w)
}
type FloatAssemblerTraits struct {
PkgName string
TypeName string // see doc in kindAssemblerTraitsGenerator
AppliedPrefix string // see doc in kindAssemblerTraitsGenerator
}
func (FloatAssemblerTraits) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Float
}
func (g FloatAssemblerTraits) EmitNodeAssemblerMethodBeginMap(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Float}.emitNodeAssemblerMethodBeginMap(w)
}
func (g FloatAssemblerTraits) EmitNodeAssemblerMethodBeginList(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Float}.emitNodeAssemblerMethodBeginList(w)
}
func (g FloatAssemblerTraits) EmitNodeAssemblerMethodAssignNull(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Float}.emitNodeAssemblerMethodAssignNull(w)
}
func (g FloatAssemblerTraits) EmitNodeAssemblerMethodAssignBool(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Float}.emitNodeAssemblerMethodAssignBool(w)
}
func (g FloatAssemblerTraits) EmitNodeAssemblerMethodAssignInt(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Float}.emitNodeAssemblerMethodAssignInt(w)
}
func (g FloatAssemblerTraits) EmitNodeAssemblerMethodAssignString(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Float}.emitNodeAssemblerMethodAssignString(w)
}
func (g FloatAssemblerTraits) EmitNodeAssemblerMethodAssignBytes(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Float}.emitNodeAssemblerMethodAssignBytes(w)
}
func (g FloatAssemblerTraits) EmitNodeAssemblerMethodAssignLink(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Float}.emitNodeAssemblerMethodAssignLink(w)
}
func (g FloatAssemblerTraits) EmitNodeAssemblerMethodStyle(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Float}.emitNodeAssemblerMethodStyle(w)
}
package mixins
import (
"io"
ipld "github.com/ipld/go-ipld-prime"
)
type LinkTraits struct {
PkgName string
TypeName string // see doc in kindTraitsGenerator
TypeSymbol string // see doc in kindTraitsGenerator
}
func (LinkTraits) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Link
}
func (g LinkTraits) EmitNodeMethodReprKind(w io.Writer) {
doTemplate(`
func ({{ .TypeSymbol }}) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Link
}
`, w, g)
}
func (g LinkTraits) EmitNodeMethodLookupString(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Link}.emitNodeMethodLookupString(w)
}
func (g LinkTraits) EmitNodeMethodLookup(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Link}.emitNodeMethodLookup(w)
}
func (g LinkTraits) EmitNodeMethodLookupIndex(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Link}.emitNodeMethodLookupIndex(w)
}
func (g LinkTraits) EmitNodeMethodLookupSegment(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Link}.emitNodeMethodLookupSegment(w)
}
func (g LinkTraits) EmitNodeMethodMapIterator(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Link}.emitNodeMethodMapIterator(w)
}
func (g LinkTraits) EmitNodeMethodListIterator(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Link}.emitNodeMethodListIterator(w)
}
func (g LinkTraits) EmitNodeMethodLength(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Link}.emitNodeMethodLength(w)
}
func (g LinkTraits) EmitNodeMethodIsUndefined(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Link}.emitNodeMethodIsUndefined(w)
}
func (g LinkTraits) EmitNodeMethodIsNull(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Link}.emitNodeMethodIsNull(w)
}
func (g LinkTraits) EmitNodeMethodAsBool(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Link}.emitNodeMethodAsBool(w)
}
func (g LinkTraits) EmitNodeMethodAsInt(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Link}.emitNodeMethodAsInt(w)
}
func (g LinkTraits) EmitNodeMethodAsFloat(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Link}.emitNodeMethodAsFloat(w)
}
func (g LinkTraits) EmitNodeMethodAsString(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Link}.emitNodeMethodAsString(w)
}
func (g LinkTraits) EmitNodeMethodAsBytes(w io.Writer) {
kindTraitsGenerator{g.PkgName, g.TypeName, g.TypeSymbol, ipld.ReprKind_Link}.emitNodeMethodAsBytes(w)
}
type LinkAssemblerTraits struct {
PkgName string
TypeName string // see doc in kindAssemblerTraitsGenerator
AppliedPrefix string // see doc in kindAssemblerTraitsGenerator
}
func (LinkAssemblerTraits) ReprKind() ipld.ReprKind {
return ipld.ReprKind_Link
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodBeginMap(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Link}.emitNodeAssemblerMethodBeginMap(w)
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodBeginList(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Link}.emitNodeAssemblerMethodBeginList(w)
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignNull(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Link}.emitNodeAssemblerMethodAssignNull(w)
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignBool(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Link}.emitNodeAssemblerMethodAssignBool(w)
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignInt(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Link}.emitNodeAssemblerMethodAssignInt(w)
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignFloat(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Link}.emitNodeAssemblerMethodAssignFloat(w)
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignString(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Link}.emitNodeAssemblerMethodAssignString(w)
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodAssignBytes(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Link}.emitNodeAssemblerMethodAssignBytes(w)
}
func (g LinkAssemblerTraits) EmitNodeAssemblerMethodStyle(w io.Writer) {
kindAssemblerTraitsGenerator{g.PkgName, g.TypeName, g.AppliedPrefix, ipld.ReprKind_Link}.emitNodeAssemblerMethodStyle(w)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment