Pass pointer to tag instead of by value.

pull/13171/head
Joshua Haberman 16 years ago
parent cbc05553c9
commit d7632d271c
  1. 6
      src/upb_msg.c
  2. 10
      src/upb_parse.h

@ -247,12 +247,12 @@ void upb_msg_reuse_submsg(void **msg, struct upb_msg *m)
/* Serialization/Deserialization. ********************************************/ /* Serialization/Deserialization. ********************************************/
static upb_field_type_t tag_cb(void *udata, struct upb_tag tag, static upb_field_type_t tag_cb(void *udata, struct upb_tag *tag,
void **user_field_desc) void **user_field_desc)
{ {
struct upb_msg_parse_state *s = udata; struct upb_msg_parse_state *s = udata;
struct upb_msg_field *f = upb_msg_fieldbynum(s->top->m, tag.field_number); struct upb_msg_field *f = upb_msg_fieldbynum(s->top->m, tag->field_number);
if(!f || !upb_check_type(tag.wire_type, f->type)) if(!f || !upb_check_type(tag->wire_type, f->type))
return 0; /* Skip unknown or fields of the wrong type. */ return 0; /* Skip unknown or fields of the wrong type. */
*user_field_desc = f; *user_field_desc = f;
return f->type; return f->type;

@ -87,7 +87,7 @@ void upb_parse_free(struct upb_parse_state *state);
* skipping all submessages, in the case of a submessage), the callback should * skipping all submessages, in the case of a submessage), the callback should
* return zero. */ * return zero. */
typedef upb_field_type_t (*upb_tag_cb)(void *udata, typedef upb_field_type_t (*upb_tag_cb)(void *udata,
struct upb_tag tag, struct upb_tag *tag,
void **user_field_desc); void **user_field_desc);
/* The callback that is called when a regular value (ie. not a string or /* The callback that is called when a regular value (ie. not a string or
@ -133,13 +133,9 @@ upb_status_t upb_parse(struct upb_parse_state *s, void *buf, size_t len,
extern upb_wire_type_t upb_expected_wire_types[]; extern upb_wire_type_t upb_expected_wire_types[];
/* Returns true if wt is the correct on-the-wire type for ft. */ /* Returns true if wt is the correct on-the-wire type for ft. */
INLINE bool upb_check_type(upb_wire_type_t wt, upb_field_type_t ft) { INLINE bool upb_check_type(upb_wire_type_t wt, upb_field_type_t ft) {
if(ft == 10) { // GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_GROUP)
return wt == UPB_WIRE_TYPE_START_GROUP;
} else {
/* With packed arrays, anything can be delimited (except groups). */ /* With packed arrays, anything can be delimited (except groups). */
return wt == UPB_WIRE_TYPE_DELIMITED || return (wt == UPB_WIRE_TYPE_DELIMITED) || upb_type_info[ft].expected_wire_type == wt;
upb_type_info[ft].expected_wire_type == wt; ; // && ft != GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_GROUP );
}
} }
/* Data-consuming functions (to be called from value cb). *********************/ /* Data-consuming functions (to be called from value cb). *********************/

Loading…
Cancel
Save