summaryrefslogtreecommitdiff
path: root/upb/generated_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'upb/generated_util.h')
-rw-r--r--upb/generated_util.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/upb/generated_util.h b/upb/generated_util.h
index 5d6ccb4..edd7298 100644
--- a/upb/generated_util.h
+++ b/upb/generated_util.h
@@ -7,6 +7,7 @@
#define UPB_GENERATED_UTIL_H_
#include <stdint.h>
+#include "upb/msg.h"
#include "upb/structs.int.h"
#define PTR_AT(msg, ofs, type) (type*)((const char*)msg + ofs)
@@ -15,7 +16,7 @@ UPB_INLINE const void *_upb_array_accessor(const void *msg, size_t ofs,
size_t *size) {
const upb_array *arr = *PTR_AT(msg, ofs, const upb_array*);
if (arr) {
- if (size) *size = arr->size;
+ if (size) *size = arr->len;
return arr->data;
} else {
if (size) *size = 0;
@@ -27,7 +28,7 @@ UPB_INLINE void *_upb_array_mutable_accessor(void *msg, size_t ofs,
size_t *size) {
upb_array *arr = *PTR_AT(msg, ofs, upb_array*);
if (arr) {
- if (size) *size = arr->size;
+ if (size) *size = arr->len;
return arr->data;
} else {
if (size) size = 0;
@@ -81,7 +82,7 @@ UPB_INLINE bool _upb_array_append_accessor(void *msg, size_t ofs,
}
UPB_INLINE bool _upb_has_field(const void *msg, size_t idx) {
- return (*PTR_AT(msg, idx / 8, const char) & (idx % 8)) != 0;
+ return (*PTR_AT(msg, idx / 8, const char) & (1 << (idx % 8))) != 0;
}
UPB_INLINE bool _upb_has_oneof_field(const void *msg, size_t case_ofs, int32_t num) {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback