summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-07-07 19:51:53 -0700
committerJoshua Haberman <joshua@reverberate.org>2009-07-07 19:51:53 -0700
commitb2bbafb67457835c4cf9061610ea9549740669c2 (patch)
treefaac999c7dc86737c97d585c7826ae6c5799da90
parentd7b666ecf47f7f5269ad5b7f826bca98f7350746 (diff)
Header file changes for C++ compatibility.
-rw-r--r--upb_context.h4
-rw-r--r--upb_msg.h16
-rw-r--r--upb_string.h1
3 files changed, 12 insertions, 9 deletions
diff --git a/upb_context.h b/upb_context.h
index ffff214..4ddaed6 100644
--- a/upb_context.h
+++ b/upb_context.h
@@ -73,12 +73,12 @@ struct upb_symtab_entry *upb_context_lookup(struct upb_context *c,
struct upb_string *symbol);
INLINE struct upb_symtab_entry *upb_context_symbegin(struct upb_context *c) {
- return upb_strtable_begin(&c->symtab);
+ return (struct upb_symtab_entry*)upb_strtable_begin(&c->symtab);
}
INLINE struct upb_symtab_entry *upb_context_symnext(
struct upb_context *c, struct upb_symtab_entry *cur) {
- return upb_strtable_next(&c->symtab, &cur->e);
+ return (struct upb_symtab_entry*)upb_strtable_next(&c->symtab, &cur->e);
}
/* Adding symbols. ************************************************************/
diff --git a/upb_msg.h b/upb_msg.h
index e06fa6e..8910505 100644
--- a/upb_msg.h
+++ b/upb_msg.h
@@ -176,14 +176,16 @@ void upb_msg_ref(struct upb_msg *m, struct upb_msg_field *f, union upb_symbol_re
* possible. These return NULL if no such field is found. */
INLINE struct upb_msg_field *upb_msg_fieldbynum(struct upb_msg *m,
uint32_t number) {
- struct upb_fieldsbynum_entry *e = upb_inttable_lookup(
- &m->fields_by_num, number, sizeof(struct upb_fieldsbynum_entry));
+ struct upb_fieldsbynum_entry *e =
+ (struct upb_fieldsbynum_entry*)upb_inttable_lookup(
+ &m->fields_by_num, number, sizeof(struct upb_fieldsbynum_entry));
return e ? &e->f : NULL;
}
INLINE struct upb_msg_field *upb_msg_fieldbyname(struct upb_msg *m,
struct upb_string *name) {
struct upb_fieldsbyname_entry *e =
- upb_strtable_lookup(&m->fields_by_name, name);
+ (struct upb_fieldsbyname_entry*)upb_strtable_lookup(
+ &m->fields_by_name, name);
return e ? &e->f : NULL;
}
@@ -236,7 +238,8 @@ INLINE void upb_msg_clear(void *s, struct upb_msg *m)
/* Returns a pointer to a specific field in a message. */
INLINE union upb_value_ptr upb_msg_getptr(void *data, struct upb_msg_field *f) {
- union upb_value_ptr p = {._void = ((char*)data + f->byte_offset)};
+ union upb_value_ptr p;
+ p._void = ((char*)data + f->byte_offset);
return p;
}
@@ -253,9 +256,8 @@ struct upb_array {
INLINE union upb_value_ptr upb_array_getelementptr(
struct upb_array *arr, uint32_t n, upb_field_type_t type)
{
- union upb_value_ptr ptr = {
- ._void = ((char*)arr->elements._void + n*upb_type_info[type].size)
- };
+ union upb_value_ptr ptr;
+ ptr._void = (void*)((char*)arr->elements._void + n*upb_type_info[type].size);
return ptr;
}
diff --git a/upb_string.h b/upb_string.h
index 44bc653..7a05811 100644
--- a/upb_string.h
+++ b/upb_string.h
@@ -65,6 +65,7 @@ bool upb_strreadfile(const char *filename, struct upb_string *data);
/* Allows defining upb_strings as literals, ie:
* struct upb_string str = UPB_STRLIT("Hello, World!\n");
+ * Doesn't work with C++ due to lack of struct initializer syntax.
*/
#define UPB_STRLIT(strlit) {.ptr=strlit, .byte_len=sizeof(strlit)-1}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback