@@ -25,12 +25,24 @@ class FieldType {
2525 isRepeated = false ,
2626 isRequired = false ;
2727
28+ const FieldType .required (this .baseType)
29+ : isGroup = false ,
30+ isPacked = false ,
31+ isRepeated = false ,
32+ isRequired = true ;
33+
2834 const FieldType .repeated (this .baseType)
2935 : isGroup = false ,
3036 isPacked = false ,
3137 isRepeated = true ,
3238 isRequired = false ;
3339
40+ const FieldType .packed (this .baseType)
41+ : isGroup = false ,
42+ isPacked = true ,
43+ isRepeated = false ,
44+ isRequired = false ;
45+
3446 const FieldType .fromBaseType (this .baseType)
3547 : isGroup = false ,
3648 isPacked = false ,
@@ -186,182 +198,83 @@ class PbFieldType {
186198 static int _INT_ZERO () => 0 ;
187199 static double _DOUBLE_ZERO () => 0.0 ;
188200
189- static const int _REQUIRED_BIT = 0x1 ;
190- static const int _REPEATED_BIT = 0x2 ;
191- static const int _PACKED_BIT = 0x4 ;
192-
193- static const int _BOOL_BIT = 0x10 ;
194- static const int _BYTES_BIT = 0x20 ;
195- static const int _STRING_BIT = 0x40 ;
196- static const int _DOUBLE_BIT = 0x80 ;
197- static const int _FLOAT_BIT = 0x100 ;
198- static const int _ENUM_BIT = 0x200 ;
199- static const int _GROUP_BIT = 0x400 ;
200- static const int _INT32_BIT = 0x800 ;
201- static const int _INT64_BIT = 0x1000 ;
202- static const int _SINT32_BIT = 0x2000 ;
203- static const int _SINT64_BIT = 0x4000 ;
204- static const int _UINT32_BIT = 0x8000 ;
205- static const int _UINT64_BIT = 0x10000 ;
206- static const int _FIXED32_BIT = 0x20000 ;
207- static const int _FIXED64_BIT = 0x40000 ;
208- static const int _SFIXED32_BIT = 0x80000 ;
209- static const int _SFIXED64_BIT = 0x100000 ;
210- static const int _MESSAGE_BIT = 0x200000 ;
211- static const int _MAP_BIT = 0x400000 ;
212-
213- static const int _OPTIONAL_BOOL = _BOOL_BIT ;
214- static const int _OPTIONAL_BYTES = _BYTES_BIT ;
215- static const int _OPTIONAL_STRING = _STRING_BIT ;
216- static const int _OPTIONAL_FLOAT = _FLOAT_BIT ;
217- static const int _OPTIONAL_DOUBLE = _DOUBLE_BIT ;
218- static const int _OPTIONAL_ENUM = _ENUM_BIT ;
219- static const int _OPTIONAL_GROUP = _GROUP_BIT ;
220- static const int _OPTIONAL_INT32 = _INT32_BIT ;
221- static const int _OPTIONAL_INT64 = _INT64_BIT ;
222- static const int _OPTIONAL_SINT32 = _SINT32_BIT ;
223- static const int _OPTIONAL_SINT64 = _SINT64_BIT ;
224- static const int _OPTIONAL_UINT32 = _UINT32_BIT ;
225- static const int _OPTIONAL_UINT64 = _UINT64_BIT ;
226- static const int _OPTIONAL_FIXED32 = _FIXED32_BIT ;
227- static const int _OPTIONAL_FIXED64 = _FIXED64_BIT ;
228- static const int _OPTIONAL_SFIXED32 = _SFIXED32_BIT ;
229- static const int _OPTIONAL_SFIXED64 = _SFIXED64_BIT ;
230- static const int _OPTIONAL_MESSAGE = _MESSAGE_BIT ;
231-
232- static const int _REQUIRED_BOOL = _REQUIRED_BIT | _BOOL_BIT ;
233- static const int _REQUIRED_BYTES = _REQUIRED_BIT | _BYTES_BIT ;
234- static const int _REQUIRED_STRING = _REQUIRED_BIT | _STRING_BIT ;
235- static const int _REQUIRED_FLOAT = _REQUIRED_BIT | _FLOAT_BIT ;
236- static const int _REQUIRED_DOUBLE = _REQUIRED_BIT | _DOUBLE_BIT ;
237- static const int _REQUIRED_ENUM = _REQUIRED_BIT | _ENUM_BIT ;
238- static const int _REQUIRED_GROUP = _REQUIRED_BIT | _GROUP_BIT ;
239- static const int _REQUIRED_INT32 = _REQUIRED_BIT | _INT32_BIT ;
240- static const int _REQUIRED_INT64 = _REQUIRED_BIT | _INT64_BIT ;
241- static const int _REQUIRED_SINT32 = _REQUIRED_BIT | _SINT32_BIT ;
242- static const int _REQUIRED_SINT64 = _REQUIRED_BIT | _SINT64_BIT ;
243- static const int _REQUIRED_UINT32 = _REQUIRED_BIT | _UINT32_BIT ;
244- static const int _REQUIRED_UINT64 = _REQUIRED_BIT | _UINT64_BIT ;
245- static const int _REQUIRED_FIXED32 = _REQUIRED_BIT | _FIXED32_BIT ;
246- static const int _REQUIRED_FIXED64 = _REQUIRED_BIT | _FIXED64_BIT ;
247- static const int _REQUIRED_SFIXED32 = _REQUIRED_BIT | _SFIXED32_BIT ;
248- static const int _REQUIRED_SFIXED64 = _REQUIRED_BIT | _SFIXED64_BIT ;
249- static const int _REQUIRED_MESSAGE = _REQUIRED_BIT | _MESSAGE_BIT ;
250-
251- static const int _REPEATED_BOOL = _REPEATED_BIT | _BOOL_BIT ;
252- static const int _REPEATED_BYTES = _REPEATED_BIT | _BYTES_BIT ;
253- static const int _REPEATED_STRING = _REPEATED_BIT | _STRING_BIT ;
254- static const int _REPEATED_FLOAT = _REPEATED_BIT | _FLOAT_BIT ;
255- static const int _REPEATED_DOUBLE = _REPEATED_BIT | _DOUBLE_BIT ;
256- static const int _REPEATED_ENUM = _REPEATED_BIT | _ENUM_BIT ;
257- static const int _REPEATED_GROUP = _REPEATED_BIT | _GROUP_BIT ;
258- static const int _REPEATED_INT32 = _REPEATED_BIT | _INT32_BIT ;
259- static const int _REPEATED_INT64 = _REPEATED_BIT | _INT64_BIT ;
260- static const int _REPEATED_SINT32 = _REPEATED_BIT | _SINT32_BIT ;
261- static const int _REPEATED_SINT64 = _REPEATED_BIT | _SINT64_BIT ;
262- static const int _REPEATED_UINT32 = _REPEATED_BIT | _UINT32_BIT ;
263- static const int _REPEATED_UINT64 = _REPEATED_BIT | _UINT64_BIT ;
264- static const int _REPEATED_FIXED32 = _REPEATED_BIT | _FIXED32_BIT ;
265- static const int _REPEATED_FIXED64 = _REPEATED_BIT | _FIXED64_BIT ;
266- static const int _REPEATED_SFIXED32 = _REPEATED_BIT | _SFIXED32_BIT ;
267- static const int _REPEATED_SFIXED64 = _REPEATED_BIT | _SFIXED64_BIT ;
268- static const int _REPEATED_MESSAGE = _REPEATED_BIT | _MESSAGE_BIT ;
269-
270- static const int _PACKED_BOOL = _REPEATED_BIT | _PACKED_BIT | _BOOL_BIT ;
271- static const int _PACKED_FLOAT = _REPEATED_BIT | _PACKED_BIT | _FLOAT_BIT ;
272- static const int _PACKED_DOUBLE = _REPEATED_BIT | _PACKED_BIT | _DOUBLE_BIT ;
273- static const int _PACKED_ENUM = _REPEATED_BIT | _PACKED_BIT | _ENUM_BIT ;
274- static const int _PACKED_INT32 = _REPEATED_BIT | _PACKED_BIT | _INT32_BIT ;
275- static const int _PACKED_INT64 = _REPEATED_BIT | _PACKED_BIT | _INT64_BIT ;
276- static const int _PACKED_SINT32 = _REPEATED_BIT | _PACKED_BIT | _SINT32_BIT ;
277- static const int _PACKED_SINT64 = _REPEATED_BIT | _PACKED_BIT | _SINT64_BIT ;
278- static const int _PACKED_UINT32 = _REPEATED_BIT | _PACKED_BIT | _UINT32_BIT ;
279- static const int _PACKED_UINT64 = _REPEATED_BIT | _PACKED_BIT | _UINT64_BIT ;
280- static const int _PACKED_FIXED32 = _REPEATED_BIT | _PACKED_BIT | _FIXED32_BIT ;
281- static const int _PACKED_FIXED64 = _REPEATED_BIT | _PACKED_BIT | _FIXED64_BIT ;
282- static const int _PACKED_SFIXED32 =
283- _REPEATED_BIT | _PACKED_BIT | _SFIXED32_BIT ;
284- static const int _PACKED_SFIXED64 =
285- _REPEATED_BIT | _PACKED_BIT | _SFIXED64_BIT ;
286-
287- static const int _MAP = _MAP_BIT | _MESSAGE_BIT ;
288201 // Short names for use in generated code.
289202
290203 // _O_ptional.
291- static const int OB = _OPTIONAL_BOOL ;
292- static const int OY = _OPTIONAL_BYTES ;
293- static const int OS = _OPTIONAL_STRING ;
294- static const int OF = _OPTIONAL_FLOAT ;
295- static const int OD = _OPTIONAL_DOUBLE ;
296- static const int OE = _OPTIONAL_ENUM ;
297- static const int OG = _OPTIONAL_GROUP ;
298- static const int O3 = _OPTIONAL_INT32 ;
299- static const int O6 = _OPTIONAL_INT64 ;
300- static const int OS3 = _OPTIONAL_SINT32 ;
301- static const int OS6 = _OPTIONAL_SINT64 ;
302- static const int OU3 = _OPTIONAL_UINT32 ;
303- static const int OU6 = _OPTIONAL_UINT64 ;
304- static const int OF3 = _OPTIONAL_FIXED32 ;
305- static const int OF6 = _OPTIONAL_FIXED64 ;
306- static const int OSF3 = _OPTIONAL_SFIXED32 ;
307- static const int OSF6 = _OPTIONAL_SFIXED64 ;
308- static const int OM = _OPTIONAL_MESSAGE ;
204+ static const FieldType OB = FieldType . optional ( FieldBaseType . bool ) ;
205+ static const FieldType OY = FieldType . optional ( FieldBaseType .bytes) ;
206+ static const FieldType OS = FieldType . optional ( FieldBaseType .string) ;
207+ static const FieldType OF = FieldType . optional ( FieldBaseType .float) ;
208+ static const FieldType OD = FieldType . optional ( FieldBaseType . double ) ;
209+ static const FieldType OE = FieldType . optional ( FieldBaseType .enum_) ;
210+ static const FieldType OG = FieldType . optional ( FieldBaseType .group) ;
211+ static const FieldType O3 = FieldType . optional ( FieldBaseType .int32) ;
212+ static const FieldType O6 = FieldType . optional ( FieldBaseType .int64) ;
213+ static const FieldType OS3 = FieldType . optional ( FieldBaseType .sint32) ;
214+ static const FieldType OS6 = FieldType . optional ( FieldBaseType .sint64) ;
215+ static const FieldType OU3 = FieldType . optional ( FieldBaseType .uint32) ;
216+ static const FieldType OU6 = FieldType . optional ( FieldBaseType .uint64) ;
217+ static const FieldType OF3 = FieldType . optional ( FieldBaseType .fixed32) ;
218+ static const FieldType OF6 = FieldType . optional ( FieldBaseType .fixed64) ;
219+ static const FieldType OSF3 = FieldType . optional ( FieldBaseType .sfixed32) ;
220+ static const FieldType OSF6 = FieldType . optional ( FieldBaseType .sfixed64) ;
221+ static const FieldType OM = FieldType . optional ( FieldBaseType .message) ;
309222
310223 // re_Q_uired.
311- static const int QB = _REQUIRED_BOOL ;
312- static const int QY = _REQUIRED_BYTES ;
313- static const int QS = _REQUIRED_STRING ;
314- static const int QF = _REQUIRED_FLOAT ;
315- static const int QD = _REQUIRED_DOUBLE ;
316- static const int QE = _REQUIRED_ENUM ;
317- static const int QG = _REQUIRED_GROUP ;
318- static const int Q3 = _REQUIRED_INT32 ;
319- static const int Q6 = _REQUIRED_INT64 ;
320- static const int QS3 = _REQUIRED_SINT32 ;
321- static const int QS6 = _REQUIRED_SINT64 ;
322- static const int QU3 = _REQUIRED_UINT32 ;
323- static const int QU6 = _REQUIRED_UINT64 ;
324- static const int QF3 = _REQUIRED_FIXED32 ;
325- static const int QF6 = _REQUIRED_FIXED64 ;
326- static const int QSF3 = _REQUIRED_SFIXED32 ;
327- static const int QSF6 = _REQUIRED_SFIXED64 ;
328- static const int QM = _REQUIRED_MESSAGE ;
224+ static const FieldType QB = FieldType . required ( FieldBaseType . bool ) ;
225+ static const FieldType QY = FieldType . required ( FieldBaseType .bytes) ;
226+ static const FieldType QS = FieldType . required ( FieldBaseType .string) ;
227+ static const FieldType QF = FieldType . required ( FieldBaseType .float) ;
228+ static const FieldType QD = FieldType . required ( FieldBaseType . double ) ;
229+ static const FieldType QE = FieldType . required ( FieldBaseType .enum_) ;
230+ static const FieldType QG = FieldType . required ( FieldBaseType .group) ;
231+ static const FieldType Q3 = FieldType . required ( FieldBaseType .int32) ;
232+ static const FieldType Q6 = FieldType . required ( FieldBaseType .int64) ;
233+ static const FieldType QS3 = FieldType . required ( FieldBaseType .sint32) ;
234+ static const FieldType QS6 = FieldType . required ( FieldBaseType .sint64) ;
235+ static const FieldType QU3 = FieldType . required ( FieldBaseType .uint32) ;
236+ static const FieldType QU6 = FieldType . required ( FieldBaseType .uint64) ;
237+ static const FieldType QF3 = FieldType . required ( FieldBaseType .fixed32) ;
238+ static const FieldType QF6 = FieldType . required ( FieldBaseType .fixed64) ;
239+ static const FieldType QSF3 = FieldType . required ( FieldBaseType .sfixed32) ;
240+ static const FieldType QSF6 = FieldType . required ( FieldBaseType .sfixed64) ;
241+ static const FieldType QM = FieldType . required ( FieldBaseType .message) ;
329242
330243 // re_P_eated.
331- static const int PB = _REPEATED_BOOL ;
332- static const int PY = _REPEATED_BYTES ;
333- static const int PS = _REPEATED_STRING ;
334- static const int PF = _REPEATED_FLOAT ;
335- static const int PD = _REPEATED_DOUBLE ;
336- static const int PE = _REPEATED_ENUM ;
337- static const int PG = _REPEATED_GROUP ;
338- static const int P3 = _REPEATED_INT32 ;
339- static const int P6 = _REPEATED_INT64 ;
340- static const int PS3 = _REPEATED_SINT32 ;
341- static const int PS6 = _REPEATED_SINT64 ;
342- static const int PU3 = _REPEATED_UINT32 ;
343- static const int PU6 = _REPEATED_UINT64 ;
344- static const int PF3 = _REPEATED_FIXED32 ;
345- static const int PF6 = _REPEATED_FIXED64 ;
346- static const int PSF3 = _REPEATED_SFIXED32 ;
347- static const int PSF6 = _REPEATED_SFIXED64 ;
348- static const int PM = _REPEATED_MESSAGE ;
244+ static const FieldType PB = FieldType . repeated ( FieldBaseType . bool ) ;
245+ static const FieldType PY = FieldType . repeated ( FieldBaseType .bytes) ;
246+ static const FieldType PS = FieldType . repeated ( FieldBaseType .string) ;
247+ static const FieldType PF = FieldType . repeated ( FieldBaseType .float) ;
248+ static const FieldType PD = FieldType . repeated ( FieldBaseType . double ) ;
249+ static const FieldType PE = FieldType . repeated ( FieldBaseType .enum_) ;
250+ static const FieldType PG = FieldType . repeated ( FieldBaseType .group) ;
251+ static const FieldType P3 = FieldType . repeated ( FieldBaseType .int32) ;
252+ static const FieldType P6 = FieldType . repeated ( FieldBaseType .int64) ;
253+ static const FieldType PS3 = FieldType . repeated ( FieldBaseType .sint32) ;
254+ static const FieldType PS6 = FieldType . repeated ( FieldBaseType .sint64) ;
255+ static const FieldType PU3 = FieldType . repeated ( FieldBaseType .uint32) ;
256+ static const FieldType PU6 = FieldType . repeated ( FieldBaseType .uint64) ;
257+ static const FieldType PF3 = FieldType . repeated ( FieldBaseType .fixed32) ;
258+ static const FieldType PF6 = FieldType . repeated ( FieldBaseType .fixed64) ;
259+ static const FieldType PSF3 = FieldType . repeated ( FieldBaseType .sfixed32) ;
260+ static const FieldType PSF6 = FieldType . repeated ( FieldBaseType .sfixed64) ;
261+ static const FieldType PM = FieldType . repeated ( FieldBaseType .message) ;
349262
350263 // pac_K_ed.
351- static const int KB = _PACKED_BOOL ;
352- static const int KE = _PACKED_ENUM ;
353- static const int KF = _PACKED_FLOAT ;
354- static const int KD = _PACKED_DOUBLE ;
355- static const int K3 = _PACKED_INT32 ;
356- static const int K6 = _PACKED_INT64 ;
357- static const int KS3 = _PACKED_SINT32 ;
358- static const int KS6 = _PACKED_SINT64 ;
359- static const int KU3 = _PACKED_UINT32 ;
360- static const int KU6 = _PACKED_UINT64 ;
361- static const int KF3 = _PACKED_FIXED32 ;
362- static const int KF6 = _PACKED_FIXED64 ;
363- static const int KSF3 = _PACKED_SFIXED32 ;
364- static const int KSF6 = _PACKED_SFIXED64 ;
365-
366- static const int M = _MAP ;
264+ static const FieldType KB = FieldType . packed ( FieldBaseType . bool ) ;
265+ static const FieldType KE = FieldType . packed ( FieldBaseType .enum_) ;
266+ static const FieldType KF = FieldType . packed ( FieldBaseType .float) ;
267+ static const FieldType KD = FieldType . packed ( FieldBaseType . double ) ;
268+ static const FieldType K3 = FieldType . packed ( FieldBaseType .int32) ;
269+ static const FieldType K6 = FieldType . packed ( FieldBaseType .int64) ;
270+ static const FieldType KS3 = FieldType . packed ( FieldBaseType .sint32) ;
271+ static const FieldType KS6 = FieldType . packed ( FieldBaseType .sint64) ;
272+ static const FieldType KU3 = FieldType . packed ( FieldBaseType .uint32) ;
273+ static const FieldType KU6 = FieldType . packed ( FieldBaseType .uint64) ;
274+ static const FieldType KF3 = FieldType . packed ( FieldBaseType .fixed32) ;
275+ static const FieldType KF6 = FieldType . packed ( FieldBaseType .fixed64) ;
276+ static const FieldType KSF3 = FieldType . packed ( FieldBaseType .sfixed32) ;
277+ static const FieldType KSF6 = FieldType . packed ( FieldBaseType .sfixed64) ;
278+
279+ static const FieldType M = FieldType . MAP () ;
367280}
0 commit comments