third_party/upb/upb/json/parser.c
static bool handle_mapentry(upb_json_parser *p) {
  const upb_fielddef *mapfield;
  const upb_msgdef *mapentrymsg;
  upb_jsonparser_frame *inner;
  upb_selector_t sel;

  /* Map entry: p->top->sink is the seq frame, so we need to start a frame
   * for the mapentry itself, and then set |f| in that frame so that the map
   * value field is parsed, and also set a flag to end the frame after the
   * map-entry value is parsed. */
  if (!check_stack(p)) return false;

  mapfield = p->top->mapfield;
  mapentrymsg = upb_fielddef_msgsubdef(mapfield);

  inner = p->top + 1;
  p->top->f = mapfield;
  sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSUBMSG);
  upb_sink_startsubmsg(&p->top->sink, sel, &inner->sink);
  inner->m = mapentrymsg;
  inner->name_table = NULL;
  inner->mapfield = mapfield;
  inner->is_map = false;
  inner->is_unknown_field = false;

  /* Don't set this to true *yet* -- we reuse parsing handlers below to push
   * the key field value to the sink, and these handlers will pop the frame
   * if they see is_mapentry (when invoked by the parser state machine, they
   * would have just seen the map-entry value, not key). */
  inner->is_mapentry = false;
  p->top = inner;

  /* send STARTMSG in submsg frame. */
  upb_sink_startmsg(&p->top->sink);

  parse_mapentry_key(p);

  /* Set up the value field to receive the map-entry value. */
  p->top->f = upb_msgdef_itof(p->top->m, UPB_MAPENTRY_VALUE);
  p->top->is_mapentry = true;  /* set up to pop frame after value is parsed. */
  p->top->mapfield = mapfield;
  if (p->top->f == NULL) {
    upb_status_seterrmsg(&p->status, "mapentry message has no value");
    upb_env_reporterror(p->env, &p->status);
    return false;
  }

  return true;
}
/* Helper: emit one map entry (as a submessage in the map field sequence). This
 * is invoked from end_membername(), at the end of the map entry's key string,
 * with the map key in the accumulate buffer. It parses the key from that
 * buffer, emits the handler calls to start the mapentry submessage (setting up
 * its subframe in the process), and sets up state in the subframe so that the
 * value parser (invoked next) will emit the mapentry's value field and then
 * end the mapentry message. */
emit one map entry (as a submessage in the map field sequence). This
is invoked from end_membername(), at the end of the map entry's key string,
with the map key in the accumulate buffer. It parses the key from that
buffer, emits the handler calls to start the mapentry submessage (setting up
its subframe in the process), and sets up state in the subframe so that the
value parser (invoked next) will emit the mapentry's value field and then
end the mapentry message.
emit one map entry ( as a submessage in the map field sequence ) . This is invoked from end_membername () at the end of the map entry ' s key string with the map key in the accumulate buffer . It parses the key from that buffer emits the handler calls to start the mapentry submessage ( setting up its subframe in the process ) and sets up state in the subframe so that the value parser ( invoked next ) will emit the mapentry ' s value field and then end the mapentry message .
static bool handle_mapentry(upb_json_parser *p) {
  const upb_fielddef *mapfield;
  const upb_msgdef *mapentrymsg;
  upb_jsonparser_frame *inner;
  upb_selector_t sel;
  if (!check_stack(p)) return false;
  mapfield = p->top->mapfield;
  mapentrymsg = upb_fielddef_msgsubdef(mapfield);
  inner = p->top + 1;
  p->top->f = mapfield;
  sel = getsel_for_handlertype(p, UPB_HANDLER_STARTSUBMSG);
  upb_sink_startsubmsg(&p->top->sink, sel, &inner->sink);
  inner->m = mapentrymsg;
  inner->name_table = NULL;
  inner->mapfield = mapfield;
  inner->is_map = false;
  inner->is_unknown_field = false;
  inner->is_mapentry = false;
  p->top = inner;
  upb_sink_startmsg(&p->top->sink);
  parse_mapentry_key(p);
  p->top->f = upb_msgdef_itof(p->top->m, UPB_MAPENTRY_VALUE);
  p->top->is_mapentry = true;  
  p->top->mapfield = mapfield;
  if (p->top->f == NULL) {
    upb_status_seterrmsg(&p->status, "mapentry message has no value");
    upb_env_reporterror(p->env, &p->status);
    return false;
  }
  return true;
}
static bool handle_mapentry ( upb_json_parser * p ) { const upb_fielddef * mapfield ; const upb_msgdef * mapentrymsg ; upb_jsonparser_frame * inner ; upb_selector_t sel ; if ( ! check_stack ( p ) ) return false ; mapfield = p -> top -> mapfield ; mapentrymsg = upb_fielddef_msgsubdef ( mapfield ) ; inner = p -> top + 1 ; p -> top -> f = mapfield ; sel = getsel_for_handlertype ( p , UPB_HANDLER_STARTSUBMSG ) ; upb_sink_startsubmsg ( & p -> top -> sink , sel , & inner -> sink ) ; inner -> m = mapentrymsg ; inner -> name_table = NULL ; inner -> mapfield = mapfield ; inner -> is_map = false ; inner -> is_unknown_field = false ; inner -> is_mapentry = false ; p -> top = inner ; upb_sink_startmsg ( & p -> top -> sink ) ; parse_mapentry_key ( p ) ; p -> top -> f = upb_msgdef_itof ( p -> top -> m , UPB_MAPENTRY_VALUE ) ; p -> top -> is_mapentry = true ; p -> top -> mapfield = mapfield ; if ( p -> top -> f == NULL ) { upb_status_seterrmsg ( & p -> status , " " ) ; upb_env_reporterror ( p -> env , & p -> status ) ; return false ; } return true ; }
Helper: emit one map entry (as a submessage in the map field sequence).
Helper : emit one map entry ( as a submessage in the map field sequence ) .
/* Map entry: p->top->sink is the seq frame, so we need to start a frame
   * for the mapentry itself, and then set |f| in that frame so that the map
   * value field is parsed, and also set a flag to end the frame after the
   * map-entry value is parsed. */ /* Don't set this to true *yet* -- we reuse parsing handlers below to push
   * the key field value to the sink, and these handlers will pop the frame
   * if they see is_mapentry (when invoked by the parser state machine, they
   * would have just seen the map-entry value, not key). */ /* send STARTMSG in submsg frame. */ /* Set up the value field to receive the map-entry value. */ /* set up to pop frame after value is parsed. */