Header file changes for C++ compatibility.

pull/13171/head
Joshua Haberman 16 years ago
parent d7b666ecf4
commit b2bbafb674
  1. 4
      upb_context.h
  2. 16
      upb_msg.h
  3. 1
      upb_string.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. ************************************************************/

@ -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;
}

@ -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}

Loading…
Cancel
Save