示例#1
0
func (l *library) ReadFile(filepath string) error {
	xmllib := backend.XmlLibraryNew()
	err := xmllib.ReadFile(filepath)
	if err != nil {
		return fmt.Errorf("library.Read: %v", err)
	}
	return l.createLibFromXml(xmllib)
}
示例#2
0
func (l *library) Read(data []byte) (cnt int, err error) {
	xmllib := backend.XmlLibraryNew()
	cnt, err = xmllib.Read(data)
	if err != nil {
		err = fmt.Errorf("library.Read: %v", err)
		return
	}
	err = l.createLibFromXml(xmllib)
	return
}
示例#3
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
}