Просмотр исходного кода

ptypes: regen and remove transforms from regen.sh

Ross Light 9 лет назад
Родитель
Сommit
8616e8ee5e

+ 34 - 4
ptypes/any/any.pb.go

@@ -28,8 +28,36 @@ var _ = math.Inf
 // proto package needs to be updated.
 const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
 
-// `Any` contains an arbitrary serialized message along with a URL
-// that describes the type of the serialized message.
+// `Any` contains an arbitrary serialized protocol buffer message along with a
+// URL that describes the type of the serialized message.
+//
+// Protobuf library provides support to pack/unpack Any values in the form
+// of utility functions or additional generated methods of the Any type.
+//
+// Example 1: Pack and unpack a message in C++.
+//
+//     Foo foo = ...;
+//     Any any;
+//     any.PackFrom(foo);
+//     ...
+//     if (any.UnpackTo(&foo)) {
+//       ...
+//     }
+//
+// Example 2: Pack and unpack a message in Java.
+//
+//     Foo foo = ...;
+//     Any any = Any.pack(foo);
+//     ...
+//     if (any.is(Foo.class)) {
+//       foo = any.unpack(Foo.class);
+//     }
+//
+// The pack methods provided by protobuf library will by default use
+// 'type.googleapis.com/full.type.name' as the type URL and the unpack
+// methods only use the fully qualified type name after the last '/'
+// in the type URL, for example "foo.bar.com/x/y.z" will yield type
+// name "y.z".
 //
 //
 // JSON
