proto, runtime/protoiface: add support for fast-path marshaling

Allow message implementations to provide optimized versions of standard
operations. Generated messages now include a ProtoReflectMethods method,
returning a protoiface.Methods struct containing pointers to assorted
optional functions.

The Methods struct also includes a Flags field indicating support for
optional features such as deterministic marshaling.

Implementation of the fast paths (and tests) will come in later CLs.

Change-Id: Idd1beed0ecf43ec5e5e7b8da2ee1e08d3ce32213
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/170340
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/internal/testprotos/test3/test.pb.go b/internal/testprotos/test3/test.pb.go
index c76410b..ad26119 100644
--- a/internal/testprotos/test3/test.pb.go
+++ b/internal/testprotos/test3/test.pb.go
@@ -6,6 +6,7 @@
 import (
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoregistry "github.com/golang/protobuf/v2/reflect/protoregistry"
+	protoiface "github.com/golang/protobuf/v2/runtime/protoiface"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	sync "sync"
 )
@@ -186,6 +187,10 @@
 	return xxx_File_test3_test_proto_messageTypes[0].MessageOf(x)
 }
 
+func (m *TestAllTypes) XXX_Methods() *protoiface.Methods {
+	return xxx_File_test3_test_proto_messageTypes[0].Methods()
+}
+
 // Deprecated: Use TestAllTypes.ProtoReflect.Type instead.
 func (*TestAllTypes) Descriptor() ([]byte, []int) {
 	return xxx_File_test3_test_proto_rawDescGZIP(), []int{0}
@@ -769,6 +774,10 @@
 	return xxx_File_test3_test_proto_messageTypes[1].MessageOf(x)
 }
 
+func (m *ForeignMessage) XXX_Methods() *protoiface.Methods {
+	return xxx_File_test3_test_proto_messageTypes[1].Methods()
+}
+
 // Deprecated: Use ForeignMessage.ProtoReflect.Type instead.
 func (*ForeignMessage) Descriptor() ([]byte, []int) {
 	return xxx_File_test3_test_proto_rawDescGZIP(), []int{1}
@@ -810,6 +819,10 @@
 	return xxx_File_test3_test_proto_messageTypes[2].MessageOf(x)
 }
 
+func (m *TestAllTypes_NestedMessage) XXX_Methods() *protoiface.Methods {
+	return xxx_File_test3_test_proto_messageTypes[2].Methods()
+}
+
 // Deprecated: Use TestAllTypes_NestedMessage.ProtoReflect.Type instead.
 func (*TestAllTypes_NestedMessage) Descriptor() ([]byte, []int) {
 	return xxx_File_test3_test_proto_rawDescGZIP(), []int{0, 0}
diff --git a/internal/testprotos/test3/test_import.pb.go b/internal/testprotos/test3/test_import.pb.go
index 7d0b70c..8b89c52 100644
--- a/internal/testprotos/test3/test_import.pb.go
+++ b/internal/testprotos/test3/test_import.pb.go
@@ -6,6 +6,7 @@
 import (
 	protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
 	protoregistry "github.com/golang/protobuf/v2/reflect/protoregistry"
+	protoiface "github.com/golang/protobuf/v2/runtime/protoiface"
 	protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
 	sync "sync"
 )
@@ -65,6 +66,10 @@
 	return xxx_File_test3_test_import_proto_messageTypes[0].MessageOf(x)
 }
 
+func (m *ImportMessage) XXX_Methods() *protoiface.Methods {
+	return xxx_File_test3_test_import_proto_messageTypes[0].Methods()
+}
+
 // Deprecated: Use ImportMessage.ProtoReflect.Type instead.
 func (*ImportMessage) Descriptor() ([]byte, []int) {
 	return xxx_File_test3_test_import_proto_rawDescGZIP(), []int{0}