internal/prototype: move from reflect/prototype
The prototype package was initially used by generated reflection support,
but has now been replaced by internal/fileinit.
Eventually, this functionality should be deleted and re-written in terms
of other components in the repo.
Usages that prototype currently provides (but should be moved) are:
* Constructing standalone messages and enums, which is behavior we should
provide in reflect/protodesc. The google.protobuf.{Enum,Type} are well-known
proto messages designed for this purpose.
* Constructing placeholder files, enums, and messages.
* Consructing protoreflect.{Message,Enum,Extension}Types, which are protobuf
descriptors with associated Go type information.
Change-Id: Id7dbefff952682781b439aa555508c59b2629f9e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/167383
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/cmd/protoc-gen-go/internal_gengo/reflect.go b/cmd/protoc-gen-go/internal_gengo/reflect.go
index e11dc15..55fb42c 100644
--- a/cmd/protoc-gen-go/internal_gengo/reflect.go
+++ b/cmd/protoc-gen-go/internal_gengo/reflect.go
@@ -27,7 +27,7 @@
reflectPackage = protogen.GoImportPath("reflect")
protoimplPackage = protogen.GoImportPath("github.com/golang/protobuf/v2/runtime/protoimpl")
protoreflectPackage = protogen.GoImportPath("github.com/golang/protobuf/v2/reflect/protoreflect")
- prototypePackage = protogen.GoImportPath("github.com/golang/protobuf/v2/reflect/prototype")
+ prototypePackage = protogen.GoImportPath("github.com/golang/protobuf/v2/internal/prototype")
)
// TODO: Add support for proto options.
diff --git a/internal/cmd/generate-types/main.go b/internal/cmd/generate-types/main.go
index 8fa3222..0c0a34d 100644
--- a/internal/cmd/generate-types/main.go
+++ b/internal/cmd/generate-types/main.go
@@ -40,7 +40,7 @@
chdirRoot()
writeSource("internal/fileinit/desc_list_gen.go", generateFileinitDescList())
writeSource("proto/decode_gen.go", generateProtoDecode())
- writeSource("reflect/prototype/protofile_list_gen.go", generateListTypes())
+ writeSource("internal/prototype/protofile_list_gen.go", generateListTypes())
}
// chdirRoot changes the working directory to the repository root.
diff --git a/internal/cmd/pbdump/pbdump.go b/internal/cmd/pbdump/pbdump.go
index fc96696..c6cb7c7 100644
--- a/internal/cmd/pbdump/pbdump.go
+++ b/internal/cmd/pbdump/pbdump.go
@@ -19,9 +19,9 @@
"github.com/golang/protobuf/v2/internal/encoding/pack"
"github.com/golang/protobuf/v2/internal/encoding/wire"
+ "github.com/golang/protobuf/v2/internal/prototype"
"github.com/golang/protobuf/v2/internal/scalar"
"github.com/golang/protobuf/v2/reflect/protoreflect"
- "github.com/golang/protobuf/v2/reflect/prototype"
descriptorpb "github.com/golang/protobuf/v2/types/descriptor"
)
diff --git a/internal/cmd/pbdump/pbdump_test.go b/internal/cmd/pbdump/pbdump_test.go
index ddc20a1..9e50ec4 100644
--- a/internal/cmd/pbdump/pbdump_test.go
+++ b/internal/cmd/pbdump/pbdump_test.go
@@ -12,8 +12,8 @@
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
+ ptype "github.com/golang/protobuf/v2/internal/prototype"
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
- ptype "github.com/golang/protobuf/v2/reflect/prototype"
)
func TestFields(t *testing.T) {
diff --git a/internal/encoding/pack/pack_test.go b/internal/encoding/pack/pack_test.go
index 7ab0530..6ac901c 100644
--- a/internal/encoding/pack/pack_test.go
+++ b/internal/encoding/pack/pack_test.go
@@ -11,8 +11,8 @@
"math"
"testing"
+ ptype "github.com/golang/protobuf/v2/internal/prototype"
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
- ptype "github.com/golang/protobuf/v2/reflect/prototype"
cmp "github.com/google/go-cmp/cmp"
)
diff --git a/internal/encoding/tag/tag.go b/internal/encoding/tag/tag.go
index 3afedb8..4a57adc 100644
--- a/internal/encoding/tag/tag.go
+++ b/internal/encoding/tag/tag.go
@@ -12,9 +12,9 @@
"strings"
defval "github.com/golang/protobuf/v2/internal/encoding/defval"
+ ptype "github.com/golang/protobuf/v2/internal/prototype"
scalar "github.com/golang/protobuf/v2/internal/scalar"
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
- ptype "github.com/golang/protobuf/v2/reflect/prototype"
descriptorpb "github.com/golang/protobuf/v2/types/descriptor"
)
diff --git a/internal/encoding/tag/tag_test.go b/internal/encoding/tag/tag_test.go
index d137350..cb34993 100644
--- a/internal/encoding/tag/tag_test.go
+++ b/internal/encoding/tag/tag_test.go
@@ -8,8 +8,8 @@
"reflect"
"testing"
+ ptype "github.com/golang/protobuf/v2/internal/prototype"
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
- ptype "github.com/golang/protobuf/v2/reflect/prototype"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
)
diff --git a/internal/fileinit/desc.go b/internal/fileinit/desc.go
index 6e798d3..8c49f3c 100644
--- a/internal/fileinit/desc.go
+++ b/internal/fileinit/desc.go
@@ -14,10 +14,10 @@
"sync"
pragma "github.com/golang/protobuf/v2/internal/pragma"
+ ptype "github.com/golang/protobuf/v2/internal/prototype"
pfmt "github.com/golang/protobuf/v2/internal/typefmt"
"github.com/golang/protobuf/v2/proto"
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
- ptype "github.com/golang/protobuf/v2/reflect/prototype"
)
// FileBuilder construct a protoreflect.FileDescriptor from the
diff --git a/internal/fileinit/desc_lazy.go b/internal/fileinit/desc_lazy.go
index 2f7d3ca..0ff208a 100644
--- a/internal/fileinit/desc_lazy.go
+++ b/internal/fileinit/desc_lazy.go
@@ -13,9 +13,9 @@
defval "github.com/golang/protobuf/v2/internal/encoding/defval"
wire "github.com/golang/protobuf/v2/internal/encoding/wire"
pimpl "github.com/golang/protobuf/v2/internal/impl"
+ ptype "github.com/golang/protobuf/v2/internal/prototype"
pvalue "github.com/golang/protobuf/v2/internal/value"
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
- ptype "github.com/golang/protobuf/v2/reflect/prototype"
)
func (file *fileDesc) lazyInit() *fileLazy {
diff --git a/internal/impl/export.go b/internal/impl/export.go
index 0a153c4..a38390d 100644
--- a/internal/impl/export.go
+++ b/internal/impl/export.go
@@ -5,8 +5,8 @@
package impl
import (
+ ptype "github.com/golang/protobuf/v2/internal/prototype"
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
- ptype "github.com/golang/protobuf/v2/reflect/prototype"
)
// Export is a zero-length named type that exists only to export a set of
diff --git a/internal/impl/legacy_test.go b/internal/impl/legacy_test.go
index cf832fd..7fea32e 100644
--- a/internal/impl/legacy_test.go
+++ b/internal/impl/legacy_test.go
@@ -14,9 +14,9 @@
pack "github.com/golang/protobuf/v2/internal/encoding/pack"
pimpl "github.com/golang/protobuf/v2/internal/impl"
pragma "github.com/golang/protobuf/v2/internal/pragma"
+ ptype "github.com/golang/protobuf/v2/internal/prototype"
scalar "github.com/golang/protobuf/v2/internal/scalar"
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
- ptype "github.com/golang/protobuf/v2/reflect/prototype"
cmp "github.com/google/go-cmp/cmp"
cmpopts "github.com/google/go-cmp/cmp/cmpopts"
diff --git a/internal/impl/message_test.go b/internal/impl/message_test.go
index b7f3770..71bcb70 100644
--- a/internal/impl/message_test.go
+++ b/internal/impl/message_test.go
@@ -13,10 +13,10 @@
protoV1 "github.com/golang/protobuf/proto"
pimpl "github.com/golang/protobuf/v2/internal/impl"
+ ptype "github.com/golang/protobuf/v2/internal/prototype"
scalar "github.com/golang/protobuf/v2/internal/scalar"
pvalue "github.com/golang/protobuf/v2/internal/value"
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
- ptype "github.com/golang/protobuf/v2/reflect/prototype"
cmp "github.com/google/go-cmp/cmp"
cmpopts "github.com/google/go-cmp/cmp/cmpopts"
diff --git a/internal/legacy/enum.go b/internal/legacy/enum.go
index 89b5c87..98fd0fa 100644
--- a/internal/legacy/enum.go
+++ b/internal/legacy/enum.go
@@ -10,9 +10,9 @@
"reflect"
"sync"
+ ptype "github.com/golang/protobuf/v2/internal/prototype"
pvalue "github.com/golang/protobuf/v2/internal/value"
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
- ptype "github.com/golang/protobuf/v2/reflect/prototype"
descriptorpb "github.com/golang/protobuf/v2/types/descriptor"
)
diff --git a/internal/legacy/extension.go b/internal/legacy/extension.go
index 357dcb3..1626702 100644
--- a/internal/legacy/extension.go
+++ b/internal/legacy/extension.go
@@ -12,10 +12,10 @@
papi "github.com/golang/protobuf/protoapi"
ptag "github.com/golang/protobuf/v2/internal/encoding/tag"
pimpl "github.com/golang/protobuf/v2/internal/impl"
+ ptype "github.com/golang/protobuf/v2/internal/prototype"
pfmt "github.com/golang/protobuf/v2/internal/typefmt"
pvalue "github.com/golang/protobuf/v2/internal/value"
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
- ptype "github.com/golang/protobuf/v2/reflect/prototype"
)
// extensionDescKey is a comparable version of protoapi.ExtensionDesc
diff --git a/internal/legacy/extension_test.go b/internal/legacy/extension_test.go
index 9f431bd..440863f 100644
--- a/internal/legacy/extension_test.go
+++ b/internal/legacy/extension_test.go
@@ -9,8 +9,8 @@
papi "github.com/golang/protobuf/protoapi"
pimpl "github.com/golang/protobuf/v2/internal/impl"
+ ptype "github.com/golang/protobuf/v2/internal/prototype"
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
- ptype "github.com/golang/protobuf/v2/reflect/prototype"
// The legacy package must be imported prior to use of any legacy messages.
// TODO: Remove this when protoV1 registers these hooks for you.
diff --git a/internal/legacy/message.go b/internal/legacy/message.go
index 3a1b11b..c604ec8 100644
--- a/internal/legacy/message.go
+++ b/internal/legacy/message.go
@@ -13,9 +13,9 @@
ptag "github.com/golang/protobuf/v2/internal/encoding/tag"
pimpl "github.com/golang/protobuf/v2/internal/impl"
+ ptype "github.com/golang/protobuf/v2/internal/prototype"
scalar "github.com/golang/protobuf/v2/internal/scalar"
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
- ptype "github.com/golang/protobuf/v2/reflect/prototype"
descriptorpb "github.com/golang/protobuf/v2/types/descriptor"
)
diff --git a/reflect/prototype/desc_test.go b/internal/prototype/desc_test.go
similarity index 100%
rename from reflect/prototype/desc_test.go
rename to internal/prototype/desc_test.go
diff --git a/reflect/prototype/go_type.go b/internal/prototype/go_type.go
similarity index 100%
rename from reflect/prototype/go_type.go
rename to internal/prototype/go_type.go
diff --git a/reflect/prototype/name_pure.go b/internal/prototype/name_pure.go
similarity index 100%
rename from reflect/prototype/name_pure.go
rename to internal/prototype/name_pure.go
diff --git a/reflect/prototype/name_unsafe.go b/internal/prototype/name_unsafe.go
similarity index 100%
rename from reflect/prototype/name_unsafe.go
rename to internal/prototype/name_unsafe.go
diff --git a/reflect/prototype/options.go b/internal/prototype/options.go
similarity index 100%
rename from reflect/prototype/options.go
rename to internal/prototype/options.go
diff --git a/reflect/prototype/placeholder.go b/internal/prototype/placeholder.go
similarity index 100%
rename from reflect/prototype/placeholder.go
rename to internal/prototype/placeholder.go
diff --git a/reflect/prototype/placeholder_type.go b/internal/prototype/placeholder_type.go
similarity index 100%
rename from reflect/prototype/placeholder_type.go
rename to internal/prototype/placeholder_type.go
diff --git a/reflect/prototype/protofile.go b/internal/prototype/protofile.go
similarity index 98%
rename from reflect/prototype/protofile.go
rename to internal/prototype/protofile.go
index 9b141cd..6a9ad19 100644
--- a/reflect/prototype/protofile.go
+++ b/internal/prototype/protofile.go
@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// TODO: Delete this package and re-write functionality to depend on
+// reflect/protodesc and internal/fileinit.
+
// Package prototype provides builders to construct protobuf types that
// implement the interfaces defined in the protoreflect package.
//
diff --git a/reflect/prototype/protofile_list.go b/internal/prototype/protofile_list.go
similarity index 100%
rename from reflect/prototype/protofile_list.go
rename to internal/prototype/protofile_list.go
diff --git a/reflect/prototype/protofile_list_gen.go b/internal/prototype/protofile_list_gen.go
similarity index 100%
rename from reflect/prototype/protofile_list_gen.go
rename to internal/prototype/protofile_list_gen.go
diff --git a/reflect/prototype/protofile_type.go b/internal/prototype/protofile_type.go
similarity index 100%
rename from reflect/prototype/protofile_type.go
rename to internal/prototype/protofile_type.go
diff --git a/reflect/prototype/resolve_test.go b/internal/prototype/resolve_test.go
similarity index 100%
rename from reflect/prototype/resolve_test.go
rename to internal/prototype/resolve_test.go
diff --git a/reflect/prototype/standalone.go b/internal/prototype/standalone.go
similarity index 100%
rename from reflect/prototype/standalone.go
rename to internal/prototype/standalone.go
diff --git a/reflect/prototype/standalone_type.go b/internal/prototype/standalone_type.go
similarity index 100%
rename from reflect/prototype/standalone_type.go
rename to internal/prototype/standalone_type.go
diff --git a/reflect/prototype/type_test.go b/internal/prototype/type_test.go
similarity index 99%
rename from reflect/prototype/type_test.go
rename to internal/prototype/type_test.go
index 5064af4..07c0aab 100644
--- a/reflect/prototype/type_test.go
+++ b/internal/prototype/type_test.go
@@ -14,10 +14,10 @@
protoV1 "github.com/golang/protobuf/proto"
detrand "github.com/golang/protobuf/v2/internal/detrand"
+ ptype "github.com/golang/protobuf/v2/internal/prototype"
scalar "github.com/golang/protobuf/v2/internal/scalar"
pdesc "github.com/golang/protobuf/v2/reflect/protodesc"
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
- ptype "github.com/golang/protobuf/v2/reflect/prototype"
descriptorpb "github.com/golang/protobuf/v2/types/descriptor"
)
diff --git a/reflect/prototype/validate.go b/internal/prototype/validate.go
similarity index 100%
rename from reflect/prototype/validate.go
rename to internal/prototype/validate.go
diff --git a/reflect/protodesc/protodesc.go b/reflect/protodesc/protodesc.go
index e2b402b..41b4055 100644
--- a/reflect/protodesc/protodesc.go
+++ b/reflect/protodesc/protodesc.go
@@ -12,9 +12,9 @@
"github.com/golang/protobuf/v2/internal/encoding/defval"
"github.com/golang/protobuf/v2/internal/errors"
+ "github.com/golang/protobuf/v2/internal/prototype"
"github.com/golang/protobuf/v2/reflect/protoreflect"
"github.com/golang/protobuf/v2/reflect/protoregistry"
- "github.com/golang/protobuf/v2/reflect/prototype"
descriptorpb "github.com/golang/protobuf/v2/types/descriptor"
)
diff --git a/reflect/protoregistry/registry_test.go b/reflect/protoregistry/registry_test.go
index c7ddae4..ee9d742 100644
--- a/reflect/protoregistry/registry_test.go
+++ b/reflect/protoregistry/registry_test.go
@@ -14,9 +14,9 @@
"github.com/golang/protobuf/protoapi"
"github.com/golang/protobuf/v2/internal/legacy"
+ ptype "github.com/golang/protobuf/v2/internal/prototype"
pref "github.com/golang/protobuf/v2/reflect/protoreflect"
preg "github.com/golang/protobuf/v2/reflect/protoregistry"
- ptype "github.com/golang/protobuf/v2/reflect/prototype"
testpb "github.com/golang/protobuf/v2/reflect/protoregistry/testprotos"
)
diff --git a/types/descriptor/descriptor.pb.go b/types/descriptor/descriptor.pb.go
index 737dd86..5b34ef8 100644
--- a/types/descriptor/descriptor.pb.go
+++ b/types/descriptor/descriptor.pb.go
@@ -5,8 +5,8 @@
import (
protoapi "github.com/golang/protobuf/protoapi"
+ prototype "github.com/golang/protobuf/v2/internal/prototype"
protoreflect "github.com/golang/protobuf/v2/reflect/protoreflect"
- prototype "github.com/golang/protobuf/v2/reflect/prototype"
protoimpl "github.com/golang/protobuf/v2/runtime/protoimpl"
reflect "reflect"
)