// ToCipdPackage converts this to a swarming api SwarmingRpcsCipdPackage.
543880
func (c *CipdPackage) ToCipdPackage() *swarm.SwarmingRpcsCipdPackage {
	if c == nil {
		return nil
	}
	return &swarm.SwarmingRpcsCipdPackage{PackageName: c.Name, Version: c.Version}
}
419809
func (m *ManualSetpoint) Pack() []byte {
	data := new(bytes.Buffer)
	binary.Write(data, binary.LittleEndian, m.TIME_BOOT_MS)
	binary.Write(data, binary.LittleEndian, m.ROLL)
	binary.Write(data, binary.LittleEndian, m.PITCH)
	binary.Write(data, binary.LittleEndian, m.YAW)
	binary.Write(data, binary.LittleEndian, m.THRUST)
	binary.Write(data, binary.LittleEndian, m.MODE_SWITCH)
	binary.Write(data, binary.LittleEndian, m.MANUAL_OVERRIDE_SWITCH)
	return data.Bytes()
}
116433
func (t *PackageList) AddPackage(pkg *build.Package) {
	t.ensureInit()
	t.pkgpool[pkg] = true
	t.dirpool[pkg.Dir] = pkg
	t.namepool[getPackageName(pkg)] = pkg
}
1197728
func (e *Email) AddRecipient(Recipient string) {
	e.To = append(e.To, Recipient)
}
145722
func (m *RollPitchYawSpeedThrustSetpoint) Pack() []byte {
	data := new(bytes.Buffer)
	binary.Write(data, binary.LittleEndian, m.TIME_BOOT_MS)
	binary.Write(data, binary.LittleEndian, m.ROLL_SPEED)
	binary.Write(data, binary.LittleEndian, m.PITCH_SPEED)
	binary.Write(data, binary.LittleEndian, m.YAW_SPEED)
	binary.Write(data, binary.LittleEndian, m.THRUST)
	return data.Bytes()
}
1319
func (pb PackageBuilder) PackageXml() []byte {
	p := createPackage()

	for _, metaType := range pb.Metadata {
		p.Types = append(p.Types, metaType)
	}

	byteXml, _ := xml.MarshalIndent(p, "", "    ")
	byteXml = append([]byte(xml.Header), byteXml...)
	//if err := ioutil.WriteFile("mypackage.xml", byteXml, 0644); err != nil {
	//ErrorAndExit(err.Error())
	//}
	return byteXml
}
916208
func parsePackage(ctx *context, jsonRoot *jsongo.JSONNode) (*Package, error) {
	logf(" %s (version: %s) contains: %d services, %d messages, %d types, %d enums, %d unions, %d aliases",
		ctx.packageName,
		jsonRoot.Map(vlAPIVersion).Get(),
		jsonRoot.Map(objServices).Len(),
		jsonRoot.Map(objMessages).Len(),
		jsonRoot.Map(objTypes).Len(),
		jsonRoot.Map(objEnums).Len(),
		jsonRoot.Map(objUnions).Len(),
		jsonRoot.Map(objAliases).Len(),
	)

	pkg := Package{
		APIVersion: jsonRoot.Map(vlAPIVersion).Get().(string),
		RefMap:     make(map[string]string),
	}

	// parse enums
	enums := jsonRoot.Map(objEnums)
	pkg.Enums = make([]Enum, enums.Len())
	for i := 0; i < enums.Len(); i++ {
		enumNode := enums.At(i)

		enum, err := parseEnum(ctx, enumNode)
		if err != nil {
			return nil, err
		}
		pkg.Enums[i] = *enum
		pkg.RefMap[toApiType(enum.Name)] = enum.Name
	}
	// sort enums
	sort.SliceStable(pkg.Enums, func(i, j int) bool {
		return pkg.Enums[i].Name < pkg.Enums[j].Name
	})

	// parse aliases
	aliases := jsonRoot.Map(objAliases)
	if aliases.GetType() == jsongo.TypeMap {
		pkg.Aliases = make([]Alias, aliases.Len())
		for i, key := range aliases.GetKeys() {
			aliasNode := aliases.At(key)

			alias, err := parseAlias(ctx, key.(string), aliasNode)
			if err != nil {
				return nil, err
			}
			pkg.Aliases[i] = *alias
			pkg.RefMap[toApiType(alias.Name)] = alias.Name
		}
	}
	// sort aliases to ensure consistent order
	sort.Slice(pkg.Aliases, func(i, j int) bool {
		return pkg.Aliases[i].Name < pkg.Aliases[j].Name
	})

	// parse types
	types := jsonRoot.Map(objTypes)
	pkg.Types = make([]Type, types.Len())
	for i := 0; i < types.Len(); i++ {
		typNode := types.At(i)

		typ, err := parseType(ctx, typNode)
		if err != nil {
			return nil, err
		}
		pkg.Types[i] = *typ
		pkg.RefMap[toApiType(typ.Name)] = typ.Name
	}
	// sort types
	sort.SliceStable(pkg.Types, func(i, j int) bool {
		return pkg.Types[i].Name < pkg.Types[j].Name
	})

	// parse unions
	unions := jsonRoot.Map(objUnions)
	pkg.Unions = make([]Union, unions.Len())
	for i := 0; i < unions.Len(); i++ {
		unionNode := unions.At(i)

		union, err := parseUnion(ctx, unionNode)
		if err != nil {
			return nil, err
		}
		pkg.Unions[i] = *union
		pkg.RefMap[toApiType(union.Name)] = union.Name
	}
	// sort unions
	sort.SliceStable(pkg.Unions, func(i, j int) bool {
		return pkg.Unions[i].Name < pkg.Unions[j].Name
	})

	// parse messages
	messages := jsonRoot.Map(objMessages)
	pkg.Messages = make([]Message, messages.Len())
	for i := 0; i < messages.Len(); i++ {
		msgNode := messages.At(i)

		msg, err := parseMessage(ctx, msgNode)
		if err != nil {
			return nil, err
		}
		pkg.Messages[i] = *msg
	}
	// sort messages
	sort.SliceStable(pkg.Messages, func(i, j int) bool {
		return pkg.Messages[i].Name < pkg.Messages[j].Name
	})

	// parse services
	services := jsonRoot.Map(objServices)
	if services.GetType() == jsongo.TypeMap {
		pkg.Services = make([]Service, services.Len())
		for i, key := range services.GetKeys() {
			svcNode := services.At(key)

			svc, err := parseService(ctx, key.(string), svcNode)
			if err != nil {
				return nil, err
			}
			pkg.Services[i] = *svc
		}
	}
	// sort services
	sort.Slice(pkg.Services, func(i, j int) bool {
		// dumps first
		if pkg.Services[i].Stream != pkg.Services[j].Stream {
			return pkg.Services[i].Stream
		}
		return pkg.Services[i].RequestType < pkg.Services[j].RequestType
	})

	printPackage(&pkg)

	return &pkg, nil
}
1197020
func (s *CreateOriginEndpointOutput) SetCmafPackage(v *CmafPackage) *CreateOriginEndpointOutput {
	s.CmafPackage = v
	return s
}
78684
func (c *Client) processPacket(pkt packet.Generic) error {
	// prepare error
	var err error

	// handle individual packets
	switch typedPkt := pkt.(type) {
	case *packet.Subscribe:
		err = c.processSubscribe(typedPkt)
	case *packet.Unsubscribe:
		err = c.processUnsubscribe(typedPkt)
	case *packet.Publish:
		err = c.processPublish(typedPkt)
	case *packet.Puback:
		err = c.processPubackAndPubcomp(typedPkt.ID)
	case *packet.Pubcomp:
		err = c.processPubackAndPubcomp(typedPkt.ID)
	case *packet.Pubrec:
		err = c.processPubrec(typedPkt.ID)
	case *packet.Pubrel:
		err = c.processPubrel(typedPkt.ID)
	case *packet.Pingreq:
		err = c.processPingreq()
	case *packet.Disconnect:
		err = c.processDisconnect()
	default:
		err = c.die(ClientError, ErrUnexpectedPacket)
	}

	// return eventual error
	if err != nil {
		return err // error has already been handled
	}

	return nil
}
730733
func processPackage(fset *token.FileSet, pkgImportPath, pkgPath string, pkg *ast.Package) *model.SourceInfo {
	var (
		structSpecs     []*model.TypeInfo
		initImportPaths []string

		methodSpecs     = make(methodMap)
		validationKeys  = make(map[string]map[int]string)
		scanControllers = strings.HasSuffix(pkgImportPath, "/controllers") ||
			strings.Contains(pkgImportPath, "/controllers/")
		scanTests = strings.HasSuffix(pkgImportPath, "/tests") ||
			strings.Contains(pkgImportPath, "/tests/")
	)

	// For each source file in the package...
	utils.Logger.Info("Exaimining files in path", "package", pkgPath)
	for fname, file := range pkg.Files {
		// Imports maps the package key to the full import path.
		// e.g. import "sample/app/models" => "models": "sample/app/models"
		imports := map[string]string{}

		// For each declaration in the source file...
		for _, decl := range file.Decls {
			addImports(imports, decl, pkgPath)

			if scanControllers {
				// Match and add both structs and methods
				structSpecs = appendStruct(fname, structSpecs, pkgImportPath, pkg, decl, imports, fset)
				appendAction(fset, methodSpecs, decl, pkgImportPath, pkg.Name, imports)
			} else if scanTests {
				structSpecs = appendStruct(fname, structSpecs, pkgImportPath, pkg, decl, imports, fset)
			}

			// If this is a func... (ignore nil for external (non-Go) function)
			if funcDecl, ok := decl.(*ast.FuncDecl); ok && funcDecl.Body != nil {
				// Scan it for validation calls
				lineKeys := GetValidationKeys(fname, fset, funcDecl, imports)
				if len(lineKeys) > 0 {
					validationKeys[pkgImportPath+"."+getFuncName(funcDecl)] = lineKeys
				}

				// Check if it's an init function.
				if funcDecl.Name.Name == "init" {
					initImportPaths = []string{pkgImportPath}
				}
			}
		}
	}

	// Add the method specs to the struct specs.
	for _, spec := range structSpecs {
		spec.MethodSpecs = methodSpecs[spec.StructName]
	}

	return &model.SourceInfo{
		StructSpecs:     structSpecs,
		ValidationKeys:  validationKeys,
		InitImportPaths: initImportPaths,
	}
}
198286
func (m *RcChannelsOverride) Pack() []byte {
	data := new(bytes.Buffer)
	binary.Write(data, binary.LittleEndian, m.CHAN1_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN2_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN3_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN4_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN5_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN6_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN7_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN8_RAW)
	binary.Write(data, binary.LittleEndian, m.TARGET_SYSTEM)
	binary.Write(data, binary.LittleEndian, m.TARGET_COMPONENT)
	return data.Bytes()
}
1062457
func CollectPackages(infos map[string]*FileInfo, protos []string, importDirs []string) (map[string]*PackageInfo, error) {
	pkgMap := map[string]*PackageInfo{}

	// Collect into packages.
	for _, info := range infos {
		packageInfo, ok := pkgMap[info.ComputedPackage]
		if !ok {
			packageInfo = &PackageInfo{ComputedPackage: info.ComputedPackage}
			pkgMap[info.ComputedPackage] = packageInfo
		}
		packageInfo.Files = append(packageInfo.Files, info)
	}

	// Collect deps for each package.
	for _, pkg := range pkgMap {
		deps := map[string]*FileInfo{}
		for _, info := range pkg.Files {
			for _, dep := range info.Deps {
				deps[dep] = infos[dep]
			}
		}
		for _, dep := range deps {
			pkg.Deps = append(pkg.Deps, dep)
		}
	}

	return pkgMap, nil
}
324908
func (client *Client) UploadPackage(pkg Package, fileToUpload string) (Package, Warnings, error) {
	link, ok := pkg.Links["upload"]
	if !ok {
		return Package{}, nil, ccerror.UploadLinkNotFoundError{PackageGUID: pkg.GUID}
	}

	body, contentType, err := client.createUploadStream(fileToUpload, "bits")
	if err != nil {
		return Package{}, nil, err
	}

	request, err := client.newHTTPRequest(requestOptions{
		URL:    link.HREF,
		Method: link.Method,
		Body:   body,
	})
	if err != nil {
		return Package{}, nil, err
	}

	request.Header.Set("Content-Type", contentType)

	var responsePackage Package
	response := cloudcontroller.Response{
		DecodeJSONResponseInto: &responsePackage,
	}
	err = client.connection.Make(request, &response)

	return responsePackage, response.Warnings, err
}
3446
func (actionSet ActionSet) ToSlice() []Action {
	actions := []Action{}
	for action := range actionSet {
		actions = append(actions, action)
	}

	return actions
}
490259
func ioOutputFormatPackage(ld *LineData, b *bytes.Buffer) error {
	_, err := b.WriteString(ld.CallingPackage)
	return err
}
674173
func (m *HilRcInputsRaw) Pack() []byte {
	data := new(bytes.Buffer)
	binary.Write(data, binary.LittleEndian, m.TIME_USEC)
	binary.Write(data, binary.LittleEndian, m.CHAN1_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN2_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN3_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN4_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN5_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN6_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN7_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN8_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN9_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN10_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN11_RAW)
	binary.Write(data, binary.LittleEndian, m.CHAN12_RAW)
	binary.Write(data, binary.LittleEndian, m.RSSI)
	return data.Bytes()
}
493812
func (memif *Memif) NewPacketHandle(queueId uint8, rxCount uint16) *MemifPacketHandle {
	if rxCount == 0 {
		rxCount = 1
	}

	return &MemifPacketHandle{
		memif:   memif,
		queueId: queueId,
		rxCount: rxCount,
	}
}