func CreateXmlNodeType(t bh.NodeTypeIf) *backend.XmlNodeType { ret := backend.XmlNodeTypeNew(t.TypeName()) for _, p := range t.InPorts() { ret.InPort = append(ret.InPort, *CreateXmlNamedInPort(p)) } for _, p := range t.OutPorts() { ret.OutPort = append(ret.OutPort, *CreateXmlNamedOutPort(p)) } for _, impl := range t.Implementation() { ret.Implementation = append(ret.Implementation, *CreateXmlImplementation(impl)) } return ret }
func NodeNew(name string, ntype bh.NodeTypeIf, context bh.SignalGraphTypeIf) (ret *node, err error) { for _, n := range context.Nodes() { if n.Name() == name { err = fmt.Errorf("NodeNew error: node '%s' already exists in context.", name) return } } if len(ntype.InPorts())+len(ntype.OutPorts()) == 0 { err = fmt.Errorf("NodeNew error: type '%s' has no ports.", ntype.TypeName()) return } ret = &node{*gr.PathModePositionerObjectNew(), context, name, ntype, portListInit(), portListInit(), nil, false} for _, p := range ntype.InPorts() { ret.addInPort(p) } for _, p := range ntype.OutPorts() { ret.addOutPort(p) } ntype.(*nodeType).addInstance(ret) return }