// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package impl

import (
	
	
	
	
	

	
	
	
)

// These functions exist to support exported APIs in generated protobufs.
// While these are deprecated, they cannot be removed for compatibility reasons.

// LegacyEnumName returns the name of enums used in legacy code.
func (Export) ( protoreflect.EnumDescriptor) string {
	return legacyEnumName()
}

// LegacyMessageTypeOf returns the protoreflect.MessageType for m,
// with name used as the message name if necessary.
func (Export) ( protoiface.MessageV1,  protoreflect.FullName) protoreflect.MessageType {
	if  := (Export{}).protoMessageV2Of();  != nil {
		return .ProtoReflect().Type()
	}
	return legacyLoadMessageType(reflect.TypeOf(), )
}

// UnmarshalJSONEnum unmarshals an enum from a JSON-encoded input.
// The input can either be a string representing the enum value by name,
// or a number representing the enum number itself.
func (Export) ( protoreflect.EnumDescriptor,  []byte) (protoreflect.EnumNumber, error) {
	if [0] == '"' {
		var  protoreflect.Name
		if  := json.Unmarshal(, &);  != nil {
			return 0, errors.New("invalid input for enum %v: %s", .FullName(), )
		}
		 := .Values().ByName()
		if  == nil {
			return 0, errors.New("invalid value for enum %v: %s", .FullName(), )
		}
		return .Number(), nil
	} else {
		var  protoreflect.EnumNumber
		if  := json.Unmarshal(, &);  != nil {
			return 0, errors.New("invalid input for enum %v: %s", .FullName(), )
		}
		return , nil
	}
}

// CompressGZIP compresses the input as a GZIP-encoded file.
// The current implementation does no compression.
func (Export) ( []byte) ( []byte) {
	// RFC 1952, section 2.3.1.
	var  = [10]byte{0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff}

	// RFC 1951, section 3.2.4.
	var  [5]byte
	const  = math.MaxUint16
	 := 1 + len()/

	// RFC 1952, section 2.3.1.
	var  [8]byte
	binary.LittleEndian.PutUint32([0:4], crc32.ChecksumIEEE())
	binary.LittleEndian.PutUint32([4:8], uint32(len()))

	// Encode the input without compression using raw DEFLATE blocks.
	 = make([]byte, 0, len()+len()*+len()+len())
	 = append(, [:]...)
	for [0] == 0 {
		 := 
		if  > len() {
			[0] = 0x01 // final bit per RFC 1951, section 3.2.3.
			 = len()
		}
		binary.LittleEndian.PutUint16([1:3], uint16())
		binary.LittleEndian.PutUint16([3:5], ^uint16())
		 = append(, [:]...)
		 = append(, [:]...)
		 = [:]
	}
	 = append(, [:]...)
	return 
}