コード例 #1
0
ファイル: packager.go プロジェクト: nmakiya/tritium
func NewFromCompiledMixer(mxr *tp.Mixer) *Packager {
	pkgr := new(Packager)
	pkgr.AlreadyLoaded = make(map[string]bool)
	pkgr.IsHttpTransformer = mxr.GetIsHttpTransformer()
	pkgr.Mixer = mxr

	// now reconstruct all the type information
	pkgr.TypeMap = make(map[string]int)
	pkgr.TypeList = make([]string, len(mxr.Package.Types))

	for i, t := range mxr.Package.Types {
		pkgr.TypeMap[t.GetName()] = i
		pkgr.TypeList[i] = t.GetName()
		if super := t.GetImplements(); super != 0 {
			if pkgr.SuperclassOf == nil {
				pkgr.SuperclassOf = make(map[string]string)
			}
			nameOfSuper := pkgr.TypeList[super]
			pkgr.SuperclassOf[t.GetName()] = nameOfSuper
			// pkgr.Extensions = append(pkgr.Extensions, fmt.Sprintf("%s < %s", t.GetName(), nameOfSuper))
		}
	}

	// Set up the submixer tables for relocation in legacy mixers -- not enough
	// metadata in legacy mixers, so the whole thing will be one submixer, and
	// we won't try to eliminate redundant submixers.
	// if pkgr.GetPackagerVersion() == 0 {
	// 	pkgr.Mixer.Submixers    = make([]*tp.SubmixerInfo, 1)
	// 	pkgr.Mixer.Submixers[0] = &tp.SubmixerInfo{
	// 		Name:    proto.String(pkgr.GetName()),
	// 		Version: proto.String(pkgr.GetVersion()),
	// 		Offset:  proto.Int32(int32(0)),
	// 		Length:  proto.Int32(int32(len(pkgr.Mixer.Package.Functions))),
	// 	}
	// }

	return pkgr
}
コード例 #2
0
ファイル: packager.go プロジェクト: jcgill81/tritium
func NewFromCompiledMixer(mxr *tp.Mixer) *Packager {
	pkgr := new(Packager)
	pkgr.AlreadyLoaded = make(map[string]bool)
	pkgr.IsHttpTransformer = mxr.GetIsHttpTransformer()
	pkgr.Mixer = mxr

	// now reconstruct all the type information
	pkgr.TypeMap = make(map[string]int)
	pkgr.TypeList = make([]string, len(mxr.Package.Types))

	for i, t := range mxr.Package.Types {
		pkgr.TypeMap[t.GetName()] = i
		pkgr.TypeList[i] = t.GetName()
		if super := t.GetImplements(); super != 0 {
			if pkgr.SuperclassOf == nil {
				pkgr.SuperclassOf = make(map[string]string)
			}
			nameOfSuper := pkgr.TypeList[super]
			pkgr.SuperclassOf[t.GetName()] = nameOfSuper
		}
	}

	return pkgr
}