Protocol Buffers - Google's data interchange format (grpc依赖)
https://developers.google.com/protocol-buffers/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
126 lines
3.3 KiB
126 lines
3.3 KiB
// These are the specialized field parser functions for the fast parser. |
|
// Generated tables will refer to these by name. |
|
// |
|
// The function names are encoded with names like: |
|
// |
|
// // 123 4 |
|
// upb_pss_1bt(); // Parse singular string, 1 byte tag. |
|
// |
|
// In position 1: |
|
// - 'p' for parse, most function use this |
|
// - 'c' for copy, for when we are copying strings instead of aliasing |
|
// |
|
// In position 2 (cardinality): |
|
// - 's' for singular, with or without hasbit |
|
// - 'o' for oneof |
|
// - 'r' for non-packed repeated |
|
// - 'p' for packed repeated |
|
// |
|
// In position 3 (type): |
|
// - 'b1' for bool |
|
// - 'v4' for 4-byte varint |
|
// - 'v8' for 8-byte varint |
|
// - 'z4' for zig-zag-encoded 4-byte varint |
|
// - 'z8' for zig-zag-encoded 8-byte varint |
|
// - 'f4' for 4-byte fixed |
|
// - 'f8' for 8-byte fixed |
|
// - 'm' for sub-message |
|
// - 's' for string (validate UTF-8) |
|
// - 'b' for bytes |
|
// |
|
// In position 4 (tag length): |
|
// - '1' for one-byte tags (field numbers 1-15) |
|
// - '2' for two-byte tags (field numbers 16-2048) |
|
|
|
#ifndef UPB_DECODE_FAST_H_ |
|
#define UPB_DECODE_FAST_H_ |
|
|
|
#include "upb/msg.h" |
|
|
|
struct upb_decstate; |
|
|
|
// The fallback, generic parsing function that can handle any field type. |
|
// This just uses the regular (non-fast) parser to parse a single field. |
|
const char *fastdecode_generic(struct upb_decstate *d, const char *ptr, |
|
upb_msg *msg, intptr_t table, uint64_t hasbits, |
|
uint64_t data); |
|
|
|
#define UPB_PARSE_PARAMS \ |
|
struct upb_decstate *d, const char *ptr, upb_msg *msg, intptr_t table, \ |
|
uint64_t hasbits, uint64_t data |
|
|
|
/* primitive fields ***********************************************************/ |
|
|
|
#define F(card, type, valbytes, tagbytes) \ |
|
const char *upb_p##card##type##valbytes##_##tagbytes##bt(UPB_PARSE_PARAMS); |
|
|
|
#define TYPES(card, tagbytes) \ |
|
F(card, b, 1, tagbytes) \ |
|
F(card, v, 4, tagbytes) \ |
|
F(card, v, 8, tagbytes) \ |
|
F(card, z, 4, tagbytes) \ |
|
F(card, z, 8, tagbytes) \ |
|
F(card, f, 4, tagbytes) \ |
|
F(card, f, 8, tagbytes) |
|
|
|
#define TAGBYTES(card) \ |
|
TYPES(card, 1) \ |
|
TYPES(card, 2) |
|
|
|
TAGBYTES(s) |
|
TAGBYTES(o) |
|
TAGBYTES(r) |
|
TAGBYTES(p) |
|
|
|
#undef F |
|
#undef TYPES |
|
#undef TAGBYTES |
|
|
|
/* string fields **************************************************************/ |
|
|
|
#define F(card, tagbytes, type) \ |
|
const char *upb_p##card##type##_##tagbytes##bt(UPB_PARSE_PARAMS); \ |
|
const char *upb_c##card##type##_##tagbytes##bt(UPB_PARSE_PARAMS); |
|
|
|
#define UTF8(card, tagbytes) \ |
|
F(card, tagbytes, s) \ |
|
F(card, tagbytes, b) |
|
|
|
#define TAGBYTES(card) \ |
|
UTF8(card, 1) \ |
|
UTF8(card, 2) |
|
|
|
TAGBYTES(s) |
|
TAGBYTES(o) |
|
TAGBYTES(r) |
|
|
|
#undef F |
|
#undef TAGBYTES |
|
|
|
/* sub-message fields *********************************************************/ |
|
|
|
#define F(card, tagbytes, size_ceil, ceil_arg) \ |
|
const char *upb_p##card##m_##tagbytes##bt_max##size_ceil##b(UPB_PARSE_PARAMS); |
|
|
|
#define SIZES(card, tagbytes) \ |
|
F(card, tagbytes, 64, 64) \ |
|
F(card, tagbytes, 128, 128) \ |
|
F(card, tagbytes, 192, 192) \ |
|
F(card, tagbytes, 256, 256) \ |
|
F(card, tagbytes, max, -1) |
|
|
|
#define TAGBYTES(card) \ |
|
SIZES(card, 1) \ |
|
SIZES(card, 2) |
|
|
|
TAGBYTES(s) |
|
TAGBYTES(o) |
|
TAGBYTES(r) |
|
|
|
#undef TAGBYTES |
|
#undef SIZES |
|
#undef F |
|
|
|
#undef UPB_PARSE_PARAMS |
|
|
|
#endif /* UPB_DECODE_FAST_H_ */
|
|
|