From f49f7f94c10de1ab39bd045e4ff6bb281541b51f Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 22 Dec 2009 17:08:14 -0800 Subject: More progress, upb_data and upb_def compile (but are incomplete). --- src/upb_def.h | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/upb_def.h') diff --git a/src/upb_def.h b/src/upb_def.h index 87c2be8..e8c7548 100644 --- a/src/upb_def.h +++ b/src/upb_def.h @@ -26,6 +26,7 @@ #ifndef UPB_DEF_H_ #define UPB_DEF_H_ +#include "upb_data.h" #include "upb_atomic.h" #include "upb_table.h" @@ -53,7 +54,7 @@ enum upb_def_type { typedef int8_t upb_def_type_t; struct upb_def { - struct upb_string *fqname; // Fully qualified. + upb_string *fqname; // Fully qualified. upb_atomic_refcount_t refcount; upb_def_type_t type; @@ -121,7 +122,7 @@ struct upb_fielddef { upb_field_type_t type; upb_label_t label; upb_field_number_t number; - struct upb_string *name; + upb_string *name; // These are set only when this fielddef is part of a msgdef. uint32_t byte_offset; // Where in a upb_msg to find the data. @@ -205,9 +206,9 @@ INLINE struct upb_fielddef *upb_msg_itof(struct upb_msgdef *m, uint32_t num) { } INLINE struct upb_fielddef *upb_msg_ntof(struct upb_msgdef *m, - struct upb_string *name) { + upb_string *name) { struct upb_ntof_ent *e; - e = (struct upb_ntof_ent*) upb_strtable_lookup(&m->ntof, name); + e = (struct upb_ntof_ent*)upb_strtable_lookup(&m->ntof, name); return e ? e->f : NULL; } @@ -222,9 +223,9 @@ struct upb_enumdef { typedef int32_t upb_enumval_t; // Lookups from name to integer and vice-versa. -bool upb_enumdef_ntoi(struct upb_enumdef *e, struct upb_string *name, +bool upb_enumdef_ntoi(struct upb_enumdef *e, upb_string *name, upb_enumval_t *num); -struct upb_string *upb_enumdef_iton(struct upb_enumdef *e, upb_enumval_t num); +upb_string *upb_enumdef_iton(struct upb_enumdef *e, upb_enumval_t num); // Iteration over name/value pairs. The order is undefined. // struct upb_enumd_iter i; @@ -234,7 +235,7 @@ struct upb_string *upb_enumdef_iton(struct upb_enumdef *e, upb_enumval_t num); struct upb_enum_iter { struct upb_enumdef *e; void *state; // Internal iteration state. - struct upb_string *name; + upb_string *name; upb_enumval_t val; }; void upb_enum_begin(struct upb_enum_iter *iter, struct upb_enumdef *e); @@ -278,14 +279,12 @@ INLINE void upb_symtab_unref(struct upb_symtab *s) { // // If a def is found, the caller owns one ref on the returned def. Otherwise // returns NULL. -struct upb_def *upb_symtab_resolve(struct upb_symtab *s, - struct upb_string *base, - struct upb_string *symbol); +struct upb_def *upb_symtab_resolve(struct upb_symtab *s, upb_string *base, + upb_string *symbol); // Find an entry in the symbol table with this exact name. If a def is found, // the caller owns one ref on the returned def. Otherwise returns NULL. -struct upb_def *upb_symtab_lookup(struct upb_symtab *s, - struct upb_string *sym); +struct upb_def *upb_symtab_lookup(struct upb_symtab *s, upb_string *sym); // Gets an array of pointers to all currently active defs in this symtab. The // caller owns the returned array (which is of length *count) as well as a ref @@ -299,7 +298,7 @@ struct upb_def **upb_symtab_getdefs(struct upb_symtab *s, int *count, // defined in desc). desc may not attempt to define any names that are already // defined in this symtab. Caller retains ownership of desc. status indicates // whether the operation was successful or not, and the error message (if any). -void upb_symtab_add_desc(struct upb_symtab *s, struct upb_string *desc, +void upb_symtab_add_desc(struct upb_symtab *s, upb_string *desc, struct upb_status *status); #ifdef __cplusplus -- cgit v1.2.3