Commit 252cfea5 authored by Eric Myhre's avatar Eric Myhre

AssignLink reinstated in NodeAssembler.

(Probably should've done this a while ago.  Much earlier in this
research branch, I thought the design of Link/LinkBuilder etc might
get a review... but at this point, its clear there's plenty of
work already do to just sorting out the assembler situation, so
any rethinks of links is *definitely* deferred for future investigation
(if indeed anything ever happens there at all).)

Doing very partial fixes to the example "generated" maps;
just enough to compile.  I'm not intending to use them as a template
for actual codegen later, so their quality is irrelevant at this point.
parent 9519c700
......@@ -105,6 +105,9 @@ func (nb *anyBuilder) AssignString(v string) error {
func (nb *anyBuilder) AssignBytes(v []byte) error {
panic("soon")
}
func (nb *anyBuilder) AssignLink(v ipld.Link) error {
panic("soon")
}
func (nb *anyBuilder) AssignNode(v ipld.Node) error {
// TODO what to do here? should we just... keep it, in another `Node` field?
panic("soon")
......
......@@ -135,6 +135,9 @@ func (na *plainInt__Assembler) AssignNode(v ipld.Node) error {
return nil
}
}
func (plainInt__Assembler) AssignLink(ipld.Link) error {
return mixins.IntAssembler{"int"}.AssignLink(nil)
}
func (plainInt__Assembler) Style() ipld.NodeStyle {
return Style__Int{}
}
......@@ -197,6 +197,9 @@ func (na *plainMap__Assembler) AssignNode(v ipld.Node) error {
// (wait... actually, probably we can? 'Assign' is a "finish" method. we can&should invalidate the wip pointer here.)
panic("later")
}
func (plainMap__Assembler) AssignLink(ipld.Link) error {
return mixins.MapAssembler{"map"}.AssignLink(nil)
}
func (plainMap__Assembler) Style() ipld.NodeStyle { panic("later") }
// -- MapNodeAssembler -->
......@@ -301,6 +304,9 @@ func (mka *plainMap__KeyAssembler) AssignString(v string) error {
func (plainMap__KeyAssembler) AssignBytes([]byte) error {
return mixins.StringAssembler{"string"}.AssignBytes(nil)
}
func (plainMap__KeyAssembler) AssignLink(ipld.Link) error {
return mixins.StringAssembler{"string"}.AssignLink(nil)
}
func (mka *plainMap__KeyAssembler) AssignNode(v ipld.Node) error {
vs, err := v.AsString()
if err != nil {
......@@ -334,6 +340,7 @@ func (mva *plainMap__ValueAssembler) AssignString(v string) error {
return mva.AssignNode(&vb)
}
func (mva *plainMap__ValueAssembler) AssignBytes([]byte) error { panic("todo") }
func (mva *plainMap__ValueAssembler) AssignLink(ipld.Link) error { panic("todo") }
func (mva *plainMap__ValueAssembler) AssignNode(v ipld.Node) error {
l := len(mva.ma.w.t) - 1
mva.ma.w.t[l].v = v
......
......@@ -359,6 +359,7 @@ func (_Map_K_T__Assembler) AssignInt(v int) error { pa
func (_Map_K_T__Assembler) AssignFloat(float64) error { panic("no") }
func (_Map_K_T__Assembler) AssignString(v string) error { panic("no") }
func (_Map_K_T__Assembler) AssignBytes([]byte) error { panic("no") }
func (_Map_K_T__Assembler) AssignLink(ipld.Link) error { panic("no") }
func (ta *_Map_K_T__Assembler) AssignNode(v ipld.Node) error {
if v2, ok := v.(*Map_K_T); ok {
*ta.w = *v2
......@@ -452,6 +453,7 @@ func (mka *_Map_K_T__KeyAssembler) AssignString(v string) error {
return nil
}
func (_Map_K_T__KeyAssembler) AssignBytes([]byte) error { panic("no") }
func (_Map_K_T__KeyAssembler) AssignLink(ipld.Link) error { panic("no") }
func (mka *_Map_K_T__KeyAssembler) AssignNode(v ipld.Node) error {
vs, err := v.AsString()
if err != nil {
......@@ -479,6 +481,7 @@ func (mva *_Map_K_T__ValueAssembler) AssignInt(v int) error {
func (mva *_Map_K_T__ValueAssembler) AssignFloat(float64) error { panic("todo") }
func (mva *_Map_K_T__ValueAssembler) AssignString(v string) error { panic("todo") }
func (mva *_Map_K_T__ValueAssembler) AssignBytes([]byte) error { panic("todo") }
func (mva *_Map_K_T__ValueAssembler) AssignLink(ipld.Link) error { panic("todo") }
func (mva *_Map_K_T__ValueAssembler) AssignNode(v ipld.Node) error {
if err := mva.ca.AssignNode(v); err != nil {
return err
......
......@@ -132,6 +132,9 @@ func (na *plainString__Assembler) AssignString(v string) error {
func (plainString__Assembler) AssignBytes([]byte) error {
return mixins.StringAssembler{"string"}.AssignBytes(nil)
}
func (plainString__Assembler) AssignLink(ipld.Link) error {
return mixins.StringAssembler{"string"}.AssignLink(nil)
}
func (na *plainString__Assembler) AssignNode(v ipld.Node) error {
if s, err := v.AsString(); err != nil {
return err
......
......@@ -24,6 +24,7 @@ type NodeAssembler interface {
AssignFloat(float64) error
AssignString(string) error
AssignBytes([]byte) error
AssignLink(Link) error
AssignNode(Node) error // if you already have a completely constructed subtree, this method puts the whole thing in place at once.
......
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