summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-11-14 15:49:21 -0800
committerJoshua Haberman <joshua@reverberate.org>2009-11-14 15:49:21 -0800
commit7cde43ea0abf2022a0c800c7af1d5f1ec2033bea (patch)
tree22961315d9b00831a0384e9f1fc0f88b8b76aa6e /src
parente252432a4176b6524e8c064673459e947ba11cb7 (diff)
Renamed upb_msg_fielddef -> upb_fielddef, upb_enum -> upb_enumdef.
Diffstat (limited to 'src')
-rw-r--r--src/upb.h2
-rw-r--r--src/upb_array.h4
-rw-r--r--src/upb_context.c6
-rw-r--r--src/upb_def.c22
-rw-r--r--src/upb_def.h56
-rw-r--r--src/upb_inlinedefs.c2
-rw-r--r--src/upb_mm.c14
-rw-r--r--src/upb_mm.h12
-rw-r--r--src/upb_msg.c22
-rw-r--r--src/upb_msg.h8
-rw-r--r--src/upb_struct.h8
-rw-r--r--src/upb_text.c6
12 files changed, 82 insertions, 80 deletions
diff --git a/src/upb.h b/src/upb.h
index 9ad141d..e8ec001 100644
--- a/src/upb.h
+++ b/src/upb.h
@@ -224,7 +224,7 @@ INLINE void upb_value_write(union upb_value_ptr ptr, union upb_value val,
// All the different definitions that can occur in .proto files.
union upb_symbol_ref {
struct upb_msgdef *msg;
- struct upb_enum *_enum;
+ struct upb_enumdef *_enum;
struct upb_svc *svc;
};
diff --git a/src/upb_array.h b/src/upb_array.h
index 577cbd4..70923b6 100644
--- a/src/upb_array.h
+++ b/src/upb_array.h
@@ -23,7 +23,7 @@
#define UPB_ARRAY_H_
#include <stdlib.h>
-#include "upb_msg.h" /* Because we use upb_msg_fielddef */
+#include "upb_def.h" /* Because we use upb_fielddef */
#ifdef __cplusplus
extern "C" {
@@ -43,7 +43,7 @@ INLINE union upb_value_ptr upb_array_getelementptr(struct upb_array *arr,
/* Allocation/Deallocation/Resizing. ******************************************/
-INLINE struct upb_array *upb_array_new(struct upb_msg_fielddef *f)
+INLINE struct upb_array *upb_array_new(struct upb_fielddef *f)
{
struct upb_array *arr = (struct upb_array*)malloc(sizeof(*arr));
upb_mmhead_init(&arr->mmhead);
diff --git a/src/upb_context.c b/src/upb_context.c
index 2ac14c6..2d558d9 100644
--- a/src/upb_context.c
+++ b/src/upb_context.c
@@ -57,7 +57,7 @@ static void free_symtab(struct upb_strtable *t)
for(; e; e = upb_strtable_next(t, &e->e)) {
switch(e->type) {
case UPB_SYM_MESSAGE: upb_msgdef_free(e->ref.msg); break;
- case UPB_SYM_ENUM: upb_enum_free(e->ref._enum); break;
+ case UPB_SYM_ENUM: upb_enumdef_free(e->ref._enum); break;
default: break; /* TODO */
}
free(e->ref.msg); /* The pointer is the same for all. */
@@ -211,7 +211,7 @@ static void insert_enum(struct upb_strtable *t,
e.e.key = fqname;
e.type = UPB_SYM_ENUM;
e.ref._enum = malloc(sizeof(*e.ref._enum));
- upb_enum_init(e.ref._enum, ed, c);
+ upb_enumdef_init(e.ref._enum, ed, c);
upb_strtable_insert(t, &e.e);
}
@@ -291,7 +291,7 @@ void addfd(struct upb_strtable *addto, struct upb_strtable *existingdefs,
if(e->type == UPB_SYM_MESSAGE) {
struct upb_msgdef *m = e->ref.msg;
for(unsigned int i = 0; i < m->num_fields; i++) {
- struct upb_msg_fielddef *f = &m->fields[i];
+ struct upb_fielddef *f = &m->fields[i];
google_protobuf_FieldDescriptorProto *fd = m->field_descriptors[i];
union upb_symbol_ref ref;
if(fd->type == GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_MESSAGE ||
diff --git a/src/upb_def.c b/src/upb_def.c
index 5450f5f..00a0610 100644
--- a/src/upb_def.c
+++ b/src/upb_def.c
@@ -66,7 +66,7 @@ void upb_msgdef_init(struct upb_msgdef *m, google_protobuf_DescriptorProto *d,
size_t max_align = 0;
for(unsigned int i = 0; i < m->num_fields; i++) {
- struct upb_msg_fielddef *f = &m->fields[i];
+ struct upb_fielddef *f = &m->fields[i];
google_protobuf_FieldDescriptorProto *fd = m->field_descriptors[i];
struct upb_type_info *type_info = &upb_type_info[fd->type];
@@ -103,7 +103,7 @@ void upb_msgdef_free(struct upb_msgdef *m)
free(m->field_descriptors);
}
-void upb_msgdef_setref(struct upb_msgdef *m, struct upb_msg_fielddef *f,
+void upb_msgdef_setref(struct upb_msgdef *m, struct upb_fielddef *f,
union upb_symbol_ref ref) {
struct google_protobuf_FieldDescriptorProto *d =
upb_msg_field_descriptor(f, m);
@@ -118,28 +118,30 @@ void upb_msgdef_setref(struct upb_msgdef *m, struct upb_msg_fielddef *f,
}
-void upb_enum_init(struct upb_enum *e,
+void upb_enumdef_init(struct upb_enumdef *e,
struct google_protobuf_EnumDescriptorProto *ed,
struct upb_context *c) {
int num_values = ed->set_flags.has.value ? ed->value->len : 0;
e->descriptor = ed;
e->context = c;
upb_atomic_refcount_init(&e->refcount, 0);
- 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));
+ upb_strtable_init(&e->nametoint, num_values,
+ sizeof(struct upb_enumdef_ntoi_entry));
+ upb_inttable_init(&e->inttoname, num_values,
+ sizeof(struct upb_enumdef_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};
+ struct upb_enumdef_ntoi_entry ntoi_entry = {.e = {.key = *value->name},
+ .value = value->number};
+ struct upb_enumdef_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);
}
}
-void upb_enum_free(struct upb_enum *e) {
+void upb_enumdef_free(struct upb_enumdef *e) {
upb_strtable_free(&e->nametoint);
upb_inttable_free(&e->inttoname);
}
diff --git a/src/upb_def.h b/src/upb_def.h
index a5d6d4c..8cbaab6 100644
--- a/src/upb_def.h
+++ b/src/upb_def.h
@@ -5,8 +5,8 @@
*
* Provides definitions of .proto constructs:
* - upb_msgdef: describes a "message" construct.
- * - upb_msg_fielddef: describes a message field.
- * - upb_enum: describes an enum.
+ * - upb_fielddef: describes a message field.
+ * - upb_enumdef: describes an enum.
* (TODO: descriptions of extensions and services).
*
* This file contains routines for creating and manipulating the definitions
@@ -25,7 +25,7 @@ extern "C" {
/* Message definition. ********************************************************/
-struct upb_msg_fielddef;
+struct upb_fielddef;
struct upb_context;
/* Structure that describes a single .proto message type. */
struct upb_msgdef {
@@ -39,7 +39,7 @@ struct upb_msgdef {
uint32_t num_required_fields; /* Required fields have the lowest set bytemasks. */
struct upb_inttable fields_by_num;
struct upb_strtable fields_by_name;
- struct upb_msg_fielddef *fields;
+ struct upb_fielddef *fields;
struct google_protobuf_FieldDescriptorProto **field_descriptors;
};
@@ -48,7 +48,7 @@ struct upb_msgdef {
* because copies of this struct are in the hash table that is read in the
* critical path of parsing. Minimizing the size of this struct increases
* cache-friendliness. */
-struct upb_msg_fielddef {
+struct upb_fielddef {
union upb_symbol_ref ref;
uint32_t byte_offset; /* Where to find the data. */
uint16_t field_index; /* Indexes upb_msgdef.fields and indicates set bit */
@@ -56,26 +56,26 @@ struct upb_msg_fielddef {
upb_label_t label;
};
-INLINE bool upb_issubmsg(struct upb_msg_fielddef *f) {
+INLINE bool upb_issubmsg(struct upb_fielddef *f) {
return upb_issubmsgtype(f->type);
}
-INLINE bool upb_isstring(struct upb_msg_fielddef *f) {
+INLINE bool upb_isstring(struct upb_fielddef *f) {
return upb_isstringtype(f->type);
}
-INLINE bool upb_isarray(struct upb_msg_fielddef *f) {
+INLINE bool upb_isarray(struct upb_fielddef *f) {
return f->label == GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_REPEATED;
}
-INLINE bool upb_field_ismm(struct upb_msg_fielddef *f) {
+INLINE bool upb_field_ismm(struct upb_fielddef *f) {
return upb_isarray(f) || upb_isstring(f) || upb_issubmsg(f);
}
-INLINE bool upb_elem_ismm(struct upb_msg_fielddef *f) {
+INLINE bool upb_elem_ismm(struct upb_fielddef *f) {
return upb_isstring(f) || upb_issubmsg(f);
}
/* Defined iff upb_field_ismm(f). */
-INLINE upb_mm_ptrtype upb_field_ptrtype(struct upb_msg_fielddef *f) {
+INLINE upb_mm_ptrtype upb_field_ptrtype(struct upb_fielddef *f) {
if(upb_isarray(f)) return UPB_MM_ARR_REF;
else if(upb_isstring(f)) return UPB_MM_STR_REF;
else if(upb_issubmsg(f)) return UPB_MM_MSG_REF;
@@ -83,15 +83,15 @@ INLINE upb_mm_ptrtype upb_field_ptrtype(struct upb_msg_fielddef *f) {
}
/* Defined iff upb_elem_ismm(f). */
-INLINE upb_mm_ptrtype upb_elem_ptrtype(struct upb_msg_fielddef *f) {
+INLINE upb_mm_ptrtype upb_elem_ptrtype(struct upb_fielddef *f) {
if(upb_isstring(f)) return UPB_MM_STR_REF;
else if(upb_issubmsg(f)) return UPB_MM_MSG_REF;
else return -1;
}
-/* Can be used to retrieve a field descriptor given the upb_msg_fielddef. */
+/* Can be used to retrieve a field descriptor given the upb_fielddef. */
INLINE struct google_protobuf_FieldDescriptorProto *upb_msg_field_descriptor(
- struct upb_msg_fielddef *f, struct upb_msgdef *m) {
+ struct upb_fielddef *f, struct upb_msgdef *m) {
return m->field_descriptors[f->field_index];
}
@@ -104,18 +104,18 @@ INLINE struct google_protobuf_FieldDescriptorProto *upb_msg_field_descriptor(
struct upb_fieldsbynum_entry {
struct upb_inttable_entry e;
- struct upb_msg_fielddef f;
+ struct upb_fielddef f;
};
struct upb_fieldsbyname_entry {
struct upb_strtable_entry e;
- struct upb_msg_fielddef f;
+ struct upb_fielddef f;
};
/* Looks up a field by name or number. While these are written to be as fast
* as possible, it will still be faster to cache the results of this lookup if
* possible. These return NULL if no such field is found. */
-INLINE struct upb_msg_fielddef *upb_msg_fieldbynum(struct upb_msgdef *m,
+INLINE struct upb_fielddef *upb_msg_fieldbynum(struct upb_msgdef *m,
uint32_t number) {
struct upb_fieldsbynum_entry *e =
(struct upb_fieldsbynum_entry*)upb_inttable_fast_lookup(
@@ -123,7 +123,7 @@ INLINE struct upb_msg_fielddef *upb_msg_fieldbynum(struct upb_msgdef *m,
return e ? &e->f : NULL;
}
-INLINE struct upb_msg_fielddef *upb_msg_fieldbyname(struct upb_msgdef *m,
+INLINE struct upb_fielddef *upb_msg_fieldbyname(struct upb_msgdef *m,
struct upb_string *name) {
struct upb_fieldsbyname_entry *e =
(struct upb_fieldsbyname_entry*)upb_strtable_lookup(
@@ -133,7 +133,7 @@ INLINE struct upb_msg_fielddef *upb_msg_fieldbyname(struct upb_msgdef *m,
/* Enums. *********************************************************************/
-struct upb_enum {
+struct upb_enumdef {
upb_atomic_refcount_t refcount;
struct upb_context *context;
struct google_protobuf_EnumDescriptorProto *descriptor;
@@ -141,22 +141,22 @@ struct upb_enum {
struct upb_inttable inttoname;
};
-struct upb_enum_ntoi_entry {
+struct upb_enumdef_ntoi_entry {
struct upb_strtable_entry e;
uint32_t value;
};
-struct upb_enum_iton_entry {
+struct upb_enumdef_iton_entry {
struct upb_inttable_entry e;
struct upb_string *string;
};
/* Initializes and frees an enum, respectively. Caller retains ownership of
* ed, but it must outlive e. */
-void upb_enum_init(struct upb_enum *e,
- struct google_protobuf_EnumDescriptorProto *ed,
- struct upb_context *c);
-void upb_enum_free(struct upb_enum *e);
+void upb_enumdef_init(struct upb_enumdef *e,
+ struct google_protobuf_EnumDescriptorProto *ed,
+ struct upb_context *c);
+void upb_enumdef_free(struct upb_enumdef *e);
/* Internal functions. ********************************************************/
@@ -166,7 +166,7 @@ void upb_enum_free(struct upb_enum *e);
*
* Caller retains ownership of d, but the msg will contain references to it, so
* it must outlive the msg. Note that init does not resolve
- * upb_msg_fielddef.ref the caller should do that post-initialization by
+ * upb_fielddef.ref the caller should do that post-initialization by
* calling upb_msg_ref() below.
*
* fqname indicates the fully-qualified name of this message. Ownership of
@@ -189,10 +189,10 @@ void upb_msgdef_sortfds(struct google_protobuf_FieldDescriptorProto **fds,
size_t num);
/* Clients use this function on a previously initialized upb_msgdef to resolve
- * the "ref" field in the upb_msg_fielddef. Since messages can refer to each
+ * the "ref" field in the upb_fielddef. Since messages can refer to each
* other in mutually-recursive ways, this step must be separated from
* initialization. */
-void upb_msgdef_setref(struct upb_msgdef *m, struct upb_msg_fielddef *f,
+void upb_msgdef_setref(struct upb_msgdef *m, struct upb_fielddef *f,
union upb_symbol_ref ref);
#ifdef __cplusplus
diff --git a/src/upb_inlinedefs.c b/src/upb_inlinedefs.c
index 7a55e06..7100849 100644
--- a/src/upb_inlinedefs.c
+++ b/src/upb_inlinedefs.c
@@ -14,7 +14,7 @@
#define INLINE
#include "upb_array.h"
#include "upb_context.h"
-#include "upb_enum.h"
+#include "upb_def.h"
#include "upb_mm.h"
#include "upb_msg.h"
#include "upb_parse.h"
diff --git a/src/upb_mm.c b/src/upb_mm.c
index 6f9a028..212c2a2 100644
--- a/src/upb_mm.c
+++ b/src/upb_mm.c
@@ -20,7 +20,7 @@ static void upb_mm_destroy(union upb_value_ptr p, upb_mm_ptrtype type)
void upb_msg_destroy(struct upb_msg *msg) {
uint32_t i;
for(i = 0; i < msg->def->num_fields; i++) {
- struct upb_msg_fielddef *f = &msg->def->fields[i];
+ struct upb_fielddef *f = &msg->def->fields[i];
if(!upb_msg_isset(msg, f) || !upb_field_ismm(f)) continue;
upb_mm_destroy(upb_msg_getptr(msg, f), upb_field_ptrtype(f));
}
@@ -42,7 +42,7 @@ void upb_array_destroy(struct upb_array *arr)
}
static union upb_mmptr upb_mm_newptr(upb_mm_ptrtype type,
- struct upb_msg_fielddef *f)
+ struct upb_fielddef *f)
{
union upb_mmptr p = {NULL};
switch(type) {
@@ -96,7 +96,7 @@ struct upb_mm_ref *upb_mm_newmsg_ref(struct upb_msgdef *def, struct upb_mm *mm)
}
struct upb_mm_ref *upb_mm_getfieldref(struct upb_mm_ref *msgref,
- struct upb_msg_fielddef *f,
+ struct upb_fielddef *f,
bool *refcreated)
{
assert(upb_field_ismm(f));
@@ -121,7 +121,7 @@ struct upb_mm_ref *upb_mm_getelemref(struct upb_mm_ref *arrref, upb_arraylen_t i
bool *refcreated)
{
struct upb_array *arr = arrref->p.arr;
- struct upb_msg_fielddef *f = arr->fielddef;
+ struct upb_fielddef *f = arr->fielddef;
assert(upb_elem_ismm(f));
assert(i < arr->len);
union upb_value_ptr p = upb_array_getelementptr(arr, i);
@@ -161,7 +161,7 @@ void upb_mm_release(struct upb_mm_ref *ref)
}
void upb_mm_msg_set(struct upb_mm_ref *from_msg_ref, struct upb_mm_ref *to_ref,
- struct upb_msg_fielddef *f)
+ struct upb_fielddef *f)
{
assert(upb_field_ismm(f));
union upb_mmptr fromval = from_msg_ref->p;
@@ -179,7 +179,7 @@ void upb_mm_msg_set(struct upb_mm_ref *from_msg_ref, struct upb_mm_ref *to_ref,
upb_mm_ref(toval, type);
}
-void upb_mm_msgclear(struct upb_mm_ref *from_msg_ref, struct upb_msg_fielddef *f)
+void upb_mm_msgclear(struct upb_mm_ref *from_msg_ref, struct upb_fielddef *f)
{
assert(upb_field_ismm(f));
union upb_mmptr fromval = from_msg_ref->p;
@@ -196,7 +196,7 @@ void upb_mm_msgclear_all(struct upb_mm_ref *from)
{
struct upb_msgdef *def = from->p.msg->def;
for(uint32_t i = 0; i < def->num_fields; i++) {
- struct upb_msg_fielddef *f = &def->fields[i];
+ struct upb_fielddef *f = &def->fields[i];
if(!upb_field_ismm(f)) continue;
upb_mm_msgclear(from, f);
}
diff --git a/src/upb_mm.h b/src/upb_mm.h
index 88cb043..2e3e082 100644
--- a/src/upb_mm.h
+++ b/src/upb_mm.h
@@ -40,7 +40,7 @@ typedef int16_t upb_mm_id;
struct upb_msg;
struct upb_array;
struct upb_string;
-struct upb_msg_fielddef;
+struct upb_fielddef;
struct upb_mm_ref;
/* Info about a mm. */
@@ -76,7 +76,7 @@ struct upb_mm_ref *upb_mm_getref(union upb_mmptr p, upb_mm_ptrtype type,
* returns it, otherwise calls the given callback to create one. 'created'
* indicates whether a new reference was created. */
struct upb_mm_ref *upb_mm_getfieldref(struct upb_mm_ref *msgref,
- struct upb_msg_fielddef *f,
+ struct upb_fielddef *f,
bool *refcreated);
/* Array len must be < i. */
struct upb_mm_ref *upb_mm_getelemref(struct upb_mm_ref *arrref, upb_arraylen_t i,
@@ -87,16 +87,16 @@ struct upb_mm_ref *upb_mm_getelemref(struct upb_mm_ref *arrref, upb_arraylen_t i
void upb_mm_release(struct upb_mm_ref *ref);
void upb_mm_msgset(struct upb_mm_ref *msg, struct upb_mm_ref *to,
- struct upb_msg_fielddef *f);
-void upb_mm_msgclear(struct upb_mm_ref *from, struct upb_msg_fielddef *f);
+ struct upb_fielddef *f);
+void upb_mm_msgclear(struct upb_mm_ref *from, struct upb_fielddef *f);
void upb_mm_msgclear_all(struct upb_mm_ref *from);
void upb_mm_arrset(struct upb_mm_ref *from, struct upb_mm_ref *to, uint32_t i);
/* Defined iff upb_field_ismm(f). */
-INLINE upb_mm_ptrtype upb_field_ptrtype(struct upb_msg_fielddef *f);
+INLINE upb_mm_ptrtype upb_field_ptrtype(struct upb_fielddef *f);
/* Defined iff upb_elem_ismm(f). */
-INLINE upb_mm_ptrtype upb_elem_ptrtype(struct upb_msg_fielddef *f);
+INLINE upb_mm_ptrtype upb_elem_ptrtype(struct upb_fielddef *f);
INLINE void upb_mm_unref(union upb_mmptr p, upb_mm_ptrtype type);
diff --git a/src/upb_msg.c b/src/upb_msg.c
index 4c78063..926eda0 100644
--- a/src/upb_msg.c
+++ b/src/upb_msg.c
@@ -30,7 +30,7 @@ struct upb_msgparser {
* should be stored, taking into account whether f is an array that may need to
* be allocated or resized. */
static union upb_value_ptr get_value_ptr(struct upb_msg *msg,
- struct upb_msg_fielddef *f)
+ struct upb_fielddef *f)
{
union upb_value_ptr p = upb_msg_getptr(msg, f);
if(upb_isarray(f)) {
@@ -54,7 +54,7 @@ static upb_field_type_t tag_cb(void *udata, struct upb_tag *tag,
void **user_field_desc)
{
struct upb_msgparser *mp = udata;
- struct upb_msg_fielddef *f =
+ struct upb_fielddef *f =
upb_msg_fieldbynum(mp->top->msg->def, tag->field_number);
if(!f || !upb_check_type(tag->wire_type, f->type))
return 0; /* Skip unknown or fields of the wrong type. */
@@ -66,7 +66,7 @@ static void *value_cb(void *udata, uint8_t *buf, uint8_t *end,
void *user_field_desc, struct upb_status *status)
{
struct upb_msgparser *mp = udata;
- struct upb_msg_fielddef *f = user_field_desc;
+ struct upb_fielddef *f = user_field_desc;
struct upb_msg *msg = mp->top->msg;
union upb_value_ptr p = get_value_ptr(msg, f);
upb_msg_set(msg, f);
@@ -78,7 +78,7 @@ static void str_cb(void *udata, uint8_t *str,
void *udesc)
{
struct upb_msgparser *mp = udata;
- struct upb_msg_fielddef *f = udesc;
+ struct upb_fielddef *f = udesc;
struct upb_msg *msg = mp->top->msg;
union upb_value_ptr p = get_value_ptr(msg, f);
upb_msg_set(msg, f);
@@ -103,7 +103,7 @@ static void str_cb(void *udata, uint8_t *str,
static void start_cb(void *udata, void *user_field_desc)
{
struct upb_msgparser *mp = udata;
- struct upb_msg_fielddef *f = user_field_desc;
+ struct upb_fielddef *f = user_field_desc;
struct upb_msg *oldmsg = mp->top->msg;
union upb_value_ptr p = get_value_ptr(oldmsg, f);
@@ -185,7 +185,7 @@ static size_t get_msgsize(struct upb_msgsizes *sizes, struct upb_msg *m);
/* Returns a size of a value as it will be serialized. Does *not* include
* the size of the tag -- that is already accounted for. */
static size_t get_valuesize(struct upb_msgsizes *sizes, union upb_value_ptr p,
- struct upb_msg_fielddef *f,
+ struct upb_fielddef *f,
google_protobuf_FieldDescriptorProto *fd)
{
switch(f->type) {
@@ -227,7 +227,7 @@ static size_t get_msgsize(struct upb_msgsizes *sizes, struct upb_msg *m)
size_t size = 0;
/* We iterate over fields and arrays in reverse order. */
for(int32_t i = m->def->num_fields - 1; i >= 0; i--) {
- struct upb_msg_fielddef *f = &m->def->fields[i];
+ struct upb_fielddef *f = &m->def->fields[i];
google_protobuf_FieldDescriptorProto *fd = upb_msg_field_descriptor(f, m->def);
if(!upb_msg_isset(m, f)) continue;
union upb_value_ptr p = upb_msg_getptr(m, f);
@@ -306,7 +306,7 @@ void upb_msg_serialize_init(struct upb_msg_serialize_state *s, struct upb_msg *m
#if 0
static uint8_t *serialize_tag(uint8_t *buf, uint8_t *end,
- struct upb_msg_fielddef *f,
+ struct upb_fielddef *f,
struct upb_status *status)
{
/* TODO: need to have the field number also. */
@@ -331,7 +331,7 @@ size_t upb_msg_serialize(struct upb_msg_serialize_state *s,
struct upb_msgdef *m = s->top->m;
while(buf < end) {
- struct upb_msg_fielddef *f = &m->fields[i];
+ struct upb_fielddef *f = &m->fields[i];
//union upb_value_ptr p = upb_msg_getptr(msg, f);
buf = serialize_tag(buf, end, f, status);
if(f->type == GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_MESSAGE) {
@@ -382,7 +382,7 @@ bool upb_value_eql(union upb_value_ptr p1, union upb_value_ptr p2,
}
bool upb_array_eql(struct upb_array *arr1, struct upb_array *arr2,
- struct upb_msg_fielddef *f, bool recursive)
+ struct upb_fielddef *f, bool recursive)
{
if(arr1->len != arr2->len) return false;
if(upb_issubmsg(f)) {
@@ -416,7 +416,7 @@ bool upb_msg_eql(struct upb_msg *msg1, struct upb_msg *msg2, bool recursive)
* padding) and memcmp the masked messages. */
for(uint32_t i = 0; i < m->num_fields; i++) {
- struct upb_msg_fielddef *f = &m->fields[i];
+ struct upb_fielddef *f = &m->fields[i];
bool msg1set = upb_msg_isset(msg1, f);
bool msg2set = upb_msg_isset(msg2, f);
if(msg1set != msg2set) return false;
diff --git a/src/upb_msg.h b/src/upb_msg.h
index 552e2dc..4ca1e2a 100644
--- a/src/upb_msg.h
+++ b/src/upb_msg.h
@@ -70,7 +70,7 @@ INLINE struct upb_msg *upb_msg_new(struct upb_msgdef *md) {
/* Returns a pointer to a specific field in a message. */
INLINE union upb_value_ptr upb_msg_getptr(struct upb_msg *msg,
- struct upb_msg_fielddef *f) {
+ struct upb_fielddef *f) {
union upb_value_ptr p;
p._void = &msg->data[f->byte_offset];
return p;
@@ -95,19 +95,19 @@ INLINE uint8_t upb_isset_mask(uint32_t field_index) {
}
/* Returns true if the given field is set, false otherwise. */
-INLINE void upb_msg_set(struct upb_msg *msg, struct upb_msg_fielddef *f)
+INLINE void upb_msg_set(struct upb_msg *msg, struct upb_fielddef *f)
{
msg->data[upb_isset_offset(f->field_index)] |= upb_isset_mask(f->field_index);
}
/* Clears the set bit for this field in the given message. */
-INLINE void upb_msg_unset(struct upb_msg *msg, struct upb_msg_fielddef *f)
+INLINE void upb_msg_unset(struct upb_msg *msg, struct upb_fielddef *f)
{
msg->data[upb_isset_offset(f->field_index)] &= ~upb_isset_mask(f->field_index);
}
/* Tests whether the given field is set. */
-INLINE bool upb_msg_isset(struct upb_msg *msg, struct upb_msg_fielddef *f)
+INLINE bool upb_msg_isset(struct upb_msg *msg, struct upb_fielddef *f)
{
return msg->data[upb_isset_offset(f->field_index)] & upb_isset_mask(f->field_index);
}
diff --git a/src/upb_struct.h b/src/upb_struct.h
index c83978f..094c207 100644
--- a/src/upb_struct.h
+++ b/src/upb_struct.h
@@ -47,7 +47,7 @@ INLINE void upb_mmhead_ref(struct upb_mmhead *head) {
/* These are all self describing. */
struct upb_msgdef;
-struct upb_msg_fielddef;
+struct upb_fielddef;
struct upb_msg {
struct upb_mmhead mmhead;
@@ -58,7 +58,7 @@ struct upb_msg {
typedef uint32_t upb_arraylen_t; /* can be at most 2**32 elements long. */
struct upb_array {
struct upb_mmhead mmhead;
- struct upb_msg_fielddef *fielddef; /* Defines the type of the array. */
+ struct upb_fielddef *fielddef; /* Defines the type of the array. */
union upb_value_ptr elements;
upb_arraylen_t len; /* Number of elements in "elements". */
upb_arraylen_t size; /* Memory we own. */
@@ -78,7 +78,7 @@ struct upb_string {
#define UPB_DEFINE_ARRAY_TYPE(name, type) \
struct name ## _array { \
struct upb_mmhead mmhead; \
- struct upb_msg_fielddef *fielddef; \
+ struct upb_fielddef *fielddef; \
type elements; \
upb_arraylen_t len; \
upb_arraylen_t size; \
@@ -99,7 +99,7 @@ UPB_DEFINE_ARRAY_TYPE(upb_msg, void*)
#define UPB_DEFINE_MSG_ARRAY(msg_type) \
UPB_MSG_ARRAY(msg_type) { \
struct upb_mmhead mmhead; \
- struct upb_msg_fielddef *fielddef; \
+ struct upb_fielddef *fielddef; \
msg_type **elements; \
upb_arraylen_t len; \
upb_arraylen_t size; \
diff --git a/src/upb_text.c b/src/upb_text.c
index bed4b43..ade8888 100644
--- a/src/upb_text.c
+++ b/src/upb_text.c
@@ -83,7 +83,7 @@ void upb_text_pop(struct upb_text_printer *p,
}
static void printval(struct upb_text_printer *printer, union upb_value_ptr p,
- struct upb_msg_fielddef *f,
+ struct upb_fielddef *f,
google_protobuf_FieldDescriptorProto *fd,
FILE *stream);
@@ -92,7 +92,7 @@ static void printmsg(struct upb_text_printer *printer, struct upb_msg *msg,
{
struct upb_msgdef *m = msg->def;
for(uint32_t i = 0; i < m->num_fields; i++) {
- struct upb_msg_fielddef *f = &m->fields[i];
+ struct upb_fielddef *f = &m->fields[i];
google_protobuf_FieldDescriptorProto *fd = upb_msg_field_descriptor(f, m);
if(!upb_msg_isset(msg, f)) continue;
union upb_value_ptr p = upb_msg_getptr(msg, f);
@@ -109,7 +109,7 @@ static void printmsg(struct upb_text_printer *printer, struct upb_msg *msg,
}
static void printval(struct upb_text_printer *printer, union upb_value_ptr p,
- struct upb_msg_fielddef *f,
+ struct upb_fielddef *f,
google_protobuf_FieldDescriptorProto *fd,
FILE *stream)
{
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback