Skip to content

Commit 586ed73

Browse files
iahsmeta-codesync[bot]
authored andcommitted
Migrate deprecated_terse_writes from thrift_cpp2_options to field-level @cpp.DeprecatedTerseWrite
Summary: X-link: facebookresearch/DCPerf#538 The `deprecated_terse_writes` option in `thrift_cpp2_options` applies globally to all fields. This diff migrates the behavior to per-field `cpp.DeprecatedTerseWrite` structured annotations, which is the preferred approach. Changes to the carbon compiler (`cppgen.py` and `targets.py`): - Add `cpp.DeprecatedTerseWrite` annotation to each non-optional, non-structured-type field in generated `.thrift` files - Remove `deprecated_terse_writes` from `thrift_cpp2_options` in generated `BUCK` files - Skip the annotation for structured types (structs, unions, exceptions) since `cpp.DeprecatedTerseWrite` is not supported on them All 28 IDL files regenerated. Reviewed By: vitaut Differential Revision: D97542094 fbshipit-source-id: fd0684d2f9ca69e793ed2ef9628e070ec7e15a14
1 parent 46fea1f commit 586ed73

File tree

8 files changed

+334
-0
lines changed

8 files changed

+334
-0
lines changed

mcrouter/lib/carbon/example/gen/HelloGoodbye.thrift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,21 @@ enum EnumUInt32 {
3636
},
3737
}
3838
struct HelloRequest {
39+
@cpp.DeprecatedTerseWrite
3940
1: carbon.IOBufKey key
41+
@cpp.DeprecatedTerseWrite
4042
2: carbon.ui64 shardId
43+
@cpp.DeprecatedTerseWrite
4144
3: carbon.ui64 deadlineMs
45+
@cpp.DeprecatedTerseWrite
4246
4: string message
47+
@cpp.DeprecatedTerseWrite
4348
5: EnumUInt32 priority
49+
@cpp.DeprecatedTerseWrite
4450
6: carbon.ui64 beforeLatencyUs
51+
@cpp.DeprecatedTerseWrite
4552
7: carbon.ui64 afterLatencyUs
53+
@cpp.DeprecatedTerseWrite
4654
8: carbon.ui32 clientVersion
4755
}
4856
@thrift.DeprecatedUnvalidatedAnnotations{
@@ -51,7 +59,9 @@ struct HelloRequest {
5159
},
5260
}
5361
struct HelloReply {
62+
@cpp.DeprecatedTerseWrite
5463
1: carbon_result.Result result
64+
@cpp.DeprecatedTerseWrite
5565
2: string message
5666
}
5767
@thrift.DeprecatedUnvalidatedAnnotations{
@@ -60,7 +70,9 @@ struct HelloReply {
6070
},
6171
}
6272
struct GoodbyeRequest {
73+
@cpp.DeprecatedTerseWrite
6374
1: carbon.IOBufKey key
75+
@cpp.DeprecatedTerseWrite
6476
2: carbon.ui64 shardId
6577
}
6678
@thrift.DeprecatedUnvalidatedAnnotations{
@@ -69,7 +81,9 @@ struct GoodbyeRequest {
6981
},
7082
}
7183
struct GoodbyeReply {
84+
@cpp.DeprecatedTerseWrite
7285
1: carbon_result.Result result
86+
@cpp.DeprecatedTerseWrite
7387
2: string message
7488
}
7589

mcrouter/lib/carbon/test/gen/A.thrift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ namespace py3 carbon.test.A.thrift
3030
},
3131
}
3232
struct TestARequest {
33+
@cpp.DeprecatedTerseWrite
3334
1: carbon.IOBufKey key
35+
@cpp.DeprecatedTerseWrite
3436
2: bool dummy2
3537
}
3638
@thrift.DeprecatedUnvalidatedAnnotations{
@@ -39,7 +41,9 @@ struct TestARequest {
3941
},
4042
}
4143
struct TestAReply {
44+
@cpp.DeprecatedTerseWrite
4245
1: carbon_result.Result result
46+
@cpp.DeprecatedTerseWrite
4347
2: i32 valInt32
4448
}
4549

