MCPcopy Create free account
hub / github.com/cogentcore/core / copyFrom

Function copyFrom

tree/nodebase.go:671–691  ·  view source on GitHub ↗

copyFrom is the implementation of [NodeBase.CopyFrom].

(to, from Node)

Source from the content-addressed store, hash-verified

669
670// copyFrom is the implementation of [NodeBase.CopyFrom].
671func copyFrom(to, from Node) {
672 fc := from.AsTree().Children
673 if len(fc) == 0 {
674 to.AsTree().DeleteChildren()
675 } else {
676 p := make(TypePlan, len(fc))
677 for i, c := range fc {
678 p[i].Type = c.AsTree().NodeType()
679 p[i].Name = c.AsTree().Name
680 }
681 UpdateSlice(&to.AsTree().Children, to, p)
682 }
683
684 maps.Copy(to.AsTree().Properties, from.AsTree().Properties)
685
686 to.AsTree().This.CopyFieldsFrom(from)
687 for i, kid := range to.AsTree().Children {
688 fmk := from.AsTree().Child(i)
689 copyFrom(kid, fmk)
690 }
691}
692
693// Clone creates and returns a deep copy of the tree from this node down.
694// Any pointers within the cloned tree will correctly point within the new

Callers 1

CopyFromMethod · 0.85

Calls 7

UpdateSliceFunction · 0.85
DeleteChildrenMethod · 0.80
NodeTypeMethod · 0.80
ChildMethod · 0.80
AsTreeMethod · 0.65
CopyMethod · 0.65
CopyFieldsFromMethod · 0.65

Tested by

no test coverage detected