diff options
author | Josh Haberman <jhaberman@gmail.com> | 2013-10-24 12:43:19 -0700 |
---|---|---|
committer | Josh Haberman <jhaberman@gmail.com> | 2013-10-24 12:43:19 -0700 |
commit | 26d98ca94f2f049e8767b4a9a33d185a3d7ea0fd (patch) | |
tree | 340bcf495f06ed05c9f3fb423f210caf4edce2b1 /upb/shim/shim.c | |
parent | 61109fca1f967771c21dc7184aee35f3b439c577 (diff) |
Merge from Google-internal development:
- rewritten decoder; interpreted decoder is bytecode-based,
JIT decoder no longer falls back to the interpreter.
- C++ improvements: C++11-compatible iterators, upb::reffed_ptr
for RAII refcounting, better upcast/downcast support.
- removed the gross upb_value abstraction from public upb.h.
Diffstat (limited to 'upb/shim/shim.c')
-rw-r--r-- | upb/shim/shim.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/upb/shim/shim.c b/upb/shim/shim.c index 6a79ac0..a249e84 100644 --- a/upb/shim/shim.c +++ b/upb/shim/shim.c @@ -53,17 +53,27 @@ bool upb_shim_set(upb_handlers *h, const upb_fielddef *f, size_t offset, #undef TYPE } -const upb_shim_data *upb_shim_getdata(const upb_handlers *h, upb_selector_t s) { +const upb_shim_data *upb_shim_getdata(const upb_handlers *h, upb_selector_t s, + upb_fieldtype_t *type) { upb_func *f = upb_handlers_gethandler(h, s); - if ((upb_int64_handler*)f == upb_shim_setint64 || - (upb_int32_handler*)f == upb_shim_setint32 || - (upb_uint64_handler*)f == upb_shim_setuint64 || - (upb_uint32_handler*)f == upb_shim_setuint32 || - (upb_double_handler*)f == upb_shim_setdouble || - (upb_float_handler*)f == upb_shim_setfloat || - (upb_bool_handler*)f == upb_shim_setbool) { - return (const upb_shim_data*)upb_handlers_gethandlerdata(h, s); + + if ((upb_int64_handler*)f == upb_shim_setint64) { + *type = UPB_TYPE_INT64; + } else if ((upb_int32_handler*)f == upb_shim_setint32) { + *type = UPB_TYPE_INT32; + } else if ((upb_uint64_handler*)f == upb_shim_setuint64) { + *type = UPB_TYPE_UINT64; + } else if ((upb_uint32_handler*)f == upb_shim_setuint32) { + *type = UPB_TYPE_UINT32; + } else if ((upb_double_handler*)f == upb_shim_setdouble) { + *type = UPB_TYPE_DOUBLE; + } else if ((upb_float_handler*)f == upb_shim_setfloat) { + *type = UPB_TYPE_FLOAT; + } else if ((upb_bool_handler*)f == upb_shim_setbool) { + *type = UPB_TYPE_BOOL; } else { return NULL; } + + return (const upb_shim_data*)upb_handlers_gethandlerdata(h, s); } |