summaryrefslogtreecommitdiff
path: root/upb/table.int.h
diff options
context:
space:
mode:
authorBo Yang <teboring@google.com>2018-06-14 20:03:20 +0000
committerBo Yang <teboring@google.com>2018-06-14 20:03:20 +0000
commit1080117f2b64a7a9f00fca65365c04762c2e915b (patch)
treea7a59c1c0831c0a76a35762f1aedfc646fb58732 /upb/table.int.h
parentd73b12ed3c475aca7fa306d739df5ff4c6728a32 (diff)
Revert "Prepare upb_value for encoding/decoding map."
This reverts commit f30dd0ff0cead9bb1f8f3b1b295392d75705486b.
Diffstat (limited to 'upb/table.int.h')
-rw-r--r--upb/table.int.h43
1 files changed, 25 insertions, 18 deletions
diff --git a/upb/table.int.h b/upb/table.int.h
index 610e3bc..225235e 100644
--- a/upb/table.int.h
+++ b/upb/table.int.h
@@ -24,6 +24,10 @@
#include <string.h>
#include "upb/upb.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* upb_value ******************************************************************/
@@ -45,7 +49,7 @@ typedef enum {
} upb_ctype_t;
typedef struct {
- upb_msgval val;
+ uint64_t val;
#ifndef NDEBUG
/* In debug mode we carry the value type around also so we can check accesses
* to be sure the right member is being read. */
@@ -69,13 +73,13 @@ UPB_INLINE char *upb_gstrdup(const char *s) {
return upb_strdup(s, &upb_alloc_global);
}
-UPB_INLINE void _upb_value_setval(upb_value *v, upb_msgval val,
+UPB_INLINE void _upb_value_setval(upb_value *v, uint64_t val,
upb_ctype_t ctype) {
v->val = val;
SET_TYPE(v->ctype, ctype);
}
-UPB_INLINE upb_value _upb_value_val(upb_msgval val, upb_ctype_t ctype) {
+UPB_INLINE upb_value _upb_value_val(uint64_t val, upb_ctype_t ctype) {
upb_value ret;
_upb_value_setval(&ret, val, ctype);
return ret;
@@ -91,7 +95,7 @@ UPB_INLINE upb_value _upb_value_val(upb_msgval val, upb_ctype_t ctype) {
* upb_value upb_value_int32(int32_t val); */
#define FUNCS(name, membername, type_t, converter, proto_type) \
UPB_INLINE void upb_value_set ## name(upb_value *val, type_t cval) { \
- val->val = upb_msgval_ ## converter(cval); \
+ val->val = (converter)cval; \
SET_TYPE(val->ctype, proto_type); \
} \
UPB_INLINE upb_value upb_value_ ## name(type_t val) { \
@@ -101,18 +105,18 @@ UPB_INLINE upb_value _upb_value_val(upb_msgval val, upb_ctype_t ctype) {
} \
UPB_INLINE type_t upb_value_get ## name(upb_value val) { \
UPB_ASSERT_DEBUGVAR(val.ctype == proto_type); \
- return (type_t)upb_msgval_get ## converter(val.val); \
+ return (type_t)(converter)val.val; \
}
-FUNCS(int32, int32, int32_t, int32, UPB_CTYPE_INT32)
-FUNCS(int64, int64, int64_t, int64, UPB_CTYPE_INT64)
-FUNCS(uint32, uint32, uint32_t, uint32, UPB_CTYPE_UINT32)
-FUNCS(uint64, uint64, uint64_t, uint64, UPB_CTYPE_UINT64)
-FUNCS(bool, _bool, bool, bool, UPB_CTYPE_BOOL)
-FUNCS(cstr, cstr, char*, cstr, UPB_CTYPE_CSTR)
-FUNCS(ptr, ptr, void*, ptr, UPB_CTYPE_PTR)
-FUNCS(constptr, constptr, const void*, constptr, UPB_CTYPE_CONSTPTR)
-FUNCS(fptr, fptr, upb_func*, fptr, UPB_CTYPE_FPTR)
+FUNCS(int32, int32, int32_t, int32_t, UPB_CTYPE_INT32)
+FUNCS(int64, int64, int64_t, int64_t, UPB_CTYPE_INT64)
+FUNCS(uint32, uint32, uint32_t, uint32_t, UPB_CTYPE_UINT32)
+FUNCS(uint64, uint64, uint64_t, uint64_t, UPB_CTYPE_UINT64)
+FUNCS(bool, _bool, bool, bool, UPB_CTYPE_BOOL)
+FUNCS(cstr, cstr, char*, uintptr_t, UPB_CTYPE_CSTR)
+FUNCS(ptr, ptr, void*, uintptr_t, UPB_CTYPE_PTR)
+FUNCS(constptr, constptr, const void*, uintptr_t, UPB_CTYPE_CONSTPTR)
+FUNCS(fptr, fptr, upb_func*, uintptr_t, UPB_CTYPE_FPTR)
#undef FUNCS
@@ -183,7 +187,7 @@ UPB_INLINE char *upb_tabstr(upb_tabkey key, uint32_t *len) {
* This separate definition is necessary because in C++, UINTPTR_MAX isn't
* reliably available. */
typedef struct {
- upb_msgval val;
+ uint64_t val;
} upb_tabval;
#else
@@ -214,7 +218,7 @@ typedef union {
} staticinit;
/* The normal accessor that we use for everything at runtime. */
- upb_msgval val;
+ uint64_t val;
} upb_tabval;
#ifdef UPB_PTR_IS_64BITS
@@ -348,7 +352,7 @@ static const upb_tabent *upb_getentry(const upb_table *t, uint32_t hash) {
}
UPB_INLINE bool upb_arrhas(upb_tabval key) {
- return key.val.u64 != (uint64_t)-1;
+ return key.val != (uint64_t)-1;
}
/* Initialize and uninitialize a table, respectively. If memory allocation
@@ -585,6 +589,9 @@ void upb_inttable_iter_setdone(upb_inttable_iter *i);
bool upb_inttable_iter_isequal(const upb_inttable_iter *i1,
const upb_inttable_iter *i2);
-UPB_END_EXTERN_C
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
#endif /* UPB_TABLE_H_ */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback