diff --git a/gogoproto/gogo.proto b/gogoproto/gogo.proto index f8f7463b2e..b80c85653f 100644 --- a/gogoproto/gogo.proto +++ b/gogoproto/gogo.proto @@ -139,4 +139,6 @@ extend google.protobuf.FieldOptions { optional bool stdtime = 65010; optional bool stdduration = 65011; + optional bool wktpointer = 65012; + } diff --git a/gogoproto/helper.go b/gogoproto/helper.go index c8cafe69a3..390d4e4be6 100644 --- a/gogoproto/helper.go +++ b/gogoproto/helper.go @@ -47,6 +47,55 @@ func IsStdDuration(field *google_protobuf.FieldDescriptorProto) bool { return proto.GetBoolExtension(field.Options, E_Stdduration, false) } +func IsStdDouble(field *google_protobuf.FieldDescriptorProto) bool { + return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.DoubleValue" +} + +func IsStdFloat(field *google_protobuf.FieldDescriptorProto) bool { + return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.FloatValue" +} + +func IsStdInt64(field *google_protobuf.FieldDescriptorProto) bool { + return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.Int64Value" +} + +func IsStdUInt64(field *google_protobuf.FieldDescriptorProto) bool { + return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.UInt64Value" +} + +func IsStdInt32(field *google_protobuf.FieldDescriptorProto) bool { + return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.Int32Value" +} + +func IsStdUInt32(field *google_protobuf.FieldDescriptorProto) bool { + return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.UInt32Value" +} + +func IsStdBool(field *google_protobuf.FieldDescriptorProto) bool { + return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.BoolValue" +} + +func IsStdString(field *google_protobuf.FieldDescriptorProto) bool { + return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.StringValue" +} + +func IsStdBytes(field *google_protobuf.FieldDescriptorProto) bool { + return proto.GetBoolExtension(field.Options, E_Wktpointer, false) && *field.TypeName == ".google.protobuf.BytesValue" +} + +func IsStdType(field *google_protobuf.FieldDescriptorProto) bool { + return (IsStdTime(field) || IsStdDuration(field) || + IsStdDouble(field) || IsStdFloat(field) || + IsStdInt64(field) || IsStdUInt64(field) || + IsStdInt32(field) || IsStdUInt32(field) || + IsStdBool(field) || + IsStdString(field) || IsStdBytes(field)) +} + +func IsWktPtr(field *google_protobuf.FieldDescriptorProto) bool { + return proto.GetBoolExtension(field.Options, E_Wktpointer, false) +} + func NeedsNilCheck(proto3 bool, field *google_protobuf.FieldDescriptorProto) bool { nullable := IsNullable(field) if field.IsMessage() || IsCustomType(field) { diff --git a/plugin/equal/equal.go b/plugin/equal/equal.go index 41a2c97041..6358fc99ad 100644 --- a/plugin/equal/equal.go +++ b/plugin/equal/equal.go @@ -292,7 +292,16 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato repeated := field.IsRepeated() ctype := gogoproto.IsCustomType(field) nullable := gogoproto.IsNullable(field) - isDuration := gogoproto.IsStdDuration(field) + isNormal := (gogoproto.IsStdDuration(field) || + gogoproto.IsStdDouble(field) || + gogoproto.IsStdFloat(field) || + gogoproto.IsStdInt64(field) || + gogoproto.IsStdUInt64(field) || + gogoproto.IsStdInt32(field) || + gogoproto.IsStdUInt32(field) || + gogoproto.IsStdBool(field) || + gogoproto.IsStdString(field)) + isBytes := gogoproto.IsStdBytes(field) isTimestamp := gogoproto.IsStdTime(field) // oneof := field.OneofIndex != nil if !repeated { @@ -322,7 +331,7 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato } p.Out() p.P(`}`) - } else if isDuration { + } else if isNormal { if nullable { p.generateNullableField(fieldname, verbose) } else { @@ -336,6 +345,32 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato } p.Out() p.P(`}`) + } else if isBytes { + if nullable { + p.P(`if that1.`, fieldname, ` == nil {`) + p.In() + p.P(`if this.`, fieldname, ` != nil {`) + p.In() + if verbose { + p.P(`return `, p.fmtPkg.Use(), `.Errorf("this.`, fieldname, ` != nil && that1.`, fieldname, ` == nil")`) + } else { + p.P(`return false`) + } + p.Out() + p.P(`}`) + p.Out() + p.P(`} else if !`, p.bytesPkg.Use(), `.Equal(*this.`, fieldname, `, *that1.`, fieldname, `) {`) + } else { + p.P(`if !`, p.bytesPkg.Use(), `.Equal(this.`, fieldname, `, that1.`, fieldname, `) {`) + } + p.In() + if verbose { + p.P(`return `, p.fmtPkg.Use(), `.Errorf("`, fieldname, ` this(%v) Not Equal that(%v)", this.`, fieldname, `, that1.`, fieldname, `)`) + } else { + p.P(`return false`) + } + p.Out() + p.P(`}`) } else { if field.IsMessage() || p.IsGroup(field) { if nullable { @@ -387,12 +422,18 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato } else { p.P(`if !this.`, fieldname, `[i].Equal(that1.`, fieldname, `[i]) {`) } - } else if isDuration { + } else if isNormal { if nullable { p.P(`if dthis, dthat := this.`, fieldname, `[i], that1.`, fieldname, `[i]; (dthis != nil && dthat != nil && *dthis != *dthat) || (dthis != nil && dthat == nil) || (dthis == nil && dthat != nil) {`) } else { p.P(`if this.`, fieldname, `[i] != that1.`, fieldname, `[i] {`) } + } else if isBytes { + if nullable { + p.P(`if !`, p.bytesPkg.Use(), `.Equal(*this.`, fieldname, `[i], *that1.`, fieldname, `[i]) {`) + } else { + p.P(`if !`, p.bytesPkg.Use(), `.Equal(this.`, fieldname, `[i], that1.`, fieldname, `[i]) {`) + } } else { if p.IsMap(field) { m := p.GoMapType(nil, field) @@ -401,6 +442,16 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato nullable, valuegoTyp, valuegoAliasTyp = generator.GoMapValueTypes(field, m.ValueField, valuegoTyp, valuegoAliasTyp) mapValue := m.ValueAliasField + mapValueNormal := (gogoproto.IsStdDuration(mapValue) || + gogoproto.IsStdDouble(mapValue) || + gogoproto.IsStdFloat(mapValue) || + gogoproto.IsStdInt64(mapValue) || + gogoproto.IsStdUInt64(mapValue) || + gogoproto.IsStdInt32(mapValue) || + gogoproto.IsStdUInt32(mapValue) || + gogoproto.IsStdBool(mapValue) || + gogoproto.IsStdString(mapValue)) + mapValueBytes := gogoproto.IsStdBytes(mapValue) if mapValue.IsMessage() || p.IsGroup(mapValue) { if nullable && valuegoTyp == valuegoAliasTyp { p.P(`if !this.`, fieldname, `[i].Equal(that1.`, fieldname, `[i]) {`) @@ -408,14 +459,26 @@ func (p *plugin) generateField(file *generator.FileDescriptor, message *generato // Equal() has a pointer receiver, but map value is a value type a := `this.` + fieldname + `[i]` b := `that1.` + fieldname + `[i]` - if valuegoTyp != valuegoAliasTyp { + if !mapValueNormal && !mapValueBytes && valuegoTyp != valuegoAliasTyp { // cast back to the type that has the generated methods on it a = `(` + valuegoTyp + `)(` + a + `)` b = `(` + valuegoTyp + `)(` + b + `)` } p.P(`a := `, a) p.P(`b := `, b) - if nullable { + if mapValueNormal { + if nullable { + p.P(`if *a != *b {`) + } else { + p.P(`if a != b {`) + } + } else if mapValueBytes { + if nullable { + p.P(`if !`, p.bytesPkg.Use(), `.Equal(*a, *b) {`) + } else { + p.P(`if !`, p.bytesPkg.Use(), `.Equal(a, b) {`) + } + } else if nullable { p.P(`if !a.Equal(b) {`) } else { p.P(`if !(&a).Equal(&b) {`) diff --git a/plugin/gostring/gostring.go b/plugin/gostring/gostring.go index 31e01e898d..6003d65f22 100644 --- a/plugin/gostring/gostring.go +++ b/plugin/gostring/gostring.go @@ -225,7 +225,7 @@ func (p *gostring) Generate(file *generator.FileDescriptor) { p.P(`s = append(s, "`, fieldname, `: " + `, mapName, `+ ",\n")`) p.Out() p.P(`}`) - } else if (field.IsMessage() && !gogoproto.IsCustomType(field) && !gogoproto.IsStdTime(field) && !gogoproto.IsStdDuration(field)) || p.IsGroup(field) { + } else if (field.IsMessage() && !gogoproto.IsCustomType(field) && !gogoproto.IsStdType(field)) || p.IsGroup(field) { if nullable || repeated { p.P(`if this.`, fieldname, ` != nil {`) p.In() diff --git a/plugin/marshalto/marshalto.go b/plugin/marshalto/marshalto.go index 24110cb443..3da7a77ad3 100644 --- a/plugin/marshalto/marshalto.go +++ b/plugin/marshalto/marshalto.go @@ -313,12 +313,39 @@ func (p *marshalto) mapField(numGen NumGen, field *descriptor.FieldDescriptorPro case descriptor.FieldDescriptorProto_TYPE_SINT64: p.callVarint(`(uint64(`, varName, `) << 1) ^ uint64((`, varName, ` >> 63))`) case descriptor.FieldDescriptorProto_TYPE_MESSAGE: - if gogoproto.IsStdTime(field) { + if gogoproto.IsStdTime(kvField) { p.callVarint(p.typesPkg.Use(), `.SizeOfStdTime(*`, varName, `)`) p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdTimeMarshalTo(*`, varName, `, dAtA[i:])`) - } else if gogoproto.IsStdDuration(field) { + } else if gogoproto.IsStdDuration(kvField) { p.callVarint(p.typesPkg.Use(), `.SizeOfStdDuration(*`, varName, `)`) p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdDurationMarshalTo(*`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdDouble(kvField) { + p.callVarint(p.typesPkg.Use(), `.SizeOfStdDouble(*`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdDoubleMarshalTo(*`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdFloat(kvField) { + p.callVarint(p.typesPkg.Use(), `.SizeOfStdFloat(*`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdFloatMarshalTo(*`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdInt64(kvField) { + p.callVarint(p.typesPkg.Use(), `.SizeOfStdInt64(*`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdInt64MarshalTo(*`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdUInt64(kvField) { + p.callVarint(p.typesPkg.Use(), `.SizeOfStdUInt64(*`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdUInt64MarshalTo(*`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdInt32(kvField) { + p.callVarint(p.typesPkg.Use(), `.SizeOfStdInt32(*`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdInt32MarshalTo(*`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdUInt32(kvField) { + p.callVarint(p.typesPkg.Use(), `.SizeOfStdUInt32(*`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdUInt32MarshalTo(*`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdBool(kvField) { + p.callVarint(p.typesPkg.Use(), `.SizeOfStdBool(*`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdBoolMarshalTo(*`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdString(kvField) { + p.callVarint(p.typesPkg.Use(), `.SizeOfStdString(*`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdStringMarshalTo(*`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdBytes(kvField) { + p.callVarint(p.typesPkg.Use(), `.SizeOfStdBytes(*`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdBytesMarshalTo(*`, varName, `, dAtA[i:])`) } else if protoSizer { p.callVarint(varName, `.ProtoSize()`) p.P(`n`, numGen.Next(), `, err := `, varName, `.MarshalTo(dAtA[i:])`) @@ -781,8 +808,7 @@ func (p *marshalto) generateField(proto3 bool, numGen NumGen, file *generator.Fi sum = append(sum, `soz`+p.localName+`(uint64(v))`) case descriptor.FieldDescriptorProto_TYPE_MESSAGE: if valuegoTyp != valuegoAliasTyp && - !gogoproto.IsStdTime(field) && - !gogoproto.IsStdDuration(field) { + !gogoproto.IsStdType(m.ValueAliasField) { if nullable { // cast back to the type that has the generated methods on it accessor = `((` + valuegoTyp + `)(` + accessor + `))` @@ -795,10 +821,28 @@ func (p *marshalto) generateField(proto3 bool, numGen NumGen, file *generator.Fi p.P(`msgSize := 0`) p.P(`if `, accessor, ` != nil {`) p.In() - if gogoproto.IsStdTime(field) { + if gogoproto.IsStdTime(m.ValueAliasField) { p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdTime(*`, accessor, `)`) - } else if gogoproto.IsStdDuration(field) { + } else if gogoproto.IsStdDuration(m.ValueAliasField) { p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdDuration(*`, accessor, `)`) + } else if gogoproto.IsStdDouble(m.ValueAliasField) { + p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdDouble(*`, accessor, `)`) + } else if gogoproto.IsStdFloat(m.ValueAliasField) { + p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdFloat(*`, accessor, `)`) + } else if gogoproto.IsStdInt64(m.ValueAliasField) { + p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdInt64(*`, accessor, `)`) + } else if gogoproto.IsStdUInt64(m.ValueAliasField) { + p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdUInt64(*`, accessor, `)`) + } else if gogoproto.IsStdInt32(m.ValueAliasField) { + p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdInt32(*`, accessor, `)`) + } else if gogoproto.IsStdUInt32(m.ValueAliasField) { + p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdUInt32(*`, accessor, `)`) + } else if gogoproto.IsStdBool(m.ValueAliasField) { + p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdBool(*`, accessor, `)`) + } else if gogoproto.IsStdString(m.ValueAliasField) { + p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdString(*`, accessor, `)`) + } else if gogoproto.IsStdBytes(m.ValueAliasField) { + p.P(`msgSize = `, p.typesPkg.Use(), `.SizeOfStdBytes(*`, accessor, `)`) } else if protoSizer { p.P(`msgSize = `, accessor, `.ProtoSize()`) } else { @@ -828,7 +872,7 @@ func (p *marshalto) generateField(proto3 bool, numGen NumGen, file *generator.Fi p.In() } p.encodeKey(2, wireToType(valuewire)) - p.mapField(numGen, field, m.ValueField, accessor, protoSizer) + p.mapField(numGen, field, m.ValueAliasField, accessor, protoSizer) if nullableMsg || plainBytes { p.Out() p.P(`}`) @@ -852,6 +896,60 @@ func (p *marshalto) generateField(proto3 bool, numGen NumGen, file *generator.Fi } p.callVarint(p.typesPkg.Use(), `.SizeOfStdDuration(`, varName, `)`) p.P(`n, err := `, p.typesPkg.Use(), `.StdDurationMarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdDouble(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdDouble(`, varName, `)`) + p.P(`n, err := `, p.typesPkg.Use(), `.StdDoubleMarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdFloat(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdFloat(`, varName, `)`) + p.P(`n, err := `, p.typesPkg.Use(), `.StdFloatMarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdInt64(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdInt64(`, varName, `)`) + p.P(`n, err := `, p.typesPkg.Use(), `.StdInt64MarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdUInt64(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdUInt64(`, varName, `)`) + p.P(`n, err := `, p.typesPkg.Use(), `.StdUInt64MarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdInt32(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdInt32(`, varName, `)`) + p.P(`n, err := `, p.typesPkg.Use(), `.StdInt32MarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdUInt32(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdUInt32(`, varName, `)`) + p.P(`n, err := `, p.typesPkg.Use(), `.StdUInt32MarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdBool(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdBool(`, varName, `)`) + p.P(`n, err := `, p.typesPkg.Use(), `.StdBoolMarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdString(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdString(`, varName, `)`) + p.P(`n, err := `, p.typesPkg.Use(), `.StdStringMarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdBytes(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdBytes(`, varName, `)`) + p.P(`n, err := `, p.typesPkg.Use(), `.StdBytesMarshalTo(`, varName, `, dAtA[i:])`) } else if protoSizer { p.callVarint(varName, ".ProtoSize()") p.P(`n, err := `, varName, `.MarshalTo(dAtA[i:])`) @@ -882,6 +980,60 @@ func (p *marshalto) generateField(proto3 bool, numGen NumGen, file *generator.Fi } p.callVarint(p.typesPkg.Use(), `.SizeOfStdDuration(`, varName, `)`) p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdDurationMarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdDouble(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdDouble(`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdDoubleMarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdFloat(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdFloat(`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdFloatMarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdInt64(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdInt64(`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdInt64MarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdUInt64(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdUInt64(`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdUInt64MarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdInt32(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdInt32(`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdInt32MarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdUInt32(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdUInt32(`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdUInt32MarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdBool(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdBool(`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdBoolMarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdString(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdString(`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdStringMarshalTo(`, varName, `, dAtA[i:])`) + } else if gogoproto.IsStdBytes(field) { + if gogoproto.IsNullable(field) { + varName = "*" + varName + } + p.callVarint(p.typesPkg.Use(), `.SizeOfStdBytes(`, varName, `)`) + p.P(`n`, numGen.Next(), `, err := `, p.typesPkg.Use(), `.StdBytesMarshalTo(`, varName, `, dAtA[i:])`) } else if protoSizer { p.callVarint(varName, `.ProtoSize()`) p.P(`n`, numGen.Next(), `, err := `, varName, `.MarshalTo(dAtA[i:])`) diff --git a/plugin/populate/populate.go b/plugin/populate/populate.go index 40869581b5..19b9e3e90d 100644 --- a/plugin/populate/populate.go +++ b/plugin/populate/populate.go @@ -182,7 +182,7 @@ func negative(fieldType descriptor.FieldDescriptorProto_Type) bool { return true } -func (p *plugin) getFuncName(goTypName string) string { +func (p *plugin) getFuncName(goTypName string, field *descriptor.FieldDescriptorProto) string { funcName := "NewPopulated" + goTypName goTypNames := strings.Split(goTypName, ".") if len(goTypNames) == 2 { @@ -190,23 +190,43 @@ func (p *plugin) getFuncName(goTypName string) string { } else if len(goTypNames) != 1 { panic(fmt.Errorf("unreachable: too many dots in %v", goTypName)) } - switch funcName { - case "time.NewPopulatedTime": - funcName = p.typesPkg.Use() + ".NewPopulatedStdTime" - case "time.NewPopulatedDuration": - funcName = p.typesPkg.Use() + ".NewPopulatedStdDuration" + if field != nil { + switch { + case gogoproto.IsStdTime(field): + funcName = p.typesPkg.Use() + ".NewPopulatedStdTime" + case gogoproto.IsStdDuration(field): + funcName = p.typesPkg.Use() + ".NewPopulatedStdDuration" + case gogoproto.IsStdDouble(field): + funcName = p.typesPkg.Use() + ".NewPopulatedStdDouble" + case gogoproto.IsStdFloat(field): + funcName = p.typesPkg.Use() + ".NewPopulatedStdFloat" + case gogoproto.IsStdInt64(field): + funcName = p.typesPkg.Use() + ".NewPopulatedStdInt64" + case gogoproto.IsStdUInt64(field): + funcName = p.typesPkg.Use() + ".NewPopulatedStdUInt64" + case gogoproto.IsStdInt32(field): + funcName = p.typesPkg.Use() + ".NewPopulatedStdInt32" + case gogoproto.IsStdUInt32(field): + funcName = p.typesPkg.Use() + ".NewPopulatedStdUInt32" + case gogoproto.IsStdBool(field): + funcName = p.typesPkg.Use() + ".NewPopulatedStdBool" + case gogoproto.IsStdString(field): + funcName = p.typesPkg.Use() + ".NewPopulatedStdString" + case gogoproto.IsStdBytes(field): + funcName = p.typesPkg.Use() + ".NewPopulatedStdBytes" + } } return funcName } -func (p *plugin) getFuncCall(goTypName string) string { - funcName := p.getFuncName(goTypName) +func (p *plugin) getFuncCall(goTypName string, field *descriptor.FieldDescriptorProto) string { + funcName := p.getFuncName(goTypName, field) funcCall := funcName + "(r, easy)" return funcCall } func (p *plugin) getCustomFuncCall(goTypName string) string { - funcName := p.getFuncName(goTypName) + funcName := p.getFuncName(goTypName, nil) funcCall := funcName + "(r)" return funcCall } @@ -259,13 +279,13 @@ func (p *plugin) GenerateField(file *generator.FileDescriptor, message *generato if m.ValueField.IsMessage() || p.IsGroup(field) || (m.ValueField.IsBytes() && gogoproto.IsCustomType(field)) { s := `this.` + fieldname + `[` + keyval + `] = ` - if gogoproto.IsStdTime(field) || gogoproto.IsStdDuration(field) { + if gogoproto.IsStdType(field) { valuegoTyp = valuegoAliasTyp } funcCall := p.getCustomFuncCall(goTypName) if !gogoproto.IsCustomType(field) { goTypName = generator.GoTypeToName(valuegoTyp) - funcCall = p.getFuncCall(goTypName) + funcCall = p.getFuncCall(goTypName, m.ValueAliasField) } if !nullable { funcCall = `*` + funcCall @@ -322,7 +342,7 @@ func (p *plugin) GenerateField(file *generator.FileDescriptor, message *generato p.P(`this.`, fieldname, ` = *`, p.varGen.Current()) } } else if field.IsMessage() || p.IsGroup(field) { - funcCall := p.getFuncCall(goTypName) + funcCall := p.getFuncCall(goTypName, field) if field.IsRepeated() { p.P(p.varGen.Next(), ` := r.Intn(5)`) p.P(`this.`, fieldname, ` = make(`, goTyp, `, `, p.varGen.Current(), `)`) diff --git a/plugin/size/size.go b/plugin/size/size.go index 20e66678c4..10aa2f449d 100644 --- a/plugin/size/size.go +++ b/plugin/size/size.go @@ -206,18 +206,32 @@ func (p *size) sizeZigZag() { } func (p *size) std(field *descriptor.FieldDescriptorProto, name string) (string, bool) { + ptr := "" + if gogoproto.IsNullable(field) { + ptr = "*" + } if gogoproto.IsStdTime(field) { - if gogoproto.IsNullable(field) { - return p.typesPkg.Use() + `.SizeOfStdTime(*` + name + `)`, true - } else { - return p.typesPkg.Use() + `.SizeOfStdTime(` + name + `)`, true - } + return p.typesPkg.Use() + `.SizeOfStdTime(` + ptr + name + `)`, true } else if gogoproto.IsStdDuration(field) { - if gogoproto.IsNullable(field) { - return p.typesPkg.Use() + `.SizeOfStdDuration(*` + name + `)`, true - } else { - return p.typesPkg.Use() + `.SizeOfStdDuration(` + name + `)`, true - } + return p.typesPkg.Use() + `.SizeOfStdDuration(` + ptr + name + `)`, true + } else if gogoproto.IsStdDouble(field) { + return p.typesPkg.Use() + `.SizeOfStdDouble(` + ptr + name + `)`, true + } else if gogoproto.IsStdFloat(field) { + return p.typesPkg.Use() + `.SizeOfStdFloat(` + ptr + name + `)`, true + } else if gogoproto.IsStdInt64(field) { + return p.typesPkg.Use() + `.SizeOfStdInt64(` + ptr + name + `)`, true + } else if gogoproto.IsStdUInt64(field) { + return p.typesPkg.Use() + `.SizeOfStdUInt64(` + ptr + name + `)`, true + } else if gogoproto.IsStdInt32(field) { + return p.typesPkg.Use() + `.SizeOfStdInt32(` + ptr + name + `)`, true + } else if gogoproto.IsStdUInt32(field) { + return p.typesPkg.Use() + `.SizeOfStdUInt32(` + ptr + name + `)`, true + } else if gogoproto.IsStdBool(field) { + return p.typesPkg.Use() + `.SizeOfStdBool(` + ptr + name + `)`, true + } else if gogoproto.IsStdString(field) { + return p.typesPkg.Use() + `.SizeOfStdString(` + ptr + name + `)`, true + } else if gogoproto.IsStdBytes(field) { + return p.typesPkg.Use() + `.SizeOfStdBytes(` + ptr + name + `)`, true } return "", false } @@ -447,7 +461,7 @@ func (p *size) generateField(proto3 bool, file *generator.FileDescriptor, messag sum = append(sum, strconv.Itoa(valueKeySize)) sum = append(sum, `soz`+p.localName+`(uint64(v))`) case descriptor.FieldDescriptorProto_TYPE_MESSAGE: - stdSizeCall, stdOk := p.std(field, "v") + stdSizeCall, stdOk := p.std(m.ValueAliasField, "v") if nullable { p.P(`l = 0`) p.P(`if v != nil {`) diff --git a/plugin/unmarshal/unmarshal.go b/plugin/unmarshal/unmarshal.go index d7cfb59400..38b13b61de 100644 --- a/plugin/unmarshal/unmarshal.go +++ b/plugin/unmarshal/unmarshal.go @@ -280,6 +280,24 @@ func (p *unmarshal) declareMapField(varName string, nullable bool, customType bo p.P(varName, ` := new(time.Time)`) } else if gogoproto.IsStdDuration(field) { p.P(varName, ` := new(time.Duration)`) + } else if gogoproto.IsStdDouble(field) { + p.P(varName, ` := new(float64)`) + } else if gogoproto.IsStdFloat(field) { + p.P(varName, ` := new(float32)`) + } else if gogoproto.IsStdInt64(field) { + p.P(varName, ` := new(int64)`) + } else if gogoproto.IsStdUInt64(field) { + p.P(varName, ` := new(uint64)`) + } else if gogoproto.IsStdInt32(field) { + p.P(varName, ` := new(int32)`) + } else if gogoproto.IsStdUInt32(field) { + p.P(varName, ` := new(uint32)`) + } else if gogoproto.IsStdBool(field) { + p.P(varName, ` := new(bool)`) + } else if gogoproto.IsStdString(field) { + p.P(varName, ` := new(string)`) + } else if gogoproto.IsStdBytes(field) { + p.P(varName, ` := new([]byte)`) } else { desc := p.ObjectNamed(field.GetTypeName()) msgname := p.TypeName(desc) @@ -383,6 +401,24 @@ func (p *unmarshal) mapField(varName string, customType bool, field *descriptor. p.P(`if err := `, p.typesPkg.Use(), `.StdTimeUnmarshal(`, varName, `, `, buf, `); err != nil {`) } else if gogoproto.IsStdDuration(field) { p.P(`if err := `, p.typesPkg.Use(), `.StdDurationUnmarshal(`, varName, `, `, buf, `); err != nil {`) + } else if gogoproto.IsStdDouble(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdDoubleUnmarshal(`, varName, `, `, buf, `); err != nil {`) + } else if gogoproto.IsStdFloat(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdFloatUnmarshal(`, varName, `, `, buf, `); err != nil {`) + } else if gogoproto.IsStdInt64(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdInt64Unmarshal(`, varName, `, `, buf, `); err != nil {`) + } else if gogoproto.IsStdUInt64(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdUInt64Unmarshal(`, varName, `, `, buf, `); err != nil {`) + } else if gogoproto.IsStdInt32(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdInt32Unmarshal(`, varName, `, `, buf, `); err != nil {`) + } else if gogoproto.IsStdUInt32(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdUInt32Unmarshal(`, varName, `, `, buf, `); err != nil {`) + } else if gogoproto.IsStdBool(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdBoolUnmarshal(`, varName, `, `, buf, `); err != nil {`) + } else if gogoproto.IsStdString(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdStringUnmarshal(`, varName, `, `, buf, `); err != nil {`) + } else if gogoproto.IsStdBytes(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdBytesUnmarshal(`, varName, `, `, buf, `); err != nil {`) } else { desc := p.ObjectNamed(field.GetTypeName()) msgname := p.TypeName(desc) @@ -648,6 +684,78 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip p.P(`v := time.Duration(0)`) p.P(`if err := `, p.typesPkg.Use(), `.StdDurationUnmarshal(&v, `, buf, `); err != nil {`) } + } else if gogoproto.IsStdDouble(field) { + if nullable { + p.P(`v := new(float64)`) + p.P(`if err := `, p.typesPkg.Use(), `.StdDoubleUnmarshal(v, `, buf, `); err != nil {`) + } else { + p.P(`v := 0`) + p.P(`if err := `, p.typesPkg.Use(), `.StdDoubleUnmarshal(&v, `, buf, `); err != nil {`) + } + } else if gogoproto.IsStdFloat(field) { + if nullable { + p.P(`v := new(float32)`) + p.P(`if err := `, p.typesPkg.Use(), `.StdFloatUnmarshal(v, `, buf, `); err != nil {`) + } else { + p.P(`v := 0`) + p.P(`if err := `, p.typesPkg.Use(), `.StdFloatUnmarshal(&v, `, buf, `); err != nil {`) + } + } else if gogoproto.IsStdInt64(field) { + if nullable { + p.P(`v := new(int64)`) + p.P(`if err := `, p.typesPkg.Use(), `.StdInt64Unmarshal(v, `, buf, `); err != nil {`) + } else { + p.P(`v := 0`) + p.P(`if err := `, p.typesPkg.Use(), `.StdInt64Unmarshal(&v, `, buf, `); err != nil {`) + } + } else if gogoproto.IsStdUInt64(field) { + if nullable { + p.P(`v := new(uint64)`) + p.P(`if err := `, p.typesPkg.Use(), `.StdUInt64Unmarshal(v, `, buf, `); err != nil {`) + } else { + p.P(`v := 0`) + p.P(`if err := `, p.typesPkg.Use(), `.StdUInt64Unmarshal(&v, `, buf, `); err != nil {`) + } + } else if gogoproto.IsStdInt32(field) { + if nullable { + p.P(`v := new(int32)`) + p.P(`if err := `, p.typesPkg.Use(), `.StdInt32Unmarshal(v, `, buf, `); err != nil {`) + } else { + p.P(`v := 0`) + p.P(`if err := `, p.typesPkg.Use(), `.StdInt32Unmarshal(&v, `, buf, `); err != nil {`) + } + } else if gogoproto.IsStdUInt32(field) { + if nullable { + p.P(`v := new(uint32)`) + p.P(`if err := `, p.typesPkg.Use(), `.StdUInt32Unmarshal(v, `, buf, `); err != nil {`) + } else { + p.P(`v := 0`) + p.P(`if err := `, p.typesPkg.Use(), `.StdUInt32Unmarshal(&v, `, buf, `); err != nil {`) + } + } else if gogoproto.IsStdBool(field) { + if nullable { + p.P(`v := new(bool)`) + p.P(`if err := `, p.typesPkg.Use(), `.StdBoolUnmarshal(v, `, buf, `); err != nil {`) + } else { + p.P(`v := false`) + p.P(`if err := `, p.typesPkg.Use(), `.StdBoolUnmarshal(&v, `, buf, `); err != nil {`) + } + } else if gogoproto.IsStdString(field) { + if nullable { + p.P(`v := new(string)`) + p.P(`if err := `, p.typesPkg.Use(), `.StdStringUnmarshal(v, `, buf, `); err != nil {`) + } else { + p.P(`v := ""`) + p.P(`if err := `, p.typesPkg.Use(), `.StdStringUnmarshal(&v, `, buf, `); err != nil {`) + } + } else if gogoproto.IsStdBytes(field) { + if nullable { + p.P(`v := new([]byte)`) + p.P(`if err := `, p.typesPkg.Use(), `.StdBytesUnmarshal(v, `, buf, `); err != nil {`) + } else { + p.P(`var v []byte`) + p.P(`if err := `, p.typesPkg.Use(), `.StdBytesUnmarshal(&v, `, buf, `); err != nil {`) + } } else { p.P(`v := &`, msgname, `{}`) p.P(`if err := v.Unmarshal(`, buf, `); err != nil {`) @@ -679,7 +787,7 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip } nullable, valuegoTyp, valuegoAliasTyp = generator.GoMapValueTypes(field, m.ValueField, valuegoTyp, valuegoAliasTyp) - if gogoproto.IsStdTime(field) || gogoproto.IsStdDuration(field) { + if gogoproto.IsStdType(field) { valuegoTyp = valuegoAliasTyp } @@ -762,6 +870,60 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip } else { p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, time.Duration(0))`) } + } else if gogoproto.IsStdDouble(field) { + if nullable { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(float64))`) + } else { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, 0)`) + } + } else if gogoproto.IsStdFloat(field) { + if nullable { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(float32))`) + } else { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, 0)`) + } + } else if gogoproto.IsStdInt64(field) { + if nullable { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(int64))`) + } else { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, 0)`) + } + } else if gogoproto.IsStdUInt64(field) { + if nullable { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(uint64))`) + } else { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, 0)`) + } + } else if gogoproto.IsStdInt32(field) { + if nullable { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(int32))`) + } else { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, 0)`) + } + } else if gogoproto.IsStdUInt32(field) { + if nullable { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(uint32))`) + } else { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, 0)`) + } + } else if gogoproto.IsStdBool(field) { + if nullable { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(bool))`) + } else { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, false)`) + } + } else if gogoproto.IsStdString(field) { + if nullable { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new(string))`) + } else { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, "")`) + } + } else if gogoproto.IsStdBytes(field) { + if nullable { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, new([]byte))`) + } else { + p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, []byte{})`) + } } else if nullable && !gogoproto.IsCustomType(field) { p.P(`m.`, fieldname, ` = append(m.`, fieldname, `, &`, msgname, `{})`) } else { @@ -784,6 +946,60 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip } else { p.P(`if err := `, p.typesPkg.Use(), `.StdDurationUnmarshal(&(`, varName, `),`, buf, `); err != nil {`) } + } else if gogoproto.IsStdDouble(field) { + if nullable { + p.P(`if err := `, p.typesPkg.Use(), `.StdDoubleUnmarshal(`, varName, `,`, buf, `); err != nil {`) + } else { + p.P(`if err := `, p.typesPkg.Use(), `.StdDoubleUnmarshal(&(`, varName, `),`, buf, `); err != nil {`) + } + } else if gogoproto.IsStdFloat(field) { + if nullable { + p.P(`if err := `, p.typesPkg.Use(), `.StdFloatUnmarshal(`, varName, `,`, buf, `); err != nil {`) + } else { + p.P(`if err := `, p.typesPkg.Use(), `.StdFloatUnmarshal(&(`, varName, `),`, buf, `); err != nil {`) + } + } else if gogoproto.IsStdInt64(field) { + if nullable { + p.P(`if err := `, p.typesPkg.Use(), `.StdInt64Unmarshal(`, varName, `,`, buf, `); err != nil {`) + } else { + p.P(`if err := `, p.typesPkg.Use(), `.StdInt64Unmarshal(&(`, varName, `),`, buf, `); err != nil {`) + } + } else if gogoproto.IsStdUInt64(field) { + if nullable { + p.P(`if err := `, p.typesPkg.Use(), `.StdUInt64Unmarshal(`, varName, `,`, buf, `); err != nil {`) + } else { + p.P(`if err := `, p.typesPkg.Use(), `.StdUInt64Unmarshal(&(`, varName, `),`, buf, `); err != nil {`) + } + } else if gogoproto.IsStdInt32(field) { + if nullable { + p.P(`if err := `, p.typesPkg.Use(), `.StdInt32Unmarshal(`, varName, `,`, buf, `); err != nil {`) + } else { + p.P(`if err := `, p.typesPkg.Use(), `.StdInt32Unmarshal(&(`, varName, `),`, buf, `); err != nil {`) + } + } else if gogoproto.IsStdUInt32(field) { + if nullable { + p.P(`if err := `, p.typesPkg.Use(), `.StdUInt32Unmarshal(`, varName, `,`, buf, `); err != nil {`) + } else { + p.P(`if err := `, p.typesPkg.Use(), `.StdUInt32Unmarshal(&(`, varName, `),`, buf, `); err != nil {`) + } + } else if gogoproto.IsStdBool(field) { + if nullable { + p.P(`if err := `, p.typesPkg.Use(), `.StdBoolUnmarshal(`, varName, `,`, buf, `); err != nil {`) + } else { + p.P(`if err := `, p.typesPkg.Use(), `.StdBoolUnmarshal(&(`, varName, `),`, buf, `); err != nil {`) + } + } else if gogoproto.IsStdString(field) { + if nullable { + p.P(`if err := `, p.typesPkg.Use(), `.StdStringUnmarshal(`, varName, `,`, buf, `); err != nil {`) + } else { + p.P(`if err := `, p.typesPkg.Use(), `.StdStringUnmarshal(&(`, varName, `),`, buf, `); err != nil {`) + } + } else if gogoproto.IsStdBytes(field) { + if nullable { + p.P(`if err := `, p.typesPkg.Use(), `.StdBytesUnmarshal(`, varName, `,`, buf, `); err != nil {`) + } else { + p.P(`if err := `, p.typesPkg.Use(), `.StdBytesUnmarshal(&(`, varName, `),`, buf, `); err != nil {`) + } } else { p.P(`if err := `, varName, `.Unmarshal(`, buf, `); err != nil {`) } @@ -798,6 +1014,24 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip p.P(`m.`, fieldname, ` = new(time.Time)`) } else if gogoproto.IsStdDuration(field) { p.P(`m.`, fieldname, ` = new(time.Duration)`) + } else if gogoproto.IsStdDouble(field) { + p.P(`m.`, fieldname, ` = new(float64)`) + } else if gogoproto.IsStdFloat(field) { + p.P(`m.`, fieldname, ` = new(float32)`) + } else if gogoproto.IsStdInt64(field) { + p.P(`m.`, fieldname, ` = new(int64)`) + } else if gogoproto.IsStdUInt64(field) { + p.P(`m.`, fieldname, ` = new(uint64)`) + } else if gogoproto.IsStdInt32(field) { + p.P(`m.`, fieldname, ` = new(int32)`) + } else if gogoproto.IsStdUInt32(field) { + p.P(`m.`, fieldname, ` = new(uint32)`) + } else if gogoproto.IsStdBool(field) { + p.P(`m.`, fieldname, ` = new(bool)`) + } else if gogoproto.IsStdString(field) { + p.P(`m.`, fieldname, ` = new(string)`) + } else if gogoproto.IsStdBytes(field) { + p.P(`m.`, fieldname, ` = new([]byte)`) } else { goType, _ := p.GoType(nil, field) // remove the star from the type @@ -809,6 +1043,24 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip p.P(`if err := `, p.typesPkg.Use(), `.StdTimeUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) } else if gogoproto.IsStdDuration(field) { p.P(`if err := `, p.typesPkg.Use(), `.StdDurationUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdDouble(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdDoubleUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdFloat(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdFloatUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdInt64(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdInt64Unmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdUInt64(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdUInt64Unmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdInt32(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdInt32Unmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdUInt32(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdUInt32Unmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdBool(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdBoolUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdString(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdStringUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdBytes(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdBytesUnmarshal(m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) } else { p.P(`if err := m.`, fieldname, `.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {`) } @@ -821,6 +1073,24 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip p.P(`if err := `, p.typesPkg.Use(), `.StdTimeUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) } else if gogoproto.IsStdDuration(field) { p.P(`if err := `, p.typesPkg.Use(), `.StdDurationUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdDouble(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdDoubleUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdFloat(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdFloatUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdInt64(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdInt64Unmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdUInt64(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdUInt64Unmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdInt32(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdInt32Unmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdUInt32(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdUInt32Unmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdBool(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdBoolUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdString(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdStringUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) + } else if gogoproto.IsStdBytes(field) { + p.P(`if err := `, p.typesPkg.Use(), `.StdBytesUnmarshal(&m.`, fieldname, `, dAtA[iNdEx:postIndex]); err != nil {`) } else { p.P(`if err := m.`, fieldname, `.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {`) } diff --git a/proto/properties.go b/proto/properties.go index 7a5e28efe5..3f6f40e559 100644 --- a/proto/properties.go +++ b/proto/properties.go @@ -153,6 +153,7 @@ type Properties struct { CastType string StdTime bool StdDuration bool + WktPointer bool stype reflect.Type // set for struct types only ctype reflect.Type // set for custom types only @@ -274,6 +275,8 @@ outer: p.StdTime = true case f == "stdduration": p.StdDuration = true + case f == "wktptr": + p.WktPointer = true } } } @@ -296,6 +299,10 @@ func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, loc p.setTag(lockGetProp) return } + if p.WktPointer && !isMap { + p.setTag(lockGetProp) + return + } switch t1 := typ; t1.Kind() { case reflect.Struct: p.stype = typ @@ -330,6 +337,7 @@ func (p *Properties) setFieldProps(typ reflect.Type, f *reflect.StructField, loc p.mvalprop.CustomType = p.CustomType p.mvalprop.StdDuration = p.StdDuration p.mvalprop.StdTime = p.StdTime + p.mvalprop.WktPointer = p.WktPointer p.mvalprop.init(vtype, "Value", f.Tag.Get("protobuf_val"), nil, lockGetProp) } p.setTag(lockGetProp) diff --git a/proto/table_marshal.go b/proto/table_marshal.go index b479760a84..3e7f9653ed 100644 --- a/proto/table_marshal.go +++ b/proto/table_marshal.go @@ -97,6 +97,8 @@ type marshalElemInfo struct { var ( marshalInfoMap = map[reflect.Type]*marshalInfo{} marshalInfoLock sync.Mutex + + uint8SliceType = reflect.TypeOf(([]uint8)(nil)).Kind() ) // getMarshalInfo returns the information to marshal a given type of message. @@ -581,6 +583,7 @@ func typeMarshaler(t reflect.Type, tags []string, nozero, oneof bool) (sizer, ma ctype := false isTime := false isDuration := false + isWktPointer := false for i := 2; i < len(tags); i++ { if tags[i] == "packed" { packed = true @@ -597,6 +600,9 @@ func typeMarshaler(t reflect.Type, tags []string, nozero, oneof bool) (sizer, ma if tags[i] == "stdduration" { isDuration = true } + if tags[i] == "wktptr" { + isWktPointer = true + } } if !proto3 && !pointer && !slice { nozero = false @@ -642,6 +648,112 @@ func typeMarshaler(t reflect.Type, tags []string, nozero, oneof bool) (sizer, ma return makeDurationMarshaler(getMarshalInfo(t)) } + if isWktPointer { + switch t.Kind() { + case reflect.Float64: + if pointer { + if slice { + return makeStdDoubleValuePtrSliceMarshaler(getMarshalInfo(t)) + } + return makeStdDoubleValuePtrMarshaler(getMarshalInfo(t)) + } + if slice { + return makeStdDoubleValueSliceMarshaler(getMarshalInfo(t)) + } + return makeStdDoubleValueMarshaler(getMarshalInfo(t)) + case reflect.Float32: + if pointer { + if slice { + return makeStdFloatValuePtrSliceMarshaler(getMarshalInfo(t)) + } + return makeStdFloatValuePtrMarshaler(getMarshalInfo(t)) + } + if slice { + return makeStdFloatValueSliceMarshaler(getMarshalInfo(t)) + } + return makeStdFloatValueMarshaler(getMarshalInfo(t)) + case reflect.Int64: + if pointer { + if slice { + return makeStdInt64ValuePtrSliceMarshaler(getMarshalInfo(t)) + } + return makeStdInt64ValuePtrMarshaler(getMarshalInfo(t)) + } + if slice { + return makeStdInt64ValueSliceMarshaler(getMarshalInfo(t)) + } + return makeStdInt64ValueMarshaler(getMarshalInfo(t)) + case reflect.Uint64: + if pointer { + if slice { + return makeStdUInt64ValuePtrSliceMarshaler(getMarshalInfo(t)) + } + return makeStdUInt64ValuePtrMarshaler(getMarshalInfo(t)) + } + if slice { + return makeStdUInt64ValueSliceMarshaler(getMarshalInfo(t)) + } + return makeStdUInt64ValueMarshaler(getMarshalInfo(t)) + case reflect.Int32: + if pointer { + if slice { + return makeStdInt32ValuePtrSliceMarshaler(getMarshalInfo(t)) + } + return makeStdInt32ValuePtrMarshaler(getMarshalInfo(t)) + } + if slice { + return makeStdInt32ValueSliceMarshaler(getMarshalInfo(t)) + } + return makeStdInt32ValueMarshaler(getMarshalInfo(t)) + case reflect.Uint32: + if pointer { + if slice { + return makeStdUInt32ValuePtrSliceMarshaler(getMarshalInfo(t)) + } + return makeStdUInt32ValuePtrMarshaler(getMarshalInfo(t)) + } + if slice { + return makeStdUInt32ValueSliceMarshaler(getMarshalInfo(t)) + } + return makeStdUInt32ValueMarshaler(getMarshalInfo(t)) + case reflect.Bool: + if pointer { + if slice { + return makeStdBoolValuePtrSliceMarshaler(getMarshalInfo(t)) + } + return makeStdBoolValuePtrMarshaler(getMarshalInfo(t)) + } + if slice { + return makeStdBoolValueSliceMarshaler(getMarshalInfo(t)) + } + return makeStdBoolValueMarshaler(getMarshalInfo(t)) + case reflect.String: + if pointer { + if slice { + return makeStdStringValuePtrSliceMarshaler(getMarshalInfo(t)) + } + return makeStdStringValuePtrMarshaler(getMarshalInfo(t)) + } + if slice { + return makeStdStringValueSliceMarshaler(getMarshalInfo(t)) + } + return makeStdStringValueMarshaler(getMarshalInfo(t)) + case uint8SliceType: + if pointer { + if slice { + return makeStdBytesValuePtrSliceMarshaler(getMarshalInfo(t)) + } + return makeStdBytesValuePtrMarshaler(getMarshalInfo(t)) + } + if slice { + return makeStdBytesValueSliceMarshaler(getMarshalInfo(t)) + } + return makeStdBytesValueMarshaler(getMarshalInfo(t)) + default: + panic(fmt.Sprintf("unknown wktpointer type %#v", t)) + } + } + switch t.Kind() { case reflect.Bool: if pointer { @@ -2332,6 +2444,9 @@ func makeMapMarshaler(f *reflect.StructField) (sizer, marshaler) { if t == "stdduration" { valTags = append(valTags, t) } + if t == "wktptr" { + valTags = append(valTags, t) + } } keySizer, keyMarshaler := typeMarshaler(keyType, keyTags, false, false) // don't omit zero value in map valSizer, valMarshaler := typeMarshaler(valType, valTags, false, false) // don't omit zero value in map diff --git a/proto/table_unmarshal.go b/proto/table_unmarshal.go index b6371bb56b..adafc5b415 100644 --- a/proto/table_unmarshal.go +++ b/proto/table_unmarshal.go @@ -465,6 +465,7 @@ func typeUnmarshaler(t reflect.Type, tags string) unmarshaler { ctype := false isTime := false isDuration := false + isWktPointer := false for _, tag := range tagArray[3:] { if strings.HasPrefix(tag, "name=") { name = tag[5:] @@ -478,6 +479,9 @@ func typeUnmarshaler(t reflect.Type, tags string) unmarshaler { if tag == "stdduration" { isDuration = true } + if tag == "wktptr" { + isWktPointer = true + } } // Figure out packaging (pointer, slice, or both) @@ -532,6 +536,112 @@ func typeUnmarshaler(t reflect.Type, tags string) unmarshaler { return makeUnmarshalDuration(getUnmarshalInfo(t), name) } + if isWktPointer { + switch t.Kind() { + case reflect.Float64: + if pointer { + if slice { + return makeStdDoubleValuePtrSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdDoubleValuePtrUnmarshaler(getUnmarshalInfo(t), name) + } + if slice { + return makeStdDoubleValueSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdDoubleValueUnmarshaler(getUnmarshalInfo(t), name) + case reflect.Float32: + if pointer { + if slice { + return makeStdFloatValuePtrSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdFloatValuePtrUnmarshaler(getUnmarshalInfo(t), name) + } + if slice { + return makeStdFloatValueSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdFloatValueUnmarshaler(getUnmarshalInfo(t), name) + case reflect.Int64: + if pointer { + if slice { + return makeStdInt64ValuePtrSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdInt64ValuePtrUnmarshaler(getUnmarshalInfo(t), name) + } + if slice { + return makeStdInt64ValueSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdInt64ValueUnmarshaler(getUnmarshalInfo(t), name) + case reflect.Uint64: + if pointer { + if slice { + return makeStdUInt64ValuePtrSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdUInt64ValuePtrUnmarshaler(getUnmarshalInfo(t), name) + } + if slice { + return makeStdUInt64ValueSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdUInt64ValueUnmarshaler(getUnmarshalInfo(t), name) + case reflect.Int32: + if pointer { + if slice { + return makeStdInt32ValuePtrSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdInt32ValuePtrUnmarshaler(getUnmarshalInfo(t), name) + } + if slice { + return makeStdInt32ValueSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdInt32ValueUnmarshaler(getUnmarshalInfo(t), name) + case reflect.Uint32: + if pointer { + if slice { + return makeStdUInt32ValuePtrSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdUInt32ValuePtrUnmarshaler(getUnmarshalInfo(t), name) + } + if slice { + return makeStdUInt32ValueSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdUInt32ValueUnmarshaler(getUnmarshalInfo(t), name) + case reflect.Bool: + if pointer { + if slice { + return makeStdBoolValuePtrSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdBoolValuePtrUnmarshaler(getUnmarshalInfo(t), name) + } + if slice { + return makeStdBoolValueSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdBoolValueUnmarshaler(getUnmarshalInfo(t), name) + case reflect.String: + if pointer { + if slice { + return makeStdStringValuePtrSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdStringValuePtrUnmarshaler(getUnmarshalInfo(t), name) + } + if slice { + return makeStdStringValueSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdStringValueUnmarshaler(getUnmarshalInfo(t), name) + case uint8SliceType: + if pointer { + if slice { + return makeStdBytesValuePtrSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdBytesValuePtrUnmarshaler(getUnmarshalInfo(t), name) + } + if slice { + return makeStdBytesValueSliceUnmarshaler(getUnmarshalInfo(t), name) + } + return makeStdBytesValueUnmarshaler(getUnmarshalInfo(t), name) + default: + panic(fmt.Sprintf("unknown wktpointer type %#v", t)) + } + } + // We'll never have both pointer and slice for basic types. if pointer && slice && t.Kind() != reflect.Struct { panic("both pointer and slice for basic type in " + t.Name()) @@ -1741,6 +1851,9 @@ func makeUnmarshalMap(f *reflect.StructField) unmarshaler { if t == "stdduration" { valTags = append(valTags, t) } + if t == "wktptr" { + valTags = append(valTags, t) + } } unmarshalKey := typeUnmarshaler(kt, f.Tag.Get("protobuf_key")) unmarshalVal := typeUnmarshaler(vt, strings.Join(valTags, ",")) diff --git a/proto/wrappers.go b/proto/wrappers.go new file mode 100644 index 0000000000..b175d1b642 --- /dev/null +++ b/proto/wrappers.go @@ -0,0 +1,1888 @@ +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2018, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +import ( + "io" + "reflect" +) + +func makeStdDoubleValueMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + t := ptr.asPointerTo(u.typ).Interface().(*float64) + v := &float64Value{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + t := ptr.asPointerTo(u.typ).Interface().(*float64) + v := &float64Value{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdDoubleValuePtrMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + if ptr.isNil() { + return 0 + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*float64) + v := &float64Value{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + if ptr.isNil() { + return b, nil + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*float64) + v := &float64Value{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdDoubleValueSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(u.typ) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(float64) + v := &float64Value{t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(u.typ) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(float64) + v := &float64Value{t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdDoubleValuePtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*float64) + v := &float64Value{*t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*float64) + v := &float64Value{*t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdDoubleValueUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &float64Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(sub.typ).Elem() + s.Set(reflect.ValueOf(m.Value)) + return b[x:], nil + } +} + +func makeStdDoubleValuePtrUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &float64Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem() + s.Set(reflect.ValueOf(&m.Value)) + return b[x:], nil + } +} + +func makeStdDoubleValuePtrSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &float64Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(reflect.PtrTo(sub.typ)) + newSlice := reflect.Append(slice, reflect.ValueOf(&m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdDoubleValueSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &float64Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(sub.typ) + newSlice := reflect.Append(slice, reflect.ValueOf(m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdFloatValueMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + t := ptr.asPointerTo(u.typ).Interface().(*float32) + v := &float32Value{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + t := ptr.asPointerTo(u.typ).Interface().(*float32) + v := &float32Value{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdFloatValuePtrMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + if ptr.isNil() { + return 0 + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*float32) + v := &float32Value{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + if ptr.isNil() { + return b, nil + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*float32) + v := &float32Value{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdFloatValueSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(u.typ) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(float32) + v := &float32Value{t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(u.typ) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(float32) + v := &float32Value{t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdFloatValuePtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*float32) + v := &float32Value{*t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*float32) + v := &float32Value{*t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdFloatValueUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &float32Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(sub.typ).Elem() + s.Set(reflect.ValueOf(m.Value)) + return b[x:], nil + } +} + +func makeStdFloatValuePtrUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &float32Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem() + s.Set(reflect.ValueOf(&m.Value)) + return b[x:], nil + } +} + +func makeStdFloatValuePtrSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &float32Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(reflect.PtrTo(sub.typ)) + newSlice := reflect.Append(slice, reflect.ValueOf(&m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdFloatValueSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &float32Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(sub.typ) + newSlice := reflect.Append(slice, reflect.ValueOf(m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdInt64ValueMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + t := ptr.asPointerTo(u.typ).Interface().(*int64) + v := &int64Value{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + t := ptr.asPointerTo(u.typ).Interface().(*int64) + v := &int64Value{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdInt64ValuePtrMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + if ptr.isNil() { + return 0 + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*int64) + v := &int64Value{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + if ptr.isNil() { + return b, nil + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*int64) + v := &int64Value{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdInt64ValueSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(u.typ) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(int64) + v := &int64Value{t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(u.typ) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(int64) + v := &int64Value{t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdInt64ValuePtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*int64) + v := &int64Value{*t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*int64) + v := &int64Value{*t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdInt64ValueUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &int64Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(sub.typ).Elem() + s.Set(reflect.ValueOf(m.Value)) + return b[x:], nil + } +} + +func makeStdInt64ValuePtrUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &int64Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem() + s.Set(reflect.ValueOf(&m.Value)) + return b[x:], nil + } +} + +func makeStdInt64ValuePtrSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &int64Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(reflect.PtrTo(sub.typ)) + newSlice := reflect.Append(slice, reflect.ValueOf(&m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdInt64ValueSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &int64Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(sub.typ) + newSlice := reflect.Append(slice, reflect.ValueOf(m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdUInt64ValueMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + t := ptr.asPointerTo(u.typ).Interface().(*uint64) + v := &uint64Value{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + t := ptr.asPointerTo(u.typ).Interface().(*uint64) + v := &uint64Value{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdUInt64ValuePtrMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + if ptr.isNil() { + return 0 + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*uint64) + v := &uint64Value{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + if ptr.isNil() { + return b, nil + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*uint64) + v := &uint64Value{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdUInt64ValueSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(u.typ) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(uint64) + v := &uint64Value{t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(u.typ) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(uint64) + v := &uint64Value{t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdUInt64ValuePtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*uint64) + v := &uint64Value{*t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*uint64) + v := &uint64Value{*t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdUInt64ValueUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &uint64Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(sub.typ).Elem() + s.Set(reflect.ValueOf(m.Value)) + return b[x:], nil + } +} + +func makeStdUInt64ValuePtrUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &uint64Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem() + s.Set(reflect.ValueOf(&m.Value)) + return b[x:], nil + } +} + +func makeStdUInt64ValuePtrSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &uint64Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(reflect.PtrTo(sub.typ)) + newSlice := reflect.Append(slice, reflect.ValueOf(&m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdUInt64ValueSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &uint64Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(sub.typ) + newSlice := reflect.Append(slice, reflect.ValueOf(m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdInt32ValueMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + t := ptr.asPointerTo(u.typ).Interface().(*int32) + v := &int32Value{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + t := ptr.asPointerTo(u.typ).Interface().(*int32) + v := &int32Value{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdInt32ValuePtrMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + if ptr.isNil() { + return 0 + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*int32) + v := &int32Value{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + if ptr.isNil() { + return b, nil + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*int32) + v := &int32Value{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdInt32ValueSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(u.typ) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(int32) + v := &int32Value{t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(u.typ) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(int32) + v := &int32Value{t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdInt32ValuePtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*int32) + v := &int32Value{*t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*int32) + v := &int32Value{*t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdInt32ValueUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &int32Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(sub.typ).Elem() + s.Set(reflect.ValueOf(m.Value)) + return b[x:], nil + } +} + +func makeStdInt32ValuePtrUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &int32Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem() + s.Set(reflect.ValueOf(&m.Value)) + return b[x:], nil + } +} + +func makeStdInt32ValuePtrSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &int32Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(reflect.PtrTo(sub.typ)) + newSlice := reflect.Append(slice, reflect.ValueOf(&m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdInt32ValueSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &int32Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(sub.typ) + newSlice := reflect.Append(slice, reflect.ValueOf(m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdUInt32ValueMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + t := ptr.asPointerTo(u.typ).Interface().(*uint32) + v := &uint32Value{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + t := ptr.asPointerTo(u.typ).Interface().(*uint32) + v := &uint32Value{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdUInt32ValuePtrMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + if ptr.isNil() { + return 0 + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*uint32) + v := &uint32Value{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + if ptr.isNil() { + return b, nil + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*uint32) + v := &uint32Value{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdUInt32ValueSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(u.typ) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(uint32) + v := &uint32Value{t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(u.typ) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(uint32) + v := &uint32Value{t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdUInt32ValuePtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*uint32) + v := &uint32Value{*t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*uint32) + v := &uint32Value{*t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdUInt32ValueUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &uint32Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(sub.typ).Elem() + s.Set(reflect.ValueOf(m.Value)) + return b[x:], nil + } +} + +func makeStdUInt32ValuePtrUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &uint32Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem() + s.Set(reflect.ValueOf(&m.Value)) + return b[x:], nil + } +} + +func makeStdUInt32ValuePtrSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &uint32Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(reflect.PtrTo(sub.typ)) + newSlice := reflect.Append(slice, reflect.ValueOf(&m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdUInt32ValueSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &uint32Value{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(sub.typ) + newSlice := reflect.Append(slice, reflect.ValueOf(m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdBoolValueMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + t := ptr.asPointerTo(u.typ).Interface().(*bool) + v := &boolValue{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + t := ptr.asPointerTo(u.typ).Interface().(*bool) + v := &boolValue{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdBoolValuePtrMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + if ptr.isNil() { + return 0 + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*bool) + v := &boolValue{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + if ptr.isNil() { + return b, nil + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*bool) + v := &boolValue{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdBoolValueSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(u.typ) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(bool) + v := &boolValue{t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(u.typ) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(bool) + v := &boolValue{t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdBoolValuePtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*bool) + v := &boolValue{*t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*bool) + v := &boolValue{*t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdBoolValueUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &boolValue{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(sub.typ).Elem() + s.Set(reflect.ValueOf(m.Value)) + return b[x:], nil + } +} + +func makeStdBoolValuePtrUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &boolValue{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem() + s.Set(reflect.ValueOf(&m.Value)) + return b[x:], nil + } +} + +func makeStdBoolValuePtrSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &boolValue{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(reflect.PtrTo(sub.typ)) + newSlice := reflect.Append(slice, reflect.ValueOf(&m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdBoolValueSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &boolValue{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(sub.typ) + newSlice := reflect.Append(slice, reflect.ValueOf(m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdStringValueMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + t := ptr.asPointerTo(u.typ).Interface().(*string) + v := &stringValue{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + t := ptr.asPointerTo(u.typ).Interface().(*string) + v := &stringValue{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdStringValuePtrMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + if ptr.isNil() { + return 0 + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*string) + v := &stringValue{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + if ptr.isNil() { + return b, nil + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*string) + v := &stringValue{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdStringValueSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(u.typ) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(string) + v := &stringValue{t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(u.typ) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(string) + v := &stringValue{t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdStringValuePtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*string) + v := &stringValue{*t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*string) + v := &stringValue{*t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdStringValueUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &stringValue{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(sub.typ).Elem() + s.Set(reflect.ValueOf(m.Value)) + return b[x:], nil + } +} + +func makeStdStringValuePtrUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &stringValue{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem() + s.Set(reflect.ValueOf(&m.Value)) + return b[x:], nil + } +} + +func makeStdStringValuePtrSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &stringValue{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(reflect.PtrTo(sub.typ)) + newSlice := reflect.Append(slice, reflect.ValueOf(&m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdStringValueSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &stringValue{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(sub.typ) + newSlice := reflect.Append(slice, reflect.ValueOf(m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdBytesValueMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + t := ptr.asPointerTo(u.typ).Interface().(*[]byte) + v := &bytesValue{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + t := ptr.asPointerTo(u.typ).Interface().(*[]byte) + v := &bytesValue{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdBytesValuePtrMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + if ptr.isNil() { + return 0 + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*[]byte) + v := &bytesValue{*t} + siz := Size(v) + return tagsize + SizeVarint(uint64(siz)) + siz + }, func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + if ptr.isNil() { + return b, nil + } + t := ptr.asPointerTo(reflect.PtrTo(u.typ)).Elem().Interface().(*[]byte) + v := &bytesValue{*t} + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(len(buf))) + b = append(b, buf...) + return b, nil + } +} + +func makeStdBytesValueSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(u.typ) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().([]byte) + v := &bytesValue{t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(u.typ) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().([]byte) + v := &bytesValue{t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdBytesValuePtrSliceMarshaler(u *marshalInfo) (sizer, marshaler) { + return func(ptr pointer, tagsize int) int { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + n := 0 + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*[]byte) + v := &bytesValue{*t} + siz := Size(v) + n += siz + SizeVarint(uint64(siz)) + tagsize + } + return n + }, + func(b []byte, ptr pointer, wiretag uint64, deterministic bool) ([]byte, error) { + s := ptr.getSlice(reflect.PtrTo(u.typ)) + for i := 0; i < s.Len(); i++ { + elem := s.Index(i) + t := elem.Interface().(*[]byte) + v := &bytesValue{*t} + siz := Size(v) + buf, err := Marshal(v) + if err != nil { + return nil, err + } + b = appendVarint(b, wiretag) + b = appendVarint(b, uint64(siz)) + b = append(b, buf...) + } + + return b, nil + } +} + +func makeStdBytesValueUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &bytesValue{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(sub.typ).Elem() + s.Set(reflect.ValueOf(m.Value)) + return b[x:], nil + } +} + +func makeStdBytesValuePtrUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &bytesValue{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + s := f.asPointerTo(reflect.PtrTo(sub.typ)).Elem() + s.Set(reflect.ValueOf(&m.Value)) + return b[x:], nil + } +} + +func makeStdBytesValuePtrSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &bytesValue{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(reflect.PtrTo(sub.typ)) + newSlice := reflect.Append(slice, reflect.ValueOf(&m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} + +func makeStdBytesValueSliceUnmarshaler(sub *unmarshalInfo, name string) unmarshaler { + return func(b []byte, f pointer, w int) ([]byte, error) { + if w != WireBytes { + return nil, errInternalBadWireType + } + x, n := decodeVarint(b) + if n == 0 { + return nil, io.ErrUnexpectedEOF + } + b = b[n:] + if x > uint64(len(b)) { + return nil, io.ErrUnexpectedEOF + } + m := &bytesValue{} + if err := Unmarshal(b[:x], m); err != nil { + return nil, err + } + slice := f.getSlice(sub.typ) + newSlice := reflect.Append(slice, reflect.ValueOf(m.Value)) + slice.Set(newSlice) + return b[x:], nil + } +} diff --git a/proto/wrappers_gogo.go b/proto/wrappers_gogo.go new file mode 100644 index 0000000000..c1cf7bf85e --- /dev/null +++ b/proto/wrappers_gogo.go @@ -0,0 +1,113 @@ +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2018, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package proto + +type float64Value struct { + Value float64 `protobuf:"fixed64,1,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *float64Value) Reset() { *m = float64Value{} } +func (*float64Value) ProtoMessage() {} +func (*float64Value) String() string { return "float64" } + +type float32Value struct { + Value float32 `protobuf:"fixed32,1,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *float32Value) Reset() { *m = float32Value{} } +func (*float32Value) ProtoMessage() {} +func (*float32Value) String() string { return "float32" } + +type int64Value struct { + Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *int64Value) Reset() { *m = int64Value{} } +func (*int64Value) ProtoMessage() {} +func (*int64Value) String() string { return "int64" } + +type uint64Value struct { + Value uint64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *uint64Value) Reset() { *m = uint64Value{} } +func (*uint64Value) ProtoMessage() {} +func (*uint64Value) String() string { return "uint64" } + +type int32Value struct { + Value int32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *int32Value) Reset() { *m = int32Value{} } +func (*int32Value) ProtoMessage() {} +func (*int32Value) String() string { return "int32" } + +type uint32Value struct { + Value uint32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *uint32Value) Reset() { *m = uint32Value{} } +func (*uint32Value) ProtoMessage() {} +func (*uint32Value) String() string { return "uint32" } + +type boolValue struct { + Value bool `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *boolValue) Reset() { *m = boolValue{} } +func (*boolValue) ProtoMessage() {} +func (*boolValue) String() string { return "bool" } + +type stringValue struct { + Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *stringValue) Reset() { *m = stringValue{} } +func (*stringValue) ProtoMessage() {} +func (*stringValue) String() string { return "string" } + +type bytesValue struct { + Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *bytesValue) Reset() { *m = bytesValue{} } +func (*bytesValue) ProtoMessage() {} +func (*bytesValue) String() string { return "[]byte" } + +func init() { + RegisterType((*float64Value)(nil), "gogo.protobuf.proto.DoubleValue") + RegisterType((*float32Value)(nil), "gogo.protobuf.proto.FloatValue") + RegisterType((*int64Value)(nil), "gogo.protobuf.proto.Int64Value") + RegisterType((*uint64Value)(nil), "gogo.protobuf.proto.UInt64Value") + RegisterType((*int32Value)(nil), "gogo.protobuf.proto.Int32Value") + RegisterType((*uint32Value)(nil), "gogo.protobuf.proto.UInt32Value") + RegisterType((*boolValue)(nil), "gogo.protobuf.proto.BoolValue") + RegisterType((*stringValue)(nil), "gogo.protobuf.proto.StringValue") + RegisterType((*bytesValue)(nil), "gogo.protobuf.proto.BytesValue") +} diff --git a/protoc-gen-gogo/generator/generator.go b/protoc-gen-gogo/generator/generator.go index 23df8be930..a2d18f122f 100644 --- a/protoc-gen-gogo/generator/generator.go +++ b/protoc-gen-gogo/generator/generator.go @@ -1752,7 +1752,11 @@ func (g *Generator) goTag(message *Descriptor, field *descriptor.FieldDescriptor if gogoproto.IsStdDuration(field) { stdduration = ",stdduration" } - return strconv.Quote(fmt.Sprintf("%s,%d,%s%s%s%s%s%s%s%s%s%s%s%s%s", + wktptr := "" + if gogoproto.IsWktPtr(field) { + wktptr = ",wktptr" + } + return strconv.Quote(fmt.Sprintf("%s,%d,%s%s%s%s%s%s%s%s%s%s%s%s%s%s", wiretype, field.GetNumber(), optrepreq, @@ -1767,7 +1771,8 @@ func (g *Generator) goTag(message *Descriptor, field *descriptor.FieldDescriptor castkey, castvalue, stdtime, - stdduration)) + stdduration, + wktptr)) } func needsStar(field *descriptor.FieldDescriptorProto, proto3 bool, allowOneOf bool) bool { @@ -1880,6 +1885,24 @@ func (g *Generator) GoType(message *Descriptor, field *descriptor.FieldDescripto case gogoproto.IsStdDuration(field): g.customImports = append(g.customImports, "time") typ = "time.Duration" + case gogoproto.IsStdDouble(field): + typ = "float64" + case gogoproto.IsStdFloat(field): + typ = "float32" + case gogoproto.IsStdInt64(field): + typ = "int64" + case gogoproto.IsStdUInt64(field): + typ = "uint64" + case gogoproto.IsStdInt32(field): + typ = "int32" + case gogoproto.IsStdUInt32(field): + typ = "uint32" + case gogoproto.IsStdBool(field): + typ = "bool" + case gogoproto.IsStdString(field): + typ = "string" + case gogoproto.IsStdBytes(field): + typ = "[]byte" } if needsStar(field, g.file.proto3 && field.Extendee == nil, message != nil && message.allowOneof()) { typ = "*" + typ @@ -1952,7 +1975,7 @@ func (g *Generator) GoMapType(d *Descriptor, field *descriptor.FieldDescriptorPr if !gogoproto.IsNullable(m.ValueAliasField) { valType = strings.TrimPrefix(valType, "*") } - if !gogoproto.IsStdTime(field) && !gogoproto.IsStdDuration(field) && !gogoproto.IsCustomType(field) && !gogoproto.IsCastType(field) { + if !gogoproto.IsStdType(m.ValueAliasField) && !gogoproto.IsCustomType(field) && !gogoproto.IsCastType(field) { g.RecordTypeUse(m.ValueAliasField.GetTypeName()) } default: @@ -1960,7 +1983,9 @@ func (g *Generator) GoMapType(d *Descriptor, field *descriptor.FieldDescriptorPr if !gogoproto.IsNullable(m.ValueAliasField) { valType = strings.TrimPrefix(valType, "*") } - g.RecordTypeUse(m.ValueAliasField.GetTypeName()) + if !gogoproto.IsStdType(field) { + g.RecordTypeUse(m.ValueAliasField.GetTypeName()) + } } else { valType = strings.TrimPrefix(valType, "*") } @@ -2192,7 +2217,7 @@ func (g *Generator) generateMessage(message *Descriptor) { fieldFullPath := fmt.Sprintf("%s,%d,%d", message.path, messageFieldPath, i) g.PrintComments(fieldFullPath) g.P(Annotate(message.file, fieldFullPath, fieldName), "\t", typename, "\t`", tag, "`", fieldDeprecated) - if !gogoproto.IsStdTime(field) && !gogoproto.IsStdDuration(field) && !gogoproto.IsCustomType(field) && !gogoproto.IsCastType(field) { + if !gogoproto.IsStdType(field) && !gogoproto.IsCustomType(field) && !gogoproto.IsCastType(field) { g.RecordTypeUse(field.GetTypeName()) } } @@ -2223,7 +2248,7 @@ func (g *Generator) generateMessage(message *Descriptor) { // over all its fields to be able to mark as used any imported types // used by those fields. for _, field := range message.Field { - if !gogoproto.IsStdTime(field) && !gogoproto.IsStdDuration(field) && !gogoproto.IsCustomType(field) && !gogoproto.IsCastType(field) { + if !gogoproto.IsStdType(field) && !gogoproto.IsCustomType(field) && !gogoproto.IsCastType(field) { g.RecordTypeUse(field.GetTypeName()) } } @@ -2533,7 +2558,7 @@ func (g *Generator) generateMessage(message *Descriptor) { tag := "protobuf:" + g.goTag(message, field, wiretype) fieldFullPath := fmt.Sprintf("%s,%d,%d", message.path, messageFieldPath, i) g.P("type ", Annotate(message.file, fieldFullPath, oneofTypeName[field]), " struct{ ", Annotate(message.file, fieldFullPath, fieldNames[field]), " ", fieldTypes[field], " `", tag, "` }") - if !gogoproto.IsStdTime(field) && !gogoproto.IsStdDuration(field) && !gogoproto.IsCustomType(field) && !gogoproto.IsCastType(field) { + if !gogoproto.IsStdType(field) && !gogoproto.IsCustomType(field) && !gogoproto.IsCastType(field) { g.RecordTypeUse(field.GetTypeName()) } oneofTypes = append(oneofTypes, oneofTypeName[field]) @@ -2650,8 +2675,17 @@ func (g *Generator) generateMessage(message *Descriptor) { } else { goTyp, _ := g.GoType(message, field) goTypName := GoTypeToName(goTyp) - if !gogoproto.IsNullable(field) && gogoproto.IsStdDuration(field) { + if !gogoproto.IsNullable(field) && (gogoproto.IsStdDuration(field) || + gogoproto.IsStdDouble(field) || gogoproto.IsStdFloat(field) || + gogoproto.IsStdInt64(field) || gogoproto.IsStdUInt64(field) || + gogoproto.IsStdInt32(field) || gogoproto.IsStdUInt32(field)) { g.P("return 0") + } else if !gogoproto.IsNullable(field) && gogoproto.IsStdBool(field) { + g.P("return false") + } else if !gogoproto.IsNullable(field) && gogoproto.IsStdString(field) { + g.P("return \"\"") + } else if !gogoproto.IsNullable(field) && gogoproto.IsStdBytes(field) { + g.P("return []byte{}") } else { g.P("return ", goTypName, "{}") } @@ -2817,27 +2851,39 @@ func (g *Generator) generateMessage(message *Descriptor) { g.Out() g.P(`}`) val = "dAtA" - } else if gogoproto.IsStdTime(field) { + } else if gogoproto.IsStdType(field) { pkg := g.useTypes() + ptr := "" + fnname := "" if gogoproto.IsNullable(field) { - g.P(`dAtA, err := `, pkg, `.StdTimeMarshal(*`, val, `)`) - } else { - g.P(`dAtA, err := `, pkg, `.StdTimeMarshal(`, val, `)`) + ptr = "*" } - g.P(`if err != nil {`) - g.In() - g.P(`return err`) - g.Out() - g.P(`}`) - val = "dAtA" - pre, post = "b.EncodeRawBytes(", ")" - } else if gogoproto.IsStdDuration(field) { - pkg := g.useTypes() - if gogoproto.IsNullable(field) { - g.P(`dAtA, err := `, pkg, `.StdDurationMarshal(*`, val, `)`) + if gogoproto.IsStdTime(field) { + fnname = "Time" + } else if gogoproto.IsStdDuration(field) { + fnname = "Duration" + } else if gogoproto.IsStdDouble(field) { + fnname = "Double" + } else if gogoproto.IsStdFloat(field) { + fnname = "Float" + } else if gogoproto.IsStdInt64(field) { + fnname = "Int64" + } else if gogoproto.IsStdUInt64(field) { + fnname = "UInt64" + } else if gogoproto.IsStdInt32(field) { + fnname = "Int32" + } else if gogoproto.IsStdUInt32(field) { + fnname = "UInt32" + } else if gogoproto.IsStdBool(field) { + fnname = "Bool" + } else if gogoproto.IsStdString(field) { + fnname = "String" + } else if gogoproto.IsStdBytes(field) { + fnname = "Bytes" } else { - g.P(`dAtA, err := `, pkg, `.StdDurationMarshal(`, val, `)`) + panic("internal error") } + g.P(`dAtA, err := `, pkg, `.Std`, fnname, `Marshal(`, ptr, val, `)`) g.P(`if err != nil {`) g.In() g.P(`return err`) @@ -2908,7 +2954,7 @@ func (g *Generator) generateMessage(message *Descriptor) { dec = "b.DecodeGroup(msg)" // handled specially below case descriptor.FieldDescriptorProto_TYPE_MESSAGE: - if gogoproto.IsStdTime(field) || gogoproto.IsStdDuration(field) { + if gogoproto.IsStdType(field) { dec = "b.DecodeRawBytes(true)" } else { g.P("msg := new(", fieldTypes[field][1:], ")") // drop star @@ -2949,35 +2995,61 @@ func (g *Generator) generateMessage(message *Descriptor) { g.P(`c := &cc`) g.P(`err = c.Unmarshal(`, val, `)`) val = "*c" - } else if gogoproto.IsStdTime(field) { - pkg := g.useTypes() - g.P(`if err != nil {`) - g.In() - g.P(`return true, err`) - g.Out() - g.P(`}`) - g.P(`c := new(time.Time)`) - g.P(`if err2 := `, pkg, `.StdTimeUnmarshal(c, `, val, `); err2 != nil {`) - g.In() - g.P(`return true, err`) - g.Out() - g.P(`}`) - val = "c" - } else if gogoproto.IsStdDuration(field) { + } else if gogoproto.IsStdType(field) { + var stdtype string + var fnname string + if gogoproto.IsStdTime(field) { + stdtype = "time.Time" + fnname = "Time" + } else if gogoproto.IsStdDuration(field) { + stdtype = "time.Duration" + fnname = "Duration" + } else if gogoproto.IsStdDouble(field) { + stdtype = "float64" + fnname = "Double" + } else if gogoproto.IsStdFloat(field) { + stdtype = "float32" + fnname = "Float" + } else if gogoproto.IsStdInt64(field) { + stdtype = "int64" + fnname = "Int64" + } else if gogoproto.IsStdUInt64(field) { + stdtype = "uint64" + fnname = "UInt64" + } else if gogoproto.IsStdInt32(field) { + stdtype = "int32" + fnname = "Int32" + } else if gogoproto.IsStdUInt32(field) { + stdtype = "uint32" + fnname = "UInt32" + } else if gogoproto.IsStdBool(field) { + stdtype = "bool" + fnname = "Bool" + } else if gogoproto.IsStdString(field) { + stdtype = "string" + fnname = "String" + } else if gogoproto.IsStdBytes(field) { + stdtype = "[]byte" + fnname = "Bytes" + } else { + panic("internal error") + } + pkg := g.useTypes() g.P(`if err != nil {`) g.In() g.P(`return true, err`) g.Out() g.P(`}`) - g.P(`c := new(time.Duration)`) - g.P(`if err2 := `, pkg, `.StdDurationUnmarshal(c, `, val, `); err2 != nil {`) + g.P(`c := new(`, stdtype, `)`) + g.P(`if err2 := `, pkg, `.Std`, fnname, `Unmarshal(c, `, val, `); err2 != nil {`) g.In() g.P(`return true, err`) g.Out() g.P(`}`) val = "c" } + if cast != "" { val = cast + "(" + val + ")" } @@ -2989,7 +3061,7 @@ func (g *Generator) generateMessage(message *Descriptor) { val += " != 0" case descriptor.FieldDescriptorProto_TYPE_GROUP, descriptor.FieldDescriptorProto_TYPE_MESSAGE: - if !gogoproto.IsStdTime(field) && !gogoproto.IsStdDuration(field) { + if !gogoproto.IsStdType(field) { val = "msg" } } @@ -3047,18 +3119,36 @@ func (g *Generator) generateMessage(message *Descriptor) { case descriptor.FieldDescriptorProto_TYPE_GROUP: fixed = g.Pkg["proto"] + ".Size(" + val + ")" case descriptor.FieldDescriptorProto_TYPE_MESSAGE: - if gogoproto.IsStdTime(field) { - if gogoproto.IsNullable(field) { - val = "*" + val - } + if gogoproto.IsStdType(field) { pkg := g.useTypes() - g.P("s := ", pkg, ".SizeOfStdTime(", val, ")") - } else if gogoproto.IsStdDuration(field) { if gogoproto.IsNullable(field) { val = "*" + val } - pkg := g.useTypes() - g.P("s := ", pkg, ".SizeOfStdDuration(", val, ")") + if gogoproto.IsStdTime(field) { + g.P("s := ", pkg, ".SizeOfStdTime(", val, ")") + } else if gogoproto.IsStdDuration(field) { + g.P("s := ", pkg, ".SizeOfStdDuration(", val, ")") + } else if gogoproto.IsStdDouble(field) { + g.P("s := ", pkg, ".SizeOfStdDouble(", val, ")") + } else if gogoproto.IsStdFloat(field) { + g.P("s := ", pkg, ".SizeOfStdFloat(", val, ")") + } else if gogoproto.IsStdInt64(field) { + g.P("s := ", pkg, ".SizeOfStdInt64(", val, ")") + } else if gogoproto.IsStdUInt64(field) { + g.P("s := ", pkg, ".SizeOfStdUInt64(", val, ")") + } else if gogoproto.IsStdInt32(field) { + g.P("s := ", pkg, ".SizeOfStdInt32(", val, ")") + } else if gogoproto.IsStdUInt32(field) { + g.P("s := ", pkg, ".SizeOfStdUInt32(", val, ")") + } else if gogoproto.IsStdBool(field) { + g.P("s := ", pkg, ".SizeOfStdBool(", val, ")") + } else if gogoproto.IsStdString(field) { + g.P("s := ", pkg, ".SizeOfStdString(", val, ")") + } else if gogoproto.IsStdBytes(field) { + g.P("s := ", pkg, ".SizeOfStdBytes(", val, ")") + } else { + panic("internal error") + } } else { g.P("s := ", g.Pkg["proto"], ".Size(", val, ")") } diff --git a/protoc-gen-gogo/generator/helper.go b/protoc-gen-gogo/generator/helper.go index 8104f066c4..697bbf52d1 100644 --- a/protoc-gen-gogo/generator/helper.go +++ b/protoc-gen-gogo/generator/helper.go @@ -262,6 +262,13 @@ func (g *Generator) GetMapValueField(field, valField *descriptor.FieldDescriptor } } + wktptr := gogoproto.IsWktPtr(field) + if wktptr { + if err := proto.SetExtension(valField.Options, gogoproto.E_Wktpointer, &wktptr); err != nil { + g.Fail(err.Error()) + } + } + if valType := gogoproto.GetCastValue(field); len(valType) > 0 { if err := proto.SetExtension(valField.Options, gogoproto.E_Casttype, &valType); err != nil { g.Fail(err.Error()) diff --git a/test/stdtypes/Makefile b/test/stdtypes/Makefile index 82c4c8c0b2..a8d105cce0 100644 --- a/test/stdtypes/Makefile +++ b/test/stdtypes/Makefile @@ -31,7 +31,8 @@ regenerate: go install github.com/gogo/protobuf/protoc-gen-gogo protoc-min-version --version="3.0.0" --gogo_out=\ Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\ - Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types\ + Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\ + Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types\ :. \ --proto_path=../../../../../:../../protobuf/:. stdtypes.proto diff --git a/test/stdtypes/stdtypes.proto b/test/stdtypes/stdtypes.proto index fb69b73278..7182dd3e4d 100644 --- a/test/stdtypes/stdtypes.proto +++ b/test/stdtypes/stdtypes.proto @@ -34,6 +34,7 @@ import "github.com/gogo/protobuf/gogoproto/gogo.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; option (gogoproto.testgen_all) = true; option (gogoproto.populate_all) = true; @@ -52,6 +53,33 @@ message StdTypes { google.protobuf.Duration nullableDuration = 2 [(gogoproto.stdduration) = true]; google.protobuf.Timestamp timestamp = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; google.protobuf.Duration duration = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + + google.protobuf.DoubleValue nullableDouble = 5 [(gogoproto.wktpointer) = true]; + google.protobuf.DoubleValue nonnullDouble = 6 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + google.protobuf.FloatValue nullableFloat = 7 [(gogoproto.wktpointer) = true]; + google.protobuf.FloatValue nonnullFloat = 8 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + google.protobuf.Int64Value nullableInt64 = 9 [(gogoproto.wktpointer) = true]; + google.protobuf.Int64Value nonnullInt64 = 10 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + google.protobuf.UInt64Value nullableUInt64 = 11 [(gogoproto.wktpointer) = true]; + google.protobuf.UInt64Value nonnullUInt64 = 12 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + google.protobuf.Int32Value nullableInt32 = 13 [(gogoproto.wktpointer) = true]; + google.protobuf.Int32Value nonnullInt32 = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + google.protobuf.UInt32Value nullableUInt32 = 15 [(gogoproto.wktpointer) = true]; + google.protobuf.UInt32Value nonnullUInt32 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + google.protobuf.BoolValue nullableBool = 17 [(gogoproto.wktpointer) = true]; + google.protobuf.BoolValue nonnullBool = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + google.protobuf.StringValue nullableString = 19 [(gogoproto.wktpointer) = true]; + google.protobuf.StringValue nonnullString = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + google.protobuf.BytesValue nullableBytes = 21 [(gogoproto.wktpointer) = true]; + google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message RepStdTypes { @@ -59,6 +87,33 @@ message RepStdTypes { repeated google.protobuf.Duration nullableDurations = 2 [(gogoproto.stdduration) = true]; repeated google.protobuf.Timestamp timestamps = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; repeated google.protobuf.Duration durations = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.DoubleValue nullableDouble = 5 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.DoubleValue nonnullDouble = 6 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.FloatValue nullableFloat = 7 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.FloatValue nonnullFloat = 8 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.Int64Value nullableInt64 = 9 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.Int64Value nonnullInt64 = 10 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.UInt64Value nullableUInt64 = 11 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.UInt64Value nonnullUInt64 = 12 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.Int32Value nullableInt32 = 13 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.Int32Value nonnullInt32 = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.UInt32Value nullableUInt32 = 15 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.UInt32Value nonnullUInt32 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.BoolValue nullableBool = 17 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.BoolValue nonnullBool = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.StringValue nullableString = 19 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.StringValue nonnullString = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.BytesValue nullableBytes = 21 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message MapStdTypes { @@ -67,12 +122,48 @@ message MapStdTypes { map nullableDuration = 3 [(gogoproto.stdduration) = true]; map duration = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + + map nullableDouble = 5 [(gogoproto.wktpointer) = true]; + map nonnullDouble = 6 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableFloat = 7 [(gogoproto.wktpointer) = true]; + map nonnullFloat = 8 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableInt64 = 9 [(gogoproto.wktpointer) = true]; + map nonnullInt64 = 10 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableUInt64 = 11 [(gogoproto.wktpointer) = true]; + map nonnullUInt64 = 12 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableInt32 = 13 [(gogoproto.wktpointer) = true]; + map nonnullInt32 = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableUInt32 = 15 [(gogoproto.wktpointer) = true]; + map nonnullUInt32 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableBool = 17 [(gogoproto.wktpointer) = true]; + map nonnullBool = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableString = 19 [(gogoproto.wktpointer) = true]; + map nonnullString = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableBytes = 21 [(gogoproto.wktpointer) = true]; + map nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message OneofStdTypes { oneof OneOfStdTimes { google.protobuf.Timestamp timestamp = 1 [(gogoproto.stdtime) = true]; google.protobuf.Duration duration = 2 [(gogoproto.stdduration) = true]; + google.protobuf.DoubleValue repDouble = 3 [(gogoproto.wktpointer) = true]; + google.protobuf.FloatValue repFloat = 4 [(gogoproto.wktpointer) = true]; + google.protobuf.Int64Value repInt64 = 5 [(gogoproto.wktpointer) = true]; + google.protobuf.UInt64Value repUInt64 = 6 [(gogoproto.wktpointer) = true]; + google.protobuf.Int32Value repInt32 = 7 [(gogoproto.wktpointer) = true]; + google.protobuf.UInt32Value repUInt32 = 8 [(gogoproto.wktpointer) = true]; + google.protobuf.BoolValue repBool = 9 [(gogoproto.wktpointer) = true]; + google.protobuf.StringValue repString = 10 [(gogoproto.wktpointer) = true]; + google.protobuf.BytesValue repBytes = 11 [(gogoproto.wktpointer) = true]; } } diff --git a/test/types/combos/both/types.proto b/test/types/combos/both/types.proto index 6c03777632..0b019f2cd3 100644 --- a/test/types/combos/both/types.proto +++ b/test/types/combos/both/types.proto @@ -73,15 +73,53 @@ message ProtoTypes { option (gogoproto.compare) = true; google.protobuf.Timestamp nullableTimestamp = 1; google.protobuf.Duration nullableDuration = 2; - google.protobuf.Timestamp timestamp = 3 [(gogoproto.nullable) = false]; - google.protobuf.Duration duration = 4 [(gogoproto.nullable) = false]; + google.protobuf.DoubleValue nullableDouble = 3; + google.protobuf.FloatValue nullableFloat = 4; + google.protobuf.Int64Value nullableInt64 = 5; + google.protobuf.UInt64Value nullableUInt64 = 6; + google.protobuf.Int32Value nullableInt32 = 7; + google.protobuf.UInt32Value nullableUInt32 = 8; + google.protobuf.BoolValue nullableBool = 9; + google.protobuf.StringValue nullableString = 10; + google.protobuf.BytesValue nullableBytes = 11; + + google.protobuf.Timestamp timestamp = 12 [(gogoproto.nullable) = false]; + google.protobuf.Duration duration = 13 [(gogoproto.nullable) = false]; + google.protobuf.DoubleValue nonnullDouble = 14 [(gogoproto.nullable) = false]; + google.protobuf.FloatValue nonnullFloat = 15 [(gogoproto.nullable) = false]; + google.protobuf.Int64Value nonnullInt64 = 16 [(gogoproto.nullable) = false]; + google.protobuf.UInt64Value nonnullUInt64 = 17 [(gogoproto.nullable) = false]; + google.protobuf.Int32Value nonnullInt32 = 18 [(gogoproto.nullable) = false]; + google.protobuf.UInt32Value nonnullUInt32 = 19 [(gogoproto.nullable) = false]; + google.protobuf.BoolValue nonnullBool = 20 [(gogoproto.nullable) = false]; + google.protobuf.StringValue nonnullString = 21 [(gogoproto.nullable) = false]; + google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.nullable) = false]; } message StdTypes { google.protobuf.Timestamp nullableTimestamp = 1 [(gogoproto.stdtime) = true]; google.protobuf.Duration nullableDuration = 2 [(gogoproto.stdduration) = true]; - google.protobuf.Timestamp timestamp = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; - google.protobuf.Duration duration = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + google.protobuf.DoubleValue nullableDouble = 3 [(gogoproto.wktpointer) = true];; + google.protobuf.FloatValue nullableFloat = 4 [(gogoproto.wktpointer) = true];; + google.protobuf.Int64Value nullableInt64 = 5 [(gogoproto.wktpointer) = true];; + google.protobuf.UInt64Value nullableUInt64 = 6 [(gogoproto.wktpointer) = true];; + google.protobuf.Int32Value nullableInt32 = 7 [(gogoproto.wktpointer) = true];; + google.protobuf.UInt32Value nullableUInt32 = 8 [(gogoproto.wktpointer) = true];; + google.protobuf.BoolValue nullableBool = 9 [(gogoproto.wktpointer) = true];; + google.protobuf.StringValue nullableString = 10 [(gogoproto.wktpointer) = true];; + google.protobuf.BytesValue nullableBytes = 11 [(gogoproto.wktpointer) = true];; + + google.protobuf.Timestamp timestamp = 12 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + google.protobuf.Duration duration = 13 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + google.protobuf.DoubleValue nonnullDouble = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.FloatValue nonnullFloat = 15 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.Int64Value nonnullInt64 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.UInt64Value nonnullUInt64 = 17 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.Int32Value nonnullInt32 = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.UInt32Value nonnullUInt32 = 19 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.BoolValue nonnullBool = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.StringValue nonnullString = 21 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message RepProtoTypes { @@ -90,6 +128,33 @@ message RepProtoTypes { repeated google.protobuf.Duration nullableDurations = 2; repeated google.protobuf.Timestamp timestamps = 3 [(gogoproto.nullable) = false]; repeated google.protobuf.Duration durations = 4 [(gogoproto.nullable) = false]; + + repeated google.protobuf.DoubleValue nullableDouble = 5; + repeated google.protobuf.DoubleValue nonnullDouble = 6 [(gogoproto.nullable) = false]; + + repeated google.protobuf.FloatValue nullableFloat = 7; + repeated google.protobuf.FloatValue nonnullFloat = 8 [(gogoproto.nullable) = false]; + + repeated google.protobuf.Int64Value nullableInt64 = 9; + repeated google.protobuf.Int64Value nonnullInt64 = 10 [(gogoproto.nullable) = false]; + + repeated google.protobuf.UInt64Value nullableUInt64 = 11; + repeated google.protobuf.UInt64Value nonnullUInt64 = 12 [(gogoproto.nullable) = false]; + + repeated google.protobuf.Int32Value nullableInt32 = 13; + repeated google.protobuf.Int32Value nonnullInt32 = 14 [(gogoproto.nullable) = false]; + + repeated google.protobuf.UInt32Value nullableUInt32 = 15; + repeated google.protobuf.UInt32Value nonnullUInt32 = 16 [(gogoproto.nullable) = false]; + + repeated google.protobuf.BoolValue nullableBool = 17; + repeated google.protobuf.BoolValue nonnullBool = 18 [(gogoproto.nullable) = false]; + + repeated google.protobuf.StringValue nullableString = 19; + repeated google.protobuf.StringValue nonnullString = 20 [(gogoproto.nullable) = false]; + + repeated google.protobuf.BytesValue nullableBytes = 21; + repeated google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.nullable) = false]; } message RepStdTypes { @@ -97,6 +162,33 @@ message RepStdTypes { repeated google.protobuf.Duration nullableDurations = 2 [(gogoproto.stdduration) = true]; repeated google.protobuf.Timestamp timestamps = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; repeated google.protobuf.Duration durations = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.DoubleValue nullableDouble = 5 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.DoubleValue nonnullDouble = 6 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.FloatValue nullableFloat = 7 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.FloatValue nonnullFloat = 8 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.Int64Value nullableInt64 = 9 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.Int64Value nonnullInt64 = 10 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.UInt64Value nullableUInt64 = 11 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.UInt64Value nonnullUInt64 = 12 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.Int32Value nullableInt32 = 13 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.Int32Value nonnullInt32 = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.UInt32Value nullableUInt32 = 15 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.UInt32Value nonnullUInt32 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.BoolValue nullableBool = 17 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.BoolValue nonnullBool = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.StringValue nullableString = 19 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.StringValue nonnullString = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.BytesValue nullableBytes = 21 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message MapProtoTypes { @@ -105,6 +197,33 @@ message MapProtoTypes { map nullableDuration = 3; map duration = 4 [(gogoproto.nullable) = false]; + + map nullableDouble = 5; + map nonnullDouble = 6 [(gogoproto.nullable) = false]; + + map nullableFloat = 7; + map nonnullFloat = 8 [(gogoproto.nullable) = false]; + + map nullableInt64 = 9; + map nonnullInt64 = 10 [(gogoproto.nullable) = false]; + + map nullableUInt64 = 11; + map nonnullUInt64 = 12 [(gogoproto.nullable) = false]; + + map nullableInt32 = 13; + map nonnullInt32 = 14 [(gogoproto.nullable) = false]; + + map nullableUInt32 = 15; + map nonnullUInt32 = 16 [(gogoproto.nullable) = false]; + + map nullableBool = 17; + map nonnullBool = 18 [(gogoproto.nullable) = false]; + + map nullableString = 19; + map nonnullString = 20 [(gogoproto.nullable) = false]; + + map nullableBytes = 21; + map nonnullBytes = 22 [(gogoproto.nullable) = false]; } message MapStdTypes { @@ -113,12 +232,48 @@ message MapStdTypes { map nullableDuration = 3 [(gogoproto.stdduration) = true]; map duration = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + + map nullableDouble = 5 [(gogoproto.wktpointer) = true]; + map nonnullDouble = 6 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableFloat = 7 [(gogoproto.wktpointer) = true]; + map nonnullFloat = 8 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableInt64 = 9 [(gogoproto.wktpointer) = true]; + map nonnullInt64 = 10 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableUInt64 = 11 [(gogoproto.wktpointer) = true]; + map nonnullUInt64 = 12 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableInt32 = 13 [(gogoproto.wktpointer) = true]; + map nonnullInt32 = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableUInt32 = 15 [(gogoproto.wktpointer) = true]; + map nonnullUInt32 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableBool = 17 [(gogoproto.wktpointer) = true]; + map nonnullBool = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableString = 19 [(gogoproto.wktpointer) = true]; + map nonnullString = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableBytes = 21 [(gogoproto.wktpointer) = true]; + map nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message OneofProtoTypes { oneof OneOfProtoTimes { google.protobuf.Timestamp timestamp = 1; google.protobuf.Duration duration = 2; + google.protobuf.DoubleValue repDouble = 3; + google.protobuf.FloatValue repFloat = 4; + google.protobuf.Int64Value repInt64 = 5; + google.protobuf.UInt64Value repUInt64 = 6; + google.protobuf.Int32Value repInt32 = 7; + google.protobuf.UInt32Value repUInt32 = 8; + google.protobuf.BoolValue repBool = 9; + google.protobuf.StringValue repString = 10; + google.protobuf.BytesValue repBytes = 11; } } @@ -126,6 +281,15 @@ message OneofStdTypes { oneof OneOfStdTimes { google.protobuf.Timestamp timestamp = 1 [(gogoproto.stdtime) = true]; google.protobuf.Duration duration = 2 [(gogoproto.stdduration) = true]; + google.protobuf.DoubleValue repDouble = 3 [(gogoproto.wktpointer) = true]; + google.protobuf.FloatValue repFloat = 4 [(gogoproto.wktpointer) = true]; + google.protobuf.Int64Value repInt64 = 5 [(gogoproto.wktpointer) = true]; + google.protobuf.UInt64Value repUInt64 = 6 [(gogoproto.wktpointer) = true]; + google.protobuf.Int32Value repInt32 = 7 [(gogoproto.wktpointer) = true]; + google.protobuf.UInt32Value repUInt32 = 8 [(gogoproto.wktpointer) = true]; + google.protobuf.BoolValue repBool = 9 [(gogoproto.wktpointer) = true]; + google.protobuf.StringValue repString = 10 [(gogoproto.wktpointer) = true]; + google.protobuf.BytesValue repBytes = 11 [(gogoproto.wktpointer) = true]; } } diff --git a/test/types/combos/marshaler/types.proto b/test/types/combos/marshaler/types.proto index 05cb95567a..c1d79f65e9 100644 --- a/test/types/combos/marshaler/types.proto +++ b/test/types/combos/marshaler/types.proto @@ -73,15 +73,53 @@ message ProtoTypes { option (gogoproto.compare) = true; google.protobuf.Timestamp nullableTimestamp = 1; google.protobuf.Duration nullableDuration = 2; - google.protobuf.Timestamp timestamp = 3 [(gogoproto.nullable) = false]; - google.protobuf.Duration duration = 4 [(gogoproto.nullable) = false]; + google.protobuf.DoubleValue nullableDouble = 3; + google.protobuf.FloatValue nullableFloat = 4; + google.protobuf.Int64Value nullableInt64 = 5; + google.protobuf.UInt64Value nullableUInt64 = 6; + google.protobuf.Int32Value nullableInt32 = 7; + google.protobuf.UInt32Value nullableUInt32 = 8; + google.protobuf.BoolValue nullableBool = 9; + google.protobuf.StringValue nullableString = 10; + google.protobuf.BytesValue nullableBytes = 11; + + google.protobuf.Timestamp timestamp = 12 [(gogoproto.nullable) = false]; + google.protobuf.Duration duration = 13 [(gogoproto.nullable) = false]; + google.protobuf.DoubleValue nonnullDouble = 14 [(gogoproto.nullable) = false]; + google.protobuf.FloatValue nonnullFloat = 15 [(gogoproto.nullable) = false]; + google.protobuf.Int64Value nonnullInt64 = 16 [(gogoproto.nullable) = false]; + google.protobuf.UInt64Value nonnullUInt64 = 17 [(gogoproto.nullable) = false]; + google.protobuf.Int32Value nonnullInt32 = 18 [(gogoproto.nullable) = false]; + google.protobuf.UInt32Value nonnullUInt32 = 19 [(gogoproto.nullable) = false]; + google.protobuf.BoolValue nonnullBool = 20 [(gogoproto.nullable) = false]; + google.protobuf.StringValue nonnullString = 21 [(gogoproto.nullable) = false]; + google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.nullable) = false]; } message StdTypes { google.protobuf.Timestamp nullableTimestamp = 1 [(gogoproto.stdtime) = true]; google.protobuf.Duration nullableDuration = 2 [(gogoproto.stdduration) = true]; - google.protobuf.Timestamp timestamp = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; - google.protobuf.Duration duration = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + google.protobuf.DoubleValue nullableDouble = 3 [(gogoproto.wktpointer) = true];; + google.protobuf.FloatValue nullableFloat = 4 [(gogoproto.wktpointer) = true];; + google.protobuf.Int64Value nullableInt64 = 5 [(gogoproto.wktpointer) = true];; + google.protobuf.UInt64Value nullableUInt64 = 6 [(gogoproto.wktpointer) = true];; + google.protobuf.Int32Value nullableInt32 = 7 [(gogoproto.wktpointer) = true];; + google.protobuf.UInt32Value nullableUInt32 = 8 [(gogoproto.wktpointer) = true];; + google.protobuf.BoolValue nullableBool = 9 [(gogoproto.wktpointer) = true];; + google.protobuf.StringValue nullableString = 10 [(gogoproto.wktpointer) = true];; + google.protobuf.BytesValue nullableBytes = 11 [(gogoproto.wktpointer) = true];; + + google.protobuf.Timestamp timestamp = 12 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + google.protobuf.Duration duration = 13 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + google.protobuf.DoubleValue nonnullDouble = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.FloatValue nonnullFloat = 15 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.Int64Value nonnullInt64 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.UInt64Value nonnullUInt64 = 17 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.Int32Value nonnullInt32 = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.UInt32Value nonnullUInt32 = 19 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.BoolValue nonnullBool = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.StringValue nonnullString = 21 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message RepProtoTypes { @@ -90,6 +128,33 @@ message RepProtoTypes { repeated google.protobuf.Duration nullableDurations = 2; repeated google.protobuf.Timestamp timestamps = 3 [(gogoproto.nullable) = false]; repeated google.protobuf.Duration durations = 4 [(gogoproto.nullable) = false]; + + repeated google.protobuf.DoubleValue nullableDouble = 5; + repeated google.protobuf.DoubleValue nonnullDouble = 6 [(gogoproto.nullable) = false]; + + repeated google.protobuf.FloatValue nullableFloat = 7; + repeated google.protobuf.FloatValue nonnullFloat = 8 [(gogoproto.nullable) = false]; + + repeated google.protobuf.Int64Value nullableInt64 = 9; + repeated google.protobuf.Int64Value nonnullInt64 = 10 [(gogoproto.nullable) = false]; + + repeated google.protobuf.UInt64Value nullableUInt64 = 11; + repeated google.protobuf.UInt64Value nonnullUInt64 = 12 [(gogoproto.nullable) = false]; + + repeated google.protobuf.Int32Value nullableInt32 = 13; + repeated google.protobuf.Int32Value nonnullInt32 = 14 [(gogoproto.nullable) = false]; + + repeated google.protobuf.UInt32Value nullableUInt32 = 15; + repeated google.protobuf.UInt32Value nonnullUInt32 = 16 [(gogoproto.nullable) = false]; + + repeated google.protobuf.BoolValue nullableBool = 17; + repeated google.protobuf.BoolValue nonnullBool = 18 [(gogoproto.nullable) = false]; + + repeated google.protobuf.StringValue nullableString = 19; + repeated google.protobuf.StringValue nonnullString = 20 [(gogoproto.nullable) = false]; + + repeated google.protobuf.BytesValue nullableBytes = 21; + repeated google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.nullable) = false]; } message RepStdTypes { @@ -97,6 +162,33 @@ message RepStdTypes { repeated google.protobuf.Duration nullableDurations = 2 [(gogoproto.stdduration) = true]; repeated google.protobuf.Timestamp timestamps = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; repeated google.protobuf.Duration durations = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.DoubleValue nullableDouble = 5 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.DoubleValue nonnullDouble = 6 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.FloatValue nullableFloat = 7 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.FloatValue nonnullFloat = 8 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.Int64Value nullableInt64 = 9 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.Int64Value nonnullInt64 = 10 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.UInt64Value nullableUInt64 = 11 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.UInt64Value nonnullUInt64 = 12 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.Int32Value nullableInt32 = 13 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.Int32Value nonnullInt32 = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.UInt32Value nullableUInt32 = 15 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.UInt32Value nonnullUInt32 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.BoolValue nullableBool = 17 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.BoolValue nonnullBool = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.StringValue nullableString = 19 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.StringValue nonnullString = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.BytesValue nullableBytes = 21 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message MapProtoTypes { @@ -105,6 +197,33 @@ message MapProtoTypes { map nullableDuration = 3; map duration = 4 [(gogoproto.nullable) = false]; + + map nullableDouble = 5; + map nonnullDouble = 6 [(gogoproto.nullable) = false]; + + map nullableFloat = 7; + map nonnullFloat = 8 [(gogoproto.nullable) = false]; + + map nullableInt64 = 9; + map nonnullInt64 = 10 [(gogoproto.nullable) = false]; + + map nullableUInt64 = 11; + map nonnullUInt64 = 12 [(gogoproto.nullable) = false]; + + map nullableInt32 = 13; + map nonnullInt32 = 14 [(gogoproto.nullable) = false]; + + map nullableUInt32 = 15; + map nonnullUInt32 = 16 [(gogoproto.nullable) = false]; + + map nullableBool = 17; + map nonnullBool = 18 [(gogoproto.nullable) = false]; + + map nullableString = 19; + map nonnullString = 20 [(gogoproto.nullable) = false]; + + map nullableBytes = 21; + map nonnullBytes = 22 [(gogoproto.nullable) = false]; } message MapStdTypes { @@ -113,12 +232,48 @@ message MapStdTypes { map nullableDuration = 3 [(gogoproto.stdduration) = true]; map duration = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + + map nullableDouble = 5 [(gogoproto.wktpointer) = true]; + map nonnullDouble = 6 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableFloat = 7 [(gogoproto.wktpointer) = true]; + map nonnullFloat = 8 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableInt64 = 9 [(gogoproto.wktpointer) = true]; + map nonnullInt64 = 10 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableUInt64 = 11 [(gogoproto.wktpointer) = true]; + map nonnullUInt64 = 12 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableInt32 = 13 [(gogoproto.wktpointer) = true]; + map nonnullInt32 = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableUInt32 = 15 [(gogoproto.wktpointer) = true]; + map nonnullUInt32 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableBool = 17 [(gogoproto.wktpointer) = true]; + map nonnullBool = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableString = 19 [(gogoproto.wktpointer) = true]; + map nonnullString = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableBytes = 21 [(gogoproto.wktpointer) = true]; + map nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message OneofProtoTypes { oneof OneOfProtoTimes { google.protobuf.Timestamp timestamp = 1; google.protobuf.Duration duration = 2; + google.protobuf.DoubleValue repDouble = 3; + google.protobuf.FloatValue repFloat = 4; + google.protobuf.Int64Value repInt64 = 5; + google.protobuf.UInt64Value repUInt64 = 6; + google.protobuf.Int32Value repInt32 = 7; + google.protobuf.UInt32Value repUInt32 = 8; + google.protobuf.BoolValue repBool = 9; + google.protobuf.StringValue repString = 10; + google.protobuf.BytesValue repBytes = 11; } } @@ -126,6 +281,15 @@ message OneofStdTypes { oneof OneOfStdTimes { google.protobuf.Timestamp timestamp = 1 [(gogoproto.stdtime) = true]; google.protobuf.Duration duration = 2 [(gogoproto.stdduration) = true]; + google.protobuf.DoubleValue repDouble = 3 [(gogoproto.wktpointer) = true]; + google.protobuf.FloatValue repFloat = 4 [(gogoproto.wktpointer) = true]; + google.protobuf.Int64Value repInt64 = 5 [(gogoproto.wktpointer) = true]; + google.protobuf.UInt64Value repUInt64 = 6 [(gogoproto.wktpointer) = true]; + google.protobuf.Int32Value repInt32 = 7 [(gogoproto.wktpointer) = true]; + google.protobuf.UInt32Value repUInt32 = 8 [(gogoproto.wktpointer) = true]; + google.protobuf.BoolValue repBool = 9 [(gogoproto.wktpointer) = true]; + google.protobuf.StringValue repString = 10 [(gogoproto.wktpointer) = true]; + google.protobuf.BytesValue repBytes = 11 [(gogoproto.wktpointer) = true]; } } diff --git a/test/types/combos/neither/types.proto b/test/types/combos/neither/types.proto index 3c26fae202..86c2eccdb3 100644 --- a/test/types/combos/neither/types.proto +++ b/test/types/combos/neither/types.proto @@ -73,15 +73,53 @@ message ProtoTypes { option (gogoproto.compare) = true; google.protobuf.Timestamp nullableTimestamp = 1; google.protobuf.Duration nullableDuration = 2; - google.protobuf.Timestamp timestamp = 3 [(gogoproto.nullable) = false]; - google.protobuf.Duration duration = 4 [(gogoproto.nullable) = false]; + google.protobuf.DoubleValue nullableDouble = 3; + google.protobuf.FloatValue nullableFloat = 4; + google.protobuf.Int64Value nullableInt64 = 5; + google.protobuf.UInt64Value nullableUInt64 = 6; + google.protobuf.Int32Value nullableInt32 = 7; + google.protobuf.UInt32Value nullableUInt32 = 8; + google.protobuf.BoolValue nullableBool = 9; + google.protobuf.StringValue nullableString = 10; + google.protobuf.BytesValue nullableBytes = 11; + + google.protobuf.Timestamp timestamp = 12 [(gogoproto.nullable) = false]; + google.protobuf.Duration duration = 13 [(gogoproto.nullable) = false]; + google.protobuf.DoubleValue nonnullDouble = 14 [(gogoproto.nullable) = false]; + google.protobuf.FloatValue nonnullFloat = 15 [(gogoproto.nullable) = false]; + google.protobuf.Int64Value nonnullInt64 = 16 [(gogoproto.nullable) = false]; + google.protobuf.UInt64Value nonnullUInt64 = 17 [(gogoproto.nullable) = false]; + google.protobuf.Int32Value nonnullInt32 = 18 [(gogoproto.nullable) = false]; + google.protobuf.UInt32Value nonnullUInt32 = 19 [(gogoproto.nullable) = false]; + google.protobuf.BoolValue nonnullBool = 20 [(gogoproto.nullable) = false]; + google.protobuf.StringValue nonnullString = 21 [(gogoproto.nullable) = false]; + google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.nullable) = false]; } message StdTypes { google.protobuf.Timestamp nullableTimestamp = 1 [(gogoproto.stdtime) = true]; google.protobuf.Duration nullableDuration = 2 [(gogoproto.stdduration) = true]; - google.protobuf.Timestamp timestamp = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; - google.protobuf.Duration duration = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + google.protobuf.DoubleValue nullableDouble = 3 [(gogoproto.wktpointer) = true];; + google.protobuf.FloatValue nullableFloat = 4 [(gogoproto.wktpointer) = true];; + google.protobuf.Int64Value nullableInt64 = 5 [(gogoproto.wktpointer) = true];; + google.protobuf.UInt64Value nullableUInt64 = 6 [(gogoproto.wktpointer) = true];; + google.protobuf.Int32Value nullableInt32 = 7 [(gogoproto.wktpointer) = true];; + google.protobuf.UInt32Value nullableUInt32 = 8 [(gogoproto.wktpointer) = true];; + google.protobuf.BoolValue nullableBool = 9 [(gogoproto.wktpointer) = true];; + google.protobuf.StringValue nullableString = 10 [(gogoproto.wktpointer) = true];; + google.protobuf.BytesValue nullableBytes = 11 [(gogoproto.wktpointer) = true];; + + google.protobuf.Timestamp timestamp = 12 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + google.protobuf.Duration duration = 13 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + google.protobuf.DoubleValue nonnullDouble = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.FloatValue nonnullFloat = 15 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.Int64Value nonnullInt64 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.UInt64Value nonnullUInt64 = 17 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.Int32Value nonnullInt32 = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.UInt32Value nonnullUInt32 = 19 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.BoolValue nonnullBool = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.StringValue nonnullString = 21 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message RepProtoTypes { @@ -90,6 +128,33 @@ message RepProtoTypes { repeated google.protobuf.Duration nullableDurations = 2; repeated google.protobuf.Timestamp timestamps = 3 [(gogoproto.nullable) = false]; repeated google.protobuf.Duration durations = 4 [(gogoproto.nullable) = false]; + + repeated google.protobuf.DoubleValue nullableDouble = 5; + repeated google.protobuf.DoubleValue nonnullDouble = 6 [(gogoproto.nullable) = false]; + + repeated google.protobuf.FloatValue nullableFloat = 7; + repeated google.protobuf.FloatValue nonnullFloat = 8 [(gogoproto.nullable) = false]; + + repeated google.protobuf.Int64Value nullableInt64 = 9; + repeated google.protobuf.Int64Value nonnullInt64 = 10 [(gogoproto.nullable) = false]; + + repeated google.protobuf.UInt64Value nullableUInt64 = 11; + repeated google.protobuf.UInt64Value nonnullUInt64 = 12 [(gogoproto.nullable) = false]; + + repeated google.protobuf.Int32Value nullableInt32 = 13; + repeated google.protobuf.Int32Value nonnullInt32 = 14 [(gogoproto.nullable) = false]; + + repeated google.protobuf.UInt32Value nullableUInt32 = 15; + repeated google.protobuf.UInt32Value nonnullUInt32 = 16 [(gogoproto.nullable) = false]; + + repeated google.protobuf.BoolValue nullableBool = 17; + repeated google.protobuf.BoolValue nonnullBool = 18 [(gogoproto.nullable) = false]; + + repeated google.protobuf.StringValue nullableString = 19; + repeated google.protobuf.StringValue nonnullString = 20 [(gogoproto.nullable) = false]; + + repeated google.protobuf.BytesValue nullableBytes = 21; + repeated google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.nullable) = false]; } message RepStdTypes { @@ -97,6 +162,33 @@ message RepStdTypes { repeated google.protobuf.Duration nullableDurations = 2 [(gogoproto.stdduration) = true]; repeated google.protobuf.Timestamp timestamps = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; repeated google.protobuf.Duration durations = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.DoubleValue nullableDouble = 5 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.DoubleValue nonnullDouble = 6 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.FloatValue nullableFloat = 7 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.FloatValue nonnullFloat = 8 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.Int64Value nullableInt64 = 9 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.Int64Value nonnullInt64 = 10 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.UInt64Value nullableUInt64 = 11 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.UInt64Value nonnullUInt64 = 12 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.Int32Value nullableInt32 = 13 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.Int32Value nonnullInt32 = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.UInt32Value nullableUInt32 = 15 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.UInt32Value nonnullUInt32 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.BoolValue nullableBool = 17 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.BoolValue nonnullBool = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.StringValue nullableString = 19 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.StringValue nonnullString = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.BytesValue nullableBytes = 21 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message MapProtoTypes { @@ -105,6 +197,33 @@ message MapProtoTypes { map nullableDuration = 3; map duration = 4 [(gogoproto.nullable) = false]; + + map nullableDouble = 5; + map nonnullDouble = 6 [(gogoproto.nullable) = false]; + + map nullableFloat = 7; + map nonnullFloat = 8 [(gogoproto.nullable) = false]; + + map nullableInt64 = 9; + map nonnullInt64 = 10 [(gogoproto.nullable) = false]; + + map nullableUInt64 = 11; + map nonnullUInt64 = 12 [(gogoproto.nullable) = false]; + + map nullableInt32 = 13; + map nonnullInt32 = 14 [(gogoproto.nullable) = false]; + + map nullableUInt32 = 15; + map nonnullUInt32 = 16 [(gogoproto.nullable) = false]; + + map nullableBool = 17; + map nonnullBool = 18 [(gogoproto.nullable) = false]; + + map nullableString = 19; + map nonnullString = 20 [(gogoproto.nullable) = false]; + + map nullableBytes = 21; + map nonnullBytes = 22 [(gogoproto.nullable) = false]; } message MapStdTypes { @@ -113,12 +232,48 @@ message MapStdTypes { map nullableDuration = 3 [(gogoproto.stdduration) = true]; map duration = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + + map nullableDouble = 5 [(gogoproto.wktpointer) = true]; + map nonnullDouble = 6 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableFloat = 7 [(gogoproto.wktpointer) = true]; + map nonnullFloat = 8 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableInt64 = 9 [(gogoproto.wktpointer) = true]; + map nonnullInt64 = 10 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableUInt64 = 11 [(gogoproto.wktpointer) = true]; + map nonnullUInt64 = 12 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableInt32 = 13 [(gogoproto.wktpointer) = true]; + map nonnullInt32 = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableUInt32 = 15 [(gogoproto.wktpointer) = true]; + map nonnullUInt32 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableBool = 17 [(gogoproto.wktpointer) = true]; + map nonnullBool = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableString = 19 [(gogoproto.wktpointer) = true]; + map nonnullString = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableBytes = 21 [(gogoproto.wktpointer) = true]; + map nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message OneofProtoTypes { oneof OneOfProtoTimes { google.protobuf.Timestamp timestamp = 1; google.protobuf.Duration duration = 2; + google.protobuf.DoubleValue repDouble = 3; + google.protobuf.FloatValue repFloat = 4; + google.protobuf.Int64Value repInt64 = 5; + google.protobuf.UInt64Value repUInt64 = 6; + google.protobuf.Int32Value repInt32 = 7; + google.protobuf.UInt32Value repUInt32 = 8; + google.protobuf.BoolValue repBool = 9; + google.protobuf.StringValue repString = 10; + google.protobuf.BytesValue repBytes = 11; } } @@ -126,6 +281,15 @@ message OneofStdTypes { oneof OneOfStdTimes { google.protobuf.Timestamp timestamp = 1 [(gogoproto.stdtime) = true]; google.protobuf.Duration duration = 2 [(gogoproto.stdduration) = true]; + google.protobuf.DoubleValue repDouble = 3 [(gogoproto.wktpointer) = true]; + google.protobuf.FloatValue repFloat = 4 [(gogoproto.wktpointer) = true]; + google.protobuf.Int64Value repInt64 = 5 [(gogoproto.wktpointer) = true]; + google.protobuf.UInt64Value repUInt64 = 6 [(gogoproto.wktpointer) = true]; + google.protobuf.Int32Value repInt32 = 7 [(gogoproto.wktpointer) = true]; + google.protobuf.UInt32Value repUInt32 = 8 [(gogoproto.wktpointer) = true]; + google.protobuf.BoolValue repBool = 9 [(gogoproto.wktpointer) = true]; + google.protobuf.StringValue repString = 10 [(gogoproto.wktpointer) = true]; + google.protobuf.BytesValue repBytes = 11 [(gogoproto.wktpointer) = true]; } } diff --git a/test/types/combos/unmarshaler/types.proto b/test/types/combos/unmarshaler/types.proto index 0fd0bb6a81..60adfbfb5b 100644 --- a/test/types/combos/unmarshaler/types.proto +++ b/test/types/combos/unmarshaler/types.proto @@ -73,15 +73,53 @@ message ProtoTypes { option (gogoproto.compare) = true; google.protobuf.Timestamp nullableTimestamp = 1; google.protobuf.Duration nullableDuration = 2; - google.protobuf.Timestamp timestamp = 3 [(gogoproto.nullable) = false]; - google.protobuf.Duration duration = 4 [(gogoproto.nullable) = false]; + google.protobuf.DoubleValue nullableDouble = 3; + google.protobuf.FloatValue nullableFloat = 4; + google.protobuf.Int64Value nullableInt64 = 5; + google.protobuf.UInt64Value nullableUInt64 = 6; + google.protobuf.Int32Value nullableInt32 = 7; + google.protobuf.UInt32Value nullableUInt32 = 8; + google.protobuf.BoolValue nullableBool = 9; + google.protobuf.StringValue nullableString = 10; + google.protobuf.BytesValue nullableBytes = 11; + + google.protobuf.Timestamp timestamp = 12 [(gogoproto.nullable) = false]; + google.protobuf.Duration duration = 13 [(gogoproto.nullable) = false]; + google.protobuf.DoubleValue nonnullDouble = 14 [(gogoproto.nullable) = false]; + google.protobuf.FloatValue nonnullFloat = 15 [(gogoproto.nullable) = false]; + google.protobuf.Int64Value nonnullInt64 = 16 [(gogoproto.nullable) = false]; + google.protobuf.UInt64Value nonnullUInt64 = 17 [(gogoproto.nullable) = false]; + google.protobuf.Int32Value nonnullInt32 = 18 [(gogoproto.nullable) = false]; + google.protobuf.UInt32Value nonnullUInt32 = 19 [(gogoproto.nullable) = false]; + google.protobuf.BoolValue nonnullBool = 20 [(gogoproto.nullable) = false]; + google.protobuf.StringValue nonnullString = 21 [(gogoproto.nullable) = false]; + google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.nullable) = false]; } message StdTypes { google.protobuf.Timestamp nullableTimestamp = 1 [(gogoproto.stdtime) = true]; google.protobuf.Duration nullableDuration = 2 [(gogoproto.stdduration) = true]; - google.protobuf.Timestamp timestamp = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; - google.protobuf.Duration duration = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + google.protobuf.DoubleValue nullableDouble = 3 [(gogoproto.wktpointer) = true];; + google.protobuf.FloatValue nullableFloat = 4 [(gogoproto.wktpointer) = true];; + google.protobuf.Int64Value nullableInt64 = 5 [(gogoproto.wktpointer) = true];; + google.protobuf.UInt64Value nullableUInt64 = 6 [(gogoproto.wktpointer) = true];; + google.protobuf.Int32Value nullableInt32 = 7 [(gogoproto.wktpointer) = true];; + google.protobuf.UInt32Value nullableUInt32 = 8 [(gogoproto.wktpointer) = true];; + google.protobuf.BoolValue nullableBool = 9 [(gogoproto.wktpointer) = true];; + google.protobuf.StringValue nullableString = 10 [(gogoproto.wktpointer) = true];; + google.protobuf.BytesValue nullableBytes = 11 [(gogoproto.wktpointer) = true];; + + google.protobuf.Timestamp timestamp = 12 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + google.protobuf.Duration duration = 13 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + google.protobuf.DoubleValue nonnullDouble = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.FloatValue nonnullFloat = 15 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.Int64Value nonnullInt64 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.UInt64Value nonnullUInt64 = 17 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.Int32Value nonnullInt32 = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.UInt32Value nonnullUInt32 = 19 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.BoolValue nonnullBool = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.StringValue nonnullString = 21 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message RepProtoTypes { @@ -90,6 +128,33 @@ message RepProtoTypes { repeated google.protobuf.Duration nullableDurations = 2; repeated google.protobuf.Timestamp timestamps = 3 [(gogoproto.nullable) = false]; repeated google.protobuf.Duration durations = 4 [(gogoproto.nullable) = false]; + + repeated google.protobuf.DoubleValue nullableDouble = 5; + repeated google.protobuf.DoubleValue nonnullDouble = 6 [(gogoproto.nullable) = false]; + + repeated google.protobuf.FloatValue nullableFloat = 7; + repeated google.protobuf.FloatValue nonnullFloat = 8 [(gogoproto.nullable) = false]; + + repeated google.protobuf.Int64Value nullableInt64 = 9; + repeated google.protobuf.Int64Value nonnullInt64 = 10 [(gogoproto.nullable) = false]; + + repeated google.protobuf.UInt64Value nullableUInt64 = 11; + repeated google.protobuf.UInt64Value nonnullUInt64 = 12 [(gogoproto.nullable) = false]; + + repeated google.protobuf.Int32Value nullableInt32 = 13; + repeated google.protobuf.Int32Value nonnullInt32 = 14 [(gogoproto.nullable) = false]; + + repeated google.protobuf.UInt32Value nullableUInt32 = 15; + repeated google.protobuf.UInt32Value nonnullUInt32 = 16 [(gogoproto.nullable) = false]; + + repeated google.protobuf.BoolValue nullableBool = 17; + repeated google.protobuf.BoolValue nonnullBool = 18 [(gogoproto.nullable) = false]; + + repeated google.protobuf.StringValue nullableString = 19; + repeated google.protobuf.StringValue nonnullString = 20 [(gogoproto.nullable) = false]; + + repeated google.protobuf.BytesValue nullableBytes = 21; + repeated google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.nullable) = false]; } message RepStdTypes { @@ -97,6 +162,33 @@ message RepStdTypes { repeated google.protobuf.Duration nullableDurations = 2 [(gogoproto.stdduration) = true]; repeated google.protobuf.Timestamp timestamps = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; repeated google.protobuf.Duration durations = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.DoubleValue nullableDouble = 5 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.DoubleValue nonnullDouble = 6 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.FloatValue nullableFloat = 7 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.FloatValue nonnullFloat = 8 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.Int64Value nullableInt64 = 9 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.Int64Value nonnullInt64 = 10 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.UInt64Value nullableUInt64 = 11 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.UInt64Value nonnullUInt64 = 12 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.Int32Value nullableInt32 = 13 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.Int32Value nonnullInt32 = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.UInt32Value nullableUInt32 = 15 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.UInt32Value nonnullUInt32 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.BoolValue nullableBool = 17 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.BoolValue nonnullBool = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.StringValue nullableString = 19 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.StringValue nonnullString = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.BytesValue nullableBytes = 21 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message MapProtoTypes { @@ -105,6 +197,33 @@ message MapProtoTypes { map nullableDuration = 3; map duration = 4 [(gogoproto.nullable) = false]; + + map nullableDouble = 5; + map nonnullDouble = 6 [(gogoproto.nullable) = false]; + + map nullableFloat = 7; + map nonnullFloat = 8 [(gogoproto.nullable) = false]; + + map nullableInt64 = 9; + map nonnullInt64 = 10 [(gogoproto.nullable) = false]; + + map nullableUInt64 = 11; + map nonnullUInt64 = 12 [(gogoproto.nullable) = false]; + + map nullableInt32 = 13; + map nonnullInt32 = 14 [(gogoproto.nullable) = false]; + + map nullableUInt32 = 15; + map nonnullUInt32 = 16 [(gogoproto.nullable) = false]; + + map nullableBool = 17; + map nonnullBool = 18 [(gogoproto.nullable) = false]; + + map nullableString = 19; + map nonnullString = 20 [(gogoproto.nullable) = false]; + + map nullableBytes = 21; + map nonnullBytes = 22 [(gogoproto.nullable) = false]; } message MapStdTypes { @@ -113,12 +232,48 @@ message MapStdTypes { map nullableDuration = 3 [(gogoproto.stdduration) = true]; map duration = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + + map nullableDouble = 5 [(gogoproto.wktpointer) = true]; + map nonnullDouble = 6 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableFloat = 7 [(gogoproto.wktpointer) = true]; + map nonnullFloat = 8 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableInt64 = 9 [(gogoproto.wktpointer) = true]; + map nonnullInt64 = 10 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableUInt64 = 11 [(gogoproto.wktpointer) = true]; + map nonnullUInt64 = 12 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableInt32 = 13 [(gogoproto.wktpointer) = true]; + map nonnullInt32 = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableUInt32 = 15 [(gogoproto.wktpointer) = true]; + map nonnullUInt32 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableBool = 17 [(gogoproto.wktpointer) = true]; + map nonnullBool = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableString = 19 [(gogoproto.wktpointer) = true]; + map nonnullString = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableBytes = 21 [(gogoproto.wktpointer) = true]; + map nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message OneofProtoTypes { oneof OneOfProtoTimes { google.protobuf.Timestamp timestamp = 1; google.protobuf.Duration duration = 2; + google.protobuf.DoubleValue repDouble = 3; + google.protobuf.FloatValue repFloat = 4; + google.protobuf.Int64Value repInt64 = 5; + google.protobuf.UInt64Value repUInt64 = 6; + google.protobuf.Int32Value repInt32 = 7; + google.protobuf.UInt32Value repUInt32 = 8; + google.protobuf.BoolValue repBool = 9; + google.protobuf.StringValue repString = 10; + google.protobuf.BytesValue repBytes = 11; } } @@ -126,6 +281,15 @@ message OneofStdTypes { oneof OneOfStdTimes { google.protobuf.Timestamp timestamp = 1 [(gogoproto.stdtime) = true]; google.protobuf.Duration duration = 2 [(gogoproto.stdduration) = true]; + google.protobuf.DoubleValue repDouble = 3 [(gogoproto.wktpointer) = true]; + google.protobuf.FloatValue repFloat = 4 [(gogoproto.wktpointer) = true]; + google.protobuf.Int64Value repInt64 = 5 [(gogoproto.wktpointer) = true]; + google.protobuf.UInt64Value repUInt64 = 6 [(gogoproto.wktpointer) = true]; + google.protobuf.Int32Value repInt32 = 7 [(gogoproto.wktpointer) = true]; + google.protobuf.UInt32Value repUInt32 = 8 [(gogoproto.wktpointer) = true]; + google.protobuf.BoolValue repBool = 9 [(gogoproto.wktpointer) = true]; + google.protobuf.StringValue repString = 10 [(gogoproto.wktpointer) = true]; + google.protobuf.BytesValue repBytes = 11 [(gogoproto.wktpointer) = true]; } } diff --git a/test/types/types.proto b/test/types/types.proto index 3c26fae202..86c2eccdb3 100644 --- a/test/types/types.proto +++ b/test/types/types.proto @@ -73,15 +73,53 @@ message ProtoTypes { option (gogoproto.compare) = true; google.protobuf.Timestamp nullableTimestamp = 1; google.protobuf.Duration nullableDuration = 2; - google.protobuf.Timestamp timestamp = 3 [(gogoproto.nullable) = false]; - google.protobuf.Duration duration = 4 [(gogoproto.nullable) = false]; + google.protobuf.DoubleValue nullableDouble = 3; + google.protobuf.FloatValue nullableFloat = 4; + google.protobuf.Int64Value nullableInt64 = 5; + google.protobuf.UInt64Value nullableUInt64 = 6; + google.protobuf.Int32Value nullableInt32 = 7; + google.protobuf.UInt32Value nullableUInt32 = 8; + google.protobuf.BoolValue nullableBool = 9; + google.protobuf.StringValue nullableString = 10; + google.protobuf.BytesValue nullableBytes = 11; + + google.protobuf.Timestamp timestamp = 12 [(gogoproto.nullable) = false]; + google.protobuf.Duration duration = 13 [(gogoproto.nullable) = false]; + google.protobuf.DoubleValue nonnullDouble = 14 [(gogoproto.nullable) = false]; + google.protobuf.FloatValue nonnullFloat = 15 [(gogoproto.nullable) = false]; + google.protobuf.Int64Value nonnullInt64 = 16 [(gogoproto.nullable) = false]; + google.protobuf.UInt64Value nonnullUInt64 = 17 [(gogoproto.nullable) = false]; + google.protobuf.Int32Value nonnullInt32 = 18 [(gogoproto.nullable) = false]; + google.protobuf.UInt32Value nonnullUInt32 = 19 [(gogoproto.nullable) = false]; + google.protobuf.BoolValue nonnullBool = 20 [(gogoproto.nullable) = false]; + google.protobuf.StringValue nonnullString = 21 [(gogoproto.nullable) = false]; + google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.nullable) = false]; } message StdTypes { google.protobuf.Timestamp nullableTimestamp = 1 [(gogoproto.stdtime) = true]; google.protobuf.Duration nullableDuration = 2 [(gogoproto.stdduration) = true]; - google.protobuf.Timestamp timestamp = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; - google.protobuf.Duration duration = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + google.protobuf.DoubleValue nullableDouble = 3 [(gogoproto.wktpointer) = true];; + google.protobuf.FloatValue nullableFloat = 4 [(gogoproto.wktpointer) = true];; + google.protobuf.Int64Value nullableInt64 = 5 [(gogoproto.wktpointer) = true];; + google.protobuf.UInt64Value nullableUInt64 = 6 [(gogoproto.wktpointer) = true];; + google.protobuf.Int32Value nullableInt32 = 7 [(gogoproto.wktpointer) = true];; + google.protobuf.UInt32Value nullableUInt32 = 8 [(gogoproto.wktpointer) = true];; + google.protobuf.BoolValue nullableBool = 9 [(gogoproto.wktpointer) = true];; + google.protobuf.StringValue nullableString = 10 [(gogoproto.wktpointer) = true];; + google.protobuf.BytesValue nullableBytes = 11 [(gogoproto.wktpointer) = true];; + + google.protobuf.Timestamp timestamp = 12 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + google.protobuf.Duration duration = 13 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + google.protobuf.DoubleValue nonnullDouble = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.FloatValue nonnullFloat = 15 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.Int64Value nonnullInt64 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.UInt64Value nonnullUInt64 = 17 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.Int32Value nonnullInt32 = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.UInt32Value nonnullUInt32 = 19 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.BoolValue nonnullBool = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.StringValue nonnullString = 21 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message RepProtoTypes { @@ -90,6 +128,33 @@ message RepProtoTypes { repeated google.protobuf.Duration nullableDurations = 2; repeated google.protobuf.Timestamp timestamps = 3 [(gogoproto.nullable) = false]; repeated google.protobuf.Duration durations = 4 [(gogoproto.nullable) = false]; + + repeated google.protobuf.DoubleValue nullableDouble = 5; + repeated google.protobuf.DoubleValue nonnullDouble = 6 [(gogoproto.nullable) = false]; + + repeated google.protobuf.FloatValue nullableFloat = 7; + repeated google.protobuf.FloatValue nonnullFloat = 8 [(gogoproto.nullable) = false]; + + repeated google.protobuf.Int64Value nullableInt64 = 9; + repeated google.protobuf.Int64Value nonnullInt64 = 10 [(gogoproto.nullable) = false]; + + repeated google.protobuf.UInt64Value nullableUInt64 = 11; + repeated google.protobuf.UInt64Value nonnullUInt64 = 12 [(gogoproto.nullable) = false]; + + repeated google.protobuf.Int32Value nullableInt32 = 13; + repeated google.protobuf.Int32Value nonnullInt32 = 14 [(gogoproto.nullable) = false]; + + repeated google.protobuf.UInt32Value nullableUInt32 = 15; + repeated google.protobuf.UInt32Value nonnullUInt32 = 16 [(gogoproto.nullable) = false]; + + repeated google.protobuf.BoolValue nullableBool = 17; + repeated google.protobuf.BoolValue nonnullBool = 18 [(gogoproto.nullable) = false]; + + repeated google.protobuf.StringValue nullableString = 19; + repeated google.protobuf.StringValue nonnullString = 20 [(gogoproto.nullable) = false]; + + repeated google.protobuf.BytesValue nullableBytes = 21; + repeated google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.nullable) = false]; } message RepStdTypes { @@ -97,6 +162,33 @@ message RepStdTypes { repeated google.protobuf.Duration nullableDurations = 2 [(gogoproto.stdduration) = true]; repeated google.protobuf.Timestamp timestamps = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; repeated google.protobuf.Duration durations = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.DoubleValue nullableDouble = 5 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.DoubleValue nonnullDouble = 6 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.FloatValue nullableFloat = 7 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.FloatValue nonnullFloat = 8 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.Int64Value nullableInt64 = 9 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.Int64Value nonnullInt64 = 10 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.UInt64Value nullableUInt64 = 11 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.UInt64Value nonnullUInt64 = 12 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.Int32Value nullableInt32 = 13 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.Int32Value nonnullInt32 = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.UInt32Value nullableUInt32 = 15 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.UInt32Value nonnullUInt32 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.BoolValue nullableBool = 17 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.BoolValue nonnullBool = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.StringValue nullableString = 19 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.StringValue nonnullString = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + repeated google.protobuf.BytesValue nullableBytes = 21 [(gogoproto.wktpointer) = true]; + repeated google.protobuf.BytesValue nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message MapProtoTypes { @@ -105,6 +197,33 @@ message MapProtoTypes { map nullableDuration = 3; map duration = 4 [(gogoproto.nullable) = false]; + + map nullableDouble = 5; + map nonnullDouble = 6 [(gogoproto.nullable) = false]; + + map nullableFloat = 7; + map nonnullFloat = 8 [(gogoproto.nullable) = false]; + + map nullableInt64 = 9; + map nonnullInt64 = 10 [(gogoproto.nullable) = false]; + + map nullableUInt64 = 11; + map nonnullUInt64 = 12 [(gogoproto.nullable) = false]; + + map nullableInt32 = 13; + map nonnullInt32 = 14 [(gogoproto.nullable) = false]; + + map nullableUInt32 = 15; + map nonnullUInt32 = 16 [(gogoproto.nullable) = false]; + + map nullableBool = 17; + map nonnullBool = 18 [(gogoproto.nullable) = false]; + + map nullableString = 19; + map nonnullString = 20 [(gogoproto.nullable) = false]; + + map nullableBytes = 21; + map nonnullBytes = 22 [(gogoproto.nullable) = false]; } message MapStdTypes { @@ -113,12 +232,48 @@ message MapStdTypes { map nullableDuration = 3 [(gogoproto.stdduration) = true]; map duration = 4 [(gogoproto.stdduration) = true, (gogoproto.nullable) = false]; + + map nullableDouble = 5 [(gogoproto.wktpointer) = true]; + map nonnullDouble = 6 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableFloat = 7 [(gogoproto.wktpointer) = true]; + map nonnullFloat = 8 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableInt64 = 9 [(gogoproto.wktpointer) = true]; + map nonnullInt64 = 10 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableUInt64 = 11 [(gogoproto.wktpointer) = true]; + map nonnullUInt64 = 12 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableInt32 = 13 [(gogoproto.wktpointer) = true]; + map nonnullInt32 = 14 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableUInt32 = 15 [(gogoproto.wktpointer) = true]; + map nonnullUInt32 = 16 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableBool = 17 [(gogoproto.wktpointer) = true]; + map nonnullBool = 18 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableString = 19 [(gogoproto.wktpointer) = true]; + map nonnullString = 20 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; + + map nullableBytes = 21 [(gogoproto.wktpointer) = true]; + map nonnullBytes = 22 [(gogoproto.wktpointer) = true, (gogoproto.nullable) = false]; } message OneofProtoTypes { oneof OneOfProtoTimes { google.protobuf.Timestamp timestamp = 1; google.protobuf.Duration duration = 2; + google.protobuf.DoubleValue repDouble = 3; + google.protobuf.FloatValue repFloat = 4; + google.protobuf.Int64Value repInt64 = 5; + google.protobuf.UInt64Value repUInt64 = 6; + google.protobuf.Int32Value repInt32 = 7; + google.protobuf.UInt32Value repUInt32 = 8; + google.protobuf.BoolValue repBool = 9; + google.protobuf.StringValue repString = 10; + google.protobuf.BytesValue repBytes = 11; } } @@ -126,6 +281,15 @@ message OneofStdTypes { oneof OneOfStdTimes { google.protobuf.Timestamp timestamp = 1 [(gogoproto.stdtime) = true]; google.protobuf.Duration duration = 2 [(gogoproto.stdduration) = true]; + google.protobuf.DoubleValue repDouble = 3 [(gogoproto.wktpointer) = true]; + google.protobuf.FloatValue repFloat = 4 [(gogoproto.wktpointer) = true]; + google.protobuf.Int64Value repInt64 = 5 [(gogoproto.wktpointer) = true]; + google.protobuf.UInt64Value repUInt64 = 6 [(gogoproto.wktpointer) = true]; + google.protobuf.Int32Value repInt32 = 7 [(gogoproto.wktpointer) = true]; + google.protobuf.UInt32Value repUInt32 = 8 [(gogoproto.wktpointer) = true]; + google.protobuf.BoolValue repBool = 9 [(gogoproto.wktpointer) = true]; + google.protobuf.StringValue repString = 10 [(gogoproto.wktpointer) = true]; + google.protobuf.BytesValue repBytes = 11 [(gogoproto.wktpointer) = true]; } } diff --git a/types/wrappers_gogo.go b/types/wrappers_gogo.go new file mode 100644 index 0000000000..d905df3605 --- /dev/null +++ b/types/wrappers_gogo.go @@ -0,0 +1,300 @@ +// Protocol Buffers for Go with Gadgets +// +// Copyright (c) 2018, The GoGo Authors. All rights reserved. +// http://github.com/gogo/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +package types + +func NewPopulatedStdDouble(r randyWrappers, easy bool) *float64 { + v := NewPopulatedDoubleValue(r, easy) + return &v.Value +} + +func SizeOfStdDouble(v float64) int { + pv := &DoubleValue{Value: v} + return pv.Size() +} + +func StdDoubleMarshal(v float64) ([]byte, error) { + size := SizeOfStdDouble(v) + buf := make([]byte, size) + _, err := StdDoubleMarshalTo(v, buf) + return buf, err +} + +func StdDoubleMarshalTo(v float64, data []byte) (int, error) { + pv := &DoubleValue{Value: v} + return pv.MarshalTo(data) +} + +func StdDoubleUnmarshal(v *float64, data []byte) error { + pv := &DoubleValue{} + if err := pv.Unmarshal(data); err != nil { + return err + } + *v = pv.Value + return nil +} +func NewPopulatedStdFloat(r randyWrappers, easy bool) *float32 { + v := NewPopulatedFloatValue(r, easy) + return &v.Value +} + +func SizeOfStdFloat(v float32) int { + pv := &FloatValue{Value: v} + return pv.Size() +} + +func StdFloatMarshal(v float32) ([]byte, error) { + size := SizeOfStdFloat(v) + buf := make([]byte, size) + _, err := StdFloatMarshalTo(v, buf) + return buf, err +} + +func StdFloatMarshalTo(v float32, data []byte) (int, error) { + pv := &FloatValue{Value: v} + return pv.MarshalTo(data) +} + +func StdFloatUnmarshal(v *float32, data []byte) error { + pv := &FloatValue{} + if err := pv.Unmarshal(data); err != nil { + return err + } + *v = pv.Value + return nil +} +func NewPopulatedStdInt64(r randyWrappers, easy bool) *int64 { + v := NewPopulatedInt64Value(r, easy) + return &v.Value +} + +func SizeOfStdInt64(v int64) int { + pv := &Int64Value{Value: v} + return pv.Size() +} + +func StdInt64Marshal(v int64) ([]byte, error) { + size := SizeOfStdInt64(v) + buf := make([]byte, size) + _, err := StdInt64MarshalTo(v, buf) + return buf, err +} + +func StdInt64MarshalTo(v int64, data []byte) (int, error) { + pv := &Int64Value{Value: v} + return pv.MarshalTo(data) +} + +func StdInt64Unmarshal(v *int64, data []byte) error { + pv := &Int64Value{} + if err := pv.Unmarshal(data); err != nil { + return err + } + *v = pv.Value + return nil +} +func NewPopulatedStdUInt64(r randyWrappers, easy bool) *uint64 { + v := NewPopulatedUInt64Value(r, easy) + return &v.Value +} + +func SizeOfStdUInt64(v uint64) int { + pv := &UInt64Value{Value: v} + return pv.Size() +} + +func StdUInt64Marshal(v uint64) ([]byte, error) { + size := SizeOfStdUInt64(v) + buf := make([]byte, size) + _, err := StdUInt64MarshalTo(v, buf) + return buf, err +} + +func StdUInt64MarshalTo(v uint64, data []byte) (int, error) { + pv := &UInt64Value{Value: v} + return pv.MarshalTo(data) +} + +func StdUInt64Unmarshal(v *uint64, data []byte) error { + pv := &UInt64Value{} + if err := pv.Unmarshal(data); err != nil { + return err + } + *v = pv.Value + return nil +} +func NewPopulatedStdInt32(r randyWrappers, easy bool) *int32 { + v := NewPopulatedInt32Value(r, easy) + return &v.Value +} + +func SizeOfStdInt32(v int32) int { + pv := &Int32Value{Value: v} + return pv.Size() +} + +func StdInt32Marshal(v int32) ([]byte, error) { + size := SizeOfStdInt32(v) + buf := make([]byte, size) + _, err := StdInt32MarshalTo(v, buf) + return buf, err +} + +func StdInt32MarshalTo(v int32, data []byte) (int, error) { + pv := &Int32Value{Value: v} + return pv.MarshalTo(data) +} + +func StdInt32Unmarshal(v *int32, data []byte) error { + pv := &Int32Value{} + if err := pv.Unmarshal(data); err != nil { + return err + } + *v = pv.Value + return nil +} +func NewPopulatedStdUInt32(r randyWrappers, easy bool) *uint32 { + v := NewPopulatedUInt32Value(r, easy) + return &v.Value +} + +func SizeOfStdUInt32(v uint32) int { + pv := &UInt32Value{Value: v} + return pv.Size() +} + +func StdUInt32Marshal(v uint32) ([]byte, error) { + size := SizeOfStdUInt32(v) + buf := make([]byte, size) + _, err := StdUInt32MarshalTo(v, buf) + return buf, err +} + +func StdUInt32MarshalTo(v uint32, data []byte) (int, error) { + pv := &UInt32Value{Value: v} + return pv.MarshalTo(data) +} + +func StdUInt32Unmarshal(v *uint32, data []byte) error { + pv := &UInt32Value{} + if err := pv.Unmarshal(data); err != nil { + return err + } + *v = pv.Value + return nil +} +func NewPopulatedStdBool(r randyWrappers, easy bool) *bool { + v := NewPopulatedBoolValue(r, easy) + return &v.Value +} + +func SizeOfStdBool(v bool) int { + pv := &BoolValue{Value: v} + return pv.Size() +} + +func StdBoolMarshal(v bool) ([]byte, error) { + size := SizeOfStdBool(v) + buf := make([]byte, size) + _, err := StdBoolMarshalTo(v, buf) + return buf, err +} + +func StdBoolMarshalTo(v bool, data []byte) (int, error) { + pv := &BoolValue{Value: v} + return pv.MarshalTo(data) +} + +func StdBoolUnmarshal(v *bool, data []byte) error { + pv := &BoolValue{} + if err := pv.Unmarshal(data); err != nil { + return err + } + *v = pv.Value + return nil +} +func NewPopulatedStdString(r randyWrappers, easy bool) *string { + v := NewPopulatedStringValue(r, easy) + return &v.Value +} + +func SizeOfStdString(v string) int { + pv := &StringValue{Value: v} + return pv.Size() +} + +func StdStringMarshal(v string) ([]byte, error) { + size := SizeOfStdString(v) + buf := make([]byte, size) + _, err := StdStringMarshalTo(v, buf) + return buf, err +} + +func StdStringMarshalTo(v string, data []byte) (int, error) { + pv := &StringValue{Value: v} + return pv.MarshalTo(data) +} + +func StdStringUnmarshal(v *string, data []byte) error { + pv := &StringValue{} + if err := pv.Unmarshal(data); err != nil { + return err + } + *v = pv.Value + return nil +} +func NewPopulatedStdBytes(r randyWrappers, easy bool) *[]byte { + v := NewPopulatedBytesValue(r, easy) + return &v.Value +} + +func SizeOfStdBytes(v []byte) int { + pv := &BytesValue{Value: v} + return pv.Size() +} + +func StdBytesMarshal(v []byte) ([]byte, error) { + size := SizeOfStdBytes(v) + buf := make([]byte, size) + _, err := StdBytesMarshalTo(v, buf) + return buf, err +} + +func StdBytesMarshalTo(v []byte, data []byte) (int, error) { + pv := &BytesValue{Value: v} + return pv.MarshalTo(data) +} + +func StdBytesUnmarshal(v *[]byte, data []byte) error { + pv := &BytesValue{} + if err := pv.Unmarshal(data); err != nil { + return err + } + *v = pv.Value + return nil +}