This is a significant change to the upb_stream protocol, and should hopefully be the last significant change. All callbacks are now registered ahead-of-time instead of having delegated callbacks registered at runtime, which makes it much easier to aggressively optimize ahead-of-time (like with a JIT). Other impacts of this change: - You no longer need to have loaded descriptor.proto as a upb_def to load other descriptors! This means the special-case code we used for bootstrapping is no longer necessary, and we no longer need to link the descriptor for descriptor.proto into upb. - A client can now register any upb_value as what will be delivered to their value callback, not just a upb_fielddef*. This should allow for other clients to get more bang out of the streaming decoder. This change unfortunately causes a bit of a performance regression -- I think largely due to highly suboptimal code that GCC generates when structs are returned by value. See: http://blog.reverberate.org/2011/03/19/when-a-compilers-slow-code-actually-bites-you/ On the other hand, once we have a JIT this should no longer matter. Performance numbers: plain.parsestream_googlemessage1.upb_table: 374 -> 396 (5.88) plain.parsestream_googlemessage2.upb_table: 616 -> 449 (-27.11) plain.parsetostruct_googlemessage1.upb_table_byref: 268 -> 269 (0.37) plain.parsetostruct_googlemessage1.upb_table_byval: 215 -> 204 (-5.12) plain.parsetostruct_googlemessage2.upb_table_byref: 307 -> 281 (-8.47) plain.parsetostruct_googlemessage2.upb_table_byval: 297 -> 272 (-8.42) omitfp.parsestream_googlemessage1.upb_table: 423 -> 410 (-3.07) omitfp.parsestream_googlemessage2.upb_table: 679 -> 483 (-28.87) omitfp.parsetostruct_googlemessage1.upb_table_byref: 287 -> 282 (-1.74) omitfp.parsetostruct_googlemessage1.upb_table_byval: 226 -> 219 (-3.10) omitfp.parsetostruct_googlemessage2.upb_table_byref: 315 -> 298 (-5.40) omitfp.parsetostruct_googlemessage2.upb_table_byval: 297 -> 287 (-3.37)pull/13171/head
parent
37e1c3102b
commit
8ef6873e0e
25 changed files with 1440 additions and 1760 deletions
@ -1,331 +0,0 @@ |
||||
unsigned char descriptor_pb[] = { |
||||
0x0a, 0xd8, 0x1e, 0x0a, 0x14, 0x73, 0x72, 0x63, 0x2f, 0x64, 0x65, 0x73, |
||||
0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, |
||||
0x6f, 0x12, 0x0f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, |
||||
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x47, 0x0a, 0x11, 0x46, 0x69, |
||||
0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, |
||||
0x53, 0x65, 0x74, 0x12, 0x32, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, |
||||
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, |
||||
0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, |
||||
0x46, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, |
||||
0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x97, 0x03, 0x0a, 0x13, |
||||
0x46, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, |
||||
0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x0a, 0x04, 0x6e, |
||||
0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x12, 0x0f, 0x0a, |
||||
0x07, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, |
||||
0x28, 0x09, 0x12, 0x12, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x65, 0x6e, 0x64, |
||||
0x65, 0x6e, 0x63, 0x79, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x12, 0x36, |
||||
0x0a, 0x0c, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x79, |
||||
0x70, 0x65, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x67, |
||||
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, |
||||
0x75, 0x66, 0x2e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, |
||||
0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x37, 0x0a, 0x09, 0x65, 0x6e, |
||||
0x75, 0x6d, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x03, 0x28, |
||||
0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, |
||||
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6e, 0x75, 0x6d, |
||||
0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, |
||||
0x6f, 0x74, 0x6f, 0x12, 0x38, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, |
||||
0x63, 0x65, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x67, |
||||
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, |
||||
0x75, 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, |
||||
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, |
||||
0x6f, 0x12, 0x38, 0x0a, 0x09, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, |
||||
0x6f, 0x6e, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x67, |
||||
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, |
||||
0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x44, 0x65, 0x73, 0x63, |
||||
0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, |
||||
0x2d, 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x08, |
||||
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, |
||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, |
||||
0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x39, |
||||
0x0a, 0x10, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, 0x6f, 0x64, |
||||
0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, |
||||
0x32, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, |
||||
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x6f, 0x75, 0x72, 0x63, |
||||
0x65, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0xa9, 0x03, |
||||
0x0a, 0x0f, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, |
||||
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x0a, 0x04, 0x6e, 0x61, 0x6d, |
||||
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x12, 0x34, 0x0a, 0x05, 0x66, |
||||
0x69, 0x65, 0x6c, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, |
||||
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, |
||||
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x44, 0x65, |
||||
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, |
||||
0x6f, 0x12, 0x38, 0x0a, 0x09, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, |
||||
0x6f, 0x6e, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x67, |
||||
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, |
||||
0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x44, 0x65, 0x73, 0x63, |
||||
0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, |
||||
0x35, 0x0a, 0x0b, 0x6e, 0x65, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x74, 0x79, |
||||
0x70, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x67, |
||||
0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, |
||||
0x75, 0x66, 0x2e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, |
||||
0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x37, 0x0a, 0x09, 0x65, 0x6e, |
||||
0x75, 0x6d, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x03, 0x28, |
||||
0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, |
||||
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6e, 0x75, 0x6d, |
||||
0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, |
||||
0x6f, 0x74, 0x6f, 0x12, 0x48, 0x0a, 0x0f, 0x65, 0x78, 0x74, 0x65, 0x6e, |
||||
0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x05, |
||||
0x20, 0x03, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, |
||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, |
||||
0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, |
||||
0x74, 0x6f, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, |
||||
0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x30, 0x0a, 0x07, 0x6f, 0x70, 0x74, |
||||
0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, |
||||
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, |
||||
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, |
||||
0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x2c, 0x0a, 0x0e, 0x45, |
||||
0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x61, 0x6e, 0x67, |
||||
0x65, 0x12, 0x0d, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x01, |
||||
0x20, 0x01, 0x28, 0x05, 0x12, 0x0b, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, |
||||
0x02, 0x20, 0x01, 0x28, 0x05, 0x22, 0x94, 0x05, 0x0a, 0x14, 0x46, 0x69, |
||||
0x65, 0x6c, 0x64, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, |
||||
0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x0a, 0x04, 0x6e, 0x61, |
||||
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x12, 0x0e, 0x0a, 0x06, |
||||
0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, |
||||
0x12, 0x3a, 0x0a, 0x05, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x04, 0x20, |
||||
0x01, 0x28, 0x0e, 0x32, 0x2b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, |
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, |
||||
0x65, 0x6c, 0x64, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, |
||||
0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, |
||||
0x12, 0x38, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, |
||||
0x28, 0x0e, 0x32, 0x2a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, |
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, |
||||
0x6c, 0x64, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, |
||||
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x11, |
||||
0x0a, 0x09, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, |
||||
0x06, 0x20, 0x01, 0x28, 0x09, 0x12, 0x10, 0x0a, 0x08, 0x65, 0x78, 0x74, |
||||
0x65, 0x6e, 0x64, 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x12, |
||||
0x15, 0x0a, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x76, |
||||
0x61, 0x6c, 0x75, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x12, 0x2e, |
||||
0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x08, 0x20, |
||||
0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, |
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, |
||||
0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0xb6, |
||||
0x02, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x54, |
||||
0x59, 0x50, 0x45, 0x5f, 0x44, 0x4f, 0x55, 0x42, 0x4c, 0x45, 0x10, 0x01, |
||||
0x12, 0x0e, 0x0a, 0x0a, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x46, 0x4c, 0x4f, |
||||
0x41, 0x54, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x54, 0x59, 0x50, 0x45, |
||||
0x5f, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x10, 0x03, 0x12, 0x0f, 0x0a, 0x0b, |
||||
0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x10, |
||||
0x04, 0x12, 0x0e, 0x0a, 0x0a, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x49, 0x4e, |
||||
0x54, 0x33, 0x32, 0x10, 0x05, 0x12, 0x10, 0x0a, 0x0c, 0x54, 0x59, 0x50, |
||||
0x45, 0x5f, 0x46, 0x49, 0x58, 0x45, 0x44, 0x36, 0x34, 0x10, 0x06, 0x12, |
||||
0x10, 0x0a, 0x0c, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x46, 0x49, 0x58, 0x45, |
||||
0x44, 0x33, 0x32, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x54, 0x59, 0x50, |
||||
0x45, 0x5f, 0x42, 0x4f, 0x4f, 0x4c, 0x10, 0x08, 0x12, 0x0f, 0x0a, 0x0b, |
||||
0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, |
||||
0x09, 0x12, 0x0e, 0x0a, 0x0a, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x47, 0x52, |
||||
0x4f, 0x55, 0x50, 0x10, 0x0a, 0x12, 0x10, 0x0a, 0x0c, 0x54, 0x59, 0x50, |
||||
0x45, 0x5f, 0x4d, 0x45, 0x53, 0x53, 0x41, 0x47, 0x45, 0x10, 0x0b, 0x12, |
||||
0x0e, 0x0a, 0x0a, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x42, 0x59, 0x54, 0x45, |
||||
0x53, 0x10, 0x0c, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x59, 0x50, 0x45, 0x5f, |
||||
0x55, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x10, 0x0d, 0x12, 0x0d, 0x0a, 0x09, |
||||
0x54, 0x59, 0x50, 0x45, 0x5f, 0x45, 0x4e, 0x55, 0x4d, 0x10, 0x0e, 0x12, |
||||
0x11, 0x0a, 0x0d, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x46, 0x49, 0x58, |
||||
0x45, 0x44, 0x33, 0x32, 0x10, 0x0f, 0x12, 0x11, 0x0a, 0x0d, 0x54, 0x59, |
||||
0x50, 0x45, 0x5f, 0x53, 0x46, 0x49, 0x58, 0x45, 0x44, 0x36, 0x34, 0x10, |
||||
0x10, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x49, |
||||
0x4e, 0x54, 0x33, 0x32, 0x10, 0x11, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x59, |
||||
0x50, 0x45, 0x5f, 0x53, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x10, 0x12, 0x22, |
||||
0x43, 0x0a, 0x05, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x12, 0x0a, 0x0e, |
||||
0x4c, 0x41, 0x42, 0x45, 0x4c, 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, |
||||
0x41, 0x4c, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x4c, 0x41, 0x42, 0x45, |
||||
0x4c, 0x5f, 0x52, 0x45, 0x51, 0x55, 0x49, 0x52, 0x45, 0x44, 0x10, 0x02, |
||||
0x12, 0x12, 0x0a, 0x0e, 0x4c, 0x41, 0x42, 0x45, 0x4c, 0x5f, 0x52, 0x45, |
||||
0x50, 0x45, 0x41, 0x54, 0x45, 0x44, 0x10, 0x03, 0x22, 0x8c, 0x01, 0x0a, |
||||
0x13, 0x45, 0x6e, 0x75, 0x6d, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, |
||||
0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x0a, 0x04, |
||||
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x12, 0x38, |
||||
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, |
||||
0x0b, 0x32, 0x29, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, |
||||
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6e, 0x75, 0x6d, |
||||
0x56, 0x61, 0x6c, 0x75, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, |
||||
0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2d, 0x0a, 0x07, |
||||
0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, |
||||
0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, |
||||
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6e, 0x75, 0x6d, |
||||
0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x6c, 0x0a, 0x18, 0x45, |
||||
0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x44, 0x65, 0x73, 0x63, |
||||
0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, |
||||
0x0c, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, |
||||
0x09, 0x12, 0x0e, 0x0a, 0x06, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, |
||||
0x02, 0x20, 0x01, 0x28, 0x05, 0x12, 0x32, 0x0a, 0x07, 0x6f, 0x70, 0x74, |
||||
0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, |
||||
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, |
||||
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, |
||||
0x75, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x90, 0x01, |
||||
0x0a, 0x16, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x73, |
||||
0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, |
||||
0x12, 0x0c, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, |
||||
0x28, 0x09, 0x12, 0x36, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, |
||||
0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x67, 0x6f, 0x6f, |
||||
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, |
||||
0x2e, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x44, 0x65, 0x73, 0x63, 0x72, |
||||
0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x30, |
||||
0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, |
||||
0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, |
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x65, |
||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, |
||||
0x22, 0x7f, 0x0a, 0x15, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x44, 0x65, |
||||
0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, |
||||
0x6f, 0x12, 0x0c, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, |
||||
0x01, 0x28, 0x09, 0x12, 0x12, 0x0a, 0x0a, 0x69, 0x6e, 0x70, 0x75, 0x74, |
||||
0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x12, |
||||
0x13, 0x0a, 0x0b, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x5f, 0x74, 0x79, |
||||
0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x12, 0x2f, 0x0a, 0x07, |
||||
0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, |
||||
0x0b, 0x32, 0x1e, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, |
||||
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x74, 0x68, |
||||
0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0xd5, 0x03, |
||||
0x0a, 0x0b, 0x46, 0x69, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, |
||||
0x73, 0x12, 0x14, 0x0a, 0x0c, 0x6a, 0x61, 0x76, 0x61, 0x5f, 0x70, 0x61, |
||||
0x63, 0x6b, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x12, |
||||
0x1c, 0x0a, 0x14, 0x6a, 0x61, 0x76, 0x61, 0x5f, 0x6f, 0x75, 0x74, 0x65, |
||||
0x72, 0x5f, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x6e, 0x61, 0x6d, 0x65, 0x18, |
||||
0x08, 0x20, 0x01, 0x28, 0x09, 0x12, 0x22, 0x0a, 0x13, 0x6a, 0x61, 0x76, |
||||
0x61, 0x5f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x5f, 0x66, |
||||
0x69, 0x6c, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, |
||||
0x66, 0x61, 0x6c, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x1d, 0x6a, 0x61, 0x76, |
||||
0x61, 0x5f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x5f, 0x65, |
||||
0x71, 0x75, 0x61, 0x6c, 0x73, 0x5f, 0x61, 0x6e, 0x64, 0x5f, 0x68, 0x61, |
||||
0x73, 0x68, 0x18, 0x14, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, |
||||
0x6c, 0x73, 0x65, 0x12, 0x46, 0x0a, 0x0c, 0x6f, 0x70, 0x74, 0x69, 0x6d, |
||||
0x69, 0x7a, 0x65, 0x5f, 0x66, 0x6f, 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, |
||||
0x0e, 0x32, 0x29, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, |
||||
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x6c, 0x65, |
||||
0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x4f, 0x70, 0x74, 0x69, |
||||
0x6d, 0x69, 0x7a, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x3a, 0x05, 0x53, 0x50, |
||||
0x45, 0x45, 0x44, 0x12, 0x22, 0x0a, 0x13, 0x63, 0x63, 0x5f, 0x67, 0x65, |
||||
0x6e, 0x65, 0x72, 0x69, 0x63, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, |
||||
0x65, 0x73, 0x18, 0x10, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, |
||||
0x6c, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x15, 0x6a, 0x61, 0x76, 0x61, 0x5f, |
||||
0x67, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x5f, 0x73, 0x65, 0x72, 0x76, |
||||
0x69, 0x63, 0x65, 0x73, 0x18, 0x11, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, |
||||
0x66, 0x61, 0x6c, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x13, 0x70, 0x79, 0x5f, |
||||
0x67, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x5f, 0x73, 0x65, 0x72, 0x76, |
||||
0x69, 0x63, 0x65, 0x73, 0x18, 0x12, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, |
||||
0x66, 0x61, 0x6c, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x14, 0x75, 0x6e, 0x69, |
||||
0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, |
||||
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, |
||||
0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, |
||||
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, |
||||
0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, |
||||
0x6f, 0x6e, 0x22, 0x3a, 0x0a, 0x0c, 0x4f, 0x70, 0x74, 0x69, 0x6d, 0x69, |
||||
0x7a, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x50, |
||||
0x45, 0x45, 0x44, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x43, 0x4f, 0x44, |
||||
0x45, 0x5f, 0x53, 0x49, 0x5a, 0x45, 0x10, 0x02, 0x12, 0x10, 0x0a, 0x0c, |
||||
0x4c, 0x49, 0x54, 0x45, 0x5f, 0x52, 0x55, 0x4e, 0x54, 0x49, 0x4d, 0x45, |
||||
0x10, 0x03, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, |
||||
0x02, 0x22, 0xb8, 0x01, 0x0a, 0x0e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, |
||||
0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x26, 0x0a, 0x17, |
||||
0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x5f, |
||||
0x77, 0x69, 0x72, 0x65, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, |
||||
0x01, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, |
||||
0x12, 0x2e, 0x0a, 0x1f, 0x6e, 0x6f, 0x5f, 0x73, 0x74, 0x61, 0x6e, 0x64, |
||||
0x61, 0x72, 0x64, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, |
||||
0x6f, 0x72, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x6f, 0x72, 0x18, |
||||
0x02, 0x20, 0x01, 0x28, 0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, |
||||
0x12, 0x43, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, |
||||
0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, |
||||
0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, |
||||
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, |
||||
0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, |
||||
0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, |
||||
0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x22, 0x94, 0x02, 0x0a, |
||||
0x0c, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, |
||||
0x73, 0x12, 0x3a, 0x0a, 0x05, 0x63, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, |
||||
0x20, 0x01, 0x28, 0x0e, 0x32, 0x23, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, |
||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, |
||||
0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, |
||||
0x43, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x06, 0x53, 0x54, 0x52, 0x49, 0x4e, |
||||
0x47, 0x12, 0x0e, 0x0a, 0x06, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x64, 0x18, |
||||
0x02, 0x20, 0x01, 0x28, 0x08, 0x12, 0x19, 0x0a, 0x0a, 0x64, 0x65, 0x70, |
||||
0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, |
||||
0x08, 0x3a, 0x05, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x14, |
||||
0x65, 0x78, 0x70, 0x65, 0x72, 0x69, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x6c, |
||||
0x5f, 0x6d, 0x61, 0x70, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x09, 0x20, 0x01, |
||||
0x28, 0x09, 0x12, 0x43, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, |
||||
0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, |
||||
0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, |
||||
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, |
||||
0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, |
||||
0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x22, |
||||
0x2f, 0x0a, 0x05, 0x43, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0a, 0x0a, 0x06, |
||||
0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, |
||||
0x43, 0x4f, 0x52, 0x44, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x54, |
||||
0x52, 0x49, 0x4e, 0x47, 0x5f, 0x50, 0x49, 0x45, 0x43, 0x45, 0x10, 0x02, |
||||
0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x22, |
||||
0x5d, 0x0a, 0x0b, 0x45, 0x6e, 0x75, 0x6d, 0x4f, 0x70, 0x74, 0x69, 0x6f, |
||||
0x6e, 0x73, 0x12, 0x43, 0x0a, 0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, |
||||
0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, |
||||
0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, |
||||
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, |
||||
0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, |
||||
0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, |
||||
0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, 0x80, 0x02, 0x22, 0x62, |
||||
0x0a, 0x10, 0x45, 0x6e, 0x75, 0x6d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x4f, |
||||
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x43, 0x0a, 0x14, 0x75, 0x6e, |
||||
0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x5f, |
||||
0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, 0x03, 0x28, |
||||
0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, |
||||
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, |
||||
0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, |
||||
0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, 0x80, 0x80, |
||||
0x80, 0x02, 0x22, 0x60, 0x0a, 0x0e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, |
||||
0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x43, 0x0a, 0x14, |
||||
0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, |
||||
0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, 0x20, |
||||
0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, |
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x6e, |
||||
0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, |
||||
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, 0x80, |
||||
0x80, 0x80, 0x80, 0x02, 0x22, 0x5f, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x68, |
||||
0x6f, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x43, 0x0a, |
||||
0x14, 0x75, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, |
||||
0x65, 0x64, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0xe7, 0x07, |
||||
0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, |
||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, |
||||
0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, |
||||
0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2a, 0x09, 0x08, 0xe8, 0x07, 0x10, |
||||
0x80, 0x80, 0x80, 0x80, 0x02, 0x22, 0x9e, 0x02, 0x0a, 0x13, 0x55, 0x6e, |
||||
0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, 0x74, 0x65, 0x64, 0x4f, |
||||
0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3b, 0x0a, 0x04, 0x6e, 0x61, 0x6d, |
||||
0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x67, 0x6f, |
||||
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, |
||||
0x66, 0x2e, 0x55, 0x6e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x70, 0x72, 0x65, |
||||
0x74, 0x65, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x4e, 0x61, |
||||
0x6d, 0x65, 0x50, 0x61, 0x72, 0x74, 0x12, 0x18, 0x0a, 0x10, 0x69, 0x64, |
||||
0x65, 0x6e, 0x74, 0x69, 0x66, 0x69, 0x65, 0x72, 0x5f, 0x76, 0x61, 0x6c, |
||||
0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x12, 0x1a, 0x0a, 0x12, |
||||
0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x74, |
||||
0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, |
||||
0x12, 0x1a, 0x0a, 0x12, 0x6e, 0x65, 0x67, 0x61, 0x74, 0x69, 0x76, 0x65, |
||||
0x5f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, |
||||
0x20, 0x01, 0x28, 0x03, 0x12, 0x14, 0x0a, 0x0c, 0x64, 0x6f, 0x75, 0x62, |
||||
0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, |
||||
0x28, 0x01, 0x12, 0x14, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, |
||||
0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, |
||||
0x12, 0x17, 0x0a, 0x0f, 0x61, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, |
||||
0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, |
||||
0x09, 0x1a, 0x33, 0x0a, 0x08, 0x4e, 0x61, 0x6d, 0x65, 0x50, 0x61, 0x72, |
||||
0x74, 0x12, 0x11, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x70, 0x61, |
||||
0x72, 0x74, 0x18, 0x01, 0x20, 0x02, 0x28, 0x09, 0x12, 0x14, 0x0a, 0x0c, |
||||
0x69, 0x73, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, |
||||
0x18, 0x02, 0x20, 0x02, 0x28, 0x08, 0x22, 0x7c, 0x0a, 0x0e, 0x53, 0x6f, |
||||
0x75, 0x72, 0x63, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, |
||||
0x12, 0x3a, 0x0a, 0x08, 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, |
||||
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x67, 0x6f, 0x6f, |
||||
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, |
||||
0x2e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x6f, 0x64, 0x65, 0x49, |
||||
0x6e, 0x66, 0x6f, 0x2e, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, |
||||
0x1a, 0x2e, 0x0a, 0x08, 0x4c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, |
||||
0x12, 0x10, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x03, |
||||
0x28, 0x05, 0x42, 0x02, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x04, 0x73, 0x70, |
||||
0x61, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x05, 0x42, 0x02, 0x10, 0x01, |
||||
0x42, 0x29, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x6f, 0x67, |
||||
0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x42, |
||||
0x10, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x50, |
||||
0x72, 0x6f, 0x74, 0x6f, 0x73, 0x48, 0x01 |
||||
}; |
||||
unsigned int descriptor_pb_len = 3931; |
@ -0,0 +1,328 @@ |
||||
/*
|
||||
* upb - a minimalist implementation of protocol buffers. |
||||
* |
||||
* Copyright (c) 2011 Joshua Haberman. See LICENSE for details. |
||||
*/ |
||||
|
||||
#include <stdlib.h> |
||||
#include "upb_stream.h" |
||||
|
||||
|
||||
/* upb_handlers ***************************************************************/ |
||||
|
||||
static upb_flow_t upb_startmsg_nop(void *closure) { |
||||
(void)closure; |
||||
return UPB_CONTINUE; |
||||
} |
||||
|
||||
static void upb_endmsg_nop(void *closure, upb_status *status) { |
||||
(void)closure; |
||||
(void)status; |
||||
} |
||||
|
||||
static upb_flow_t upb_value_nop(void *closure, upb_value fval, upb_value val) { |
||||
(void)closure; |
||||
(void)fval; |
||||
(void)val; |
||||
return UPB_CONTINUE; |
||||
} |
||||
|
||||
static upb_sflow_t upb_startsubmsg_nop(void *closure, upb_value fval) { |
||||
(void)fval; |
||||
return UPB_CONTINUE_WITH(closure); |
||||
} |
||||
|
||||
static upb_flow_t upb_endsubmsg_nop(void *closure, upb_value fval) { |
||||
(void)closure; |
||||
(void)fval; |
||||
return UPB_CONTINUE; |
||||
} |
||||
|
||||
static upb_flow_t upb_unknownval_nop(void *closure, upb_field_number_t fieldnum, |
||||
upb_value val) { |
||||
(void)closure; |
||||
(void)fieldnum; |
||||
(void)val; |
||||
return UPB_CONTINUE; |
||||
} |
||||
|
||||
static void upb_msgent_init(upb_handlers_msgent *e) { |
||||
upb_inttable_init(&e->fieldtab, 8, sizeof(upb_handlers_fieldent)); |
||||
e->startmsg = &upb_startmsg_nop; |
||||
e->endmsg = &upb_endmsg_nop; |
||||
e->unknownval = &upb_unknownval_nop; |
||||
} |
||||
|
||||
void upb_handlers_init(upb_handlers *h, upb_msgdef *md) { |
||||
h->msgs_len = 1; |
||||
h->msgs_size = 4; |
||||
h->msgs = malloc(h->msgs_size * sizeof(*h->msgs)); |
||||
h->top = &h->stack[0]; |
||||
h->limit = &h->stack[UPB_MAX_TYPE_DEPTH]; |
||||
h->toplevel_msgdef = md; |
||||
if (md) upb_msgdef_ref(md); |
||||
|
||||
h->top->msgent_index = 0; |
||||
h->top->msgdef = md; |
||||
h->msgent = &h->msgs[0]; |
||||
upb_msgent_init(h->msgent); |
||||
} |
||||
|
||||
void upb_handlers_uninit(upb_handlers *h) { |
||||
for (int i = 0; i < h->msgs_len; i++) upb_inttable_free(&h->msgs[i].fieldtab); |
||||
free(h->msgs); |
||||
upb_msgdef_unref(h->toplevel_msgdef); |
||||
} |
||||
|
||||
static upb_handlers_fieldent *upb_handlers_getorcreate_without_fval( |
||||
upb_handlers *h, upb_field_number_t fieldnum, upb_fieldtype_t type) { |
||||
upb_handlers_fieldent *f = |
||||
upb_inttable_lookup(&h->msgent->fieldtab, fieldnum); |
||||
if (!f) { |
||||
upb_wire_type_t native_wire_type = upb_types[type].native_wire_type; |
||||
upb_handlers_fieldent new_f = { |
||||
false, type, native_wire_type, -1, UPB_NO_VALUE, |
||||
{&upb_value_nop}, &upb_endsubmsg_nop}; |
||||
if (upb_issubmsgtype(type)) new_f.cb.startsubmsg = &upb_startsubmsg_nop; |
||||
upb_inttable_insert(&h->msgent->fieldtab, fieldnum, &new_f); |
||||
|
||||
f = upb_inttable_lookup(&h->msgent->fieldtab, fieldnum); |
||||
assert(f); |
||||
} |
||||
assert(f->type == type); |
||||
return f; |
||||
} |
||||
|
||||
static upb_handlers_fieldent *upb_handlers_getorcreate( |
||||
upb_handlers *h, upb_field_number_t fieldnum, |
||||
upb_fieldtype_t type, upb_value fval) { |
||||
upb_handlers_fieldent *f = |
||||
upb_handlers_getorcreate_without_fval(h, fieldnum, type); |
||||
f->fval = fval; |
||||
return f; |
||||
} |
||||
|
||||
void upb_register_startend(upb_handlers *h, upb_startmsg_handler_t startmsg, |
||||
upb_endmsg_handler_t endmsg) { |
||||
h->msgent->startmsg = startmsg ? startmsg : &upb_startmsg_nop; |
||||
h->msgent->endmsg = endmsg ? endmsg : &upb_endmsg_nop; |
||||
} |
||||
|
||||
// TODO:
|
||||
// void upb_register_unknownval(upb_handlers *h,
|
||||
// upb_unknownval_handler_t unknown);
|
||||
// bool upb_handlers_link(upb_handlers *h, upb_fielddef *f);
|
||||
// void upb_register_path_value(upb_handlers *h, const char *path,
|
||||
// upb_value_handler_t value, upb_value fval);
|
||||
|
||||
void upb_register_all(upb_handlers *h, upb_startmsg_handler_t start, |
||||
upb_endmsg_handler_t end, |
||||
upb_value_handler_t value, |
||||
upb_startsubmsg_handler_t startsubmsg, |
||||
upb_endsubmsg_handler_t endsubmsg, |
||||
upb_unknownval_handler_t unknown) { |
||||
upb_register_startend(h, start, end); |
||||
//upb_register_unknownval(h, unknown);
|
||||
upb_msgdef *m = h->top->msgdef; |
||||
upb_msg_iter i; |
||||
for(i = upb_msg_begin(m); !upb_msg_done(i); i = upb_msg_next(m, i)) { |
||||
upb_fielddef *f = upb_msg_iter_field(i); |
||||
upb_value fval; |
||||
upb_value_setfielddef(&fval, f); |
||||
if (upb_issubmsg(f)) { |
||||
upb_handlers_push(h, f, startsubmsg, endsubmsg, fval, false); |
||||
upb_register_all(h, start, end, value, startsubmsg, endsubmsg, unknown); |
||||
upb_handlers_pop(h, f); |
||||
} else { |
||||
upb_register_value(h, f, value, fval); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void upb_register_typed_value(upb_handlers *h, upb_field_number_t fieldnum, |
||||
upb_fieldtype_t type, upb_value_handler_t value, |
||||
upb_value fval) { |
||||
upb_handlers_getorcreate(h, fieldnum, type, fval)->cb.value = |
||||
value ? value : &upb_value_nop; |
||||
} |
||||
|
||||
void upb_register_value(upb_handlers *h, upb_fielddef *f, |
||||
upb_value_handler_t value, upb_value fval) { |
||||
assert(f->msgdef == h->top->msgdef); |
||||
upb_register_typed_value(h, f->number, f->type, value, fval); |
||||
} |
||||
|
||||
void upb_register_typed_submsg(upb_handlers *h, upb_field_number_t fieldnum, |
||||
upb_fieldtype_t type, |
||||
upb_startsubmsg_handler_t start, |
||||
upb_endsubmsg_handler_t end, |
||||
upb_value fval) { |
||||
upb_handlers_fieldent *f = upb_handlers_getorcreate(h, fieldnum, type, fval); |
||||
f->cb.startsubmsg = start ? start : &upb_startsubmsg_nop; |
||||
f->endsubmsg = end ? end : &upb_endsubmsg_nop; |
||||
} |
||||
|
||||
void upb_handlers_typed_link(upb_handlers *h, |
||||
upb_field_number_t fieldnum, |
||||
upb_fieldtype_t type, |
||||
int frames) { |
||||
assert(frames <= (h->top - h->stack)); |
||||
upb_handlers_fieldent *f = |
||||
upb_handlers_getorcreate_without_fval(h, fieldnum, type); |
||||
f->msgent_index = (h->top - frames)->msgent_index; |
||||
} |
||||
|
||||
void upb_handlers_typed_push(upb_handlers *h, upb_field_number_t fieldnum, |
||||
upb_fieldtype_t type) { |
||||
upb_handlers_fieldent *f = |
||||
upb_handlers_getorcreate_without_fval(h, fieldnum, type); |
||||
if (h->top == h->limit) abort(); // TODO: make growable.
|
||||
++h->top; |
||||
if (f->msgent_index == -1) { |
||||
// Need to push a new msgent.
|
||||
if (h->msgs_size == h->msgs_len) { |
||||
h->msgs_size *= 2; |
||||
h->msgs = realloc(h->msgs, h->msgs_size * sizeof(*h->msgs)); |
||||
} |
||||
f->msgent_index = h->msgs_len++; |
||||
h->msgent = &h->msgs[f->msgent_index]; |
||||
upb_msgent_init(h->msgent); |
||||
} else { |
||||
h->msgent = &h->msgs[f->msgent_index]; |
||||
} |
||||
h->top->msgent_index = f->msgent_index; |
||||
if (h->toplevel_msgdef) { |
||||
upb_fielddef *f = upb_msgdef_itof((h->top - 1)->msgdef, fieldnum); |
||||
assert(f); |
||||
h->top->msgdef = upb_downcast_msgdef(f->def); |
||||
} |
||||
} |
||||
|
||||
void upb_handlers_push(upb_handlers *h, upb_fielddef *f, |
||||
upb_startsubmsg_handler_t start, |
||||
upb_endsubmsg_handler_t end, upb_value fval, |
||||
bool delegate) { |
||||
assert(f->msgdef == h->top->msgdef); |
||||
(void)delegate; // TODO
|
||||
upb_register_typed_submsg(h, f->number, f->type, start, end, fval); |
||||
upb_handlers_typed_push(h, f->number, f->type); |
||||
} |
||||
|
||||
void upb_handlers_typed_pop(upb_handlers *h) { |
||||
assert(h->top > h->stack); |
||||
--h->top; |
||||
h->msgent = &h->msgs[h->top->msgent_index]; |
||||
} |
||||
|
||||
void upb_handlers_pop(upb_handlers *h, upb_fielddef *f) { |
||||
(void)f; // TODO: Check that this matches the corresponding push.
|
||||
upb_handlers_typed_pop(h); |
||||
} |
||||
|
||||
/* upb_dispatcher *************************************************************/ |
||||
|
||||
static upb_handlers_fieldent toplevel_f = { |
||||
false, 0, 0, 0, // The one value that is actually read
|
||||
#ifdef NDEBUG |
||||
{{0}}, |
||||
#else |
||||
{{0}, UPB_VALUETYPE_RAW}, |
||||
#endif |
||||
{NULL}, NULL}; |
||||
|
||||
void upb_dispatcher_init(upb_dispatcher *d, upb_handlers *h, |
||||
size_t top_end_offset) { |
||||
d->handlers = h; |
||||
for (int i = 0; i < h->msgs_len; i++) |
||||
upb_inttable_compact(&h->msgs[i].fieldtab); |
||||
d->stack[0].end_offset = top_end_offset; |
||||
d->stack[0].f = &toplevel_f; |
||||
upb_status_init(&d->status); |
||||
} |
||||
|
||||
void upb_dispatcher_reset(upb_dispatcher *d) { |
||||
d->msgent = &d->handlers->msgs[0]; |
||||
d->dispatch_table = &d->msgent->fieldtab; |
||||
d->current_depth = 0; |
||||
d->skip_depth = INT_MAX; |
||||
d->noframe_depth = INT_MAX; |
||||
d->delegated_depth = 0; |
||||
d->top = d->stack; |
||||
d->limit = &d->stack[UPB_MAX_NESTING]; |
||||
} |
||||
|
||||
void upb_dispatcher_uninit(upb_dispatcher *d) { |
||||
upb_status_uninit(&d->status); |
||||
} |
||||
|
||||
void upb_dispatcher_break(upb_dispatcher *d) { |
||||
assert(d->skip_depth == INT_MAX); |
||||
assert(d->noframe_depth == INT_MAX); |
||||
d->noframe_depth = d->current_depth; |
||||
} |
||||
|
||||
upb_flow_t upb_dispatch_startmsg(upb_dispatcher *d, void *closure) { |
||||
d->top->closure = closure; |
||||
upb_flow_t flow = d->msgent->startmsg(closure); |
||||
if (flow != UPB_CONTINUE) { |
||||
d->noframe_depth = d->current_depth + 1; |
||||
d->skip_depth = (flow == UPB_BREAK) ? d->delegated_depth : d->current_depth; |
||||
return UPB_SKIPSUBMSG; |
||||
} |
||||
return UPB_CONTINUE; |
||||
} |
||||
|
||||
void upb_dispatch_endmsg(upb_dispatcher *d, upb_status *status) { |
||||
assert(d->top == d->stack); |
||||
d->msgent->endmsg(d->top->closure, &d->status); |
||||
// TODO: should we avoid this copy by passing client's status obj to cbs?
|
||||
upb_copyerr(status, &d->status); |
||||
} |
||||
|
||||
upb_flow_t upb_dispatch_startsubmsg(upb_dispatcher *d, |
||||
upb_dispatcher_field *f, |
||||
size_t userval) { |
||||
++d->current_depth; |
||||
if (upb_dispatcher_skipping(d)) return UPB_SKIPSUBMSG; |
||||
upb_sflow_t sflow = f->cb.startsubmsg(d->top->closure, f->fval); |
||||
if (sflow.flow != UPB_CONTINUE) { |
||||
d->noframe_depth = d->current_depth; |
||||
d->skip_depth = (sflow.flow == UPB_BREAK) ? |
||||
d->delegated_depth : d->current_depth; |
||||
return UPB_SKIPSUBMSG; |
||||
} |
||||
|
||||
++d->top; |
||||
if(d->top >= d->limit) { |
||||
upb_seterr(&d->status, UPB_ERROR, "Nesting too deep."); |
||||
d->noframe_depth = d->current_depth; |
||||
d->skip_depth = d->delegated_depth; |
||||
return UPB_SKIPSUBMSG; |
||||
} |
||||
d->top->f = f; |
||||
d->top->end_offset = userval; |
||||
d->top->closure = sflow.closure; |
||||
d->msgent = upb_handlers_getmsgent(d->handlers, f); |
||||
d->dispatch_table = &d->msgent->fieldtab; |
||||
return upb_dispatch_startmsg(d, d->top->closure); |
||||
} |
||||
|
||||
upb_flow_t upb_dispatch_endsubmsg(upb_dispatcher *d) { |
||||
upb_flow_t flow; |
||||
if (upb_dispatcher_noframe(d)) { |
||||
flow = UPB_SKIPSUBMSG; |
||||
} else { |
||||
assert(d->top > d->stack); |
||||
upb_dispatcher_field *old_f = d->top->f; |
||||
d->msgent->endmsg(d->top->closure, &d->status); |
||||
--d->top; |
||||
d->msgent = upb_handlers_getmsgent(d->handlers, d->top->f); |
||||
d->dispatch_table = &d->msgent->fieldtab; |
||||
d->noframe_depth = INT_MAX; |
||||
if (!upb_dispatcher_skipping(d)) d->skip_depth = INT_MAX; |
||||
// Deliver like a regular value.
|
||||
flow = old_f->endsubmsg(d->top->closure, old_f->fval); |
||||
} |
||||
--d->current_depth; |
||||
return flow; |
||||
} |
@ -1,303 +0,0 @@ |
||||
/*
|
||||
* upb - a minimalist implementation of protocol buffers. |
||||
* |
||||
* vtable declarations for types that are implementing any of the src or sink |
||||
* interfaces. Only components that are implementing these interfaces need |
||||
* to worry about this file. |
||||
* |
||||
* Copyright (c) 2010 Joshua Haberman. See LICENSE for details. |
||||
*/ |
||||
|
||||
#ifndef UPB_SRCSINK_VTBL_H_ |
||||
#define UPB_SRCSINK_VTBL_H_ |
||||
|
||||
#include <assert.h> |
||||
#include "upb_stream.h" |
||||
#include "upb_string.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
// Typedefs for function pointers to all of the virtual functions.
|
||||
|
||||
// upb_src
|
||||
typedef void (*upb_src_sethandlers_fptr)(upb_src *src, upb_handlers *handlers); |
||||
typedef void (*upb_src_run_fptr)(upb_src *src, upb_status *status); |
||||
|
||||
// upb_bytesrc.
|
||||
typedef upb_strlen_t (*upb_bytesrc_read_fptr)( |
||||
upb_bytesrc *src, void *buf, upb_strlen_t count, upb_status *status); |
||||
typedef bool (*upb_bytesrc_getstr_fptr)( |
||||
upb_bytesrc *src, upb_string *str, upb_status *status); |
||||
|
||||
// upb_bytesink.
|
||||
typedef upb_strlen_t (*upb_bytesink_write_fptr)( |
||||
upb_bytesink *bytesink, void *buf, upb_strlen_t count); |
||||
typedef upb_strlen_t (*upb_bytesink_putstr_fptr)( |
||||
upb_bytesink *bytesink, upb_string *str, upb_status *status); |
||||
typedef upb_strlen_t (*upb_bytesink_vprintf_fptr)( |
||||
upb_bytesink *bytesink, upb_status *status, const char *fmt, va_list args); |
||||
|
||||
// Vtables for the above interfaces.
|
||||
typedef struct { |
||||
upb_bytesrc_read_fptr read; |
||||
upb_bytesrc_getstr_fptr getstr; |
||||
} upb_bytesrc_vtbl; |
||||
|
||||
typedef struct { |
||||
upb_bytesink_write_fptr write; |
||||
upb_bytesink_putstr_fptr putstr; |
||||
upb_bytesink_vprintf_fptr vprintf; |
||||
} upb_bytesink_vtbl; |
||||
|
||||
typedef struct { |
||||
upb_src_sethandlers_fptr sethandlers; |
||||
upb_src_run_fptr run; |
||||
} upb_src_vtbl; |
||||
|
||||
|
||||
// "Base Class" definitions; components that implement these interfaces should
|
||||
// contain one of these structures.
|
||||
|
||||
struct _upb_bytesrc { |
||||
upb_bytesrc_vtbl *vtbl; |
||||
}; |
||||
|
||||
struct _upb_bytesink { |
||||
upb_bytesink_vtbl *vtbl; |
||||
}; |
||||
|
||||
struct _upb_src { |
||||
upb_src_vtbl *vtbl; |
||||
}; |
||||
|
||||
INLINE void upb_bytesrc_init(upb_bytesrc *s, upb_bytesrc_vtbl *vtbl) { |
||||
s->vtbl = vtbl; |
||||
} |
||||
|
||||
INLINE void upb_bytesink_init(upb_bytesink *s, upb_bytesink_vtbl *vtbl) { |
||||
s->vtbl = vtbl; |
||||
} |
||||
|
||||
INLINE void upb_src_init(upb_src *s, upb_src_vtbl *vtbl) { |
||||
s->vtbl = vtbl; |
||||
} |
||||
|
||||
// Implementation of virtual function dispatch.
|
||||
|
||||
// upb_src
|
||||
INLINE void upb_src_sethandlers(upb_src *src, upb_handlers *handlers) { |
||||
src->vtbl->sethandlers(src, handlers); |
||||
} |
||||
|
||||
INLINE void upb_src_run(upb_src *src, upb_status *status) { |
||||
src->vtbl->run(src, status); |
||||
} |
||||
|
||||
// upb_bytesrc
|
||||
INLINE upb_strlen_t upb_bytesrc_read(upb_bytesrc *src, void *buf, |
||||
upb_strlen_t count, upb_status *status) { |
||||
return src->vtbl->read(src, buf, count, status); |
||||
} |
||||
|
||||
INLINE bool upb_bytesrc_getstr(upb_bytesrc *src, upb_string *str, |
||||
upb_status *status) { |
||||
return src->vtbl->getstr(src, str, status); |
||||
} |
||||
|
||||
INLINE bool upb_bytesrc_getfullstr(upb_bytesrc *src, upb_string *str, |
||||
upb_status *status) { |
||||
// We start with a getstr, because that could possibly alias data instead of
|
||||
// copying.
|
||||
if (!upb_bytesrc_getstr(src, str, status)) return false; |
||||
// Trade-off between number of read calls and amount of overallocation.
|
||||
const size_t bufsize = 4096; |
||||
do { |
||||
upb_strlen_t len = upb_string_len(str); |
||||
char *buf = upb_string_getrwbuf(str, len + bufsize); |
||||
upb_strlen_t read = upb_bytesrc_read(src, buf + len, bufsize, status); |
||||
if (read < 0) return false; |
||||
// Resize to proper size.
|
||||
upb_string_getrwbuf(str, len + read); |
||||
} while (!status->code != UPB_EOF); |
||||
return true; |
||||
} |
||||
|
||||
|
||||
// upb_bytesink
|
||||
INLINE upb_strlen_t upb_bytesink_write(upb_bytesink *sink, void *buf, |
||||
upb_strlen_t count) { |
||||
return sink->vtbl->write(sink, buf, count); |
||||
} |
||||
|
||||
INLINE upb_strlen_t upb_bytesink_putstr(upb_bytesink *sink, upb_string *str, upb_status *status) { |
||||
return sink->vtbl->putstr(sink, str, status); |
||||
} |
||||
|
||||
INLINE upb_strlen_t upb_bytesink_printf(upb_bytesink *sink, upb_status *status, const char *fmt, ...) { |
||||
va_list args; |
||||
va_start(args, fmt); |
||||
upb_strlen_t ret = sink->vtbl->vprintf(sink, status, fmt, args); |
||||
va_end(args); |
||||
return ret; |
||||
} |
||||
|
||||
// upb_handlers
|
||||
struct _upb_handlers { |
||||
upb_handlerset *set; |
||||
void *closure; |
||||
upb_status *status; // We don't own this.
|
||||
}; |
||||
|
||||
INLINE void upb_handlers_init(upb_handlers *h) { |
||||
(void)h; |
||||
} |
||||
INLINE void upb_handlers_uninit(upb_handlers *h) { |
||||
(void)h; |
||||
} |
||||
|
||||
INLINE void upb_handlers_reset(upb_handlers *h) { |
||||
h->set = NULL; |
||||
h->closure = NULL; |
||||
} |
||||
|
||||
INLINE bool upb_handlers_isempty(upb_handlers *h) { |
||||
return !h->set && !h->closure; |
||||
} |
||||
|
||||
INLINE upb_flow_t upb_nop(void *closure) { |
||||
(void)closure; |
||||
return UPB_CONTINUE; |
||||
} |
||||
|
||||
INLINE upb_flow_t upb_value_nop(void *closure, struct _upb_fielddef *f, upb_value val) { |
||||
(void)closure; |
||||
(void)f; |
||||
(void)val; |
||||
return UPB_CONTINUE; |
||||
} |
||||
|
||||
INLINE upb_flow_t upb_startsubmsg_nop(void *closure, struct _upb_fielddef *f, |
||||
upb_handlers *delegate_to) { |
||||
(void)closure; |
||||
(void)f; |
||||
(void)delegate_to; |
||||
return UPB_CONTINUE; |
||||
} |
||||
|
||||
INLINE upb_flow_t upb_endsubmsg_nop(void *closure, struct _upb_fielddef *f) { |
||||
(void)closure; |
||||
(void)f; |
||||
return UPB_CONTINUE; |
||||
} |
||||
|
||||
INLINE upb_flow_t upb_unknownval_nop(void *closure, upb_field_number_t fieldnum, |
||||
upb_value val) { |
||||
(void)closure; |
||||
(void)fieldnum; |
||||
(void)val; |
||||
return UPB_CONTINUE; |
||||
} |
||||
|
||||
INLINE void upb_register_handlerset(upb_handlers *h, upb_handlerset *set) { |
||||
if (!set->startmsg) set->startmsg = &upb_nop; |
||||
if (!set->endmsg) set->endmsg = &upb_nop; |
||||
if (!set->value) set->value = &upb_value_nop; |
||||
if (!set->startsubmsg) set->startsubmsg = &upb_startsubmsg_nop; |
||||
if (!set->endsubmsg) set->endsubmsg = &upb_endsubmsg_nop; |
||||
if (!set->unknownval) set->unknownval = &upb_unknownval_nop; |
||||
h->set = set; |
||||
} |
||||
|
||||
INLINE void upb_set_handler_closure(upb_handlers *h, void *closure, |
||||
upb_status *status) { |
||||
h->closure = closure; |
||||
h->status = status; |
||||
} |
||||
|
||||
// upb_dispatcher
|
||||
typedef struct { |
||||
upb_handlers handlers; |
||||
int depth; |
||||
} upb_dispatcher_frame; |
||||
|
||||
struct _upb_dispatcher { |
||||
upb_dispatcher_frame stack[UPB_MAX_NESTING], *top, *limit; |
||||
bool supports_skip; |
||||
}; |
||||
|
||||
INLINE void upb_dispatcher_init(upb_dispatcher *d) { |
||||
d->limit = d->stack + sizeof(d->stack); |
||||
} |
||||
|
||||
INLINE void upb_dispatcher_reset(upb_dispatcher *d, upb_handlers *h, |
||||
bool supports_skip) { |
||||
d->top = d->stack; |
||||
d->top->depth = 1; // Never want to trigger end-of-delegation.
|
||||
d->top->handlers = *h; |
||||
d->supports_skip = supports_skip; |
||||
} |
||||
|
||||
INLINE upb_flow_t upb_dispatch_startmsg(upb_dispatcher *d) { |
||||
assert(d->stack == d->top); |
||||
return d->top->handlers.set->startmsg(d->top->handlers.closure); |
||||
} |
||||
|
||||
INLINE upb_flow_t upb_dispatch_endmsg(upb_dispatcher *d) { |
||||
assert(d->stack == d->top); |
||||
return d->top->handlers.set->endmsg(d->top->handlers.closure); |
||||
} |
||||
|
||||
// TODO: several edge cases to fix:
|
||||
// - delegated start returns UPB_BREAK, should replay the start on resume.
|
||||
// - endsubmsg returns UPB_BREAK, should NOT replay the delegated endmsg.
|
||||
INLINE upb_flow_t upb_dispatch_startsubmsg(upb_dispatcher *d, |
||||
struct _upb_fielddef *f) { |
||||
upb_handlers handlers; |
||||
upb_handlers_init(&handlers); |
||||
upb_handlers_reset(&handlers); |
||||
upb_flow_t ret = d->top->handlers.set->startsubmsg(d->top->handlers.closure, f, &handlers); |
||||
assert((ret == UPB_DELEGATE) == !upb_handlers_isempty(&handlers)); |
||||
if (ret == UPB_DELEGATE) { |
||||
++d->top; |
||||
d->top->handlers = handlers; |
||||
d->top->depth = 0; |
||||
ret = d->top->handlers.set->startmsg(d->top->handlers.closure); |
||||
} |
||||
if (ret == UPB_CONTINUE || !d->supports_skip) ++d->top->depth; |
||||
upb_handlers_uninit(&handlers); |
||||
return ret; |
||||
} |
||||
|
||||
INLINE upb_flow_t upb_dispatch_endsubmsg(upb_dispatcher *d, |
||||
struct _upb_fielddef *f) { |
||||
upb_flow_t ret; |
||||
if (--d->top->depth == 0) { |
||||
ret = d->top->handlers.set->endmsg(d->top->handlers.closure); |
||||
//assert(ret != UPB_BREAK);
|
||||
if (ret != UPB_CONTINUE) return ret; |
||||
--d->top; |
||||
assert(d->top >= d->stack); |
||||
} |
||||
return d->top->handlers.set->endsubmsg(d->top->handlers.closure, f); |
||||
} |
||||
|
||||
INLINE upb_flow_t upb_dispatch_value(upb_dispatcher *d, |
||||
struct _upb_fielddef *f, |
||||
upb_value val) { |
||||
return d->top->handlers.set->value(d->top->handlers.closure, f, val); |
||||
} |
||||
|
||||
INLINE upb_flow_t upb_dispatch_unknownval(upb_dispatcher *d, |
||||
upb_field_number_t fieldnum, |
||||
upb_value val) { |
||||
return d->top->handlers.set->unknownval(d->top->handlers.closure, |
||||
fieldnum, val); |
||||
} |
||||
|
||||
#ifdef __cplusplus |
||||
} /* extern "C" */ |
||||
#endif |
||||
|
||||
#endif |
Loading…
Reference in new issue