mcrouter/lib/carbon/test/gen/B.thrift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ namespace py3 carbon.test.B.thrift
2929
},
3030
}
3131
struct TestBRequest {
32+
@cpp.DeprecatedTerseWrite
3233
1: carbon.IOBufKey key
34+
@cpp.DeprecatedTerseWrite
3335
2: bool dummy2
3436
}
3537
@thrift.DeprecatedUnvalidatedAnnotations{
@@ -38,7 +40,9 @@ struct TestBRequest {
3840
},
3941
}
4042
struct TestBReply {
43+
@cpp.DeprecatedTerseWrite
4144
1: carbon_result.Result result
45+
@cpp.DeprecatedTerseWrite
4246
2: i32 valInt32
4347
}
4448

mcrouter/lib/carbon/test/gen/CarbonTest.thrift

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,44 +30,80 @@ namespace py3 carbon.test.thrift
3030
},
3131
}
3232
struct TestRequest {
33+
@cpp.DeprecatedTerseWrite
3334
1: carbon.IOBufKey key
35+
@cpp.DeprecatedTerseWrite
3436
2: bool dummy2
37+
@cpp.DeprecatedTerseWrite
3538
3: bool testBool
39+
@cpp.DeprecatedTerseWrite
3640
4: carbon.ui8 testChar
41+
@cpp.DeprecatedTerseWrite
3742
5: byte testInt8
43+
@cpp.DeprecatedTerseWrite
3844
6: i16 testInt16
45+
@cpp.DeprecatedTerseWrite
3946
7: i32 testInt32
47+
@cpp.DeprecatedTerseWrite
4048
8: i64 testInt64
49+
@cpp.DeprecatedTerseWrite
4150
9: carbon.ui8 testUInt8
51+
@cpp.DeprecatedTerseWrite
4252
10: carbon.ui16 testUInt16
53+
@cpp.DeprecatedTerseWrite
4354
11: carbon.ui32 testUInt32
55+
@cpp.DeprecatedTerseWrite
4456
12: carbon.ui64 testUInt64
57+
@cpp.DeprecatedTerseWrite
4558
13: float testFloat
59+
@cpp.DeprecatedTerseWrite
4660
14: double testDouble
61+
@cpp.DeprecatedTerseWrite
4762
15: string testShortString
63+
@cpp.DeprecatedTerseWrite
4864
16: string testLongString
65+
@cpp.DeprecatedTerseWrite
4966
17: carbon.IOBuf testIobuf
67+
@cpp.DeprecatedTerseWrite
5068
19: list<string> testList
5169
20: optional string testOptionalString
5270
21: optional carbon.IOBuf testOptionalIobuf
71+
@cpp.DeprecatedTerseWrite
5372
22: bool dummy22
73+
@cpp.DeprecatedTerseWrite
5474
23: bool dummy23
75+
@cpp.DeprecatedTerseWrite
5576
24: list<list<carbon.ui64>> testNestedVec
77+
@cpp.DeprecatedTerseWrite
5678
25: string_to_string_std_unordered_map testUMap
79+
@cpp.DeprecatedTerseWrite
5780
26: double_to_double_std_map testMap
81+
@cpp.DeprecatedTerseWrite
5882
27: string_to_list_carbon_ui16_std_map testComplexMap
83+
@cpp.DeprecatedTerseWrite
5984
28: string_std_unordered_set testUSet
85+
@cpp.DeprecatedTerseWrite
6086
29: carbon_ui64_std_set testSet
6187
30: optional bool testOptionalBool
88+
@cpp.DeprecatedTerseWrite
6289
31: string dummy31
90+
@cpp.DeprecatedTerseWrite
6391
32: list<carbon.IOBuf> testIOBufList
92+
@cpp.DeprecatedTerseWrite
6493
33: string_to_string_folly_F14FastMap testF14FastMap
94+
@cpp.DeprecatedTerseWrite
6595
34: string_to_string_folly_F14NodeMap testF14NodeMap
96+
@cpp.DeprecatedTerseWrite
6697
35: string_to_string_folly_F14ValueMap testF14ValueMap
98+
@cpp.DeprecatedTerseWrite
6799
36: string_to_string_folly_F14VectorMap testF14VectorMap
100+
@cpp.DeprecatedTerseWrite
68101
37: string_folly_F14FastSet testF14FastSet
102+
@cpp.DeprecatedTerseWrite
69103
38: string_folly_F14NodeSet testF14NodeSet
104+
@cpp.DeprecatedTerseWrite
70105
39: string_folly_F14ValueSet testF14ValueSet
106+
@cpp.DeprecatedTerseWrite
71107
40: string_folly_F14VectorSet testF14VectorSet
72108
41: optional string testOptionalKeywordString
73109
42: optional carbon.IOBuf testOptionalKeywordIobuf
@@ -79,8 +115,11 @@ struct TestRequest {
79115
},
80116
}
81117
struct TestReply {
118+
@cpp.DeprecatedTerseWrite
82119
1: carbon_result.Result result
120+
@cpp.DeprecatedTerseWrite
83121
2: i32 valInt32
122+
@cpp.DeprecatedTerseWrite
84123
3: i64 valInt64
85124
}
86125
@thrift.DeprecatedUnvalidatedAnnotations{
@@ -89,6 +128,7 @@ struct TestReply {
89128
},
90129
}
91130
struct TestRequestStringKey {
131+
@cpp.DeprecatedTerseWrite
92132
1: carbon.StringKey key
93133
}
94134
@thrift.DeprecatedUnvalidatedAnnotations{
@@ -97,34 +137,54 @@ struct TestRequestStringKey {
97137
},
98138
}
99139
struct TestReplyStringKey {
140+
@cpp.DeprecatedTerseWrite
100141
1: carbon_result.Result result
101142
}
102143
struct TestOptionalBool {
103144
1: optional bool optionalBool
104145
}
105146
union TestUnion {
147+
@cpp.DeprecatedTerseWrite
106148
1: carbon.ui64 a
149+
@cpp.DeprecatedTerseWrite
107150
2: carbon.ui32 b
151+
@cpp.DeprecatedTerseWrite
108152
3: carbon.ui16 c
109153
}
110154
struct TestF14Containers {
155+
@cpp.DeprecatedTerseWrite
111156
1: string_to_i64_folly_F14FastMap fastMap
157+
@cpp.DeprecatedTerseWrite
112158
2: string_to_i64_folly_F14NodeMap nodeMap
159+
@cpp.DeprecatedTerseWrite
113160
3: string_to_i64_folly_F14ValueMap valueMap
161+
@cpp.DeprecatedTerseWrite
114162
4: string_to_i64_folly_F14VectorMap vectorMap
163+
@cpp.DeprecatedTerseWrite
115164
5: i64_folly_F14FastSet fastSet
165+
@cpp.DeprecatedTerseWrite
116166
6: i64_folly_F14FastSet nodeSet
167+
@cpp.DeprecatedTerseWrite
117168
7: i64_folly_F14FastSet valueSet
169+
@cpp.DeprecatedTerseWrite
118170
8: i64_folly_F14FastSet vectorSet
119171
}
120172
struct TestStdContainers {
173+
@cpp.DeprecatedTerseWrite
121174
1: string_to_i64_std_unordered_map fastMap
175+
@cpp.DeprecatedTerseWrite
122176
2: string_to_i64_std_unordered_map nodeMap
177+
@cpp.DeprecatedTerseWrite
123178
3: string_to_i64_std_unordered_map valueMap
179+
@cpp.DeprecatedTerseWrite
124180
4: string_to_i64_std_unordered_map vectorMap
181+
@cpp.DeprecatedTerseWrite
125182
5: i64_std_unordered_set fastSet
183+
@cpp.DeprecatedTerseWrite
126184
6: i64_std_unordered_set nodeSet
185+
@cpp.DeprecatedTerseWrite
127186
7: i64_std_unordered_set valueSet
187+
@cpp.DeprecatedTerseWrite
128188
8: i64_std_unordered_set vectorSet
129189
}
130190
@cpp.EnumType{type = cpp.EnumUnderlyingType.U32}
@@ -170,21 +230,27 @@ enum EnumInt8 {
170230
}
171231

172232
struct StructWithEnumUInt32 {
233+
@cpp.DeprecatedTerseWrite
173234
1: EnumUInt32 testEnum
174235
}
175236
struct StructWithEnumUInt16 {
237+
@cpp.DeprecatedTerseWrite
176238
1: EnumUInt16 testEnum
177239
}
178240
struct StructWithEnumUInt8 {
241+
@cpp.DeprecatedTerseWrite
179242
1: EnumUInt8 testEnum
180243
}
181244
struct StructWithEnumInt32 {
245+
@cpp.DeprecatedTerseWrite
182246
1: EnumInt32 testEnum
183247
}
184248
struct StructWithEnumInt16 {
249+
@cpp.DeprecatedTerseWrite
185250
1: EnumInt16 testEnum
186251
}
187252
struct StructWithEnumInt8 {
253+
@cpp.DeprecatedTerseWrite
188254
1: EnumInt8 testEnum
189255
}
190256
struct StructWithOptionalEnumUInt32 {

0 commit comments

Comments
 (0)