// Converters for the EUC-JP encoding
420425
func init() {
	RegisterCharset(&Charset{
		Name:    "EUC-JP",
		Aliases: []string{"extended_unix_code_packed_format_for_japanese", "cseucpkdfmtjapanese"},
		NewDecoder: func() Decoder {
			return decodeEucJP
		},
		NewEncoder: func() Encoder {
			jis0208Table.Reverse()
			jis0212Table.Reverse()
			return encodeEucJP
		},
	})
}
1360009
func convertNotFound(err error) error {
	if params.IsCodeNotFound(err) {
		return errors.NewNotFound(err, "")
	}
	return err
}
561916
func (orig *BarJSON) Convert() (*Bar, error) {
	ret := &Bar{}

	b := NewBarJSONBuilder().AddAll()
	for _, info := range b._properties {
		if err := info.Decoder(orig, ret); err != nil {
			return nil, err
		}
	}

	return ret, nil
}
865468
func loadKeycodeConverterData() (map[string][]string, error) {
	buf, err := grab(keycodeConverterDataInc)
	if err != nil {
		return nil, err
	}
	buf = fixRE.ReplaceAllLiteral(buf, []byte(", "))

	domMap := make(map[string][]string)
	matches := usbKeyRE.FindAllStringSubmatch(string(buf), -1)
	for _, m := range matches {
		vkey := m[7]
		if _, ok := domMap[vkey]; ok {
			panic(fmt.Sprintf("vkey %s already defined", vkey))
		}
		domMap[vkey] = m[1:]
	}

	return domMap, nil
}
13087
func DecodeFormats(mediaTypes media.Types, maps ...map[string]interface{}) (Formats, error) {
	f := make(Formats, len(DefaultFormats))
	copy(f, DefaultFormats)

	for _, m := range maps {
		for k, v := range m {
			found := false
			for i, vv := range f {
				if strings.EqualFold(k, vv.Name) {
					// Merge it with the existing
					if err := decode(mediaTypes, v, &f[i]); err != nil {
						return f, err
					}
					found = true
				}
			}
			if !found {
				var newOutFormat Format
				newOutFormat.Name = k
				if err := decode(mediaTypes, v, &newOutFormat); err != nil {
					return f, err
				}

				// We need values for these
				if newOutFormat.BaseName == "" {
					newOutFormat.BaseName = "index"
				}
				if newOutFormat.Rel == "" {
					newOutFormat.Rel = "alternate"
				}

				f = append(f, newOutFormat)
			}
		}
	}

	sort.Sort(f)

	return f, nil
}
720597
func ConvertPortBindings(portBindings []types.PortBinding) ([]json.RawMessage, error) {
	var pbs []json.RawMessage

	// Enumerate through the port bindings specified by the user and convert
	// them into the internal structure matching the JSON blob that can be
	// understood by the HCS.
	for _, elem := range portBindings {
		proto := strings.ToUpper(elem.Proto.String())
		if proto != "TCP" && proto != "UDP" {
			return nil, fmt.Errorf("invalid protocol %s", elem.Proto.String())
		}

		if elem.HostPort != elem.HostPortEnd {
			return nil, fmt.Errorf("Windows does not support more than one host port in NAT settings")
		}

		if len(elem.HostIP) != 0 {
			return nil, fmt.Errorf("Windows does not support host IP addresses in NAT settings")
		}

		encodedPolicy, err := json.Marshal(hcsshim.NatPolicy{
			Type:         "NAT",
			ExternalPort: elem.HostPort,
			InternalPort: elem.Port,
			Protocol:     elem.Proto.String(),
		})

		if err != nil {
			return nil, err
		}
		pbs = append(pbs, encodedPolicy)
	}
	return pbs, nil
}
1177148
func (r *Reader) convert(samples *[2][1152]float32) {
	nSamples := r.Decoder.NSamples()
	nChannels := 2
	if r.Mono {
		nChannels = 1
	}

	format := formatDescriptions[r.Format]
	offset := float32(1)
	if format.signed {
		offset = 0
	}
	multiplier := float32(int(1) << uint(format.bits-1))
	max := (1 + offset) * multiplier
	le := format.le
	size := format.size
	jump := size
	if !r.Mono {
		jump *= 2
	}

	for outCh := 0; outCh < nChannels; outCh++ {
		inCh := outCh
		if r.Swap {
			inCh = 1 - outCh
		}
		ptr := outCh * size

		for t := 0; t < nSamples; t++ {
			s := (samples[inCh][t] + offset) * multiplier
			if s >= max {
				s--
			}
			var si int
			if s < 0 {
				si = int(s - 0.5)
			} else {
				si = int(s + 0.5)
			}
			if le {
				for i := 0; i < size; i++ {
					r.buffer[ptr+i] = byte(si & 0xff)
					si >>= 8
				}
			} else {
				for i := 0; i < size; i++ {
					r.buffer[ptr+size-1-i] = byte(si & 0xff)
					si >>= 8
				}
			}
			ptr += jump
		}

		if r.Mono {
			break
		}
	}

	r.unread = r.buffer[0 : jump*nSamples]
}
943287
func convertToMultiServers(conf jsonconfig.Obj) (jsonconfig.Obj, error) {
	server := conf.OptionalString("server", "")
	if server == "" {
		return nil, errors.New("could not convert config to multi-servers style: no \"server\" key found")
	}
	newConf := jsonconfig.Obj{
		"servers": map[string]interface{}{
			"server": map[string]interface{}{
				"auth":    conf.OptionalString("auth", ""),
				"default": true,
				"server":  server,
			},
		},
		"identity":           conf.OptionalString("identity", ""),
		"identitySecretRing": conf.OptionalString("identitySecretRing", ""),
	}
	if ignoredFiles := conf.OptionalList("ignoredFiles"); ignoredFiles != nil {
		var list []interface{}
		for _, v := range ignoredFiles {
			list = append(list, v)
		}
		newConf["ignoredFiles"] = list
	}
	return newConf, nil
}
1322554
func (d *Decoder) RegisterConverter(value interface{}, converterFunc Converter) {
	d.cache.registerConverter(value, converterFunc)
}
66531
func Convert(ref C.CFTypeRef) (interface{}, error) {
	typeID := C.CFGetTypeID(ref)
	if typeID == C.CFStringGetTypeID() {
		return CFStringToString(C.CFStringRef(ref)), nil
	} else if typeID == C.CFDictionaryGetTypeID() {
		return ConvertCFDictionary(C.CFDictionaryRef(ref))
	} else if typeID == C.CFArrayGetTypeID() {
		arr := CFArrayToArray(C.CFArrayRef(ref))
		results := make([]interface{}, 0, len(arr))
		for _, ref := range arr {
			v, err := Convert(ref)
			if err != nil {
				return nil, err
			}
			results = append(results, v)
			return results, nil
		}
	} else if typeID == C.CFDataGetTypeID() {
		b, err := CFDataToBytes(C.CFDataRef(ref))
		if err != nil {
			return nil, err
		}
		return b, nil
	} else if typeID == C.CFNumberGetTypeID() {
		return CFNumberToInterface(C.CFNumberRef(ref)), nil
	} else if typeID == C.CFBooleanGetTypeID() {
		if C.CFBooleanGetValue(C.CFBooleanRef(ref)) != 0 {
			return true, nil
		}
		return false, nil
	}

	return nil, fmt.Errorf("Invalid type: %s", CFTypeDescription(ref))
}
844406
func NewVersionConverter(t TypeConverter, o runtime.ObjectConvertor, h schema.GroupVersion) merge.Converter {
	return &versionConverter{
		typeConverter:   t,
		objectConvertor: o,
		hubGetter: func(from schema.GroupVersion) schema.GroupVersion {
			return schema.GroupVersion{
				Group:   from.Group,
				Version: h.Version,
			}
		},
	}
}
761115
func (jsonList SampleFJSONList) Convert() ([]*SampleF, error) {
	orig := ([]*SampleFJSON)(jsonList)

	list := make([]*SampleF, len(orig))
	for idx, or := range orig {
		obj, err := or.Convert()
		if err != nil {
			return nil, err
		}
		list[idx] = obj
	}

	return list, nil
}
92683
func (p *Engine) convertFilters() map[string]pongo2.FilterFunction {
	filters := make(map[string]pongo2.FilterFunction, len(p.Config.Filters))
	for k, v := range p.Config.Filters {
		func(filterName string, filterFunc FilterFunction) {
			fn := pongo2.FilterFunction(func(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) {
				theOut, theErr := filterFunc((*Value)(in), (*Value)(param))
				return (*pongo2.Value)(theOut), (*pongo2.Error)(theErr)
			})
			filters[filterName] = fn
		}(k, v)
	}
	return filters
}
1280457
func (orig *SampleJSON) Convert() (*Sample, error) {
	ret := &Sample{}

	b := NewSampleJSONBuilder().AddAll()
	for _, info := range b._properties {
		if err := info.Decoder(orig, ret); err != nil {
			return nil, err
		}
	}

	return ret, nil
}
1042528
func (g *Generator) ConvertType(from, to string) {
	g.typeConversions[from] = to
}
713879
func (b *PersonJSONBuilder) Convert(orig *Person) (*PersonJSON, error) {
	if orig == nil {
		return nil, nil
	}
	ret := &PersonJSON{}

	for _, info := range b._properties {
		if err := info.Encoder(orig, ret); err != nil {
			return nil, err
		}
	}

	return ret, nil
}
1069312
func NewTypeConverter(models proto.Models) (TypeConverter, error) {
	parser, err := newGVKParser(models)
	if err != nil {
		return nil, err
	}
	return &typeConverter{parser: parser}, nil
}