Skip to content

Commit

Permalink
Merge pull request #91 from ipld/codegen-link-support-target-prototyp…
Browse files Browse the repository at this point in the history
…e-detection

Codegen for links should emit the methods to conform to the schema.TypedLinkNode interface where applicable.
  • Loading branch information
warpfork authored Oct 15, 2020
2 parents f978745 + 6de19b1 commit 6a41703
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions schema/gen/go/genLink.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ func (g linkGenerator) EmitTypedNodeMethodType(w io.Writer) {
return nil /*TODO:typelit*/
}
`, w, g.AdjCfg, g)

// Bonus feature for some links (conforms to the schema.TypedLinkNode interface):
if g.Type.HasReferencedType() {
doTemplate(`
func ({{ .Type | TypeSymbol }}) LinkTargetNodePrototype() ipld.NodePrototype {
return Type.{{ .Type | TypeSymbol }}__Repr
}
`, w, g.AdjCfg, g)
}
}

func (g linkGenerator) EmitTypedNodeMethodRepresentation(w io.Writer) {
Expand Down

0 comments on commit 6a41703

Please sign in to comment.