Ejemplo n.º 1
0
func LibraryUsesSignalType(l bh.LibraryIf, st bh.SignalTypeIf) bool {
	for _, t := range l.SignalTypes() {
		if t.TypeName() == st.TypeName() {
			return true
		}
	}
	for _, t := range l.NodeTypes() {
		for _, impl := range t.Implementation() {
			if impl.ImplementationType() == bh.NodeTypeGraph {
				if SignalGraphTypeUsesSignalType(impl.Graph(), st) {
					return true
				}
			}
		}
	}
	return false
}
Ejemplo n.º 2
0
func CreateXmlLibrary(l bh.LibraryIf) *backend.XmlLibrary {
	fname := l.Filename()
	ret := backend.XmlLibraryNew()
	reflist := tool.StringListInit()
	for _, t := range l.SignalTypes() {
		ref := t.DefinedAt()
		_, ok := reflist.Find(ref)
		if !ok && ref != fname {
			reflist.Append(ref)
		}
	}
	for _, t := range l.NodeTypes() {
		ref := t.DefinedAt()
		_, ok := reflist.Find(ref)
		if !ok && ref != fname {
			reflist.Append(ref)
		}
		for _, impl := range t.Implementation() {
			if impl.ImplementationType() == bh.NodeTypeGraph {
				for _, lib := range impl.Graph().Libraries() {
					ref := lib.Filename()
					_, ok := reflist.Find(ref)
					if !ok && ref != fname {
						reflist.Append(ref)
					}
				}
			}
		}
	}
	for _, ref := range reflist.Strings() {
		ret.Libraries = append(ret.Libraries, *CreateXmlLibraryRef(ref))
	}
	for _, t := range l.SignalTypes() {
		ret.SignalTypes = append(ret.SignalTypes, *CreateXmlSignalType(t))
	}
	for _, t := range l.NodeTypes() {
		ret.NodeTypes = append(ret.NodeTypes, *CreateXmlNodeType(t))
	}
	return ret
}