Commit 32be50ab authored by Eric Myhre's avatar Eric Myhre

Finish connecting map and list to rest of scalars.

Also map able to create child list.
parent 9aeff0a4
......@@ -232,19 +232,33 @@ func (lva *plainList__ValueAssembler) BeginList(sizeHint int) (ipld.ListNodeAsse
_, err := la.ca.BeginList(sizeHint)
return &la, err
}
func (lva *plainList__ValueAssembler) AssignNull() error { panic("todo") }
func (lva *plainList__ValueAssembler) AssignBool(bool) error { panic("todo") }
func (lva *plainList__ValueAssembler) AssignNull() error {
return lva.AssignNode(ipld.Null)
}
func (lva *plainList__ValueAssembler) AssignBool(v bool) error {
vb := plainBool(v)
return lva.AssignNode(&vb)
}
func (lva *plainList__ValueAssembler) AssignInt(v int) error {
vb := plainInt(v)
return lva.AssignNode(&vb)
}
func (lva *plainList__ValueAssembler) AssignFloat(float64) error { panic("todo") }
func (lva *plainList__ValueAssembler) AssignFloat(v float64) error {
vb := plainFloat(v)
return lva.AssignNode(&vb)
}
func (lva *plainList__ValueAssembler) AssignString(v string) error {
vb := plainString(v)
return lva.AssignNode(&vb)
}
func (lva *plainList__ValueAssembler) AssignBytes([]byte) error { panic("todo") }
func (lva *plainList__ValueAssembler) AssignLink(ipld.Link) error { panic("todo") }
func (lva *plainList__ValueAssembler) AssignBytes(v []byte) error {
vb := plainBytes(v)
return lva.AssignNode(&vb)
}
func (lva *plainList__ValueAssembler) AssignLink(v ipld.Link) error {
vb := plainLink{v}
return lva.AssignNode(&vb)
}
func (lva *plainList__ValueAssembler) AssignNode(v ipld.Node) error {
lva.la.w.x = append(lva.la.w.x, v)
lva.la.state = laState_initial
......
......@@ -326,21 +326,39 @@ func (mva *plainMap__ValueAssembler) BeginMap(sizeHint int) (ipld.MapNodeAssembl
return &ma, err
}
func (mva *plainMap__ValueAssembler) BeginList(sizeHint int) (ipld.ListNodeAssembler, error) {
panic("todo") // now please
la := plainMap__ValueAssemblerList{}
la.ca.w = &plainList{}
la.p = mva.ma
_, err := la.ca.BeginList(sizeHint)
return &la, err
}
func (mva *plainMap__ValueAssembler) AssignNull() error {
return mva.AssignNode(ipld.Null)
}
func (mva *plainMap__ValueAssembler) AssignBool(v bool) error {
vb := plainBool(v)
return mva.AssignNode(&vb)
}
func (mva *plainMap__ValueAssembler) AssignNull() error { panic("todo") }
func (mva *plainMap__ValueAssembler) AssignBool(bool) error { panic("todo") }
func (mva *plainMap__ValueAssembler) AssignInt(v int) error {
vb := plainInt(v)
return mva.AssignNode(&vb)
}
func (mva *plainMap__ValueAssembler) AssignFloat(float64) error { panic("todo") }
func (mva *plainMap__ValueAssembler) AssignFloat(v float64) error {
vb := plainFloat(v)
return mva.AssignNode(&vb)
}
func (mva *plainMap__ValueAssembler) AssignString(v string) error {
vb := plainString(v)
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) AssignBytes(v []byte) error {
vb := plainBytes(v)
return mva.AssignNode(&vb)
}
func (mva *plainMap__ValueAssembler) AssignLink(v ipld.Link) error {
vb := plainLink{v}
return mva.AssignNode(&vb)
}
func (mva *plainMap__ValueAssembler) AssignNode(v ipld.Node) error {
l := len(mva.ma.w.t) - 1
mva.ma.w.t[l].v = v
......@@ -380,3 +398,26 @@ func (ma *plainMap__ValueAssemblerMap) Finish() error {
ma.ca.w = nil
return ma.p.va.AssignNode(w)
}
type plainMap__ValueAssemblerList struct {
ca plainList__Assembler
p *plainMap__Assembler // pointer back to parent, for final insert and state bump
}
// we briefly state only the methods we need to delegate here.
// just embedding plainList__Assembler also behaves correctly,
// but causes a lot of unnecessary autogenerated functions in the final binary.
func (la *plainMap__ValueAssemblerList) AssembleValue() ipld.NodeAssembler {
return la.ca.AssembleValue()
}
func (plainMap__ValueAssemblerList) ValueStyle() ipld.NodeStyle { panic("later") }
func (la *plainMap__ValueAssemblerList) Finish() error {
if err := la.ca.Finish(); err != nil {
return err
}
w := la.ca.w
la.ca.w = nil
return la.p.va.AssignNode(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