diff --git a/examples/fastpb_gen/base.pb.fast.go b/examples/fastpb_gen/base.pb.fast.go index d9f51be..057d68c 100644 --- a/examples/fastpb_gen/base.pb.fast.go +++ b/examples/fastpb_gen/base.pb.fast.go @@ -172,7 +172,7 @@ func (x *Base) fastWriteField1(buf []byte) (offset int) { if x.LogID == "" { return offset } - offset += fastpb.WriteString(buf[offset:], 1, x.LogID) + offset += fastpb.WriteString(buf[offset:], 1, x.GetLogID()) return offset } @@ -180,7 +180,7 @@ func (x *Base) fastWriteField2(buf []byte) (offset int) { if x.Caller == "" { return offset } - offset += fastpb.WriteString(buf[offset:], 2, x.Caller) + offset += fastpb.WriteString(buf[offset:], 2, x.GetCaller()) return offset } @@ -188,7 +188,7 @@ func (x *Base) fastWriteField3(buf []byte) (offset int) { if x.Addr == "" { return offset } - offset += fastpb.WriteString(buf[offset:], 3, x.Addr) + offset += fastpb.WriteString(buf[offset:], 3, x.GetAddr()) return offset } @@ -196,7 +196,7 @@ func (x *Base) fastWriteField4(buf []byte) (offset int) { if x.Client == "" { return offset } - offset += fastpb.WriteString(buf[offset:], 4, x.Client) + offset += fastpb.WriteString(buf[offset:], 4, x.GetClient()) return offset } @@ -204,7 +204,7 @@ func (x *Base) fastWriteField6(buf []byte) (offset int) { if x.Extra == nil { return offset } - for k, v := range x.Extra { + for k, v := range x.GetExtra() { offset += fastpb.WriteMapEntry(buf[offset:], 6, func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 @@ -230,7 +230,7 @@ func (x *BaseResp) fastWriteField1(buf []byte) (offset int) { if x.StatusMessage == "" { return offset } - offset += fastpb.WriteString(buf[offset:], 1, x.StatusMessage) + offset += fastpb.WriteString(buf[offset:], 1, x.GetStatusMessage()) return offset } @@ -238,7 +238,7 @@ func (x *BaseResp) fastWriteField2(buf []byte) (offset int) { if x.StatusCode == 0 { return offset } - offset += fastpb.WriteInt32(buf[offset:], 2, x.StatusCode) + offset += fastpb.WriteInt32(buf[offset:], 2, x.GetStatusCode()) return offset } @@ -246,7 +246,7 @@ func (x *BaseResp) fastWriteField3(buf []byte) (offset int) { if x.Extra == nil { return offset } - for k, v := range x.Extra { + for k, v := range x.GetExtra() { offset += fastpb.WriteMapEntry(buf[offset:], 3, func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 @@ -274,7 +274,7 @@ func (x *Base) sizeField1() (n int) { if x.LogID == "" { return n } - n += fastpb.SizeString(1, x.LogID) + n += fastpb.SizeString(1, x.GetLogID()) return n } @@ -282,7 +282,7 @@ func (x *Base) sizeField2() (n int) { if x.Caller == "" { return n } - n += fastpb.SizeString(2, x.Caller) + n += fastpb.SizeString(2, x.GetCaller()) return n } @@ -290,7 +290,7 @@ func (x *Base) sizeField3() (n int) { if x.Addr == "" { return n } - n += fastpb.SizeString(3, x.Addr) + n += fastpb.SizeString(3, x.GetAddr()) return n } @@ -298,7 +298,7 @@ func (x *Base) sizeField4() (n int) { if x.Client == "" { return n } - n += fastpb.SizeString(4, x.Client) + n += fastpb.SizeString(4, x.GetClient()) return n } @@ -306,7 +306,7 @@ func (x *Base) sizeField6() (n int) { if x.Extra == nil { return n } - for k, v := range x.Extra { + for k, v := range x.GetExtra() { n += fastpb.SizeMapEntry(6, func(numTagOrKey, numIdxOrVal int32) int { n := 0 @@ -332,7 +332,7 @@ func (x *BaseResp) sizeField1() (n int) { if x.StatusMessage == "" { return n } - n += fastpb.SizeString(1, x.StatusMessage) + n += fastpb.SizeString(1, x.GetStatusMessage()) return n } @@ -340,7 +340,7 @@ func (x *BaseResp) sizeField2() (n int) { if x.StatusCode == 0 { return n } - n += fastpb.SizeInt32(2, x.StatusCode) + n += fastpb.SizeInt32(2, x.GetStatusCode()) return n } @@ -348,7 +348,7 @@ func (x *BaseResp) sizeField3() (n int) { if x.Extra == nil { return n } - for k, v := range x.Extra { + for k, v := range x.GetExtra() { n += fastpb.SizeMapEntry(3, func(numTagOrKey, numIdxOrVal int32) int { n := 0 diff --git a/examples/fastpb_gen/base.pb.go b/examples/fastpb_gen/base.pb.go index 6c5af2a..76ccbdb 100644 --- a/examples/fastpb_gen/base.pb.go +++ b/examples/fastpb_gen/base.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.0 -// protoc v3.21.3 +// protoc v3.21.12 // source: base.proto package fastpb_gen diff --git a/examples/fastpb_gen/echo.pb.fast.go b/examples/fastpb_gen/echo.pb.fast.go index 1d36d8c..163121d 100644 --- a/examples/fastpb_gen/echo.pb.fast.go +++ b/examples/fastpb_gen/echo.pb.fast.go @@ -1056,7 +1056,7 @@ func (x *Message) fastWriteField1(buf []byte) (offset int) { if x.Field1 == 0 { return offset } - offset += fastpb.WriteDouble(buf[offset:], 1, x.Field1) + offset += fastpb.WriteDouble(buf[offset:], 1, x.GetField1()) return offset } @@ -1064,7 +1064,7 @@ func (x *Message) fastWriteField2(buf []byte) (offset int) { if x.Field2 == 0 { return offset } - offset += fastpb.WriteFloat(buf[offset:], 2, x.Field2) + offset += fastpb.WriteFloat(buf[offset:], 2, x.GetField2()) return offset } @@ -1072,7 +1072,7 @@ func (x *Message) fastWriteField3(buf []byte) (offset int) { if x.Field3 == 0 { return offset } - offset += fastpb.WriteInt32(buf[offset:], 3, x.Field3) + offset += fastpb.WriteInt32(buf[offset:], 3, x.GetField3()) return offset } @@ -1080,7 +1080,7 @@ func (x *Message) fastWriteField4(buf []byte) (offset int) { if x.Field4 == 0 { return offset } - offset += fastpb.WriteInt64(buf[offset:], 4, x.Field4) + offset += fastpb.WriteInt64(buf[offset:], 4, x.GetField4()) return offset } @@ -1088,7 +1088,7 @@ func (x *Message) fastWriteField5(buf []byte) (offset int) { if x.Field5 == 0 { return offset } - offset += fastpb.WriteUint32(buf[offset:], 5, x.Field5) + offset += fastpb.WriteUint32(buf[offset:], 5, x.GetField5()) return offset } @@ -1096,7 +1096,7 @@ func (x *Message) fastWriteField6(buf []byte) (offset int) { if x.Field6 == 0 { return offset } - offset += fastpb.WriteUint64(buf[offset:], 6, x.Field6) + offset += fastpb.WriteUint64(buf[offset:], 6, x.GetField6()) return offset } @@ -1104,7 +1104,7 @@ func (x *Message) fastWriteField7(buf []byte) (offset int) { if x.Field7 == 0 { return offset } - offset += fastpb.WriteSint32(buf[offset:], 7, x.Field7) + offset += fastpb.WriteSint32(buf[offset:], 7, x.GetField7()) return offset } @@ -1112,7 +1112,7 @@ func (x *Message) fastWriteField8(buf []byte) (offset int) { if x.Field8 == 0 { return offset } - offset += fastpb.WriteSint64(buf[offset:], 8, x.Field8) + offset += fastpb.WriteSint64(buf[offset:], 8, x.GetField8()) return offset } @@ -1120,7 +1120,7 @@ func (x *Message) fastWriteField9(buf []byte) (offset int) { if x.Field9 == 0 { return offset } - offset += fastpb.WriteFixed32(buf[offset:], 9, x.Field9) + offset += fastpb.WriteFixed32(buf[offset:], 9, x.GetField9()) return offset } @@ -1128,7 +1128,7 @@ func (x *Message) fastWriteField10(buf []byte) (offset int) { if x.Field10 == 0 { return offset } - offset += fastpb.WriteFixed64(buf[offset:], 10, x.Field10) + offset += fastpb.WriteFixed64(buf[offset:], 10, x.GetField10()) return offset } @@ -1136,7 +1136,7 @@ func (x *Message) fastWriteField11(buf []byte) (offset int) { if x.Field11 == 0 { return offset } - offset += fastpb.WriteSfixed32(buf[offset:], 11, x.Field11) + offset += fastpb.WriteSfixed32(buf[offset:], 11, x.GetField11()) return offset } @@ -1144,7 +1144,7 @@ func (x *Message) fastWriteField12(buf []byte) (offset int) { if x.Field12 == 0 { return offset } - offset += fastpb.WriteSfixed64(buf[offset:], 12, x.Field12) + offset += fastpb.WriteSfixed64(buf[offset:], 12, x.GetField12()) return offset } @@ -1152,7 +1152,7 @@ func (x *Message) fastWriteField13(buf []byte) (offset int) { if !x.Field13 { return offset } - offset += fastpb.WriteBool(buf[offset:], 13, x.Field13) + offset += fastpb.WriteBool(buf[offset:], 13, x.GetField13()) return offset } @@ -1160,7 +1160,7 @@ func (x *Message) fastWriteField14(buf []byte) (offset int) { if x.Field14 == "" { return offset } - offset += fastpb.WriteString(buf[offset:], 14, x.Field14) + offset += fastpb.WriteString(buf[offset:], 14, x.GetField14()) return offset } @@ -1168,7 +1168,7 @@ func (x *Message) fastWriteField15(buf []byte) (offset int) { if len(x.Field15) == 0 { return offset } - offset += fastpb.WriteBytes(buf[offset:], 15, x.Field15) + offset += fastpb.WriteBytes(buf[offset:], 15, x.GetField15()) return offset } @@ -1176,7 +1176,7 @@ func (x *Message) fastWriteField16(buf []byte) (offset int) { if x.Field16 == nil { return offset } - offset += fastpb.WriteMessage(buf[offset:], 16, x.Field16) + offset += fastpb.WriteMessage(buf[offset:], 16, x.GetField16()) return offset } @@ -1184,8 +1184,8 @@ func (x *Message) fastWriteField20(buf []byte) (offset int) { if len(x.Field20) == 0 { return offset } - for i := range x.Field20 { - offset += fastpb.WriteString(buf[offset:], 20, x.Field20[i]) + for i := range x.GetField20() { + offset += fastpb.WriteString(buf[offset:], 20, x.GetField20()[i]) } return offset } @@ -1194,8 +1194,8 @@ func (x *Message) fastWriteField21(buf []byte) (offset int) { if x.Field21 == nil { return offset } - for i := range x.Field21 { - offset += fastpb.WriteMessage(buf[offset:], 21, x.Field21[i]) + for i := range x.GetField21() { + offset += fastpb.WriteMessage(buf[offset:], 21, x.GetField21()[i]) } return offset } @@ -1204,7 +1204,7 @@ func (x *Message) fastWriteField22(buf []byte) (offset int) { if x.Field22 == nil { return offset } - for k, v := range x.Field22 { + for k, v := range x.GetField22() { offset += fastpb.WriteMapEntry(buf[offset:], 22, func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 @@ -1220,7 +1220,7 @@ func (x *Message) fastWriteField23(buf []byte) (offset int) { if x.Field23 == nil { return offset } - for k, v := range x.Field23 { + for k, v := range x.GetField23() { offset += fastpb.WriteMapEntry(buf[offset:], 23, func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 @@ -1236,7 +1236,7 @@ func (x *Message) fastWriteField24(buf []byte) (offset int) { if x.Field24 == nil { return offset } - for k, v := range x.Field24 { + for k, v := range x.GetField24() { offset += fastpb.WriteMapEntry(buf[offset:], 24, func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 @@ -1252,7 +1252,7 @@ func (x *Message) fastWriteField27(buf []byte) (offset int) { if x.Field27 == 0 { return offset } - offset += fastpb.WriteInt32(buf[offset:], 27, int32(x.Field27)) + offset += fastpb.WriteInt32(buf[offset:], 27, int32(x.GetField27())) return offset } @@ -1260,10 +1260,10 @@ func (x *Message) fastWriteField28(buf []byte) (offset int) { if len(x.Field28) == 0 { return offset } - offset += fastpb.WriteListPacked(buf[offset:], 28, len(x.Field28), + offset += fastpb.WriteListPacked(buf[offset:], 28, len(x.GetField28()), func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 - offset += fastpb.WriteInt32(buf[offset:], numTagOrKey, int32(x.Field28[numIdxOrVal])) + offset += fastpb.WriteInt32(buf[offset:], numTagOrKey, int32(x.GetField28()[numIdxOrVal])) return offset }) return offset @@ -1273,7 +1273,7 @@ func (x *Message) fastWriteField29(buf []byte) (offset int) { if x.Field29 == nil { return offset } - for k, v := range x.Field29 { + for k, v := range x.GetField29() { offset += fastpb.WriteMapEntry(buf[offset:], 29, func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 @@ -1289,7 +1289,7 @@ func (x *Message) fastWriteField30(buf []byte) (offset int) { if x.Field30 == 0 { return offset } - offset += fastpb.WriteInt32(buf[offset:], 30, int32(x.Field30)) + offset += fastpb.WriteInt32(buf[offset:], 30, int32(x.GetField30())) return offset } @@ -1297,10 +1297,10 @@ func (x *Message) fastWriteField31(buf []byte) (offset int) { if len(x.Field31) == 0 { return offset } - offset += fastpb.WriteListPacked(buf[offset:], 31, len(x.Field31), + offset += fastpb.WriteListPacked(buf[offset:], 31, len(x.GetField31()), func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 - offset += fastpb.WriteInt32(buf[offset:], numTagOrKey, int32(x.Field31[numIdxOrVal])) + offset += fastpb.WriteInt32(buf[offset:], numTagOrKey, int32(x.GetField31()[numIdxOrVal])) return offset }) return offset @@ -1310,7 +1310,7 @@ func (x *Message) fastWriteField32(buf []byte) (offset int) { if x.Field32 == nil { return offset } - for k, v := range x.Field32 { + for k, v := range x.GetField32() { offset += fastpb.WriteMapEntry(buf[offset:], 32, func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 @@ -1326,7 +1326,7 @@ func (x *Message) fastWriteField33(buf []byte) (offset int) { if x.Field33 == 0 { return offset } - offset += fastpb.WriteInt32(buf[offset:], 33, int32(x.Field33)) + offset += fastpb.WriteInt32(buf[offset:], 33, int32(x.GetField33())) return offset } @@ -1334,10 +1334,10 @@ func (x *Message) fastWriteField34(buf []byte) (offset int) { if len(x.Field34) == 0 { return offset } - offset += fastpb.WriteListPacked(buf[offset:], 34, len(x.Field34), + offset += fastpb.WriteListPacked(buf[offset:], 34, len(x.GetField34()), func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 - offset += fastpb.WriteInt32(buf[offset:], numTagOrKey, int32(x.Field34[numIdxOrVal])) + offset += fastpb.WriteInt32(buf[offset:], numTagOrKey, int32(x.GetField34()[numIdxOrVal])) return offset }) return offset @@ -1347,7 +1347,7 @@ func (x *Message) fastWriteField35(buf []byte) (offset int) { if x.Field35 == nil { return offset } - for k, v := range x.Field35 { + for k, v := range x.GetField35() { offset += fastpb.WriteMapEntry(buf[offset:], 35, func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 @@ -1363,7 +1363,7 @@ func (x *Message) fastWriteField36(buf []byte) (offset int) { if x.Field36 == 0 { return offset } - offset += fastpb.WriteInt32(buf[offset:], 36, int32(x.Field36)) + offset += fastpb.WriteInt32(buf[offset:], 36, int32(x.GetField36())) return offset } @@ -1371,10 +1371,10 @@ func (x *Message) fastWriteField37(buf []byte) (offset int) { if len(x.Field37) == 0 { return offset } - offset += fastpb.WriteListPacked(buf[offset:], 37, len(x.Field37), + offset += fastpb.WriteListPacked(buf[offset:], 37, len(x.GetField37()), func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 - offset += fastpb.WriteInt32(buf[offset:], numTagOrKey, int32(x.Field37[numIdxOrVal])) + offset += fastpb.WriteInt32(buf[offset:], numTagOrKey, int32(x.GetField37()[numIdxOrVal])) return offset }) return offset @@ -1384,7 +1384,7 @@ func (x *Message) fastWriteField38(buf []byte) (offset int) { if x.Field38 == nil { return offset } - for k, v := range x.Field38 { + for k, v := range x.GetField38() { offset += fastpb.WriteMapEntry(buf[offset:], 38, func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 @@ -1440,7 +1440,7 @@ func (x *Message) fastWriteField50(buf []byte) (offset int) { if x.Field50 == nil { return offset } - offset += fastpb.WriteMessage(buf[offset:], 50, x.Field50) + offset += fastpb.WriteMessage(buf[offset:], 50, x.GetField50()) return offset } @@ -1448,7 +1448,7 @@ func (x *Message) fastWriteField51(buf []byte) (offset int) { if x.Field51 == nil { return offset } - offset += fastpb.WriteInt32(buf[offset:], 51, *x.Field51) + offset += fastpb.WriteInt32(buf[offset:], 51, x.GetField51()) return offset } @@ -1456,7 +1456,7 @@ func (x *Message) fastWriteField52(buf []byte) (offset int) { if x.Field52 == nil { return offset } - offset += fastpb.WriteInt64(buf[offset:], 52, *x.Field52) + offset += fastpb.WriteInt64(buf[offset:], 52, x.GetField52()) return offset } @@ -1464,7 +1464,7 @@ func (x *Message) fastWriteField53(buf []byte) (offset int) { if x.Field53 == nil { return offset } - offset += fastpb.WriteUint32(buf[offset:], 53, *x.Field53) + offset += fastpb.WriteUint32(buf[offset:], 53, x.GetField53()) return offset } @@ -1472,7 +1472,7 @@ func (x *Message) fastWriteField54(buf []byte) (offset int) { if x.Field54 == nil { return offset } - offset += fastpb.WriteUint64(buf[offset:], 54, *x.Field54) + offset += fastpb.WriteUint64(buf[offset:], 54, x.GetField54()) return offset } @@ -1480,7 +1480,7 @@ func (x *Message) fastWriteField55(buf []byte) (offset int) { if x.Field55 == nil { return offset } - offset += fastpb.WriteSint32(buf[offset:], 55, *x.Field55) + offset += fastpb.WriteSint32(buf[offset:], 55, x.GetField55()) return offset } @@ -1488,7 +1488,7 @@ func (x *Message) fastWriteField56(buf []byte) (offset int) { if x.Field56 == nil { return offset } - offset += fastpb.WriteSint64(buf[offset:], 56, *x.Field56) + offset += fastpb.WriteSint64(buf[offset:], 56, x.GetField56()) return offset } @@ -1496,7 +1496,7 @@ func (x *Message) fastWriteField57(buf []byte) (offset int) { if x.Field57 == nil { return offset } - offset += fastpb.WriteBool(buf[offset:], 57, *x.Field57) + offset += fastpb.WriteBool(buf[offset:], 57, x.GetField57()) return offset } @@ -1504,7 +1504,7 @@ func (x *Message) fastWriteField58(buf []byte) (offset int) { if x.Field58 == nil { return offset } - offset += fastpb.WriteString(buf[offset:], 58, *x.Field58) + offset += fastpb.WriteString(buf[offset:], 58, x.GetField58()) return offset } @@ -1512,7 +1512,7 @@ func (x *Message) fastWriteField59(buf []byte) (offset int) { if x.Field59 == nil { return offset } - offset += fastpb.WriteMessage(buf[offset:], 59, x.Field59) + offset += fastpb.WriteMessage(buf[offset:], 59, x.GetField59()) return offset } @@ -1530,7 +1530,7 @@ func (x *Request) fastWriteField1(buf []byte) (offset int) { if x.Message == nil { return offset } - offset += fastpb.WriteMessage(buf[offset:], 1, x.Message) + offset += fastpb.WriteMessage(buf[offset:], 1, x.GetMessage()) return offset } @@ -1538,7 +1538,7 @@ func (x *Request) fastWriteField2(buf []byte) (offset int) { if x.Req == nil { return offset } - offset += fastpb.WriteMessage(buf[offset:], 2, x.Req) + offset += fastpb.WriteMessage(buf[offset:], 2, x.GetReq()) return offset } @@ -1546,7 +1546,7 @@ func (x *Request) fastWriteField255(buf []byte) (offset int) { if x.Base == nil { return offset } - offset += fastpb.WriteMessage(buf[offset:], 255, x.Base) + offset += fastpb.WriteMessage(buf[offset:], 255, x.GetBase()) return offset } @@ -1564,7 +1564,7 @@ func (x *Response) fastWriteField1(buf []byte) (offset int) { if x.Action == "" { return offset } - offset += fastpb.WriteString(buf[offset:], 1, x.Action) + offset += fastpb.WriteString(buf[offset:], 1, x.GetAction()) return offset } @@ -1572,7 +1572,7 @@ func (x *Response) fastWriteField2(buf []byte) (offset int) { if x.Msg == "" { return offset } - offset += fastpb.WriteString(buf[offset:], 2, x.Msg) + offset += fastpb.WriteString(buf[offset:], 2, x.GetMsg()) return offset } @@ -1580,7 +1580,7 @@ func (x *Response) fastWriteField255(buf []byte) (offset int) { if x.BaseResp == nil { return offset } - offset += fastpb.WriteMessage(buf[offset:], 255, x.BaseResp) + offset += fastpb.WriteMessage(buf[offset:], 255, x.GetBaseResp()) return offset } @@ -1614,7 +1614,7 @@ func (x *Message_Condition) fastWriteField4(buf []byte) (offset int) { if !x.Field4 { return offset } - offset += fastpb.WriteBool(buf[offset:], 4, x.Field4) + offset += fastpb.WriteBool(buf[offset:], 4, x.GetField4()) return offset } @@ -1631,7 +1631,7 @@ func (x *Message_ConditionTree) fastWriteField1(buf []byte) (offset int) { if x.Field1 == nil { return offset } - for k, v := range x.Field1 { + for k, v := range x.GetField1() { offset += fastpb.WriteMapEntry(buf[offset:], 1, func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 @@ -1647,8 +1647,8 @@ func (x *Message_ConditionTree) fastWriteField2(buf []byte) (offset int) { if x.Field2 == nil { return offset } - for i := range x.Field2 { - offset += fastpb.WriteMessage(buf[offset:], 2, x.Field2[i]) + for i := range x.GetField2() { + offset += fastpb.WriteMessage(buf[offset:], 2, x.GetField2()[i]) } return offset } @@ -1712,7 +1712,7 @@ func (x *Message) sizeField1() (n int) { if x.Field1 == 0 { return n } - n += fastpb.SizeDouble(1, x.Field1) + n += fastpb.SizeDouble(1, x.GetField1()) return n } @@ -1720,7 +1720,7 @@ func (x *Message) sizeField2() (n int) { if x.Field2 == 0 { return n } - n += fastpb.SizeFloat(2, x.Field2) + n += fastpb.SizeFloat(2, x.GetField2()) return n } @@ -1728,7 +1728,7 @@ func (x *Message) sizeField3() (n int) { if x.Field3 == 0 { return n } - n += fastpb.SizeInt32(3, x.Field3) + n += fastpb.SizeInt32(3, x.GetField3()) return n } @@ -1736,7 +1736,7 @@ func (x *Message) sizeField4() (n int) { if x.Field4 == 0 { return n } - n += fastpb.SizeInt64(4, x.Field4) + n += fastpb.SizeInt64(4, x.GetField4()) return n } @@ -1744,7 +1744,7 @@ func (x *Message) sizeField5() (n int) { if x.Field5 == 0 { return n } - n += fastpb.SizeUint32(5, x.Field5) + n += fastpb.SizeUint32(5, x.GetField5()) return n } @@ -1752,7 +1752,7 @@ func (x *Message) sizeField6() (n int) { if x.Field6 == 0 { return n } - n += fastpb.SizeUint64(6, x.Field6) + n += fastpb.SizeUint64(6, x.GetField6()) return n } @@ -1760,7 +1760,7 @@ func (x *Message) sizeField7() (n int) { if x.Field7 == 0 { return n } - n += fastpb.SizeSint32(7, x.Field7) + n += fastpb.SizeSint32(7, x.GetField7()) return n } @@ -1768,7 +1768,7 @@ func (x *Message) sizeField8() (n int) { if x.Field8 == 0 { return n } - n += fastpb.SizeSint64(8, x.Field8) + n += fastpb.SizeSint64(8, x.GetField8()) return n } @@ -1776,7 +1776,7 @@ func (x *Message) sizeField9() (n int) { if x.Field9 == 0 { return n } - n += fastpb.SizeFixed32(9, x.Field9) + n += fastpb.SizeFixed32(9, x.GetField9()) return n } @@ -1784,7 +1784,7 @@ func (x *Message) sizeField10() (n int) { if x.Field10 == 0 { return n } - n += fastpb.SizeFixed64(10, x.Field10) + n += fastpb.SizeFixed64(10, x.GetField10()) return n } @@ -1792,7 +1792,7 @@ func (x *Message) sizeField11() (n int) { if x.Field11 == 0 { return n } - n += fastpb.SizeSfixed32(11, x.Field11) + n += fastpb.SizeSfixed32(11, x.GetField11()) return n } @@ -1800,7 +1800,7 @@ func (x *Message) sizeField12() (n int) { if x.Field12 == 0 { return n } - n += fastpb.SizeSfixed64(12, x.Field12) + n += fastpb.SizeSfixed64(12, x.GetField12()) return n } @@ -1808,7 +1808,7 @@ func (x *Message) sizeField13() (n int) { if !x.Field13 { return n } - n += fastpb.SizeBool(13, x.Field13) + n += fastpb.SizeBool(13, x.GetField13()) return n } @@ -1816,7 +1816,7 @@ func (x *Message) sizeField14() (n int) { if x.Field14 == "" { return n } - n += fastpb.SizeString(14, x.Field14) + n += fastpb.SizeString(14, x.GetField14()) return n } @@ -1824,7 +1824,7 @@ func (x *Message) sizeField15() (n int) { if len(x.Field15) == 0 { return n } - n += fastpb.SizeBytes(15, x.Field15) + n += fastpb.SizeBytes(15, x.GetField15()) return n } @@ -1832,7 +1832,7 @@ func (x *Message) sizeField16() (n int) { if x.Field16 == nil { return n } - n += fastpb.SizeMessage(16, x.Field16) + n += fastpb.SizeMessage(16, x.GetField16()) return n } @@ -1840,8 +1840,8 @@ func (x *Message) sizeField20() (n int) { if len(x.Field20) == 0 { return n } - for i := range x.Field20 { - n += fastpb.SizeString(20, x.Field20[i]) + for i := range x.GetField20() { + n += fastpb.SizeString(20, x.GetField20()[i]) } return n } @@ -1850,8 +1850,8 @@ func (x *Message) sizeField21() (n int) { if x.Field21 == nil { return n } - for i := range x.Field21 { - n += fastpb.SizeMessage(21, x.Field21[i]) + for i := range x.GetField21() { + n += fastpb.SizeMessage(21, x.GetField21()[i]) } return n } @@ -1860,7 +1860,7 @@ func (x *Message) sizeField22() (n int) { if x.Field22 == nil { return n } - for k, v := range x.Field22 { + for k, v := range x.GetField22() { n += fastpb.SizeMapEntry(22, func(numTagOrKey, numIdxOrVal int32) int { n := 0 @@ -1876,7 +1876,7 @@ func (x *Message) sizeField23() (n int) { if x.Field23 == nil { return n } - for k, v := range x.Field23 { + for k, v := range x.GetField23() { n += fastpb.SizeMapEntry(23, func(numTagOrKey, numIdxOrVal int32) int { n := 0 @@ -1892,7 +1892,7 @@ func (x *Message) sizeField24() (n int) { if x.Field24 == nil { return n } - for k, v := range x.Field24 { + for k, v := range x.GetField24() { n += fastpb.SizeMapEntry(24, func(numTagOrKey, numIdxOrVal int32) int { n := 0 @@ -1908,7 +1908,7 @@ func (x *Message) sizeField27() (n int) { if x.Field27 == 0 { return n } - n += fastpb.SizeInt32(27, int32(x.Field27)) + n += fastpb.SizeInt32(27, int32(x.GetField27())) return n } @@ -1916,10 +1916,10 @@ func (x *Message) sizeField28() (n int) { if len(x.Field28) == 0 { return n } - n += fastpb.SizeListPacked(28, len(x.Field28), + n += fastpb.SizeListPacked(28, len(x.GetField28()), func(numTagOrKey, numIdxOrVal int32) int { n := 0 - n += fastpb.SizeInt32(numTagOrKey, int32(x.Field28[numIdxOrVal])) + n += fastpb.SizeInt32(numTagOrKey, int32(x.GetField28()[numIdxOrVal])) return n }) return n @@ -1929,7 +1929,7 @@ func (x *Message) sizeField29() (n int) { if x.Field29 == nil { return n } - for k, v := range x.Field29 { + for k, v := range x.GetField29() { n += fastpb.SizeMapEntry(29, func(numTagOrKey, numIdxOrVal int32) int { n := 0 @@ -1945,7 +1945,7 @@ func (x *Message) sizeField30() (n int) { if x.Field30 == 0 { return n } - n += fastpb.SizeInt32(30, int32(x.Field30)) + n += fastpb.SizeInt32(30, int32(x.GetField30())) return n } @@ -1953,10 +1953,10 @@ func (x *Message) sizeField31() (n int) { if len(x.Field31) == 0 { return n } - n += fastpb.SizeListPacked(31, len(x.Field31), + n += fastpb.SizeListPacked(31, len(x.GetField31()), func(numTagOrKey, numIdxOrVal int32) int { n := 0 - n += fastpb.SizeInt32(numTagOrKey, int32(x.Field31[numIdxOrVal])) + n += fastpb.SizeInt32(numTagOrKey, int32(x.GetField31()[numIdxOrVal])) return n }) return n @@ -1966,7 +1966,7 @@ func (x *Message) sizeField32() (n int) { if x.Field32 == nil { return n } - for k, v := range x.Field32 { + for k, v := range x.GetField32() { n += fastpb.SizeMapEntry(32, func(numTagOrKey, numIdxOrVal int32) int { n := 0 @@ -1982,7 +1982,7 @@ func (x *Message) sizeField33() (n int) { if x.Field33 == 0 { return n } - n += fastpb.SizeInt32(33, int32(x.Field33)) + n += fastpb.SizeInt32(33, int32(x.GetField33())) return n } @@ -1990,10 +1990,10 @@ func (x *Message) sizeField34() (n int) { if len(x.Field34) == 0 { return n } - n += fastpb.SizeListPacked(34, len(x.Field34), + n += fastpb.SizeListPacked(34, len(x.GetField34()), func(numTagOrKey, numIdxOrVal int32) int { n := 0 - n += fastpb.SizeInt32(numTagOrKey, int32(x.Field34[numIdxOrVal])) + n += fastpb.SizeInt32(numTagOrKey, int32(x.GetField34()[numIdxOrVal])) return n }) return n @@ -2003,7 +2003,7 @@ func (x *Message) sizeField35() (n int) { if x.Field35 == nil { return n } - for k, v := range x.Field35 { + for k, v := range x.GetField35() { n += fastpb.SizeMapEntry(35, func(numTagOrKey, numIdxOrVal int32) int { n := 0 @@ -2019,7 +2019,7 @@ func (x *Message) sizeField36() (n int) { if x.Field36 == 0 { return n } - n += fastpb.SizeInt32(36, int32(x.Field36)) + n += fastpb.SizeInt32(36, int32(x.GetField36())) return n } @@ -2027,10 +2027,10 @@ func (x *Message) sizeField37() (n int) { if len(x.Field37) == 0 { return n } - n += fastpb.SizeListPacked(37, len(x.Field37), + n += fastpb.SizeListPacked(37, len(x.GetField37()), func(numTagOrKey, numIdxOrVal int32) int { n := 0 - n += fastpb.SizeInt32(numTagOrKey, int32(x.Field37[numIdxOrVal])) + n += fastpb.SizeInt32(numTagOrKey, int32(x.GetField37()[numIdxOrVal])) return n }) return n @@ -2040,7 +2040,7 @@ func (x *Message) sizeField38() (n int) { if x.Field38 == nil { return n } - for k, v := range x.Field38 { + for k, v := range x.GetField38() { n += fastpb.SizeMapEntry(38, func(numTagOrKey, numIdxOrVal int32) int { n := 0 @@ -2096,7 +2096,7 @@ func (x *Message) sizeField50() (n int) { if x.Field50 == nil { return n } - n += fastpb.SizeMessage(50, x.Field50) + n += fastpb.SizeMessage(50, x.GetField50()) return n } @@ -2104,7 +2104,7 @@ func (x *Message) sizeField51() (n int) { if x.Field51 == nil { return n } - n += fastpb.SizeInt32(51, *x.Field51) + n += fastpb.SizeInt32(51, x.GetField51()) return n } @@ -2112,7 +2112,7 @@ func (x *Message) sizeField52() (n int) { if x.Field52 == nil { return n } - n += fastpb.SizeInt64(52, *x.Field52) + n += fastpb.SizeInt64(52, x.GetField52()) return n } @@ -2120,7 +2120,7 @@ func (x *Message) sizeField53() (n int) { if x.Field53 == nil { return n } - n += fastpb.SizeUint32(53, *x.Field53) + n += fastpb.SizeUint32(53, x.GetField53()) return n } @@ -2128,7 +2128,7 @@ func (x *Message) sizeField54() (n int) { if x.Field54 == nil { return n } - n += fastpb.SizeUint64(54, *x.Field54) + n += fastpb.SizeUint64(54, x.GetField54()) return n } @@ -2136,7 +2136,7 @@ func (x *Message) sizeField55() (n int) { if x.Field55 == nil { return n } - n += fastpb.SizeSint32(55, *x.Field55) + n += fastpb.SizeSint32(55, x.GetField55()) return n } @@ -2144,7 +2144,7 @@ func (x *Message) sizeField56() (n int) { if x.Field56 == nil { return n } - n += fastpb.SizeSint64(56, *x.Field56) + n += fastpb.SizeSint64(56, x.GetField56()) return n } @@ -2152,7 +2152,7 @@ func (x *Message) sizeField57() (n int) { if x.Field57 == nil { return n } - n += fastpb.SizeBool(57, *x.Field57) + n += fastpb.SizeBool(57, x.GetField57()) return n } @@ -2160,7 +2160,7 @@ func (x *Message) sizeField58() (n int) { if x.Field58 == nil { return n } - n += fastpb.SizeString(58, *x.Field58) + n += fastpb.SizeString(58, x.GetField58()) return n } @@ -2168,7 +2168,7 @@ func (x *Message) sizeField59() (n int) { if x.Field59 == nil { return n } - n += fastpb.SizeMessage(59, x.Field59) + n += fastpb.SizeMessage(59, x.GetField59()) return n } @@ -2186,7 +2186,7 @@ func (x *Request) sizeField1() (n int) { if x.Message == nil { return n } - n += fastpb.SizeMessage(1, x.Message) + n += fastpb.SizeMessage(1, x.GetMessage()) return n } @@ -2194,7 +2194,7 @@ func (x *Request) sizeField2() (n int) { if x.Req == nil { return n } - n += fastpb.SizeMessage(2, x.Req) + n += fastpb.SizeMessage(2, x.GetReq()) return n } @@ -2202,7 +2202,7 @@ func (x *Request) sizeField255() (n int) { if x.Base == nil { return n } - n += fastpb.SizeMessage(255, x.Base) + n += fastpb.SizeMessage(255, x.GetBase()) return n } @@ -2220,7 +2220,7 @@ func (x *Response) sizeField1() (n int) { if x.Action == "" { return n } - n += fastpb.SizeString(1, x.Action) + n += fastpb.SizeString(1, x.GetAction()) return n } @@ -2228,7 +2228,7 @@ func (x *Response) sizeField2() (n int) { if x.Msg == "" { return n } - n += fastpb.SizeString(2, x.Msg) + n += fastpb.SizeString(2, x.GetMsg()) return n } @@ -2236,7 +2236,7 @@ func (x *Response) sizeField255() (n int) { if x.BaseResp == nil { return n } - n += fastpb.SizeMessage(255, x.BaseResp) + n += fastpb.SizeMessage(255, x.GetBaseResp()) return n } @@ -2270,7 +2270,7 @@ func (x *Message_Condition) sizeField4() (n int) { if !x.Field4 { return n } - n += fastpb.SizeBool(4, x.Field4) + n += fastpb.SizeBool(4, x.GetField4()) return n } @@ -2287,7 +2287,7 @@ func (x *Message_ConditionTree) sizeField1() (n int) { if x.Field1 == nil { return n } - for k, v := range x.Field1 { + for k, v := range x.GetField1() { n += fastpb.SizeMapEntry(1, func(numTagOrKey, numIdxOrVal int32) int { n := 0 @@ -2303,8 +2303,8 @@ func (x *Message_ConditionTree) sizeField2() (n int) { if x.Field2 == nil { return n } - for i := range x.Field2 { - n += fastpb.SizeMessage(2, x.Field2[i]) + for i := range x.GetField2() { + n += fastpb.SizeMessage(2, x.GetField2()[i]) } return n } diff --git a/examples/fastpb_gen/echo.pb.go b/examples/fastpb_gen/echo.pb.go index b0f22da..3d4d989 100644 --- a/examples/fastpb_gen/echo.pb.go +++ b/examples/fastpb_gen/echo.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.0 -// protoc v3.21.3 +// protoc v3.21.12 // source: echo.proto package fastpb_gen @@ -381,7 +381,7 @@ func (x *Message) GetField30() nested.MsgEnum { if x != nil { return x.Field30 } - return nested.MsgEnum_ENUM0 + return nested.MsgEnum(0) } func (x *Message) GetField31() []nested.MsgEnum { diff --git a/examples/fastpb_gen/mount/mount.pb.fast.go b/examples/fastpb_gen/mount/mount.pb.fast.go new file mode 100644 index 0000000..0f3dd52 --- /dev/null +++ b/examples/fastpb_gen/mount/mount.pb.fast.go @@ -0,0 +1,140 @@ +// Code generated by Fastpb v0.0.2. DO NOT EDIT. + +package mount + +import ( + fmt "fmt" + fastpb "github.com/cloudwego/fastpb" + player "github.com/cloudwego/fastpb/examples/fastpb_gen/user/player" +) + +var ( + _ = fmt.Errorf + _ = fastpb.Skip +) + +func (x *Mount) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 3: + offset, err = x.fastReadField3(buf, _type) + if err != nil { + goto ReadFieldError + } + case 4: + offset, err = x.fastReadField4(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_Mount[number], err) +} + +func (x *Mount) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.Name, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *Mount) fastReadField3(buf []byte, _type int8) (offset int, err error) { + x.Owner, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *Mount) fastReadField4(buf []byte, _type int8) (offset int, err error) { + var v int32 + v, offset, err = fastpb.ReadInt32(buf, _type) + if err != nil { + return offset, err + } + x.Kind = player.PlayerKind(v) + return offset, nil +} + +func (x *Mount) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField3(buf[offset:]) + offset += x.fastWriteField4(buf[offset:]) + return offset +} + +func (x *Mount) fastWriteField1(buf []byte) (offset int) { + if x.Name == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetName()) + return offset +} + +func (x *Mount) fastWriteField3(buf []byte) (offset int) { + if x.Owner == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 3, x.GetOwner()) + return offset +} + +func (x *Mount) fastWriteField4(buf []byte) (offset int) { + if x.Kind == 0 { + return offset + } + offset += fastpb.WriteInt32(buf[offset:], 4, int32(x.GetKind())) + return offset +} + +func (x *Mount) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField3() + n += x.sizeField4() + return n +} + +func (x *Mount) sizeField1() (n int) { + if x.Name == "" { + return n + } + n += fastpb.SizeString(1, x.GetName()) + return n +} + +func (x *Mount) sizeField3() (n int) { + if x.Owner == "" { + return n + } + n += fastpb.SizeString(3, x.GetOwner()) + return n +} + +func (x *Mount) sizeField4() (n int) { + if x.Kind == 0 { + return n + } + n += fastpb.SizeInt32(4, int32(x.GetKind())) + return n +} + +var fieldIDToName_Mount = map[int32]string{ + 1: "Name", + 3: "Owner", + 4: "Kind", +} + +var _ = player.File_user_player_player_proto diff --git a/examples/fastpb_gen/mount/mount.pb.go b/examples/fastpb_gen/mount/mount.pb.go new file mode 100644 index 0000000..583f060 --- /dev/null +++ b/examples/fastpb_gen/mount/mount.pb.go @@ -0,0 +1,169 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.21.12 +// source: mount/mount.proto + +package mount + +import ( + player "github.com/cloudwego/fastpb/examples/fastpb_gen/user/player" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Mount struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Owner string `protobuf:"bytes,3,opt,name=owner,proto3" json:"owner,omitempty"` + Kind player.PlayerKind `protobuf:"varint,4,opt,name=kind,proto3,enum=player.PlayerKind" json:"kind,omitempty"` +} + +func (x *Mount) Reset() { + *x = Mount{} + if protoimpl.UnsafeEnabled { + mi := &file_mount_mount_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Mount) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Mount) ProtoMessage() {} + +func (x *Mount) ProtoReflect() protoreflect.Message { + mi := &file_mount_mount_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Mount.ProtoReflect.Descriptor instead. +func (*Mount) Descriptor() ([]byte, []int) { + return file_mount_mount_proto_rawDescGZIP(), []int{0} +} + +func (x *Mount) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Mount) GetOwner() string { + if x != nil { + return x.Owner + } + return "" +} + +func (x *Mount) GetKind() player.PlayerKind { + if x != nil { + return x.Kind + } + return player.PlayerKind(0) +} + +var File_mount_mount_proto protoreflect.FileDescriptor + +var file_mount_mount_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x2f, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x1a, 0x18, 0x75, 0x73, 0x65, 0x72, + 0x2f, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x59, 0x0a, 0x05, 0x4d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x50, + 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4b, 0x69, 0x6e, 0x64, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x42, + 0x3d, 0x5a, 0x3b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6c, + 0x6f, 0x75, 0x64, 0x77, 0x65, 0x67, 0x6f, 0x2f, 0x66, 0x61, 0x73, 0x74, 0x70, 0x62, 0x2f, 0x65, + 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x66, 0x61, 0x73, 0x74, 0x70, 0x62, 0x5f, 0x67, + 0x65, 0x6e, 0x2f, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x3b, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_mount_mount_proto_rawDescOnce sync.Once + file_mount_mount_proto_rawDescData = file_mount_mount_proto_rawDesc +) + +func file_mount_mount_proto_rawDescGZIP() []byte { + file_mount_mount_proto_rawDescOnce.Do(func() { + file_mount_mount_proto_rawDescData = protoimpl.X.CompressGZIP(file_mount_mount_proto_rawDescData) + }) + return file_mount_mount_proto_rawDescData +} + +var file_mount_mount_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_mount_mount_proto_goTypes = []interface{}{ + (*Mount)(nil), // 0: mount.Mount + (player.PlayerKind)(0), // 1: player.PlayerKind +} +var file_mount_mount_proto_depIdxs = []int32{ + 1, // 0: mount.Mount.kind:type_name -> player.PlayerKind + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_mount_mount_proto_init() } +func file_mount_mount_proto_init() { + if File_mount_mount_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_mount_mount_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Mount); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_mount_mount_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_mount_mount_proto_goTypes, + DependencyIndexes: file_mount_mount_proto_depIdxs, + MessageInfos: file_mount_mount_proto_msgTypes, + }.Build() + File_mount_mount_proto = out.File + file_mount_mount_proto_rawDesc = nil + file_mount_mount_proto_goTypes = nil + file_mount_mount_proto_depIdxs = nil +} diff --git a/examples/fastpb_gen/nested/nested.pb.fast.go b/examples/fastpb_gen/nested/nested.pb.fast.go index 3e92d54..107563b 100644 --- a/examples/fastpb_gen/nested/nested.pb.fast.go +++ b/examples/fastpb_gen/nested/nested.pb.fast.go @@ -594,7 +594,7 @@ func (x *Message) fastWriteField1(buf []byte) (offset int) { if x.Field1 == 0 { return offset } - offset += fastpb.WriteDouble(buf[offset:], 1, x.Field1) + offset += fastpb.WriteDouble(buf[offset:], 1, x.GetField1()) return offset } @@ -602,7 +602,7 @@ func (x *Message) fastWriteField2(buf []byte) (offset int) { if x.Field2 == 0 { return offset } - offset += fastpb.WriteFloat(buf[offset:], 2, x.Field2) + offset += fastpb.WriteFloat(buf[offset:], 2, x.GetField2()) return offset } @@ -610,7 +610,7 @@ func (x *Message) fastWriteField3(buf []byte) (offset int) { if x.Field3 == 0 { return offset } - offset += fastpb.WriteInt32(buf[offset:], 3, x.Field3) + offset += fastpb.WriteInt32(buf[offset:], 3, x.GetField3()) return offset } @@ -618,7 +618,7 @@ func (x *Message) fastWriteField4(buf []byte) (offset int) { if x.Field4 == 0 { return offset } - offset += fastpb.WriteInt64(buf[offset:], 4, x.Field4) + offset += fastpb.WriteInt64(buf[offset:], 4, x.GetField4()) return offset } @@ -626,7 +626,7 @@ func (x *Message) fastWriteField5(buf []byte) (offset int) { if x.Field5 == 0 { return offset } - offset += fastpb.WriteUint32(buf[offset:], 5, x.Field5) + offset += fastpb.WriteUint32(buf[offset:], 5, x.GetField5()) return offset } @@ -634,7 +634,7 @@ func (x *Message) fastWriteField6(buf []byte) (offset int) { if x.Field6 == 0 { return offset } - offset += fastpb.WriteUint64(buf[offset:], 6, x.Field6) + offset += fastpb.WriteUint64(buf[offset:], 6, x.GetField6()) return offset } @@ -642,7 +642,7 @@ func (x *Message) fastWriteField7(buf []byte) (offset int) { if x.Field7 == 0 { return offset } - offset += fastpb.WriteSint32(buf[offset:], 7, x.Field7) + offset += fastpb.WriteSint32(buf[offset:], 7, x.GetField7()) return offset } @@ -650,7 +650,7 @@ func (x *Message) fastWriteField8(buf []byte) (offset int) { if x.Field8 == 0 { return offset } - offset += fastpb.WriteSint64(buf[offset:], 8, x.Field8) + offset += fastpb.WriteSint64(buf[offset:], 8, x.GetField8()) return offset } @@ -658,7 +658,7 @@ func (x *Message) fastWriteField9(buf []byte) (offset int) { if x.Field9 == 0 { return offset } - offset += fastpb.WriteFixed32(buf[offset:], 9, x.Field9) + offset += fastpb.WriteFixed32(buf[offset:], 9, x.GetField9()) return offset } @@ -666,7 +666,7 @@ func (x *Message) fastWriteField10(buf []byte) (offset int) { if x.Field10 == 0 { return offset } - offset += fastpb.WriteFixed64(buf[offset:], 10, x.Field10) + offset += fastpb.WriteFixed64(buf[offset:], 10, x.GetField10()) return offset } @@ -674,7 +674,7 @@ func (x *Message) fastWriteField11(buf []byte) (offset int) { if x.Field11 == 0 { return offset } - offset += fastpb.WriteSfixed32(buf[offset:], 11, x.Field11) + offset += fastpb.WriteSfixed32(buf[offset:], 11, x.GetField11()) return offset } @@ -682,7 +682,7 @@ func (x *Message) fastWriteField12(buf []byte) (offset int) { if x.Field12 == 0 { return offset } - offset += fastpb.WriteSfixed64(buf[offset:], 12, x.Field12) + offset += fastpb.WriteSfixed64(buf[offset:], 12, x.GetField12()) return offset } @@ -690,7 +690,7 @@ func (x *Message) fastWriteField13(buf []byte) (offset int) { if !x.Field13 { return offset } - offset += fastpb.WriteBool(buf[offset:], 13, x.Field13) + offset += fastpb.WriteBool(buf[offset:], 13, x.GetField13()) return offset } @@ -698,7 +698,7 @@ func (x *Message) fastWriteField14(buf []byte) (offset int) { if x.Field14 == "" { return offset } - offset += fastpb.WriteString(buf[offset:], 14, x.Field14) + offset += fastpb.WriteString(buf[offset:], 14, x.GetField14()) return offset } @@ -706,7 +706,7 @@ func (x *Message) fastWriteField15(buf []byte) (offset int) { if len(x.Field15) == 0 { return offset } - offset += fastpb.WriteBytes(buf[offset:], 15, x.Field15) + offset += fastpb.WriteBytes(buf[offset:], 15, x.GetField15()) return offset } @@ -714,7 +714,7 @@ func (x *Message) fastWriteField16(buf []byte) (offset int) { if x.Field16 == nil { return offset } - offset += fastpb.WriteMessage(buf[offset:], 16, x.Field16) + offset += fastpb.WriteMessage(buf[offset:], 16, x.GetField16()) return offset } @@ -722,8 +722,8 @@ func (x *Message) fastWriteField20(buf []byte) (offset int) { if len(x.Field20) == 0 { return offset } - for i := range x.Field20 { - offset += fastpb.WriteString(buf[offset:], 20, x.Field20[i]) + for i := range x.GetField20() { + offset += fastpb.WriteString(buf[offset:], 20, x.GetField20()[i]) } return offset } @@ -732,8 +732,8 @@ func (x *Message) fastWriteField21(buf []byte) (offset int) { if x.Field21 == nil { return offset } - for i := range x.Field21 { - offset += fastpb.WriteMessage(buf[offset:], 21, x.Field21[i]) + for i := range x.GetField21() { + offset += fastpb.WriteMessage(buf[offset:], 21, x.GetField21()[i]) } return offset } @@ -742,7 +742,7 @@ func (x *Message) fastWriteField22(buf []byte) (offset int) { if x.Field22 == nil { return offset } - for k, v := range x.Field22 { + for k, v := range x.GetField22() { offset += fastpb.WriteMapEntry(buf[offset:], 22, func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 @@ -758,7 +758,7 @@ func (x *Message) fastWriteField23(buf []byte) (offset int) { if x.Field23 == nil { return offset } - for k, v := range x.Field23 { + for k, v := range x.GetField23() { offset += fastpb.WriteMapEntry(buf[offset:], 23, func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 @@ -774,7 +774,7 @@ func (x *Message) fastWriteField33(buf []byte) (offset int) { if x.Field33 == 0 { return offset } - offset += fastpb.WriteInt32(buf[offset:], 33, int32(x.Field33)) + offset += fastpb.WriteInt32(buf[offset:], 33, int32(x.GetField33())) return offset } @@ -782,10 +782,10 @@ func (x *Message) fastWriteField34(buf []byte) (offset int) { if len(x.Field34) == 0 { return offset } - offset += fastpb.WriteListPacked(buf[offset:], 34, len(x.Field34), + offset += fastpb.WriteListPacked(buf[offset:], 34, len(x.GetField34()), func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 - offset += fastpb.WriteInt32(buf[offset:], numTagOrKey, int32(x.Field34[numIdxOrVal])) + offset += fastpb.WriteInt32(buf[offset:], numTagOrKey, int32(x.GetField34()[numIdxOrVal])) return offset }) return offset @@ -795,7 +795,7 @@ func (x *Message) fastWriteField35(buf []byte) (offset int) { if x.Field35 == nil { return offset } - for k, v := range x.Field35 { + for k, v := range x.GetField35() { offset += fastpb.WriteMapEntry(buf[offset:], 35, func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 @@ -811,7 +811,7 @@ func (x *Message) fastWriteField36(buf []byte) (offset int) { if x.Field36 == 0 { return offset } - offset += fastpb.WriteInt32(buf[offset:], 36, int32(x.Field36)) + offset += fastpb.WriteInt32(buf[offset:], 36, int32(x.GetField36())) return offset } @@ -819,10 +819,10 @@ func (x *Message) fastWriteField37(buf []byte) (offset int) { if len(x.Field37) == 0 { return offset } - offset += fastpb.WriteListPacked(buf[offset:], 37, len(x.Field37), + offset += fastpb.WriteListPacked(buf[offset:], 37, len(x.GetField37()), func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 - offset += fastpb.WriteInt32(buf[offset:], numTagOrKey, int32(x.Field37[numIdxOrVal])) + offset += fastpb.WriteInt32(buf[offset:], numTagOrKey, int32(x.GetField37()[numIdxOrVal])) return offset }) return offset @@ -832,7 +832,7 @@ func (x *Message) fastWriteField38(buf []byte) (offset int) { if x.Field38 == nil { return offset } - for k, v := range x.Field38 { + for k, v := range x.GetField38() { offset += fastpb.WriteMapEntry(buf[offset:], 38, func(buf []byte, numTagOrKey, numIdxOrVal int32) int { offset := 0 @@ -872,7 +872,7 @@ func (x *Message) fastWriteField50(buf []byte) (offset int) { if x.Field50 == nil { return offset } - offset += fastpb.WriteMessage(buf[offset:], 50, x.Field50) + offset += fastpb.WriteMessage(buf[offset:], 50, x.GetField50()) return offset } @@ -906,7 +906,7 @@ func (x *Message_Condition) fastWriteField4(buf []byte) (offset int) { if !x.Field4 { return offset } - offset += fastpb.WriteBool(buf[offset:], 4, x.Field4) + offset += fastpb.WriteBool(buf[offset:], 4, x.GetField4()) return offset } @@ -922,8 +922,8 @@ func (x *Message_ConditionTree) fastWriteField2(buf []byte) (offset int) { if x.Field2 == nil { return offset } - for i := range x.Field2 { - offset += fastpb.WriteMessage(buf[offset:], 2, x.Field2[i]) + for i := range x.GetField2() { + offset += fastpb.WriteMessage(buf[offset:], 2, x.GetField2()[i]) } return offset } @@ -969,7 +969,7 @@ func (x *Message) sizeField1() (n int) { if x.Field1 == 0 { return n } - n += fastpb.SizeDouble(1, x.Field1) + n += fastpb.SizeDouble(1, x.GetField1()) return n } @@ -977,7 +977,7 @@ func (x *Message) sizeField2() (n int) { if x.Field2 == 0 { return n } - n += fastpb.SizeFloat(2, x.Field2) + n += fastpb.SizeFloat(2, x.GetField2()) return n } @@ -985,7 +985,7 @@ func (x *Message) sizeField3() (n int) { if x.Field3 == 0 { return n } - n += fastpb.SizeInt32(3, x.Field3) + n += fastpb.SizeInt32(3, x.GetField3()) return n } @@ -993,7 +993,7 @@ func (x *Message) sizeField4() (n int) { if x.Field4 == 0 { return n } - n += fastpb.SizeInt64(4, x.Field4) + n += fastpb.SizeInt64(4, x.GetField4()) return n } @@ -1001,7 +1001,7 @@ func (x *Message) sizeField5() (n int) { if x.Field5 == 0 { return n } - n += fastpb.SizeUint32(5, x.Field5) + n += fastpb.SizeUint32(5, x.GetField5()) return n } @@ -1009,7 +1009,7 @@ func (x *Message) sizeField6() (n int) { if x.Field6 == 0 { return n } - n += fastpb.SizeUint64(6, x.Field6) + n += fastpb.SizeUint64(6, x.GetField6()) return n } @@ -1017,7 +1017,7 @@ func (x *Message) sizeField7() (n int) { if x.Field7 == 0 { return n } - n += fastpb.SizeSint32(7, x.Field7) + n += fastpb.SizeSint32(7, x.GetField7()) return n } @@ -1025,7 +1025,7 @@ func (x *Message) sizeField8() (n int) { if x.Field8 == 0 { return n } - n += fastpb.SizeSint64(8, x.Field8) + n += fastpb.SizeSint64(8, x.GetField8()) return n } @@ -1033,7 +1033,7 @@ func (x *Message) sizeField9() (n int) { if x.Field9 == 0 { return n } - n += fastpb.SizeFixed32(9, x.Field9) + n += fastpb.SizeFixed32(9, x.GetField9()) return n } @@ -1041,7 +1041,7 @@ func (x *Message) sizeField10() (n int) { if x.Field10 == 0 { return n } - n += fastpb.SizeFixed64(10, x.Field10) + n += fastpb.SizeFixed64(10, x.GetField10()) return n } @@ -1049,7 +1049,7 @@ func (x *Message) sizeField11() (n int) { if x.Field11 == 0 { return n } - n += fastpb.SizeSfixed32(11, x.Field11) + n += fastpb.SizeSfixed32(11, x.GetField11()) return n } @@ -1057,7 +1057,7 @@ func (x *Message) sizeField12() (n int) { if x.Field12 == 0 { return n } - n += fastpb.SizeSfixed64(12, x.Field12) + n += fastpb.SizeSfixed64(12, x.GetField12()) return n } @@ -1065,7 +1065,7 @@ func (x *Message) sizeField13() (n int) { if !x.Field13 { return n } - n += fastpb.SizeBool(13, x.Field13) + n += fastpb.SizeBool(13, x.GetField13()) return n } @@ -1073,7 +1073,7 @@ func (x *Message) sizeField14() (n int) { if x.Field14 == "" { return n } - n += fastpb.SizeString(14, x.Field14) + n += fastpb.SizeString(14, x.GetField14()) return n } @@ -1081,7 +1081,7 @@ func (x *Message) sizeField15() (n int) { if len(x.Field15) == 0 { return n } - n += fastpb.SizeBytes(15, x.Field15) + n += fastpb.SizeBytes(15, x.GetField15()) return n } @@ -1089,7 +1089,7 @@ func (x *Message) sizeField16() (n int) { if x.Field16 == nil { return n } - n += fastpb.SizeMessage(16, x.Field16) + n += fastpb.SizeMessage(16, x.GetField16()) return n } @@ -1097,8 +1097,8 @@ func (x *Message) sizeField20() (n int) { if len(x.Field20) == 0 { return n } - for i := range x.Field20 { - n += fastpb.SizeString(20, x.Field20[i]) + for i := range x.GetField20() { + n += fastpb.SizeString(20, x.GetField20()[i]) } return n } @@ -1107,8 +1107,8 @@ func (x *Message) sizeField21() (n int) { if x.Field21 == nil { return n } - for i := range x.Field21 { - n += fastpb.SizeMessage(21, x.Field21[i]) + for i := range x.GetField21() { + n += fastpb.SizeMessage(21, x.GetField21()[i]) } return n } @@ -1117,7 +1117,7 @@ func (x *Message) sizeField22() (n int) { if x.Field22 == nil { return n } - for k, v := range x.Field22 { + for k, v := range x.GetField22() { n += fastpb.SizeMapEntry(22, func(numTagOrKey, numIdxOrVal int32) int { n := 0 @@ -1133,7 +1133,7 @@ func (x *Message) sizeField23() (n int) { if x.Field23 == nil { return n } - for k, v := range x.Field23 { + for k, v := range x.GetField23() { n += fastpb.SizeMapEntry(23, func(numTagOrKey, numIdxOrVal int32) int { n := 0 @@ -1149,7 +1149,7 @@ func (x *Message) sizeField33() (n int) { if x.Field33 == 0 { return n } - n += fastpb.SizeInt32(33, int32(x.Field33)) + n += fastpb.SizeInt32(33, int32(x.GetField33())) return n } @@ -1157,10 +1157,10 @@ func (x *Message) sizeField34() (n int) { if len(x.Field34) == 0 { return n } - n += fastpb.SizeListPacked(34, len(x.Field34), + n += fastpb.SizeListPacked(34, len(x.GetField34()), func(numTagOrKey, numIdxOrVal int32) int { n := 0 - n += fastpb.SizeInt32(numTagOrKey, int32(x.Field34[numIdxOrVal])) + n += fastpb.SizeInt32(numTagOrKey, int32(x.GetField34()[numIdxOrVal])) return n }) return n @@ -1170,7 +1170,7 @@ func (x *Message) sizeField35() (n int) { if x.Field35 == nil { return n } - for k, v := range x.Field35 { + for k, v := range x.GetField35() { n += fastpb.SizeMapEntry(35, func(numTagOrKey, numIdxOrVal int32) int { n := 0 @@ -1186,7 +1186,7 @@ func (x *Message) sizeField36() (n int) { if x.Field36 == 0 { return n } - n += fastpb.SizeInt32(36, int32(x.Field36)) + n += fastpb.SizeInt32(36, int32(x.GetField36())) return n } @@ -1194,10 +1194,10 @@ func (x *Message) sizeField37() (n int) { if len(x.Field37) == 0 { return n } - n += fastpb.SizeListPacked(37, len(x.Field37), + n += fastpb.SizeListPacked(37, len(x.GetField37()), func(numTagOrKey, numIdxOrVal int32) int { n := 0 - n += fastpb.SizeInt32(numTagOrKey, int32(x.Field37[numIdxOrVal])) + n += fastpb.SizeInt32(numTagOrKey, int32(x.GetField37()[numIdxOrVal])) return n }) return n @@ -1207,7 +1207,7 @@ func (x *Message) sizeField38() (n int) { if x.Field38 == nil { return n } - for k, v := range x.Field38 { + for k, v := range x.GetField38() { n += fastpb.SizeMapEntry(38, func(numTagOrKey, numIdxOrVal int32) int { n := 0 @@ -1247,7 +1247,7 @@ func (x *Message) sizeField50() (n int) { if x.Field50 == nil { return n } - n += fastpb.SizeMessage(50, x.Field50) + n += fastpb.SizeMessage(50, x.GetField50()) return n } @@ -1281,7 +1281,7 @@ func (x *Message_Condition) sizeField4() (n int) { if !x.Field4 { return n } - n += fastpb.SizeBool(4, x.Field4) + n += fastpb.SizeBool(4, x.GetField4()) return n } @@ -1297,8 +1297,8 @@ func (x *Message_ConditionTree) sizeField2() (n int) { if x.Field2 == nil { return n } - for i := range x.Field2 { - n += fastpb.SizeMessage(2, x.Field2[i]) + for i := range x.GetField2() { + n += fastpb.SizeMessage(2, x.GetField2()[i]) } return n } diff --git a/examples/fastpb_gen/nested/nested.pb.go b/examples/fastpb_gen/nested/nested.pb.go index 91c25f4..03ae5b5 100644 --- a/examples/fastpb_gen/nested/nested.pb.go +++ b/examples/fastpb_gen/nested/nested.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 +// protoc-gen-go v1.28.0 // protoc v3.21.12 // source: nested.proto diff --git a/examples/fastpb_gen/pet/pet.pb.fast.go b/examples/fastpb_gen/pet/pet.pb.fast.go index 5d775f4..c6d1d15 100644 --- a/examples/fastpb_gen/pet/pet.pb.fast.go +++ b/examples/fastpb_gen/pet/pet.pb.fast.go @@ -88,7 +88,7 @@ func (x *Pet) fastWriteField1(buf []byte) (offset int) { if x.Name == "" { return offset } - offset += fastpb.WriteString(buf[offset:], 1, x.Name) + offset += fastpb.WriteString(buf[offset:], 1, x.GetName()) return offset } @@ -96,7 +96,7 @@ func (x *Pet) fastWriteField2(buf []byte) (offset int) { if x.Age == 0 { return offset } - offset += fastpb.WriteInt32(buf[offset:], 2, x.Age) + offset += fastpb.WriteInt32(buf[offset:], 2, x.GetAge()) return offset } @@ -104,7 +104,7 @@ func (x *Pet) fastWriteField3(buf []byte) (offset int) { if x.Owner == "" { return offset } - offset += fastpb.WriteString(buf[offset:], 3, x.Owner) + offset += fastpb.WriteString(buf[offset:], 3, x.GetOwner()) return offset } @@ -112,7 +112,7 @@ func (x *Pet) fastWriteField4(buf []byte) (offset int) { if x.Group == 0 { return offset } - offset += fastpb.WriteInt32(buf[offset:], 4, int32(x.Group)) + offset += fastpb.WriteInt32(buf[offset:], 4, int32(x.GetGroup())) return offset } @@ -131,7 +131,7 @@ func (x *Pet) sizeField1() (n int) { if x.Name == "" { return n } - n += fastpb.SizeString(1, x.Name) + n += fastpb.SizeString(1, x.GetName()) return n } @@ -139,7 +139,7 @@ func (x *Pet) sizeField2() (n int) { if x.Age == 0 { return n } - n += fastpb.SizeInt32(2, x.Age) + n += fastpb.SizeInt32(2, x.GetAge()) return n } @@ -147,7 +147,7 @@ func (x *Pet) sizeField3() (n int) { if x.Owner == "" { return n } - n += fastpb.SizeString(3, x.Owner) + n += fastpb.SizeString(3, x.GetOwner()) return n } @@ -155,7 +155,7 @@ func (x *Pet) sizeField4() (n int) { if x.Group == 0 { return n } - n += fastpb.SizeInt32(4, int32(x.Group)) + n += fastpb.SizeInt32(4, int32(x.GetGroup())) return n } diff --git a/examples/fastpb_gen/pet/pet.pb.go b/examples/fastpb_gen/pet/pet.pb.go index bd55bf4..dc57da4 100644 --- a/examples/fastpb_gen/pet/pet.pb.go +++ b/examples/fastpb_gen/pet/pet.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.0 -// protoc v3.21.1 +// protoc v3.21.12 // source: pet/pet.proto package pet diff --git a/examples/fastpb_gen/user/player/player.pb.fast.go b/examples/fastpb_gen/user/player/player.pb.fast.go new file mode 100644 index 0000000..73da21c --- /dev/null +++ b/examples/fastpb_gen/user/player/player.pb.fast.go @@ -0,0 +1,195 @@ +// Code generated by Fastpb v0.0.2. DO NOT EDIT. + +package playercustom + +import ( + fmt "fmt" + fastpb "github.com/cloudwego/fastpb" +) + +var ( + _ = fmt.Errorf + _ = fastpb.Skip +) + +func (x *Player) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 2: + offset, err = x.fastReadField2(buf, _type) + if err != nil { + goto ReadFieldError + } + case 3: + offset, err = x.fastReadField3(buf, _type) + if err != nil { + goto ReadFieldError + } + case 4: + offset, err = x.fastReadField4(buf, _type) + if err != nil { + goto ReadFieldError + } + case 5: + offset, err = x.fastReadField5(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_Player[number], err) +} + +func (x *Player) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.Id, offset, err = fastpb.ReadInt32(buf, _type) + return offset, err +} + +func (x *Player) fastReadField2(buf []byte, _type int8) (offset int, err error) { + x.Name, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *Player) fastReadField3(buf []byte, _type int8) (offset int, err error) { + var v int32 + v, offset, err = fastpb.ReadInt32(buf, _type) + if err != nil { + return offset, err + } + x.Kind = PlayerKind(v) + return offset, nil +} + +func (x *Player) fastReadField4(buf []byte, _type int8) (offset int, err error) { + x.Level, offset, err = fastpb.ReadInt32(buf, _type) + return offset, err +} + +func (x *Player) fastReadField5(buf []byte, _type int8) (offset int, err error) { + x.Exp, offset, err = fastpb.ReadInt32(buf, _type) + return offset, err +} + +func (x *Player) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField2(buf[offset:]) + offset += x.fastWriteField3(buf[offset:]) + offset += x.fastWriteField4(buf[offset:]) + offset += x.fastWriteField5(buf[offset:]) + return offset +} + +func (x *Player) fastWriteField1(buf []byte) (offset int) { + if x.Id == 0 { + return offset + } + offset += fastpb.WriteInt32(buf[offset:], 1, x.GetId()) + return offset +} + +func (x *Player) fastWriteField2(buf []byte) (offset int) { + if x.Name == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 2, x.GetName()) + return offset +} + +func (x *Player) fastWriteField3(buf []byte) (offset int) { + if x.Kind == 0 { + return offset + } + offset += fastpb.WriteInt32(buf[offset:], 3, int32(x.GetKind())) + return offset +} + +func (x *Player) fastWriteField4(buf []byte) (offset int) { + if x.Level == 0 { + return offset + } + offset += fastpb.WriteInt32(buf[offset:], 4, x.GetLevel()) + return offset +} + +func (x *Player) fastWriteField5(buf []byte) (offset int) { + if x.Exp == 0 { + return offset + } + offset += fastpb.WriteInt32(buf[offset:], 5, x.GetExp()) + return offset +} + +func (x *Player) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField2() + n += x.sizeField3() + n += x.sizeField4() + n += x.sizeField5() + return n +} + +func (x *Player) sizeField1() (n int) { + if x.Id == 0 { + return n + } + n += fastpb.SizeInt32(1, x.GetId()) + return n +} + +func (x *Player) sizeField2() (n int) { + if x.Name == "" { + return n + } + n += fastpb.SizeString(2, x.GetName()) + return n +} + +func (x *Player) sizeField3() (n int) { + if x.Kind == 0 { + return n + } + n += fastpb.SizeInt32(3, int32(x.GetKind())) + return n +} + +func (x *Player) sizeField4() (n int) { + if x.Level == 0 { + return n + } + n += fastpb.SizeInt32(4, x.GetLevel()) + return n +} + +func (x *Player) sizeField5() (n int) { + if x.Exp == 0 { + return n + } + n += fastpb.SizeInt32(5, x.GetExp()) + return n +} + +var fieldIDToName_Player = map[int32]string{ + 1: "Id", + 2: "Name", + 3: "Kind", + 4: "Level", + 5: "Exp", +} diff --git a/examples/fastpb_gen/user/player/player.pb.go b/examples/fastpb_gen/user/player/player.pb.go new file mode 100644 index 0000000..dee5d9b --- /dev/null +++ b/examples/fastpb_gen/user/player/player.pb.go @@ -0,0 +1,240 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.21.12 +// source: user/player/player.proto + +package playercustom + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type PlayerKind int32 + +const ( + PlayerKind_STRENGTH PlayerKind = 0 + PlayerKind_AGILITY PlayerKind = 1 + PlayerKind_INTELLECTUAL PlayerKind = 2 +) + +// Enum value maps for PlayerKind. +var ( + PlayerKind_name = map[int32]string{ + 0: "STRENGTH", + 1: "AGILITY", + 2: "INTELLECTUAL", + } + PlayerKind_value = map[string]int32{ + "STRENGTH": 0, + "AGILITY": 1, + "INTELLECTUAL": 2, + } +) + +func (x PlayerKind) Enum() *PlayerKind { + p := new(PlayerKind) + *p = x + return p +} + +func (x PlayerKind) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (PlayerKind) Descriptor() protoreflect.EnumDescriptor { + return file_user_player_player_proto_enumTypes[0].Descriptor() +} + +func (PlayerKind) Type() protoreflect.EnumType { + return &file_user_player_player_proto_enumTypes[0] +} + +func (x PlayerKind) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use PlayerKind.Descriptor instead. +func (PlayerKind) EnumDescriptor() ([]byte, []int) { + return file_user_player_player_proto_rawDescGZIP(), []int{0} +} + +type Player struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Kind PlayerKind `protobuf:"varint,3,opt,name=kind,proto3,enum=player.PlayerKind" json:"kind,omitempty"` + Level int32 `protobuf:"varint,4,opt,name=level,proto3" json:"level,omitempty"` + Exp int32 `protobuf:"varint,5,opt,name=exp,proto3" json:"exp,omitempty"` +} + +func (x *Player) Reset() { + *x = Player{} + if protoimpl.UnsafeEnabled { + mi := &file_user_player_player_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Player) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Player) ProtoMessage() {} + +func (x *Player) ProtoReflect() protoreflect.Message { + mi := &file_user_player_player_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Player.ProtoReflect.Descriptor instead. +func (*Player) Descriptor() ([]byte, []int) { + return file_user_player_player_proto_rawDescGZIP(), []int{0} +} + +func (x *Player) GetId() int32 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Player) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Player) GetKind() PlayerKind { + if x != nil { + return x.Kind + } + return PlayerKind_STRENGTH +} + +func (x *Player) GetLevel() int32 { + if x != nil { + return x.Level + } + return 0 +} + +func (x *Player) GetExp() int32 { + if x != nil { + return x.Exp + } + return 0 +} + +var File_user_player_player_proto protoreflect.FileDescriptor + +var file_user_player_player_proto_rawDesc = []byte{ + 0x0a, 0x18, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2f, 0x70, 0x6c, + 0x61, 0x79, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x70, 0x6c, 0x61, 0x79, + 0x65, 0x72, 0x22, 0x7c, 0x0a, 0x06, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x26, 0x0a, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, + 0x2e, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x2e, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4b, 0x69, + 0x6e, 0x64, 0x52, 0x04, 0x6b, 0x69, 0x6e, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, + 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x10, + 0x0a, 0x03, 0x65, 0x78, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x65, 0x78, 0x70, + 0x2a, 0x39, 0x0a, 0x0a, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x0c, + 0x0a, 0x08, 0x53, 0x54, 0x52, 0x45, 0x4e, 0x47, 0x54, 0x48, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, + 0x41, 0x47, 0x49, 0x4c, 0x49, 0x54, 0x59, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x49, 0x4e, 0x54, + 0x45, 0x4c, 0x4c, 0x45, 0x43, 0x54, 0x55, 0x41, 0x4c, 0x10, 0x02, 0x42, 0x4a, 0x5a, 0x48, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x77, + 0x65, 0x67, 0x6f, 0x2f, 0x66, 0x61, 0x73, 0x74, 0x70, 0x62, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x73, 0x2f, 0x66, 0x61, 0x73, 0x74, 0x70, 0x62, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x75, + 0x73, 0x65, 0x72, 0x2f, 0x70, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x3b, 0x70, 0x6c, 0x61, 0x79, 0x65, + 0x72, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_user_player_player_proto_rawDescOnce sync.Once + file_user_player_player_proto_rawDescData = file_user_player_player_proto_rawDesc +) + +func file_user_player_player_proto_rawDescGZIP() []byte { + file_user_player_player_proto_rawDescOnce.Do(func() { + file_user_player_player_proto_rawDescData = protoimpl.X.CompressGZIP(file_user_player_player_proto_rawDescData) + }) + return file_user_player_player_proto_rawDescData +} + +var file_user_player_player_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_user_player_player_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_user_player_player_proto_goTypes = []interface{}{ + (PlayerKind)(0), // 0: player.PlayerKind + (*Player)(nil), // 1: player.Player +} +var file_user_player_player_proto_depIdxs = []int32{ + 0, // 0: player.Player.kind:type_name -> player.PlayerKind + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_user_player_player_proto_init() } +func file_user_player_player_proto_init() { + if File_user_player_player_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_user_player_player_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Player); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_user_player_player_proto_rawDesc, + NumEnums: 1, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_user_player_player_proto_goTypes, + DependencyIndexes: file_user_player_player_proto_depIdxs, + EnumInfos: file_user_player_player_proto_enumTypes, + MessageInfos: file_user_player_player_proto_msgTypes, + }.Build() + File_user_player_player_proto = out.File + file_user_player_player_proto_rawDesc = nil + file_user_player_player_proto_goTypes = nil + file_user_player_player_proto_depIdxs = nil +} diff --git a/examples/fastpb_gen/user/user.pb.fast.go b/examples/fastpb_gen/user/user.pb.fast.go index b391262..0fce45d 100644 --- a/examples/fastpb_gen/user/user.pb.fast.go +++ b/examples/fastpb_gen/user/user.pb.fast.go @@ -60,7 +60,7 @@ func (x *User) fastWriteField1(buf []byte) (offset int) { if x.Id == 0 { return offset } - offset += fastpb.WriteInt32(buf[offset:], 1, x.Id) + offset += fastpb.WriteInt32(buf[offset:], 1, x.GetId()) return offset } @@ -68,7 +68,7 @@ func (x *User) fastWriteField2(buf []byte) (offset int) { if x.Name == "" { return offset } - offset += fastpb.WriteString(buf[offset:], 2, x.Name) + offset += fastpb.WriteString(buf[offset:], 2, x.GetName()) return offset } @@ -85,7 +85,7 @@ func (x *User) sizeField1() (n int) { if x.Id == 0 { return n } - n += fastpb.SizeInt32(1, x.Id) + n += fastpb.SizeInt32(1, x.GetId()) return n } @@ -93,7 +93,7 @@ func (x *User) sizeField2() (n int) { if x.Name == "" { return n } - n += fastpb.SizeString(2, x.Name) + n += fastpb.SizeString(2, x.GetName()) return n } diff --git a/examples/fastpb_gen/user/user.pb.go b/examples/fastpb_gen/user/user.pb.go index a7f3821..3e20ab0 100644 --- a/examples/fastpb_gen/user/user.pb.go +++ b/examples/fastpb_gen/user/user.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.0 -// protoc v3.21.1 +// protoc v3.21.12 // source: user/user.proto package user diff --git a/examples/gen_code.bat b/examples/gen_code.bat index d42ff8e..afabcd8 100644 --- a/examples/gen_code.bat +++ b/examples/gen_code.bat @@ -1,4 +1,7 @@ protoc --go_opt=paths=source_relative --go_out=./fastpb_gen --fastpb_opt=paths=source_relative --fastpb_out=./fastpb_gen -I ./idl/ user/user.proto -protoc --go_opt=paths=source_relative --go_out=./fastpb_gen --fastpb_opt=paths=source_relative --fastpb_out=./fastpb_gen -I ./idl/ pet/pet.proto \ No newline at end of file +protoc --go_opt=paths=source_relative --go_out=./fastpb_gen --fastpb_opt=paths=source_relative --fastpb_out=./fastpb_gen -I ./idl/ pet/pet.proto + +protoc --go_opt=paths=source_relative --go_out=./fastpb_gen --fastpb_opt=paths=source_relative --fastpb_out=./fastpb_gen -I ./idl/ user/player/player.proto +protoc --go_opt=paths=source_relative --go_out=./fastpb_gen --fastpb_opt=paths=source_relative --fastpb_out=./fastpb_gen -I ./idl/ mount/mount.proto \ No newline at end of file diff --git a/examples/gen_code.sh b/examples/gen_code.sh index ba8f86d..a199a41 100755 --- a/examples/gen_code.sh +++ b/examples/gen_code.sh @@ -33,3 +33,6 @@ protoc --go_opt=paths=source_relative --go_out=./fastpb_gen/nested --fastpb_opt= protoc --go_opt=paths=source_relative --go_out=./fastpb_gen --fastpb_opt=paths=source_relative --fastpb_out=./fastpb_gen -I ./idl/ user/user.proto protoc --go_opt=paths=source_relative --go_out=./fastpb_gen --fastpb_opt=paths=source_relative --fastpb_out=./fastpb_gen -I ./idl/ pet/pet.proto + +protoc --go_opt=paths=source_relative --go_out=./fastpb_gen --fastpb_opt=paths=source_relative --fastpb_out=./fastpb_gen -I ./idl/ user/player/player.proto +protoc --go_opt=paths=source_relative --go_out=./fastpb_gen --fastpb_opt=paths=source_relative --fastpb_out=./fastpb_gen -I ./idl/ mount/mount.proto diff --git a/examples/idl/mount/mount.proto b/examples/idl/mount/mount.proto new file mode 100644 index 0000000..8955121 --- /dev/null +++ b/examples/idl/mount/mount.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package mount; +option go_package = "github.com/cloudwego/fastpb/examples/fastpb_gen/mount;mount"; + +import "user/player/player.proto"; +message Mount { + string name = 1; + string owner = 3; + player.PlayerKind kind = 4; +} \ No newline at end of file diff --git a/examples/idl/user/player/player.proto b/examples/idl/user/player/player.proto new file mode 100644 index 0000000..4b7e610 --- /dev/null +++ b/examples/idl/user/player/player.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; +package player; +option go_package = "github.com/cloudwego/fastpb/examples/fastpb_gen/user/player;playercustom"; + +message Player { + int32 id = 1; + string name = 2; + PlayerKind kind = 3; + int32 level = 4; + int32 exp = 5; +} + +enum PlayerKind { + STRENGTH = 0; + AGILITY = 1; + INTELLECTUAL = 2; +} \ No newline at end of file diff --git a/protoc-gen-fastpb/generator/generator.go b/protoc-gen-fastpb/generator/generator.go index 365d269..2040e71 100644 --- a/protoc-gen-fastpb/generator/generator.go +++ b/protoc-gen-fastpb/generator/generator.go @@ -161,12 +161,24 @@ func (fg *fastgen) newFieldBody(f *protogen.Field, desc protoreflect.FieldDescri // *struct b := &bodyMessage{} // FIXME: Any is unsupported. - b.TypeName = "*" + parseTypeName(desc.Message(), fg.f.Proto) + typeName := parseTypeName(desc.Message(), fg.f.Proto) + names := strings.Split(typeName, ";") + if len(names) > 1 { + b.TypeName = "*" + names[0] + filepath.Ext(names[1]) + } else { + b.TypeName = "*" + typeName + } return b case protoreflect.EnumKind: // Enum b := &bodyEnum{} - b.TypeName = parseTypeName(desc.Enum(), fg.f.Proto) + typeName := parseTypeName(desc.Enum(), fg.f.Proto) + names := strings.Split(typeName, ";") + if len(names) > 1 { + b.TypeName = names[0] + filepath.Ext(names[1]) + } else { + b.TypeName = typeName + } b.IsOptional = isPointer return b default: