Commit 25702f19 authored by Eric Myhre's avatar Eric Myhre

Add kinded rejections for map; fix typo for string

Signed-off-by: default avatarEric Myhre <hash@exultant.us>
parent f6e469ce
......@@ -82,8 +82,8 @@ func (generateKindedRejections) emitNodeMethodAsFloat(w io.Writer, t schema.Type
func (generateKindedRejections) emitNodeMethodAsString(w io.Writer, t schema.Type) {
doTemplate(`
func ({{ .Name }}) AsBytes() ([]byte, error) {
return nil, ipld.ErrWrongKind{MethodName: "{{ .Name }}.AsBytes", AppropriateKind: ipld.ReprKindSet_JustString, ActualKind: {{ .Kind.ActsLike | ReprKindConst }}}
func ({{ .Name }}) AsString() (string, error) {
return "", ipld.ErrWrongKind{MethodName: "{{ .Name }}.AsString", AppropriateKind: ipld.ReprKindSet_JustString, ActualKind: {{ .Kind.ActsLike | ReprKindConst }}}
}
`, w, t)
}
......@@ -142,3 +142,38 @@ func (gk generateKindedRejections_String) EmitNodeMethodAsBytes(w io.Writer) {
func (gk generateKindedRejections_String) EmitNodeMethodAsLink(w io.Writer) {
generateKindedRejections{}.emitNodeMethodAsLink(w, gk.Type)
}
// Embeddable to do all the "nope" methods at once.
//
// Used for anything that "acts like" map (so, also struct).
type generateKindedRejections_Map struct {
Type schema.Type // used so we can generate error messages with the type name.
}
func (gk generateKindedRejections_Map) EmitNodeMethodTraverseIndex(w io.Writer) {
generateKindedRejections{}.emitNodeMethodTraverseIndex(w, gk.Type)
}
func (gk generateKindedRejections_Map) EmitNodeMethodListIterator(w io.Writer) {
generateKindedRejections{}.emitNodeMethodListIterator(w, gk.Type)
}
func (gk generateKindedRejections_Map) EmitNodeMethodIsNull(w io.Writer) {
generateKindedRejections{}.emitNodeMethodIsNull(w, gk.Type)
}
func (gk generateKindedRejections_Map) EmitNodeMethodAsBool(w io.Writer) {
generateKindedRejections{}.emitNodeMethodAsBool(w, gk.Type)
}
func (gk generateKindedRejections_Map) EmitNodeMethodAsInt(w io.Writer) {
generateKindedRejections{}.emitNodeMethodAsInt(w, gk.Type)
}
func (gk generateKindedRejections_Map) EmitNodeMethodAsFloat(w io.Writer) {
generateKindedRejections{}.emitNodeMethodAsFloat(w, gk.Type)
}
func (gk generateKindedRejections_Map) EmitNodeMethodAsString(w io.Writer) {
generateKindedRejections{}.emitNodeMethodAsString(w, gk.Type)
}
func (gk generateKindedRejections_Map) EmitNodeMethodAsBytes(w io.Writer) {
generateKindedRejections{}.emitNodeMethodAsBytes(w, gk.Type)
}
func (gk generateKindedRejections_Map) EmitNodeMethodAsLink(w io.Writer) {
generateKindedRejections{}.emitNodeMethodAsLink(w, gk.Type)
}
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