summaryrefslogtreecommitdiff
path: root/upb/shim
diff options
context:
space:
mode:
Diffstat (limited to 'upb/shim')
-rw-r--r--upb/shim/shim.c28
-rw-r--r--upb/shim/shim.h16
2 files changed, 28 insertions, 16 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);
}
diff --git a/upb/shim/shim.h b/upb/shim/shim.h
index 98310d7..bc47bbb 100644
--- a/upb/shim/shim.h
+++ b/upb/shim/shim.h
@@ -37,9 +37,10 @@ struct Shim {
// true if the handler was set successfully.
static bool Set(Handlers *h, const FieldDef *f, size_t ofs, int32_t hasbit);
- // If this handler is a shim, returns the corresponding upb::Shim::Data.
- // Otherwise returns NULL.
- static const Data* GetData(const Handlers* h, Handlers::Selector s);
+ // If this handler is a shim, returns the corresponding upb::Shim::Data and
+ // stores the type in "type". Otherwise returns NULL.
+ static const Data* GetData(const Handlers* h, Handlers::Selector s,
+ FieldDef::Type* type);
};
} // namespace upb
@@ -50,7 +51,8 @@ extern "C" {
// C API.
bool upb_shim_set(upb_handlers *h, const upb_fielddef *f, size_t offset,
int32_t hasbit);
-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);
#ifdef __cplusplus
} // extern "C"
@@ -62,9 +64,9 @@ inline bool Shim::Set(Handlers* h, const FieldDef* f, size_t ofs,
int32_t hasbit) {
return upb_shim_set(h, f, ofs, hasbit);
}
-inline const Shim::Data* Shim::GetData(const Handlers* h,
- Handlers::Selector s) {
- return upb_shim_getdata(h, s);
+inline const Shim::Data* Shim::GetData(const Handlers* h, Handlers::Selector s,
+ FieldDef::Type* type) {
+ return upb_shim_getdata(h, s, type);
}
} // namespace
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback