Пример #1
0
Файл: upb.c Проект: chenbk85/upb
static upb_sflow_t PyUpb_Message_StartSubmessage(void *m, upb_value fval) {
  PyObject **submsg = PyUpb_Accessor_GetPtr(m, fval);
  PyTypeObject *type = Py_TYPE(m);
  if (!*submsg) *submsg = type->tp_alloc(type, 0);
  upb_stdmsg_sethas(m, fval);
  return UPB_CONTINUE_WITH(*submsg);
}
Пример #2
0
Файл: upb.c Проект: chenbk85/upb
static upb_sflow_t PyUpb_Message_StartSequence(void *m, upb_value fval) {
  PyObject **seq = PyUpb_Accessor_GetPtr(m, fval);
  PyTypeObject *type = ((PyUpb_MessageType*)Py_TYPE(m))->alt_type;
  if (!*seq) *seq = type->tp_alloc(type, 0);
  upb_stdmsg_sethas(m, fval);
  return UPB_CONTINUE_WITH(*seq);
}
Пример #3
0
Файл: upb.c Проект: chenbk85/upb
static upb_flow_t PyUpb_Message_StringValue(
    void *m, upb_value fval, upb_value val) {
  PyObject **str = PyUpb_Accessor_GetPtr(m, fval);
  if (*str) { Py_DECREF(*str); }
  *str = PyString_FromStringAndSize(NULL, upb_value_getstrref(val)->len);
  upb_strref_read(upb_value_getstrref(val), PyString_AsString(*str));
  upb_stdmsg_sethas(m, fval);
  return UPB_CONTINUE;
}
Пример #4
0
upb_sflow_t upb_stdmsg_startsubmsg(void *_m, upb_value fval) {
  assert(_m != NULL);
  char *m = _m;
  const upb_fielddef *f = upb_value_getfielddef(fval);
  void **subm = (void*)&m[f->offset];
  if (!upb_stdmsg_has(m, fval)) {
    upb_stdmsg_recycle(subm, upb_downcast_msgdef(f->def));
    upb_stdmsg_sethas(m, fval);
  }
  return UPB_CONTINUE_WITH(*subm);
}
Пример #5
0
upb_sflow_t upb_stdmsg_startseq(void *_m, upb_value fval) {
  char *m = _m;
  const upb_fielddef *f = upb_value_getfielddef(fval);
  upb_stdarray **arr = (void*)&m[f->offset];
  if (!upb_stdmsg_has(_m, fval)) {
    if (!*arr) {
      *arr = malloc(sizeof(**arr));
      (*arr)->size = 0;
      (*arr)->ptr = NULL;
    }
    (*arr)->len = 0;
    upb_stdmsg_sethas(m, fval);
  }
  return UPB_CONTINUE_WITH(*arr);
}