@@ -62,7 +90,7 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
 //
 type Any struct {
 	// A URL/resource name whose content describes the type of the
-	// serialized message.
+	// serialized protocol buffer message.
 	//
 	// For URLs which use the schema `http`, `https`, or no schema, the
 	// following restrictions and interpretations apply:
@@ -70,6 +98,8 @@ type Any struct {
 	// * If no schema is provided, `https` is assumed.
 	// * The last segment of the URL's path must represent the fully
 	//   qualified name of the type (as in `path/google.protobuf.Duration`).
+	//   The name should be in a canonical form (e.g., leading "." is
+	//   not accepted).
 	// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
 	//   value in binary format, or produce an error.
 	// * Applications are allowed to cache lookup results based on the
@@ -82,7 +112,7 @@ type Any struct {
 	// used with implementation specific semantics.
 	//
 	TypeUrl string `protobuf:"bytes,1,opt,name=type_url,json=typeUrl" json:"type_url,omitempty"`
-	// Must be valid serialized data of the above specified type.
+	// Must be a valid serialized protocol buffer of the above specified type.
 	Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
 }
 

+ 35 - 5
ptypes/any/any.proto

@@ -31,17 +31,45 @@
 syntax = "proto3";
 
 package google.protobuf;
-option go_package = "github.com/golang/protobuf/ptypes/any";
 
 option csharp_namespace = "Google.Protobuf.WellKnownTypes";
+option go_package = "github.com/golang/protobuf/ptypes/any";
 option java_package = "com.google.protobuf";
 option java_outer_classname = "AnyProto";
 option java_multiple_files = true;
 option java_generate_equals_and_hash = true;
 option objc_class_prefix = "GPB";
 
-// `Any` contains an arbitrary serialized message along with a URL
-// that describes the type of the serialized message.
+// `Any` contains an arbitrary serialized protocol buffer message along with a
+// URL that describes the type of the serialized message.
+//
+// Protobuf library provides support to pack/unpack Any values in the form
+// of utility functions or additional generated methods of the Any type.
+//
+// Example 1: Pack and unpack a message in C++.
+//
+//     Foo foo = ...;
+//     Any any;
+//     any.PackFrom(foo);
+//     ...
+//     if (any.UnpackTo(&foo)) {
+//       ...
+//     }
+//
+// Example 2: Pack and unpack a message in Java.
+//
+//     Foo foo = ...;
+//     Any any = Any.pack(foo);
+//     ...
+//     if (any.is(Foo.class)) {
+//       foo = any.unpack(Foo.class);
+//     }
+//
+// The pack methods provided by protobuf library will by default use
+// 'type.googleapis.com/full.type.name' as the type URL and the unpack
+// methods only use the fully qualified type name after the last '/'
+// in the type URL, for example "foo.bar.com/x/y.z" will yield type
+// name "y.z".
 //
 //
 // JSON
@@ -74,7 +102,7 @@ option objc_class_prefix = "GPB";
 //
 message Any {
   // A URL/resource name whose content describes the type of the
-  // serialized message.
+  // serialized protocol buffer message.
   //
   // For URLs which use the schema `http`, `https`, or no schema, the
   // following restrictions and interpretations apply:
@@ -82,6 +110,8 @@ message Any {
   // * If no schema is provided, `https` is assumed.
   // * The last segment of the URL's path must represent the fully
   //   qualified name of the type (as in `path/google.protobuf.Duration`).
+  //   The name should be in a canonical form (e.g., leading "." is
+  //   not accepted).
   // * An HTTP GET on the URL must yield a [google.protobuf.Type][]
   //   value in binary format, or produce an error.
   // * Applications are allowed to cache lookup results based on the
@@ -95,6 +125,6 @@ message Any {
   //
   string type_url = 1;
 
-  // Must be valid serialized data of the above specified type.
+  // Must be a valid serialized protocol buffer of the above specified type.
   bytes value = 2;
 }

+ 1 - 0
ptypes/duration/duration.pb.go

@@ -69,6 +69,7 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
 //       end.nanos -= 1000000000;
 //     }
 //
+//
 type Duration struct {
 	// Signed seconds of the span of time. Must be from -315,576,000,000
 	// to +315,576,000,000 inclusive.

+ 2 - 1
ptypes/duration/duration.proto

@@ -31,9 +31,9 @@
 syntax = "proto3";
 
 package google.protobuf;
-option go_package = "github.com/golang/protobuf/ptypes/duration";
 
 option csharp_namespace = "Google.Protobuf.WellKnownTypes";
+option go_package = "github.com/golang/protobuf/ptypes/duration";
 option java_package = "com.google.protobuf";
 option java_outer_classname = "DurationProto";
 option java_multiple_files = true;
@@ -81,6 +81,7 @@ option objc_class_prefix = "GPB";
 //       end.nanos -= 1000000000;
 //     }
 //
+//
 message Duration {
 
   // Signed seconds of the span of time. Must be from -315,576,000,000

+ 1 - 1
ptypes/empty/empty.proto

@@ -31,9 +31,9 @@
 syntax = "proto3";
 
 package google.protobuf;
-option go_package = "github.com/golang/protobuf/ptypes/empty";
 
 option csharp_namespace = "Google.Protobuf.WellKnownTypes";
+option go_package = "github.com/golang/protobuf/ptypes/empty";
 option java_package = "com.google.protobuf";
 option java_outer_classname = "EmptyProto";
 option java_multiple_files = true;

+ 2 - 8
ptypes/regen.sh

@@ -51,17 +51,11 @@ for f in $(cd $PKG && find * -name '*.proto'); do
   fi
   filename_map[$up]=$f
 done
-# Pass 2: copy files, making necessary adjustments.
+# Pass 2: copy files
 for up in "${!filename_map[@]}"; do
   f=${filename_map[$up]}
   shortname=$(basename $f | sed 's,\.proto$,,')
-  cat $tmpdir/$UPSTREAM_SUBDIR/$up |
-    # Adjust proto package.
-    # TODO(dsymonds): Remove when the right go_package options are upstream.
-    sed '/^package /a option go_package = "github.com\/golang\/protobuf\/ptypes\/'${shortname}'";' |
-    # Unfortunately "package struct" and "package type" don't work.
-    sed '/option go_package/s,struct",struct;structpb",' |
-    cat > $PKG/$f
+  cp $tmpdir/$UPSTREAM_SUBDIR/$up $PKG/$f
 done
 
 # Run protoc once per package.

+ 1 - 1
ptypes/struct/struct.pb.go

@@ -63,7 +63,7 @@ func (NullValue) XXX_WellKnownType() string       { return "NullValue" }
 //
 // The JSON representation for `Struct` is JSON object.
 type Struct struct {
-	// Map of dynamically typed values.
+	// Unordered map of dynamically typed values.
 	Fields map[string]*Value `protobuf:"bytes,1,rep,name=fields" json:"fields,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
 }
 

+ 2 - 2
ptypes/struct/struct.proto

@@ -31,9 +31,9 @@
 syntax = "proto3";
 
 package google.protobuf;
-option go_package = "github.com/golang/protobuf/ptypes/struct;structpb";
 
 option csharp_namespace = "Google.Protobuf.WellKnownTypes";
+option go_package = "github.com/golang/protobuf/ptypes/struct;structpb";
 option java_package = "com.google.protobuf";
 option java_outer_classname = "StructProto";
 option java_multiple_files = true;
@@ -50,7 +50,7 @@ option objc_class_prefix = "GPB";
 //
 // The JSON representation for `Struct` is JSON object.
 message Struct {
-  // Map of dynamically typed values.
+  // Unordered map of dynamically typed values.
   map<string, Value> fields = 1;
 }
 

+ 1 - 1
ptypes/timestamp/timestamp.proto

@@ -31,10 +31,10 @@
 syntax = "proto3";
 
 package google.protobuf;
-option go_package = "github.com/golang/protobuf/ptypes/timestamp";
 
 option csharp_namespace = "Google.Protobuf.WellKnownTypes";
 option cc_enable_arenas = true;
+option go_package = "github.com/golang/protobuf/ptypes/timestamp";
 option java_package = "com.google.protobuf";
 option java_outer_classname = "TimestampProto";
 option java_multiple_files = true;

+ 1 - 1
ptypes/wrappers/wrappers.proto

@@ -36,10 +36,10 @@
 syntax = "proto3";
 
 package google.protobuf;
-option go_package = "github.com/golang/protobuf/ptypes/wrappers";
 
 option csharp_namespace = "Google.Protobuf.WellKnownTypes";
 option cc_enable_arenas = true;
+option go_package = "github.com/golang/protobuf/ptypes/wrappers";
 option java_package = "com.google.protobuf";
 option java_outer_classname = "WrappersProto";
 option java_multiple_files = true;