Esempio n. 1
0
File: handlers.c Progetto: YauzZ/upb
static int32_t trygetsel(upb_handlers *h, const upb_fielddef *f,
                         upb_handlertype_t type) {
  upb_selector_t sel;
  assert(!upb_handlers_isfrozen(h));
  if (upb_handlers_msgdef(h) != upb_fielddef_containingtype(f)) {
    upb_status_seterrf(
        &h->status_, "type mismatch: field %s does not belong to message %s",
        upb_fielddef_name(f), upb_msgdef_fullname(upb_handlers_msgdef(h)));
    return -1;
  }
  if (!upb_handlers_getselector(f, type, &sel)) {
    upb_status_seterrf(
        &h->status_,
        "type mismatch: cannot register handler type %d for field %s",
        type, upb_fielddef_name(f));
    return -1;
  }
  return sel;
}
Esempio n. 2
0
static upb_selector_t getsel(const upb_fielddef *f, upb_handlertype_t type) {
    upb_selector_t ret;
    bool ok = upb_handlers_getselector(f, type, &ret);
    UPB_ASSERT_VAR(ok, ok);
    return ret;
}