From aecbfe42243ccd06425f021df6fe8d8d65974db7 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Fri, 3 Jul 2009 11:50:13 -0700 Subject: Moved upb_enum to a proper C file, updated upb_inlinedefs. --- upb_enum.h | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'upb_enum.h') diff --git a/upb_enum.h b/upb_enum.h index 2c4010b..9fea3a4 100644 --- a/upb_enum.h +++ b/upb_enum.h @@ -34,27 +34,8 @@ struct upb_enum_iton_entry { /* Initializes and frees an enum, respectively. Caller retains ownership of * ed, but it must outlive e. */ -INLINE void upb_enum_init(struct upb_enum *e, - struct google_protobuf_EnumDescriptorProto *ed) { - int num_values = ed->set_flags.has.value ? ed->value->len : 0; - e->descriptor = ed; - upb_strtable_init(&e->nametoint, num_values, sizeof(struct upb_enum_ntoi_entry)); - upb_inttable_init(&e->inttoname, num_values, sizeof(struct upb_enum_iton_entry)); - - for(int i = 0; i < num_values; i++) { - google_protobuf_EnumValueDescriptorProto *value = ed->value->elements[i]; - struct upb_enum_ntoi_entry ntoi_entry = {.e = {.key = *value->name}, - .value = value->number}; - struct upb_enum_iton_entry iton_entry = {.e = {.key = value->number}, - .string = value->name}; - upb_strtable_insert(&e->nametoint, &ntoi_entry.e); - upb_inttable_insert(&e->inttoname, &iton_entry.e); - } -} - -INLINE void upb_enum_free(struct upb_enum *e) { - upb_strtable_free(&e->nametoint); - upb_inttable_free(&e->inttoname); -} +void upb_enum_init(struct upb_enum *e, + struct google_protobuf_EnumDescriptorProto *ed); +void upb_enum_free(struct upb_enum *e); #endif /* UPB_ENUM_H_ */ -- cgit v1.2.3