mpagenko | af80163 | 2020-07-03 10:00:42 +0000 | [diff] [blame] | 1 | // Copyright 2020 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package protoreflect |
| 6 | |
| 7 | import ( |
| 8 | "google.golang.org/protobuf/internal/pragma" |
| 9 | ) |
| 10 | |
| 11 | // The following types are used by the fast-path Message.ProtoMethods method. |
| 12 | // |
| 13 | // To avoid polluting the public protoreflect API with types used only by |
| 14 | // low-level implementations, the canonical definitions of these types are |
| 15 | // in the runtime/protoiface package. The definitions here and in protoiface |
| 16 | // must be kept in sync. |
| 17 | type ( |
| 18 | methods = struct { |
| 19 | pragma.NoUnkeyedLiterals |
| 20 | Flags supportFlags |
| 21 | Size func(sizeInput) sizeOutput |
| 22 | Marshal func(marshalInput) (marshalOutput, error) |
| 23 | Unmarshal func(unmarshalInput) (unmarshalOutput, error) |
| 24 | Merge func(mergeInput) mergeOutput |
| 25 | CheckInitialized func(checkInitializedInput) (checkInitializedOutput, error) |
| 26 | } |
| 27 | supportFlags = uint64 |
| 28 | sizeInput = struct { |
| 29 | pragma.NoUnkeyedLiterals |
| 30 | Message Message |
| 31 | Flags uint8 |
| 32 | } |
| 33 | sizeOutput = struct { |
| 34 | pragma.NoUnkeyedLiterals |
| 35 | Size int |
| 36 | } |
| 37 | marshalInput = struct { |
| 38 | pragma.NoUnkeyedLiterals |
| 39 | Message Message |
| 40 | Buf []byte |
| 41 | Flags uint8 |
| 42 | } |
| 43 | marshalOutput = struct { |
| 44 | pragma.NoUnkeyedLiterals |
| 45 | Buf []byte |
| 46 | } |
| 47 | unmarshalInput = struct { |
| 48 | pragma.NoUnkeyedLiterals |
| 49 | Message Message |
| 50 | Buf []byte |
| 51 | Flags uint8 |
| 52 | Resolver interface { |
| 53 | FindExtensionByName(field FullName) (ExtensionType, error) |
| 54 | FindExtensionByNumber(message FullName, field FieldNumber) (ExtensionType, error) |
| 55 | } |
| 56 | } |
| 57 | unmarshalOutput = struct { |
| 58 | pragma.NoUnkeyedLiterals |
| 59 | Flags uint8 |
| 60 | } |
| 61 | mergeInput = struct { |
| 62 | pragma.NoUnkeyedLiterals |
| 63 | Source Message |
| 64 | Destination Message |
| 65 | } |
| 66 | mergeOutput = struct { |
| 67 | pragma.NoUnkeyedLiterals |
| 68 | Flags uint8 |
| 69 | } |
| 70 | checkInitializedInput = struct { |
| 71 | pragma.NoUnkeyedLiterals |
| 72 | Message Message |
| 73 | } |
| 74 | checkInitializedOutput = struct { |
| 75 | pragma.NoUnkeyedLiterals |
| 76 | } |
| 77 | ) |