From 26d98ca94f2f049e8767b4a9a33d185a3d7ea0fd Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Thu, 24 Oct 2013 12:43:19 -0700 Subject: 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. --- upb/shim/shim.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'upb/shim/shim.c') 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); } -- cgit v1.2.3