diff options
author | Josh Haberman <haberman@google.com> | 2013-02-15 16:27:18 -0800 |
---|---|---|
committer | Josh Haberman <haberman@google.com> | 2013-02-15 16:27:18 -0800 |
commit | 7d3e2bd2c4cfd1296d1d6f996d7548de26540d41 (patch) | |
tree | b4b35967b3322c65cfb1a32220e8718de09d85fc /upb/msg.c | |
parent | ea198bdcf947ba4bd51474bdd4f7b82b5e4cf41d (diff) |
Sync with 8 months of Google-internal development.
Many things have changed and been simplified.
The memory-management story for upb_def and upb_handlers
is much more robust; upb_def and upb_handlers should be
fairly stable interfaces now. There is still much work
to do for the runtime component (upb_sink).
Diffstat (limited to 'upb/msg.c')
-rw-r--r-- | upb/msg.c | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/upb/msg.c b/upb/msg.c deleted file mode 100644 index c671b7b..0000000 --- a/upb/msg.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * upb - a minimalist implementation of protocol buffers. - * - * Copyright (c) 2010 Google Inc. See LICENSE for details. - * Author: Josh Haberman <jhaberman@gmail.com> - * - */ - -#include "upb/upb.h" -#include "upb/msg.h" - -#define UPB_ACCESSOR(type, ctype) \ - upb_flow_t upb_stdmsg_set ## type (void *_m, upb_value fval, \ - upb_value val) { \ - assert(_m != NULL); \ - const upb_fielddef *f = upb_value_getfielddef(fval); \ - uint8_t *m = _m; \ - /* Hasbit is set automatically by the handlers. */ \ - *(ctype*)&m[f->offset] = upb_value_get ## type(val); \ - return UPB_CONTINUE; \ - } \ - -UPB_ACCESSOR(double, double) -UPB_ACCESSOR(float, float) -UPB_ACCESSOR(int32, int32_t) -UPB_ACCESSOR(int64, int64_t) -UPB_ACCESSOR(uint32, uint32_t) -UPB_ACCESSOR(uint64, uint64_t) -UPB_ACCESSOR(bool, bool) -UPB_ACCESSOR(ptr, void*) -#undef UPB_ACCESSORS - -static void upb_accessors_onfreg(void *c, upb_fhandlers *fh, - const upb_fielddef *f) { - (void)c; - if (f->accessor) { - upb_fhandlers_setfval(fh, f->fval); - if (upb_isseq(f)) { - upb_fhandlers_setstartseq(fh, f->accessor->startseq); - upb_fhandlers_setvalue(fh, f->accessor->append); - upb_fhandlers_setstartsubmsg(fh, f->accessor->appendsubmsg); - } else { - upb_fhandlers_setvalue(fh, f->accessor->set); - upb_fhandlers_setstartsubmsg(fh, f->accessor->startsubmsg); - upb_fhandlers_sethasbit(fh, f->hasbit); - } - } -} - -upb_mhandlers *upb_accessors_reghandlers(upb_handlers *h, const upb_msgdef *m) { - return upb_handlers_regmsgdef(h, m, NULL, &upb_accessors_onfreg, NULL); -} |